[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[creduce-dev] Patches to update for LLVM svn API changes



Hi CReduce people,

I have two patches, one which should be applied to the llvm-svn-compatible branch, and the other which is really just the pile of autoconf and makefile hacks I had to apply to make things build with my installation of LLVM.

Please apply the first, if that's OK.

LLVM also grew a new `llvm-config --system-libs` flag set, which I had to glue onto LLVM_LDFLAGS.  That's in the second patch and should be unobjectionable.

I'm not sure what creduce should do about -Werror in LLVM's cflags.  It doesn't really make sense to take LLVM's warning flags, apply them to creduce, and then expect that to build with -Werror.  Therefore, I just tried to remove -Werror when possible.

Thanks for the awesome tool!
Reid
diff --git a/clang_delta/RemoveNestedFunction.cpp b/clang_delta/RemoveNestedFunction.cpp
index 0fc7349..c24e4da 100644
--- a/clang_delta/RemoveNestedFunction.cpp
+++ b/clang_delta/RemoveNestedFunction.cpp
@@ -251,7 +251,7 @@ bool RemoveNestedFunction::addNewTmpVariable(ASTContext &ASTCtx)
     if (!FD)
       FD = lookupFunctionDecl(DName, TheFuncDecl->getLookupParent());
     TransAssert(FD && "Cannot resolve DName!");
-    QT = FD->getResultType();
+    QT = FD->getReturnType();
     //FIXME: This is actually not quite correct, we should get the instantiated
     // type here.
     return writeNewTmpVariable(QT, VarStr);
@@ -263,7 +263,7 @@ bool RemoveNestedFunction::addNewTmpVariable(ASTContext &ASTCtx)
     const FunctionDecl *FD = lookupFunctionDecl(DName, CXXRD);
     // FIXME: try to resolve FD here
     if (FD)
-      QT = FD->getResultType();
+      QT = FD->getReturnType();
     return writeNewTmpVariable(QT, VarStr);
   }
 
@@ -297,7 +297,7 @@ bool RemoveNestedFunction::addNewTmpVariable(ASTContext &ASTCtx)
       TransAssert(Ctx && "Bad DeclContext!");
       const FunctionDecl *FD = lookupFunctionDecl(DName, Ctx);
       TransAssert(FD && "Cannot resolve DName!");
-      QT = FD->getResultType();
+      QT = FD->getReturnType();
       return writeNewTmpVariable(QT, VarStr);
     }
     
@@ -309,7 +309,7 @@ bool RemoveNestedFunction::addNewTmpVariable(ASTContext &ASTCtx)
       if (!FD) {
         return writeNewTmpVariable(QT, VarStr);
       }
-      QT = FD->getResultType();
+      QT = FD->getReturnType();
       const Type *RVTy = QT.getTypePtr();
       if (RVTy->getAs<InjectedClassNameType>()) {
         // handle cases like:
diff --git a/clang_delta/RenameCXXMethod.cpp b/clang_delta/RenameCXXMethod.cpp
index e5a47d8..7b5ff6a 100644
--- a/clang_delta/RenameCXXMethod.cpp
+++ b/clang_delta/RenameCXXMethod.cpp
@@ -638,7 +638,7 @@ const FunctionDecl* RenameCXXMethod::getFunctionDeclFromOverloadTemplate(
       return NULL;
   }
 
-  const Type *Ty = FD->getResultType().getTypePtr();
+  const Type *Ty = FD->getReturnType().getTypePtr();
   return getFunctionDeclFromType(Ty, DName);
 }
 
