Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
cb777d8
Revert all downstream commits
devajithvs Nov 27, 2025
fb9837d
Revert "Implement FileManager uncaching."
vgvassilev Mar 18, 2014
150073d
Revert "Accessor to "is file opened"; this is crucial info for us."
Axel-Naumann Oct 20, 2014
471a09e
Revert "[clang] Add API to iterate already loaded specializations"
hahnjo Jul 3, 2023
4758f84
Add Parser::ParserCurTokRestoreRAII
vgvassilev Nov 16, 2012
7e154c7
Access sema internals and revert the list of unused decls.
vgvassilev Mar 28, 2014
fa5b12a
More RAIIs for autoloading.
Axel-Naumann Aug 26, 2013
e500ba0
Also store Parser paren numbers; likely fixes ROOT-6976:
Axel-Naumann Jan 8, 2015
ad412fd
Provide (possibly updated) CodegenOpts to StartModule.
Axel-Naumann Jan 7, 2015
ebe65dc
Restore pre-LLVM20 behaviour in HeaderSearch::LookupFile
devajithvs Sep 19, 2025
5013e50
Implement a module attribute 'optional' to allow missing headers.
vgvassilev Mar 27, 2023
fa0a2aa
Remove macro and print macro.
CristinaCristescu Oct 29, 2013
794cbae
Cleanup cached constant (.str) from codegen.
Axel-Naumann Apr 6, 2016
ec89922
Buffer the pending instantiations in case or recursive parsing.
Axel-Naumann Dec 2, 2014
938bb4c
Add method to forget generated declarations
hahnjo Jul 11, 2023
959189e
Add (debug) printout of ModuleBuilder data structures
vgvassilev Feb 27, 2014
4452e7b
Add RAII to buffer delayed infos, for recursive parsing.
Axel-Naumann Jul 22, 2016
65b481f
Refactor generation counter in LLVM
vgvassilev Mar 28, 2018
cf31991
Import various changes to the global module index.
vgvassilev Aug 15, 2020
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
16 changes: 8 additions & 8 deletions interpreter/cling/lib/Interpreter/ClangInternalState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
26 changes: 13 additions & 13 deletions interpreter/cling/lib/Interpreter/DeclUnloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions interpreter/cling/lib/Interpreter/TransactionUnloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
42 changes: 0 additions & 42 deletions interpreter/llvm-project/clang/include/clang/AST/DeclTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<typename T> void foo(auto x)`
bool isAbbreviated() const {
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include <map>
#include <memory>
#include <string>
#include <set>

namespace llvm {

Expand Down Expand Up @@ -108,11 +107,6 @@ class FileManager : public RefCountedBase<FileManager> {
/// The canonical names of files and directories .
llvm::DenseMap<const void *, llvm::StringRef> CanonicalNames;

std::set<const FileEntry*> FileEntriesToReread;

/// The canonical names of directories.
llvm::DenseMap<const DirectoryEntry *, llvm::StringRef> CanonicalDirNames;

/// Storage for canonical names that we have computed.
llvm::BumpPtrAllocator CanonicalNameStorage;

Expand Down Expand Up @@ -332,9 +326,6 @@ class FileManager : public RefCountedBase<FileManager> {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class alignas(8) ContentCache {

/// Set the buffer.
void setBuffer(std::unique_ptr<llvm::MemoryBuffer> B) {
IsBufferInvalid = !B;
IsBufferInvalid = false;
Buffer = std::move(B);
}

Expand Down Expand Up @@ -845,8 +845,6 @@ class SourceManager : public RefCountedBase<SourceManager> {

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);
Expand Down
6 changes: 3 additions & 3 deletions interpreter/llvm-project/clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,9 +757,6 @@ class ASTReader
/// files.
llvm::DenseSet<LoadedMacroInfo> LoadedUndefs;

/// \Token literal data loaded and owned by us.
std::vector<std::string *> TokenLiteralDataLoaded;

using GlobalMacroMapType =
ContinuousRangeMap<serialization::MacroID, ModuleFile *, 4>;

Expand Down
2 changes: 1 addition & 1 deletion interpreter/llvm-project/clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10080,7 +10080,7 @@ Expected<FileID> ASTImporter::Import(FileID FromID, bool IsBuiltin) {
// FIXME: We want to re-use the existing MemoryBuffer!
std::optional<llvm::MemoryBufferRef> FromBuf =
Cache->getBufferOrNone(FromContext.getDiagnostics(),
FromFileManager, SourceLocation{});
FromSM.getFileManager(), SourceLocation{});
if (!FromBuf)
return llvm::make_error<ASTImportError>(ASTImportError::Unknown);

Expand Down
6 changes: 6 additions & 0 deletions interpreter/llvm-project/clang/lib/AST/DeclTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 1 addition & 7 deletions interpreter/llvm-project/clang/lib/AST/TemplateBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 1 addition & 23 deletions interpreter/llvm-project/clang/lib/Basic/Diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
45 changes: 4 additions & 41 deletions interpreter/llvm-project/clang/lib/Basic/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,25 +221,7 @@ llvm::Expected<FileEntryRef> 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<FileEntry *>()) {
auto found = FileEntriesToReread.find(Value.V.get<FileEntry*>());
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());
Expand All @@ -248,6 +230,8 @@ llvm::Expected<FileEntryRef> 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.
Expand Down Expand Up @@ -351,9 +335,7 @@ llvm::Expected<FileEntryRef> 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;
}

Expand All @@ -373,20 +355,6 @@ llvm::Expected<FileEntryRef> 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<FileEntry *>()
&& Value.V.get<FileEntry*>() == StaleFileEntry) {
fe.setValue(FileEntryRef::MapValue(*UFE, DirInfo));
}
}
}
}

return ReturnedRef;
}

Expand Down Expand Up @@ -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<OptionalFileEntryRef> &UIDToFiles) const {
UIDToFiles.clear();
Expand Down
Loading
Loading