|
6 | 6 | #include <sys/stat.h> |
7 | 7 | #include <unistd.h> |
8 | 8 |
|
| 9 | +// `llvm/Support/Host.h` is deprecated in favour of `llvm/TargetParser/Host.h` since clang 17 |
| 10 | +#if LIBCLANG_MAJOR > 16 |
| 11 | +#include "llvm/TargetParser/Host.h" |
| 12 | +#else |
9 | 13 | #include "llvm/Support/Host.h" |
| 14 | +#endif |
10 | 15 | #include "llvm/Support/CommandLine.h" |
11 | 16 | #include "llvm/Support/raw_ostream.h" |
12 | 17 |
|
@@ -239,8 +244,10 @@ int main(int argc, char * argv[]) { |
239 | 244 | #endif |
240 | 245 | clang::Preprocessor& pp = ci.getPreprocessor(); |
241 | 246 |
|
242 | | -#if (LIBCLANG_MAJOR >= 10) |
| 247 | +#if (LIBCLANG_MAJOR >= 10) && (LIBCLANG_MAJOR < 18) |
243 | 248 | clang::InitializePreprocessor(pp, ppo, ci.getPCHContainerReader(), ci.getFrontendOpts()); |
| 249 | +#elif (LIBCLANG_MAJOR >= 18) |
| 250 | + clang::InitializePreprocessor(pp, ppo, ci.getPCHContainerReader(), ci.getFrontendOpts(), ci.getCodeGenOpts()); |
244 | 251 | #endif |
245 | 252 |
|
246 | 253 | // Add all of the include directories to the preprocessor |
@@ -301,14 +308,18 @@ int main(int argc, char * argv[]) { |
301 | 308 | exit(-1); |
302 | 309 | } |
303 | 310 | // Open up the input file and parse it |
304 | | -#if (LIBCLANG_MAJOR >= 10) |
| 311 | +#if (LIBCLANG_MAJOR >= 10 && LIBCLANG_MAJOR < 18) |
305 | 312 | const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath).get(); |
| 313 | +#elif (LIBCLANG_MAJOR >= 18) |
| 314 | + clang::FileEntryRef fileEntryRef = llvm::cantFail(ci.getFileManager().getFileRef(inputFilePath)); |
306 | 315 | #else |
307 | 316 | const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath); |
308 | 317 | #endif |
309 | 318 | free(inputFilePath); |
310 | | -#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) |
| 319 | +#if ((LIBCLANG_MAJOR > 3 && LIBCLANG_MAJOR < 18)) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5)) |
311 | 320 | ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(fileEntry, clang::SourceLocation(), clang::SrcMgr::C_User)); |
| 321 | +#elif (LIBCLANG_MAJOR >= 18) |
| 322 | + ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(fileEntryRef, clang::SourceLocation(), clang::SrcMgr::C_User)); |
312 | 323 | #else |
313 | 324 | ci.getSourceManager().createMainFileID(fileEntry); |
314 | 325 | #endif |
|
0 commit comments