[clangd] Fix (most) naming warnings from clang-tidy. NFC

llvm-svn: 338021
This commit is contained in:
Ilya Biryukov 2018-07-26 12:05:31 +00:00
parent 127093129a
commit 74f2655dc7
16 changed files with 51 additions and 51 deletions

View File

@ -121,7 +121,7 @@ void clangd::dumpAST(ParsedAST &AST, llvm::raw_ostream &OS) {
}
llvm::Optional<ParsedAST>
ParsedAST::Build(std::unique_ptr<clang::CompilerInvocation> CI,
ParsedAST::build(std::unique_ptr<clang::CompilerInvocation> CI,
std::shared_ptr<const PreambleData> Preamble,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
std::shared_ptr<PCHContainerOperations> PCHs,
@ -367,7 +367,7 @@ llvm::Optional<ParsedAST> clangd::buildAST(
// dirs.
}
return ParsedAST::Build(
return ParsedAST::build(
llvm::make_unique<CompilerInvocation>(*Invocation), Preamble,
llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents), PCHs, Inputs.FS);
}

View File

@ -68,7 +68,7 @@ public:
/// Attempts to run Clang and store parsed AST. If \p Preamble is non-null
/// it is reused during parsing.
static llvm::Optional<ParsedAST>
Build(std::unique_ptr<clang::CompilerInvocation> CI,
build(std::unique_ptr<clang::CompilerInvocation> CI,
std::shared_ptr<const PreambleData> Preamble,
std::unique_ptr<llvm::MemoryBuffer> Buffer,
std::shared_ptr<PCHContainerOperations> PCHs,

View File

@ -704,7 +704,7 @@ public:
CurrentArg, S, *Allocator, CCTUInfo, true);
assert(CCS && "Expected the CodeCompletionString to be non-null");
// FIXME: for headers, we need to get a comment from the index.
SigHelp.signatures.push_back(ProcessOverloadCandidate(
SigHelp.signatures.push_back(processOverloadCandidate(
Candidate, *CCS,
getParameterDocComment(S.getASTContext(), Candidate, CurrentArg,
/*CommentsFromHeaders=*/false)));
@ -719,7 +719,7 @@ private:
// FIXME(ioeric): consider moving CodeCompletionString logic here to
// CompletionString.h.
SignatureInformation
ProcessOverloadCandidate(const OverloadCandidate &Candidate,
processOverloadCandidate(const OverloadCandidate &Candidate,
const CodeCompletionString &CCS,
llvm::StringRef DocComment) const {
SignatureInformation Result;

View File

@ -32,7 +32,7 @@ void appendEscapeSnippet(const llvm::StringRef Text, std::string *Out) {
}
}
bool LooksLikeDocComment(llvm::StringRef CommentText) {
bool looksLikeDocComment(llvm::StringRef CommentText) {
// We don't report comments that only contain "special" chars.
// This avoids reporting various delimiters, like:
// =================
@ -67,7 +67,7 @@ std::string getDocComment(const ASTContext &Ctx,
// write them into PCH, because they are racy and slow to load.
assert(!Ctx.getSourceManager().isLoadedSourceLocation(RC->getLocStart()));
std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
if (!LooksLikeDocComment(Doc))
if (!looksLikeDocComment(Doc))
return "";
return Doc;
}
@ -86,7 +86,7 @@ getParameterDocComment(const ASTContext &Ctx,
// write them into PCH, because they are racy and slow to load.
assert(!Ctx.getSourceManager().isLoadedSourceLocation(RC->getLocStart()));
std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics());
if (!LooksLikeDocComment(Doc))
if (!looksLikeDocComment(Doc))
return "";
return Doc;
}

View File

@ -109,10 +109,10 @@ void clangd::reply(json::Value &&Result) {
});
}
void clangd::replyError(ErrorCode code, const llvm::StringRef &Message) {
elog("Error {0}: {1}", static_cast<int>(code), Message);
void clangd::replyError(ErrorCode Code, const llvm::StringRef &Message) {
elog("Error {0}: {1}", static_cast<int>(Code), Message);
RequestSpan::attach([&](json::Object &Args) {
Args["Error"] = json::Object{{"code", static_cast<int>(code)},
Args["Error"] = json::Object{{"code", static_cast<int>(Code)},
{"message", Message.str()}};
});
@ -123,7 +123,7 @@ void clangd::replyError(ErrorCode code, const llvm::StringRef &Message) {
->writeMessage(json::Object{
{"jsonrpc", "2.0"},
{"id", *ID},
{"error", json::Object{{"code", static_cast<int>(code)},
{"error", json::Object{{"code", static_cast<int>(Code)},
{"message", Message}}},
});
}

View File

@ -63,7 +63,7 @@ private:
void reply(llvm::json::Value &&Result);
/// Sends an error response to the client, and logs it.
/// Current context must derive from JSONRPCDispatcher::Handler.
void replyError(ErrorCode code, const llvm::StringRef &Message);
void replyError(ErrorCode Code, const llvm::StringRef &Message);
/// Sends a request to the client.
/// Current context must derive from JSONRPCDispatcher::Handler.
void call(llvm::StringRef Method, llvm::json::Value &&Params);

View File

@ -208,10 +208,10 @@ bool fromJSON(const json::Value &Params, SymbolKindCapabilities &R) {
}
SymbolKind adjustKindToCapability(SymbolKind Kind,
SymbolKindBitset &supportedSymbolKinds) {
SymbolKindBitset &SupportedSymbolKinds) {
auto KindVal = static_cast<size_t>(Kind);
if (KindVal >= SymbolKindMin && KindVal <= supportedSymbolKinds.size() &&
supportedSymbolKinds[KindVal])
if (KindVal >= SymbolKindMin && KindVal <= SupportedSymbolKinds.size() &&
SupportedSymbolKinds[KindVal])
return Kind;
switch (Kind) {

View File

@ -27,7 +27,7 @@
namespace clang {
namespace clangd {
using namespace llvm;
static bool IsReserved(StringRef Name) {
static bool isReserved(StringRef Name) {
// FIXME: Should we exclude _Bool and others recognized by the standard?
return Name.size() >= 2 && Name[0] == '_' &&
(isUppercase(Name[1]) || Name[1] == '_');
@ -174,15 +174,15 @@ void SymbolQualitySignals::merge(const CodeCompletionResult &SemaCCResult) {
if (SemaCCResult.Declaration) {
if (auto *ID = SemaCCResult.Declaration->getIdentifier())
ReservedName = ReservedName || IsReserved(ID->getName());
ReservedName = ReservedName || isReserved(ID->getName());
} else if (SemaCCResult.Kind == CodeCompletionResult::RK_Macro)
ReservedName = ReservedName || IsReserved(SemaCCResult.Macro->getName());
ReservedName = ReservedName || isReserved(SemaCCResult.Macro->getName());
}
void SymbolQualitySignals::merge(const Symbol &IndexResult) {
References = std::max(IndexResult.References, References);
Category = categorize(IndexResult.SymInfo);
ReservedName = ReservedName || IsReserved(IndexResult.Name);
ReservedName = ReservedName || isReserved(IndexResult.Name);
}
float SymbolQualitySignals::evaluate() const {
@ -199,8 +199,8 @@ float SymbolQualitySignals::evaluate() const {
// boost = f * sigmoid(m * std::log(References)) - 0.5 * f + 0.59
// Sample data points: (10, 1.00), (100, 1.41), (1000, 1.82),
// (10K, 2.21), (100K, 2.58), (1M, 2.94)
float s = std::pow(References, -0.06);
Score *= 6.0 * (1 - s) / (1 + s) + 0.59;
float S = std::pow(References, -0.06);
Score *= 6.0 * (1 - S) / (1 + S) + 0.59;
}
if (Deprecated)
@ -241,7 +241,7 @@ raw_ostream &operator<<(raw_ostream &OS, const SymbolQualitySignals &S) {
}
static SymbolRelevanceSignals::AccessibleScope
ComputeScope(const NamedDecl *D) {
computeScope(const NamedDecl *D) {
// Injected "Foo" within the class "Foo" has file scope, not class scope.
const DeclContext *DC = D->getDeclContext();
if (auto *R = dyn_cast_or_null<RecordDecl>(D))
@ -291,7 +291,7 @@ void SymbolRelevanceSignals::merge(const CodeCompletionResult &SemaCCResult) {
// Declarations are scoped, others (like macros) are assumed global.
if (SemaCCResult.Declaration)
Scope = std::min(Scope, ComputeScope(SemaCCResult.Declaration));
Scope = std::min(Scope, computeScope(SemaCCResult.Declaration));
}
static std::pair<float, unsigned> proximityScore(llvm::StringRef SymbolURI,

View File

@ -159,7 +159,7 @@ public:
/// is null, all requests will be processed on the calling thread
/// synchronously instead. \p Barrier is acquired when processing each
/// request, it is be used to limit the number of actively running threads.
static ASTWorkerHandle Create(PathRef FileName,
static ASTWorkerHandle create(PathRef FileName,
TUScheduler::ASTCache &IdleASTs,
AsyncTaskRunner *Tasks, Semaphore &Barrier,
steady_clock::duration UpdateDebounce,
@ -282,7 +282,7 @@ private:
std::shared_ptr<ASTWorker> Worker;
};
ASTWorkerHandle ASTWorker::Create(PathRef FileName,
ASTWorkerHandle ASTWorker::create(PathRef FileName,
TUScheduler::ASTCache &IdleASTs,
AsyncTaskRunner *Tasks, Semaphore &Barrier,
steady_clock::duration UpdateDebounce,
@ -639,7 +639,7 @@ void TUScheduler::update(
std::unique_ptr<FileData> &FD = Files[File];
if (!FD) {
// Create a new worker to process the AST-related tasks.
ASTWorkerHandle Worker = ASTWorker::Create(
ASTWorkerHandle Worker = ASTWorker::create(
File, *IdleASTs, WorkerThreads ? WorkerThreads.getPointer() : nullptr,
Barrier, UpdateDebounce, PCHOps, StorePreamblesInMemory,
PreambleCallback);

View File

@ -25,7 +25,7 @@ namespace {
// Get the definition from a given declaration `D`.
// Return nullptr if no definition is found, or the declaration type of `D` is
// not supported.
const Decl *GetDefinition(const Decl *D) {
const Decl *getDefinition(const Decl *D) {
assert(D);
if (const auto *TD = dyn_cast<TagDecl>(D))
return TD->getDefinition();
@ -40,7 +40,7 @@ const Decl *GetDefinition(const Decl *D) {
// HintPath is used to resolve the path of URI.
// FIXME: figure out a good home for it, and share the implementation with
// FindSymbols.
llvm::Optional<Location> ToLSPLocation(const SymbolLocation &Loc,
llvm::Optional<Location> toLSPLocation(const SymbolLocation &Loc,
llvm::StringRef HintPath) {
if (!Loc)
return llvm::None;
@ -116,7 +116,7 @@ public:
// We don't use parameter `D`, as Parameter `D` is the canonical
// declaration, which is the first declaration of a redeclarable
// declaration, and it could be a forward declaration.
if (const auto *Def = GetDefinition(D)) {
if (const auto *Def = getDefinition(D)) {
Decls.push_back(Def);
} else {
// Couldn't find a definition, fall back to use `D`.
@ -279,7 +279,7 @@ std::vector<Location> findDefinitions(ParsedAST &AST, Position Pos,
auto L = makeLocation(AST, SourceRange(Loc, Loc));
// The declaration in the identified symbols is a definition if possible
// otherwise it is declaration.
bool IsDef = GetDefinition(D) == D;
bool IsDef = getDefinition(D) == D;
// Populate one of the slots with location for the AST.
if (!IsDef)
Candidate.Decl = L;
@ -305,9 +305,9 @@ std::vector<Location> findDefinitions(ParsedAST &AST, Position Pos,
auto &Value = It->second;
if (!Value.Def)
Value.Def = ToLSPLocation(Sym.Definition, HintPath);
Value.Def = toLSPLocation(Sym.Definition, HintPath);
if (!Value.Decl)
Value.Decl = ToLSPLocation(Sym.CanonicalDeclaration, HintPath);
Value.Decl = toLSPLocation(Sym.CanonicalDeclaration, HintPath);
});
}
@ -410,7 +410,7 @@ std::vector<DocumentHighlight> findDocumentHighlights(ParsedAST &AST,
return DocHighlightsFinder.takeHighlights();
}
static PrintingPolicy PrintingPolicyForDecls(PrintingPolicy Base) {
static PrintingPolicy printingPolicyForDecls(PrintingPolicy Base) {
PrintingPolicy Policy(Base);
Policy.AnonymousTagLocations = false;
@ -424,11 +424,11 @@ static PrintingPolicy PrintingPolicyForDecls(PrintingPolicy Base) {
/// Return a string representation (e.g. "class MyNamespace::MyClass") of
/// the type declaration \p TD.
static std::string TypeDeclToString(const TypeDecl *TD) {
static std::string typeDeclToString(const TypeDecl *TD) {
QualType Type = TD->getASTContext().getTypeDeclType(TD);
PrintingPolicy Policy =
PrintingPolicyForDecls(TD->getASTContext().getPrintingPolicy());
printingPolicyForDecls(TD->getASTContext().getPrintingPolicy());
std::string Name;
llvm::raw_string_ostream Stream(Name);
@ -439,10 +439,10 @@ static std::string TypeDeclToString(const TypeDecl *TD) {
/// Return a string representation (e.g. "namespace ns1::ns2") of
/// the named declaration \p ND.
static std::string NamedDeclQualifiedName(const NamedDecl *ND,
static std::string namedDeclQualifiedName(const NamedDecl *ND,
StringRef Prefix) {
PrintingPolicy Policy =
PrintingPolicyForDecls(ND->getASTContext().getPrintingPolicy());
printingPolicyForDecls(ND->getASTContext().getPrintingPolicy());
std::string Name;
llvm::raw_string_ostream Stream(Name);
@ -461,11 +461,11 @@ static llvm::Optional<std::string> getScopeName(const Decl *D) {
if (isa<TranslationUnitDecl>(DC))
return std::string("global namespace");
if (const TypeDecl *TD = dyn_cast<TypeDecl>(DC))
return TypeDeclToString(TD);
return typeDeclToString(TD);
else if (const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(DC))
return NamedDeclQualifiedName(ND, "namespace");
return namedDeclQualifiedName(ND, "namespace");
else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(DC))
return NamedDeclQualifiedName(FD, "function");
return namedDeclQualifiedName(FD, "function");
return llvm::None;
}
@ -492,7 +492,7 @@ static Hover getHoverContents(const Decl *D) {
llvm::raw_string_ostream OS(DeclText);
PrintingPolicy Policy =
PrintingPolicyForDecls(D->getASTContext().getPrintingPolicy());
printingPolicyForDecls(D->getASTContext().getPrintingPolicy());
D->print(OS, Policy);
@ -507,7 +507,7 @@ static Hover getHoverContents(QualType T, ASTContext &ASTCtx) {
Hover H;
std::string TypeText;
llvm::raw_string_ostream OS(TypeText);
PrintingPolicy Policy = PrintingPolicyForDecls(ASTCtx.getPrintingPolicy());
PrintingPolicy Policy = printingPolicyForDecls(ASTCtx.getPrintingPolicy());
T.print(OS, Policy);
OS.flush();
H.contents.value += TypeText;

View File

@ -77,7 +77,7 @@ class MergedIndex : public SymbolIndex {
private:
const SymbolIndex *Dynamic, *Static;
};
}
} // namespace
Symbol
mergeSymbol(const Symbol &L, const Symbol &R, Symbol::Details *Scratch) {

View File

@ -168,7 +168,7 @@ template <> struct ScalarEnumerationTraits<SymbolKind> {
namespace clang {
namespace clangd {
SymbolSlab SymbolsFromYAML(llvm::StringRef YAMLContent) {
SymbolSlab symbolsFromYAML(llvm::StringRef YAMLContent) {
// Store data of pointer fields (excl. `StringRef`) like `Detail`.
llvm::BumpPtrAllocator Arena;
llvm::yaml::Input Yin(YAMLContent, &Arena);

View File

@ -27,7 +27,7 @@ namespace clang {
namespace clangd {
// Read symbols from a YAML-format string.
SymbolSlab SymbolsFromYAML(llvm::StringRef YAMLContent);
SymbolSlab symbolsFromYAML(llvm::StringRef YAMLContent);
// Read one symbol from a YAML-stream.
// The arena must be the Input's context! (i.e. yaml::Input Input(Text, &Arena))

View File

@ -40,7 +40,7 @@ std::unique_ptr<SymbolIndex> buildStaticIndex(llvm::StringRef YamlSymbolFile) {
llvm::errs() << "Can't open " << YamlSymbolFile << "\n";
return nullptr;
}
auto Slab = SymbolsFromYAML(Buffer.get()->getBuffer());
auto Slab = symbolsFromYAML(Buffer.get()->getBuffer());
SymbolSlab::Builder SymsBuilder;
for (auto Sym : Slab)
SymsBuilder.insert(Sym);

View File

@ -723,14 +723,14 @@ CompletionSnippetSuffix: '-snippet'
...
)";
auto Symbols1 = SymbolsFromYAML(YAML1);
auto Symbols1 = symbolsFromYAML(YAML1);
EXPECT_THAT(Symbols1,
UnorderedElementsAre(AllOf(QName("clang::Foo1"), Labeled("Foo1"),
Doc("Foo doc"), ReturnType("int"),
DeclURI("file:///path/foo.h"),
ForCodeCompletion(true))));
auto Symbols2 = SymbolsFromYAML(YAML2);
auto Symbols2 = symbolsFromYAML(YAML2);
EXPECT_THAT(Symbols2, UnorderedElementsAre(AllOf(
QName("clang::Foo2"), Labeled("Foo2-sig"),
Not(HasReturnType()), DeclURI("file:///path/bar.h"),
@ -742,7 +742,7 @@ CompletionSnippetSuffix: '-snippet'
SymbolsToYAML(Symbols1, OS);
SymbolsToYAML(Symbols2, OS);
}
auto ConcatenatedSymbols = SymbolsFromYAML(ConcatenatedYAML);
auto ConcatenatedSymbols = symbolsFromYAML(ConcatenatedYAML);
EXPECT_THAT(ConcatenatedSymbols,
UnorderedElementsAre(QName("clang::Foo1"),
QName("clang::Foo2")));

View File

@ -30,7 +30,7 @@ ParsedAST TestTU::build() const {
Cmd.push_back(FullHeaderName.c_str());
}
Cmd.insert(Cmd.end(), ExtraArgs.begin(), ExtraArgs.end());
auto AST = ParsedAST::Build(
auto AST = ParsedAST::build(
createInvocationFromCommandLine(Cmd), nullptr,
MemoryBuffer::getMemBufferCopy(Code),
std::make_shared<PCHContainerOperations>(),