aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 20:23:46 +0100
committerBenjamin Kramer <benny.kra@googlemail.com>2020-01-28 23:25:25 +0100
commitadcd02683856c30ba6f349279509acecd90063df (patch)
tree7b5927ef2ecab1618842183fac5ebe848f5832dd /clang/lib/Frontend/ASTUnit.cpp
parent5eaf44f99f0a0a3bdfa892892b8aaca841c8dbe0 (diff)
downloadllvm-adcd02683856c30ba6f349279509acecd90063df.zip
llvm-adcd02683856c30ba6f349279509acecd90063df.tar.gz
llvm-adcd02683856c30ba6f349279509acecd90063df.tar.bz2
Make llvm::StringRef to std::string conversions explicit.
This is how it should've been and brings it more in line with std::string_view. There should be no functional change here. This is mostly mechanical from a custom clang-tidy check, with a lot of manual fixups. It uncovers a lot of minor inefficiencies. This doesn't actually modify StringRef yet, I'll do that in a follow-up.
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index b326495..7920aa2 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -784,7 +784,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
UserFilesAreVolatile);
AST->ModuleCache = new InMemoryModuleCache;
AST->HSOpts = std::make_shared<HeaderSearchOptions>();
- AST->HSOpts->ModuleFormat = PCHContainerRdr.getFormat();
+ AST->HSOpts->ModuleFormat = std::string(PCHContainerRdr.getFormat());
AST->HeaderInfo.reset(new HeaderSearch(AST->HSOpts,
AST->getSourceManager(),
AST->getDiagnostics(),
@@ -847,7 +847,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromASTFile(
return nullptr;
}
- AST->OriginalSourceFile = AST->Reader->getOriginalSourceFile();
+ AST->OriginalSourceFile = std::string(AST->Reader->getOriginalSourceFile());
PP.setCounterValue(Counter);
@@ -1131,7 +1131,8 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
CICleanup(Clang.get());
Clang->setInvocation(CCInvocation);
- OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
+ OriginalSourceFile =
+ std::string(Clang->getFrontendOpts().Inputs[0].getFile());
// Set up diagnostics, capturing any diagnostics that would
// otherwise be dropped.
@@ -1260,13 +1261,13 @@ makeStandaloneDiagnostic(const LangOptions &LangOpts,
ASTUnit::StandaloneDiagnostic OutDiag;
OutDiag.ID = InDiag.getID();
OutDiag.Level = InDiag.getLevel();
- OutDiag.Message = InDiag.getMessage();
+ OutDiag.Message = std::string(InDiag.getMessage());
OutDiag.LocOffset = 0;
if (InDiag.getLocation().isInvalid())
return OutDiag;
const SourceManager &SM = InDiag.getLocation().getManager();
SourceLocation FileLoc = SM.getFileLoc(InDiag.getLocation());
- OutDiag.Filename = SM.getFilename(FileLoc);
+ OutDiag.Filename = std::string(SM.getFilename(FileLoc));
if (OutDiag.Filename.empty())
return OutDiag;
OutDiag.LocOffset = SM.getFileOffset(FileLoc);
@@ -1532,7 +1533,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
if (!ResourceFilesPath.empty()) {
// Override the resources path.
- CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath;
+ CI->getHeaderSearchOpts().ResourceDir = std::string(ResourceFilesPath);
}
AST->OnlyLocalDecls = OnlyLocalDecls;
AST->CaptureDiagnostics = CaptureDiagnostics;
@@ -1564,7 +1565,8 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
CICleanup(Clang.get());
Clang->setInvocation(std::move(CI));
- AST->OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
+ AST->OriginalSourceFile =
+ std::string(Clang->getFrontendOpts().Inputs[0].getFile());
// Set up diagnostics, capturing any diagnostics that would
// otherwise be dropped.
@@ -1767,13 +1769,14 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
PPOpts.RetainExcludedConditionalBlocks = RetainExcludedConditionalBlocks;
// Override the resources path.
- CI->getHeaderSearchOpts().ResourceDir = ResourceFilesPath;
+ CI->getHeaderSearchOpts().ResourceDir = std::string(ResourceFilesPath);
CI->getFrontendOpts().SkipFunctionBodies =
SkipFunctionBodies == SkipFunctionBodiesScope::PreambleAndMainFile;
if (ModuleFormat)
- CI->getHeaderSearchOpts().ModuleFormat = ModuleFormat.getValue();
+ CI->getHeaderSearchOpts().ModuleFormat =
+ std::string(ModuleFormat.getValue());
// Create the AST unit.
std::unique_ptr<ASTUnit> AST;
@@ -2165,7 +2168,7 @@ void ASTUnit::CodeComplete(
assert(IncludeBriefComments == this->IncludeBriefCommentsInCodeCompletion);
- FrontendOpts.CodeCompletionAt.FileName = File;
+ FrontendOpts.CodeCompletionAt.FileName = std::string(File);
FrontendOpts.CodeCompletionAt.Line = Line;
FrontendOpts.CodeCompletionAt.Column = Column;
@@ -2185,7 +2188,8 @@ void ASTUnit::CodeComplete(
auto &Inv = *CCInvocation;
Clang->setInvocation(std::move(CCInvocation));
- OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
+ OriginalSourceFile =
+ std::string(Clang->getFrontendOpts().Inputs[0].getFile());
// Set up diagnostics, capturing any diagnostics produced.
Clang->setDiagnostics(&Diag);