From fd98e22a59d339148d9b68c6339fbf69157a82c9 Mon Sep 17 00:00:00 2001 From: zrlk Date: Thu, 14 Apr 2022 19:33:05 -0700 Subject: [UPSTREAM] chore: update LLVM (#5254) Bug: http://b/241011085 Cherry-pick change to build kythe with latest LLVM. Change-Id: Ifcbc3d80f430a275db074c115b9fca2fcb408e41 (cherry picked from commit 6a1baed2f889a36bb25e3f4429fd14016ef5cf3b) --- kythe/cxx/extractor/cxx_extractor.cc | 8 ++++---- kythe/cxx/indexer/cxx/IndexerASTHooks.cc | 3 +++ kythe/cxx/indexer/cxx/IndexerPPCallbacks.cc | 12 +++++++----- kythe/cxx/indexer/cxx/IndexerPPCallbacks.h | 2 +- kythe/cxx/indexer/cxx/semantic_hash.cc | 3 +++ kythe/cxx/tools/fyi/fyi.cc | 10 +++++----- setup.bzl | 2 +- 7 files changed, 24 insertions(+), 16 deletions(-) diff --git a/kythe/cxx/extractor/cxx_extractor.cc b/kythe/cxx/extractor/cxx_extractor.cc index e4ef24c52..c244aca01 100644 --- a/kythe/cxx/extractor/cxx_extractor.cc +++ b/kythe/cxx/extractor/cxx_extractor.cc @@ -454,7 +454,7 @@ class ExtractorPPCallbacks : public clang::PPCallbacks { void InclusionDirective( clang::SourceLocation HashLoc, const clang::Token& IncludeTok, llvm::StringRef FileName, bool IsAngled, clang::CharSourceRange Range, - const clang::FileEntry* File, llvm::StringRef SearchPath, + llvm::Optional File, llvm::StringRef SearchPath, llvm::StringRef RelativePath, const clang::Module* Imported, clang::SrcMgr::CharacteristicKind FileType) override; @@ -843,10 +843,10 @@ std::string IncludeDirGroupToString(const clang::frontend::IncludeDirGroup& G) { void ExtractorPPCallbacks::InclusionDirective( clang::SourceLocation HashLoc, const clang::Token& IncludeTok, llvm::StringRef FileName, bool IsAngled, clang::CharSourceRange Range, - const clang::FileEntry* File, llvm::StringRef SearchPath, + llvm::Optional File, llvm::StringRef SearchPath, llvm::StringRef RelativePath, const clang::Module* Imported, clang::SrcMgr::CharacteristicKind FileType) { - if (File == nullptr) { + if (!File) { LOG(WARNING) << "Found null file: " << FileName.str(); LOG(WARNING) << "Search path was " << SearchPath.str(); LOG(WARNING) << "Relative path was " << RelativePath.str(); @@ -870,7 +870,7 @@ void ExtractorPPCallbacks::InclusionDirective( return; } last_inclusion_directive_path_ = - AddFile(File, FileName, SearchPath, RelativePath); + AddFile(&File->getFileEntry(), FileName, SearchPath, RelativePath); last_inclusion_offset_ = source_manager_->getFileOffset(HashLoc); } diff --git a/kythe/cxx/indexer/cxx/IndexerASTHooks.cc b/kythe/cxx/indexer/cxx/IndexerASTHooks.cc index 0a467bd9f..60519a2d1 100644 --- a/kythe/cxx/indexer/cxx/IndexerASTHooks.cc +++ b/kythe/cxx/indexer/cxx/IndexerASTHooks.cc @@ -4042,6 +4042,9 @@ IndexerASTVisitor::BuildNodeIdForTemplateName(const clang::TemplateName& Name) { case TemplateName::SubstTemplateTemplateParmPack: CHECK(IgnoreUnimplemented) << "TN.SubstTemplateTemplateParmPack"; return absl::nullopt; + case TemplateName::UsingTemplate: + CHECK(options_.IgnoreUnimplemented) << "TN.UsingTemplate"; + return absl::nullopt; } CHECK(IgnoreUnimplemented) << "Unexpected TemplateName kind: " << Name.getKind(); diff --git a/kythe/cxx/indexer/cxx/IndexerPPCallbacks.cc b/kythe/cxx/indexer/cxx/IndexerPPCallbacks.cc index 187cc494c..1f6eef65f 100644 --- a/kythe/cxx/indexer/cxx/IndexerPPCallbacks.cc +++ b/kythe/cxx/indexer/cxx/IndexerPPCallbacks.cc @@ -240,14 +240,16 @@ void IndexerPPCallbacks::Ifndef(clang::SourceLocation Location, void IndexerPPCallbacks::InclusionDirective( clang::SourceLocation HashLocation, const clang::Token& IncludeToken, llvm::StringRef Filename, bool IsAngled, - clang::CharSourceRange FilenameRange, const clang::FileEntry* FileEntry, - llvm::StringRef SearchPath, llvm::StringRef RelativePath, - const clang::Module* Imported, clang::SrcMgr::CharacteristicKind FileType) { + clang::CharSourceRange FilenameRange, + llvm::Optional FileRef, llvm::StringRef SearchPath, + llvm::StringRef RelativePath, const clang::Module* Imported, + clang::SrcMgr::CharacteristicKind FileType) { // TODO(zarko) (Modules): Check if `Imported` is non-null; if so, this // was transformed to a module import. - if (FileEntry != nullptr) { + if (FileRef) { Observer.recordIncludesRange( - RangeInCurrentContext(FilenameRange.getAsRange()), FileEntry); + RangeInCurrentContext(FilenameRange.getAsRange()), + &FileRef->getFileEntry()); } LastInclusionHash = HashLocation; } diff --git a/kythe/cxx/indexer/cxx/IndexerPPCallbacks.h b/kythe/cxx/indexer/cxx/IndexerPPCallbacks.h index 8ae2df153..92b2d8b77 100644 --- a/kythe/cxx/indexer/cxx/IndexerPPCallbacks.h +++ b/kythe/cxx/indexer/cxx/IndexerPPCallbacks.h @@ -66,7 +66,7 @@ class IndexerPPCallbacks : public clang::PPCallbacks { const clang::Token& IncludeToken, llvm::StringRef Filename, bool IsAngled, clang::CharSourceRange FilenameRange, - const clang::FileEntry* FileEntry, + llvm::Optional FileEntry, llvm::StringRef SearchPath, llvm::StringRef RelativePath, const clang::Module* Imported, diff --git a/kythe/cxx/indexer/cxx/semantic_hash.cc b/kythe/cxx/indexer/cxx/semantic_hash.cc index 53d535b21..4b8c9dbb6 100644 --- a/kythe/cxx/indexer/cxx/semantic_hash.cc +++ b/kythe/cxx/indexer/cxx/semantic_hash.cc @@ -49,6 +49,9 @@ uint64_t SemanticHash::Hash(const clang::TemplateName& name) const { CHECK(ignore_unimplemented_) << "SemanticHash(SubstTemplateTemplateParmPack)"; return 0; + case TemplateName::UsingTemplate: + CHECK(ignore_unimplemented_) << "SemanticHash(UsingTemplate)"; + return 0; } CHECK(ignore_unimplemented_) << "Unexpected TemplateName Kind: " << name.getKind(); diff --git a/kythe/cxx/tools/fyi/fyi.cc b/kythe/cxx/tools/fyi/fyi.cc index fcf161a8f..e9560343e 100644 --- a/kythe/cxx/tools/fyi/fyi.cc +++ b/kythe/cxx/tools/fyi/fyi.cc @@ -280,7 +280,7 @@ class PreprocessorHooks : public clang::PPCallbacks { const clang::Token& include_token, llvm::StringRef file_name, bool is_angled, clang::CharSourceRange file_name_range, - const clang::FileEntry* include_file, + llvm::Optional include_file, llvm::StringRef search_path, llvm::StringRef relative_path, const clang::Module* imported, @@ -490,9 +490,9 @@ void PreprocessorHooks::InclusionDirective( clang::SourceLocation hash_location, const clang::Token& include_token, llvm::StringRef file_name, bool is_angled, clang::CharSourceRange file_name_range, - const clang::FileEntry* include_file, llvm::StringRef search_path, - llvm::StringRef relative_path, const clang::Module* imported, - clang::SrcMgr::CharacteristicKind FileType) { + llvm::Optional include_file, + llvm::StringRef search_path, llvm::StringRef relative_path, + const clang::Module* imported, clang::SrcMgr::CharacteristicKind FileType) { if (!enclosing_pass_ || !enclosing_pass_->tracker()) { return; } @@ -501,7 +501,7 @@ void PreprocessorHooks::InclusionDirective( auto id_position = source_manager->getDecomposedExpansionLoc(hash_location); const auto* source_file = source_manager->getFileEntryForID(id_position.first); - if (source_file == nullptr || include_file == nullptr) { + if (source_file == nullptr || !include_file) { return; } if (tracked_file_ == source_file) { diff --git a/setup.bzl b/setup.bzl index 6a95e3df9..55d78d296 100644 --- a/setup.bzl +++ b/setup.bzl @@ -141,7 +141,7 @@ def kythe_rule_repositories(): maybe( github_archive, repo_name = "llvm/llvm-project", - commit = "40d85f16c45e09c1e280bcb8e63342392036f1eb", + commit = "4c564940a14f55d2315d2676b10fea0660ea814a", name = "llvm-project-raw", build_file_content = "#empty", sha256 = "938127d27b04c2fcff4814075771e2e434eb5e20a8b6935e0141454effaf6be7", -- cgit v1.2.3