Skip to content

Commit

Permalink
Allow building against llvm 17
Browse files Browse the repository at this point in the history
  • Loading branch information
thetheodor committed Jun 11, 2024
1 parent 5602f8d commit b2257c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions python_src/static_globals/instrumenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ def get_instrumenter(
except: # noqa: E722
pass
if not clang:
try:
clang = CompilerExe.from_path(Path("clang-15"))
except: # noqa: E722
pass
if not clang:
clang = CompilerExe.from_path(Path("clang-14"))
for clang_path in ("clang-17", "clang-16", "clang-15", "clang-14"):
try:
clang = CompilerExe.from_path(Path(clang_path))
break
except: # noqa: E722
pass
assert clang, "Could not find clang"

instrumenter = ClangTool.init_with_paths_from_clang(
Path(__file__).parent / "make-globals-static", clang
Expand Down
4 changes: 2 additions & 2 deletions src/GlobalStaticMaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ void detail::RuleActionCallback::run(
llvm::errs() << "An error has occured.\n";
return;
}
#if CLANG_VERSION_MAJOR == 15
#if CLANG_VERSION_MAJOR == 15 || CLANG_VERSION_MAJOR == 16 || CLANG_VERSION_MAJOR == 17
Expected<SmallVector<transformer::Edit, 1>> Edits =
Rule.Cases[findSelectedCase(Result, Rule)].Edits(Result);
#elif CLANG_VERSION_MAJOR == 14
Expected<SmallVector<transformer::Edit, 1>> Edits =
findSelectedCase(Result, Rule).Edits(Result);
#else
#error "Only versions 14 and 15 are supported"
#error "Only versions 14, 15, 16 and 17 are supported"
#endif
if (!Edits) {
llvm::errs() << "Rewrite failed: " << llvm::toString(Edits.takeError())
Expand Down

0 comments on commit b2257c1

Please sign in to comment.