diff --git a/.travis.yml b/.travis.yml index 0d36b3a..473effb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,3 +14,8 @@ matrix: language: cpp sudo: true script: docker build --build-arg TARGET_LLVM_VERSION=9 . + - os: linux + compiler: gcc + language: cpp + sudo: true + script: docker build --build-arg TARGET_LLVM_VERSION=10 . diff --git a/include/clangmetatool/meta_tool_factory.h b/include/clangmetatool/meta_tool_factory.h index cf57514..c4f524b 100644 --- a/include/clangmetatool/meta_tool_factory.h +++ b/include/clangmetatool/meta_tool_factory.h @@ -2,6 +2,7 @@ #define INCLUDED_CLANGMETATOOL_META_TOOL_FACTORY_H #include +#include #include #include @@ -45,7 +46,13 @@ class MetaToolFactory : public clang::tooling::FrontendActionFactory { * This will create the object of your tool giving the * replacemnets map as an argument. */ +#if LLVM_VERSION_MAJOR >= 10 + virtual std::unique_ptr create() { + return std::make_unique(replacements, args); + } +#else virtual clang::FrontendAction *create() { return new T(replacements, args); } +#endif }; } // namespace clangmetatool diff --git a/src/propagation/propagation_visitor.h b/src/propagation/propagation_visitor.h index 4db3205..46a1265 100644 --- a/src/propagation/propagation_visitor.h +++ b/src/propagation/propagation_visitor.h @@ -84,15 +84,21 @@ class PropagationVisitor : public clang::ConstStmtVisitor { StateType &&state, const clang::CFGBlock *block) : buildingLoopChanges(false), map(map), state(state), loop(0), context(AC) { - // Find the first statement in the block + // Find the first statement in the block, note that the statements are not + // necessarily in order as stored in the block. const clang::Stmt *startStmt = nullptr; + const clang::SourceManager& SM = AC.getSourceManager(); for (auto elem : *block) { - if (util::getStmtFromCFGElement(startStmt, elem)) { - break; + const clang::Stmt *elemStmt = nullptr; + if (util::getStmtFromCFGElement(elemStmt, elem) + && (!startStmt + || SM.isBeforeInTranslationUnit(elemStmt->getBeginLoc(), + startStmt->getBeginLoc()))) { + startStmt = elemStmt; } } - // If there are acutally statements in the block + // If there are actually statements in the block if (nullptr != startStmt) { for (const auto &it : state) { // Add all the variable values in the starting state to the top of