[NFC][clangd] cleanup llvm-else-after-return findings

Cleanup of clang-tidy findings: removing "else" after a return statement
to improve readability of the code.

This patch was created by applying the clang-tidy fixes automatically.

Differential Revision: https://reviews.llvm.org/D113892
This commit is contained in:
Christian Kühnel 2021-11-15 15:00:23 +00:00
parent 4ea066acc9
commit ec4a2c9565
12 changed files with 28 additions and 28 deletions

View File

@ -929,8 +929,7 @@ void ClangdLSPServer::onDocumentSymbol(const DocumentSymbolParams &Params,
adjustSymbolKinds(*Items, SupportedSymbolKinds);
if (SupportsHierarchicalDocumentSymbol)
return Reply(std::move(*Items));
else
return Reply(flattenSymbolHierarchy(*Items, FileURI));
return Reply(flattenSymbolHierarchy(*Items, FileURI));
});
}

View File

@ -320,8 +320,9 @@ llvm::SmallString<256> FuzzyMatcher::dumpLast(llvm::raw_ostream &OS) const {
if (!WordContainsPattern) {
OS << "Substring check failed.\n";
return Result;
} else if (isAwful(std::max(Scores[PatN][WordN][Match].Score,
Scores[PatN][WordN][Miss].Score))) {
}
if (isAwful(std::max(Scores[PatN][WordN][Match].Score,
Scores[PatN][WordN][Miss].Score))) {
OS << "Substring check passed, but all matches are forbidden\n";
}
if (!(PatTypeSet & 1 << Upper))

View File

@ -74,7 +74,7 @@ std::string getLocalScope(const Decl *D) {
// - Classes, categories, and protocols: "MyClass(Category)"
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(DC))
return printObjCMethod(*MD);
else if (const ObjCContainerDecl *CD = dyn_cast<ObjCContainerDecl>(DC))
if (const ObjCContainerDecl *CD = dyn_cast<ObjCContainerDecl>(DC))
return printObjCContainer(*CD);
auto GetName = [](const TypeDecl *D) {

View File

@ -194,8 +194,7 @@ bool JSONTransport::handleMessage(llvm::json::Value Message,
if (ID)
return Handler.onCall(*Method, std::move(Params), std::move(*ID));
else
return Handler.onNotify(*Method, std::move(Params));
return Handler.onNotify(*Method, std::move(Params));
}
// Tries to read a line up to and including \n.
@ -254,14 +253,14 @@ bool JSONTransport::readStandardMessage(std::string &JSON) {
}
llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
continue;
} else if (!LineRef.trim().empty()) {
// It's another header, ignore it.
continue;
} else {
// An empty line indicates the end of headers.
// Go ahead and read the JSON.
break;
}
// An empty line indicates the end of headers.
// Go ahead and read the JSON.
if (LineRef.trim().empty())
break;
// It's another header, ignore it.
}
// The fuzzer likes crashing us by sending "Content-Length: 9999999999999999"

View File

@ -151,7 +151,8 @@ llvm::Expected<std::string> parsePath(llvm::StringRef Path) {
namespace path = llvm::sys::path;
if (path::is_absolute(Path, path::Style::posix)) {
return std::string(Path);
} else if (path::is_absolute(Path, path::Style::windows)) {
}
if (path::is_absolute(Path, path::Style::windows)) {
std::string Converted = path::convert_to_slash(Path, path::Style::windows);
if (Converted.front() != '/')
Converted = "/" + Converted;

View File

@ -695,7 +695,8 @@ bool fromJSON(const llvm::json::Value &Params, ExecuteCommandParams &R,
if (ArgsArray->size() > 1) {
P.field("arguments").report("Command should have 0 or 1 argument");
return false;
} else if (ArgsArray->size() == 1) {
}
if (ArgsArray->size() == 1) {
R.argument = ArgsArray->front();
}
return true;

View File

@ -346,7 +346,7 @@ private:
SM.getTopMacroCallerLoc(Batch.back().location());
return testTokenRange(SM.getFileOffset(ArgStart),
SM.getFileOffset(ArgEnd));
} else {
} else { // NOLINT(llvm-else-after-return)
/* fall through and treat as part of the macro body */
}
}
@ -357,8 +357,7 @@ private:
if (Expansion.first == SelFile)
// FIXME: also check ( and ) for function-like macros?
return testToken(Expansion.second);
else
return NoTokens;
return NoTokens;
}
// Is the closed token range [Begin, End] selected?

View File

@ -1282,8 +1282,8 @@ void ASTWorker::run() {
if (Done) {
if (Requests.empty())
return;
else // Even though Done is set, finish pending requests.
break; // However, skip delays to shutdown fast.
// Even though Done is set, finish pending requests.
break; // However, skip delays to shutdown fast.
}
// Tracing: we have a next request, attribute this sleep to it.

View File

@ -826,10 +826,9 @@ std::vector<LocatedSymbol> locateSymbolAt(ParsedAST &AST, Position Pos,
log("Found definition heuristically using nearby identifier {0}",
NearbyIdent->text(SM));
return ASTResults;
} else {
vlog("No definition found using nearby identifier {0} at {1}",
Word->Text, Word->Location.printToString(SM));
}
vlog("No definition found using nearby identifier {0} at {1}", Word->Text,
Word->Location.printToString(SM));
}
// No nearby word, or it didn't refer to anything either. Try the index.
auto TextualResults =

View File

@ -687,7 +687,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const IndexFileOut &O) {
llvm::Expected<IndexFileIn> readIndexFile(llvm::StringRef Data) {
if (Data.startswith("RIFF")) {
return readRIFF(Data);
} else if (auto YAMLContents = readYAML(Data)) {
}
if (auto YAMLContents = readYAML(Data)) {
return std::move(*YAMLContents);
} else {
return error("Not a RIFF file and failed to parse as YAML: {0}",

View File

@ -250,7 +250,8 @@ bool AddUsing::prepare(const Selection &Inputs) {
for (; Node->Parent; Node = Node->Parent) {
if (Node->ASTNode.get<NestedNameSpecifierLoc>()) {
continue;
} else if (auto *T = Node->ASTNode.get<TypeLoc>()) {
}
if (auto *T = Node->ASTNode.get<TypeLoc>()) {
if (T->getAs<ElaboratedTypeLoc>()) {
break;
} else if (Node->Parent->ASTNode.get<TypeLoc>() ||

View File

@ -223,8 +223,7 @@ bool alwaysReturns(const ExtractionZone &EZ) {
while (const auto *CS = llvm::dyn_cast<CompoundStmt>(Last)) {
if (CS->body_empty())
return false;
else
Last = CS->body_back();
Last = CS->body_back();
}
return llvm::isa<ReturnStmt>(Last);
}