fixes lots of llvm warnings
MODIFY
llvm_mode/GNUmakefile
llvm_mode/GNUmakefile
@@ -241,7 +241,7 @@ endif
ifneq "$(LLVM_CONFIG)" ""
CLANG_CFL += -I$(shell dirname $(LLVM_CONFIG))/../include
endif
-CLANG_CPPFL = `$(LLVM_CONFIG) --cxxflags` -fno-rtti -fPIC $(CXXFLAGS)
+CLANG_CPPFL = `$(LLVM_CONFIG) --cxxflags` -fno-rtti -fPIC $(CXXFLAGS) -Wno-deprecated-declarations
CLANG_LFL = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)

MODIFY
llvm_mode/LLVMInsTrim.so.cc
llvm_mode/LLVMInsTrim.so.cc
@@ -144,7 +144,7 @@ struct InsTrim : public ModulePass {
#ifdef AFL_HAVE_VECTOR_INTRINSICS
unsigned int ngram_size = 0;
/* Decide previous location vector size (must be a power of two) */
- VectorType *PrevLocTy;
+ VectorType *PrevLocTy = NULL;
if (ngram_size_str)
if (sscanf(ngram_size_str, "%u", &ngram_size) != 1 || ngram_size < 2 ||
@@ -194,7 +194,7 @@ struct InsTrim : public ModulePass {
new GlobalVariable(M, PointerType::get(Int8Ty, 0), false,
GlobalValue::ExternalLinkage, 0, "__afl_area_ptr");
GlobalVariable *AFLPrevLoc;
- GlobalVariable *AFLContext;
+ GlobalVariable *AFLContext = NULL;
LoadInst * PrevCtx = NULL; // for CTX sensitive coverage
if (ctx_str)

MODIFY
llvm_mode/afl-clang-fast.c
llvm_mode/afl-clang-fast.c
@@ -379,7 +379,9 @@ static void edit_params(u32 argc, char **argv, char **envp) {
if (instrument_mode == INSTRUMENT_PCGUARD) {
-#if LLVM_VERSION_MAJOR >= 4
+#if LLVM_VERSION_MAJOR > 4 || \
+ (LLVM_VERSION_MAJOR == 4 && \
+ (LLVM_VERSION_MINOR > 0 || LLVM_VERSION_PATCH >= 1))
cc_params[cc_par_cnt++] =
"-fsanitize-coverage=trace-pc-guard"; // edge coverage by default
#else

MODIFY
llvm_mode/afl-ld-lto.c
llvm_mode/afl-ld-lto.c
@@ -278,7 +278,7 @@ int main(int argc, char **argv) {
if (debug) {
- (void)getcwd(thecwd, sizeof(thecwd));
+ if (getcwd(thecwd, sizeof(thecwd)) != 0) strcpy(thecwd, ".");
SAYF(cMGN "[D] " cRST "cd \"%s\";", thecwd);
for (i = 0; i < argc; i++)

MODIFY
llvm_mode/afl-llvm-common.cc
llvm_mode/afl-llvm-common.cc
@@ -260,7 +260,8 @@ void scanForDangerousFunctions(llvm::Module *M) {
if (!M) return;
-#if LLVM_VERSION_MAJOR >= 4
+#if LLVM_VERSION_MAJOR > 3 || \
+ (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 9)
for (GlobalIFunc &IF : M->ifuncs()) {
@@ -345,7 +346,6 @@ static std::string getSourceName(llvm::Function *F) {
DILocation *cDILoc = dyn_cast<DILocation>(Loc.getAsMDNode());
- unsigned int instLine = cDILoc->getLine();
StringRef instFilename = cDILoc->getFilename();
if (instFilename.str().empty()) {
@@ -353,12 +353,7 @@ static std::string getSourceName(llvm::Function *F) {
/* If the original location is empty, try using the inlined location
*/
DILocation *oDILoc = cDILoc->getInlinedAt();
- if (oDILoc) {
-
- instFilename = oDILoc->getFilename();
- instLine = oDILoc->getLine();
-
- }
+ if (oDILoc) { instFilename = oDILoc->getFilename(); }
}
@@ -371,10 +366,8 @@ static std::string getSourceName(llvm::Function *F) {
DILocation cDILoc(Loc.getAsMDNode(F->getContext()));
- unsigned int instLine = cDILoc.getLineNumber();
StringRef instFilename = cDILoc.getFilename();
- (void)instLine;
/* Continue only if we know where we actually are */
return instFilename.str();

MODIFY
llvm_mode/afl-llvm-lto-instrumentation.so.cc
llvm_mode/afl-llvm-lto-instrumentation.so.cc
@@ -596,7 +596,7 @@ bool AFLLTOPass::runOnModule(Module &M) {
do {
--i;
- BasicBlock * newBB;
+ BasicBlock * newBB = NULL;
BasicBlock * origBB = &(*InsBlocks[i]);
std::vector<BasicBlock *> Successors;
Instruction * TI = origBB->getTerminator();

MODIFY
llvm_mode/afl-llvm-pass.so.cc
llvm_mode/afl-llvm-pass.so.cc
@@ -194,7 +194,7 @@ bool AFLCoverage::runOnModule(Module &M) {
#ifdef AFL_HAVE_VECTOR_INTRINSICS
/* Decide previous location vector size (must be a power of two) */
- VectorType *PrevLocTy;
+ VectorType *PrevLocTy = NULL;
if (ngram_size_str)
if (sscanf(ngram_size_str, "%u", &ngram_size) != 1 || ngram_size < 2 ||
@@ -236,7 +236,7 @@ bool AFLCoverage::runOnModule(Module &M) {
new GlobalVariable(M, PointerType::get(Int8Ty, 0), false,
GlobalValue::ExternalLinkage, 0, "__afl_area_ptr");
GlobalVariable *AFLPrevLoc;
- GlobalVariable *AFLContext;
+ GlobalVariable *AFLContext = NULL;
if (ctx_str)
#ifdef __ANDROID__
@@ -292,7 +292,7 @@ bool AFLCoverage::runOnModule(Module &M) {
ConstantInt *Zero = ConstantInt::get(Int8Ty, 0);
ConstantInt *One = ConstantInt::get(Int8Ty, 1);
- LoadInst *PrevCtx; // CTX sensitive coverage
+ LoadInst *PrevCtx = NULL; // CTX sensitive coverage
/* Instrument all the things! */

MODIFY
llvm_mode/compare-transform-pass.so.cc
llvm_mode/compare-transform-pass.so.cc
@@ -137,7 +137,6 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
bool isStrcasecmp = processStrcasecmp;
bool isStrncasecmp = processStrncasecmp;
bool isIntMemcpy = true;
- bool indirect = false;
Function *Callee = callInst->getCalledFunction();
if (!Callee) continue;
@@ -264,8 +263,6 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
}
- if ((HasStr1 || HasStr2)) indirect = true;
-
}
if (isIntMemcpy) continue;
@@ -278,7 +275,6 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
Str1 = StringRef(*val);
HasStr1 = true;
- indirect = true;
// fprintf(stderr, "loaded1 %s\n", Str1.str().c_str());
} else {
@@ -288,7 +284,6 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp,
Str2 = StringRef(*val);
HasStr2 = true;
- indirect = true;
// fprintf(stderr, "loaded2 %s\n", Str2.str().c_str());
}

fixes lots of llvm warnings