mirror of
https://github.com/nasa/trick.git
synced 2025-02-06 10:59:27 +00:00
Incorporate llvm 18 changes. (#1685)
* Incorporate llvm 18 changes. * Fixed to set input file properly for clang3.4 or ealier. * Fixed missing brackets and added the rule back for the condition to call clang init preprocessor which was taken out incorrectly by the last commit.
This commit is contained in:
parent
f475627ef7
commit
d40bc12570
@ -1,4 +1,9 @@
|
|||||||
|
// `llvm/Support/Host.h` is deprecated in favour of `llvm/TargetParser/Host.h` since clang 17
|
||||||
|
#if LIBCLANG_MAJOR > 16
|
||||||
|
#include "llvm/TargetParser/Host.h"
|
||||||
|
#else
|
||||||
#include "llvm/Support/Host.h"
|
#include "llvm/Support/Host.h"
|
||||||
|
#endif
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
|
@ -6,7 +6,12 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
// `llvm/Support/Host.h` is deprecated in favour of `llvm/TargetParser/Host.h` since clang 17
|
||||||
|
#if LIBCLANG_MAJOR > 16
|
||||||
|
#include "llvm/TargetParser/Host.h"
|
||||||
|
#else
|
||||||
#include "llvm/Support/Host.h"
|
#include "llvm/Support/Host.h"
|
||||||
|
#endif
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
@ -239,8 +244,10 @@ int main(int argc, char * argv[]) {
|
|||||||
#endif
|
#endif
|
||||||
clang::Preprocessor& pp = ci.getPreprocessor();
|
clang::Preprocessor& pp = ci.getPreprocessor();
|
||||||
|
|
||||||
#if (LIBCLANG_MAJOR >= 10)
|
#if (LIBCLANG_MAJOR >= 10) && (LIBCLANG_MAJOR < 18)
|
||||||
clang::InitializePreprocessor(pp, ppo, ci.getPCHContainerReader(), ci.getFrontendOpts());
|
clang::InitializePreprocessor(pp, ppo, ci.getPCHContainerReader(), ci.getFrontendOpts());
|
||||||
|
#elif (LIBCLANG_MAJOR >= 18)
|
||||||
|
clang::InitializePreprocessor(pp, ppo, ci.getPCHContainerReader(), ci.getFrontendOpts(), ci.getCodeGenOpts());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Add all of the include directories to the preprocessor
|
// Add all of the include directories to the preprocessor
|
||||||
@ -301,14 +308,18 @@ int main(int argc, char * argv[]) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
// Open up the input file and parse it
|
// Open up the input file and parse it
|
||||||
#if (LIBCLANG_MAJOR >= 10)
|
#if (LIBCLANG_MAJOR >= 10 && LIBCLANG_MAJOR < 18)
|
||||||
const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath).get();
|
const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath).get();
|
||||||
|
#elif (LIBCLANG_MAJOR >= 18)
|
||||||
|
clang::FileEntryRef fileEntryRef = llvm::cantFail(ci.getFileManager().getFileRef(inputFilePath));
|
||||||
#else
|
#else
|
||||||
const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath);
|
const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath);
|
||||||
#endif
|
#endif
|
||||||
free(inputFilePath);
|
free(inputFilePath);
|
||||||
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
#if ((LIBCLANG_MAJOR > 3 && LIBCLANG_MAJOR < 18)) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 5))
|
||||||
ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(fileEntry, clang::SourceLocation(), clang::SrcMgr::C_User));
|
ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(fileEntry, clang::SourceLocation(), clang::SrcMgr::C_User));
|
||||||
|
#elif (LIBCLANG_MAJOR >= 18)
|
||||||
|
ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(fileEntryRef, clang::SourceLocation(), clang::SrcMgr::C_User));
|
||||||
#else
|
#else
|
||||||
ci.getSourceManager().createMainFileID(fileEntry);
|
ci.getSourceManager().createMainFileID(fileEntry);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user