[NFC] Fix typos in Clangd and Clang

Reviewed by: Jim

Differential Revision: https://reviews.llvm.org/D71455
This commit is contained in:
Kirill Bobyrev 2019-12-16 10:33:56 +01:00
parent f49d15b3f8
commit 3b9715cb21
21 changed files with 83 additions and 85 deletions

View File

@ -377,7 +377,7 @@ public:
// Loc of "auto" in operator auto()
if (CurLoc.isInvalid() && dyn_cast<CXXConversionDecl>(D))
CurLoc = D->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
// Loc of "auto" in function with traling return type (c++11).
// Loc of "auto" in function with trailing return type (c++11).
if (CurLoc.isInvalid())
CurLoc = D->getSourceRange().getBegin();
if (CurLoc != SearchedLocation)

View File

@ -466,7 +466,7 @@ void ClangdServer::locateSymbolAt(PathRef File, Position Pos,
void ClangdServer::switchSourceHeader(
PathRef Path, Callback<llvm::Optional<clangd::Path>> CB) {
// We want to return the result as fast as possible, stragety is:
// We want to return the result as fast as possible, strategy is:
// 1) use the file-only heuristic, it requires some IO but it is much
// faster than building AST, but it only works when .h/.cc files are in
// the same directory.

View File

@ -395,7 +395,7 @@ private:
std::string ReturnType;
};
// If all BundledEntrys have the same value for a property, return it.
// If all BundledEntries have the same value for a property, return it.
template <std::string BundledEntry::*Member>
const std::string *onlyValue() const {
auto B = Bundled.begin(), E = Bundled.end();
@ -499,7 +499,7 @@ llvm::Optional<SymbolID> getSymbolID(const CodeCompletionResult &R,
llvm_unreachable("unknown CodeCompletionResult kind");
}
// Scopes of the paritial identifier we're trying to complete.
// Scopes of the partial identifier we're trying to complete.
// It is used when we query the index for more completion results.
struct SpecifiedScope {
// The scopes we should look in, determined by Sema.
@ -874,7 +874,7 @@ public:
// Function Template.
// - High score is better.
// - Shorter signature is better.
// - Alphebatically smaller is better.
// - Alphabetically smaller is better.
if (L.Quality.NumberOfParameters != R.Quality.NumberOfParameters)
return L.Quality.NumberOfParameters < R.Quality.NumberOfParameters;
if (L.Quality.NumberOfOptionalParameters !=
@ -1510,7 +1510,7 @@ private:
}
// Merges Sema and Index results where possible, to form CompletionCandidates.
// \p Identifiers is raw idenfiers that can also be completion condidates.
// \p Identifiers is raw idenfiers that can also be completion candidates.
// Identifiers are not merged with results from index or sema.
// Groups overloads if desired, to form CompletionCandidate::Bundles. The
// bundles are scored and top results are returned, best to worst.

View File

@ -232,7 +232,7 @@ std::string capitalize(std::string Message) {
}
/// Returns a message sent to LSP for the main diagnostic in \p D.
/// This message may include notes, if they're not emited in some other way.
/// This message may include notes, if they're not emitted in some other way.
/// Example output:
///
/// no matching function for call to 'foo'

View File

@ -53,7 +53,7 @@ struct ClangdDiagnosticOptions {
struct DiagBase {
std::string Message;
// Intended to be used only in error messages.
// May be relative, absolute or even artifically constructed.
// May be relative, absolute or even artificially constructed.
std::string File;
// Absolute path to containing file, if available.
llvm::Optional<std::string> AbsFile;

View File

@ -649,10 +649,10 @@ llvm::SmallVector<ReferenceLoc, 2> refInTypeLoc(TypeLoc L) {
return {*V.Ref};
}
class ExplicitReferenceColletor
: public RecursiveASTVisitor<ExplicitReferenceColletor> {
class ExplicitReferenceCollector
: public RecursiveASTVisitor<ExplicitReferenceCollector> {
public:
ExplicitReferenceColletor(llvm::function_ref<void(ReferenceLoc)> Out)
ExplicitReferenceCollector(llvm::function_ref<void(ReferenceLoc)> Out)
: Out(Out) {
assert(Out);
}
@ -798,16 +798,16 @@ private:
void findExplicitReferences(const Stmt *S,
llvm::function_ref<void(ReferenceLoc)> Out) {
assert(S);
ExplicitReferenceColletor(Out).TraverseStmt(const_cast<Stmt *>(S));
ExplicitReferenceCollector(Out).TraverseStmt(const_cast<Stmt *>(S));
}
void findExplicitReferences(const Decl *D,
llvm::function_ref<void(ReferenceLoc)> Out) {
assert(D);
ExplicitReferenceColletor(Out).TraverseDecl(const_cast<Decl *>(D));
ExplicitReferenceCollector(Out).TraverseDecl(const_cast<Decl *>(D));
}
void findExplicitReferences(const ASTContext &AST,
llvm::function_ref<void(ReferenceLoc)> Out) {
ExplicitReferenceColletor(Out).TraverseAST(const_cast<ASTContext &>(AST));
ExplicitReferenceCollector(Out).TraverseAST(const_cast<ASTContext &>(AST));
}
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, DeclRelation R) {

View File

@ -28,7 +28,7 @@ namespace {
/// Escape a markdown text block. Ensures the punctuation will not introduce
/// any of the markdown constructs.
std::string renderText(llvm::StringRef Input) {
// Escaping ASCII punctiation ensures we can't start a markdown construct.
// Escaping ASCII punctuation ensures we can't start a markdown construct.
constexpr llvm::StringLiteral Punctuation =
R"txt(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)txt";
@ -93,7 +93,7 @@ std::string getMarkerForCodeBlock(llvm::StringRef Input) {
return std::string(/*Repeat=*/std::max(3u, MaxBackticks + 1), '`');
}
// Trims the input and concatanates whitespace blocks into a single ` `.
// Trims the input and concatenates whitespace blocks into a single ` `.
std::string canonicalizeSpaces(std::string Input) {
// Goes over the string and preserves only a single ` ` for any whitespace
// chunks, the rest is moved to the end of the string and dropped in the end.
@ -102,7 +102,7 @@ std::string canonicalizeSpaces(std::string Input) {
llvm::SplitString(Input, Words);
if (Words.empty())
return "";
// Go over each word and and add it to the string.
// Go over each word and add it to the string.
for (llvm::StringRef Word : Words) {
llvm::for_each(Word, [&WritePtr](const char C) { *WritePtr++ = C; });
// Separate from next block.

View File

@ -480,7 +480,7 @@ void ASTWorker::update(ParseInputs Inputs, WantDiagnostics WantDiags) {
{
std::lock_guard<std::mutex> Lock(PublishMu);
// No need to rebuild the AST if we won't send the diagnotics. However,
// No need to rebuild the AST if we won't send the diagnostics. However,
// note that we don't prevent preamble rebuilds.
if (!CanPublishResults)
return;

View File

@ -55,7 +55,7 @@ public:
};
// Called by Clangd to receive messages from the client.
// The transport should in turn invoke the handler to process messages.
// If handler returns false, the transport should immedately exit the loop.
// If handler returns false, the transport should immediately exit the loop.
// (This is used to implement the `exit` notification).
// Otherwise, it returns an error when the transport becomes unusable.
virtual llvm::Error loop(MessageHandler &) = 0;

View File

@ -120,7 +120,7 @@ SymbolLocation getPreferredLocation(const Location &ASTLoc,
const SymbolLocation &IdxLoc,
std::string &Scratch) {
// Also use a dummy symbol for the index location so that other fields (e.g.
// definition) are not factored into the preferrence.
// definition) are not factored into the preference.
Symbol ASTSym, IdxSym;
ASTSym.ID = IdxSym.ID = SymbolID("dummy_id");
ASTSym.CanonicalDeclaration = toIndexLocation(ASTLoc, Scratch);
@ -353,10 +353,10 @@ public:
}
bool
handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
llvm::ArrayRef<index::SymbolRelation> Relations,
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles,
llvm::ArrayRef<index::SymbolRelation> Relations,
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
assert(D->isCanonicalDecl() && "expect D to be a canonical declaration");
const SourceManager &SM = AST.getSourceManager();
Loc = SM.getFileLoc(Loc);

View File

@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
//
// FileIndex implements SymbolIndex for symbols from a set of files. Symbols are
// maintained at source-file granuality (e.g. with ASTs), and files can be
// maintained at source-file granularity (e.g. with ASTs), and files can be
// updated dynamically.
//
//===----------------------------------------------------------------------===//

View File

@ -245,14 +245,14 @@ bool SymbolCollector::shouldCollectSymbol(const NamedDecl &ND,
}
// Always return true to continue indexing.
bool SymbolCollector::handleDeclOccurence(
bool SymbolCollector::handleDeclOccurrence(
const Decl *D, index::SymbolRoleSet Roles,
llvm::ArrayRef<index::SymbolRelation> Relations, SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) {
assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
assert(CompletionAllocator && CompletionTUInfo);
assert(ASTNode.OrigD);
// Indexing API puts cannonical decl into D, which might not have a valid
// Indexing API puts canonical decl into D, which might not have a valid
// source location for implicit/built-in decls. Fallback to original decl in
// such cases.
if (D->getLocation().isInvalid())
@ -346,10 +346,10 @@ bool SymbolCollector::handleDeclOccurence(
return true;
}
bool SymbolCollector::handleMacroOccurence(const IdentifierInfo *Name,
const MacroInfo *MI,
index::SymbolRoleSet Roles,
SourceLocation Loc) {
bool SymbolCollector::handleMacroOccurrence(const IdentifierInfo *Name,
const MacroInfo *MI,
index::SymbolRoleSet Roles,
SourceLocation Loc) {
assert(PP.get());
const auto &SM = PP->getSourceManager();
@ -524,9 +524,8 @@ void SymbolCollector::finish() {
auto FileURI = toURI(SM, FileEntry->getName(), Opts);
Found = URICache.insert({FID, FileURI}).first;
} else {
// Ignore cases where we can not find a corresponding file entry
// for the loc, thoses are not interesting, e.g. symbols formed
// via macro concatenation.
// Ignore cases where we can not find a corresponding file entry for
// given location, e.g. symbols formed via macro concatenation.
return None;
}
}

View File

@ -99,14 +99,14 @@ public:
}
bool
handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
ArrayRef<index::SymbolRelation> Relations,
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override;
handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles,
ArrayRef<index::SymbolRelation> Relations,
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override;
bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI,
index::SymbolRoleSet Roles,
SourceLocation Loc) override;
bool handleMacroOccurrence(const IdentifierInfo *Name, const MacroInfo *MI,
index::SymbolRoleSet Roles,
SourceLocation Loc) override;
SymbolSlab takeSymbols() { return std::move(Symbols).build(); }
RefSlab takeRefs() { return std::move(Refs).build(); }

View File

@ -364,7 +364,7 @@ llvm::Expected<FileEdits> renameOutsideFile(
std::move(FileAndOccurrences.second),
RenameDecl.getASTContext().getLangOpts());
if (!RenameRanges) {
// Our heuristice fails to adjust rename ranges to the current state of
// Our heuristics fails to adjust rename ranges to the current state of
// the file, it is most likely the index is stale, so we give up the
// entire rename.
return llvm::make_error<llvm::StringError>(
@ -387,7 +387,7 @@ llvm::Expected<FileEdits> renameOutsideFile(
return Results;
}
// A simple edit is eithor changing line or column, but not both.
// A simple edit is either changing line or column, but not both.
bool impliesSimpleEdit(const Position &LHS, const Position &RHS) {
return LHS.line == RHS.line || LHS.character == RHS.character;
}

View File

@ -39,16 +39,16 @@ public:
virtual void setPreprocessor(std::shared_ptr<Preprocessor> PP) {}
/// \returns true to continue indexing, or false to abort.
virtual bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
ArrayRef<SymbolRelation> Relations,
SourceLocation Loc, ASTNodeInfo ASTNode) {
virtual bool handleDeclOccurrence(const Decl *D, SymbolRoleSet Roles,
ArrayRef<SymbolRelation> Relations,
SourceLocation Loc, ASTNodeInfo ASTNode) {
return true;
}
/// \returns true to continue indexing, or false to abort.
virtual bool handleMacroOccurence(const IdentifierInfo *Name,
const MacroInfo *MI, SymbolRoleSet Roles,
SourceLocation Loc) {
virtual bool handleMacroOccurrence(const IdentifierInfo *Name,
const MacroInfo *MI, SymbolRoleSet Roles,
SourceLocation Loc) {
return true;
}
@ -57,9 +57,9 @@ public:
/// This will be called for each module reference in an import decl.
/// For "@import MyMod.SubMod", there will be a call for 'MyMod' with the
/// 'reference' role, and a call for 'SubMod' with the 'declaration' role.
virtual bool handleModuleOccurence(const ImportDecl *ImportD,
const Module *Mod, SymbolRoleSet Roles,
SourceLocation Loc) {
virtual bool handleModuleOccurrence(const ImportDecl *ImportD,
const Module *Mod, SymbolRoleSet Roles,
SourceLocation Loc) {
return true;
}

View File

@ -151,7 +151,7 @@ static void indexPreprocessorMacros(const Preprocessor &PP,
IndexDataConsumer &DataConsumer) {
for (const auto &M : PP.macros())
if (MacroDirective *MD = M.second.getLatest())
DataConsumer.handleMacroOccurence(
DataConsumer.handleMacroOccurrence(
M.first, MD->getMacroInfo(),
static_cast<unsigned>(index::SymbolRole::Definition),
MD->getLocation());

View File

@ -99,9 +99,8 @@ static void reportModuleReferences(const Module *Mod,
return;
reportModuleReferences(Mod->Parent, IdLocs.drop_back(), ImportD,
DataConsumer);
DataConsumer.handleModuleOccurence(ImportD, Mod,
(SymbolRoleSet)SymbolRole::Reference,
IdLocs.back());
DataConsumer.handleModuleOccurrence(
ImportD, Mod, (SymbolRoleSet)SymbolRole::Reference, IdLocs.back());
}
bool IndexingContext::importedModule(const ImportDecl *ImportD) {
@ -145,7 +144,7 @@ bool IndexingContext::importedModule(const ImportDecl *ImportD) {
if (ImportD->isImplicit())
Roles |= (unsigned)SymbolRole::Implicit;
return DataConsumer.handleModuleOccurence(ImportD, Mod, Roles, Loc);
return DataConsumer.handleModuleOccurrence(ImportD, Mod, Roles, Loc);
}
bool IndexingContext::isTemplateImplicitInstantiation(const Decl *D) {
@ -443,26 +442,26 @@ bool IndexingContext::handleDeclOccurrence(const Decl *D, SourceLocation Loc,
}
IndexDataConsumer::ASTNodeInfo Node{OrigE, OrigD, Parent, ContainerDC};
return DataConsumer.handleDeclOccurence(D, Roles, FinalRelations, Loc, Node);
return DataConsumer.handleDeclOccurrence(D, Roles, FinalRelations, Loc, Node);
}
void IndexingContext::handleMacroDefined(const IdentifierInfo &Name,
SourceLocation Loc,
const MacroInfo &MI) {
SymbolRoleSet Roles = (unsigned)SymbolRole::Definition;
DataConsumer.handleMacroOccurence(&Name, &MI, Roles, Loc);
DataConsumer.handleMacroOccurrence(&Name, &MI, Roles, Loc);
}
void IndexingContext::handleMacroUndefined(const IdentifierInfo &Name,
SourceLocation Loc,
const MacroInfo &MI) {
SymbolRoleSet Roles = (unsigned)SymbolRole::Undefinition;
DataConsumer.handleMacroOccurence(&Name, &MI, Roles, Loc);
DataConsumer.handleMacroOccurrence(&Name, &MI, Roles, Loc);
}
void IndexingContext::handleMacroReference(const IdentifierInfo &Name,
SourceLocation Loc,
const MacroInfo &MI) {
SymbolRoleSet Roles = (unsigned)SymbolRole::Reference;
DataConsumer.handleMacroOccurence(&Name, &MI, Roles, Loc);
DataConsumer.handleMacroOccurrence(&Name, &MI, Roles, Loc);
}

View File

@ -94,9 +94,9 @@ public:
this->PP = std::move(PP);
}
bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
ArrayRef<SymbolRelation> Relations,
SourceLocation Loc, ASTNodeInfo ASTNode) override {
bool handleDeclOccurrence(const Decl *D, SymbolRoleSet Roles,
ArrayRef<SymbolRelation> Relations,
SourceLocation Loc, ASTNodeInfo ASTNode) override {
ASTContext &Ctx = D->getASTContext();
SourceManager &SM = Ctx.getSourceManager();
@ -132,9 +132,9 @@ public:
return true;
}
bool handleModuleOccurence(const ImportDecl *ImportD,
const clang::Module *Mod,
SymbolRoleSet Roles, SourceLocation Loc) override {
bool handleModuleOccurrence(const ImportDecl *ImportD,
const clang::Module *Mod, SymbolRoleSet Roles,
SourceLocation Loc) override {
ASTContext &Ctx = ImportD->getASTContext();
SourceManager &SM = Ctx.getSourceManager();
@ -156,8 +156,8 @@ public:
return true;
}
bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI,
SymbolRoleSet Roles, SourceLocation Loc) override {
bool handleMacroOccurrence(const IdentifierInfo *Name, const MacroInfo *MI,
SymbolRoleSet Roles, SourceLocation Loc) override {
assert(PP);
SourceManager &SM = PP->getSourceManager();

View File

@ -154,7 +154,7 @@ CXSymbolRole getSymbolRole(SymbolRoleSet Role) {
}
}
bool CXIndexDataConsumer::handleDeclOccurence(
bool CXIndexDataConsumer::handleDeclOccurrence(
const Decl *D, SymbolRoleSet Roles, ArrayRef<SymbolRelation> Relations,
SourceLocation Loc, ASTNodeInfo ASTNode) {
Loc = getASTContext().getSourceManager().getFileLoc(Loc);
@ -220,10 +220,10 @@ bool CXIndexDataConsumer::handleDeclOccurence(
return !shouldAbort();
}
bool CXIndexDataConsumer::handleModuleOccurence(const ImportDecl *ImportD,
const Module *Mod,
SymbolRoleSet Roles,
SourceLocation Loc) {
bool CXIndexDataConsumer::handleModuleOccurrence(const ImportDecl *ImportD,
const Module *Mod,
SymbolRoleSet Roles,
SourceLocation Loc) {
if (Roles & (SymbolRoleSet)SymbolRole::Declaration)
IndexingDeclVisitor(*this, SourceLocation(), nullptr).Visit(ImportD);
return !shouldAbort();

View File

@ -431,13 +431,13 @@ public:
static bool isTemplateImplicitInstantiation(const Decl *D);
private:
bool handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
ArrayRef<index::SymbolRelation> Relations,
SourceLocation Loc, ASTNodeInfo ASTNode) override;
bool handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles,
ArrayRef<index::SymbolRelation> Relations,
SourceLocation Loc, ASTNodeInfo ASTNode) override;
bool handleModuleOccurence(const ImportDecl *ImportD, const Module *Mod,
index::SymbolRoleSet Roles,
SourceLocation Loc) override;
bool handleModuleOccurrence(const ImportDecl *ImportD, const Module *Mod,
index::SymbolRoleSet Roles,
SourceLocation Loc) override;
void finish() override;

View File

@ -74,9 +74,9 @@ public:
IndexDataConsumer::initialize(Ctx);
}
bool handleDeclOccurence(const Decl *D, SymbolRoleSet Roles,
ArrayRef<SymbolRelation>, SourceLocation Loc,
ASTNodeInfo) override {
bool handleDeclOccurrence(const Decl *D, SymbolRoleSet Roles,
ArrayRef<SymbolRelation>, SourceLocation Loc,
ASTNodeInfo) override {
const auto *ND = llvm::dyn_cast<NamedDecl>(D);
if (!ND)
return true;
@ -91,8 +91,8 @@ public:
return true;
}
bool handleMacroOccurence(const IdentifierInfo *Name, const MacroInfo *MI,
SymbolRoleSet Roles, SourceLocation Loc) override {
bool handleMacroOccurrence(const IdentifierInfo *Name, const MacroInfo *MI,
SymbolRoleSet Roles, SourceLocation Loc) override {
TestSymbol S;
S.SymInfo = getSymbolInfoForMacro(*MI);
S.QName = Name->getName();