[clang] 9b2c25c - [clang] Use SmallString::operator std::string (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 20 18:57:43 PST 2024
Author: Kazu Hirata
Date: 2024-01-20T18:57:30-08:00
New Revision: 9b2c25c70466d6f081a2915e661840f965b6056a
URL: https://github.com/llvm/llvm-project/commit/9b2c25c70466d6f081a2915e661840f965b6056a
DIFF: https://github.com/llvm/llvm-project/commit/9b2c25c70466d6f081a2915e661840f965b6056a.diff
LOG: [clang] Use SmallString::operator std::string (NFC)
Added:
Modified:
clang/lib/ARCMigrate/FileRemapper.cpp
clang/lib/ARCMigrate/ObjCMT.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/Mangle.cpp
clang/lib/Basic/FileManager.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Tooling/ASTDiff/ASTDiff.cpp
clang/lib/Tooling/CompilationDatabase.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/lib/Tooling/Tooling.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
clang/utils/TableGen/MveEmitter.cpp
Removed:
################################################################################
diff --git a/clang/lib/ARCMigrate/FileRemapper.cpp b/clang/lib/ARCMigrate/FileRemapper.cpp
index 7abc862ceecc237..84024c3bafdca01 100644
--- a/clang/lib/ARCMigrate/FileRemapper.cpp
+++ b/clang/lib/ARCMigrate/FileRemapper.cpp
@@ -43,7 +43,7 @@ std::string FileRemapper::getRemapInfoFile(StringRef outputDir) {
assert(!outputDir.empty());
SmallString<128> InfoFile = outputDir;
llvm::sys::path::append(InfoFile, "remap");
- return std::string(InfoFile.str());
+ return std::string(InfoFile);
}
bool FileRemapper::initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag,
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index ed363a46a200443..0786c81516b2d14 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -2201,7 +2201,7 @@ static std::string applyEditsToTemp(FileEntryRef FE,
TmpOut.write(NewText.data(), NewText.size());
TmpOut.close();
- return std::string(TempPath.str());
+ return std::string(TempPath);
}
bool arcmt::getFileRemappingsFromFileList(
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index ade403da65dd959..f1efa98e175edf5 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -690,7 +690,7 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
if (!Buffer.empty() && Buffer.front() == '\01')
return std::string(Buffer.substr(1));
- return std::string(Buffer.str());
+ return std::string(Buffer);
}
return std::string(ND->getIdentifier()->getName());
}
@@ -986,7 +986,7 @@ std::string FixedPointLiteral::getValueAsString(unsigned Radix) const {
SmallString<64> S;
FixedPointValueToString(
S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale);
- return std::string(S.str());
+ return std::string(S);
}
void CharacterLiteral::print(unsigned Val, CharacterLiteralKind Kind,
diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index d3a6b61fd2bec9c..30cff1ba2e6f379 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -464,7 +464,7 @@ class ASTNameGenerator::Implementation {
SmallString<40> Mangled;
auto Prefix = getClassSymbolPrefix(Kind, OCD->getASTContext());
llvm::Mangler::getNameWithPrefix(Mangled, Prefix + ClassName, DL);
- return std::string(Mangled.str());
+ return std::string(Mangled);
};
return {
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index d16626b10652136..974c8c22598f630 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -532,7 +532,7 @@ void FileManager::fillRealPathName(FileEntry *UFE, llvm::StringRef FileName) {
// misleading. We need to clean up the interface here.
makeAbsolutePath(AbsPath);
llvm::sys::path::remove_dots(AbsPath, /*remove_dot_dot=*/true);
- UFE->RealPathName = std::string(AbsPath.str());
+ UFE->RealPathName = std::string(AbsPath);
}
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 353370f1d761b92..5b43272bfa62f40 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -893,7 +893,7 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
llvm::raw_svector_ostream OS(ModuleID);
OS << ModuleIDPrefix << llvm::format("%" PRIx64, FatbinWrapper->getGUID());
llvm::Constant *ModuleIDConstant = makeConstantArray(
- std::string(ModuleID.str()), "", ModuleIDSectionName, 32, /*AddNull=*/true);
+ std::string(ModuleID), "", ModuleIDSectionName, 32, /*AddNull=*/true);
// Create an alias for the FatbinWrapper that nvcc will look for.
llvm::GlobalAlias::create(llvm::GlobalValue::ExternalLinkage,
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 94c10e50d7d0648..986470042bd83cf 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -247,7 +247,7 @@ CrossTranslationUnitContext::getLookupName(const NamedDecl *ND) {
bool Ret = index::generateUSRForDecl(ND, DeclUSR);
if (Ret)
return {};
- return std::string(DeclUSR.str());
+ return std::string(DeclUSR);
}
/// Recursively visits the decls of a DeclContext, and returns one with the
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 42d55d09ea5a136..afb2948f05ae5b4 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -308,7 +308,7 @@ void ModuleMap::resolveHeader(Module *Mod,
setUmbrellaHeaderAsWritten(Mod, *File, Header.FileName,
RelativePathName.str());
} else {
- Module::Header H = {Header.FileName, std::string(RelativePathName.str()),
+ Module::Header H = {Header.FileName, std::string(RelativePathName),
*File};
addHeader(Mod, H, headerKindToRole(Header.Kind));
}
diff --git a/clang/lib/Tooling/ASTDiff/ASTDiff.cpp b/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
index 356b4bd5a1b85cb..5f7153cd53ac210 100644
--- a/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ b/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -453,12 +453,12 @@ std::string SyntaxTree::Impl::getStmtValue(const Stmt *S) const {
if (auto *I = dyn_cast<IntegerLiteral>(S)) {
SmallString<256> Str;
I->getValue().toString(Str, /*Radix=*/10, /*Signed=*/false);
- return std::string(Str.str());
+ return std::string(Str);
}
if (auto *F = dyn_cast<FloatingLiteral>(S)) {
SmallString<256> Str;
F->getValue().toString(Str);
- return std::string(Str.str());
+ return std::string(Str);
}
if (auto *D = dyn_cast<DeclRefExpr>(S))
return getRelativeName(D->getDecl(), getEnclosingDeclContext(AST, S));
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index 9d8f0d03a7d5cba..af18194ae0fe44d 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -216,7 +216,7 @@ std::string GetClangToolCommand() {
SmallString<128> ClangToolPath;
ClangToolPath = llvm::sys::path::parent_path(ClangExecutable);
llvm::sys::path::append(ClangToolPath, "clang-tool");
- return std::string(ClangToolPath.str());
+ return std::string(ClangToolPath);
}
} // namespace
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
index c54e6d523800b6b..7ab4a699af6dfca 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -103,7 +103,7 @@ static void visitPrebuiltModule(StringRef PrebuiltModuleFilename,
static std::string makeObjFileName(StringRef FileName) {
SmallString<128> ObjFileName(FileName);
llvm::sys::path::replace_extension(ObjFileName, "o");
- return std::string(ObjFileName.str());
+ return std::string(ObjFileName);
}
/// Deduce the dependency target based on the output file and input files.
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index d82cd5e886e46ab..c5c3cdb47e92e89 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -261,7 +261,7 @@ llvm::Expected<std::string> getAbsolutePath(llvm::vfs::FileSystem &FS,
if (auto EC = FS.makeAbsolute(AbsolutePath))
return llvm::errorCodeToError(EC);
llvm::sys::path::native(AbsolutePath);
- return std::string(AbsolutePath.str());
+ return std::string(AbsolutePath);
}
std::string getAbsolutePath(StringRef File) {
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 3888e6c08ab0f43..89b88e386f25729 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1919,7 +1919,7 @@ struct AttributeSubjectMatchRule {
}
if (isAbstractRule())
Result += "_abstract";
- return std::string(Result.str());
+ return std::string(Result);
}
std::string getEnumValue() const { return "attr::" + getEnumValueName(); }
diff --git a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
index 47b871afdeebea7..f1cd9af0519d1b8 100644
--- a/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
@@ -66,7 +66,7 @@ void clang::EmitClangCommentHTMLNamedCharacterReferences(RecordKeeper &Records,
}
CLiteral.append(";");
- StringMatcher::StringPair Match(Spelling, std::string(CLiteral.str()));
+ StringMatcher::StringPair Match(Spelling, std::string(CLiteral));
NameToUTF8.push_back(Match);
}
diff --git a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
index a8a80ed882bdef0..480c7c83f5f8ef6 100644
--- a/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ b/clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -1343,7 +1343,7 @@ static std::string getDiagCategoryEnum(llvm::StringRef name) {
SmallString<256> enumName = llvm::StringRef("DiagCat_");
for (llvm::StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
enumName += isalnum(*I) ? *I : '_';
- return std::string(enumName.str());
+ return std::string(enumName);
}
/// Emit the array of diagnostic subgroups.
diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index f0bd0865c1c8b56..496cb10d14f2de5 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -896,7 +896,7 @@ class ACLEIntrinsic {
llvm::APInt i = iOrig.trunc(64);
SmallString<40> s;
i.toString(s, 16, true, true);
- return std::string(s.str());
+ return std::string(s);
}
std::string genSema() const {
More information about the cfe-commits
mailing list