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.
}
}
- 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();
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);
}
/// 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)
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;
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>(
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;
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(),
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(),
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))
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:
= 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;
}
// 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))
"failed writing index");
}
- return llvm::writeFileAtomically(
- (IndexPath + "-%%%%%%%%").str(), IndexPath,
- llvm::StringRef(OutputBuffer.data(), OutputBuffer.size()));
+ return llvm::writeFileAtomically((IndexPath + "-%%%%%%%%").str(), IndexPath,
+ OutputBuffer);
}
namespace {
if (Loc.isMacroID())
return Lexer::getImmediateMacroName(Loc, getSourceManager(),
getLangOpts());
- SmallVector<char, 16> buf;
+ SmallString<16> buf;
return Lexer::getSpelling(Loc, buf, getSourceManager(), getLangOpts());
}
}
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