-
Notifications
You must be signed in to change notification settings - Fork 15k
NFC: Clean up of IntrusiveRefCntPtr construction from raw pointers. #151782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…lang::ExternalASTSource.
…lang::SourceManager
…lang::FileManager
|
@llvm/pr-subscribers-clang-modules @llvm/pr-subscribers-clang-static-analyzer-1 Author: James Y Knight (jyknight) ChangesThis commit handles the following types:
Part of cleanup #151026 Patch is 71.81 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/151782.diff 41 Files Affected:
diff --git a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
index 7b0e4ecda8214..30bb313524cbe 100644
--- a/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
+++ b/clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
@@ -53,7 +53,7 @@ class Action : public clang::ASTFrontendAction {
Compiler->createSema(getTranslationUnitKind(), CompletionConsumer);
SemaSource->setCompilerInstance(Compiler);
- Compiler->getSema().addExternalSource(SemaSource.get());
+ Compiler->getSema().addExternalSource(SemaSource);
clang::ParseAST(Compiler->getSema(), Compiler->getFrontendOpts().ShowStats,
Compiler->getFrontendOpts().SkipFunctionBodies);
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 3b98274a80420..db86963bdf80e 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1335,6 +1335,12 @@ class ASTContext : public RefCountedBase<ASTContext> {
return ExternalSource.get();
}
+ /// Retrieve a pointer to the external AST source associated
+ /// with this AST context, if any. Returns as an IntrusiveRefCntPtr.
+ IntrusiveRefCntPtr<ExternalASTSource> getExternalSourcePtr() const {
+ return ExternalSource;
+ }
+
/// Attach an AST mutation listener to the AST context.
///
/// The AST mutation listener provides the ability to track modifications to
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 7dd9aeff12217..ad54016da11d2 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -451,6 +451,9 @@ class ASTUnit {
const SourceManager &getSourceManager() const { return *SourceMgr; }
SourceManager &getSourceManager() { return *SourceMgr; }
+ llvm::IntrusiveRefCntPtr<SourceManager> getSourceManagerPtr() {
+ return SourceMgr;
+ }
const Preprocessor &getPreprocessor() const { return *PP; }
Preprocessor &getPreprocessor() { return *PP; }
@@ -458,8 +461,11 @@ class ASTUnit {
const ASTContext &getASTContext() const { return *Ctx; }
ASTContext &getASTContext() { return *Ctx; }
+ llvm::IntrusiveRefCntPtr<ASTContext> getASTContextPtr() { return Ctx; }
- void setASTContext(ASTContext *ctx) { Ctx = ctx; }
+ void setASTContext(llvm::IntrusiveRefCntPtr<ASTContext> ctx) {
+ Ctx = std::move(ctx);
+ }
void setPreprocessor(std::shared_ptr<Preprocessor> pp);
/// Enable source-range based diagnostic messages.
@@ -495,6 +501,7 @@ class ASTUnit {
const FileManager &getFileManager() const { return *FileMgr; }
FileManager &getFileManager() { return *FileMgr; }
+ IntrusiveRefCntPtr<FileManager> getFileManagerPtr() { return FileMgr; }
const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; }
@@ -803,8 +810,8 @@ class ASTUnit {
std::shared_ptr<CompilerInvocation> CI,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
std::shared_ptr<DiagnosticOptions> DiagOpts,
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
- bool OnlyLocalDecls = false,
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
+ IntrusiveRefCntPtr<FileManager> FileMgr, bool OnlyLocalDecls = false,
CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
unsigned PrecompilePreambleAfterNParses = 0,
TranslationUnitKind TUKind = TU_Complete,
@@ -922,8 +929,9 @@ class ASTUnit {
CodeCompleteConsumer &Consumer,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diag,
- LangOptions &LangOpts, SourceManager &SourceMgr,
- FileManager &FileMgr,
+ LangOptions &LangOpts,
+ llvm::IntrusiveRefCntPtr<SourceManager> SourceMgr,
+ llvm::IntrusiveRefCntPtr<FileManager> FileMgr,
SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics,
SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers,
std::unique_ptr<SyntaxOnlyAction> Act);
diff --git a/clang/include/clang/Frontend/CompilerInstance.h b/clang/include/clang/Frontend/CompilerInstance.h
index a24decd620a65..64ebb70a6a24c 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -446,7 +446,7 @@ class CompilerInstance : public ModuleLoader {
}
/// Replace the current file manager and virtual file system.
- void setFileManager(FileManager *Value);
+ void setFileManager(IntrusiveRefCntPtr<FileManager> Value);
/// @}
/// @name Source Manager
@@ -471,7 +471,7 @@ class CompilerInstance : public ModuleLoader {
}
/// setSourceManager - Replace the current source manager.
- void setSourceManager(SourceManager *Value);
+ void setSourceManager(llvm::IntrusiveRefCntPtr<SourceManager> Value);
/// @}
/// @name Preprocessor
@@ -516,7 +516,7 @@ class CompilerInstance : public ModuleLoader {
}
/// setASTContext - Replace the current AST context.
- void setASTContext(ASTContext *Value);
+ void setASTContext(llvm::IntrusiveRefCntPtr<ASTContext> Value);
/// Replace the current Sema; the compiler instance takes ownership
/// of S.
diff --git a/clang/include/clang/Frontend/Utils.h b/clang/include/clang/Frontend/Utils.h
index 604e42067a3f1..f86c2f5074de0 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -189,7 +189,7 @@ void AttachHeaderIncludeGen(Preprocessor &PP,
/// memory, mainly for testing.
IntrusiveRefCntPtr<ExternalSemaSource>
createChainedIncludesSource(CompilerInstance &CI,
- IntrusiveRefCntPtr<ExternalSemaSource> &Reader);
+ IntrusiveRefCntPtr<ASTReader> &OutReader);
/// Optional inputs to createInvocation.
struct CreateInvocationOptions {
diff --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
index 391c2177d75ec..8bcaa121b3039 100644
--- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -40,7 +40,7 @@ class MultiplexExternalSemaSource : public ExternalSemaSource {
static char ID;
private:
- SmallVector<ExternalSemaSource *, 2> Sources;
+ SmallVector<llvm::IntrusiveRefCntPtr<ExternalSemaSource>, 2> Sources;
public:
/// Constructs a new multiplexing external sema source and appends the
@@ -49,15 +49,14 @@ class MultiplexExternalSemaSource : public ExternalSemaSource {
///\param[in] S1 - A non-null (old) ExternalSemaSource.
///\param[in] S2 - A non-null (new) ExternalSemaSource.
///
- MultiplexExternalSemaSource(ExternalSemaSource *S1, ExternalSemaSource *S2);
-
- ~MultiplexExternalSemaSource() override;
+ MultiplexExternalSemaSource(llvm::IntrusiveRefCntPtr<ExternalSemaSource> S1,
+ llvm::IntrusiveRefCntPtr<ExternalSemaSource> S2);
/// Appends new source to the source list.
///
///\param[in] Source - An ExternalSemaSource.
///
- void AddSource(ExternalSemaSource *Source);
+ void AddSource(llvm::IntrusiveRefCntPtr<ExternalSemaSource> Source);
//===--------------------------------------------------------------------===//
// ExternalASTSource.
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 423dcf9e2b708..0b2c027e6da67 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -927,7 +927,7 @@ class Sema final : public SemaBase {
///
///\param[in] E - A non-null external sema source.
///
- void addExternalSource(ExternalSemaSource *E);
+ void addExternalSource(IntrusiveRefCntPtr<ExternalSemaSource> E);
/// Print out statistics about the semantic analysis.
void PrintStats() const;
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 5711f454a9c9e..a4078257a889f 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -831,11 +831,10 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
AST->CaptureDiagnostics = CaptureDiagnostics;
AST->DiagOpts = DiagOpts;
AST->Diagnostics = Diags;
- AST->FileMgr = new FileManager(FileSystemOpts, VFS);
+ AST->FileMgr = llvm::makeIntrusiveRefCnt<FileManager>(FileSystemOpts, VFS);
AST->UserFilesAreVolatile = UserFilesAreVolatile;
- AST->SourceMgr = new SourceManager(AST->getDiagnostics(),
- AST->getFileManager(),
- UserFilesAreVolatile);
+ AST->SourceMgr = llvm::makeIntrusiveRefCnt<SourceManager>(
+ AST->getDiagnostics(), AST->getFileManager(), UserFilesAreVolatile);
AST->ModCache = createCrossProcessModuleCache();
AST->HSOpts = std::make_unique<HeaderSearchOptions>(HSOpts);
AST->HSOpts->ModuleFormat = std::string(PCHContainerRdr.getFormats().front());
@@ -858,20 +857,20 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
Preprocessor &PP = *AST->PP;
if (ToLoad >= LoadASTOnly)
- AST->Ctx = new ASTContext(*AST->LangOpts, AST->getSourceManager(),
- PP.getIdentifierTable(), PP.getSelectorTable(),
- PP.getBuiltinInfo(),
- AST->getTranslationUnitKind());
+ AST->Ctx = llvm::makeIntrusiveRefCnt<ASTContext>(
+ *AST->LangOpts, AST->getSourceManager(), PP.getIdentifierTable(),
+ PP.getSelectorTable(), PP.getBuiltinInfo(),
+ AST->getTranslationUnitKind());
DisableValidationForModuleKind disableValid =
DisableValidationForModuleKind::None;
if (::getenv("LIBCLANG_DISABLE_PCH_VALIDATION"))
disableValid = DisableValidationForModuleKind::All;
- AST->Reader = new ASTReader(PP, *AST->ModCache, AST->Ctx.get(),
- PCHContainerRdr, *AST->CodeGenOpts, {},
- /*isysroot=*/"",
- /*DisableValidationKind=*/disableValid,
- AllowASTWithCompilerErrors);
+ AST->Reader = llvm::makeIntrusiveRefCnt<ASTReader>(
+ PP, *AST->ModCache, AST->Ctx.get(), PCHContainerRdr, *AST->CodeGenOpts,
+ ArrayRef<std::shared_ptr<ModuleFileExtension>>(),
+ /*isysroot=*/"",
+ /*DisableValidationKind=*/disableValid, AllowASTWithCompilerErrors);
unsigned Counter = 0;
AST->Reader->setListener(std::make_unique<ASTInfoCollector>(
@@ -1191,9 +1190,11 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
// changed above in AddImplicitPreamble. If VFS is nullptr, rely on
// createFileManager to create one.
if (VFS && FileMgr && &FileMgr->getVirtualFileSystem() == VFS)
- Clang->setFileManager(&*FileMgr);
- else
- FileMgr = Clang->createFileManager(std::move(VFS));
+ Clang->setFileManager(FileMgr);
+ else {
+ Clang->createFileManager(std::move(VFS));
+ FileMgr = Clang->getFileManagerPtr();
+ }
// Recover resources if we crash before exiting this method.
llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
@@ -1226,15 +1227,15 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
ResetForParse();
- SourceMgr = new SourceManager(getDiagnostics(), *FileMgr,
- UserFilesAreVolatile);
+ SourceMgr = llvm::makeIntrusiveRefCnt<SourceManager>(
+ getDiagnostics(), *FileMgr, +UserFilesAreVolatile);
if (!OverrideMainBuffer) {
checkAndRemoveNonDriverDiags(StoredDiagnostics);
TopLevelDeclsInPreamble.clear();
}
// Create the source manager.
- Clang->setSourceManager(&getSourceManager());
+ Clang->setSourceManager(getSourceManagerPtr());
// If the main file has been overridden due to the use of a preamble,
// make that override happen and introduce the preamble.
@@ -1499,13 +1500,13 @@ void ASTUnit::transferASTDataFromCompilerInstance(CompilerInstance &CI) {
TheSema = CI.takeSema();
Consumer = CI.takeASTConsumer();
if (CI.hasASTContext())
- Ctx = &CI.getASTContext();
+ Ctx = CI.getASTContextPtr();
if (CI.hasPreprocessor())
PP = CI.getPreprocessorPtr();
CI.setSourceManager(nullptr);
CI.setFileManager(nullptr);
if (CI.hasTarget())
- Target = &CI.getTarget();
+ Target = CI.getTargetPtr();
Reader = CI.getASTReader();
HadModuleLoaderFatalFailure = CI.hadModuleLoaderFatalFailure();
if (Invocation != CI.getInvocationPtr()) {
@@ -1555,10 +1556,11 @@ ASTUnit::create(std::shared_ptr<CompilerInvocation> CI,
AST->Diagnostics = Diags;
AST->FileSystemOpts = CI->getFileSystemOpts();
AST->Invocation = std::move(CI);
- AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS);
+ AST->FileMgr =
+ llvm::makeIntrusiveRefCnt<FileManager>(AST->FileSystemOpts, VFS);
AST->UserFilesAreVolatile = UserFilesAreVolatile;
- AST->SourceMgr = new SourceManager(AST->getDiagnostics(), *AST->FileMgr,
- UserFilesAreVolatile);
+ AST->SourceMgr = llvm::makeIntrusiveRefCnt<SourceManager>(
+ AST->getDiagnostics(), *AST->FileMgr, UserFilesAreVolatile);
AST->ModCache = createCrossProcessModuleCache();
return AST;
@@ -1646,10 +1648,10 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
AST->Reader = nullptr;
// Create a file manager object to provide access to and cache the filesystem.
- Clang->setFileManager(&AST->getFileManager());
+ Clang->setFileManager(AST->getFileManagerPtr());
// Create the source manager.
- Clang->setSourceManager(&AST->getSourceManager());
+ Clang->setSourceManager(AST->getSourceManagerPtr());
FrontendAction *Act = Action;
@@ -1743,8 +1745,9 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
std::shared_ptr<CompilerInvocation> CI,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
std::shared_ptr<DiagnosticOptions> DiagOpts,
- IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
- bool OnlyLocalDecls, CaptureDiagsKind CaptureDiagnostics,
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
+ IntrusiveRefCntPtr<FileManager> FileMgr, bool OnlyLocalDecls,
+ CaptureDiagsKind CaptureDiagnostics,
unsigned PrecompilePreambleAfterNParses, TranslationUnitKind TUKind,
bool CacheCodeCompletionResults, bool IncludeBriefCommentsInCodeCompletion,
bool UserFilesAreVolatile) {
@@ -1849,7 +1852,8 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCommandLine(
AST->FileSystemOpts = CI->getFileSystemOpts();
AST->CodeGenOpts = std::make_unique<CodeGenOptions>(CI->getCodeGenOpts());
VFS = createVFSFromCompilerInvocation(*CI, *Diags, VFS);
- AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS);
+ AST->FileMgr =
+ llvm::makeIntrusiveRefCnt<FileManager>(AST->FileSystemOpts, VFS);
AST->StorePreamblesInMemory = StorePreamblesInMemory;
AST->PreambleStoragePath = PreambleStoragePath;
AST->ModCache = createCrossProcessModuleCache();
@@ -2210,7 +2214,8 @@ void ASTUnit::CodeComplete(
CodeCompleteConsumer &Consumer,
std::shared_ptr<PCHContainerOperations> PCHContainerOps,
llvm::IntrusiveRefCntPtr<DiagnosticsEngine> Diag, LangOptions &LangOpts,
- SourceManager &SourceMgr, FileManager &FileMgr,
+ llvm::IntrusiveRefCntPtr<SourceManager> SourceMgr,
+ llvm::IntrusiveRefCntPtr<FileManager> FileMgr,
SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics,
SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers,
std::unique_ptr<SyntaxOnlyAction> Act) {
@@ -2265,7 +2270,7 @@ void ASTUnit::CodeComplete(
Clang->getDiagnostics(),
&StoredDiagnostics, nullptr);
ProcessWarningOptions(*Diag, Inv.getDiagnosticOpts(),
- FileMgr.getVirtualFileSystem());
+ FileMgr->getVirtualFileSystem());
// Create the target instance.
if (!Clang->createTarget()) {
@@ -2282,8 +2287,8 @@ void ASTUnit::CodeComplete(
"IR inputs not support here!");
// Use the source and file managers that we were given.
- Clang->setFileManager(&FileMgr);
- Clang->setSourceManager(&SourceMgr);
+ Clang->setFileManager(FileMgr);
+ Clang->setSourceManager(SourceMgr);
// Remap files.
PreprocessorOpts.clearRemappedFiles();
@@ -2301,7 +2306,7 @@ void ASTUnit::CodeComplete(
auto getUniqueID =
[&FileMgr](StringRef Filename) -> std::optional<llvm::sys::fs::UniqueID> {
- if (auto Status = FileMgr.getVirtualFileSystem().status(Filename))
+ if (auto Status = FileMgr->getVirtualFileSystem().status(Filename))
return Status->getUniqueID();
return std::nullopt;
};
@@ -2322,7 +2327,7 @@ void ASTUnit::CodeComplete(
std::unique_ptr<llvm::MemoryBuffer> OverrideMainBuffer;
if (Preamble && Line > 1 && hasSameUniqueID(File, OriginalSourceFile)) {
OverrideMainBuffer = getMainBufferWithPrecompiledPreamble(
- PCHContainerOps, Inv, FileMgr.getVirtualFileSystemPtr(), false,
+ PCHContainerOps, Inv, FileMgr->getVirtualFileSystemPtr(), false,
Line - 1);
}
@@ -2333,7 +2338,7 @@ void ASTUnit::CodeComplete(
"No preamble was built, but OverrideMainBuffer is not null");
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
- FileMgr.getVirtualFileSystemPtr();
+ FileMgr->getVirtualFileSystemPtr();
Preamble->AddImplicitPreamble(Clang->getInvocation(), VFS,
OverrideMainBuffer.get());
// FIXME: there is no way to update VFS if it was changed by
diff --git a/clang/lib/Frontend/ChainedIncludesSource.cpp b/clang/lib/Frontend/ChainedIncludesSource.cpp
index 88b1076cd36ce..013814a738a36 100644
--- a/clang/lib/Frontend/ChainedIncludesSource.cpp
+++ b/clang/lib/Frontend/ChainedIncludesSource.cpp
@@ -53,17 +53,17 @@ class ChainedIncludesSource : public ExternalSemaSource {
};
} // end anonymous namespace
-static ASTReader *
+static llvm::IntrusiveRefCntPtr<ASTReader>
createASTReader(CompilerInstance &CI, StringRef pchFile,
SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> &MemBufs,
SmallVectorImpl<std::string> &bufNames,
ASTDeserializationListener *deserialListener = nullptr) {
Preprocessor &PP = CI.getPreprocessor();
- std::unique_ptr<ASTReader> Reader;
- Reader.reset(new ASTReader(
+ auto Reader = llvm::makeIntrusiveRefCnt<ASTReader>(
PP, CI.getModuleCache(), &CI.getASTContext(), CI.getPCHContainerReader(),
- CI.getCodeGenOpts(), /*Extensions=*/{},
- /*isysroot=*/"", DisableValidationForModuleKind::PCH));
+ CI.getCodeGenOpts(),
+ /*Extensions=*/ArrayRef<std::shared_ptr<ModuleFileExtension>>(),
+ /*isysroot=*/"", DisableValidationForModuleKind::PCH);
for (unsigned ti = 0; ti < bufNames.size(); ++ti) {
StringRef sr(bufNames[ti]);
Reader->addInMemoryBuffer(sr, std::move(MemBufs[ti]));
@@ -74,7 +74,7 @@ createASTReader(CompilerInstance &CI, StringRef pchFile,
case ASTReader::Success:
// Set the predefines buffer as suggested by the PCH reader.
PP.setPredefines(Reader->getSuggestedPredefines());
- return Reader.release();
+ return Reader;
case ASTReader::Failure:
case ASTReader::Missing:
@@ -87,8 +87,9 @@ createASTReader(CompilerInstance &CI, StringRef pchFile,
return nullptr;
}
-IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(
- CompilerInstance &CI, IntrusiveRefCntPtr<ExternalSemaSource> &Reader) {
+IntrusiveRefCntPtr<ExternalSemaSource>
+clang::createChainedIncludesSource(CompilerInstance &CI,
+ IntrusiveRefCntPtr<ASTReader> &OutReader) {
std::vector<std::string> &includes = CI.getPreprocessorOpts().ChainedIncludes;
assert(!includes.empty() && "No '-chain-include' in options!");
@@ -186,12 +187,12 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(
assert(!SerialBufs.empty());
std::string pchName = includes.back() + ".pch-final";
serialBufNames.push_back(pchName);
- Reader = createASTReader(CI, pchName, SerialBufs, serialBufNames);
- if (!Reader)
+ OutReader = createASTReader(CI, pchName, SerialBufs, serialBufNames);
+ if (!OutReader)
return nullptr;
auto Chain...
[truncated]
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/13997 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/13549 Here is the relevant piece of the build log for the reference |
…lvm#151782) This commit handles the following types: - clang::ExternalASTSource - clang::TargetInfo - clang::ASTContext - clang::SourceManager - clang::FileManager Part of cleanup llvm#151026 (cherry picked from commit 4205da0) Conflicts: clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/ChainedIncludesSource.cpp clang/lib/Frontend/CompilerInstance.cpp
…Instance Sharing (#11631) * [clang][deps] Remove dependency on `tooling::ToolAction` (llvm#149904) The dependency scanner was initially using a fair amount of infrastructure provided by the `clangTooling` library. Over time, the needs for bespoke handling of command lines grew and the overlap with the tooling library kept shrinking. I don't think the library provides any value anymore. I decided to remove the dependency and only reimplement the small bits required by the scanner. This allowed for a nice simplification, where we no longer need to create temporary dummy `FileManager` instances (mis-named as `DriverFileMgr` in some parts) and `SourceManager` instances to attach to the `DiagnosticsEngine`. That code was copied from the tooling library to support `DiagnosticConsumers` that expect these to exist. The scanner uses a closed set of consumers and none need these objects to exist. The motivation for this (hopefully NFC) patch are some new restrictions to how VFS's can be propagated in Clang that I'm working on. (cherry picked from commit aa1b416) * Reland "[clang] Delay normalization of `-fmodules-cache-path` (llvm#150123)" This reverts commit 613caa9, essentially reapplying 4a4bdde after moving `normalizeModuleCachePath` from clangFrontend to clangLex. This PR is part of an effort to remove file system usage from the command line parsing code. The reason for that is that it's impossible to do file system access correctly without a configured VFS, and the VFS can only be configured after the command line is parsed. I don't want to intertwine command line parsing and VFS configuration, so I decided to perform the file system access after the command line is parsed and the VFS is configured - ideally right before the file system entity is used for the first time. This patch delays normalization of the module cache path until `CompilerInstance` is asked for the cache path in the current compilation context. (cherry picked from commit 55bef46) * NFC: Clean up of IntrusiveRefCntPtr construction from raw pointers. (llvm#151545) Handles clang::DiagnosticsEngine and clang::DiagnosticIDs. For DiagnosticIDs, this mostly migrates from `new DiagnosticIDs` to convenience method `DiagnosticIDs::create()`. Part of cleanup llvm#151026 (cherry picked from commit c7f3437) Conflicts: clang/tools/driver/cc1_main.cpp clang/unittests/Driver/DXCModeTest.cpp clang/unittests/Driver/SimpleDiagnosticConsumer.h clang/unittests/Frontend/SearchPathTest.cpp clang/unittests/Lex/HeaderSearchTest.cpp clang/unittests/Tooling/RewriterTestContext.h * NFC: Clean up of IntrusiveRefCntPtr construction from raw pointers. (llvm#151782) This commit handles the following types: - clang::ExternalASTSource - clang::TargetInfo - clang::ASTContext - clang::SourceManager - clang::FileManager Part of cleanup llvm#151026 (cherry picked from commit 4205da0) Conflicts: clang/lib/Frontend/ASTUnit.cpp clang/lib/Frontend/ChainedIncludesSource.cpp clang/lib/Frontend/CompilerInstance.cpp * Merge commit '30633f308941' from llvm.org/main into next (cherry picked from commit 95ea104) Conflicts: clang/include/clang/Frontend/CompilerInstance.h clang/lib/Frontend/CompilerInstance.cpp * Merge pull request #11450 from swiftlang/jan_svoboda/cas-fix-early-vfs [clang] Fix CAS initialization after upstream llvm#158381 (cherry picked from commit 6d73002) * [clang] Avoid reparsing VFS overlay files for module dep collector (llvm#158372) This PR uses the new-ish `llvm::vfs::FileSystem::visit()` interface to collect VFS overlay entries from an existing `FileSystem` instance rather than parsing the VFS YAML file anew. This prevents duplicate diagnostics as observed by `clang/test/VFS/broken-vfs-module-dep.c`. (cherry picked from commit 4957c47) * [clang] Don't fail `ExecuteCompilerInvocation()` due to caller errors (llvm#158695) This PR changes the behavior of `clang::ExecuteCompilerInvocation()` so that it only returns early when the `DiagnosticsEngine` emitted errors **within** the function. Handling errors emitted before the function got called is a responsibility of the caller. Necessary for llvm#158381. (cherry picked from commit f33fb0d) * [clang] Only set non-empty bypass to scan VFS (llvm#159605) Normalizing an empty modules cache path results in an incorrect non-empty path (the working directory). This PR conditionalizes more code to avoid this. Tested downstream by swift/llvm-project and the `DependencyScanningCAPITests.DependencyScanningFSCacheOutOfDate` unit test. (cherry picked from commit 5a339b0) * Merge commit '0e35f56d40d3' from llvm.org/main into next (cherry picked from commit 3efcc0f) Conflicts: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp * [clang] NFCI: Clean up `CompilerInstance::create{File,Source}Manager()` (llvm#160748) The `CompilerInstance::createSourceManager()` function currently accepts the `FileManager` to be used. However, all clients call `CompilerInstance::createFileManager()` prior to creating the `SourceManager`, and it never makes sense to use a `FileManager` in the `SourceManager` that's different from the rest of the compiler. Passing the `FileManager` explicitly is redundant, error-prone, and deviates from the style of other `CompilerInstance` initialization APIs. This PR therefore removes the `FileManager` parameter from `createSourceManager()` and also stops returning the `FileManager` pointer from `createFileManager()`, since that was its primary use. Now, `createSourceManager()` internally calls `getFileManager()` instead. (cherry picked from commit b86ddae) Conflicts: clang/lib/Tooling/DependencyScanning/DependencyScannerImpl.cpp * Merge commit '436861645247' from llvm.org/main into next (cherry picked from commit 286ea7d) Conflicts: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp * [clang] Pass VFS into `ASTUnit::LoadFromASTFile()` (llvm#159166) This PR makes the `VFS` parameter to `ASTUnit::LoadFromASTFile()` required and explicit, rather than silently defaulting to the real file system. This makes it easy to correctly propagate the fully-configured VFS and load any input files like the rest of the compiler does. (cherry picked from commit cda542d) * Fix a line missing when merging 30633f3 * [clang][deps] Fix a use-after-free from expanding response files (llvm#164676) In 4368616 we accidentally moved uses of command-line args saved into a bump pointer allocator during response file expansion out of scope of the allocator. Also, the test that should have caught this (at least with asan) was not working correctly because clang-scan-deps was expanding response files itself during argument adjustment rather than the underlying scanner library. rdar://162720059 (cherry picked from commit 3e6f696) --------- Co-authored-by: Jan Svoboda <jan_svoboda@apple.com> Co-authored-by: James Y Knight <jyknight@google.com> Co-authored-by: git apple-llvm automerger <am@git-apple-llvm> Co-authored-by: Ben Langmuir <blangmuir@apple.com>
This commit handles the following types:
Part of cleanup #151026