forked from OSchip/llvm-project
[clangd] NFC: Use SmallVector<T> where possible
SmallVector<T> with default size is now the recommended version (D92522). Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D92788
This commit is contained in:
parent
0447f3508f
commit
ee02e20c08
|
@ -258,7 +258,7 @@ std::string printTemplateSpecializationArgs(const NamedDecl &ND) {
|
|||
// TemplateArgumentTypeLocs, they only have TemplateArgumentTypes. So we
|
||||
// create a new argument location list from TypeSourceInfo.
|
||||
auto STL = TSI->getTypeLoc().getAs<TemplateSpecializationTypeLoc>();
|
||||
llvm::SmallVector<TemplateArgumentLoc, 8> ArgLocs;
|
||||
llvm::SmallVector<TemplateArgumentLoc> ArgLocs;
|
||||
ArgLocs.reserve(STL.getNumArgs());
|
||||
for (unsigned I = 0; I < STL.getNumArgs(); ++I)
|
||||
ArgLocs.push_back(STL.getArgLoc(I));
|
||||
|
|
|
@ -367,7 +367,7 @@ llvm::ArrayRef<ArgStripper::Rule> ArgStripper::rulesFor(llvm::StringRef Arg) {
|
|||
for (unsigned ID = 1 /*Skip INVALID */; ID < DriverID::LastOption; ++ID) {
|
||||
if (PrevAlias[ID] || ID == DriverID::OPT_Xclang)
|
||||
continue; // Not canonical, or specially handled.
|
||||
llvm::SmallVector<Rule, 8> Rules;
|
||||
llvm::SmallVector<Rule> Rules;
|
||||
// Iterate over each alias, to add rules for parsing it.
|
||||
for (unsigned A = ID; A != DriverID::OPT_INVALID; A = NextAlias[A]) {
|
||||
if (Prefixes[A] == nullptr) // option groups.
|
||||
|
|
|
@ -92,7 +92,7 @@ private:
|
|||
static llvm::ArrayRef<Rule> rulesFor(llvm::StringRef Arg);
|
||||
const Rule *matchingRule(llvm::StringRef Arg, unsigned Mode,
|
||||
unsigned &ArgCount) const;
|
||||
llvm::SmallVector<Rule, 4> Rules;
|
||||
llvm::SmallVector<Rule> Rules;
|
||||
std::deque<std::string> Storage; // Store strings not found in option table.
|
||||
};
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ struct FragmentCompiler {
|
|||
llvm::StringRef EnumName;
|
||||
const Located<std::string> &Input;
|
||||
llvm::Optional<T> Result;
|
||||
llvm::SmallVector<llvm::StringLiteral, 8> ValidValues;
|
||||
llvm::SmallVector<llvm::StringLiteral> ValidValues;
|
||||
|
||||
public:
|
||||
EnumSwitch(llvm::StringRef EnumName, const Located<std::string> &In,
|
||||
|
|
|
@ -58,8 +58,7 @@ const llvm::hash_code FileDistance::RootHash =
|
|||
FileDistance::FileDistance(llvm::StringMap<SourceParams> Sources,
|
||||
const FileDistanceOptions &Opts)
|
||||
: Opts(Opts) {
|
||||
llvm::DenseMap<llvm::hash_code, llvm::SmallVector<llvm::hash_code, 4>>
|
||||
DownEdges;
|
||||
llvm::DenseMap<llvm::hash_code, llvm::SmallVector<llvm::hash_code>> DownEdges;
|
||||
// Compute the best distance following only up edges.
|
||||
// Keep track of down edges, in case we can use them to improve on this.
|
||||
for (const auto &S : Sources) {
|
||||
|
@ -118,7 +117,7 @@ FileDistance::FileDistance(llvm::StringMap<SourceParams> Sources,
|
|||
unsigned FileDistance::distance(llvm::StringRef Path) {
|
||||
auto Canonical = canonicalize(Path);
|
||||
unsigned Cost = Unreachable;
|
||||
llvm::SmallVector<llvm::hash_code, 16> Ancestors;
|
||||
llvm::SmallVector<llvm::hash_code> Ancestors;
|
||||
// Walk up ancestors until we find a path we know the distance for.
|
||||
for (llvm::StringRef Rest = Canonical; !Rest.empty();
|
||||
Rest = parent_path(Rest, llvm::sys::path::Style::posix)) {
|
||||
|
@ -177,7 +176,7 @@ FileDistance &URIDistance::forScheme(llvm::StringRef Scheme) {
|
|||
}
|
||||
|
||||
static std::pair<std::string, int> scopeToPath(llvm::StringRef Scope) {
|
||||
llvm::SmallVector<llvm::StringRef, 4> Split;
|
||||
llvm::SmallVector<llvm::StringRef> Split;
|
||||
Scope.split(Split, "::", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
|
||||
return {"/" + llvm::join(Split, "/"), Split.size()};
|
||||
}
|
||||
|
|
|
@ -750,9 +750,9 @@ explicitReferenceTargets(DynTypedNode N, DeclRelationSet Mask) {
|
|||
}
|
||||
|
||||
namespace {
|
||||
llvm::SmallVector<ReferenceLoc, 2> refInDecl(const Decl *D) {
|
||||
llvm::SmallVector<ReferenceLoc> refInDecl(const Decl *D) {
|
||||
struct Visitor : ConstDeclVisitor<Visitor> {
|
||||
llvm::SmallVector<ReferenceLoc, 2> Refs;
|
||||
llvm::SmallVector<ReferenceLoc> Refs;
|
||||
|
||||
void VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
|
||||
// We want to keep it as non-declaration references, as the
|
||||
|
@ -819,10 +819,10 @@ llvm::SmallVector<ReferenceLoc, 2> refInDecl(const Decl *D) {
|
|||
return V.Refs;
|
||||
}
|
||||
|
||||
llvm::SmallVector<ReferenceLoc, 2> refInStmt(const Stmt *S) {
|
||||
llvm::SmallVector<ReferenceLoc> refInStmt(const Stmt *S) {
|
||||
struct Visitor : ConstStmtVisitor<Visitor> {
|
||||
// FIXME: handle more complicated cases: more ObjC, designated initializers.
|
||||
llvm::SmallVector<ReferenceLoc, 2> Refs;
|
||||
llvm::SmallVector<ReferenceLoc> Refs;
|
||||
|
||||
void VisitConceptSpecializationExpr(const ConceptSpecializationExpr *E) {
|
||||
Refs.push_back(ReferenceLoc{E->getNestedNameSpecifierLoc(),
|
||||
|
@ -920,7 +920,7 @@ llvm::SmallVector<ReferenceLoc, 2> refInStmt(const Stmt *S) {
|
|||
return V.Refs;
|
||||
}
|
||||
|
||||
llvm::SmallVector<ReferenceLoc, 2> refInTypeLoc(TypeLoc L) {
|
||||
llvm::SmallVector<ReferenceLoc> refInTypeLoc(TypeLoc L) {
|
||||
struct Visitor : TypeLocVisitor<Visitor> {
|
||||
llvm::Optional<ReferenceLoc> Ref;
|
||||
|
||||
|
@ -1114,7 +1114,7 @@ private:
|
|||
/// be references. However, declarations can have references inside them,
|
||||
/// e.g. 'namespace foo = std' references namespace 'std' and this
|
||||
/// function will return the corresponding reference.
|
||||
llvm::SmallVector<ReferenceLoc, 2> explicitReference(DynTypedNode N) {
|
||||
llvm::SmallVector<ReferenceLoc> explicitReference(DynTypedNode N) {
|
||||
if (auto *D = N.get<Decl>())
|
||||
return refInDecl(D);
|
||||
if (auto *S = N.get<Stmt>())
|
||||
|
|
|
@ -136,7 +136,7 @@ private:
|
|||
unsigned fileIndex(llvm::StringRef Name);
|
||||
llvm::StringMap<unsigned> NameToIndex; // Values are file indexes.
|
||||
// Maps a file's index to that of the files it includes.
|
||||
llvm::DenseMap<unsigned, SmallVector<unsigned, 8>> IncludeChildren;
|
||||
llvm::DenseMap<unsigned, SmallVector<unsigned>> IncludeChildren;
|
||||
};
|
||||
|
||||
/// Returns a PPCallback that visits all inclusions in the main file.
|
||||
|
|
|
@ -79,7 +79,7 @@ llvm::Optional<DriverInfo> parseDriverOutput(llvm::StringRef Output) {
|
|||
const char SIS[] = "#include <...> search starts here:";
|
||||
const char SIE[] = "End of search list.";
|
||||
const char TS[] = "Target: ";
|
||||
llvm::SmallVector<llvm::StringRef, 8> Lines;
|
||||
llvm::SmallVector<llvm::StringRef> Lines;
|
||||
Output.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
|
||||
|
||||
enum {
|
||||
|
@ -171,8 +171,8 @@ extractSystemIncludesAndTarget(PathRef Driver, llvm::StringRef Lang,
|
|||
llvm::Optional<llvm::StringRef> Redirects[] = {
|
||||
{""}, {""}, llvm::StringRef(StdErrPath)};
|
||||
|
||||
llvm::SmallVector<llvm::StringRef, 12> Args = {Driver, "-E", "-x",
|
||||
Lang, "-", "-v"};
|
||||
llvm::SmallVector<llvm::StringRef> Args = {Driver, "-E", "-x",
|
||||
Lang, "-", "-v"};
|
||||
|
||||
// These flags will be preserved
|
||||
const llvm::StringRef FlagsToPreserve[] = {
|
||||
|
|
|
@ -83,8 +83,8 @@ public:
|
|||
// Removes the elements of Claim from the set, modifying or removing ranges
|
||||
// that overlap it.
|
||||
// Returns the continuous subranges of Claim that were actually removed.
|
||||
llvm::SmallVector<llvm::ArrayRef<T>, 4> erase(llvm::ArrayRef<T> Claim) {
|
||||
llvm::SmallVector<llvm::ArrayRef<T>, 4> Out;
|
||||
llvm::SmallVector<llvm::ArrayRef<T>> erase(llvm::ArrayRef<T> Claim) {
|
||||
llvm::SmallVector<llvm::ArrayRef<T>> Out;
|
||||
if (Claim.empty())
|
||||
return Out;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ public:
|
|||
// The parent within the selection tree. nullptr for TranslationUnitDecl.
|
||||
Node *Parent;
|
||||
// Direct children within the selection tree.
|
||||
llvm::SmallVector<const Node *, 8> Children;
|
||||
llvm::SmallVector<const Node *> Children;
|
||||
// The corresponding node from the full AST.
|
||||
ast_type_traits::DynTypedNode ASTNode;
|
||||
// The extent to which this node is covered by the selection.
|
||||
|
|
|
@ -605,7 +605,7 @@ toTheiaSemanticHighlightingInformation(
|
|||
std::vector<TheiaSemanticHighlightingInformation> Lines;
|
||||
Lines.reserve(Tokens.size());
|
||||
for (const auto &Line : Tokens) {
|
||||
llvm::SmallVector<char, 128> LineByteTokens;
|
||||
llvm::SmallVector<char> LineByteTokens;
|
||||
llvm::raw_svector_ostream OS(LineByteTokens);
|
||||
for (const auto &Token : Line.Tokens) {
|
||||
// Writes the token to LineByteTokens in the byte format specified by the
|
||||
|
|
|
@ -779,8 +779,8 @@ void parseNamespaceEvents(llvm::StringRef Code, const LangOptions &LangOpts,
|
|||
}
|
||||
|
||||
// Returns the prefix namespaces of NS: {"" ... NS}.
|
||||
llvm::SmallVector<llvm::StringRef, 8> ancestorNamespaces(llvm::StringRef NS) {
|
||||
llvm::SmallVector<llvm::StringRef, 8> Results;
|
||||
llvm::SmallVector<llvm::StringRef> ancestorNamespaces(llvm::StringRef NS) {
|
||||
llvm::SmallVector<llvm::StringRef> Results;
|
||||
Results.push_back(NS.take_front(0));
|
||||
NS.split(Results, "::", /*MaxSplit=*/-1, /*KeepEmpty=*/false);
|
||||
for (llvm::StringRef &R : Results)
|
||||
|
|
|
@ -477,7 +477,7 @@ private:
|
|||
/// thread are not locked, as it's the only writer.
|
||||
ParseInputs FileInputs; /* GUARDED_BY(Mutex) */
|
||||
/// Times of recent AST rebuilds, used for UpdateDebounce computation.
|
||||
llvm::SmallVector<DebouncePolicy::clock::duration, 8>
|
||||
llvm::SmallVector<DebouncePolicy::clock::duration>
|
||||
RebuildTimes; /* GUARDED_BY(Mutex) */
|
||||
/// Set to true to signal run() to finish processing.
|
||||
bool Done; /* GUARDED_BY(Mutex) */
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
// Compute absolute paths to all ancestors (substrings of P.Path).
|
||||
// Ensure cache entries for each ancestor exist in the map.
|
||||
llvm::StringRef Parent = path::parent_path(AbsPath);
|
||||
llvm::SmallVector<DotClangTidyCache *, 8> Caches;
|
||||
llvm::SmallVector<DotClangTidyCache *> Caches;
|
||||
{
|
||||
std::lock_guard<std::mutex> Lock(Mu);
|
||||
for (auto I = path::begin(Parent, path::Style::posix),
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
// This will take a (per-file) lock for each file that actually exists.
|
||||
std::chrono::steady_clock::time_point FreshTime =
|
||||
std::chrono::steady_clock::now() - MaxStaleness;
|
||||
llvm::SmallVector<std::shared_ptr<const tidy::ClangTidyOptions>, 4>
|
||||
llvm::SmallVector<std::shared_ptr<const tidy::ClangTidyOptions>>
|
||||
OptionStack;
|
||||
for (const DotClangTidyCache *Cache : Caches)
|
||||
if (auto Config = Cache->get(FS, FreshTime)) {
|
||||
|
|
|
@ -153,7 +153,7 @@ class FuzzyFind : public Command {
|
|||
Request.Limit = Limit;
|
||||
Request.Query = Query;
|
||||
if (Scopes.getNumOccurrences() > 0) {
|
||||
llvm::SmallVector<llvm::StringRef, 8> Scopes;
|
||||
llvm::SmallVector<llvm::StringRef> Scopes;
|
||||
llvm::StringRef(this->Scopes).split(Scopes, ',');
|
||||
Request.Scopes = {Scopes.begin(), Scopes.end()};
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ std::unique_ptr<SymbolIndex> openIndex(llvm::StringRef Index) {
|
|||
bool runCommand(std::string Request, const SymbolIndex &Index) {
|
||||
// Split on spaces and add required null-termination.
|
||||
std::replace(Request.begin(), Request.end(), ' ', '\0');
|
||||
llvm::SmallVector<llvm::StringRef, 8> Args;
|
||||
llvm::SmallVector<llvm::StringRef> Args;
|
||||
llvm::StringRef(Request).split(Args, '\0', /*MaxSplit=*/-1,
|
||||
/*KeepEmpty=*/false);
|
||||
if (Args.empty())
|
||||
|
@ -351,7 +351,7 @@ bool runCommand(std::string Request, const SymbolIndex &Index) {
|
|||
llvm::outs() << "Get detailed command help with e.g. `find -help`.\n";
|
||||
return true;
|
||||
}
|
||||
llvm::SmallVector<const char *, 8> FakeArgv;
|
||||
llvm::SmallVector<const char *> FakeArgv;
|
||||
for (llvm::StringRef S : Args)
|
||||
FakeArgv.push_back(S.data()); // Terminated by separator or end of string.
|
||||
|
||||
|
|
|
@ -480,7 +480,7 @@ public:
|
|||
const tooling::Replacement DeleteFuncBody(SM, DefRange->getBegin(),
|
||||
SourceLen, "");
|
||||
|
||||
llvm::SmallVector<std::pair<std::string, Edit>, 2> Edits;
|
||||
llvm::SmallVector<std::pair<std::string, Edit>> Edits;
|
||||
// Edit for Target.
|
||||
auto FE = Effect::fileEdit(SM, SM.getFileID(*Semicolon),
|
||||
std::move(TargetFileReplacements));
|
||||
|
|
|
@ -202,7 +202,7 @@ ExtractionContext::insertDeclaration(llvm::StringRef VarName,
|
|||
struct ParsedBinaryOperator {
|
||||
BinaryOperatorKind Kind;
|
||||
SourceLocation ExprLoc;
|
||||
llvm::SmallVector<const SelectionTree::Node*, 8> SelectedOperands;
|
||||
llvm::SmallVector<const SelectionTree::Node *> SelectedOperands;
|
||||
|
||||
// If N is a binary operator, populate this and return true.
|
||||
bool parse(const SelectionTree::Node &N) {
|
||||
|
|
|
@ -215,7 +215,7 @@ std::string getMarkerForCodeBlock(llvm::StringRef Input) {
|
|||
|
||||
// Trims the input and concatenates whitespace blocks into a single ` `.
|
||||
std::string canonicalizeSpaces(llvm::StringRef Input) {
|
||||
llvm::SmallVector<llvm::StringRef, 4> Words;
|
||||
llvm::SmallVector<llvm::StringRef> Words;
|
||||
llvm::SplitString(Input, Words);
|
||||
return llvm::join(Words, " ");
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ TEST(CommandMangler, ConfigEdits) {
|
|||
}
|
||||
|
||||
static std::string strip(llvm::StringRef Arg, llvm::StringRef Argv) {
|
||||
llvm::SmallVector<llvm::StringRef, 8> Parts;
|
||||
llvm::SmallVector<llvm::StringRef> Parts;
|
||||
llvm::SplitString(Argv, Parts);
|
||||
std::vector<std::string> Args = {Parts.begin(), Parts.end()};
|
||||
ArgStripper S;
|
||||
|
|
|
@ -29,7 +29,7 @@ Symbol symbol(llvm::StringRef QName) {
|
|||
|
||||
static std::string replace(llvm::StringRef Haystack, llvm::StringRef Needle,
|
||||
llvm::StringRef Repl) {
|
||||
llvm::SmallVector<llvm::StringRef, 8> Parts;
|
||||
llvm::SmallVector<llvm::StringRef> Parts;
|
||||
Haystack.split(Parts, Needle);
|
||||
return llvm::join(Parts, Repl);
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ const Symbol &findSymbol(const SymbolSlab &Slab, llvm::StringRef QName) {
|
|||
}
|
||||
|
||||
const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
|
||||
llvm::SmallVector<llvm::StringRef, 4> Components;
|
||||
llvm::SmallVector<llvm::StringRef> Components;
|
||||
QName.split(Components, "::");
|
||||
|
||||
auto &Ctx = AST.getASTContext();
|
||||
|
|
|
@ -154,7 +154,7 @@ protected:
|
|||
std::vector<std::string> outputLines() {
|
||||
// Deliberately don't flush output stream, the tracer should do that.
|
||||
// This is important when clangd crashes.
|
||||
llvm::SmallVector<llvm::StringRef, 4> Lines;
|
||||
llvm::SmallVector<llvm::StringRef> Lines;
|
||||
llvm::StringRef(Output).split(Lines, "\r\n");
|
||||
return {Lines.begin(), Lines.end()};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue