forked from OSchip/llvm-project
[clang][NFC] Use SmallString instead of SmallVector<char
Simplifies code in some places and is more explicit about what is being used. No additional includes were added here so no impact on compile time.
This commit is contained in:
parent
0765d78a41
commit
d44edfc109
|
@ -150,7 +150,7 @@ void State::addCallStack(unsigned Limit) {
|
|||
}
|
||||
}
|
||||
|
||||
SmallVector<char, 128> Buffer;
|
||||
SmallString<128> Buffer;
|
||||
llvm::raw_svector_ostream Out(Buffer);
|
||||
F->describe(Out);
|
||||
addDiag(CallLocation, diag::note_constexpr_call_here) << Out.str();
|
||||
|
|
|
@ -1418,7 +1418,7 @@ void JSONNodeDumper::VisitFixedPointLiteral(const FixedPointLiteral *FPL) {
|
|||
JOS.attribute("value", FPL->getValueAsString(/*Radix=*/10));
|
||||
}
|
||||
void JSONNodeDumper::VisitFloatingLiteral(const FloatingLiteral *FL) {
|
||||
llvm::SmallVector<char, 16> Buffer;
|
||||
llvm::SmallString<16> Buffer;
|
||||
FL->getValue().toString(Buffer);
|
||||
JOS.attribute("value", Buffer);
|
||||
}
|
||||
|
|
|
@ -808,7 +808,7 @@ FormatDiagnostic(const char *DiagStr, const char *DiagEnd,
|
|||
/// QualTypeVals - Pass a vector of arrays so that QualType names can be
|
||||
/// compared to see if more information is needed to be printed.
|
||||
SmallVector<intptr_t, 2> QualTypeVals;
|
||||
SmallVector<char, 64> Tree;
|
||||
SmallString<64> Tree;
|
||||
|
||||
for (unsigned i = 0, e = getNumArgs(); i < e; ++i)
|
||||
if (getArgKind(i) == DiagnosticsEngine::ak_qualtype)
|
||||
|
|
|
@ -162,8 +162,7 @@ parseCrossTUIndex(StringRef IndexPath) {
|
|||
StringRef LookupName = LineRef.substr(0, Delimiter);
|
||||
|
||||
// Store paths with posix-style directory separator.
|
||||
SmallVector<char, 32> FilePath;
|
||||
llvm::Twine{LineRef.substr(Delimiter + 1)}.toVector(FilePath);
|
||||
SmallString<32> FilePath(LineRef.substr(Delimiter + 1));
|
||||
llvm::sys::path::native(FilePath, llvm::sys::path::Style::posix);
|
||||
|
||||
bool InsertionOccured;
|
||||
|
@ -624,15 +623,14 @@ parseInvocationList(StringRef FileContent, llvm::sys::path::Style PathStyle) {
|
|||
return llvm::make_error<IndexError>(
|
||||
index_error_code::invocation_list_wrong_format);
|
||||
|
||||
SmallVector<char, 32> ValueStorage;
|
||||
SmallString<32> ValueStorage;
|
||||
StringRef SourcePath = Key->getValue(ValueStorage);
|
||||
|
||||
// Store paths with PathStyle directory separator.
|
||||
SmallVector<char, 32> NativeSourcePath;
|
||||
llvm::Twine{SourcePath}.toVector(NativeSourcePath);
|
||||
SmallString<32> NativeSourcePath(SourcePath);
|
||||
llvm::sys::path::native(NativeSourcePath, PathStyle);
|
||||
|
||||
StringRef InvocationKey{NativeSourcePath.begin(), NativeSourcePath.size()};
|
||||
StringRef InvocationKey(NativeSourcePath);
|
||||
|
||||
if (InvocationList.find(InvocationKey) != InvocationList.end())
|
||||
return llvm::make_error<IndexError>(
|
||||
|
|
|
@ -1818,7 +1818,7 @@ bool Sema::findMacroSpelling(SourceLocation &locref, StringRef name) {
|
|||
loc = getSourceManager().getExpansionLoc(loc);
|
||||
|
||||
// If that's written with the name, stop here.
|
||||
SmallVector<char, 16> buffer;
|
||||
SmallString<16> buffer;
|
||||
if (getPreprocessor().getSpelling(loc, buffer) == name) {
|
||||
locref = loc;
|
||||
return true;
|
||||
|
|
|
@ -584,7 +584,7 @@ void Sema::PrintInstantiationStack() {
|
|||
|
||||
case CodeSynthesisContext::DefaultTemplateArgumentInstantiation: {
|
||||
TemplateDecl *Template = cast<TemplateDecl>(Active->Template);
|
||||
SmallVector<char, 128> TemplateArgsStr;
|
||||
SmallString<128> TemplateArgsStr;
|
||||
llvm::raw_svector_ostream OS(TemplateArgsStr);
|
||||
Template->printName(OS);
|
||||
printTemplateArgumentList(OS, Active->template_arguments(),
|
||||
|
@ -650,7 +650,7 @@ void Sema::PrintInstantiationStack() {
|
|||
ParmVarDecl *Param = cast<ParmVarDecl>(Active->Entity);
|
||||
FunctionDecl *FD = cast<FunctionDecl>(Param->getDeclContext());
|
||||
|
||||
SmallVector<char, 128> TemplateArgsStr;
|
||||
SmallString<128> TemplateArgsStr;
|
||||
llvm::raw_svector_ostream OS(TemplateArgsStr);
|
||||
FD->printName(OS);
|
||||
printTemplateArgumentList(OS, Active->template_arguments(),
|
||||
|
@ -802,7 +802,7 @@ void Sema::PrintInstantiationStack() {
|
|||
assert(isa<FunctionDecl>(Active->Entity));
|
||||
DiagID = diag::note_checking_constraints_for_function_here;
|
||||
}
|
||||
SmallVector<char, 128> TemplateArgsStr;
|
||||
SmallString<128> TemplateArgsStr;
|
||||
llvm::raw_svector_ostream OS(TemplateArgsStr);
|
||||
cast<NamedDecl>(Active->Entity)->printName(OS);
|
||||
if (!isa<FunctionDecl>(Active->Entity))
|
||||
|
|
|
@ -1622,7 +1622,7 @@ namespace {
|
|||
ASTWriter &Writer;
|
||||
|
||||
// Keep track of the framework names we've used during serialization.
|
||||
SmallVector<char, 128> FrameworkStringData;
|
||||
SmallString<128> FrameworkStringData;
|
||||
llvm::StringMap<unsigned> FrameworkNameOffset;
|
||||
|
||||
public:
|
||||
|
@ -1709,8 +1709,7 @@ namespace {
|
|||
= FrameworkNameOffset.find(Data.HFI.Framework);
|
||||
if (Pos == FrameworkNameOffset.end()) {
|
||||
Offset = FrameworkStringData.size() + 1;
|
||||
FrameworkStringData.append(Data.HFI.Framework.begin(),
|
||||
Data.HFI.Framework.end());
|
||||
FrameworkStringData.append(Data.HFI.Framework);
|
||||
FrameworkStringData.push_back(0);
|
||||
|
||||
FrameworkNameOffset[Data.HFI.Framework] = Offset;
|
||||
|
|
|
@ -905,7 +905,7 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr,
|
|||
}
|
||||
|
||||
// The output buffer, into which the global index will be written.
|
||||
SmallVector<char, 16> OutputBuffer;
|
||||
SmallString<16> OutputBuffer;
|
||||
{
|
||||
llvm::BitstreamWriter OutputStream(OutputBuffer);
|
||||
if (Builder.writeIndex(OutputStream))
|
||||
|
@ -913,9 +913,8 @@ GlobalModuleIndex::writeIndex(FileManager &FileMgr,
|
|||
"failed writing index");
|
||||
}
|
||||
|
||||
return llvm::writeFileAtomically(
|
||||
(IndexPath + "-%%%%%%%%").str(), IndexPath,
|
||||
llvm::StringRef(OutputBuffer.data(), OutputBuffer.size()));
|
||||
return llvm::writeFileAtomically((IndexPath + "-%%%%%%%%").str(), IndexPath,
|
||||
OutputBuffer);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -93,7 +93,7 @@ StringRef CheckerContext::getMacroNameOrSpelling(SourceLocation &Loc) {
|
|||
if (Loc.isMacroID())
|
||||
return Lexer::getImmediateMacroName(Loc, getSourceManager(),
|
||||
getLangOpts());
|
||||
SmallVector<char, 16> buf;
|
||||
SmallString<16> buf;
|
||||
return Lexer::getSpelling(Loc, buf, getSourceManager(), getLangOpts());
|
||||
}
|
||||
|
||||
|
|
|
@ -133,13 +133,13 @@ const NamedDecl *getNamedDeclFor(const ASTContext &Context,
|
|||
}
|
||||
|
||||
std::string getUSRForDecl(const Decl *Decl) {
|
||||
llvm::SmallVector<char, 128> Buff;
|
||||
llvm::SmallString<128> Buff;
|
||||
|
||||
// FIXME: Add test for the nullptr case.
|
||||
if (Decl == nullptr || index::generateUSRForDecl(Decl, Buff))
|
||||
return "";
|
||||
|
||||
return std::string(Buff.data(), Buff.size());
|
||||
return std::string(Buff);
|
||||
}
|
||||
|
||||
} // end namespace tooling
|
||||
|
|
Loading…
Reference in New Issue