issue 1065 llvm 11 support (#1066)

* # 1065 all LLVM::StrRefs need to use str() to convert to std::string now

* #1065 retain backwards compatibility for llvm 3.4.2 (RHEL 7)

closes #1065

Co-authored-by: Scott Fennell <sfennell@Scotts-MacBook-Pro.local>
This commit is contained in:
Scott Fennell 2020-10-21 22:33:53 -05:00 committed by GitHub
parent da4888a1b7
commit 6618d09c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 1 deletions

View File

@ -15,7 +15,11 @@ bool CommentSaver::HandleComment(clang::Preprocessor &PP, clang::SourceRange Com
//Comment.getBegin().dump(sm) ;
if ( isInUserOrTrickCode( ci , Comment.getBegin() , hsd ) ) {
#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported
std::string file_name = ci.getSourceManager().getBufferName(Comment.getBegin()) ;
#else
std::string file_name = ci.getSourceManager().getBufferName(Comment.getBegin()).str() ;
#endif
char * resolved_path = almostRealPath( file_name.c_str() ) ;
if ( resolved_path != NULL ) {
unsigned int line_no = ci.getSourceManager().getSpellingLineNumber(Comment.getBegin()) ;

View File

@ -228,7 +228,8 @@ bool FieldVisitor::VisitFieldDecl( clang::FieldDecl *field ) {
std::cout << "FieldVisitor VisitFieldDecl" << std::endl ;
std::cout << " is_bitfield = " << fdes->isBitField() << std::endl ;
std::cout << " is_canonical = " << qt.isCanonical() << std::endl ;
std::cout << " is_hidden = " << field->isHidden() << std::endl ;
// isHidden() removed in clang 11.0
//std::cout << " is_hidden = " << field->isHidden() << std::endl ;
//field->dump() ;
}

View File

@ -226,7 +226,11 @@ bool HeaderSearchDirs::isPathInUserDir (const std::string& in_dir ) {
clang::HeaderSearch::search_dir_iterator sdi ;
for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi++ ) {
#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported
std::string curr_dir = (*sdi).getName() ;
#else
std::string curr_dir = (*sdi).getName().str() ;
#endif
if ( ! in_dir.compare(0, curr_dir.size(), curr_dir)) {
return false ;
}
@ -244,7 +248,11 @@ bool HeaderSearchDirs::isPathInUserOrTrickDir (const std::string& in_dir ) {
clang::HeaderSearch::search_dir_iterator sdi ;
for ( sdi = hs.system_dir_begin() ; sdi != hs.system_dir_end() ; sdi++ ) {
#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported
std::string curr_dir = (*sdi).getName() ;
#else
std::string curr_dir = (*sdi).getName().str() ;
#endif
if ( ! in_dir.compare(0, curr_dir.size(), curr_dir)) {
return false ;
}

View File

@ -393,7 +393,11 @@ std::set<std::string> PrintAttributes::getEmptyFiles() {
std::set<std::string> emptyFiles;
for (auto fi = ci.getSourceManager().fileinfo_begin() ; fi != ci.getSourceManager().fileinfo_end() ; ++fi ) {
const clang::FileEntry * fe = (*fi).first ;
#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported
std::string header_file_name = fe->getName() ;
#else
std::string header_file_name = fe->getName().str() ;
#endif
if ( visited_files.find(header_file_name) != visited_files.end() ) {
continue;

View File

@ -66,7 +66,11 @@ bool isInUserCode( clang::CompilerInstance & ci , clang::SourceLocation sl , Hea
if ( ! fid.isInvalid() ) {
const clang::FileEntry * fe = ci.getSourceManager().getFileEntryForID(fid) ;
if ( fe != NULL ) {
#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported
char * resolved_path = almostRealPath( fe->getName() ) ;
#else
char * resolved_path = almostRealPath( fe->getName().str() ) ;
#endif
if ( resolved_path != NULL ) {
if ( hsd.isPathInUserDir(resolved_path)) {
ret = true ;
@ -84,7 +88,11 @@ bool isInUserOrTrickCode( clang::CompilerInstance & ci , clang::SourceLocation s
if ( ! fid.isInvalid() ) {
const clang::FileEntry * fe = ci.getSourceManager().getFileEntryForID(fid) ;
if ( fe != NULL ) {
#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported
char * resolved_path = almostRealPath( fe->getName() ) ;
#else
char * resolved_path = almostRealPath( fe->getName().str() ) ;
#endif
if ( resolved_path != NULL ) {
if ( hsd.isPathInUserOrTrickDir(resolved_path)) {
ret = true ;
@ -103,7 +111,11 @@ std::string getFileName( clang::CompilerInstance & ci , clang::SourceLocation sl
if ( ! fid.isInvalid() ) {
const clang::FileEntry * fe = ci.getSourceManager().getFileEntryForID(fid) ;
if ( fe != NULL ) {
#if (LIBCLANG_MAJOR < 4) // TODO delete when RHEL 7 no longer supported
char * resolved_path = almostRealPath( fe->getName() ) ;
#else
char * resolved_path = almostRealPath( fe->getName().str() ) ;
#endif
if ( resolved_path != NULL and hsd.isPathInUserDir(resolved_path)) {
file_name.append(resolved_path);
}