diff options
Diffstat (limited to 'include/clang')
25 files changed, 175 insertions, 118 deletions
| diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 451f9da1b60a..e06b58b37be2 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -236,7 +236,11 @@ public:    bool isHidden() const { return Hidden; }    /// \brief Set whether this declaration is hidden from name lookup. -  void setHidden(bool Hide) { Hidden = Hide; } +  void setHidden(bool Hide) { +    assert((!Hide || isFromASTFile() || hasLocalOwningModuleStorage()) && +           "declaration with no owning module can't be hidden"); +    Hidden = Hide; +  }    /// \brief Determine whether this declaration is a C++ class member.    bool isCXXClassMember() const { diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 5c382b0d5780..f176e5479e1e 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -637,6 +637,8 @@ public:  private:    Module *getOwningModuleSlow() const; +protected: +  bool hasLocalOwningModuleStorage() const;  public:    /// \brief Get the imported owning module, if this decl is from an imported @@ -656,7 +658,7 @@ public:      return reinterpret_cast<Module *const *>(this)[-1];    }    void setLocalOwningModule(Module *M) { -    assert(!isFromASTFile() && Hidden && +    assert(!isFromASTFile() && Hidden && hasLocalOwningModuleStorage() &&             "should not have a cached owning module");      reinterpret_cast<Module **>(this)[-1] = M;    } diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h index f7cb4624cb55..537ad4640c24 100644 --- a/include/clang/AST/DeclCXX.h +++ b/include/clang/AST/DeclCXX.h @@ -1392,6 +1392,10 @@ public:    /// \brief Returns the destructor decl for this class.    CXXDestructorDecl *getDestructor() const; +  /// \brief Returns true if the class destructor, or any implicitly invoked +  /// destructors are marked noreturn. +  bool isAnyDestructorNoReturn() const; +    /// \brief If the class is a local class [class.local], returns    /// the enclosing function declaration.    const FunctionDecl *isLocalClass() const { diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h index 7f9764619c2b..94c77f7f73ba 100644 --- a/include/clang/ASTMatchers/ASTMatchers.h +++ b/include/clang/ASTMatchers/ASTMatchers.h @@ -1476,6 +1476,23 @@ const internal::VariadicDynCastAllOfMatcher<    Stmt,    ConditionalOperator> conditionalOperator; +/// \brief Matches a C++ static_assert declaration. +/// +/// Example: +///   staticAssertExpr() +/// matches +///   static_assert(sizeof(S) == sizeof(int)) +/// in +/// \code +///   struct S { +///     int x; +///   }; +///   static_assert(sizeof(S) == sizeof(int)); +/// \endcode +const internal::VariadicDynCastAllOfMatcher< +  Decl, +  StaticAssertDecl> staticAssertDecl; +  /// \brief Matches a reinterpret_cast expression.  ///  /// Either the source expression or the destination type can be matched diff --git a/include/clang/Analysis/CFG.h b/include/clang/Analysis/CFG.h index e7f638362639..5430c3bc6f21 100644 --- a/include/clang/Analysis/CFG.h +++ b/include/clang/Analysis/CFG.h @@ -738,6 +738,7 @@ public:      bool AddTemporaryDtors;      bool AddStaticInitBranches;      bool AddCXXNewAllocator; +    bool AddCXXDefaultInitExprInCtors;      bool alwaysAdd(const Stmt *stmt) const {        return alwaysAddMask[stmt->getStmtClass()]; @@ -758,7 +759,7 @@ public:          PruneTriviallyFalseEdges(true), AddEHEdges(false),          AddInitializers(false), AddImplicitDtors(false),          AddTemporaryDtors(false), AddStaticInitBranches(false), -        AddCXXNewAllocator(false) {} +        AddCXXNewAllocator(false), AddCXXDefaultInitExprInCtors(false) {}    };    /// \brief Provides a custom implementation of the iterator class to have the diff --git a/include/clang/Basic/DiagnosticCommonKinds.td b/include/clang/Basic/DiagnosticCommonKinds.td index afdd9269d097..deb23f3149cb 100644 --- a/include/clang/Basic/DiagnosticCommonKinds.td +++ b/include/clang/Basic/DiagnosticCommonKinds.td @@ -115,7 +115,23 @@ def err_integer_literal_too_large : Error<  def ext_integer_literal_too_large_for_signed : ExtWarn<    "integer literal is too large to be represented in a signed integer type, "    "interpreting as unsigned">, -  InGroup<DiagGroup<"implicitly-unsigned-literal">>; +  InGroup<ImplicitlyUnsignedLiteral>; +def warn_old_implicitly_unsigned_long : Warning< +  "integer literal is too large to be represented in type 'long', " +  "interpreting as 'unsigned long' per C89; this literal will " +  "%select{have type 'long long'|be ill-formed}0 in C99 onwards">, +  InGroup<C99Compat>; +def warn_old_implicitly_unsigned_long_cxx : Warning< +  "integer literal is too large to be represented in type 'long', " +  "interpreting as 'unsigned long' per C++98; this literal will " +  "%select{have type 'long long'|be ill-formed}0 in C++11 onwards">, +  InGroup<CXX11Compat>; +def ext_old_implicitly_unsigned_long_cxx : ExtWarn< +  "integer literal is too large to be represented in type 'long' and is " +  "subject to undefined behavior under C++98, interpreting as 'unsigned long'; " +  "this literal will %select{have type 'long long'|be ill-formed}0 " +  "in C++11 onwards">, +  InGroup<CXX11Compat>;  // SEH  def err_seh_expected_handler : Error< diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index 61436eabe52a..016c2e198e3a 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -239,6 +239,7 @@ def MultiChar : DiagGroup<"multichar">;  def : DiagGroup<"nested-externs">;  def CXX11LongLong : DiagGroup<"c++11-long-long">;  def LongLong : DiagGroup<"long-long", [CXX11LongLong]>; +def ImplicitlyUnsignedLiteral : DiagGroup<"implicitly-unsigned-literal">;  def MethodSignatures : DiagGroup<"method-signatures">;  def MismatchedParameterTypes : DiagGroup<"mismatched-parameter-types">;  def MismatchedReturnTypes : DiagGroup<"mismatched-return-types">; @@ -264,6 +265,8 @@ def : DiagGroup<"overflow">;  def ForwardClassReceiver : DiagGroup<"receiver-forward-class">;  def MethodAccess : DiagGroup<"objc-method-access">;  def ObjCReceiver : DiagGroup<"receiver-expr">; +// FIXME: Remove this when Xcode removes the warning setting. +def : DiagGroup<"receiver-is-weak">;  def OperatorNewReturnsNull : DiagGroup<"new-returns-null">;  def OverlengthStrings : DiagGroup<"overlength-strings">;  def OverloadedVirtual : DiagGroup<"overloaded-virtual">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 9ccd5adf21ab..be1911e7d506 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -908,10 +908,6 @@ def warn_dealloc_in_category : Warning<  InGroup<DeallocInCategory>;  def err_gc_weak_property_strong_type : Error<    "weak attribute declared on a __strong type property in GC mode">; -def warn_receiver_is_weak : Warning < -  "weak %select{receiver|property|implicit property}0 may be " -  "unpredictably set to nil">, -  InGroup<DiagGroup<"receiver-is-weak">>, DefaultIgnore;  def warn_arc_repeated_use_of_weak : Warning <    "weak %select{variable|property|implicit property|instance variable}0 %1 is "    "accessed multiple times in this %select{function|method|block|lambda}2 " @@ -2262,8 +2258,7 @@ def err_attribute_dll_member_of_dll_class : Error<    "attribute %q0 cannot be applied to member of %q1 class">;  def warn_attribute_dll_instantiated_base_class : Warning<    "propagating dll attribute to %select{already instantiated|explicitly specialized}0 " -  "base class template " -  "%select{without dll attribute|with different dll attribute}1 is not supported">, +  "base class template without dll attribute is not supported">,    InGroup<DiagGroup<"unsupported-dll-base-class-template">>, DefaultIgnore;  def err_attribute_weakref_not_static : Error<    "weakref declaration must have internal linkage">; @@ -5390,6 +5385,10 @@ def err_bad_const_cast_dest : Error<    "which is not a reference, pointer-to-object, or pointer-to-data-member">;  def ext_cast_fn_obj : Extension<    "cast between pointer-to-function and pointer-to-object is an extension">; +def ext_ms_cast_fn_obj : ExtWarn< +  "static_cast between pointer-to-function and pointer-to-object is a " +  "Microsoft extension">, +  InGroup<Microsoft>;  def warn_cxx98_compat_cast_fn_obj : Warning<    "cast between pointer-to-function and pointer-to-object is incompatible with C++98">,    InGroup<CXX98CompatPedantic>, DefaultIgnore; @@ -6334,6 +6333,9 @@ let CategoryName = "Inline Assembly Issue" in {      "remove the cast or build with -fheinous-gnu-extensions">;    def err_invalid_asm_value_for_constraint        : Error <"value '%0' out of range for constraint '%1'">; +  def err_asm_bitfield_in_memory_constraint +      : Error <"reference to a bit-field in asm " +      "%select{input|output}0 with a memory constraint '%1'">;    def warn_asm_label_on_auto_decl : Warning<      "ignored asm label '%0' on automatic variable">; @@ -7404,8 +7406,6 @@ def err_omp_unexpected_clause_value : Error<    "expected %0 in OpenMP clause '%1'">;  def err_omp_expected_var_name : Error<    "expected variable name">; -def err_omp_required_method : Error< -  "%0 variable must have an accessible, unambiguous %select{default constructor|copy constructor|copy assignment operator|'%2'|destructor}1">;  def note_omp_task_predetermined_firstprivate_here : Note<    "predetermined as a firstprivate in a task construct here">;  def err_omp_clause_ref_type_arg : Error< diff --git a/include/clang/Basic/TokenKinds.def b/include/clang/Basic/TokenKinds.def index 28aafca1162a..b6d983b55245 100644 --- a/include/clang/Basic/TokenKinds.def +++ b/include/clang/Basic/TokenKinds.def @@ -10,7 +10,8 @@  // This file defines the TokenKind database.  This includes normal tokens like  // tok::ampamp (corresponding to the && token) as well as keywords for various  // languages.  Users of this file must optionally #define the TOK, KEYWORD, -// CXX11_KEYWORD, ALIAS, or PPKEYWORD macros to make use of this file. +// CXX11_KEYWORD, CONCEPTS_KEYWORD, ALIAS, or PPKEYWORD macros to make use of +// this file.  //  //===----------------------------------------------------------------------===// @@ -26,6 +27,9 @@  #ifndef CXX11_KEYWORD  #define CXX11_KEYWORD(X,Y) KEYWORD(X,KEYCXX11|(Y))  #endif +#ifndef CONCEPTS_KEYWORD +#define CONCEPTS_KEYWORD(X) KEYWORD(X,KEYCONCEPTS) +#endif  #ifndef TYPE_TRAIT  #define TYPE_TRAIT(N,I,K) KEYWORD(I,K)  #endif @@ -226,6 +230,8 @@ PUNCTUATOR(greatergreatergreater, ">>>")  //              implementation namespace  //   KEYNOCXX - This is a keyword in every non-C++ dialect.  //   KEYCXX11 - This is a C++ keyword introduced to C++ in C++11 +//   KEYCONCEPTS - This is a keyword if the C++ extensions for concepts +//                 are enabled.  //   KEYGNU   - This is a keyword if GNU extensions are enabled  //   KEYMS    - This is a keyword if Microsoft extensions are enabled  //   KEYNOMS18 - This is a keyword that must never be enabled under @@ -344,6 +350,10 @@ CXX11_KEYWORD(nullptr               , 0)  CXX11_KEYWORD(static_assert         , 0)  CXX11_KEYWORD(thread_local          , 0) +// C++ concepts TS keywords +CONCEPTS_KEYWORD(concept) +CONCEPTS_KEYWORD(requires) +  // GNU Extensions (in impl-reserved namespace)  KEYWORD(_Decimal32                  , KEYALL)  KEYWORD(_Decimal64                  , KEYALL) @@ -738,6 +748,7 @@ ANNOTATION(module_end)  #undef TYPE_TRAIT_2  #undef TYPE_TRAIT_1  #undef TYPE_TRAIT +#undef CONCEPTS_KEYWORD  #undef CXX11_KEYWORD  #undef KEYWORD  #undef PUNCTUATOR diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake index 5d89b1aaa1ac..78a508697e83 100644 --- a/include/clang/Config/config.h.cmake +++ b/include/clang/Config/config.h.cmake @@ -8,6 +8,9 @@  /* Bug report URL. */  #define BUG_REPORT_URL "${BUG_REPORT_URL}" +/* Default OpenMP runtime used by -fopenmp. */ +#define CLANG_DEFAULT_OPENMP_RUNTIME "${CLANG_DEFAULT_OPENMP_RUNTIME}" +  /* Multilib suffix for libdir. */  #define CLANG_LIBDIR_SUFFIX "${CLANG_LIBDIR_SUFFIX}" diff --git a/include/clang/Config/config.h.in b/include/clang/Config/config.h.in index dba05db2b99d..4395e73c568a 100644 --- a/include/clang/Config/config.h.in +++ b/include/clang/Config/config.h.in @@ -8,6 +8,9 @@  /* Bug report URL. */  #undef BUG_REPORT_URL +/* Default OpenMP runtime used by -fopenmp. */ +#undef CLANG_DEFAULT_OPENMP_RUNTIME +  /* Multilib suffix for libdir. */  #undef CLANG_LIBDIR_SUFFIX diff --git a/include/clang/Driver/CLCompatOptions.td b/include/clang/Driver/CLCompatOptions.td index 959a72e5389e..e217cb755f6e 100644 --- a/include/clang/Driver/CLCompatOptions.td +++ b/include/clang/Driver/CLCompatOptions.td @@ -202,6 +202,7 @@ def _SLASH_Fi : CLCompileJoined<"Fi">,  def _SLASH_Fo : CLCompileJoined<"Fo">,    HelpText<"Set output object file, or directory (ends in / or \\)">,    MetaVarName<"<file or directory>">; +def _SLASH_GL : CLFlag<"GL">, Alias<flto>;  def _SLASH_LD : CLFlag<"LD">, HelpText<"Create DLL">;  def _SLASH_LDd : CLFlag<"LDd">, HelpText<"Create debug DLL">;  def _SLASH_link : CLRemainingArgs<"link">, @@ -286,7 +287,6 @@ def _SLASH_G2 : CLFlag<"G2">;  def _SLASH_Ge : CLFlag<"Ge">;  def _SLASH_Gh : CLFlag<"Gh">;  def _SLASH_GH : CLFlag<"GH">; -def _SLASH_GL : CLFlag<"GL">;  def _SLASH_GL_ : CLFlag<"GL-">;  def _SLASH_Gm : CLFlag<"Gm">;  def _SLASH_Gm_ : CLFlag<"Gm-">; diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index dec917b6e929..7e39a9ae5b22 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -876,6 +876,7 @@ def fno_objc_nonfragile_abi : Flag<["-"], "fno-objc-nonfragile-abi">, Group<f_Gr  def fobjc_sender_dependent_dispatch : Flag<["-"], "fobjc-sender-dependent-dispatch">, Group<f_Group>;  def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group<f_Group>;  def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>; +def fno_openmp : Flag<["-"], "fno-openmp">, Group<f_Group>, Flags<[NoArgumentUnused]>;  def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>;  def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Group<f_Group>;  def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, Group<f_Group>; diff --git a/include/clang/Driver/Types.def b/include/clang/Driver/Types.def index adc12d34debb..4b696ae5e053 100644 --- a/include/clang/Driver/Types.def +++ b/include/clang/Driver/Types.def @@ -55,14 +55,14 @@ TYPE("objective-c++",            ObjCXX,       PP_ObjCXX,       "mm",    "u")  // C family input files to precompile.  TYPE("c-header-cpp-output",      PP_CHeader,   INVALID,         "i",     "p") -TYPE("c-header",                 CHeader,      PP_CHeader,      nullptr, "pu") -TYPE("cl-header",                CLHeader,     PP_CHeader,      nullptr, "pu") +TYPE("c-header",                 CHeader,      PP_CHeader,      "h",     "pu") +TYPE("cl-header",                CLHeader,     PP_CHeader,      "h",     "pu")  TYPE("objective-c-header-cpp-output", PP_ObjCHeader, INVALID,   "mi",    "p") -TYPE("objective-c-header",       ObjCHeader,   PP_ObjCHeader,   nullptr, "pu") +TYPE("objective-c-header",       ObjCHeader,   PP_ObjCHeader,   "h",     "pu")  TYPE("c++-header-cpp-output",    PP_CXXHeader, INVALID,         "ii",    "p") -TYPE("c++-header",               CXXHeader,    PP_CXXHeader,    nullptr, "pu") +TYPE("c++-header",               CXXHeader,    PP_CXXHeader,    "hh",    "pu")  TYPE("objective-c++-header-cpp-output", PP_ObjCXXHeader, INVALID, "mii", "p") -TYPE("objective-c++-header",     ObjCXXHeader, PP_ObjCXXHeader, nullptr, "pu") +TYPE("objective-c++-header",     ObjCXXHeader, PP_ObjCXXHeader, "h",     "pu")  // Other languages.  TYPE("ada",                      Ada,          INVALID,         nullptr, "u") 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() { diff --git a/include/clang/Sema/Lookup.h b/include/clang/Sema/Lookup.h index 5bfee8b0d037..97192b53fa44 100644 --- a/include/clang/Sema/Lookup.h +++ b/include/clang/Sema/Lookup.h @@ -302,10 +302,14 @@ public:      if (!D->isInIdentifierNamespace(IDNS))        return nullptr; -    if (isHiddenDeclarationVisible() || isVisible(getSema(), D)) +    if (isVisible(getSema(), D))        return D; -    return getAcceptableDeclSlow(D); +    if (auto *Visible = getAcceptableDeclSlow(D)) +      return Visible; + +    // Even if hidden declarations are visible, prefer a visible declaration. +    return isHiddenDeclarationVisible() ? D : nullptr;    }  private: diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 39ea3c62a878..60664c5fdc99 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -5110,6 +5110,10 @@ public:                              bool AnyErrors);    void checkClassLevelDLLAttribute(CXXRecordDecl *Class); +  void propagateDLLAttrToBaseClassTemplate( +      CXXRecordDecl *Class, Attr *ClassAttr, +      ClassTemplateSpecializationDecl *BaseTemplateSpec, +      SourceLocation BaseLoc);    void CheckCompletedCXXClass(CXXRecordDecl *Record);    void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,                                           Decl *TagDecl, diff --git a/include/clang/Tooling/Core/Replacement.h b/include/clang/Tooling/Core/Replacement.h index 30a7036c2bb5..f189e1250121 100644 --- a/include/clang/Tooling/Core/Replacement.h +++ b/include/clang/Tooling/Core/Replacement.h @@ -19,6 +19,7 @@  #ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H  #define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H +#include "clang/Basic/LangOptions.h"  #include "clang/Basic/SourceLocation.h"  #include "llvm/ADT/StringRef.h"  #include <set> @@ -77,22 +78,24 @@ public:    /// \param FilePath A source file accessible via a SourceManager.    /// \param Offset The byte offset of the start of the range in the file.    /// \param Length The length of the range in bytes. -  Replacement(StringRef FilePath, unsigned Offset, -              unsigned Length, StringRef ReplacementText); +  Replacement(StringRef FilePath, unsigned Offset, unsigned Length, +              StringRef ReplacementText);    /// \brief Creates a Replacement of the range [Start, Start+Length) with    /// ReplacementText. -  Replacement(const SourceManager &Sources, SourceLocation Start, unsigned Length, -              StringRef ReplacementText); +  Replacement(const SourceManager &Sources, SourceLocation Start, +              unsigned Length, StringRef ReplacementText);    /// \brief Creates a Replacement of the given range with ReplacementText.    Replacement(const SourceManager &Sources, const CharSourceRange &Range, -              StringRef ReplacementText); +              StringRef ReplacementText, +              const LangOptions &LangOpts = LangOptions());    /// \brief Creates a Replacement of the node with ReplacementText.    template <typename Node>    Replacement(const SourceManager &Sources, const Node &NodeToReplace, -              StringRef ReplacementText); +              StringRef ReplacementText, +              const LangOptions &LangOpts = LangOptions());    /// \brief Returns whether this replacement can be applied to a file.    /// @@ -114,11 +117,13 @@ public:    std::string toString() const;   private: -  void setFromSourceLocation(const SourceManager &Sources, SourceLocation Start, -                             unsigned Length, StringRef ReplacementText); -  void setFromSourceRange(const SourceManager &Sources, -                          const CharSourceRange &Range, -                          StringRef ReplacementText); +   void setFromSourceLocation(const SourceManager &Sources, +                              SourceLocation Start, unsigned Length, +                              StringRef ReplacementText); +   void setFromSourceRange(const SourceManager &Sources, +                           const CharSourceRange &Range, +                           StringRef ReplacementText, +                           const LangOptions &LangOpts);    std::string FilePath;    Range ReplacementRange; @@ -217,10 +222,11 @@ std::string applyAllReplacements(StringRef Code, const Replacements &Replaces);  template <typename Node>  Replacement::Replacement(const SourceManager &Sources, -                         const Node &NodeToReplace, StringRef ReplacementText) { +                         const Node &NodeToReplace, StringRef ReplacementText, +                         const LangOptions &LangOpts) {    const CharSourceRange Range =        CharSourceRange::getTokenRange(NodeToReplace->getSourceRange()); -  setFromSourceRange(Sources, Range, ReplacementText); +  setFromSourceRange(Sources, Range, ReplacementText, LangOpts);  }  } // end namespace tooling | 
