Make ICG compatible with clang/llvm 15 #1449 (#1450)

Made a couple of changes in ICG source code to handle clang API differences.  Encapsulated
differences in ifdefs.  Added libclangSupport to ICG link line.
This commit is contained in:
Alex Lin 2023-02-07 12:46:34 -06:00 committed by GitHub
parent afbc78c5e7
commit a48b39bfc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2603 additions and 4574 deletions

View File

@ -233,6 +233,8 @@ AC_CHECK_FILE([$LLVM_LIB_DIR/libclangFrontend.a],
)
)
AC_CHECK_FILE([$LLVM_LIB_DIR/libclangSupport.a],[ICG_CLANGLIBS="$ICG_CLANGLIBS -lclangSupport"],[])
AC_SUBST([ICG_CLANGLIBS])
TR_CLANG_VERSION

7155
configure generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -184,7 +184,7 @@ void HeaderSearchDirs::AddDirsAndFiles(std::string env_var, std::vector<std::str
void HeaderSearchDirs::ApplyHeaderSearchOptions () {
clang::ApplyHeaderSearchOptions( hs , hso , pp.getLangOpts() , pp.getTargetInfo().getTriple() ) ;
clang::HeaderSearch::search_dir_iterator sdi ;
//clang::HeaderSearch::search_dir_iterator sdi ;
/*
for ( sdi = hs.quoted_dir_begin() ; sdi != hs.quoted_dir_end() ; sdi++ ) {
std::cout << "quoted dir " << (*sdi).getName() << std::endl ;
@ -225,8 +225,13 @@ void HeaderSearchDirs::addSearchDirs ( std::vector<std::string> & include_dirs,
bool HeaderSearchDirs::isPathInUserDir (const std::string& in_dir ) {
#if (LIBCLANG_MAJOR >= 15)
for ( clang::ConstSearchDirIterator sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi = std::next(sdi) )
#else
clang::HeaderSearch::search_dir_iterator sdi ;
for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi++ ) {
for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi++ )
#endif
{
#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported
std::string curr_dir = (*sdi).getName() ;
#else
@ -252,8 +257,13 @@ bool HeaderSearchDirs::isPathInUserOrTrickDir (const std::string& in_dir ) {
return true ;
}
#if (LIBCLANG_MAJOR >= 15)
for ( clang::ConstSearchDirIterator sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi = std::next(sdi) )
#else
clang::HeaderSearch::search_dir_iterator sdi ;
for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi++ ) {
for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi++ )
#endif
{
#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported
std::string curr_dir = (*sdi).getName() ;
#else

View File

@ -160,7 +160,9 @@ int main(int argc, char * argv[]) {
// Set all of the defaults to c++
#if (LIBCLANG_MAJOR > 3) || ((LIBCLANG_MAJOR == 3) && (LIBCLANG_MINOR >= 9))
llvm::Triple trip (to.Triple) ;
#if (LIBCLANG_MAJOR >= 12)
#if (LIBCLANG_MAJOR >= 15)
//clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::Language::CXX, trip, ppo.Includes) ;
#elif (LIBCLANG_MAJOR >= 12)
clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::Language::CXX, trip, ppo.Includes) ;
#elif (LIBCLANG_MAJOR >= 10)
clang::CompilerInvocation::setLangDefaults(ci.getLangOpts(), clang::Language::CXX, trip, ppo) ;