[clangd] NFC: fix clang-tidy warnings.

Most are about llvm code style violation (found via
readability-identifier-naming check).

llvm-svn: 352205
This commit is contained in:
Haojian Wu 2019-01-25 15:14:03 +00:00
parent 1e7491ea9c
commit aa3ed5a983
11 changed files with 35 additions and 34 deletions

View File

@ -31,7 +31,7 @@ class raw_ostream;
namespace vfs {
class FileSystem;
}
} // namespace vfs
} // namespace llvm
namespace clang {
@ -39,7 +39,7 @@ class PCHContainerOperations;
namespace tooling {
struct CompileCommand;
}
} // namespace tooling
namespace clangd {

View File

@ -1588,9 +1588,9 @@ speculateCompletionFilter(llvm::StringRef Content, Position Pos) {
// Start from the character before the cursor.
int St = *Offset - 1;
// FIXME(ioeric): consider UTF characters?
auto IsValidIdentifierChar = [](char c) {
return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
(c >= '0' && c <= '9') || (c == '_'));
auto IsValidIdentifierChar = [](char C) {
return ((C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
(C >= '0' && C <= '9') || (C == '_'));
};
size_t Len = 0;
for (; (St >= 0) && IsValidIdentifierChar(Content[St]); --St, ++Len) {
@ -1682,7 +1682,7 @@ CompletionItem CodeCompletion::render(const CodeCompleteOptions &Opts) const {
// is mainly to help LSP clients again, so that changes do not effect each
// other.
for (const auto &FixIt : FixIts) {
if (IsRangeConsecutive(FixIt.range, LSP.textEdit->range)) {
if (isRangeConsecutive(FixIt.range, LSP.textEdit->range)) {
LSP.textEdit->newText = FixIt.newText + LSP.textEdit->newText;
LSP.textEdit->range.start = FixIt.range.start;
} else {

View File

@ -455,25 +455,25 @@ bool operator==(const SymbolDetails &LHS, const SymbolDetails &RHS) {
}
llvm::json::Value toJSON(const SymbolDetails &P) {
llvm::json::Object result{{"name", llvm::json::Value(nullptr)},
llvm::json::Object Result{{"name", llvm::json::Value(nullptr)},
{"containerName", llvm::json::Value(nullptr)},
{"usr", llvm::json::Value(nullptr)},
{"id", llvm::json::Value(nullptr)}};
if (!P.name.empty())
result["name"] = P.name;
Result["name"] = P.name;
if (!P.containerName.empty())
result["containerName"] = P.containerName;
Result["containerName"] = P.containerName;
if (!P.USR.empty())
result["usr"] = P.USR;
Result["usr"] = P.USR;
if (P.ID.hasValue())
result["id"] = P.ID.getValue().str();
Result["id"] = P.ID.getValue().str();
// Older clang cannot compile 'return Result', even though it is legal.
return llvm::json::Value(std::move(result));
return llvm::json::Value(std::move(Result));
}
llvm::raw_ostream &operator<<(llvm::raw_ostream &O, const SymbolDetails &S) {
@ -559,10 +559,10 @@ bool fromJSON(const llvm::json::Value &Params, CompletionContext &R) {
if (!O)
return false;
int triggerKind;
if (!O.map("triggerKind", triggerKind))
int TriggerKind;
if (!O.map("triggerKind", TriggerKind))
return false;
R.triggerKind = static_cast<CompletionTriggerKind>(triggerKind);
R.triggerKind = static_cast<CompletionTriggerKind>(TriggerKind);
if (auto *TC = Params.getAsObject()->get("triggerCharacter"))
return fromJSON(*TC, R.triggerCharacter);
@ -619,11 +619,11 @@ bool fromJSON(const llvm::json::Value &E, CompletionItemKind &Out) {
CompletionItemKind
adjustKindToCapability(CompletionItemKind Kind,
CompletionItemKindBitset &supportedCompletionItemKinds) {
CompletionItemKindBitset &SupportedCompletionItemKinds) {
auto KindVal = static_cast<size_t>(Kind);
if (KindVal >= CompletionItemKindMin &&
KindVal <= supportedCompletionItemKinds.size() &&
supportedCompletionItemKinds[KindVal])
KindVal <= SupportedCompletionItemKinds.size() &&
SupportedCompletionItemKinds[KindVal])
return Kind;
switch (Kind) {

View File

@ -231,7 +231,7 @@ TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,
return Result;
}
bool IsRangeConsecutive(const Range &Left, const Range &Right) {
bool isRangeConsecutive(const Range &Left, const Range &Right) {
return Left.end.line == Right.start.line &&
Left.end.character == Right.start.character;
}

View File

@ -90,7 +90,7 @@ TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,
llvm::Optional<std::string> getCanonicalPath(const FileEntry *F,
const SourceManager &SourceMgr);
bool IsRangeConsecutive(const Range &Left, const Range &Right);
bool isRangeConsecutive(const Range &Left, const Range &Right);
} // namespace clangd
} // namespace clang
#endif

View File

@ -61,7 +61,7 @@ using std::chrono::steady_clock;
namespace {
class ASTWorker;
}
} // namespace
static clang::clangd::Key<std::string> kFileBeingProcessed;

View File

@ -137,7 +137,7 @@ public:
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
if (Loc == SearchedLocation) {
auto isImplicitExpr = [](const Expr *E) {
auto IsImplicitExpr = [](const Expr *E) {
if (!E)
return false;
// We assume that a constructor expression is implict (was inserted by
@ -149,7 +149,7 @@ public:
return isa<ImplicitCastExpr>(E);
};
bool IsExplicit = !isImplicitExpr(ASTNode.OrigE);
bool IsExplicit = !IsImplicitExpr(ASTNode.OrigE);
// Find and add definition declarations (for GoToDefinition).
// We don't use parameter `D`, as Parameter `D` is the canonical
// declaration, which is the first declaration of a redeclarable

View File

@ -53,12 +53,12 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, SymbolOrigin O) {
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, Symbol::SymbolFlag F) {
if (F == Symbol::None)
return OS << "None";
std::string s;
std::string S;
if (F & Symbol::Deprecated)
s += "deprecated|";
S += "deprecated|";
if (F & Symbol::IndexedForCodeCompletion)
s += "completion|";
return OS << llvm::StringRef(s).rtrim('|');
S += "completion|";
return OS << llvm::StringRef(S).rtrim('|');
}
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S) {

View File

@ -105,9 +105,9 @@ public:
};
void write32(uint32_t I, llvm::raw_ostream &OS) {
char buf[4];
llvm::support::endian::write32le(buf, I);
OS.write(buf, sizeof(buf));
char Buf[4];
llvm::support::endian::write32le(Buf, I);
OS.write(Buf, sizeof(Buf));
}
void writeVar(uint32_t I, llvm::raw_ostream &OS) {

View File

@ -49,7 +49,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolID &ID) {
llvm::hash_code hash_value(const SymbolID &ID) {
// We already have a good hash, just return the first bytes.
assert(sizeof(size_t) <= SymbolID::RawSize && "size_t longer than SHA1!");
static_assert(sizeof(size_t) <= SymbolID::RawSize,
"size_t longer than SHA1!");
size_t Result;
memcpy(&Result, ID.raw().data(), sizeof(size_t));
return llvm::hash_code(Result);

View File

@ -133,11 +133,11 @@ TEST(SourceCodeTests, OffsetToPosition) {
}
TEST(SourceCodeTests, IsRangeConsecutive) {
EXPECT_TRUE(IsRangeConsecutive(range({2, 2}, {2, 3}), range({2, 3}, {2, 4})));
EXPECT_TRUE(isRangeConsecutive(range({2, 2}, {2, 3}), range({2, 3}, {2, 4})));
EXPECT_FALSE(
IsRangeConsecutive(range({0, 2}, {0, 3}), range({2, 3}, {2, 4})));
isRangeConsecutive(range({0, 2}, {0, 3}), range({2, 3}, {2, 4})));
EXPECT_FALSE(
IsRangeConsecutive(range({2, 2}, {2, 3}), range({2, 4}, {2, 5})));
isRangeConsecutive(range({2, 2}, {2, 3}), range({2, 4}, {2, 5})));
}
} // namespace