diff options
Diffstat (limited to 'include/clang/Lex')
| -rw-r--r-- | include/clang/Lex/HeaderSearchOptions.h | 4 | ||||
| -rw-r--r-- | include/clang/Lex/Lexer.h | 2 | ||||
| -rw-r--r-- | include/clang/Lex/MacroInfo.h | 96 | ||||
| -rw-r--r-- | include/clang/Lex/ModuleMap.h | 7 | ||||
| -rw-r--r-- | include/clang/Lex/PPCallbacks.h | 17 | ||||
| -rw-r--r-- | include/clang/Lex/PTHManager.h | 2 | ||||
| -rw-r--r-- | include/clang/Lex/Preprocessor.h | 6 | ||||
| -rw-r--r-- | include/clang/Lex/PreprocessorOptions.h | 12 | 
8 files changed, 62 insertions, 84 deletions
| diff --git a/include/clang/Lex/HeaderSearchOptions.h b/include/clang/Lex/HeaderSearchOptions.h index 775943de8169..316134c405b3 100644 --- a/include/clang/Lex/HeaderSearchOptions.h +++ b/include/clang/Lex/HeaderSearchOptions.h @@ -180,14 +180,14 @@ public:    /// AddPath - Add the \p Path path to the specified \p Group list.    void AddPath(StringRef Path, frontend::IncludeDirGroup Group,                 bool IsFramework, bool IgnoreSysRoot) { -    UserEntries.push_back(Entry(Path, Group, IsFramework, IgnoreSysRoot)); +    UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);    }    /// AddSystemHeaderPrefix - Override whether \#include directives naming a    /// path starting with \p Prefix should be considered as naming a system    /// header.    void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) { -    SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader)); +    SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);    }    void AddVFSOverlayFile(StringRef Name) { diff --git a/include/clang/Lex/Lexer.h b/include/clang/Lex/Lexer.h index 07564b9de784..12565d0b14b6 100644 --- a/include/clang/Lex/Lexer.h +++ b/include/clang/Lex/Lexer.h @@ -228,7 +228,7 @@ public:    /// Stringify - Convert the specified string into a C string by escaping '\'    /// and " characters.  This does not add surrounding ""'s to the string.    /// If Charify is true, this escapes the ' character instead of ". -  static std::string Stringify(const std::string &Str, bool Charify = false); +  static std::string Stringify(StringRef Str, bool Charify = false);    /// Stringify - Convert the specified string into a C string by escaping '\'    /// and " characters.  This does not add surrounding ""'s to the string. diff --git a/include/clang/Lex/MacroInfo.h b/include/clang/Lex/MacroInfo.h index 81d075cb000c..8b82a5bc9310 100644 --- a/include/clang/Lex/MacroInfo.h +++ b/include/clang/Lex/MacroInfo.h @@ -44,8 +44,8 @@ class MacroInfo {    ///    /// ArgumentList points to the first of NumArguments pointers.    /// -  /// This can be empty, for, e.g. "#define X()".  In a C99-style variadic macro, this -  /// includes the \c __VA_ARGS__ identifier on the list. +  /// This can be empty, for, e.g. "#define X()".  In a C99-style variadic +  /// macro, this includes the \c __VA_ARGS__ identifier on the list.    IdentifierInfo **ArgumentList;    /// \see ArgumentList @@ -70,15 +70,15 @@ class MacroInfo {    /// \brief True if this macro is of the form "#define X(a...)".    /// -  /// The "a" identifier in the replacement list will be replaced with all arguments -  /// of the macro starting with the specified one. +  /// The "a" identifier in the replacement list will be replaced with all +  /// arguments of the macro starting with the specified one.    bool IsGNUVarargs : 1;    /// \brief True if this macro requires processing before expansion.    ///    /// This is the case for builtin macros such as __LINE__, so long as they have -  /// not been redefined, but not for regular predefined macros from the "<built-in>" -  /// memory buffer (see Preprocessing::getPredefinesFileID). +  /// not been redefined, but not for regular predefined macros from the +  /// "<built-in>" memory buffer (see Preprocessing::getPredefinesFileID).    bool IsBuiltinMacro : 1;    /// \brief Whether this macro contains the sequence ", ## __VA_ARGS__" @@ -143,14 +143,10 @@ public:                       bool Syntactically) const;    /// \brief Set or clear the isBuiltinMacro flag. -  void setIsBuiltinMacro(bool Val = true) { -    IsBuiltinMacro = Val; -  } +  void setIsBuiltinMacro(bool Val = true) { IsBuiltinMacro = Val; }    /// \brief Set the value of the IsUsed flag. -  void setIsUsed(bool Val) { -    IsUsed = Val; -  } +  void setIsUsed(bool Val) { IsUsed = Val; }    /// \brief Set the value of the IsAllowRedefinitionsWithoutWarning flag.    void setIsAllowRedefinitionsWithoutWarning(bool Val) { @@ -158,37 +154,40 @@ public:    }    /// \brief Set the value of the IsWarnIfUnused flag. -  void setIsWarnIfUnused(bool val) { -    IsWarnIfUnused = val; -  } +  void setIsWarnIfUnused(bool val) { IsWarnIfUnused = val; }    /// \brief Set the specified list of identifiers as the argument list for    /// this macro. -  void setArgumentList(IdentifierInfo* const *List, unsigned NumArgs, +  void setArgumentList(IdentifierInfo *const *List, unsigned NumArgs,                         llvm::BumpPtrAllocator &PPAllocator) {      assert(ArgumentList == nullptr && NumArguments == 0 &&             "Argument list already set!"); -    if (NumArgs == 0) return; +    if (NumArgs == 0) +      return;      NumArguments = NumArgs; -    ArgumentList = PPAllocator.Allocate<IdentifierInfo*>(NumArgs); +    ArgumentList = PPAllocator.Allocate<IdentifierInfo *>(NumArgs);      for (unsigned i = 0; i != NumArgs; ++i)        ArgumentList[i] = List[i];    }    /// Arguments - The list of arguments for a function-like macro.  This can be    /// empty, for, e.g. "#define X()". -  typedef IdentifierInfo* const *arg_iterator; +  typedef IdentifierInfo *const *arg_iterator;    bool arg_empty() const { return NumArguments == 0; }    arg_iterator arg_begin() const { return ArgumentList; } -  arg_iterator arg_end() const { return ArgumentList+NumArguments; } +  arg_iterator arg_end() const { return ArgumentList + NumArguments; }    unsigned getNumArgs() const { return NumArguments; } +  ArrayRef<const IdentifierInfo *> args() const { +    return ArrayRef<const IdentifierInfo *>(ArgumentList, NumArguments); +  }    /// \brief Return the argument number of the specified identifier,    /// or -1 if the identifier is not a formal argument identifier. -  int getArgumentNum(IdentifierInfo *Arg) const { +  int getArgumentNum(const IdentifierInfo *Arg) const {      for (arg_iterator I = arg_begin(), E = arg_end(); I != E; ++I) -      if (*I == Arg) return I-arg_begin(); +      if (*I == Arg) +        return I - arg_begin();      return -1;    } @@ -226,15 +225,11 @@ public:    }    /// \brief Return true if we should emit a warning if the macro is unused. -  bool isWarnIfUnused() const { -    return IsWarnIfUnused; -  } +  bool isWarnIfUnused() const { return IsWarnIfUnused; }    /// \brief Return the number of tokens that this macro expands to.    /// -  unsigned getNumTokens() const { -    return ReplacementTokens.size(); -  } +  unsigned getNumTokens() const { return ReplacementTokens.size(); }    const Token &getReplacementToken(unsigned Tok) const {      assert(Tok < ReplacementTokens.size() && "Invalid token #"); @@ -249,8 +244,9 @@ public:    /// \brief Add the specified token to the replacement text for the macro.    void AddTokenToBody(const Token &Tok) { -    assert(!IsDefinitionLengthCached && -          "Changing replacement tokens after definition length got calculated"); +    assert( +        !IsDefinitionLengthCached && +        "Changing replacement tokens after definition length got calculated");      ReplacementTokens.push_back(Tok);    } @@ -282,7 +278,7 @@ public:    /// macro info.    unsigned getOwningModuleID() const {      if (isFromASTFile()) -      return *(const unsigned*)(this+1); +      return *(const unsigned *)(this + 1);      return 0;    } @@ -294,7 +290,7 @@ private:    void setOwningModuleID(unsigned ID) {      assert(isFromASTFile()); -    *(unsigned*)(this+1) = ID; +    *(unsigned *)(this + 1) = ID;    }    friend class Preprocessor; @@ -311,11 +307,7 @@ class DefMacroDirective;  /// create additional DefMacroDirectives for the same MacroInfo.  class MacroDirective {  public: -  enum Kind { -    MD_Define, -    MD_Undefine, -    MD_Visibility -  }; +  enum Kind { MD_Define, MD_Undefine, MD_Visibility };  protected:    /// \brief Previous macro directive for the same identifier, or NULL. @@ -345,9 +337,7 @@ public:    SourceLocation getLocation() const { return Loc; }    /// \brief Set previous definition of the macro with the same name. -  void setPrevious(MacroDirective *Prev) { -    Previous = Prev; -  } +  void setPrevious(MacroDirective *Prev) { Previous = Prev; }    /// \brief Get previous definition of the macro with the same name.    const MacroDirective *getPrevious() const { return Previous; } @@ -366,19 +356,19 @@ public:      bool IsPublic;    public: -    DefInfo() : DefDirective(nullptr), IsPublic(true) { } +    DefInfo() : DefDirective(nullptr), IsPublic(true) {}      DefInfo(DefMacroDirective *DefDirective, SourceLocation UndefLoc,              bool isPublic) -      : DefDirective(DefDirective), UndefLoc(UndefLoc), IsPublic(isPublic) { } +        : DefDirective(DefDirective), UndefLoc(UndefLoc), IsPublic(isPublic) {}      const DefMacroDirective *getDirective() const { return DefDirective; } -          DefMacroDirective *getDirective()       { return DefDirective; } +    DefMacroDirective *getDirective() { return DefDirective; }      inline SourceLocation getLocation() const;      inline MacroInfo *getMacroInfo();      const MacroInfo *getMacroInfo() const { -      return const_cast<DefInfo*>(this)->getMacroInfo(); +      return const_cast<DefInfo *>(this)->getMacroInfo();      }      SourceLocation getUndefLocation() const { return UndefLoc; } @@ -393,7 +383,7 @@ public:      inline DefInfo getPreviousDefinition();      const DefInfo getPreviousDefinition() const { -      return const_cast<DefInfo*>(this)->getPreviousDefinition(); +      return const_cast<DefInfo *>(this)->getPreviousDefinition();      }    }; @@ -402,7 +392,7 @@ public:    /// (if there is one) and if it is public or private.    DefInfo getDefinition();    const DefInfo getDefinition() const { -    return const_cast<MacroDirective*>(this)->getDefinition(); +    return const_cast<MacroDirective *>(this)->getDefinition();    }    bool isDefined() const { @@ -414,9 +404,7 @@ public:    const MacroInfo *getMacroInfo() const {      return getDefinition().getMacroInfo();    } -  MacroInfo *getMacroInfo() { -    return getDefinition().getMacroInfo(); -  } +  MacroInfo *getMacroInfo() { return getDefinition().getMacroInfo(); }    /// \brief Find macro definition active in the specified source location. If    /// this macro was not defined there, return NULL. @@ -450,7 +438,7 @@ public:  };  /// \brief A directive for an undefined macro. -class UndefMacroDirective : public MacroDirective  { +class UndefMacroDirective : public MacroDirective {  public:    explicit UndefMacroDirective(SourceLocation UndefLoc)        : MacroDirective(MD_Undefine, UndefLoc) { @@ -464,7 +452,7 @@ public:  };  /// \brief A directive for setting the module visibility of a macro. -class VisibilityMacroDirective : public MacroDirective  { +class VisibilityMacroDirective : public MacroDirective {  public:    explicit VisibilityMacroDirective(SourceLocation Loc, bool Public)        : MacroDirective(MD_Visibility, Loc) { @@ -518,14 +506,14 @@ class ModuleMacro : public llvm::FoldingSetNode {    unsigned NumOverriddenBy;    /// The number of modules whose macros are directly overridden by this one.    unsigned NumOverrides; -  //ModuleMacro *OverriddenMacros[NumOverrides]; +  // ModuleMacro *OverriddenMacros[NumOverrides];    friend class Preprocessor;    ModuleMacro(Module *OwningModule, IdentifierInfo *II, MacroInfo *Macro,                ArrayRef<ModuleMacro *> Overrides) -      : II(II), Macro(Macro), OwningModule(OwningModule), -        NumOverriddenBy(0), NumOverrides(Overrides.size()) { +      : II(II), Macro(Macro), OwningModule(OwningModule), NumOverriddenBy(0), +        NumOverrides(Overrides.size()) {      std::copy(Overrides.begin(), Overrides.end(),                reinterpret_cast<ModuleMacro **>(this + 1));    } diff --git a/include/clang/Lex/ModuleMap.h b/include/clang/Lex/ModuleMap.h index 83a410dfc9e8..e41efc5d419d 100644 --- a/include/clang/Lex/ModuleMap.h +++ b/include/clang/Lex/ModuleMap.h @@ -272,16 +272,11 @@ public:    /// used from.  Used to disambiguate if a header is present in multiple    /// modules.    /// -  /// \param IncludeTextualHeaders If \c true, also find textual headers. By -  /// default, these are treated like excluded headers and result in no known -  /// header being found. -  ///    /// \returns The module KnownHeader, which provides the module that owns the    /// given header file.  The KnownHeader is default constructed to indicate    /// that no module owns this header file.    KnownHeader findModuleForHeader(const FileEntry *File, -                                  Module *RequestingModule = nullptr, -                                  bool IncludeTextualHeaders = false); +                                  Module *RequestingModule = nullptr);    /// \brief Reports errors if a module must not include a specific file.    /// diff --git a/include/clang/Lex/PPCallbacks.h b/include/clang/Lex/PPCallbacks.h index 1ddb5d61eff5..3803533b49b1 100644 --- a/include/clang/Lex/PPCallbacks.h +++ b/include/clang/Lex/PPCallbacks.h @@ -155,7 +155,7 @@ public:    /// \param Loc The location of the directive.    /// \param str The text of the directive.    /// -  virtual void Ident(SourceLocation Loc, const std::string &str) { +  virtual void Ident(SourceLocation Loc, StringRef str) {    }    /// \brief Callback invoked when start reading any pragma directive. @@ -165,14 +165,13 @@ public:    /// \brief Callback invoked when a \#pragma comment directive is read.    virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, -                             const std::string &Str) { +                             StringRef Str) {    }    /// \brief Callback invoked when a \#pragma detect_mismatch directive is    /// read. -  virtual void PragmaDetectMismatch(SourceLocation Loc, -                                    const std::string &Name, -                                    const std::string &Value) { +  virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, +                                    StringRef Value) {    }    /// \brief Callback invoked when a \#pragma clang __debug directive is read. @@ -375,19 +374,19 @@ public:      Second->EndOfMainFile();    } -  void Ident(SourceLocation Loc, const std::string &str) override { +  void Ident(SourceLocation Loc, StringRef str) override {      First->Ident(Loc, str);      Second->Ident(Loc, str);    }    void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, -                     const std::string &Str) override { +                     StringRef Str) override {      First->PragmaComment(Loc, Kind, Str);      Second->PragmaComment(Loc, Kind, Str);    } -  void PragmaDetectMismatch(SourceLocation Loc, const std::string &Name, -                            const std::string &Value) override { +  void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, +                            StringRef Value) override {      First->PragmaDetectMismatch(Loc, Name, Value);      Second->PragmaDetectMismatch(Loc, Name, Value);    } diff --git a/include/clang/Lex/PTHManager.h b/include/clang/Lex/PTHManager.h index a4198f890e13..26178eddf36d 100644 --- a/include/clang/Lex/PTHManager.h +++ b/include/clang/Lex/PTHManager.h @@ -129,7 +129,7 @@ public:    /// Create - This method creates PTHManager objects.  The 'file' argument    ///  is the name of the PTH file.  This method returns NULL upon failure. -  static PTHManager *Create(const std::string& file, DiagnosticsEngine &Diags); +  static PTHManager *Create(StringRef file, DiagnosticsEngine &Diags);    void setPreprocessor(Preprocessor *pp) { PP = pp; } diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index ea15dbdf2144..f6e61c0e7ad6 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -890,7 +890,7 @@ public:    ///    /// These predefines are automatically injected when parsing the main file.    void setPredefines(const char *P) { Predefines = P; } -  void setPredefines(const std::string &P) { Predefines = P; } +  void setPredefines(StringRef P) { Predefines = P; }    /// Return information about the specified preprocessor    /// identifier token. @@ -1617,9 +1617,9 @@ private:    void PushIncludeMacroStack() {      assert(CurLexerKind != CLK_CachingLexer && "cannot push a caching lexer"); -    IncludeMacroStack.push_back(IncludeStackInfo( +    IncludeMacroStack.emplace_back(          CurLexerKind, CurSubmodule, std::move(CurLexer), std::move(CurPTHLexer), -        CurPPLexer, std::move(CurTokenLexer), CurDirLookup)); +        CurPPLexer, std::move(CurTokenLexer), CurDirLookup);      CurPPLexer = nullptr;    } diff --git a/include/clang/Lex/PreprocessorOptions.h b/include/clang/Lex/PreprocessorOptions.h index 135c87fa837b..963d95d7f1d1 100644 --- a/include/clang/Lex/PreprocessorOptions.h +++ b/include/clang/Lex/PreprocessorOptions.h @@ -149,18 +149,14 @@ public:                            RetainRemappedFileBuffers(false),                            ObjCXXARCStandardLibrary(ARCXX_nolib) { } -  void addMacroDef(StringRef Name) { -    Macros.push_back(std::make_pair(Name, false)); -  } -  void addMacroUndef(StringRef Name) { -    Macros.push_back(std::make_pair(Name, true)); -  } +  void addMacroDef(StringRef Name) { Macros.emplace_back(Name, false); } +  void addMacroUndef(StringRef Name) { Macros.emplace_back(Name, true); }    void addRemappedFile(StringRef From, StringRef To) { -    RemappedFiles.push_back(std::make_pair(From, To)); +    RemappedFiles.emplace_back(From, To);    }    void addRemappedFile(StringRef From, llvm::MemoryBuffer *To) { -    RemappedFileBuffers.push_back(std::make_pair(From, To)); +    RemappedFileBuffers.emplace_back(From, To);    }    void clearRemappedFiles() { | 
