Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate llvm 18 changes. #1685

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeTestFiles/TestICGLinkedLibs.cpp
Original file line number Diff line number Diff line change
@@ -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"
#endif
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"

Expand Down
17 changes: 14 additions & 3 deletions trick_source/codegen/Interface_Code_Gen/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
#include <sys/stat.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"
#endif
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"

Expand Down Expand Up @@ -239,8 +244,10 @@ int main(int argc, char * argv[]) {
#endif
clang::Preprocessor& pp = ci.getPreprocessor();

#if (LIBCLANG_MAJOR >= 10)
#if (LIBCLANG_MAJOR >= 10) && (LIBCLANG_MAJOR < 18)
clang::InitializePreprocessor(pp, ppo, ci.getPCHContainerReader(), ci.getFrontendOpts());
#elif (LIBCLANG_MAJOR >= 18)
clang::InitializePreprocessor(pp, ppo, ci.getPCHContainerReader(), ci.getFrontendOpts(), ci.getCodeGenOpts());
#endif

// Add all of the include directories to the preprocessor
Expand Down Expand Up @@ -301,14 +308,18 @@ int main(int argc, char * argv[]) {
exit(-1);
}
// 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();
#elif (LIBCLANG_MAJOR >= 18)
clang::FileEntryRef fileEntryRef = llvm::cantFail(ci.getFileManager().getFileRef(inputFilePath));
#else
const clang::FileEntry* fileEntry = ci.getFileManager().getFile(inputFilePath);
#endif
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));
#elif (LIBCLANG_MAJOR >= 18)
ci.getSourceManager().setMainFileID(ci.getSourceManager().createFileID(fileEntryRef, clang::SourceLocation(), clang::SrcMgr::C_User));
#else
ci.getSourceManager().createMainFileID(fileEntry);
#endif
Expand Down
Loading