Don't use Optional::getPointer (NFC)
Since std::optional does not offer getPointer(), this patch replaces X.getPointer() with &*X to make the migration from llvm::Optional to std::optional easier. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716 Differential Revision: https://reviews.llvm.org/D138466
This commit is contained in:
parent
b39b76f2ef
commit
1f914944b6
|
@ -191,7 +191,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
|
|||
WorkScheduler.emplace(CDB, TUScheduler::Options(Opts),
|
||||
std::make_unique<UpdateIndexCallbacks>(
|
||||
DynamicIdx.get(), Callbacks, TFS,
|
||||
IndexTasks ? IndexTasks.getPointer() : nullptr));
|
||||
IndexTasks ? &*IndexTasks : nullptr));
|
||||
// Adds an index to the stack, at higher priority than existing indexes.
|
||||
auto AddIndex = [&](SymbolIndex *Idx) {
|
||||
if (this->Index != nullptr) {
|
||||
|
@ -408,7 +408,7 @@ void ClangdServer::codeComplete(PathRef File, Position Pos,
|
|||
// both the old and the new version in case only one of them matches.
|
||||
CodeCompleteResult Result = clangd::codeComplete(
|
||||
File, Pos, IP->Preamble, ParseInput, CodeCompleteOpts,
|
||||
SpecFuzzyFind ? SpecFuzzyFind.getPointer() : nullptr);
|
||||
SpecFuzzyFind ? &*SpecFuzzyFind : nullptr);
|
||||
{
|
||||
clang::clangd::trace::Span Tracer("Completion results callback");
|
||||
CB(std::move(Result));
|
||||
|
|
|
@ -1768,8 +1768,8 @@ private:
|
|||
assert(IdentifierResult);
|
||||
C.Name = IdentifierResult->Name;
|
||||
}
|
||||
if (auto OverloadSet = C.overloadSet(
|
||||
Opts, FileName, Inserter ? Inserter.getPointer() : nullptr)) {
|
||||
if (auto OverloadSet =
|
||||
C.overloadSet(Opts, FileName, Inserter ? &*Inserter : nullptr)) {
|
||||
auto Ret = BundleLookup.try_emplace(OverloadSet, Bundles.size());
|
||||
if (Ret.second)
|
||||
Bundles.emplace_back();
|
||||
|
@ -1863,9 +1863,9 @@ private:
|
|||
Relevance.Name = Bundle.front().Name;
|
||||
Relevance.FilterLength = HeuristicPrefix.Name.size();
|
||||
Relevance.Query = SymbolRelevanceSignals::CodeComplete;
|
||||
Relevance.FileProximityMatch = FileProximity.getPointer();
|
||||
Relevance.FileProximityMatch = &*FileProximity;
|
||||
if (ScopeProximity)
|
||||
Relevance.ScopeProximityMatch = ScopeProximity.getPointer();
|
||||
Relevance.ScopeProximityMatch = &*ScopeProximity;
|
||||
if (PreferredType)
|
||||
Relevance.HadContextType = true;
|
||||
Relevance.ContextWords = &ContextWords;
|
||||
|
|
|
@ -482,7 +482,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
|
|||
CTContext->setASTContext(&Clang->getASTContext());
|
||||
CTContext->setCurrentFile(Filename);
|
||||
CTContext->setSelfContainedDiags(true);
|
||||
CTChecks = CTFactories.createChecksForLanguage(CTContext.getPointer());
|
||||
CTChecks = CTFactories.createChecksForLanguage(&*CTContext);
|
||||
Preprocessor *PP = &Clang->getPreprocessor();
|
||||
for (const auto &Check : CTChecks) {
|
||||
Check->registerPPCallbacks(Clang->getSourceManager(), PP, PP);
|
||||
|
@ -663,7 +663,7 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
|
|||
Preamble->Diags.end());
|
||||
// Finally, add diagnostics coming from the AST.
|
||||
{
|
||||
std::vector<Diag> D = ASTDiags.take(CTContext.getPointer());
|
||||
std::vector<Diag> D = ASTDiags.take(&*CTContext);
|
||||
Diags->insert(Diags->end(), D.begin(), D.end());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1653,10 +1653,9 @@ bool TUScheduler::update(PathRef File, ParseInputs Inputs,
|
|||
bool ContentChanged = false;
|
||||
if (!FD) {
|
||||
// Create a new worker to process the AST-related tasks.
|
||||
ASTWorkerHandle Worker =
|
||||
ASTWorker::create(File, CDB, *IdleASTs, *HeaderIncluders,
|
||||
WorkerThreads ? WorkerThreads.getPointer() : nullptr,
|
||||
Barrier, Opts, *Callbacks);
|
||||
ASTWorkerHandle Worker = ASTWorker::create(
|
||||
File, CDB, *IdleASTs, *HeaderIncluders,
|
||||
WorkerThreads ? &*WorkerThreads : nullptr, Barrier, Opts, *Callbacks);
|
||||
FD = std::unique_ptr<FileData>(
|
||||
new FileData{Inputs.Contents, std::move(Worker)});
|
||||
ContentChanged = true;
|
||||
|
|
|
@ -64,11 +64,11 @@ struct IndexFileOut {
|
|||
|
||||
IndexFileOut() = default;
|
||||
IndexFileOut(const IndexFileIn &I)
|
||||
: Symbols(I.Symbols ? I.Symbols.getPointer() : nullptr),
|
||||
Refs(I.Refs ? I.Refs.getPointer() : nullptr),
|
||||
Relations(I.Relations ? I.Relations.getPointer() : nullptr),
|
||||
Sources(I.Sources ? I.Sources.getPointer() : nullptr),
|
||||
Cmd(I.Cmd ? I.Cmd.getPointer() : nullptr) {}
|
||||
: Symbols(I.Symbols ? &*I.Symbols : nullptr),
|
||||
Refs(I.Refs ? &*I.Refs : nullptr),
|
||||
Relations(I.Relations ? &*I.Relations : nullptr),
|
||||
Sources(I.Sources ? &*I.Sources : nullptr),
|
||||
Cmd(I.Cmd ? &*I.Cmd : nullptr) {}
|
||||
};
|
||||
// Serializes an index file.
|
||||
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const IndexFileOut &O);
|
||||
|
|
|
@ -993,8 +993,7 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
|
|||
} else {
|
||||
log("Starting LSP over stdin/stdout");
|
||||
TransportLayer = newJSONTransport(
|
||||
stdin, llvm::outs(),
|
||||
InputMirrorStream ? InputMirrorStream.getPointer() : nullptr,
|
||||
stdin, llvm::outs(), InputMirrorStream ? &*InputMirrorStream : nullptr,
|
||||
PrettyPrint, InputStyle);
|
||||
}
|
||||
if (!PathMappingsArg.empty()) {
|
||||
|
|
|
@ -113,7 +113,7 @@ int main(int argc, char *argv[]) {
|
|||
if (Source.getNumOccurrences()) {
|
||||
SourceText = readOrDie(Source);
|
||||
RawStream = clang::pseudo::lex(SourceText, LangOpts);
|
||||
TokenStream *Stream = RawStream.getPointer();
|
||||
TokenStream *Stream = &*RawStream;
|
||||
|
||||
auto DirectiveStructure = clang::pseudo::DirectiveTree::parse(*RawStream);
|
||||
clang::pseudo::chooseConditionalBranches(DirectiveStructure, *RawStream);
|
||||
|
@ -121,7 +121,7 @@ int main(int argc, char *argv[]) {
|
|||
llvm::Optional<TokenStream> Preprocessed;
|
||||
if (StripDirectives) {
|
||||
Preprocessed = DirectiveStructure.stripDirectives(*Stream);
|
||||
Stream = Preprocessed.getPointer();
|
||||
Stream = &*Preprocessed;
|
||||
}
|
||||
|
||||
if (PrintSource)
|
||||
|
|
|
@ -142,7 +142,7 @@ public:
|
|||
auto Mapping = VersionMappings.find(Kind.Value);
|
||||
if (Mapping == VersionMappings.end())
|
||||
return nullptr;
|
||||
return Mapping->getSecond() ? Mapping->getSecond().getPointer() : nullptr;
|
||||
return Mapping->getSecond() ? &*Mapping->getSecond() : nullptr;
|
||||
}
|
||||
|
||||
static Optional<DarwinSDKInfo>
|
||||
|
|
|
@ -1671,8 +1671,7 @@ public:
|
|||
/// Returns the darwin target variant triple, the variant of the deployment
|
||||
/// target for which the code is being compiled.
|
||||
const llvm::Triple *getDarwinTargetVariantTriple() const {
|
||||
return DarwinTargetVariantTriple ? DarwinTargetVariantTriple.getPointer()
|
||||
: nullptr;
|
||||
return DarwinTargetVariantTriple ? &*DarwinTargetVariantTriple : nullptr;
|
||||
}
|
||||
|
||||
/// Returns the version of the darwin target variant SDK which was used during
|
||||
|
|
|
@ -424,7 +424,7 @@ public:
|
|||
|
||||
llvm::Optional<const CXXScopeSpec *> getCXXScopeSpecifier() {
|
||||
if (ScopeSpecifier)
|
||||
return ScopeSpecifier.getPointer();
|
||||
return &*ScopeSpecifier;
|
||||
return llvm::None;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -708,7 +708,7 @@ void FilterAndStoreDiagnosticConsumer::HandleDiagnostic(
|
|||
llvm::Optional<StoredDiagnostic> StoredDiag;
|
||||
if (!ResultDiag) {
|
||||
StoredDiag.emplace(Level, Info);
|
||||
ResultDiag = StoredDiag.getPointer();
|
||||
ResultDiag = &*StoredDiag;
|
||||
}
|
||||
StandaloneDiags->push_back(
|
||||
makeStandaloneDiagnostic(*LangOpts, *ResultDiag));
|
||||
|
|
|
@ -381,8 +381,7 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
|
|||
InferredTarget = BaseMethodTarget;
|
||||
} else {
|
||||
bool ResolutionError = resolveCalleeCUDATargetConflict(
|
||||
InferredTarget.value(), BaseMethodTarget,
|
||||
InferredTarget.getPointer());
|
||||
InferredTarget.value(), BaseMethodTarget, &*InferredTarget);
|
||||
if (ResolutionError) {
|
||||
if (Diagnose) {
|
||||
Diag(ClassDecl->getLocation(),
|
||||
|
@ -425,8 +424,7 @@ bool Sema::inferCUDATargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl,
|
|||
InferredTarget = FieldMethodTarget;
|
||||
} else {
|
||||
bool ResolutionError = resolveCalleeCUDATargetConflict(
|
||||
InferredTarget.value(), FieldMethodTarget,
|
||||
InferredTarget.getPointer());
|
||||
InferredTarget.value(), FieldMethodTarget, &*InferredTarget);
|
||||
if (ResolutionError) {
|
||||
if (Diagnose) {
|
||||
Diag(ClassDecl->getLocation(),
|
||||
|
|
|
@ -484,8 +484,7 @@ public:
|
|||
}
|
||||
|
||||
const Triple *getDarwinTargetVariantTriple() const {
|
||||
return DarwinTargetVariantTriple ? DarwinTargetVariantTriple.getPointer()
|
||||
: nullptr;
|
||||
return DarwinTargetVariantTriple ? &*DarwinTargetVariantTriple : nullptr;
|
||||
}
|
||||
|
||||
void setDarwinTargetVariantSDKVersion(const VersionTuple &TheSDKVersion) {
|
||||
|
|
|
@ -884,8 +884,7 @@ ExpandMemCmpPass::runImpl(Function &F, const TargetLibraryInfo *TLI,
|
|||
const DataLayout& DL = F.getParent()->getDataLayout();
|
||||
bool MadeChanges = false;
|
||||
for (auto BBIt = F.begin(); BBIt != F.end();) {
|
||||
if (runOnBlock(*BBIt, TLI, TTI, TL, DL, PSI, BFI,
|
||||
DTU ? DTU.getPointer() : nullptr)) {
|
||||
if (runOnBlock(*BBIt, TLI, TTI, TL, DL, PSI, BFI, DTU ? &*DTU : nullptr)) {
|
||||
MadeChanges = true;
|
||||
// If changes were made, restart the function from the beginning, since
|
||||
// the structure of the function was changed.
|
||||
|
|
|
@ -907,7 +907,7 @@ public:
|
|||
} else {
|
||||
// Otherwise, we need to compute it.
|
||||
LazilyComputedDomTree.emplace(F);
|
||||
DT = LazilyComputedDomTree.getPointer();
|
||||
DT = &*LazilyComputedDomTree;
|
||||
ShouldPreserveDominatorTree = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -360,7 +360,7 @@ bool ShadowStackGCLowering::runOnFunction(Function &F) {
|
|||
|
||||
// For each instruction that escapes...
|
||||
EscapeEnumerator EE(F, "gc_cleanup", /*HandleExceptions=*/true,
|
||||
DTU ? DTU.getPointer() : nullptr);
|
||||
DTU ? &*DTU : nullptr);
|
||||
while (IRBuilder<> *AtExit = EE.Next()) {
|
||||
// Pop the entry from the shadow stack. Don't reuse CurrentHead from
|
||||
// AtEntry, since that would make the value live for the entire function.
|
||||
|
|
|
@ -20,12 +20,12 @@ using namespace llvm::pdb;
|
|||
NativeTypeUDT::NativeTypeUDT(NativeSession &Session, SymIndexId Id,
|
||||
codeview::TypeIndex TI, codeview::ClassRecord CR)
|
||||
: NativeRawSymbol(Session, PDB_SymType::UDT, Id), Index(TI),
|
||||
Class(std::move(CR)), Tag(Class.getPointer()) {}
|
||||
Class(std::move(CR)), Tag(&*Class) {}
|
||||
|
||||
NativeTypeUDT::NativeTypeUDT(NativeSession &Session, SymIndexId Id,
|
||||
codeview::TypeIndex TI, codeview::UnionRecord UR)
|
||||
: NativeRawSymbol(Session, PDB_SymType::UDT, Id), Index(TI),
|
||||
Union(std::move(UR)), Tag(Union.getPointer()) {}
|
||||
Union(std::move(UR)), Tag(&*Union) {}
|
||||
|
||||
NativeTypeUDT::NativeTypeUDT(NativeSession &Session, SymIndexId Id,
|
||||
NativeTypeUDT &UnmodifiedType,
|
||||
|
|
|
@ -46,7 +46,7 @@ ToolOutputFile::ToolOutputFile(StringRef Filename, std::error_code &EC,
|
|||
return;
|
||||
}
|
||||
OSHolder.emplace(Filename, EC, Flags);
|
||||
OS = OSHolder.getPointer();
|
||||
OS = &*OSHolder;
|
||||
// If open fails, no cleanup is needed.
|
||||
if (EC)
|
||||
Installer.Keep = true;
|
||||
|
@ -55,5 +55,5 @@ ToolOutputFile::ToolOutputFile(StringRef Filename, std::error_code &EC,
|
|||
ToolOutputFile::ToolOutputFile(StringRef Filename, int FD)
|
||||
: Installer(Filename) {
|
||||
OSHolder.emplace(FD, true);
|
||||
OS = OSHolder.getPointer();
|
||||
OS = &*OSHolder;
|
||||
}
|
||||
|
|
|
@ -924,7 +924,7 @@ PreservedAnalyses LoopFlattenPass::run(LoopNest &LN, LoopAnalysisManager &LAM,
|
|||
// this pass will simplify all loops that contain inner loops,
|
||||
// regardless of whether anything ends up being flattened.
|
||||
Changed |= Flatten(LN, &AR.DT, &AR.LI, &AR.SE, &AR.AC, &AR.TTI, &U,
|
||||
MSSAU ? MSSAU.getPointer() : nullptr);
|
||||
MSSAU ? &*MSSAU : nullptr);
|
||||
|
||||
if (!Changed)
|
||||
return PreservedAnalyses::all();
|
||||
|
@ -989,8 +989,8 @@ bool LoopFlattenLegacyPass::runOnFunction(Function &F) {
|
|||
bool Changed = false;
|
||||
for (Loop *L : *LI) {
|
||||
auto LN = LoopNest::getLoopNest(*L, *SE);
|
||||
Changed |= Flatten(*LN, DT, LI, SE, AC, TTI, nullptr,
|
||||
MSSAU ? MSSAU.getPointer() : nullptr);
|
||||
Changed |=
|
||||
Flatten(*LN, DT, LI, SE, AC, TTI, nullptr, MSSAU ? &*MSSAU : nullptr);
|
||||
}
|
||||
return Changed;
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ PreservedAnalyses LoopInstSimplifyPass::run(Loop &L, LoopAnalysisManager &AM,
|
|||
AR.MSSA->verifyMemorySSA();
|
||||
}
|
||||
if (!simplifyLoopInst(L, AR.DT, AR.LI, AR.AC, AR.TLI,
|
||||
MSSAU ? MSSAU.getPointer() : nullptr))
|
||||
MSSAU ? &*MSSAU : nullptr))
|
||||
return PreservedAnalyses::all();
|
||||
|
||||
auto PA = getLoopPassPreservedAnalyses();
|
||||
|
|
|
@ -58,10 +58,9 @@ PreservedAnalyses LoopRotatePass::run(Loop &L, LoopAnalysisManager &AM,
|
|||
Optional<MemorySSAUpdater> MSSAU;
|
||||
if (AR.MSSA)
|
||||
MSSAU = MemorySSAUpdater(AR.MSSA);
|
||||
bool Changed =
|
||||
LoopRotation(&L, &AR.LI, &AR.TTI, &AR.AC, &AR.DT, &AR.SE,
|
||||
MSSAU ? MSSAU.getPointer() : nullptr, SQ, false, Threshold,
|
||||
false, PrepareForLTO || PrepareForLTOOption);
|
||||
bool Changed = LoopRotation(&L, &AR.LI, &AR.TTI, &AR.AC, &AR.DT, &AR.SE,
|
||||
MSSAU ? &*MSSAU : nullptr, SQ, false, Threshold,
|
||||
false, PrepareForLTO || PrepareForLTOOption);
|
||||
|
||||
if (!Changed)
|
||||
return PreservedAnalyses::all();
|
||||
|
@ -130,9 +129,9 @@ public:
|
|||
? DefaultRotationThreshold
|
||||
: MaxHeaderSize;
|
||||
|
||||
return LoopRotation(L, LI, TTI, AC, &DT, &SE,
|
||||
MSSAU ? MSSAU.getPointer() : nullptr, SQ, false,
|
||||
Threshold, false, PrepareForLTO || PrepareForLTOOption);
|
||||
return LoopRotation(L, LI, TTI, AC, &DT, &SE, MSSAU ? &*MSSAU : nullptr, SQ,
|
||||
false, Threshold, false,
|
||||
PrepareForLTO || PrepareForLTOOption);
|
||||
}
|
||||
};
|
||||
} // end namespace
|
||||
|
|
|
@ -721,8 +721,8 @@ PreservedAnalyses LoopSimplifyCFGPass::run(Loop &L, LoopAnalysisManager &AM,
|
|||
if (AR.MSSA)
|
||||
MSSAU = MemorySSAUpdater(AR.MSSA);
|
||||
bool DeleteCurrentLoop = false;
|
||||
if (!simplifyLoopCFG(L, AR.DT, AR.LI, AR.SE,
|
||||
MSSAU ? MSSAU.getPointer() : nullptr, DeleteCurrentLoop))
|
||||
if (!simplifyLoopCFG(L, AR.DT, AR.LI, AR.SE, MSSAU ? &*MSSAU : nullptr,
|
||||
DeleteCurrentLoop))
|
||||
return PreservedAnalyses::all();
|
||||
|
||||
if (DeleteCurrentLoop)
|
||||
|
@ -756,9 +756,8 @@ public:
|
|||
if (MSSAA && VerifyMemorySSA)
|
||||
MSSAU->getMemorySSA()->verifyMemorySSA();
|
||||
bool DeleteCurrentLoop = false;
|
||||
bool Changed =
|
||||
simplifyLoopCFG(*L, DT, LI, SE, MSSAU ? MSSAU.getPointer() : nullptr,
|
||||
DeleteCurrentLoop);
|
||||
bool Changed = simplifyLoopCFG(*L, DT, LI, SE, MSSAU ? &*MSSAU : nullptr,
|
||||
DeleteCurrentLoop);
|
||||
if (DeleteCurrentLoop)
|
||||
LPM.markLoopAsDeleted(*L);
|
||||
return Changed;
|
||||
|
|
|
@ -143,10 +143,10 @@ static bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI,
|
|||
break;
|
||||
}
|
||||
HasDeadBlocks |= replaceConditionalBranchesOnConstant(
|
||||
II, NewValue, DTU ? DTU.getPointer() : nullptr);
|
||||
II, NewValue, DTU ? &*DTU : nullptr);
|
||||
}
|
||||
if (HasDeadBlocks)
|
||||
removeUnreachableBlocks(F, DTU ? DTU.getPointer() : nullptr);
|
||||
removeUnreachableBlocks(F, DTU ? &*DTU : nullptr);
|
||||
return !Worklist.empty();
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ static bool runPartiallyInlineLibCalls(Function &F, TargetLibraryInfo *TLI,
|
|||
case LibFunc_sqrt:
|
||||
if (TTI->haveFastSqrt(Call->getType()) &&
|
||||
optimizeSQRT(Call, CalledFunc, *CurrBB, BB, TTI,
|
||||
DTU ? DTU.getPointer() : nullptr))
|
||||
DTU ? &*DTU : nullptr))
|
||||
break;
|
||||
continue;
|
||||
default:
|
||||
|
|
|
@ -873,7 +873,7 @@ static bool runImpl(Function &F, const TargetTransformInfo &TTI,
|
|||
for (BasicBlock &BB : llvm::make_early_inc_range(F)) {
|
||||
bool ModifiedDTOnIteration = false;
|
||||
MadeChange |= optimizeBlock(BB, ModifiedDTOnIteration, TTI, DL,
|
||||
DTU ? DTU.getPointer() : nullptr);
|
||||
DTU ? &*DTU : nullptr);
|
||||
|
||||
// Restart BB iteration if the dominator tree of the Function was changed
|
||||
if (ModifiedDTOnIteration)
|
||||
|
|
|
@ -3217,8 +3217,8 @@ PreservedAnalyses SimpleLoopUnswitchPass::run(Loop &L, LoopAnalysisManager &AM,
|
|||
AR.MSSA->verifyMemorySSA();
|
||||
}
|
||||
if (!unswitchLoop(L, AR.DT, AR.LI, AR.AC, AR.AA, AR.TTI, Trivial, NonTrivial,
|
||||
UnswitchCB, &AR.SE, MSSAU ? MSSAU.getPointer() : nullptr,
|
||||
PSI, AR.BFI, DestroyLoopCB))
|
||||
UnswitchCB, &AR.SE, MSSAU ? &*MSSAU : nullptr, PSI, AR.BFI,
|
||||
DestroyLoopCB))
|
||||
return PreservedAnalyses::all();
|
||||
|
||||
if (AR.MSSA && VerifyMemorySSA)
|
||||
|
|
|
@ -195,7 +195,7 @@ int main(int argc, char **argv) {
|
|||
OS = &OutFile.os();
|
||||
} else {
|
||||
BOS.emplace(OutFile.os());
|
||||
OS = BOS.getPointer();
|
||||
OS = &*BOS;
|
||||
}
|
||||
|
||||
std::unique_ptr<MCStreamer> MS(TheTarget->createMCObjectStreamer(
|
||||
|
|
Loading…
Reference in New Issue