From 21522df485be99f247a18c13827e525bda74e362 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 19 Aug 2018 22:23:42 +0000 Subject: [PATCH] [Lex] Fix some inconsistent parameter names and duplicate comments. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340145 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Lex/DirectoryLookup.h | 2 +- include/clang/Lex/HeaderSearch.h | 20 ++++++------- include/clang/Lex/Lexer.h | 12 ++++---- include/clang/Lex/ModuleMap.h | 2 +- include/clang/Lex/Pragma.h | 2 +- include/clang/Lex/Preprocessor.h | 32 ++++++++++---------- include/clang/Lex/PreprocessorLexer.h | 2 +- include/clang/Lex/TokenLexer.h | 42 +++++++++++++-------------- 8 files changed, 56 insertions(+), 58 deletions(-) diff --git a/include/clang/Lex/DirectoryLookup.h b/include/clang/Lex/DirectoryLookup.h index 55065b7d85..bfb496be50 100644 --- a/include/clang/Lex/DirectoryLookup.h +++ b/include/clang/Lex/DirectoryLookup.h @@ -191,7 +191,7 @@ private: SmallVectorImpl *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, - bool &InUserSpecifiedSystemHeader) const; + bool &InUserSpecifiedSystemFramework) const; }; diff --git a/include/clang/Lex/HeaderSearch.h b/include/clang/Lex/HeaderSearch.h index 6bb0f58f2d..8077fee226 100644 --- a/include/clang/Lex/HeaderSearch.h +++ b/include/clang/Lex/HeaderSearch.h @@ -55,7 +55,7 @@ struct HeaderFileInfo { /// True if this is a \#pragma once file. unsigned isPragmaOnce : 1; - /// DirInfo - Keep track of whether this is a system header, and if so, + /// Keep track of whether this is a system header, and if so, /// whether it is C++ clean or not. This can be set by the include paths or /// by \#pragma gcc system_header. This is an instance of /// SrcMgr::CharacteristicKind. @@ -219,14 +219,14 @@ class HeaderSearch { /// name like "Carbon" to the Carbon.framework directory. llvm::StringMap FrameworkMap; - /// IncludeAliases - maps include file names (including the quotes or + /// Maps include file names (including the quotes or /// angle brackets) to other include file names. This is used to support the /// include_alias pragma for Microsoft compatibility. using IncludeAliasMap = llvm::StringMap; std::unique_ptr IncludeAliases; - /// HeaderMaps - This is a mapping from FileEntry -> HeaderMap, uniquing + /// This is a mapping from FileEntry -> HeaderMap, uniquing /// headermaps. This vector owns the headermap. std::vector> HeaderMaps; @@ -314,7 +314,7 @@ public: (*IncludeAliases)[Source] = Dest; } - /// MapHeaderToIncludeAlias - Maps one header file name to a different header + /// Maps one header file name to a different header /// file name, for use with the include_alias pragma. Note that the source /// file name should include the angle brackets or quotes. Returns StringRef /// as null if the header cannot be mapped. @@ -408,7 +408,7 @@ public: /// HIToolbox is a subframework within Carbon.framework. If so, return /// the FileEntry for the designated file, otherwise return null. const FileEntry *LookupSubframeworkHeader( - StringRef Filename, const FileEntry *RelativeFileEnt, + StringRef Filename, const FileEntry *ContextFileEnt, SmallVectorImpl *SearchPath, SmallVectorImpl *RelativePath, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule); @@ -425,7 +425,7 @@ public: /// if we should include it. bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File, bool isImport, bool ModulesEnabled, - Module *CorrespondingModule); + Module *M); /// Return whether the specified file is a normal header, /// a system header, or a C++ friendly system header. @@ -448,9 +448,9 @@ public: } /// Mark the specified file as part of a module. - void MarkFileModuleHeader(const FileEntry *File, + void MarkFileModuleHeader(const FileEntry *FE, ModuleMap::ModuleHeaderRole Role, - bool IsCompiledModuleHeader); + bool isCompilingModuleHeader); /// Increment the count for the number of times the specified /// FileEntry has been entered. @@ -479,7 +479,7 @@ public: /// This routine does not consider the effect of \#import bool isFileMultipleIncludeGuarded(const FileEntry *File); - /// CreateHeaderMap - This method returns a HeaderMap for the specified + /// This method returns a HeaderMap for the specified /// FileEntry, uniquing them through the 'HeaderMaps' datastructure. const HeaderMap *CreateHeaderMap(const FileEntry *FE); @@ -641,7 +641,7 @@ private: /// \return \c true if the file can be used, \c false if we are not permitted to /// find this file due to requirements from \p RequestingModule. bool findUsableModuleForFrameworkHeader( - const FileEntry *File, StringRef FrameworkDir, Module *RequestingModule, + const FileEntry *File, StringRef FrameworkName, Module *RequestingModule, ModuleMap::KnownHeader *SuggestedModule, bool IsSystemFramework); /// Look up the file with the specified name and determine its owning diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h index 624151ef87..0fb874585a 100644 --- a/include/clang/Lex/Lexer.h +++ b/include/clang/Lex/Lexer.h @@ -139,7 +139,7 @@ public: /// with the specified preprocessor managing the lexing process. This lexer /// assumes that the associated file buffer and Preprocessor objects will /// outlive it, so it doesn't take ownership of either of them. - Lexer(FileID FID, const llvm::MemoryBuffer *InputBuffer, Preprocessor &PP); + Lexer(FileID FID, const llvm::MemoryBuffer *InputFile, Preprocessor &PP); /// Lexer constructor - Create a new raw lexer object. This object is only /// suitable for calls to 'LexFromRawLexer'. This lexer assumes that the @@ -150,7 +150,7 @@ public: /// Lexer constructor - Create a new raw lexer object. This object is only /// suitable for calls to 'LexFromRawLexer'. This lexer assumes that the /// text range will outlive it, so it doesn't take ownership of it. - Lexer(FileID FID, const llvm::MemoryBuffer *InputBuffer, + Lexer(FileID FID, const llvm::MemoryBuffer *FromFile, const SourceManager &SM, const LangOptions &LangOpts); Lexer(const Lexer &) = delete; @@ -310,8 +310,8 @@ public: /// location. static StringRef getSpelling(SourceLocation loc, SmallVectorImpl &buffer, - const SourceManager &SourceMgr, - const LangOptions &LangOpts, + const SourceManager &SM, + const LangOptions &options, bool *invalid = nullptr); /// MeasureTokenLength - Relex the token at the specified location and return @@ -339,7 +339,7 @@ public: /// Get the physical length (including trigraphs and escaped newlines) of the /// first \p Characters characters of the token starting at TokStart. static unsigned getTokenPrefixLength(SourceLocation TokStart, - unsigned Characters, + unsigned CharNo, const SourceManager &SM, const LangOptions &LangOpts); @@ -724,7 +724,7 @@ private: /// /// \return The Unicode codepoint specified by the UCN, or 0 if the UCN is /// invalid. - uint32_t tryReadUCN(const char *&CurPtr, const char *SlashLoc, Token *Tok); + uint32_t tryReadUCN(const char *&StartPtr, const char *SlashLoc, Token *Result); /// Try to consume a UCN as part of an identifier at the current /// location. diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h index aa519891c1..4a3984e746 100644 --- a/include/clang/Lex/ModuleMap.h +++ b/include/clang/Lex/ModuleMap.h @@ -580,7 +580,7 @@ public: /// getContainingModuleMapFile(). const FileEntry *getModuleMapFileForUniquing(const Module *M) const; - void setInferredModuleAllowedBy(Module *M, const FileEntry *ModuleMap); + void setInferredModuleAllowedBy(Module *M, const FileEntry *ModMap); /// Get any module map files other than getModuleMapFileForUniquing(M) /// that define submodules of a top-level module \p M. This is cheaper than diff --git a/include/clang/Lex/Pragma.h b/include/clang/Lex/Pragma.h index 4d74face52..fb2942f091 100644 --- a/include/clang/Lex/Pragma.h +++ b/include/clang/Lex/Pragma.h @@ -113,7 +113,7 @@ public: bool IsEmpty() const { return Handlers.empty(); } void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer, - Token &FirstToken) override; + Token &Tok) override; PragmaNamespace *getIfNamespace() override { return this; } }; diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index 0feeca56f7..cc2d59b133 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -1160,7 +1160,7 @@ public: void createPreprocessingRecord(); /// Returns true if the FileEntry is the PCH through header. - bool isPCHThroughHeader(const FileEntry *File); + bool isPCHThroughHeader(const FileEntry *FE); /// True if creating a PCH with a through header. bool creatingPCHWithThroughHeader(); @@ -1186,7 +1186,7 @@ public: /// start lexing tokens from it instead of the current buffer. /// /// Emits a diagnostic, doesn't enter the file, and returns true on error. - bool EnterSourceFile(FileID CurFileID, const DirectoryLookup *Dir, + bool EnterSourceFile(FileID FID, const DirectoryLookup *Dir, SourceLocation Loc); /// Add a Macro to the top of the include stack and start lexing @@ -1195,7 +1195,7 @@ public: /// \param Args specifies the tokens input to a function-like macro. /// \param ILEnd specifies the location of the ')' for a function-like macro /// or the identifier for an object-like macro. - void EnterMacro(Token &Identifier, SourceLocation ILEnd, MacroInfo *Macro, + void EnterMacro(Token &Tok, SourceLocation ILEnd, MacroInfo *Macro, MacroArgs *Args); /// Add a "macro" context to the top of the include stack, @@ -1749,7 +1749,7 @@ public: void SetPoisonReason(IdentifierInfo *II, unsigned DiagID); /// Display reason for poisoned identifier. - void HandlePoisonedIdentifier(Token & Tok); + void HandlePoisonedIdentifier(Token & Identifier); void MaybeHandlePoisonedIdentifier(Token & Identifier) { if(IdentifierInfo * II = Identifier.getIdentifierInfo()) { @@ -1814,7 +1814,7 @@ public: /// If not, emit a diagnostic and consume up until the eod. /// If \p EnableMacros is true, then we consider macros that expand to zero /// tokens as being ok. - void CheckEndOfDirective(const char *Directive, bool EnableMacros = false); + void CheckEndOfDirective(const char *DirType, bool EnableMacros = false); /// Read and discard all tokens remaining on the current line until /// the tok::eod token is found. @@ -1843,7 +1843,7 @@ public: /// /// \returns true if the input filename was in <>'s or false if it was /// in ""'s. - bool GetIncludeFilenameSpelling(SourceLocation Loc,StringRef &Filename); + bool GetIncludeFilenameSpelling(SourceLocation Loc,StringRef &Buffer); /// Given a "foo" or \ reference, look up the indicated file. /// @@ -1886,7 +1886,7 @@ public: /// Lex an on-off-switch (C99 6.10.6p2) and verify that it is /// followed by EOD. Return true if the token is not a valid on-off-switch. - bool LexOnOffSwitch(tok::OnOffSwitch &OOS); + bool LexOnOffSwitch(tok::OnOffSwitch &Result); bool CheckMacroName(Token &MacroNameTok, MacroUse isDefineUndef, bool *ShadowFlag = nullptr); @@ -2006,7 +2006,7 @@ private: /// If an identifier token is read that is to be expanded as a macro, handle /// it and return the next token as 'Tok'. If we lexed a token, return true; /// otherwise the caller should lex again. - bool HandleMacroExpandedIdentifier(Token &Tok, const MacroDefinition &MD); + bool HandleMacroExpandedIdentifier(Token &Identifier, const MacroDefinition &MD); /// Cache macro expanded tokens for TokenLexers. // @@ -2026,7 +2026,7 @@ private: /// After reading "MACRO(", this method is invoked to read all of the formal /// arguments specified for the macro invocation. Returns null on error. MacroArgs *ReadMacroCallArgumentList(Token &MacroName, MacroInfo *MI, - SourceLocation &ExpansionEnd); + SourceLocation &MacroEnd); /// If an identifier token is read that is to be expanded /// as a builtin macro, handle it and return the next token as 'Tok'. @@ -2177,17 +2177,17 @@ private: void replayPreambleConditionalStack(); // Macro handling. - void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterTopLevelIfndef); + void HandleDefineDirective(Token &Tok, bool ImmediatelyAfterHeaderGuard); void HandleUndefDirective(); // Conditional Inclusion. - void HandleIfdefDirective(Token &Tok, const Token &HashToken, + void HandleIfdefDirective(Token &Result, const Token &HashToken, bool isIfndef, bool ReadAnyTokensBeforeDirective); - void HandleIfDirective(Token &Tok, const Token &HashToken, + void HandleIfDirective(Token &IfToken, const Token &HashToken, bool ReadAnyTokensBeforeDirective); - void HandleEndifDirective(Token &Tok); - void HandleElseDirective(Token &Tok, const Token &HashToken); - void HandleElifDirective(Token &Tok, const Token &HashToken); + void HandleEndifDirective(Token &EndifToken); + void HandleElseDirective(Token &Result, const Token &HashToken); + void HandleElifDirective(Token &ElifToken, const Token &HashToken); // Pragmas. void HandlePragmaDirective(SourceLocation IntroducerLoc, @@ -2207,7 +2207,7 @@ public: // Return true and store the first token only if any CommentHandler // has inserted some tokens and getCommentRetentionState() is false. - bool HandleComment(Token &Token, SourceRange Comment); + bool HandleComment(Token &result, SourceRange Comment); /// A macro is used, update information about macros that need unused /// warnings. diff --git a/include/clang/Lex/PreprocessorLexer.h b/include/clang/Lex/PreprocessorLexer.h index b619f192f5..de918a2153 100644 --- a/include/clang/Lex/PreprocessorLexer.h +++ b/include/clang/Lex/PreprocessorLexer.h @@ -135,7 +135,7 @@ public: /// /// If the sequence parsed is not lexically legal, emit a diagnostic and /// return a result EOD token. - void LexIncludeFilename(Token &Result); + void LexIncludeFilename(Token &FilenameTok); /// Inform the lexer whether or not we are currently lexing a /// preprocessor directive. diff --git a/include/clang/Lex/TokenLexer.h b/include/clang/Lex/TokenLexer.h index 98935ad9c4..992ef3880f 100644 --- a/include/clang/Lex/TokenLexer.h +++ b/include/clang/Lex/TokenLexer.h @@ -31,18 +31,17 @@ class VAOptExpansionContext; class TokenLexer { friend class Preprocessor; - /// Macro - The macro we are expanding from. This is null if expanding a - /// token stream. + /// The macro we are expanding from. This is null if expanding a token stream. MacroInfo *Macro = nullptr; - /// ActualArgs - The actual arguments specified for a function-like macro, or - /// null. The TokenLexer owns the pointed-to object. + /// The actual arguments specified for a function-like macro, or null. The + /// TokenLexer owns the pointed-to object. MacroArgs *ActualArgs = nullptr; - /// PP - The current preprocessor object we are expanding for. + /// The current preprocessor object we are expanding for. Preprocessor &PP; - /// Tokens - This is the pointer to an array of tokens that the macro is + /// This is the pointer to an array of tokens that the macro is /// defined to, with arguments expanded for function-like macros. If this is /// a token stream, these are the tokens we are returning. This points into /// the macro definition we are lexing from, a cache buffer that is owned by @@ -52,14 +51,13 @@ class TokenLexer { /// may update the pointer as needed. const Token *Tokens; - /// NumTokens - This is the length of the Tokens array. + /// This is the length of the Tokens array. unsigned NumTokens; /// This is the index of the next token that Lex will return. unsigned CurTokenIdx; - /// ExpandLocStart/End - The source location range where this macro was - /// expanded. + /// The source location range where this macro was expanded. SourceLocation ExpandLocStart, ExpandLocEnd; /// Source location pointing at the source location entry chunk that @@ -81,7 +79,7 @@ class TokenLexer { bool AtStartOfLine : 1; bool HasLeadingSpace : 1; - // NextTokGetsSpace - When this is true, the next token appended to the + // When this is true, the next token appended to the // output list during function argument expansion will get a leading space, // regardless of whether it had one to begin with or not. This is used for // placemarker support. If still true after function argument expansion, the @@ -89,13 +87,13 @@ class TokenLexer { // expansion. bool NextTokGetsSpace : 1; - /// OwnsTokens - This is true if this TokenLexer allocated the Tokens + /// This is true if this TokenLexer allocated the Tokens /// array, and thus needs to free it when destroyed. For simple object-like /// macros (for example) we just point into the token buffer of the macro /// definition, we don't make a copy of it. bool OwnsTokens : 1; - /// DisableMacroExpansion - This is true when tokens lexed from the TokenLexer + /// This is true when tokens lexed from the TokenLexer /// should not be subject to further macro expansion. bool DisableMacroExpansion : 1; @@ -123,14 +121,14 @@ public: TokenLexer &operator=(const TokenLexer &) = delete; ~TokenLexer() { destroy(); } - /// Init - Initialize this TokenLexer to expand from the specified macro + /// Initialize this TokenLexer to expand from the specified macro /// with the specified argument information. Note that this ctor takes /// ownership of the ActualArgs pointer. ILEnd specifies the location of the /// ')' for a function-like macro or the identifier for an object-like macro. - void Init(Token &Tok, SourceLocation ILEnd, MacroInfo *MI, - MacroArgs *ActualArgs); + void Init(Token &Tok, SourceLocation ELEnd, MacroInfo *MI, + MacroArgs *Actuals); - /// Init - Initialize this TokenLexer with the specified token stream. + /// Initialize this TokenLexer with the specified token stream. /// This does not take ownership of the specified token vector. /// /// DisableExpansion is true when macro expansion of tokens lexed from this @@ -138,12 +136,12 @@ public: void Init(const Token *TokArray, unsigned NumToks, bool DisableMacroExpansion, bool OwnsTokens); - /// isNextTokenLParen - If the next token lexed will pop this macro off the + /// If the next token lexed will pop this macro off the /// expansion stack, return 2. If the next unexpanded token is a '(', return /// 1, otherwise return 0. unsigned isNextTokenLParen() const; - /// Lex - Lex and return a token from this macro stream. + /// Lex and return a token from this macro stream. bool Lex(Token &Tok); /// isParsingPreprocessorDirective - Return true if we are in the middle of a @@ -153,8 +151,8 @@ public: private: void destroy(); - /// isAtEnd - Return true if the next lex call will pop this macro off the - /// include stack. + /// Return true if the next lex call will pop this macro off the include + /// stack. bool isAtEnd() const { return CurTokenIdx == NumTokens; } @@ -201,7 +199,7 @@ private: /// \param[in] VCtx - contains relevant contextual information about the /// state of the tokens around and including the __VA_OPT__ token, necessary /// for stringification. - void stringifyVAOPTContents(SmallVectorImpl &ReplacementToks, + void stringifyVAOPTContents(SmallVectorImpl &ResultToks, const VAOptExpansionContext &VCtx, SourceLocation VAOPTClosingParenLoc); @@ -209,7 +207,7 @@ private: /// return preexpanded tokens from Tokens. void ExpandFunctionArguments(); - /// HandleMicrosoftCommentPaste - In microsoft compatibility mode, /##/ pastes + /// In microsoft compatibility mode, /##/ pastes /// together to form a comment that comments out everything in the current /// macro, other active macros, and anything left on the current physical /// source line of the expanded buffer. Handle this by returning the -- 2.40.0