Skip to content

Commit

Permalink
Add support for clang 10
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Beer <dbeer1@bloomberg.net>
  • Loading branch information
dbeer1 committed Apr 28, 2020
1 parent b0b28b8 commit a571e19
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
7 changes: 7 additions & 0 deletions include/clangmetatool/meta_tool_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define INCLUDED_CLANGMETATOOL_META_TOOL_FACTORY_H

#include <map>
#include <memory>
#include <string>

#include <clang/Frontend/FrontendAction.h>
Expand Down Expand Up @@ -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<clang::FrontendAction> create() {
return std::make_unique<T>(replacements, args);
}
#else
virtual clang::FrontendAction *create() { return new T(replacements, args); }
#endif
};
} // namespace clangmetatool

Expand Down
14 changes: 10 additions & 4 deletions src/propagation/propagation_visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,21 @@ class PropagationVisitor : public clang::ConstStmtVisitor<S> {
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
Expand Down

0 comments on commit a571e19

Please sign in to comment.