Skip to content

Commit 92de1d9

Browse files
committed
Merge commit 'a2f9d1d078ce' from llvm.org/main into next
2 parents d4f942c + a2f9d1d commit 92de1d9

File tree

9 files changed

+145
-119
lines changed

9 files changed

+145
-119
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
492492
llvm::StringMap<const Module *> PrimaryModuleNameMap;
493493
llvm::DenseMap<const Module *, const Module *> SameModuleLookupSet;
494494

495-
/// The include tree that is being built, if any.
496-
/// See \c FrontendOptions::CASIncludeTreeID.
497-
std::optional<std::string> CASIncludeTreeID;
498-
499-
/// The cas-fs tree that is being built, if any.
500-
/// See \c FileSystemOptions::CASFileSystemRootID.
501-
std::optional<std::string> CASFileSystemRootID;
502-
503495
static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
504496
static constexpr unsigned GeneralTypesLog2InitSize = 9;
505497
static constexpr unsigned FunctionProtoTypesLog2InitSize = 12;
@@ -1160,20 +1152,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
11601152
/// a module fragment or a module unit but not a C++20 module.
11611153
bool isInSameModule(const Module *M1, const Module *M2);
11621154

1163-
std::optional<std::string> getCASIncludeTreeID() const {
1164-
return CASIncludeTreeID;
1165-
}
1166-
void setCASIncludeTreeID(std::string ID) {
1167-
CASIncludeTreeID = std::move(ID);
1168-
}
1169-
1170-
std::optional<std::string> getCASFileSystemRootID() const {
1171-
return CASFileSystemRootID;
1172-
}
1173-
void setCASFileSystemRootID(std::string ID) {
1174-
CASFileSystemRootID = std::move(ID);
1175-
}
1176-
11771155
TranslationUnitDecl *getTranslationUnitDecl() const {
11781156
return TUDecl->getMostRecentDecl();
11791157
}

clang/include/clang/Lex/Preprocessor.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2433,6 +2433,28 @@ class Preprocessor {
24332433
!IsAtImport;
24342434
}
24352435

2436+
private:
2437+
/// The include tree that is being built, if any.
2438+
/// See \c FrontendOptions::CASIncludeTreeID.
2439+
std::optional<std::string> CASIncludeTreeID;
2440+
2441+
/// The cas-fs tree that is being built, if any.
2442+
/// See \c FileSystemOptions::CASFileSystemRootID.
2443+
std::optional<std::string> CASFileSystemRootID;
2444+
2445+
public:
2446+
std::optional<std::string> getCASIncludeTreeID() const {
2447+
return CASIncludeTreeID;
2448+
}
2449+
void setCASIncludeTreeID(std::string ID) { CASIncludeTreeID = std::move(ID); }
2450+
2451+
std::optional<std::string> getCASFileSystemRootID() const {
2452+
return CASFileSystemRootID;
2453+
}
2454+
void setCASFileSystemRootID(std::string ID) {
2455+
CASFileSystemRootID = std::move(ID);
2456+
}
2457+
24362458
/// Allocate a new MacroInfo object with the provided SourceLocation.
24372459
MacroInfo *AllocateMacroInfo(SourceLocation L);
24382460

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,7 @@ class ASTWriter : public ASTDeserializationListener,
548548
void WriteSubStmt(ASTContext &Context, Stmt *S);
549549

550550
void WriteBlockInfoBlock();
551-
void WriteControlBlock(ASTContext &Context, Preprocessor &PP,
552-
StringRef isysroot);
551+
void WriteControlBlock(Preprocessor &PP, StringRef isysroot);
553552

