Skip to content

Commit 9b2c25c

Browse files
[clang] Use SmallString::operator std::string (NFC)
1 parent 2759e47 commit 9b2c25c

16 files changed

+18
-18
lines changed

clang/lib/ARCMigrate/FileRemapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ std::string FileRemapper::getRemapInfoFile(StringRef outputDir) {
4343
assert(!outputDir.empty());
4444
SmallString<128> InfoFile = outputDir;
4545
llvm::sys::path::append(InfoFile, "remap");
46-
return std::string(InfoFile.str());
46+
return std::string(InfoFile);
4747
}
4848

4949
bool FileRemapper::initFromDisk(StringRef outputDir, DiagnosticsEngine &Diag,

clang/lib/ARCMigrate/ObjCMT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2201,7 +2201,7 @@ static std::string applyEditsToTemp(FileEntryRef FE,
22012201
TmpOut.write(NewText.data(), NewText.size());
22022202
TmpOut.close();
22032203

2204-
return std::string(TempPath.str());
2204+
return std::string(TempPath);
22052205
}
22062206

22072207
bool arcmt::getFileRemappingsFromFileList(

clang/lib/AST/Expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind IK,
690690

691691
if (!Buffer.empty() && Buffer.front() == '\01')
692692
return std::string(Buffer.substr(1));
693-
return std::string(Buffer.str());
693+
return std::string(Buffer);
694694
}
695695
return std::string(ND->getIdentifier()->getName());
696696
}
@@ -986,7 +986,7 @@ std::string FixedPointLiteral::getValueAsString(unsigned Radix) const {
986986
SmallString<64> S;
987987
FixedPointValueToString(
988988
S, llvm::APSInt::getUnsigned(getValue().getZExtValue()), Scale);
989-
return std::string(S.str());
989+
return std::string(S);
990990
}
991991

