diff --git a/interpreter/cling/lib/Interpreter/ClangInternalState.cpp b/interpreter/cling/lib/Interpreter/ClangInternalState.cpp index 112f9821e8222..177783eca6c83 100644 --- a/interpreter/cling/lib/Interpreter/ClangInternalState.cpp +++ b/interpreter/cling/lib/Interpreter/ClangInternalState.cpp @@ -274,14 +274,14 @@ namespace cling { // There is content - a memory buffer or a file. // We know it's a file because we started off the FileEntry. - // FIXME: LLVM will completely migrate to FileEntryRef. - // We added `isOpen()` in our commit: - // `Accessor to "is file opened"; this is crucial info for us.` - // Move this logic to FileEntryRef or have a workaround. - if (FE.getFileEntry().isOpen()) - ParsedOpen.emplace_back(std::move(fileName)); - else - Parsed.emplace_back(std::move(fileName)); + // // FIXME: LLVM will completely migrate to FileEntryRef. + // // We added `isOpen()` in our commit: + // // `Accessor to "is file opened"; this is crucial info for us.` + // // Move this logic to FileEntryRef or have a workaround. + // if (FE.getFileEntry().isOpen()) + // ParsedOpen.emplace_back(std::move(fileName)); + // else + // Parsed.emplace_back(std::move(fileName)); } else AST.emplace_back(std::move(fileName)); } diff --git a/interpreter/cling/lib/Interpreter/DeclUnloader.cpp b/interpreter/cling/lib/Interpreter/DeclUnloader.cpp index 37a60a0aef66d..d9a8616a36cd8 100644 --- a/interpreter/cling/lib/Interpreter/DeclUnloader.cpp +++ b/interpreter/cling/lib/Interpreter/DeclUnloader.cpp @@ -493,12 +493,12 @@ namespace cling { } DeclUnloader::~DeclUnloader() { - SourceManager& SM = m_Sema->getSourceManager(); - for (FileIDs::iterator I = m_FilesToUncache.begin(), - E = m_FilesToUncache.end(); I != E; ++I) { - // We need to reset the cache - SM.invalidateCache(*I); - } + // SourceManager& SM = m_Sema->getSourceManager(); + // for (FileIDs::iterator I = m_FilesToUncache.begin(), + // E = m_FilesToUncache.end(); I != E; ++I) { + // // We need to reset the cache + // SM.invalidateCache(*I); + // } } void DeclUnloader::CollectFilesToUncache(SourceLocation Loc) { @@ -1024,8 +1024,8 @@ namespace cling { bool Successful = true; // Remove specializations, but do not invalidate the iterator! - for (FunctionTemplateDecl::spec_iterator I = FTD->loaded_spec_begin(), - E = FTD->loaded_spec_end(); I != E; ++I) + for (FunctionTemplateDecl::spec_iterator I = FTD->spec_begin(), + E = FTD->spec_end(); I != E; ++I) Successful &= VisitFunctionDecl(*I, /*RemoveSpec=*/false); Successful &= VisitRedeclarableTemplateDecl(FTD); @@ -1036,9 +1036,9 @@ namespace cling { bool DeclUnloader::VisitClassTemplateDecl(ClassTemplateDecl* CTD) { // ClassTemplateDecl: TemplateDecl, Redeclarable bool Successful = true; - // Remove specializations, but do not invalidate the iterator! - for (ClassTemplateDecl::spec_iterator I = CTD->loaded_spec_begin(), - E = CTD->loaded_spec_end(); I != E; ++I) + // Remove specializations: + for (ClassTemplateDecl::spec_iterator I = CTD->spec_begin(), + E = CTD->spec_end(); I != E; ++I) Successful &= VisitClassTemplateSpecializationDecl(*I, /*RemoveSpec=*/false); @@ -1082,8 +1082,8 @@ namespace cling { // VarTemplateDecl: TemplateDecl, Redeclarable bool Successful = true; // Remove specializations, but do not invalidate the iterator! - for (VarTemplateDecl::spec_iterator I = VTD->loaded_spec_begin(), - E = VTD->loaded_spec_end(); + for (VarTemplateDecl::spec_iterator I = VTD->spec_begin(), + E = VTD->spec_end(); I != E; ++I) Successful &= VisitVarTemplateSpecializationDecl(*I, /*RemoveSpec=*/false); diff --git a/interpreter/cling/lib/Interpreter/TransactionUnloader.cpp b/interpreter/cling/lib/Interpreter/TransactionUnloader.cpp index 78f3c47130920..1c50d8586d0cb 100644 --- a/interpreter/cling/lib/Interpreter/TransactionUnloader.cpp +++ b/interpreter/cling/lib/Interpreter/TransactionUnloader.cpp @@ -161,9 +161,9 @@ namespace cling { else T->setState(Transaction::kRolledBackWithErrors); - // Release the input_line_X file unless verifying diagnostics. - if (!m_Interp->getCI()->getDiagnosticOpts().VerifyDiagnostics) - m_Sema->getSourceManager().invalidateCache(T->getBufferFID()); + // // Release the input_line_X file unless verifying diagnostics. + // if (!m_Interp->getCI()->getDiagnosticOpts().VerifyDiagnostics) + // m_Sema->getSourceManager().invalidateCache(T->getBufferFID()); return Successful; } diff --git a/interpreter/llvm-project/clang/include/clang/AST/DeclTemplate.h b/interpreter/llvm-project/clang/include/clang/AST/DeclTemplate.h index 8cbc48efbb52c..472b079c8f728 100644 --- a/interpreter/llvm-project/clang/include/clang/AST/DeclTemplate.h +++ b/interpreter/llvm-project/clang/include/clang/AST/DeclTemplate.h @@ -1085,20 +1085,6 @@ class FunctionTemplateDecl : public RedeclarableTemplateDecl { return makeSpecIterator(getSpecializations(), true); } - /// All specializations that that have already been loaded, ie avoiding - /// deserialization of lazily registered specializations. - spec_range loaded_specializations() const { - return spec_range(loaded_spec_begin(), loaded_spec_end()); - } - - spec_iterator loaded_spec_begin() const { - return makeSpecIterator(getCommonPtr()->Specializations, false); - } - - spec_iterator loaded_spec_end() const { - return makeSpecIterator(getCommonPtr()->Specializations, true); - } - /// Return whether this function template is an abbreviated function template, /// e.g. `void foo(auto x)` or `template void foo(auto x)` bool isAbbreviated() const { @@ -2468,20 +2454,6 @@ class ClassTemplateDecl : public RedeclarableTemplateDecl { return makeSpecIterator(getSpecializations(), true); } - /// All specializations that that have already been loaded, ie avoiding - /// deserialization of lazily registered specializations. - spec_range loaded_specializations() const { - return spec_range(loaded_spec_begin(), loaded_spec_end()); - } - - spec_iterator loaded_spec_begin() const { - return makeSpecIterator(getCommonPtr()->Specializations, false); - } - - spec_iterator loaded_spec_end() const { - return makeSpecIterator(getCommonPtr()->Specializations, true); - } - // Implement isa/cast/dyncast support static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == ClassTemplate; } @@ -3210,20 +3182,6 @@ class VarTemplateDecl : public RedeclarableTemplateDecl { return makeSpecIterator(getSpecializations(), true); } - /// All specializations that that have already been loaded, ie avoiding - /// deserialization of lazily registered specializations. - spec_range loaded_specializations() const { - return spec_range(loaded_spec_begin(), loaded_spec_end()); - } - - spec_iterator loaded_spec_begin() const { - return makeSpecIterator(getCommonPtr()->Specializations, false); - } - - spec_iterator loaded_spec_end() const { - return makeSpecIterator(getCommonPtr()->Specializations, true); - } - // Implement isa/cast/dyncast support static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == VarTemplate; } diff --git a/interpreter/llvm-project/clang/include/clang/Basic/FileEntry.h b/interpreter/llvm-project/clang/include/clang/Basic/FileEntry.h index 3d9ec4ce26558..da5ba90974293 100644 --- a/interpreter/llvm-project/clang/include/clang/Basic/FileEntry.h +++ b/interpreter/llvm-project/clang/include/clang/Basic/FileEntry.h @@ -327,7 +327,6 @@ class FileEntry { ~FileEntry(); StringRef tryGetRealPathName() const { return RealPathName; } - bool isOpen() const { return (bool)File; } off_t getSize() const { return Size; } // Size may increase due to potential z/OS EBCDIC -> UTF-8 conversion. void setSize(off_t NewSize) { Size = NewSize; } diff --git a/interpreter/llvm-project/clang/include/clang/Basic/FileManager.h b/interpreter/llvm-project/clang/include/clang/Basic/FileManager.h index e213dab0fbd66..6cc6c2bfd2b6b 100644 --- a/interpreter/llvm-project/clang/include/clang/Basic/FileManager.h +++ b/interpreter/llvm-project/clang/include/clang/Basic/FileManager.h @@ -32,7 +32,6 @@ #include #include #include -#include namespace llvm { @@ -108,11 +107,6 @@ class FileManager : public RefCountedBase { /// The canonical names of files and directories . llvm::DenseMap CanonicalNames; - std::set FileEntriesToReread; - - /// The canonical names of directories. - llvm::DenseMap CanonicalDirNames; - /// Storage for canonical names that we have computed. llvm::BumpPtrAllocator CanonicalNameStorage; @@ -332,9 +326,6 @@ class FileManager : public RefCountedBase { std::error_code getNoncachedStatValue(StringRef Path, llvm::vfs::Status &Result); - /// Remove the real file \p Entry from the cache. - void invalidateCache(FileEntryRef Entry); - /// If path is not absolute and FileSystemOptions set the working /// directory, the path is modified to be relative to the given /// working directory. diff --git a/interpreter/llvm-project/clang/include/clang/Basic/SourceManager.h b/interpreter/llvm-project/clang/include/clang/Basic/SourceManager.h index 4195cf31a1380..e0f1ea435d54e 100644 --- a/interpreter/llvm-project/clang/include/clang/Basic/SourceManager.h +++ b/interpreter/llvm-project/clang/include/clang/Basic/SourceManager.h @@ -256,7 +256,7 @@ class alignas(8) ContentCache { /// Set the buffer. void setBuffer(std::unique_ptr B) { - IsBufferInvalid = !B; + IsBufferInvalid = false; Buffer = std::move(B); } @@ -845,8 +845,6 @@ class SourceManager : public RefCountedBase { void clearIDTables(); - void invalidateCache(FileID FID); - /// Initialize this source manager suitably to replay the compilation /// described by \p Old. Requires that \p Old outlive \p *this. void initializeForReplay(const SourceManager &Old); diff --git a/interpreter/llvm-project/clang/include/clang/Sema/Sema.h b/interpreter/llvm-project/clang/include/clang/Sema/Sema.h index f53e08ac0cf13..a58ec59794e85 100644 --- a/interpreter/llvm-project/clang/include/clang/Sema/Sema.h +++ b/interpreter/llvm-project/clang/include/clang/Sema/Sema.h @@ -2732,7 +2732,7 @@ class Sema final : public SemaBase { public: // Marks SS invalid if it represents an incomplete type. - bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *&DC); + bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC); // Complete an enum decl, maybe without a scope spec. bool RequireCompleteEnumDecl(EnumDecl *D, SourceLocation L, CXXScopeSpec *SS = nullptr); @@ -11344,8 +11344,8 @@ class Sema final : public SemaBase { bool CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, - SkipBodyInfo *SkipBody = nullptr, - bool Complain = true); + SkipBodyInfo *SkipBody = nullptr); + /// Match the given template parameter lists to the given scope /// specifier, returning the template parameter list that applies to the /// name. diff --git a/interpreter/llvm-project/clang/include/clang/Serialization/ASTReader.h b/interpreter/llvm-project/clang/include/clang/Serialization/ASTReader.h index bea453546157e..2bf1f698b5cb1 100644 --- a/interpreter/llvm-project/clang/include/clang/Serialization/ASTReader.h +++ b/interpreter/llvm-project/clang/include/clang/Serialization/ASTReader.h @@ -757,9 +757,6 @@ class ASTReader /// files. llvm::DenseSet LoadedUndefs; - /// \Token literal data loaded and owned by us. - std::vector TokenLiteralDataLoaded; - using GlobalMacroMapType = ContinuousRangeMap; diff --git a/interpreter/llvm-project/clang/lib/AST/ASTImporter.cpp b/interpreter/llvm-project/clang/lib/AST/ASTImporter.cpp index 686f0068aeb48..13e7f93233a7f 100644 --- a/interpreter/llvm-project/clang/lib/AST/ASTImporter.cpp +++ b/interpreter/llvm-project/clang/lib/AST/ASTImporter.cpp @@ -10080,7 +10080,7 @@ Expected ASTImporter::Import(FileID FromID, bool IsBuiltin) { // FIXME: We want to re-use the existing MemoryBuffer! std::optional FromBuf = Cache->getBufferOrNone(FromContext.getDiagnostics(), - FromFileManager, SourceLocation{}); + FromSM.getFileManager(), SourceLocation{}); if (!FromBuf) return llvm::make_error(ASTImportError::Unknown); diff --git a/interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp b/interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp index 37412abcfbc75..fe8734d262a96 100644 --- a/interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp +++ b/interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp @@ -367,6 +367,12 @@ bool RedeclarableTemplateDecl::loadLazySpecializationsImpl( if (!ExternalSource) return false; + // If TPL is not null, it implies that we're loading specializations for + // partial templates. We need to load all specializations in such cases. + if (TPL) + return ExternalSource->LoadExternalSpecializations(this->getCanonicalDecl(), + /*OnlyPartial=*/false); + return ExternalSource->LoadExternalSpecializations(this->getCanonicalDecl(), Args); } diff --git a/interpreter/llvm-project/clang/lib/AST/TemplateBase.cpp b/interpreter/llvm-project/clang/lib/AST/TemplateBase.cpp index 1ad0661c146ef..0eef8f305fcb3 100644 --- a/interpreter/llvm-project/clang/lib/AST/TemplateBase.cpp +++ b/interpreter/llvm-project/clang/lib/AST/TemplateBase.cpp @@ -130,14 +130,8 @@ static void printIntegral(const TemplateArgument &TemplArg, raw_ostream &Out, } else Out << "(" << T->getCanonicalTypeInternal().getAsString(Policy) << ")" << Val; - } else { + } else Out << Val; - // Handle cases where the value is too large to fit into the underlying type - // i.e. where the unsignedness matters. - if (T->isBuiltinType()) - if (Val.isUnsigned() && Val.getBitWidth() == 64 && Val.countLeadingOnes()) - Out << "ull"; - } } static unsigned getArrayDepth(QualType type) { diff --git a/interpreter/llvm-project/clang/lib/Basic/Diagnostic.cpp b/interpreter/llvm-project/clang/lib/Basic/Diagnostic.cpp index dec6f04a29143..9e2f134135647 100644 --- a/interpreter/llvm-project/clang/lib/Basic/Diagnostic.cpp +++ b/interpreter/llvm-project/clang/lib/Basic/Diagnostic.cpp @@ -183,29 +183,7 @@ void DiagnosticsEngine::DiagStateMap::append(SourceManager &SrcMgr, Offset = F->ParentOffset, F = F->Parent) { F->HasLocalTransitions = true; auto &Last = F->StateTransitions.back(); - if (Last.Offset > Offset) { - // Deal with a state change induce by recursive parsing. The first parsing is - // suspended and a (recursive) parsing is started between associated (in the upper/outer - // file) with a newer line (hence greater offset). After the end of the recursive - // parsing, we go back to the first parsing and any state change will done 'earlier' - // and trigger: - // assert(Last.Offset <= Offset && "state transitions added out of order"); - auto OnePastIt = std::upper_bound( - F->StateTransitions.begin(), F->StateTransitions.end(), Offset, - [](unsigned Offset, const DiagStatePoint &P) { - return Offset < P.Offset; - }); - if (OnePastIt == F->StateTransitions.begin() || (OnePastIt[-1].Offset != Offset)) { - F->StateTransitions.insert( OnePastIt, {State, Offset}); - } else { - auto &Prev = OnePastIt[-1]; - if (Prev.State == State) - break; - Prev.State = State; - continue; - } - continue; - } + assert(Last.Offset <= Offset && "state transitions added out of order"); if (Last.Offset == Offset) { if (Last.State == State) diff --git a/interpreter/llvm-project/clang/lib/Basic/FileManager.cpp b/interpreter/llvm-project/clang/lib/Basic/FileManager.cpp index 14b36c7bc82a1..f0b6f7be6c84f 100644 --- a/interpreter/llvm-project/clang/lib/Basic/FileManager.cpp +++ b/interpreter/llvm-project/clang/lib/Basic/FileManager.cpp @@ -221,25 +221,7 @@ llvm::Expected FileManager::getFileRef(StringRef Filename, // See if there is already an entry in the map. auto SeenFileInsertResult = SeenFileEntries.insert({Filename, std::errc::no_such_file_or_directory}); - - auto *NamedFileEnt = &*SeenFileInsertResult.first; - - const FileEntry *StaleFileEntry = 0; - bool needsRereading = false; - if (NamedFileEnt && NamedFileEnt->getValue()) { - FileEntryRef::MapValue Value = *NamedFileEnt->getValue(); - if (Value.V.is()) { - auto found = FileEntriesToReread.find(Value.V.get()); - if (found != FileEntriesToReread.end()) { - needsRereading = true; - StaleFileEntry = *found; - FileEntriesToReread.erase(found); - } - } - } - - // See if there is already an entry in the map. - if (!SeenFileInsertResult.second && !needsRereading) { + if (!SeenFileInsertResult.second) { if (!SeenFileInsertResult.first->second) return llvm::errorCodeToError( SeenFileInsertResult.first->second.getError()); @@ -248,6 +230,8 @@ llvm::Expected FileManager::getFileRef(StringRef Filename, // We've not seen this before. Fill it in. ++NumFileCacheMisses; + auto *NamedFileEnt = &*SeenFileInsertResult.first; + assert(!NamedFileEnt->second && "should be newly-created"); // Get the null-terminated file name as stored as the key of the // SeenFileEntries map. @@ -351,9 +335,7 @@ llvm::Expected FileManager::getFileRef(StringRef Filename, } FileEntryRef ReturnedRef(*NamedFileEnt); - if (ReusingEntry && - llvm::sys::toTimeT(Status.getLastModificationTime()) == UFE->ModTime) { - // Already have an entry with this inode, return it. + if (ReusingEntry) { // Already have an entry with this inode, return it. return ReturnedRef; } @@ -373,20 +355,6 @@ llvm::Expected FileManager::getFileRef(StringRef Filename, // We should still fill the path even if we aren't opening the file. fillRealPathName(UFE, InterndFileName); } - - if (StaleFileEntry) { - // Find occurrences of old FileEntry; update with new one: - for (auto& fe: SeenFileEntries) { - if (fe.getValue()) { - FileEntryRef::MapValue Value = *fe.getValue(); - if (Value.V.is() - && Value.V.get() == StaleFileEntry) { - fe.setValue(FileEntryRef::MapValue(*UFE, DirInfo)); - } - } - } - } - return ReturnedRef; } @@ -645,11 +613,6 @@ FileManager::getNoncachedStatValue(StringRef Path, return std::error_code(); } -void FileManager::invalidateCache(FileEntryRef Entry) { - assert(Entry && "Cannot invalidate a NULL FileEntry"); - FileEntriesToReread.insert(Entry); -} - void FileManager::GetUniqueIDMapping( SmallVectorImpl &UIDToFiles) const { UIDToFiles.clear(); diff --git a/interpreter/llvm-project/clang/lib/Basic/SourceManager.cpp b/interpreter/llvm-project/clang/lib/Basic/SourceManager.cpp index 9343b3a3ecced..b1f2180c1d462 100644 --- a/interpreter/llvm-project/clang/lib/Basic/SourceManager.cpp +++ b/interpreter/llvm-project/clang/lib/Basic/SourceManager.cpp @@ -356,25 +356,6 @@ bool SourceManager::isMainFile(const FileEntry &SourceFile) { return false; } -void SourceManager::invalidateCache(FileID FID) { - OptionalFileEntryRef Entry = getFileEntryRefForID(FID); - if (!Entry) - return; - if (ContentCache *&E = FileInfos[*Entry]) { - E->setBuffer(nullptr); - E = 0; - } - if (!FID.isInvalid()) { - const SrcMgr::SLocEntry& SLocE = getSLocEntry(FID); - if (SLocE.isFile()) { - SrcMgr::ContentCache& CC = - const_cast(SLocE.getFile().getContentCache()); - CC.setBuffer(nullptr); - } - } - getFileManager().invalidateCache(*Entry); -} - void SourceManager::initializeForReplay(const SourceManager &Old) { assert(MainFileID.isInvalid() && "expected uninitialized SourceManager"); @@ -1492,16 +1473,6 @@ StringRef SourceManager::getBufferName(SourceLocation Loc, auto B = getBufferOrNone(getFileID(Loc)); if (Invalid) *Invalid = !B; - - // Try to get the name without reading the buffer. - FileID FID = getFileID(Loc); - const SrcMgr::SLocEntry &Entry = getSLocEntry(FID, Invalid); - if (!Invalid && Entry.isFile()) { - if (OptionalFileEntryRef FE = - Entry.getFile().getContentCache().ContentsEntry) - return FE->getName(); - } - return B ? B->getBufferIdentifier() : ""; } diff --git a/interpreter/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp b/interpreter/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp index 609e18a05b870..eb8d3ceeeba4c 100644 --- a/interpreter/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp +++ b/interpreter/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp @@ -3392,21 +3392,18 @@ llvm::Constant *CodeGenModule::EmitAnnotationString(StringRef Str) { llvm::Constant *CodeGenModule::EmitAnnotationUnit(SourceLocation Loc) { SourceManager &SM = getContext().getSourceManager(); - //PresumedLoc PLoc = SM.getPresumedLoc(Loc); - //if (PLoc.isValid()) - // return EmitAnnotationString(PLoc.getFilename()); + PresumedLoc PLoc = SM.getPresumedLoc(Loc); + if (PLoc.isValid()) + return EmitAnnotationString(PLoc.getFilename()); return EmitAnnotationString(SM.getBufferName(Loc)); } llvm::Constant *CodeGenModule::EmitAnnotationLineNo(SourceLocation L) { - return llvm::ConstantInt::get(Int32Ty, 1); -#if 0 SourceManager &SM = getContext().getSourceManager(); PresumedLoc PLoc = SM.getPresumedLoc(L); unsigned LineNo = PLoc.isValid() ? PLoc.getLine() : SM.getExpansionLineNumber(L); return llvm::ConstantInt::get(Int32Ty, LineNo); -#endif } llvm::Constant *CodeGenModule::EmitAnnotationArgs(const AnnotateAttr *Attr) { diff --git a/interpreter/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp b/interpreter/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp index 19e3bdd6e7758..46e524a023e06 100644 --- a/interpreter/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/interpreter/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp @@ -107,11 +107,6 @@ namespace clang { } llvm::Module *ReleaseModule() { - // Remove pending etc decls in case of error; the asserts in StartModule() - // will rightfully be confused otherwise, as none of the decls were - // emitted. - if (Diags.hasErrorOccurred()) - Builder->clear(); return M.release(); } diff --git a/interpreter/llvm-project/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/interpreter/llvm-project/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 57460d91d83c4..48330e9361718 100644 --- a/interpreter/llvm-project/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/interpreter/llvm-project/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -548,11 +548,6 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM, OptionalFileEntryRef File = PP->LookupFile(Pos, Filename, false, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr); - - // Check if the file was virtual - if (!File) - File = SM.getFileManager().getOptionalFileRef(Filename); - if (!File) { Diags.Report(Pos.getLocWithOffset(PH.C - PH.Begin), diag::err_verify_missing_file) diff --git a/interpreter/llvm-project/clang/lib/Lex/HeaderSearch.cpp b/interpreter/llvm-project/clang/lib/Lex/HeaderSearch.cpp index 74d4cd86adc76..483259c6d1953 100644 --- a/interpreter/llvm-project/clang/lib/Lex/HeaderSearch.cpp +++ b/interpreter/llvm-project/clang/lib/Lex/HeaderSearch.cpp @@ -212,9 +212,6 @@ std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName, if (FileMapOnly || HSOpts->PrebuiltModulePaths.empty()) return {}; - llvm::StringRef ModuleCachePath = getModuleCachePath(); - bool CacheFailure = true; - // Then go through each prebuilt module directory and try to find the pcm // file. for (const std::string &Dir : HSOpts->PrebuiltModulePaths) { @@ -229,13 +226,7 @@ std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName, ".pcm"); else llvm::sys::path::append(Result, ModuleName + ".pcm"); - // If we have the same ModuleCachePath and PrebuiltModulePath pointing - // to the same folder we should not cache the file lookup failure as it - // may be currently building an implicit module. - if (!ModuleCachePath.empty() && ModuleCachePath == Dir) - CacheFailure = false; - - if (getFileMgr().getOptionalFileRef(Result.str(), /*Open=*/false, CacheFailure)) + if (getFileMgr().getOptionalFileRef(Result)) return std::string(Result); } @@ -459,9 +450,7 @@ OptionalFileEntryRef HeaderSearch::getFileAndSuggestModule( std::error_code EC = llvm::errorToErrorCode(File.takeError()); if (EC != llvm::errc::no_such_file_or_directory && EC != llvm::errc::invalid_argument && - EC != llvm::errc::is_a_directory && - EC != llvm::errc::not_a_directory && - EC != llvm::errc::permission_denied) { + EC != llvm::errc::is_a_directory && EC != llvm::errc::not_a_directory) { Diags.Report(IncludeLoc, diag::err_cannot_open_file) << FileName << EC.message(); } diff --git a/interpreter/llvm-project/clang/lib/Lex/Lexer.cpp b/interpreter/llvm-project/clang/lib/Lex/Lexer.cpp index 75dcea2e1d5bc..087c6f13aea66 100644 --- a/interpreter/llvm-project/clang/lib/Lex/Lexer.cpp +++ b/interpreter/llvm-project/clang/lib/Lex/Lexer.cpp @@ -857,10 +857,6 @@ SourceLocation Lexer::getLocForEndOfToken(SourceLocation Loc, unsigned Offset, return {}; // Points inside the macro expansion. } - // Don't hit the file system for ASTReader tokens. - if (SM.isLoadedSourceLocation(Loc)) - return Loc; - unsigned Len = Lexer::MeasureTokenLength(Loc, SM, LangOpts); if (Len > Offset) Len = Len - Offset; diff --git a/interpreter/llvm-project/clang/lib/Lex/PPDirectives.cpp b/interpreter/llvm-project/clang/lib/Lex/PPDirectives.cpp index 19e49fc628c92..a29b73f97ab7e 100644 --- a/interpreter/llvm-project/clang/lib/Lex/PPDirectives.cpp +++ b/interpreter/llvm-project/clang/lib/Lex/PPDirectives.cpp @@ -988,7 +988,7 @@ OptionalFileEntryRef Preprocessor::LookupFile( // stack, record the parent #includes. SmallVector, 16> Includers; bool BuildSystemModule = false; - if (!FromDir && !FromFile && getCurrentFileLexer()) { + if (!FromDir && !FromFile) { FileID FID = getCurrentFileLexer()->getFileID(); OptionalFileEntryRef FileEnt = SourceMgr.getFileEntryRefForID(FID); diff --git a/interpreter/llvm-project/clang/lib/Sema/Sema.cpp b/interpreter/llvm-project/clang/lib/Sema/Sema.cpp index 1fa2e17c3a67e..e0eac690e6e65 100644 --- a/interpreter/llvm-project/clang/lib/Sema/Sema.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/Sema.cpp @@ -1517,7 +1517,7 @@ void Sema::ActOnEndOfTranslationUnit() { } if (!Diags.isIgnored(diag::warn_mismatched_delete_new, SourceLocation())) { - if (ExternalSource && !PP.isIncrementalProcessingEnabled()) + if (ExternalSource) ExternalSource->ReadMismatchingDeleteExpressions(DeleteExprs); for (const auto &DeletedFieldInfo : DeleteExprs) { for (const auto &DeleteExprLoc : DeletedFieldInfo.second) { @@ -1525,7 +1525,6 @@ void Sema::ActOnEndOfTranslationUnit() { DeleteExprLoc.second); } } - DeleteExprs.clear(); } AnalysisWarnings.IssueWarnings(Context.getTranslationUnitDecl()); diff --git a/interpreter/llvm-project/clang/lib/Sema/SemaCXXScopeSpec.cpp b/interpreter/llvm-project/clang/lib/Sema/SemaCXXScopeSpec.cpp index f72516003ad86..f04f7f9929442 100644 --- a/interpreter/llvm-project/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -190,7 +190,7 @@ CXXRecordDecl *Sema::getCurrentInstantiationOf(NestedNameSpecifier *NNS) { /// a class template specialization that is not a complete type, we /// will attempt to instantiate that class template. bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS, - DeclContext *&DC) { + DeclContext *DC) { assert(DC && "given null context"); TagDecl *tag = dyn_cast(DC); @@ -216,12 +216,6 @@ bool Sema::RequireCompleteDeclContext(CXXScopeSpec &SS, // The type must be complete. if (RequireCompleteType(loc, type, diag::err_incomplete_nested_name_spec, SS.getRange())) { - // The actual information about the decl may have been loaded via an - // external source that created a new AST node/decl for the definition - // rather than reusing the one we had (DC) like the ASTReader does. - // To avoid the caller to continue using the still incomplete decl, let's - // set it to the definition. - DC = tag->getDefinition(); SS.SetInvalid(SS.getRange()); return true; } @@ -450,15 +444,9 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, // nested-name-specifier. // The declaration context must be complete. - if (!LookupCtx->isDependentContext()) { - if (RequireCompleteDeclContext(SS, LookupCtx)) { - return true; - } else if (TagDecl* TD = dyn_cast(LookupCtx)) { - // Update the DeclContext to point to the Tag definition. - LookupCtx = TD->getDefinition(); - } - } - + if (!LookupCtx->isDependentContext() && + RequireCompleteDeclContext(SS, LookupCtx)) + return true; LookupQualifiedName(Found, LookupCtx); diff --git a/interpreter/llvm-project/clang/lib/Sema/SemaDecl.cpp b/interpreter/llvm-project/clang/lib/Sema/SemaDecl.cpp index 6054f97055acc..320ffba55c4bf 100644 --- a/interpreter/llvm-project/clang/lib/Sema/SemaDecl.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/SemaDecl.cpp @@ -352,14 +352,9 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, return nullptr; } - if (!LookupCtx->isDependentContext()) { - if (RequireCompleteDeclContext(*SS, LookupCtx)) { - return nullptr; - } else if (TagDecl* TD = dyn_cast(LookupCtx)) { - // Update the DeclContext to point to the Tag definition. - LookupCtx = TD->getDefinition(); - } - } + if (!LookupCtx->isDependentContext() && + RequireCompleteDeclContext(*SS, LookupCtx)) + return nullptr; } // In the case where we know that the identifier is a class name, we know that @@ -16924,28 +16919,6 @@ bool Sema::CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, return true; } } else if (IsFixed != Prev->isFixed()) { - // Determine whether this is a cling fwd decl. - auto hasFwdDeclAnnotation = [](const Decl *Prev) -> bool { - for(auto attr = Prev->specific_attr_begin(), - end = Prev->specific_attr_end (); - attr != end; - ++attr) - { - if (!attr->isInherited()) { - llvm::StringRef annotation = attr->getAnnotation(); - assert(!annotation.empty() && "Empty annotation!"); - if (annotation.starts_with("$clingAutoload$")) { - // autoload annotation. - return true; - } - } - } - return false; - }; - - if (hasFwdDeclAnnotation(Prev)) - return false; - Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch) << Prev->isFixed(); Diag(Prev->getLocation(), diag::note_previous_declaration); diff --git a/interpreter/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp b/interpreter/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp index 3a3e0738257aa..85de46c9adab4 100644 --- a/interpreter/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp @@ -542,8 +542,6 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, } } - (void)DiagDefaultParamID; -#if 0 // Disable until Diag is rewired // FIXME: If we knew where the '=' was, we could easily provide a fix-it // hint here. Alternatively, we could walk the type-source information // for NewParam to find the last source location in the type... but it @@ -565,7 +563,6 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Diag(OldParam->getLocation(), diag::note_previous_definition) << OldParam->getDefaultArgRange(); -#endif } else if (OldParamHasDfl) { // Merge the old default argument into the new parameter unless the new // function is a friend declaration in a template class. In the latter @@ -13243,7 +13240,7 @@ bool Sema::CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, if (Cxx20Enumerator) return false; // OK - DeclContext *RD = NamedContext + auto *RD = NamedContext ? cast(NamedContext->getRedeclContext()) : nullptr; if (RD && !RequireCompleteDeclContext(const_cast(SS), RD)) { diff --git a/interpreter/llvm-project/clang/lib/Sema/SemaExpr.cpp b/interpreter/llvm-project/clang/lib/Sema/SemaExpr.cpp index 40f4d895327e6..23d0f9532d4f8 100644 --- a/interpreter/llvm-project/clang/lib/Sema/SemaExpr.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/SemaExpr.cpp @@ -14840,47 +14840,6 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, switch (Opc) { case BO_Assign: - // ROOT hack: we want to support constructs like n = new TNamed() and if n - // wasn't declared we should declare it. - if (DeclRefExpr* DRE = dyn_cast(LHSExpr)) { - if (VarDecl* VD = dyn_cast(DRE->getDecl())) { - if (const AutoType* aTy = dyn_cast(VD->getType().getTypePtr())) { - if (const AnnotateAttr* A = VD->getAttr()) { - // If the deduction didn't take place and it is our special - // annotation - if (!aTy->isDeduced() && A->getAnnotation() == "__Auto") { - QualType ResTy; - ASTContext& C = getASTContext(); - TypeSourceInfo* TrivialTSI - = C.getTrivialTypeSourceInfo(VD->getType()); - TemplateDeductionInfo Info(RHSExpr->getExprLoc()); - TemplateDeductionResult Result = - DeduceAutoType(TrivialTSI->getTypeLoc(), RHSExpr, ResTy, Info); - if (Result != TemplateDeductionResult::Success && - Result != TemplateDeductionResult::AlreadyDiagnosed) { - Diag(VD->getLocation(), diag::err_auto_var_requires_init) - << VD->getDeclName() << VD->getType(); - VD->setInvalidDecl(); - - return ExprError(); - } - if (!ResTy.isNull()) { - VD->setTypeSourceInfo(C.getTrivialTypeSourceInfo(ResTy)); - VD->setType(ResTy); - } - VD->setInit(DefaultLvalueConversion(RHSExpr).get()); - PushOnScopeChains(VD, getCurScope(), /*Add to ctx*/true); - - // Here we need to return 'something' to make the parser happy. - // A reference to the decl is semantically closest to what we want. - return BuildDeclRefExpr(VD, VD->getType(), VK_LValue, - SourceLocation()); - } - } - } - } - } - ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, QualType(), Opc); if (getLangOpts().CPlusPlus && LHS.get()->getObjectKind() != OK_ObjCProperty) { diff --git a/interpreter/llvm-project/clang/lib/Sema/SemaExprCXX.cpp b/interpreter/llvm-project/clang/lib/Sema/SemaExprCXX.cpp index 47c9fd3f6134a..c6621402adfc9 100644 --- a/interpreter/llvm-project/clang/lib/Sema/SemaExprCXX.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/SemaExprCXX.cpp @@ -106,8 +106,7 @@ ParsedType Sema::getConstructorName(const IdentifierInfo &II, return ParsedType::make(T); } - DeclContext *DC = CurClass; - if (SS.isNotEmpty() && RequireCompleteDeclContext(SS, DC)) + if (SS.isNotEmpty() && RequireCompleteDeclContext(SS, CurClass)) return ParsedType(); // Find the injected-class-name declaration. Note that we make no attempt to diff --git a/interpreter/llvm-project/clang/lib/Sema/SemaLookup.cpp b/interpreter/llvm-project/clang/lib/Sema/SemaLookup.cpp index 1d2053050e6a6..0f5b7426e743e 100644 --- a/interpreter/llvm-project/clang/lib/Sema/SemaLookup.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/SemaLookup.cpp @@ -2277,14 +2277,8 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation, } } else { // Perform C++ unqualified name lookup. - if (CppLookupName(R, S)) { - if (R.isSingleResult()) - if (const TagDecl *TD = dyn_cast(R.getFoundDecl())) { - if (!TD->getDefinition() && ExternalSource) - ExternalSource->LookupUnqualified(R, S); - } + if (CppLookupName(R, S)) return true; - } } // If we didn't find a use of this identifier, and if the identifier diff --git a/interpreter/llvm-project/clang/lib/Sema/SemaTemplate.cpp b/interpreter/llvm-project/clang/lib/Sema/SemaTemplate.cpp index 0eb3fa3df743f..1c555b38277b0 100644 --- a/interpreter/llvm-project/clang/lib/Sema/SemaTemplate.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/SemaTemplate.cpp @@ -428,11 +428,6 @@ bool Sema::LookupTemplateName(LookupResult &Found, Scope *S, CXXScopeSpec &SS, // The declaration context must be complete. if (LookupCtx && RequireCompleteDeclContext(SS, LookupCtx)) return true; - - if (TagDecl* TD = dyn_cast_or_null(LookupCtx)) { - // Update the DeclContext to point to the Tag definition. - LookupCtx = TD->getDefinition(); - } } bool ObjectTypeSearchedInScope = false; @@ -1783,12 +1778,6 @@ static void SetNestedNameSpecifier(Sema &S, TagDecl *T, if (SS.isSet()) T->setQualifierInfo(SS.getWithLocInContext(S.Context)); } -static bool IsRootAutoloadDeclTemplate(ClassTemplateDecl *D) { - for (TagDecl *TD = D->getTemplatedDecl(); TD; TD = TD->getPreviousDecl()) - if (auto AnnotAttr = TD->getAttr()) - return AnnotAttr->getAnnotation().starts_with("$clingAutoload$"); - return false; -} // Returns the template parameter list with all default template argument // information. @@ -2075,20 +2064,6 @@ DeclResult Sema::CheckClassTemplate( return true; } - // AXEL - do not check for redecls of template arg defaults when parsing - // dictionary forward decls. - bool fwdDeclFromROOT = false; - for (const auto &A : Attr) { - if (A.getKind() != ParsedAttr::AT_Annotate) - continue; - if (A.getNumArgs() > 0 && A.isArgExpr(0)) - if (auto AnnotVal = dyn_cast(A.getArgAsExpr(0))) - if (AnnotVal->getString().starts_with("$clingAutoload$")) - fwdDeclFromROOT = true; - } - if (!fwdDeclFromROOT && PrevClassTemplate) - fwdDeclFromROOT = IsRootAutoloadDeclTemplate(PrevClassTemplate); - // Check the template parameter list of this declaration, possibly // merging in the template parameter list from the previous class // template declaration. Skip this check for a friend in a dependent @@ -2103,7 +2078,7 @@ DeclResult Sema::CheckClassTemplate( ? TPC_ClassTemplateMember : TUK == TagUseKind::Friend ? TPC_FriendClassTemplate : TPC_Other, - SkipBody, /*Complain*/!fwdDeclFromROOT)) + SkipBody)) Invalid = true; if (SS.isSet()) { @@ -2335,8 +2310,7 @@ static bool DiagnoseUnexpandedParameterPacks(Sema &S, bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, TemplateParameterList *OldParams, TemplateParamListContext TPC, - SkipBodyInfo *SkipBody, - bool Complain /*true*/) { + SkipBodyInfo *SkipBody) { bool Invalid = false; // C++ [temp.param]p10: @@ -2378,7 +2352,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, if (TemplateTypeParmDecl *NewTypeParm = dyn_cast(*NewParam)) { // Check the presence of a default argument here. - if (Complain && NewTypeParm->hasDefaultArgument() && + if (NewTypeParm->hasDefaultArgument() && DiagnoseDefaultTemplateArgument( *this, TPC, NewTypeParm->getLocation(), NewTypeParm->getDefaultArgument().getSourceRange())) @@ -2432,7 +2406,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, } // Check the presence of a default argument here. - if (Complain && NewNonTypeParm->hasDefaultArgument() && + if (NewNonTypeParm->hasDefaultArgument() && DiagnoseDefaultTemplateArgument( *this, TPC, NewNonTypeParm->getLocation(), NewNonTypeParm->getDefaultArgument().getSourceRange())) { @@ -2483,7 +2457,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, } // Check the presence of a default argument here. - if (Complain && NewTemplateParm->hasDefaultArgument() && + if (NewTemplateParm->hasDefaultArgument() && DiagnoseDefaultTemplateArgument(*this, TPC, NewTemplateParm->getLocation(), NewTemplateParm->getDefaultArgument().getSourceRange())) @@ -2537,14 +2511,6 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, Invalid = true; } - if (RedundantDefaultArg && - (((*OldParam)->hasAttr() && - (*OldParam)->getAttr()->getAnnotation() == "rootmap") || - ((*NewParam)->hasAttr() && - (*NewParam)->getAttr()->getAnnotation() == "rootmap"))) { - RedundantDefaultArg = false; - } - // [basic.def.odr]/13: // There can be more than one definition of a // ... @@ -2558,13 +2524,11 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, // argument to be repeated across translation unit. Note that the ODR is // checked elsewhere. But it is still not allowed to repeat template default // argument in the same translation unit. - if (Complain && RedundantDefaultArg) { -#if 0 // Disable until Diag is rewired + if (RedundantDefaultArg) { Diag(NewDefaultLoc, diag::err_template_param_default_arg_redefinition); Diag(OldDefaultLoc, diag::note_template_param_prev_default_arg); -#endif Invalid = true; - } else if (Complain && InconsistentDefaultArg) { + } else if (InconsistentDefaultArg) { // We could only diagnose about the case that the OldParam is imported. // The case NewParam is imported should be handled in ASTReader. Diag(NewDefaultLoc, @@ -2573,7 +2537,7 @@ bool Sema::CheckTemplateParameterList(TemplateParameterList *NewParams, diag::note_template_param_prev_default_arg_in_other_module) << PrevModuleName; Invalid = true; - } else if (Complain && MissingDefaultArg && + } else if (MissingDefaultArg && (TPC == TPC_Other || TPC == TPC_TemplateTemplateParameterPack || TPC == TPC_FriendClassTemplate)) { // C++ 23[temp.param]p14: diff --git a/interpreter/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp b/interpreter/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp index 2745ca0e718c9..73567f3be814d 100644 --- a/interpreter/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -4198,16 +4198,6 @@ static ActionResult getPatternForClassTemplateSpecialization( } Pattern = PartialSpec; } else { - // -- If no matches are found, the instantiation is generated - // from the primary template. - - // Try first to get it externally: - if(S.getExternalSource()) { - S.getExternalSource()->CompleteType(ClassTemplateSpec); - if (ClassTemplateSpec->getDefinition()) - return ClassTemplateSpec; - } - ClassTemplateDecl *Template = ClassTemplateSpec->getSpecializedTemplate(); while (Template->getInstantiatedFromMemberTemplate()) { // If we've found an explicit specialization of this class template, diff --git a/interpreter/llvm-project/clang/lib/Sema/SemaType.cpp b/interpreter/llvm-project/clang/lib/Sema/SemaType.cpp index fd3b936c195a1..77b52b832d771 100644 --- a/interpreter/llvm-project/clang/lib/Sema/SemaType.cpp +++ b/interpreter/llvm-project/clang/lib/Sema/SemaType.cpp @@ -9372,9 +9372,7 @@ bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T, // Give the external AST source a chance to complete the type. if (auto *Source = Context.getExternalSource()) { - // AXEL: allows ROOT to autoload/-parse template specializations before - // trying to instantiate through the template definition. See ROOT-7462. - if (Tag /*&& Tag->hasExternalLexicalStorage()*/) + if (Tag && Tag->hasExternalLexicalStorage()) Source->CompleteType(Tag); if (IFace && IFace->hasExternalLexicalStorage()) Source->CompleteType(IFace); diff --git a/interpreter/llvm-project/clang/lib/Serialization/ASTReader.cpp b/interpreter/llvm-project/clang/lib/Serialization/ASTReader.cpp index ac32f8bb8cad8..812f5173832d3 100644 --- a/interpreter/llvm-project/clang/lib/Serialization/ASTReader.cpp +++ b/interpreter/llvm-project/clang/lib/Serialization/ASTReader.cpp @@ -2049,14 +2049,6 @@ Token ASTReader::ReadToken(ModuleFile &M, const RecordDataImpl &Record, if (IdentifierInfo *II = getLocalIdentifier(M, Record[Idx++])) Tok.setIdentifierInfo(II); } - - if (Tok.isLiteral()) { - const RecordData& RD = reinterpret_cast(Record); - std::string* Lit = new std::string(ReadString(RD, Idx)); - TokenLiteralDataLoaded.push_back(Lit); - Tok.setLiteralData(Lit->c_str()); - } - return Tok; } @@ -2741,12 +2733,8 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) { // For an overridden file, create a virtual file with the stored // size/timestamp. - bool DisableValidation = bool(PP.getPreprocessorOpts().DisablePCHOrModuleValidation & - DisableValidationForModuleKind::All); - if ((Overridden || Transient || SkipChecks) && (!File || DisableValidation)) { + if ((Overridden || Transient || SkipChecks) && !File) File = FileMgr.getVirtualFileRef(*Filename, StoredSize, StoredTime); - Overridden = true; - } if (!File) { if (Complain) { @@ -3090,10 +3078,9 @@ ASTReader::ReadControlBlock(ModuleFile &F, // All user input files reside at the index range [0, NumUserInputs), and // system input files reside at [NumUserInputs, NumInputs). For explicitly // loaded module files, ignore missing inputs. - bool Validate = !DisableValidation && F.Kind != MK_ExplicitModule && - F.Kind != MK_PrebuiltModule; + if (!DisableValidation && F.Kind != MK_ExplicitModule && + F.Kind != MK_PrebuiltModule) { bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0; - Complain &= Validate; // If we are reading a module, we will create a verification timestamp, // so we verify all input files. Otherwise, verify only user input @@ -3105,13 +3092,12 @@ ASTReader::ReadControlBlock(ModuleFile &F, F.Kind == MK_ImplicitModule) N = NumUserInputs; - for (unsigned I = 0; I < NumInputs; ++I) { - if (I == N) - Complain = false; + for (unsigned I = 0; I < N; ++I) { InputFile IF = getInputFile(F, I+1, Complain); - if (Validate && (!IF.getFile() || IF.isOutOfDate())) + if (!IF.getFile() || IF.isOutOfDate()) return OutOfDate; } + } if (Listener) Listener->visitModuleFile(F.FileName, F.Kind); @@ -3159,7 +3145,7 @@ ASTReader::ReadControlBlock(ModuleFile &F, // // FIXME: Allow this for files explicitly specified with -include-pch. bool AllowCompatibleConfigurationMismatch = - F.Kind == MK_ExplicitModule || F.Kind == MK_PrebuiltModule; + F.Kind == MK_ExplicitModule || F.Kind == MK_PrebuiltModule; ASTReadResult Result = ReadOptionsBlock(Stream, F.FileName, ClientLoadCapabilities, @@ -3318,28 +3304,6 @@ ASTReader::ReadControlBlock(ModuleFile &F, } } - // Check if ImportedFile exists on disk - if (!llvm::sys::fs::is_directory(ImportedFile)) { - StringRef ModuleName = llvm::sys::path::filename(ImportedFile.c_str()); - ModuleName.consume_back(".pcm"); - // Get clang::Module pointer by looking up the module name - HeaderSearch &HS = PP.getHeaderSearchInfo(); - Module *M = HS.lookupModule(ModuleName, SourceLocation(), - /*AllowSearch*/ true, - /*AllowExtraModuleMapSearch*/ true); - if (M) { - std::string Path = HS.getPrebuiltModuleFileName(M->Name); - if (Path.empty()) - Path = HS.getCachedModuleFileName( - M->Name, - HS.getModuleMap().getModuleMapFileForUniquing(M)->getName()); - // FIXME: Add a hash comparison to check if ImportedFile's hash and - // the new Modules Path's hash matches or not. - if (!Path.empty()) - ImportedFile = Path; - } - } - // If our client can't cope with us being out of date, we can't cope with // our dependency being missing. unsigned Capabilities = ClientLoadCapabilities; @@ -4385,32 +4349,10 @@ void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const { ? ModuleMgr.lookupByModuleName(Name) : ModuleMgr.lookupByFileName(Name)); if (!OM) { - StringRef ModuleName = llvm::sys::path::filename(Name); - ModuleName.consume_back(".pcm"); - HeaderSearch &HS = PP.getHeaderSearchInfo(); - Module *M = HS.lookupModule(ModuleName, SourceLocation(), - /*AllowSearch*/ true, - /*AllowExtraModuleMapSearch*/ true); - std::string Path; - // If module definition exists in modulemap, search the modulepath in - // HeaderSearchInfo - if (M) { - Path = HS.getPrebuiltModuleFileName(M->Name); - if (Path.empty()) - Path = HS.getCachedModuleFileName( - M->Name, - HS.getModuleMap().getModuleMapFileForUniquing(M)->getName()); - } - - StringRef NewName = StringRef(Path); - OM = ModuleMgr.lookupByFileName(NewName); - if (!OM) { - std::string Msg = - "SourceLocation remap refers to unknown module, cannot find "; - Msg.append(std::string(NewName)); - Error(Msg); - return; - } + std::string Msg = "refers to unknown module, cannot find "; + Msg.append(std::string(Name)); + Error(Msg); + return; } ImportedModuleVector.push_back(OM); @@ -4490,15 +4432,9 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F, assert(M && M->Name == F.ModuleName && "found module with different name"); - // Check any additional module map files (e.g. module.private.modulemap) - // that are not in the pcm. - bool DisableValidation = - PP.getPreprocessorOpts().DisablePCHOrModuleValidation != - DisableValidationForModuleKind::None; - // Check the primary module map file. auto StoredModMap = FileMgr.getOptionalFileRef(F.ModuleMapPath); - if (!DisableValidation && (!StoredModMap || *StoredModMap != ModMap)) { + if (!StoredModMap || *StoredModMap != ModMap) { assert(ModMap && "found module is missing module map file"); assert((ImportedBy || F.Kind == MK_ImplicitModule) && "top-level import should be verified"); @@ -4523,7 +4459,8 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F, AdditionalStoredMaps.insert(*SF); } - if (!DisableValidation) { + // Check any additional module map files (e.g. module.private.modulemap) + // that are not in the pcm. if (auto *AdditionalModuleMaps = Map.getAdditionalModuleMapFiles(M)) { for (FileEntryRef ModMap : *AdditionalModuleMaps) { // Remove files that match @@ -4546,7 +4483,6 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F, return OutOfDate; } } - } if (Listener) Listener->ReadModuleMapFile(F.ModuleMapPath); @@ -7947,8 +7883,14 @@ void ASTReader::CompleteRedeclChain(const Decl *D) { } } - if (Template) - Template->loadLazySpecializationsImpl(Args); + if (Template) { + // For partitial specialization, load all the specializations for safety. + if (isa(D)) + Template->loadLazySpecializationsImpl(); + else + Template->loadLazySpecializationsImpl(Args); + } } CXXCtorInitializer ** @@ -10972,9 +10914,6 @@ ASTReader::ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache, ASTReader::~ASTReader() { if (OwnsDeserializationListener) delete DeserializationListener; - for (auto PStr: TokenLiteralDataLoaded) { - delete PStr; - } } IdentifierResolver &ASTReader::getIdResolver() { diff --git a/interpreter/llvm-project/clang/lib/Serialization/ASTReaderInternals.h b/interpreter/llvm-project/clang/lib/Serialization/ASTReaderInternals.h index cacef385acc45..4be2b2323ec40 100644 --- a/interpreter/llvm-project/clang/lib/Serialization/ASTReaderInternals.h +++ b/interpreter/llvm-project/clang/lib/Serialization/ASTReaderInternals.h @@ -46,7 +46,7 @@ class ASTDeclContextNameLookupTraitBase { public: // Maximum number of lookup tables we allow before condensing the tables. - static const int MaxTables = 256; + static const int MaxTables = 4; /// The lookup result is a list of global declaration IDs. using data_type = SmallVector; diff --git a/interpreter/llvm-project/clang/lib/Serialization/ASTWriter.cpp b/interpreter/llvm-project/clang/lib/Serialization/ASTWriter.cpp index 4333f0b95b853..2d0fae8b64d07 100644 --- a/interpreter/llvm-project/clang/lib/Serialization/ASTWriter.cpp +++ b/interpreter/llvm-project/clang/lib/Serialization/ASTWriter.cpp @@ -5227,9 +5227,6 @@ void ASTWriter::AddToken(const Token &Tok, RecordDataImpl &Record) { // is needed. AddIdentifierRef(Tok.getIdentifierInfo(), Record); } - - if (Tok.isLiteral()) - AddString(StringRef(Tok.getLiteralData(), Tok.getLength()), Record); } void ASTWriter::AddString(StringRef Str, RecordDataImpl &Record) { diff --git a/interpreter/llvm-project/clang/lib/Serialization/TemplateArgumentHasher.cpp b/interpreter/llvm-project/clang/lib/Serialization/TemplateArgumentHasher.cpp index b08d6c25de6f9..5fd6941256fe2 100644 --- a/interpreter/llvm-project/clang/lib/Serialization/TemplateArgumentHasher.cpp +++ b/interpreter/llvm-project/clang/lib/Serialization/TemplateArgumentHasher.cpp @@ -21,6 +21,17 @@ using namespace clang; namespace { class TemplateArgumentHasher { + // If we bail out during the process of calculating hash values for + // template arguments for any reason. We're allowed to do it since + // TemplateArgumentHasher are only required to give the same hash value + // for the same template arguments, but not required to give different + // hash value for different template arguments. + // + // So in the worst case, it is still a valid implementation to give all + // inputs the same BailedOutValue as output. + bool BailedOut = false; + static constexpr unsigned BailedOutValue = 0x12345678; + llvm::FoldingSetNodeID ID; public: @@ -30,7 +41,14 @@ class TemplateArgumentHasher { void AddInteger(unsigned V) { ID.AddInteger(V); } - unsigned getValue() { return ID.computeStableHash(); } + unsigned getValue() { + if (BailedOut) + return BailedOutValue; + + return ID.computeStableHash(); + } + + void setBailedOut() { BailedOut = true; } void AddType(const Type *T); void AddQualType(QualType T); @@ -76,7 +94,8 @@ void TemplateArgumentHasher::AddTemplateArgument(TemplateArgument TA) { case TemplateArgument::Expression: // If we meet expression in template argument, it implies // that the template is still dependent. It is meaningless - // to get a stable hash for the template. + // to get a stable hash for the template. Bail out simply. + BailedOut = true; break; case TemplateArgument::Pack: AddInteger(TA.pack_size()); @@ -93,9 +112,10 @@ void TemplateArgumentHasher::AddStructuralValue(const APValue &Value) { // 'APValue::Profile' uses pointer values to make hash for LValue and // MemberPointer, but they differ from one compiler invocation to another. - // It may be difficult to handle such cases. + // It may be difficult to handle such cases. Bail out simply. if (Kind == APValue::LValue || Kind == APValue::MemberPointer) { + BailedOut = true; return; } @@ -117,11 +137,14 @@ void TemplateArgumentHasher::AddTemplateName(TemplateName Name) { case TemplateName::DependentTemplate: case TemplateName::SubstTemplateTemplateParm: case TemplateName::SubstTemplateTemplateParmPack: + BailedOut = true; break; case TemplateName::UsingTemplate: { UsingShadowDecl *USD = Name.getAsUsingShadowDecl(); if (USD) AddDecl(USD->getTargetDecl()); + else + BailedOut = true; break; } case TemplateName::DeducedTemplate: @@ -146,6 +169,7 @@ void TemplateArgumentHasher::AddDeclarationName(DeclarationName Name) { case DeclarationName::ObjCZeroArgSelector: case DeclarationName::ObjCOneArgSelector: case DeclarationName::ObjCMultiArgSelector: + BailedOut = true; break; case DeclarationName::CXXConstructorName: case DeclarationName::CXXDestructorName: @@ -172,29 +196,16 @@ void TemplateArgumentHasher::AddDeclarationName(DeclarationName Name) { void TemplateArgumentHasher::AddDecl(const Decl *D) { const NamedDecl *ND = dyn_cast(D); if (!ND) { + BailedOut = true; return; } AddDeclarationName(ND->getDeclName()); - - // If this was a specialization we should take into account its template - // arguments. This helps to reduce collisions coming when visiting template - // specialization types (eg. when processing type template arguments). - ArrayRef Args; - if (auto *CTSD = dyn_cast(D)) - Args = CTSD->getTemplateArgs().asArray(); - else if (auto *VTSD = dyn_cast(D)) - Args = VTSD->getTemplateArgs().asArray(); - else if (auto *FD = dyn_cast(D)) - if (FD->getTemplateSpecializationArgs()) - Args = FD->getTemplateSpecializationArgs()->asArray(); - - for (auto &TA : Args) - AddTemplateArgument(TA); } void TemplateArgumentHasher::AddQualType(QualType T) { if (T.isNull()) { + BailedOut = true; return; } SplitQualType split = T.split(); @@ -204,6 +215,7 @@ void TemplateArgumentHasher::AddQualType(QualType T) { // Process a Type pointer. Add* methods call back into TemplateArgumentHasher // while Visit* methods process the relevant parts of the Type. +// Any unhandled type will make the hash computation bail out. class TypeVisitorHelper : public TypeVisitor { typedef TypeVisitor Inherited; llvm::FoldingSetNodeID &ID; @@ -235,6 +247,9 @@ class TypeVisitorHelper : public TypeVisitor { void Visit(const Type *T) { Inherited::Visit(T); } + // Unhandled types. Bail out simply. + void VisitType(const Type *T) { Hash.setBailedOut(); } + void VisitAdjustedType(const AdjustedType *T) { AddQualType(T->getOriginalType()); } diff --git a/interpreter/llvm-project/clang/utils/TableGen/ClangAttrEmitter.cpp b/interpreter/llvm-project/clang/utils/TableGen/ClangAttrEmitter.cpp index b1d9c2250b483..de12c7062666a 100644 --- a/interpreter/llvm-project/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/interpreter/llvm-project/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -488,13 +488,12 @@ namespace { } void writeValue(raw_ostream &OS) const override { - OS << "R\\\"ATTRDUMP(\" << get" << getUpperName() - << "() << \")ATTRDUMP\\\""; + OS << "\\\"\" << get" << getUpperName() << "() << \"\\\""; } void writeDump(raw_ostream &OS) const override { - OS << " OS << \" R\\\"ATTRDUMP(\" << SA->get" << getUpperName() - << "() << \")ATTRDUMP\\\"\";\n"; + OS << " OS << \" \\\"\" << SA->get" << getUpperName() + << "() << \"\\\"\";\n"; } };