summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-07-26 12:05:31 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-07-26 12:05:31 +0000
commit9c5eb38c5f15d7c61f46d5a5cf068380427a7eb3 (patch)
tree5a5f4a399af30d0ac52a2ed9c55fde8810da2a0c
parent30a69656773d5cddd8b7ad521bbf32e2f7a385a2 (diff)
[clangd] Fix (most) naming warnings from clang-tidy. NFC
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@338021 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--clangd/ClangdUnit.cpp4
-rw-r--r--clangd/ClangdUnit.h2
-rw-r--r--clangd/CodeComplete.cpp4
-rw-r--r--clangd/CodeCompletionStrings.cpp6
-rw-r--r--clangd/JSONRPCDispatcher.cpp8
-rw-r--r--clangd/JSONRPCDispatcher.h2
-rw-r--r--clangd/Protocol.cpp6
-rw-r--r--clangd/Quality.cpp16
-rw-r--r--clangd/TUScheduler.cpp6
-rw-r--r--clangd/XRefs.cpp32
-rw-r--r--clangd/index/Merge.cpp2
-rw-r--r--clangd/index/SymbolYAML.cpp2
-rw-r--r--clangd/index/SymbolYAML.h2
-rw-r--r--clangd/tool/ClangdMain.cpp2
-rw-r--r--unittests/clangd/SymbolCollectorTests.cpp6
-rw-r--r--unittests/clangd/TestTU.cpp2
16 files changed, 51 insertions, 51 deletions
diff --git a/clangd/ClangdUnit.cpp b/clangd/ClangdUnit.cpp
index a5ab4839..86e7497a 100644
--- a/clangd/ClangdUnit.cpp
+++ b/clangd/ClangdUnit.cpp
@@ -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);
}
diff --git a/clangd/ClangdUnit.h b/clangd/ClangdUnit.h
index 6db1e86d..c7aca17e 100644
--- a/clangd/ClangdUnit.h
+++ b/clangd/ClangdUnit.h
@@ -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,
diff --git a/clangd/CodeComplete.cpp b/clangd/CodeComplete.cpp
index 44c44b62..a0406591 100644
--- a/clangd/CodeComplete.cpp
+++ b/clangd/CodeComplete.cpp
@@ -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;
diff --git a/clangd/CodeCompletionStrings.cpp b/clangd/CodeCompletionStrings.cpp
index 474419d0..88b37daf 100644
--- a/clangd/CodeCompletionStrings.cpp
+++ b/clangd/CodeCompletionStrings.cpp
@@ -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;
}
diff --git a/clangd/JSONRPCDispatcher.cpp b/clangd/JSONRPCDispatcher.cpp
index 8c5fec6c..2741c665 100644
--- a/clangd/JSONRPCDispatcher.cpp
+++ b/clangd/JSONRPCDispatcher.cpp
@@ -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}}},
});
}
diff --git a/clangd/JSONRPCDispatcher.h b/clangd/JSONRPCDispatcher.h
index a3912126..e8c96fc9 100644
--- a/clangd/JSONRPCDispatcher.h
+++ b/clangd/JSONRPCDispatcher.h
@@ -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);
diff --git a/clangd/Protocol.cpp b/clangd/Protocol.cpp
index 8d99e18d..c9ff74f9 100644
--- a/clangd/Protocol.cpp
+++ b/clangd/Protocol.cpp
@@ -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) {
diff --git a/clangd/Quality.cpp b/clangd/Quality.cpp
index afbcdec6..61195b56 100644
--- a/clangd/Quality.cpp
+++ b/clangd/Quality.cpp
@@ -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,
diff --git a/clangd/TUScheduler.cpp b/clangd/TUScheduler.cpp
index 36cada53..b5305341 100644
--- a/clangd/TUScheduler.cpp
+++ b/clangd/TUScheduler.cpp
@@ -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);
diff --git a/clangd/XRefs.cpp b/clangd/XRefs.cpp
index 93882062..99ccd21f 100644
--- a/clangd/XRefs.cpp
+++ b/clangd/XRefs.cpp
@@ -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;
diff --git a/clangd/index/Merge.cpp b/clangd/index/Merge.cpp
index 4365e044..da31f8b6 100644
--- a/clangd/index/Merge.cpp
+++ b/clangd/index/Merge.cpp
@@ -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) {
diff --git a/clangd/index/SymbolYAML.cpp b/clangd/index/SymbolYAML.cpp
index 304443e6..1701b5a0 100644
--- a/clangd/index/SymbolYAML.cpp
+++ b/clangd/index/SymbolYAML.cpp
@@ -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);
diff --git a/clangd/index/SymbolYAML.h b/clangd/index/SymbolYAML.h
index 9d16cc5d..726af6c6 100644
--- a/clangd/index/SymbolYAML.h
+++ b/clangd/index/SymbolYAML.h
@@ -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))
diff --git a/clangd/tool/ClangdMain.cpp b/clangd/tool/ClangdMain.cpp
index f04a9753..5ae57404 100644
--- a/clangd/tool/ClangdMain.cpp
+++ b/clangd/tool/ClangdMain.cpp
@@ -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);
diff --git a/unittests/clangd/SymbolCollectorTests.cpp b/unittests/clangd/SymbolCollectorTests.cpp
index b2a9990f..666d0bb0 100644
--- a/unittests/clangd/SymbolCollectorTests.cpp
+++ b/unittests/clangd/SymbolCollectorTests.cpp
@@ -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")));
diff --git a/unittests/clangd/TestTU.cpp b/unittests/clangd/TestTU.cpp
index 31281200..b47d9448 100644
--- a/unittests/clangd/TestTU.cpp
+++ b/unittests/clangd/TestTU.cpp
@@ -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>(),