992992
void CharacterLiteral::print(unsigned Val, CharacterLiteralKind Kind,

clang/lib/AST/Mangle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ class ASTNameGenerator::Implementation {
464464
SmallString<40> Mangled;
465465
auto Prefix = getClassSymbolPrefix(Kind, OCD->getASTContext());
466466
llvm::Mangler::getNameWithPrefix(Mangled, Prefix + ClassName, DL);
467-
return std::string(Mangled.str());
467+
return std::string(Mangled);
468468
};
469469

470470
return {

clang/lib/Basic/FileManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ void FileManager::fillRealPathName(FileEntry *UFE, llvm::StringRef FileName) {
532532
// misleading. We need to clean up the interface here.
533533
makeAbsolutePath(AbsPath);
534534
llvm::sys::path::remove_dots(AbsPath, /*remove_dot_dot=*/true);
535-
UFE->RealPathName = std::string(AbsPath.str());
535+
UFE->RealPathName = std::string(AbsPath);
536536
}
537537

538538
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>

clang/lib/CodeGen/CGCUDANV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
893893
llvm::raw_svector_ostream OS(ModuleID);
894894
OS << ModuleIDPrefix << llvm::format("%" PRIx64, FatbinWrapper->getGUID());
895895
llvm::Constant *ModuleIDConstant = makeConstantArray(
896-
std::string(ModuleID.str()), "", ModuleIDSectionName, 32, /*AddNull=*/true);
896+
std::string(ModuleID), "", ModuleIDSectionName, 32, /*AddNull=*/true);
897897

898898
// Create an alias for the FatbinWrapper that nvcc will look for.
899899
llvm::GlobalAlias::create(llvm::GlobalValue::ExternalLinkage,

clang/lib/CrossTU/CrossTranslationUnit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ CrossTranslationUnitContext::getLookupName(const NamedDecl *ND) {
247247
bool Ret = index::generateUSRForDecl(ND, DeclUSR);
248248
if (Ret)
249249
return {};
250-
return std::string(DeclUSR.str());
250+
return std::string(DeclUSR);
251251
}
252252

253253
/// Recursively visits the decls of a DeclContext, and returns one with the

clang/lib/Lex/ModuleMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void ModuleMap::resolveHeader(Module *Mod,
308308
setUmbrellaHeaderAsWritten(Mod, *File, Header.FileName,
309309
RelativePathName.str());
310310
} else {
311-
Module::Header H = {Header.FileName, std::string(RelativePathName.str()),
311+
Module::Header H = {Header.FileName, std::string(RelativePathName),
312312
*File};
313313
addHeader(Mod, H, headerKindToRole(Header.Kind));
314314
}

clang/lib/Tooling/ASTDiff/ASTDiff.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,12 @@ std::string SyntaxTree::Impl::getStmtValue(const Stmt *S) const {
453453
if (auto *I = dyn_cast<IntegerLiteral>(S)) {
454454
SmallString<256> Str;
455455
I->getValue().toString(Str, /*Radix=*/10, /*Signed=*/false);
456-
return std::string(Str.str());
456+
return std::string(Str);
457457
}
458458
if (auto *F = dyn_cast<FloatingLiteral>(S)) {
459459
SmallString<256> Str;
460460
F->getValue().toString(Str);
461-
return std::string(Str.str());
461+
return std::string(Str);
462462
}
463463
if (auto *D = dyn_cast<DeclRefExpr>(S))
464464
return getRelativeName(D->getDecl(), getEnclosingDeclContext(AST, S));

clang/lib/Tooling/CompilationDatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ std::string GetClangToolCommand() {
216216
SmallString<128> ClangToolPath;
217217
ClangToolPath = llvm::sys::path::parent_path(ClangExecutable);
218218
llvm::sys::path::append(ClangToolPath, "clang-tool");
219-
return std::string(ClangToolPath.str());
219+
return std::string(ClangToolPath);
220220
}
221221

222222
} // namespace

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ static void visitPrebuiltModule(StringRef PrebuiltModuleFilename,
103103
static std::string makeObjFileName(StringRef FileName) {
104104
SmallString<128> ObjFileName(FileName);
105105
llvm::sys::path::replace_extension(ObjFileName, "o");
106-
return std::string(ObjFileName.str());
106+
return std::string(ObjFileName);
107107
}
108108

109109
/// Deduce the dependency target based on the output file and input files.

clang/lib/Tooling/Tooling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ llvm::Expected<std::string> getAbsolutePath(llvm::vfs::FileSystem &FS,
261261
if (auto EC = FS.makeAbsolute(AbsolutePath))
262262
return llvm::errorCodeToError(EC);
263263
llvm::sys::path::native(AbsolutePath);
264-
return std::string(AbsolutePath.str());
264+
return std::string(AbsolutePath);
265265
}
266266

267267
std::string getAbsolutePath(StringRef File) {

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,7 @@ struct AttributeSubjectMatchRule {
19191919
}
19201920
if (isAbstractRule())
19211921
Result += "_abstract";
1922-
return std::string(Result.str());
1922+
return std::string(Result);
19231923
}
19241924

19251925
std::string getEnumValue() const { return "attr::" + getEnumValueName(); }

clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void clang::EmitClangCommentHTMLNamedCharacterReferences(RecordKeeper &Records,
6666
}
6767
CLiteral.append(";");
6868

69-
StringMatcher::StringPair Match(Spelling, std::string(CLiteral.str()));
69+
StringMatcher::StringPair Match(Spelling, std::string(CLiteral));
7070
NameToUTF8.push_back(Match);
7171
}
7272

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ static std::string getDiagCategoryEnum(llvm::StringRef name) {
13431343
SmallString<256> enumName = llvm::StringRef("DiagCat_");
13441344
for (llvm::StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
13451345
enumName += isalnum(*I) ? *I : '_';
1346-
return std::string(enumName.str());
1346+
return std::string(enumName);
13471347
}
13481348

13491349
/// Emit the array of diagnostic subgroups.

clang/utils/TableGen/MveEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ class ACLEIntrinsic {
896896
llvm::APInt i = iOrig.trunc(64);
897897
SmallString<40> s;
898898
i.toString(s, 16, true, true);
899-
return std::string(s.str());
899+
return std::string(s);
900900
}
901901

902902
std::string genSema() const {

0 commit comments

Comments
 (0)