554553
/// Write out the signature and diagnostic options, and return the signature.
555554
void writeUnhashedControlBlock(Preprocessor &PP);
@@ -565,7 +564,7 @@ class ASTWriter : public ASTDeserializationListener,
565564
void WriteHeaderSearch(const HeaderSearch &HS);
566565
void WritePreprocessorDetail(PreprocessingRecord &PPRec,
567566
uint64_t MacroOffsetsBase);
568-
void WriteSubmodules(Module *WritingModule, ASTContext &Context);
567+
void WriteSubmodules(Module *WritingModule, ASTContext *Context);
569568

570569
void WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
571570
bool isModule);
@@ -586,7 +585,7 @@ class ASTWriter : public ASTDeserializationListener,
586585
void WriteComments(ASTContext &Context);
587586
void WriteSelectors(Sema &SemaRef);
588587
void WriteReferencedSelectorsPool(Sema &SemaRef);
589-
void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver &IdResolver,
588+
void WriteIdentifierTable(Preprocessor &PP, IdentifierResolver *IdResolver,
590589
bool IsModule);
591590
void WriteDeclAndTypes(ASTContext &Context);
592591
void PrepareWritingSpecialDecls(Sema &SemaRef);
@@ -643,7 +642,7 @@ class ASTWriter : public ASTDeserializationListener,
643642
void WriteDeclAbbrevs();
644643
void WriteDecl(ASTContext &Context, Decl *D);
645644

646-
ASTFileSignature WriteASTCore(Sema &SemaRef, StringRef isysroot,
645+
ASTFileSignature WriteASTCore(Sema *SemaPtr, StringRef isysroot,
647646
Module *WritingModule);
648647

649648
public:
@@ -663,10 +662,13 @@ class ASTWriter : public ASTDeserializationListener,
663662
/// include timestamps in the output file.
664663
time_t getTimestampForOutput(const FileEntry *E) const;
665664

666-
/// Write a precompiled header for the given semantic analysis.
665+
/// Write a precompiled header or a module with the AST produced by the
666+
/// \c Sema object, or a dependency scanner module with the preprocessor state
667+
/// produced by the \c Preprocessor object.
667668
///
668-
/// \param SemaRef a reference to the semantic analysis object that processed
669-
/// the AST to be written into the precompiled header.
669+
/// \param Subject The \c Sema object that processed the AST to be written, or
670+
/// in the case of a dependency scanner module the \c Preprocessor that holds
671+
/// the state.
670672
///
671673
/// \param WritingModule The module that we are writing. If null, we are
672674
/// writing a precompiled header.
@@ -677,8 +679,9 @@ class ASTWriter : public ASTDeserializationListener,
677679
///
678680
/// \return the module signature, which eventually will be a hash of
679681
/// the module but currently is merely a random 32-bit number.
680-
ASTFileSignature WriteAST(Sema &SemaRef, StringRef OutputFile,
681-
Module *WritingModule, StringRef isysroot,
682+
ASTFileSignature WriteAST(llvm::PointerUnion<Sema *, Preprocessor *> Subject,
683+
StringRef OutputFile, Module *WritingModule,
684+
StringRef isysroot,
682685
bool ShouldCacheASTInMemory = false);
683686

684687
/// Emit a token.

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,7 @@ bool ASTUnit::Save(StringRef File) {
23622362

23632363
static bool serializeUnit(ASTWriter &Writer, SmallVectorImpl<char> &Buffer,
23642364
Sema &S, raw_ostream &OS) {
2365-
Writer.WriteAST(S, std::string(), nullptr, "");
2365+
Writer.WriteAST(&S, std::string(), nullptr, "");
23662366

23672367
// Write the generated bitstream to "Out".
23682368
if (!Buffer.empty())

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
12081208
}
12091209

12101210
if (!CI.getFrontendOpts().CASIncludeTreeID.empty())
1211-
CI.getASTContext().setCASIncludeTreeID(
1211+
CI.getPreprocessor().setCASIncludeTreeID(
12121212
CI.getFrontendOpts().CASIncludeTreeID);
12131213

12141214
CI.setASTConsumer(std::move(Consumer));

0 commit comments

Comments
 (0)