[clang] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#139399)
This commit is contained in:
parent
a92de02ea3
commit
f5f8ddc166
@ -909,13 +909,13 @@ interp::Context &ASTContext::getInterpContext() {
|
|||||||
if (!InterpContext) {
|
if (!InterpContext) {
|
||||||
InterpContext.reset(new interp::Context(*this));
|
InterpContext.reset(new interp::Context(*this));
|
||||||
}
|
}
|
||||||
return *InterpContext.get();
|
return *InterpContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParentMapContext &ASTContext::getParentMapContext() {
|
ParentMapContext &ASTContext::getParentMapContext() {
|
||||||
if (!ParentMapCtx)
|
if (!ParentMapCtx)
|
||||||
ParentMapCtx.reset(new ParentMapContext(*this));
|
ParentMapCtx.reset(new ParentMapContext(*this));
|
||||||
return *ParentMapCtx.get();
|
return *ParentMapCtx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI,
|
static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI,
|
||||||
@ -13066,7 +13066,7 @@ bool ASTContext::isNearlyEmpty(const CXXRecordDecl *RD) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VTableContextBase *ASTContext::getVTableContext() {
|
VTableContextBase *ASTContext::getVTableContext() {
|
||||||
if (!VTContext.get()) {
|
if (!VTContext) {
|
||||||
auto ABI = Target->getCXXABI();
|
auto ABI = Target->getCXXABI();
|
||||||
if (ABI.isMicrosoft())
|
if (ABI.isMicrosoft())
|
||||||
VTContext.reset(new MicrosoftVTableContext(*this));
|
VTContext.reset(new MicrosoftVTableContext(*this));
|
||||||
|
@ -105,7 +105,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the program. This is only needed for unittests.
|
/// Returns the program. This is only needed for unittests.
|
||||||
Program &getProgram() const { return *P.get(); }
|
Program &getProgram() const { return *P; }
|
||||||
|
|
||||||
unsigned collectBaseOffset(const RecordDecl *BaseDecl,
|
unsigned collectBaseOffset(const RecordDecl *BaseDecl,
|
||||||
const RecordDecl *DerivedDecl) const;
|
const RecordDecl *DerivedDecl) const;
|
||||||
|
@ -985,7 +985,7 @@ llvm::GlobalVariable *CodeGenVTables::GenerateConstructionVTable(
|
|||||||
assert(!VTable->isDeclaration() && "Shouldn't set properties on declaration");
|
assert(!VTable->isDeclaration() && "Shouldn't set properties on declaration");
|
||||||
CGM.setGVProperties(VTable, RD);
|
CGM.setGVProperties(VTable, RD);
|
||||||
|
|
||||||
CGM.EmitVTableTypeMetadata(RD, VTable, *VTLayout.get());
|
CGM.EmitVTableTypeMetadata(RD, VTable, *VTLayout);
|
||||||
|
|
||||||
if (UsingRelativeLayout) {
|
if (UsingRelativeLayout) {
|
||||||
RemoveHwasanMetadata(VTable);
|
RemoveHwasanMetadata(VTable);
|
||||||
|
@ -180,7 +180,7 @@ static void validateSpecialCaseListFormat(const Driver &D,
|
|||||||
std::string BLError;
|
std::string BLError;
|
||||||
std::unique_ptr<llvm::SpecialCaseList> SCL(
|
std::unique_ptr<llvm::SpecialCaseList> SCL(
|
||||||
llvm::SpecialCaseList::create(SCLFiles, D.getVFS(), BLError));
|
llvm::SpecialCaseList::create(SCLFiles, D.getVFS(), BLError));
|
||||||
if (!SCL.get() && DiagnoseErrors)
|
if (!SCL && DiagnoseErrors)
|
||||||
D.Diag(MalformedSCLErrorDiagID) << BLError;
|
D.Diag(MalformedSCLErrorDiagID) << BLError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
|
|||||||
llvm::CrashRecoveryContextCleanupRegistrar<TopLevelDeclTrackerAction>
|
llvm::CrashRecoveryContextCleanupRegistrar<TopLevelDeclTrackerAction>
|
||||||
ActCleanup(Act.get());
|
ActCleanup(Act.get());
|
||||||
|
|
||||||
if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
|
if (!Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (SavedMainFileBuffer)
|
if (SavedMainFileBuffer)
|
||||||
@ -1650,7 +1650,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
|
|||||||
llvm::CrashRecoveryContextCleanupRegistrar<TopLevelDeclTrackerAction>
|
llvm::CrashRecoveryContextCleanupRegistrar<TopLevelDeclTrackerAction>
|
||||||
ActCleanup(TrackerAct.get());
|
ActCleanup(TrackerAct.get());
|
||||||
|
|
||||||
if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) {
|
if (!Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
|
||||||
AST->transferASTDataFromCompilerInstance(*Clang);
|
AST->transferASTDataFromCompilerInstance(*Clang);
|
||||||
if (OwnAST && ErrAST)
|
if (OwnAST && ErrAST)
|
||||||
ErrAST->swap(OwnAST);
|
ErrAST->swap(OwnAST);
|
||||||
@ -2333,7 +2333,7 @@ void ASTUnit::CodeComplete(
|
|||||||
if (!Act)
|
if (!Act)
|
||||||
Act.reset(new SyntaxOnlyAction);
|
Act.reset(new SyntaxOnlyAction);
|
||||||
|
|
||||||
if (Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) {
|
if (Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
|
||||||
if (llvm::Error Err = Act->Execute()) {
|
if (llvm::Error Err = Act->Execute()) {
|
||||||
consumeError(std::move(Err)); // FIXME this drops errors on the floor.
|
consumeError(std::move(Err)); // FIXME this drops errors on the floor.
|
||||||
}
|
}
|
||||||
|
@ -512,7 +512,7 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build(
|
|||||||
std::move(Buffer),
|
std::move(Buffer),
|
||||||
/*WritePCHFile=*/Storage->getKind() == PCHStorage::Kind::TempFile,
|
/*WritePCHFile=*/Storage->getKind() == PCHStorage::Kind::TempFile,
|
||||||
Callbacks);
|
Callbacks);
|
||||||
if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
|
if (!Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
|
||||||
return BuildPreambleError::BeginSourceFileFailed;
|
return BuildPreambleError::BeginSourceFileFailed;
|
||||||
|
|
||||||
// Performed after BeginSourceFile to ensure Clang->Preprocessor can be
|
// Performed after BeginSourceFile to ensure Clang->Preprocessor can be
|
||||||
|
@ -109,7 +109,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
|
|||||||
// Recover resources if we crash before exiting this method.
|
// Recover resources if we crash before exiting this method.
|
||||||
llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(S.get());
|
llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(S.get());
|
||||||
|
|
||||||
ParseAST(*S.get(), PrintStats, SkipFunctionBodies);
|
ParseAST(*S, PrintStats, SkipFunctionBodies);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) {
|
void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) {
|
||||||
@ -131,7 +131,7 @@ void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) {
|
|||||||
|
|
||||||
std::unique_ptr<Parser> ParseOP(
|
std::unique_ptr<Parser> ParseOP(
|
||||||
new Parser(S.getPreprocessor(), S, SkipFunctionBodies));
|
new Parser(S.getPreprocessor(), S, SkipFunctionBodies));
|
||||||
Parser &P = *ParseOP.get();
|
Parser &P = *ParseOP;
|
||||||
|
|
||||||
llvm::CrashRecoveryContextCleanupRegistrar<const void, ResetStackCleanup>
|
llvm::CrashRecoveryContextCleanupRegistrar<const void, ResetStackCleanup>
|
||||||
CleanupPrettyStack(llvm::SavePrettyStackState());
|
CleanupPrettyStack(llvm::SavePrettyStackState());
|
||||||
|
@ -601,7 +601,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
|
|||||||
|
|
||||||
std::unique_ptr<llvm::MCStreamer> Str(createNullStreamer(Ctx));
|
std::unique_ptr<llvm::MCStreamer> Str(createNullStreamer(Ctx));
|
||||||
std::unique_ptr<llvm::MCAsmParser> Parser(
|
std::unique_ptr<llvm::MCAsmParser> Parser(
|
||||||
createMCAsmParser(TempSrcMgr, Ctx, *Str.get(), *MAI));
|
createMCAsmParser(TempSrcMgr, Ctx, *Str, *MAI));
|
||||||
|
|
||||||
std::unique_ptr<llvm::MCTargetAsmParser> TargetParser(
|
std::unique_ptr<llvm::MCTargetAsmParser> TargetParser(
|
||||||
TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
|
TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
|
||||||
@ -617,7 +617,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
|
|||||||
|
|
||||||
// Change to the Intel dialect.
|
// Change to the Intel dialect.
|
||||||
Parser->setAssemblerDialect(1);
|
Parser->setAssemblerDialect(1);
|
||||||
Parser->setTargetParser(*TargetParser.get());
|
Parser->setTargetParser(*TargetParser);
|
||||||
Parser->setParsingMSInlineAsm(true);
|
Parser->setParsingMSInlineAsm(true);
|
||||||
TargetParser->setParsingMSInlineAsm(true);
|
TargetParser->setParsingMSInlineAsm(true);
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
|
|||||||
Triple T(Opts.Triple);
|
Triple T(Opts.Triple);
|
||||||
Str.reset(TheTarget->createMCObjectStreamer(
|
Str.reset(TheTarget->createMCObjectStreamer(
|
||||||
T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI));
|
T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI));
|
||||||
Str.get()->initSections(Opts.NoExecStack, *STI);
|
Str->initSections(Opts.NoExecStack, *STI);
|
||||||
if (T.isOSBinFormatMachO() && T.isOSDarwin()) {
|
if (T.isOSBinFormatMachO() && T.isOSDarwin()) {
|
||||||
Triple *TVT = Opts.DarwinTargetVariantTriple
|
Triple *TVT = Opts.DarwinTargetVariantTriple
|
||||||
? &*Opts.DarwinTargetVariantTriple
|
? &*Opts.DarwinTargetVariantTriple
|
||||||
@ -592,14 +592,14 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
|
|||||||
if (Opts.EmbedBitcode && Ctx.getObjectFileType() == MCContext::IsMachO) {
|
if (Opts.EmbedBitcode && Ctx.getObjectFileType() == MCContext::IsMachO) {
|
||||||
MCSection *AsmLabel = Ctx.getMachOSection(
|
MCSection *AsmLabel = Ctx.getMachOSection(
|
||||||
"__LLVM", "__asm", MachO::S_REGULAR, 4, SectionKind::getReadOnly());
|
"__LLVM", "__asm", MachO::S_REGULAR, 4, SectionKind::getReadOnly());
|
||||||
Str.get()->switchSection(AsmLabel);
|
Str->switchSection(AsmLabel);
|
||||||
Str.get()->emitZeros(1);
|
Str->emitZeros(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Failed = false;
|
bool Failed = false;
|
||||||
|
|
||||||
std::unique_ptr<MCAsmParser> Parser(
|
std::unique_ptr<MCAsmParser> Parser(
|
||||||
createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));
|
createMCAsmParser(SrcMgr, Ctx, *Str, *MAI));
|
||||||
|
|
||||||
// FIXME: init MCTargetOptions from sanitizer flags here.
|
// FIXME: init MCTargetOptions from sanitizer flags here.
|
||||||
std::unique_ptr<MCTargetAsmParser> TAP(
|
std::unique_ptr<MCTargetAsmParser> TAP(
|
||||||
@ -619,7 +619,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Failed) {
|
if (!Failed) {
|
||||||
Parser->setTargetParser(*TAP.get());
|
Parser->setTargetParser(*TAP);
|
||||||
Failed = Parser->Run(Opts.NoInitialTextSection);
|
Failed = Parser->Run(Opts.NoInitialTextSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4390,7 +4390,7 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
|
|||||||
CXXIdx->getPCHContainerOperations(), Diags,
|
CXXIdx->getPCHContainerOperations(), Diags,
|
||||||
CXXIdx->getClangResourcesPath(), CXXIdx->getStorePreamblesInMemory(),
|
CXXIdx->getClangResourcesPath(), CXXIdx->getStorePreamblesInMemory(),
|
||||||
CXXIdx->getPreambleStoragePath(), CXXIdx->getOnlyLocalDecls(),
|
CXXIdx->getPreambleStoragePath(), CXXIdx->getOnlyLocalDecls(),
|
||||||
CaptureDiagnostics, *RemappedFiles.get(),
|
CaptureDiagnostics, *RemappedFiles,
|
||||||
/*RemappedFilesKeepOriginalName=*/true, PrecompilePreambleAfterNParses,
|
/*RemappedFilesKeepOriginalName=*/true, PrecompilePreambleAfterNParses,
|
||||||
TUKind, CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion,
|
TUKind, CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion,
|
||||||
/*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse,
|
/*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse,
|
||||||
@ -4981,8 +4981,7 @@ clang_reparseTranslationUnit_Impl(CXTranslationUnit TU,
|
|||||||
RemappedFiles->push_back(std::make_pair(UF.Filename, MB.release()));
|
RemappedFiles->push_back(std::make_pair(UF.Filename, MB.release()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CXXUnit->Reparse(CXXIdx->getPCHContainerOperations(),
|
if (!CXXUnit->Reparse(CXXIdx->getPCHContainerOperations(), *RemappedFiles))
|
||||||
*RemappedFiles.get()))
|
|
||||||
return CXError_Success;
|
return CXError_Success;
|
||||||
if (isASTReadError(CXXUnit))
|
if (isASTReadError(CXXUnit))
|
||||||
return CXError_ASTReadError;
|
return CXError_ASTReadError;
|
||||||
|
@ -339,7 +339,7 @@ testing::AssertionResult matchAndVerifyResultConditionally(
|
|||||||
SmallString<256> Buffer;
|
SmallString<256> Buffer;
|
||||||
std::unique_ptr<ASTUnit> AST(buildASTFromCodeWithArgs(
|
std::unique_ptr<ASTUnit> AST(buildASTFromCodeWithArgs(
|
||||||
Code.toStringRef(Buffer), CompileArgs, Filename));
|
Code.toStringRef(Buffer), CompileArgs, Filename));
|
||||||
if (!AST.get())
|
if (!AST)
|
||||||
return testing::AssertionFailure()
|
return testing::AssertionFailure()
|
||||||
<< "Parsing error in \"" << Code << "\" while building AST";
|
<< "Parsing error in \"" << Code << "\" while building AST";
|
||||||
Finder.matchAST(AST->getASTContext());
|
Finder.matchAST(AST->getASTContext());
|
||||||
|
@ -40,8 +40,7 @@ public:
|
|||||||
FileEntryRef addFile(StringRef Name) {
|
FileEntryRef addFile(StringRef Name) {
|
||||||
FEs.emplace_back(new FileEntry());
|
FEs.emplace_back(new FileEntry());
|
||||||
return FileEntryRef(
|
return FileEntryRef(
|
||||||
*Files.insert({Name, FileEntryRef::MapValue(*FEs.back().get(), DR)})
|
*Files.insert({Name, FileEntryRef::MapValue(*FEs.back(), DR)}).first);
|
||||||
.first);
|
|
||||||
}
|
}
|
||||||
FileEntryRef addFileAlias(StringRef Name, FileEntryRef Base) {
|
FileEntryRef addFileAlias(StringRef Name, FileEntryRef Base) {
|
||||||
return FileEntryRef(
|
return FileEntryRef(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user