Skip to content

Commit

Permalink
[clang] Replace SmallStr.str().str() with std::string conversion oper…
Browse files Browse the repository at this point in the history
…ator.

Use the std::string conversion operator introduced in
d704921.
  • Loading branch information
JDevlieghere committed Jan 30, 2020
1 parent b2924d9 commit 509e21a
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions clang/lib/AST/Expr.cpp
Expand Up @@ -856,7 +856,7 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) {

Out << Proto;

return Name.str().str();
return std::string(Name);
}
if (const CapturedDecl *CD = dyn_cast<CapturedDecl>(CurrentDecl)) {
for (const DeclContext *DC = CD->getParent(); DC; DC = DC->getParent())
Expand Down Expand Up @@ -887,7 +887,7 @@ std::string PredefinedExpr::ComputeName(IdentKind IK, const Decl *CurrentDecl) {
MD->getSelector().print(Out);
Out << ']';

return Name.str().str();
return std::string(Name);
}
if (isa<TranslationUnitDecl>(CurrentDecl) && IK == PrettyFunction) {
// __PRETTY_FUNCTION__ -> "top level", the others produce an empty string.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CoverageMappingGen.cpp
Expand Up @@ -1282,7 +1282,7 @@ std::string normalizeFilename(StringRef Filename) {
llvm::SmallString<256> Path(Filename);
llvm::sys::fs::make_absolute(Path);
llvm::sys::path::remove_dots(Path, /*remove_dot_dot=*/true);
return Path.str().str();
return std::string(Path);
}

} // end anonymous namespace
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CrossTU/CrossTranslationUnit.cpp
Expand Up @@ -149,7 +149,7 @@ parseCrossTUIndex(StringRef IndexPath, StringRef CrossTUDir) {
StringRef FileName = LineRef.substr(Pos + 1);
SmallString<256> FilePath = CrossTUDir;
llvm::sys::path::append(FilePath, FileName);
Result[LookupName] = FilePath.str().str();
Result[LookupName] = std::string(FilePath);
} else
return llvm::make_error<IndexError>(
index_error_code::invalid_index_format, IndexPath.str(), LineNo);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/Driver.cpp
Expand Up @@ -4650,7 +4650,7 @@ std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const {
SmallString<128> P(Dir[0] == '=' ? SysRoot + Dir.substr(1) : Dir);
llvm::sys::path::append(P, Name);
if (llvm::sys::fs::exists(Twine(P)))
return P.str().str();
return std::string(P);
}
return None;
};
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Lex/HeaderSearch.cpp
Expand Up @@ -159,7 +159,7 @@ std::string HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
llvm::sys::fs::make_absolute(Result);
llvm::sys::path::append(Result, ModuleName + ".pcm");
if (getFileMgr().getFile(Result.str()))
return Result.str().str();
return std::string(Result);
}
return {};
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
Expand Up @@ -106,7 +106,7 @@ static std::string fileNameToURI(StringRef Filename) {
}
});

return Ret.str().str();
return std::string(Ret);
}

static json::Object createArtifactLocation(const FileEntry &FE) {
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/clang-refactor/TestSupport.cpp
Expand Up @@ -190,7 +190,7 @@ bool TestRefactoringResultConsumer::handleAllResults() {
const PartialDiagnosticAt &Diag = Err.getDiagnostic();
llvm::SmallString<100> DiagText;
Diag.second.EmitToString(getDiags(), DiagText);
ErrorMessage = DiagText.str().str();
ErrorMessage = std::string(DiagText);
});
}
if (!CanonicalResult && !CanonicalErrorMessage) {
Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/Driver/SanitizerArgsTest.cpp
Expand Up @@ -43,7 +43,7 @@ std::string concatPaths(llvm::ArrayRef<StringRef> Components) {
llvm::SmallString<128> P;
for (StringRef C : Components)
llvm::sys::path::append(P, C);
return P.str().str();
return std::string(P);
}

class SanitizerArgsTest : public ::testing::Test {
Expand Down
4 changes: 2 additions & 2 deletions clang/unittests/Frontend/FrontendActionTest.cpp
Expand Up @@ -252,8 +252,8 @@ TEST(ASTFrontendAction, ExternalSemaSource) {
ASSERT_TRUE(Compiler.ExecuteAction(TestAction));
// There should be one error correcting to 'moo' and a note attached to it.
EXPECT_EQ("use of undeclared identifier 'foo'; did you mean 'moo'?",
TDC->Error.str().str());
EXPECT_EQ("This is a note", TDC->Note.str().str());
std::string(TDC->Error));
EXPECT_EQ("This is a note", std::string(TDC->Note));
}

TEST(GeneratePCHFrontendAction, CacheGeneratedPCH) {
Expand Down

0 comments on commit 509e21a

Please sign in to comment.