Skip to content

Commit f5f8ddc

Browse files
[clang] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#139399)
1 parent a92de02 commit f5f8ddc

File tree

12 files changed

+23
-25
lines changed

12 files changed

+23
-25
lines changed

clang/lib/AST/ASTContext.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,13 +909,13 @@ interp::Context &ASTContext::getInterpContext() {
909909
if (!InterpContext) {
910910
InterpContext.reset(new interp::Context(*this));
911911
}
912-
return *InterpContext.get();
912+
return *InterpContext;
913913
}
914914

915915
ParentMapContext &ASTContext::getParentMapContext() {
916916
if (!ParentMapCtx)
917917
ParentMapCtx.reset(new ParentMapContext(*this));
918-
return *ParentMapCtx.get();
918+
return *ParentMapCtx;
919919
}
920920

921921
static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI,
@@ -13066,7 +13066,7 @@ bool ASTContext::isNearlyEmpty(const CXXRecordDecl *RD) const {
1306613066
}
1306713067

1306813068
VTableContextBase *ASTContext::getVTableContext() {
13069-
if (!VTContext.get()) {
13069+
if (!VTContext) {
1307013070
auto ABI = Target->getCXXABI();
1307113071
if (ABI.isMicrosoft())
1307213072
VTContext.reset(new MicrosoftVTableContext(*this));

clang/lib/AST/ByteCode/Context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class Context final {
105105
}
106106

107107
/// Returns the program. This is only needed for unittests.
108-
Program &getProgram() const { return *P.get(); }
108+
Program &getProgram() const { return *P; }
109109

110110
unsigned collectBaseOffset(const RecordDecl *BaseDecl,
111111
const RecordDecl *DerivedDecl) const;

clang/lib/CodeGen/CGVTables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ llvm::GlobalVariable *CodeGenVTables::GenerateConstructionVTable(
985985
assert(!VTable->isDeclaration() && "Shouldn't set properties on declaration");
986986
CGM.setGVProperties(VTable, RD);
987987

988-
CGM.EmitVTableTypeMetadata(RD, VTable, *VTLayout.get());
988+
CGM.EmitVTableTypeMetadata(RD, VTable, *VTLayout);
989989

990990
if (UsingRelativeLayout) {
991991
RemoveHwasanMetadata(VTable);

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void validateSpecialCaseListFormat(const Driver &D,
180180
std::string BLError;
181181
std::unique_ptr<llvm::SpecialCaseList> SCL(
182182
llvm::SpecialCaseList::create(SCLFiles, D.getVFS(), BLError));
183-
if (!SCL.get() && DiagnoseErrors)
183+
if (!SCL && DiagnoseErrors)
184184
D.Diag(MalformedSCLErrorDiagID) << BLError;
185185
}
186186

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
12481248
llvm::CrashRecoveryContextCleanupRegistrar<TopLevelDeclTrackerAction>
12491249
ActCleanup(Act.get());
12501250

1251-
if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
1251+
if (!Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
12521252
return true;
12531253

12541254
if (SavedMainFileBuffer)
@@ -1650,7 +1650,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
16501650
llvm::CrashRecoveryContextCleanupRegistrar<TopLevelDeclTrackerAction>
16511651
ActCleanup(TrackerAct.get());
16521652

1653-
if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) {
1653+
if (!Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
16541654
AST->transferASTDataFromCompilerInstance(*Clang);
16551655
if (OwnAST && ErrAST)
16561656
ErrAST->swap(OwnAST);
@@ -2333,7 +2333,7 @@ void ASTUnit::CodeComplete(
23332333
if (!Act)
23342334
Act.reset(new SyntaxOnlyAction);
23352335

2336-
if (Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0])) {
2336+
if (Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
23372337
if (llvm::Error Err = Act->Execute()) {
23382338
consumeError(std::move(Err)); // FIXME this drops errors on the floor.
23392339
}

clang/lib/Frontend/PrecompiledPreamble.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ llvm::ErrorOr<PrecompiledPreamble> PrecompiledPreamble::Build(
512512
std::move(Buffer),
513513
/*WritePCHFile=*/Storage->getKind() == PCHStorage::Kind::TempFile,
514514
Callbacks);
515-
if (!Act->BeginSourceFile(*Clang.get(), Clang->getFrontendOpts().Inputs[0]))
515+
if (!Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
516516
return BuildPreambleError::BeginSourceFileFailed;
517517

518518
// Performed after BeginSourceFile to ensure Clang->Preprocessor can be

clang/lib/Parse/ParseAST.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
109109
// Recover resources if we crash before exiting this method.
110110
llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleanupSema(S.get());
111111

112-
ParseAST(*S.get(), PrintStats, SkipFunctionBodies);
112+
ParseAST(*S, PrintStats, SkipFunctionBodies);
113113
}
114114

115115
void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) {
@@ -131,7 +131,7 @@ void clang::ParseAST(Sema &S, bool PrintStats, bool SkipFunctionBodies) {
131131

132132
std::unique_ptr<Parser> ParseOP(
133133
new Parser(S.getPreprocessor(), S, SkipFunctionBodies));
134-
Parser &P = *ParseOP.get();
134+
Parser &P = *ParseOP;
135135

136136
llvm::CrashRecoveryContextCleanupRegistrar<const void, ResetStackCleanup>
137137
CleanupPrettyStack(llvm::SavePrettyStackState());

clang/lib/Parse/ParseStmtAsm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
601601

602602
std::unique_ptr<llvm::MCStreamer> Str(createNullStreamer(Ctx));
603603
std::unique_ptr<llvm::MCAsmParser> Parser(
604-
createMCAsmParser(TempSrcMgr, Ctx, *Str.get(), *MAI));
604+
createMCAsmParser(TempSrcMgr, Ctx, *Str, *MAI));
605605

606606
std::unique_ptr<llvm::MCTargetAsmParser> TargetParser(
607607
TheTarget->createMCAsmParser(*STI, *Parser, *MII, MCOptions));
@@ -617,7 +617,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
617617

618618
// Change to the Intel dialect.
619619
Parser->setAssemblerDialect(1);
620-
Parser->setTargetParser(*TargetParser.get());
620+
Parser->setTargetParser(*TargetParser);
621621
Parser->setParsingMSInlineAsm(true);
622622
TargetParser->setParsingMSInlineAsm(true);
623623

clang/tools/driver/cc1as_main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
577577
Triple T(Opts.Triple);
578578
Str.reset(TheTarget->createMCObjectStreamer(
579579
T, Ctx, std::move(MAB), std::move(OW), std::move(CE), *STI));
580-
Str.get()->initSections(Opts.NoExecStack, *STI);
580+
Str->initSections(Opts.NoExecStack, *STI);
581581
if (T.isOSBinFormatMachO() && T.isOSDarwin()) {
582582
Triple *TVT = Opts.DarwinTargetVariantTriple
583583
? &*Opts.DarwinTargetVariantTriple
@@ -592,14 +592,14 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
592592
if (Opts.EmbedBitcode && Ctx.getObjectFileType() == MCContext::IsMachO) {
593593
MCSection *AsmLabel = Ctx.getMachOSection(
594594
"__LLVM", "__asm", MachO::S_REGULAR, 4, SectionKind::getReadOnly());
595-
Str.get()->switchSection(AsmLabel);
596-
Str.get()->emitZeros(1);
595+
Str->switchSection(AsmLabel);
596+
Str->emitZeros(1);
597597
}
598598

599599
bool Failed = false;
600600

601601
std::unique_ptr<MCAsmParser> Parser(
602-
createMCAsmParser(SrcMgr, Ctx, *Str.get(), *MAI));
602+
createMCAsmParser(SrcMgr, Ctx, *Str, *MAI));
603603

604604
// FIXME: init MCTargetOptions from sanitizer flags here.
605605
std::unique_ptr<MCTargetAsmParser> TAP(
@@ -619,7 +619,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
619619
}
620620

621621
if (!Failed) {
622-
Parser->setTargetParser(*TAP.get());
622+
Parser->setTargetParser(*TAP);
623623
Failed = Parser->Run(Opts.NoInitialTextSection);
624624
}
625625

clang/tools/libclang/CIndex.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4390,7 +4390,7 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
43904390
CXXIdx->getPCHContainerOperations(), Diags,
43914391
CXXIdx->getClangResourcesPath(), CXXIdx->getStorePreamblesInMemory(),
43924392
CXXIdx->getPreambleStoragePath(), CXXIdx->getOnlyLocalDecls(),
4393-
CaptureDiagnostics, *RemappedFiles.get(),
4393+
CaptureDiagnostics, *RemappedFiles,
43944394
/*RemappedFilesKeepOriginalName=*/true, PrecompilePreambleAfterNParses,
43954395
TUKind, CacheCodeCompletionResults, IncludeBriefCommentsInCodeCompletion,
43964396
/*AllowPCHWithCompilerErrors=*/true, SkipFunctionBodies, SingleFileParse,
@@ -4981,8 +4981,7 @@ clang_reparseTranslationUnit_Impl(CXTranslationUnit TU,
49814981
RemappedFiles->push_back(std::make_pair(UF.Filename, MB.release()));
49824982
}
49834983

4984-
if (!CXXUnit->Reparse(CXXIdx->getPCHContainerOperations(),
4985-
*RemappedFiles.get()))
4984+
if (!CXXUnit->Reparse(CXXIdx->getPCHContainerOperations(), *RemappedFiles))
49864985
return CXError_Success;
49874986
if (isASTReadError(CXXUnit))
49884987
return CXError_ASTReadError;

clang/unittests/ASTMatchers/ASTMatchersTest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ testing::AssertionResult matchAndVerifyResultConditionally(
339339
SmallString<256> Buffer;
340340
std::unique_ptr<ASTUnit> AST(buildASTFromCodeWithArgs(
341341
Code.toStringRef(Buffer), CompileArgs, Filename));
342-
if (!AST.get())
342+
if (!AST)
343343
return testing::AssertionFailure()
344344
<< "Parsing error in \"" << Code << "\" while building AST";
345345
Finder.matchAST(AST->getASTContext());

clang/unittests/Basic/FileEntryTest.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ class FileEntryTestHelper {
4040
FileEntryRef addFile(StringRef Name) {
4141
FEs.emplace_back(new FileEntry());
4242
return FileEntryRef(
43-
*Files.insert({Name, FileEntryRef::MapValue(*FEs.back().get(), DR)})
44-
.first);
43+
*Files.insert({Name, FileEntryRef::MapValue(*FEs.back(), DR)}).first);
4544
}
4645
FileEntryRef addFileAlias(StringRef Name, FileEntryRef Base) {
4746
return FileEntryRef(

0 commit comments

Comments
 (0)