@@ -663,7 +663,7 @@ const FunctionDecl* RenameCXXMethod::getFunctionDeclFromReturnType(
     const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(VD);
     if (!MD)
       return NULL;
-    const Type *Ty = MD->getResultType().getTypePtr();
+    const Type *Ty = MD->getReturnType().getTypePtr();
     return getFunctionDeclFromType(Ty, DName);
   }
   else if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(CalleeExpr)) {
@@ -671,7 +671,7 @@ const FunctionDecl* RenameCXXMethod::getFunctionDeclFromReturnType(
     const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(VD);
     if (!MD)
       return NULL;
-    const Type *Ty = MD->getResultType().getTypePtr();
+    const Type *Ty = MD->getReturnType().getTypePtr();
     return getFunctionDeclFromType(Ty, DName);
   }
   else if (const OverloadExpr *OE = dyn_cast<OverloadExpr>(CalleeExpr)) {
@@ -699,7 +699,7 @@ const FunctionDecl* RenameCXXMethod::getFunctionDeclFromReturnType(
     const FunctionDecl *FD = getFunctionDecl(DE);
     if (!FD)
       return NULL;
-    const Type *Ty = FD->getResultType().getTypePtr();
+    const Type *Ty = FD->getReturnType().getTypePtr();
     // Note that it's not always true that we could get a 
     // non-null function here, e.g.:
     // template <typename T> class A {
diff --git a/clang_delta/ReturnVoid.cpp b/clang_delta/ReturnVoid.cpp
index dde8990..197cf5f 100644
--- a/clang_delta/ReturnVoid.cpp
+++ b/clang_delta/ReturnVoid.cpp
@@ -119,7 +119,7 @@ bool ReturnVoid::isNonVoidReturnFunction(FunctionDecl *FD)
   SourceLocation SLoc = TLoc.getBeginLoc();
   if (SLoc.isInvalid())
     return false;
-  QualType RVType = FD->getResultType();
+  QualType RVType = FD->getReturnType();
   return !(RVType.getTypePtr()->isVoidType());
 }
 
diff --git a/clang_delta/SimpleInliner.cpp b/clang_delta/SimpleInliner.cpp
index bffd70b..2aefb39 100644
--- a/clang_delta/SimpleInliner.cpp
+++ b/clang_delta/SimpleInliner.cpp
@@ -388,7 +388,7 @@ std::string SimpleInliner::getNewTmpName(void)
 
 void SimpleInliner::createReturnVar(void)
 {
-  const Type *FDType = CurrentFD->getResultType().getTypePtr();
+  const Type *FDType = CurrentFD->getReturnType().getTypePtr();
   const Type *CallExprType = TheCallExpr->getCallReturnType().getTypePtr();
 
   // We don't need tmp var
@@ -398,7 +398,7 @@ void SimpleInliner::createReturnVar(void)
 
   TmpVarName = getNewTmpName();
   std::string VarStr = TmpVarName;
-  CurrentFD->getResultType().getAsStringInternal(VarStr, 
+  CurrentFD->getReturnType().getAsStringInternal(VarStr, 
                                Context->getPrintingPolicy());
   VarStr += ";";
   RewriteHelper->addLocalVarToFunc(VarStr, TheCaller);
diff --git a/clang_delta/SimplifyStructUnionDecl.cpp b/clang_delta/SimplifyStructUnionDecl.cpp
index f36b1dc..90f7628 100644
--- a/clang_delta/SimplifyStructUnionDecl.cpp
+++ b/clang_delta/SimplifyStructUnionDecl.cpp
@@ -52,7 +52,7 @@ private:
 
 bool SimplifyStructUnionDeclVisitor::VisitFunctionDecl(FunctionDecl *FD)
 {
-  const Type *T = FD->getResultType().getTypePtr();
+  const Type *T = FD->getReturnType().getTypePtr();
   return ConsumerInstance->handleOneDeclarator(T);
 }
 
diff --git a/clang_delta/TransformationManager.cpp b/clang_delta/TransformationManager.cpp
index f3a3d8d..b0296b5 100644
--- a/clang_delta/TransformationManager.cpp
+++ b/clang_delta/TransformationManager.cpp
@@ -164,8 +164,8 @@ llvm::raw_ostream *TransformationManager::getOutStream()
     return &(llvm::outs());
 
   std::string Err;
-  llvm::raw_fd_ostream *Out = 
-    new llvm::raw_fd_ostream(OutputFileName.c_str(), Err);
+  llvm::raw_fd_ostream *Out = new llvm::raw_fd_ostream(
+      OutputFileName.c_str(), Err, llvm::sys::fs::F_RW);
   assert(Err.empty() && "Cannot open output file!");
   return Out;
 }
diff --git a/clang_delta/UnionToStruct.cpp b/clang_delta/UnionToStruct.cpp
index c69e173..d4647af 100644
--- a/clang_delta/UnionToStruct.cpp
+++ b/clang_delta/UnionToStruct.cpp
@@ -67,7 +67,7 @@ private:
 
 bool UnionToStructCollectionVisitor::VisitFunctionDecl(FunctionDecl *FD)
 {
-  const Type *T = FD->getResultType().getTypePtr();
+  const Type *T = FD->getReturnType().getTypePtr();
   ConsumerInstance->addOneDeclarator(FD, T);
   return true;
 }
diff --git a/clang_delta/Makefile.am b/clang_delta/Makefile.am
index f2efc7e..6530ca7 100644
--- a/clang_delta/Makefile.am
+++ b/clang_delta/Makefile.am
@@ -19,7 +19,7 @@ GIT_FLAG = -DGIT_VERSION=\"$(GIT_HASH)\"
 # Avoid the warning by making `--ldflags' and `--libs' not look like
 # linker options.
 #
-LLVMCXXFLAGS	:= $(shell "$(LLVM_CONFIG)" --cxxflags) -fno-rtti -fno-exceptions
+LLVMCXXFLAGS	:= $(shell "$(LLVM_CONFIG)" --cxxflags | sed -e 's/-Werror//') -fno-rtti -fno-exceptions
 LLVMLDFLAGS	:= $(shell "$(LLVM_CONFIG)" \--ldflags)
 LLVMINCLUDEDIR	:= $(shell "$(LLVM_CONFIG)" --includedir)
 LLVMLIBS	:= $(shell "$(LLVM_CONFIG)" \--libs)
diff --git a/clang_delta/Makefile.in b/clang_delta/Makefile.in
index 47e02c9..2f403f2 100644
--- a/clang_delta/Makefile.in
+++ b/clang_delta/Makefile.in
@@ -402,8 +402,8 @@ GIT_FLAG = -DGIT_VERSION=\"$(GIT_HASH)\"
 # Avoid the warning by making `--ldflags' and `--libs' not look like
 # linker options.
 #
-LLVMCXXFLAGS := $(shell "$(LLVM_CONFIG)" --cxxflags) -fno-rtti -fno-exceptions
-LLVMLDFLAGS := $(shell "$(LLVM_CONFIG)" \--ldflags)
+LLVMCXXFLAGS := $(shell "$(LLVM_CONFIG)" --cxxflags | sed -e 's/-Werror//') -fno-rtti -fno-exceptions
+LLVMLDFLAGS := $(shell "$(LLVM_CONFIG)" \--ldflags) $(shell "$(LLVM_CONFIG)" \--system-libs)
 LLVMINCLUDEDIR := $(shell "$(LLVM_CONFIG)" --includedir)
 LLVMLIBS := $(shell "$(LLVM_CONFIG)" \--libs)
 clang_delta_CPPFLAGS = \
diff --git a/configure b/configure
index 95005d3..0a4ef6e 100755
--- a/configure
+++ b/configure
@@ -15290,8 +15290,8 @@ x$ax_compare_version_B" | sed 's/^ *//' | sort -r | sed "s/x${ax_compare_version
   fi
 
   LLVM_BINDIR=`$LLVM_CONFIG --bindir`
-  LLVM_CPPFLAGS=`$LLVM_CONFIG --cxxflags`
-  LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags`
+  LLVM_CPPFLAGS=`$LLVM_CONFIG --cxxflags | sed -e 's/-Werror//' | sed -e 's/-pedantic//'`
+  LLVM_LDFLAGS="`$LLVM_CONFIG --ldflags` `$LLVM_CONFIG --system-libs`"
   LLVM_LIBS=`$LLVM_CONFIG --libs engine`
 
   # The output of `llvm-config --ldflags' often contains library directives