diff options
Diffstat (limited to 'contrib/llvm/tools/clang/include/clang/Sema')
23 files changed, 1561 insertions, 825 deletions
diff --git a/contrib/llvm/tools/clang/include/clang/Sema/AttributeList.h b/contrib/llvm/tools/clang/include/clang/Sema/AttributeList.h index 508064d..c21c19f 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/AttributeList.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/AttributeList.h @@ -18,8 +18,9 @@ #include "clang/Basic/SourceLocation.h" #include "clang/Basic/VersionTuple.h" #include "clang/Sema/Ownership.h" -#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/PointerUnion.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Triple.h" #include "llvm/Support/Allocator.h" #include <cassert> @@ -79,7 +80,9 @@ public: /// __declspec(...) AS_Declspec, /// __ptr16, alignas(...), etc. - AS_Keyword + AS_Keyword, + /// #pragma ... + AS_Pragma }; private: @@ -217,7 +220,7 @@ private: ScopeLoc(scopeLoc), EllipsisLoc(ellipsisLoc), NumArgs(numArgs), SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false), IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false), - HasParsedType(false), NextInPosition(0), NextInPool(0) { + HasParsedType(false), NextInPosition(nullptr), NextInPool(nullptr) { if (numArgs) memcpy(getArgsBuffer(), args, numArgs * sizeof(ArgsUnion)); AttrKind = getKind(getName(), getScopeName(), syntaxUsed); } @@ -236,7 +239,7 @@ private: Invalid(false), UsedAsTypeAttr(false), IsAvailability(true), IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false), UnavailableLoc(unavailable), MessageExpr(messageExpr), - NextInPosition(0), NextInPool(0) { + NextInPosition(nullptr), NextInPool(nullptr) { ArgsUnion PVal(Parm); memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion)); new (&getAvailabilitySlot(IntroducedSlot)) AvailabilityChange(introduced); @@ -245,6 +248,26 @@ private: AttrKind = getKind(getName(), getScopeName(), syntaxUsed); } + /// Constructor for objc_bridge_related attributes. + AttributeList(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *Parm1, + IdentifierLoc *Parm2, + IdentifierLoc *Parm3, + Syntax syntaxUsed) + : AttrName(attrName), ScopeName(scopeName), AttrRange(attrRange), + ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(3), SyntaxUsed(syntaxUsed), + Invalid(false), UsedAsTypeAttr(false), IsAvailability(false), + IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false), + NextInPosition(nullptr), NextInPool(nullptr) { + ArgsVector Args; + Args.push_back(Parm1); + Args.push_back(Parm2); + Args.push_back(Parm3); + memcpy(getArgsBuffer(), &Args[0], 3 * sizeof(ArgsUnion)); + AttrKind = getKind(getName(), getScopeName(), syntaxUsed); + } + /// Constructor for type_tag_for_datatype attribute. AttributeList(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, @@ -254,7 +277,7 @@ private: ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(1), SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false), IsAvailability(false), IsTypeTagForDatatype(true), IsProperty(false), HasParsedType(false), - NextInPosition(NULL), NextInPool(NULL) { + NextInPosition(nullptr), NextInPool(nullptr) { ArgsUnion PVal(ArgKind); memcpy(getArgsBuffer(), &PVal, sizeof(ArgsUnion)); TypeTagForDatatypeData &ExtraData = getTypeTagForDatatypeDataSlot(); @@ -272,7 +295,7 @@ private: ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(0), SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false), IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(true), - NextInPosition(0), NextInPool(0) { + NextInPosition(nullptr), NextInPool(nullptr) { new (&getTypeBuffer()) ParsedType(typeArg); AttrKind = getKind(getName(), getScopeName(), syntaxUsed); } @@ -286,7 +309,7 @@ private: ScopeLoc(scopeLoc), EllipsisLoc(), NumArgs(0), SyntaxUsed(syntaxUsed), Invalid(false), UsedAsTypeAttr(false), IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(true), HasParsedType(false), - NextInPosition(0), NextInPool(0) { + NextInPosition(nullptr), NextInPool(nullptr) { new (&getPropertyDataBuffer()) PropertyData(getterId, setterId); AttrKind = getKind(getName(), getScopeName(), syntaxUsed); } @@ -368,44 +391,6 @@ public: return getArg(Arg).get<IdentifierLoc*>(); } - class arg_iterator { - ArgsUnion const *X; - unsigned Idx; - public: - arg_iterator(ArgsUnion const *x, unsigned idx) : X(x), Idx(idx) {} - - arg_iterator& operator++() { - ++Idx; - return *this; - } - - bool operator==(const arg_iterator& I) const { - assert (X == I.X && - "compared arg_iterators are for different argument lists"); - return Idx == I.Idx; - } - - bool operator!=(const arg_iterator& I) const { - return !operator==(I); - } - - ArgsUnion operator*() const { - return X[Idx]; - } - - unsigned getArgNum() const { - return Idx+1; - } - }; - - arg_iterator arg_begin() const { - return arg_iterator(getArgsBuffer(), 0); - } - - arg_iterator arg_end() const { - return arg_iterator(getArgsBuffer(), NumArgs); - } - const AvailabilityChange &getAvailabilityIntroduced() const { assert(getKind() == AT_Availability && "Not an availability attribute"); return getAvailabilitySlot(IntroducedSlot); @@ -464,9 +449,23 @@ public: /// to pretty print itself. unsigned getAttributeSpellingListIndex() const; + bool isTargetSpecificAttr() const; + bool isTypeAttr() const; + bool hasCustomParsing() const; unsigned getMinArgs() const; unsigned getMaxArgs() const; + bool diagnoseAppertainsTo(class Sema &S, const Decl *D) const; + bool diagnoseLangOpts(class Sema &S) const; + bool existsInTarget(const llvm::Triple &T) const; + bool isKnownToGCC() const; + + /// \brief If the parsed attribute has a semantic equivalent, and it would + /// have a semantic Spelling enumeration (due to having semantically-distinct + /// spelling variations), return the value of that semantic spelling. If the + /// parsed attribute does not have a semantic equivalent, or would not have + /// a Spelling enumeration, the value UINT_MAX is returned. + unsigned getSemanticSpelling() const; }; /// A factory, from which one makes pools, from which one creates @@ -549,11 +548,11 @@ class AttributePool { public: /// Create a new pool for a factory. - AttributePool(AttributeFactory &factory) : Factory(factory), Head(0) {} + AttributePool(AttributeFactory &factory) : Factory(factory), Head(nullptr) {} /// Move the given pool's allocations to this pool. AttributePool(AttributePool &pool) : Factory(pool.Factory), Head(pool.Head) { - pool.Head = 0; + pool.Head = nullptr; } AttributeFactory &getFactory() const { return Factory; } @@ -561,7 +560,7 @@ public: void clear() { if (Head) { Factory.reclaimPool(Head); - Head = 0; + Head = nullptr; } } @@ -569,7 +568,7 @@ public: void takeAllFrom(AttributePool &pool) { if (pool.Head) { takePool(pool.Head); - pool.Head = 0; + pool.Head = nullptr; } } @@ -607,8 +606,19 @@ public: syntax)); } - AttributeList *createIntegerAttribute(ASTContext &C, IdentifierInfo *Name, - SourceLocation TokLoc, int Arg); + AttributeList *create(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *Param1, + IdentifierLoc *Param2, + IdentifierLoc *Param3, + AttributeList::Syntax syntax) { + size_t size = sizeof(AttributeList) + 3 * sizeof(ArgsUnion); + void *memory = allocate(size); + return add(new (memory) AttributeList(attrName, attrRange, + scopeName, scopeLoc, + Param1, Param2, Param3, + syntax)); + } AttributeList *createTypeTagForDatatype( IdentifierInfo *attrName, SourceRange attrRange, @@ -647,40 +657,6 @@ public: } }; -/// addAttributeLists - Add two AttributeLists together -/// The right-hand list is appended to the left-hand list, if any -/// A pointer to the joined list is returned. -/// Note: the lists are not left unmodified. -inline AttributeList *addAttributeLists(AttributeList *Left, - AttributeList *Right) { - if (!Left) - return Right; - - AttributeList *next = Left, *prev; - do { - prev = next; - next = next->getNext(); - } while (next); - prev->setNext(Right); - return Left; -} - -/// CXX11AttributeList - A wrapper around a C++11 attribute list. -/// Stores, in addition to the list proper, whether or not an actual list was -/// (as opposed to an empty list, which may be ill-formed in some places) and -/// the source range of the list. -struct CXX11AttributeList { - AttributeList *AttrList; - SourceRange Range; - bool HasAttr; - CXX11AttributeList (AttributeList *attrList, SourceRange range, bool hasAttr) - : AttrList(attrList), Range(range), HasAttr (hasAttr) { - } - CXX11AttributeList () - : AttrList(0), Range(), HasAttr(false) { - } -}; - /// ParsedAttributes - A collection of parsed attributes. Currently /// we don't differentiate between the various attribute syntaxes, /// which is basically silly. @@ -690,21 +666,18 @@ struct CXX11AttributeList { class ParsedAttributes { public: ParsedAttributes(AttributeFactory &factory) - : pool(factory), list(0) { + : pool(factory), list(nullptr) { } - ParsedAttributes(ParsedAttributes &attrs) - : pool(attrs.pool), list(attrs.list) { - attrs.list = 0; - } + ParsedAttributes(const ParsedAttributes &) LLVM_DELETED_FUNCTION; AttributePool &getPool() const { return pool; } - bool empty() const { return list == 0; } + bool empty() const { return list == nullptr; } void add(AttributeList *newAttr) { assert(newAttr); - assert(newAttr->getNext() == 0); + assert(newAttr->getNext() == nullptr); newAttr->setNext(list); list = newAttr; } @@ -726,11 +699,11 @@ public: void takeAllFrom(ParsedAttributes &attrs) { addAll(attrs.list); - attrs.list = 0; + attrs.list = nullptr; pool.takeAllFrom(attrs.pool); } - void clear() { list = 0; pool.clear(); } + void clear() { list = nullptr; pool.clear(); } AttributeList *getList() const { return list; } /// Returns a reference to the attribute list. Try not to introduce @@ -767,6 +740,20 @@ public: return attr; } + /// Add objc_bridge_related attribute. + AttributeList *addNew(IdentifierInfo *attrName, SourceRange attrRange, + IdentifierInfo *scopeName, SourceLocation scopeLoc, + IdentifierLoc *Param1, + IdentifierLoc *Param2, + IdentifierLoc *Param3, + AttributeList::Syntax syntax) { + AttributeList *attr = + pool.create(attrName, attrRange, scopeName, scopeLoc, + Param1, Param2, Param3, syntax); + add(attr); + return attr; + } + /// Add type_tag_for_datatype attribute. AttributeList *addNewTypeTagForDatatype( IdentifierInfo *attrName, SourceRange attrRange, @@ -808,15 +795,6 @@ public: return attr; } - AttributeList *addNewInteger(ASTContext &C, IdentifierInfo *name, - SourceLocation loc, int arg) { - AttributeList *attr = - pool.createIntegerAttribute(C, name, loc, arg); - add(attr); - return attr; - } - - private: mutable AttributePool pool; AttributeList *list; @@ -831,6 +809,42 @@ enum AttributeArgumentNType { AANT_ArgumentIdentifier }; +/// These constants match the enumerated choices of +/// warn_attribute_wrong_decl_type and err_attribute_wrong_decl_type. +enum AttributeDeclKind { + ExpectedFunction, + ExpectedUnion, + ExpectedVariableOrFunction, + ExpectedFunctionOrMethod, + ExpectedParameter, + ExpectedFunctionMethodOrBlock, + ExpectedFunctionMethodOrClass, + ExpectedFunctionMethodOrParameter, + ExpectedClass, + ExpectedVariable, + ExpectedMethod, + ExpectedVariableFunctionOrLabel, + ExpectedFieldOrGlobalVar, + ExpectedStruct, + ExpectedVariableFunctionOrTag, + ExpectedTLSVar, + ExpectedVariableOrField, + ExpectedVariableFieldOrTag, + ExpectedTypeOrNamespace, + ExpectedObjectiveCInterface, + ExpectedMethodOrProperty, + ExpectedStructOrUnion, + ExpectedStructOrUnionOrClass, + ExpectedType, + ExpectedObjCInstanceMethod, + ExpectedObjCInterfaceDeclInitMethod, + ExpectedFunctionVariableOrClass, + ExpectedObjectiveCProtocol, + ExpectedFunctionGlobalVarMethodOrProperty, + ExpectedStructOrTypedef, + ExpectedObjectiveCInterfaceOrProtocol +}; + } // end namespace clang #endif diff --git a/contrib/llvm/tools/clang/include/clang/Sema/CodeCompleteConsumer.h b/contrib/llvm/tools/clang/include/clang/Sema/CodeCompleteConsumer.h index 64de82c..92a4e9a 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/CodeCompleteConsumer.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/CodeCompleteConsumer.h @@ -397,7 +397,7 @@ public: CodeCompletionString *Optional; }; - Chunk() : Kind(CK_Text), Text(0) { } + Chunk() : Kind(CK_Text), Text(nullptr) { } explicit Chunk(ChunkKind Kind, const char *Text = ""); @@ -575,14 +575,14 @@ public: CodeCompletionTUInfo &CCTUInfo) : Allocator(Allocator), CCTUInfo(CCTUInfo), Priority(0), Availability(CXAvailability_Available), - BriefComment(NULL) { } + BriefComment(nullptr) { } CodeCompletionBuilder(CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, unsigned Priority, CXAvailabilityKind Availability) : Allocator(Allocator), CCTUInfo(CCTUInfo), Priority(Priority), Availability(Availability), - BriefComment(NULL) { } + BriefComment(nullptr) { } /// \brief Retrieve the allocator into which the code completion /// strings should be allocated. @@ -700,7 +700,7 @@ public: /// \brief Build a result that refers to a declaration. CodeCompletionResult(const NamedDecl *Declaration, unsigned Priority, - NestedNameSpecifier *Qualifier = 0, + NestedNameSpecifier *Qualifier = nullptr, bool QualifierIsInformative = false, bool Accessible = true) : Declaration(Declaration), Priority(Priority), @@ -714,36 +714,34 @@ public: /// \brief Build a result that refers to a keyword or symbol. CodeCompletionResult(const char *Keyword, unsigned Priority = CCP_Keyword) - : Declaration(0), Keyword(Keyword), Priority(Priority), StartParameter(0), - Kind(RK_Keyword), CursorKind(CXCursor_NotImplemented), + : Declaration(nullptr), Keyword(Keyword), Priority(Priority), + StartParameter(0), Kind(RK_Keyword), CursorKind(CXCursor_NotImplemented), Availability(CXAvailability_Available), Hidden(false), QualifierIsInformative(0), StartsNestedNameSpecifier(false), - AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(0) - { - } + AllParametersAreInformative(false), DeclaringEntity(false), + Qualifier(nullptr) {} /// \brief Build a result that refers to a macro. CodeCompletionResult(const IdentifierInfo *Macro, unsigned Priority = CCP_Macro) - : Declaration(0), Macro(Macro), Priority(Priority), StartParameter(0), + : Declaration(nullptr), Macro(Macro), Priority(Priority), StartParameter(0), Kind(RK_Macro), CursorKind(CXCursor_MacroDefinition), Availability(CXAvailability_Available), Hidden(false), QualifierIsInformative(0), StartsNestedNameSpecifier(false), - AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(0) - { - } + AllParametersAreInformative(false), DeclaringEntity(false), + Qualifier(nullptr) {} /// \brief Build a result that refers to a pattern. CodeCompletionResult(CodeCompletionString *Pattern, unsigned Priority = CCP_CodePattern, CXCursorKind CursorKind = CXCursor_NotImplemented, CXAvailabilityKind Availability = CXAvailability_Available, - const NamedDecl *D = 0) + const NamedDecl *D = nullptr) : Declaration(D), Pattern(Pattern), Priority(Priority), StartParameter(0), Kind(RK_Pattern), CursorKind(CursorKind), Availability(Availability), Hidden(false), QualifierIsInformative(0), StartsNestedNameSpecifier(false), AllParametersAreInformative(false), - DeclaringEntity(false), Qualifier(0) + DeclaringEntity(false), Qualifier(nullptr) { } @@ -754,7 +752,8 @@ public: : Declaration(D), Pattern(Pattern), Priority(Priority), StartParameter(0), Kind(RK_Pattern), Availability(CXAvailability_Available), Hidden(false), QualifierIsInformative(false), StartsNestedNameSpecifier(false), - AllParametersAreInformative(false), DeclaringEntity(false), Qualifier(0) { + AllParametersAreInformative(false), DeclaringEntity(false), + Qualifier(nullptr) { computeCursorKindAndAvailability(); } @@ -966,20 +965,19 @@ public: CCTUInfo(new GlobalCodeCompletionAllocator) {} /// \brief Prints the finalized code-completion results. - virtual void ProcessCodeCompleteResults(Sema &S, - CodeCompletionContext Context, - CodeCompletionResult *Results, - unsigned NumResults); + void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context, + CodeCompletionResult *Results, + unsigned NumResults) override; - virtual void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, - OverloadCandidate *Candidates, - unsigned NumCandidates); + void ProcessOverloadCandidates(Sema &S, unsigned CurrentArg, + OverloadCandidate *Candidates, + unsigned NumCandidates) override; - virtual CodeCompletionAllocator &getAllocator() { + CodeCompletionAllocator &getAllocator() override { return CCTUInfo.getAllocator(); } - virtual CodeCompletionTUInfo &getCodeCompletionTUInfo() { return CCTUInfo; } + CodeCompletionTUInfo &getCodeCompletionTUInfo() override { return CCTUInfo; } }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Sema/DeclSpec.h b/contrib/llvm/tools/clang/include/clang/Sema/DeclSpec.h index 8f6bd18..8364dfc 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/DeclSpec.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/DeclSpec.h @@ -178,9 +178,9 @@ public: bool isNotEmpty() const { return !isEmpty(); } /// An error occurred during parsing of the scope specifier. - bool isInvalid() const { return isNotEmpty() && getScopeRep() == 0; } + bool isInvalid() const { return isNotEmpty() && getScopeRep() == nullptr; } /// A scope specifier is present, and it refers to a real scope. - bool isValid() const { return isNotEmpty() && getScopeRep() != 0; } + bool isValid() const { return isNotEmpty() && getScopeRep() != nullptr; } /// \brief Indicate that this nested-name-specifier is invalid. void SetInvalid(SourceRange R) { @@ -193,7 +193,7 @@ public: /// Deprecated. Some call sites intend isNotEmpty() while others intend /// isValid(). - bool isSet() const { return getScopeRep() != 0; } + bool isSet() const { return getScopeRep() != nullptr; } void clear() { Range = SourceRange(); @@ -285,14 +285,6 @@ public: static const TST TST_auto = clang::TST_auto; static const TST TST_unknown_anytype = clang::TST_unknown_anytype; static const TST TST_atomic = clang::TST_atomic; - static const TST TST_image1d_t = clang::TST_image1d_t; - static const TST TST_image1d_array_t = clang::TST_image1d_array_t; - static const TST TST_image1d_buffer_t = clang::TST_image1d_buffer_t; - static const TST TST_image2d_t = clang::TST_image2d_t; - static const TST TST_image2d_array_t = clang::TST_image2d_array_t; - static const TST TST_image3d_t = clang::TST_image3d_t; - static const TST TST_sampler_t = clang::TST_sampler_t; - static const TST TST_event_t = clang::TST_event_t; static const TST TST_error = clang::TST_error; // type-qualifiers @@ -428,11 +420,11 @@ public: Friend_specified(false), Constexpr_specified(false), Attrs(attrFactory), - ProtocolQualifiers(0), + ProtocolQualifiers(nullptr), NumProtocolQualifiers(0), - ProtocolLocs(0), + ProtocolLocs(nullptr), writtenBS(), - ObjCQualifiers(0) { + ObjCQualifiers(nullptr) { } ~DeclSpec() { delete [] ProtocolQualifiers; @@ -516,7 +508,8 @@ public: bool hasTagDefinition() const; /// \brief Turn a type-specifier-type into a string like "_Bool" or "union". - static const char *getSpecifierName(DeclSpec::TST T); + static const char *getSpecifierName(DeclSpec::TST T, + const PrintingPolicy &Policy); static const char *getSpecifierName(DeclSpec::TQ Q); static const char *getSpecifierName(DeclSpec::TSS S); static const char *getSpecifierName(DeclSpec::TSC C); @@ -604,36 +597,45 @@ public: /// TODO: use a more general approach that still allows these /// diagnostics to be ignored when desired. bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, - const char *&PrevSpec, unsigned &DiagID); + const char *&PrevSpec, unsigned &DiagID, + const PrintingPolicy &Policy); bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); bool SetTypeSpecWidth(TSW W, SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID); + unsigned &DiagID, const PrintingPolicy &Policy); bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID); + unsigned &DiagID, const PrintingPolicy &Policy); bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID, ParsedType Rep); + unsigned &DiagID, ParsedType Rep, + const PrintingPolicy &Policy); bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID, Decl *Rep, bool Owned); + unsigned &DiagID, Decl *Rep, bool Owned, + const PrintingPolicy &Policy); bool SetTypeSpecType(TST T, SourceLocation TagKwLoc, SourceLocation TagNameLoc, const char *&PrevSpec, - unsigned &DiagID, ParsedType Rep); + unsigned &DiagID, ParsedType Rep, + const PrintingPolicy &Policy); bool SetTypeSpecType(TST T, SourceLocation TagKwLoc, SourceLocation TagNameLoc, const char *&PrevSpec, - unsigned &DiagID, Decl *Rep, bool Owned); + unsigned &DiagID, Decl *Rep, bool Owned, + const PrintingPolicy &Policy); bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID, Expr *Rep); + unsigned &DiagID, Expr *Rep, + const PrintingPolicy &policy); bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, - const char *&PrevSpec, unsigned &DiagID); + const char *&PrevSpec, unsigned &DiagID, + const PrintingPolicy &Policy); bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, - const char *&PrevSpec, unsigned &DiagID); + const char *&PrevSpec, unsigned &DiagID, + const PrintingPolicy &Policy); bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, - const char *&PrevSpec, unsigned &DiagID); + const char *&PrevSpec, unsigned &DiagID, + const PrintingPolicy &Policy); bool SetTypeSpecError(); void UpdateDeclRep(Decl *Rep) { assert(isDeclRep((TST) TypeSpecType)); @@ -707,22 +709,12 @@ public: void addAttributes(AttributeList *AL) { Attrs.addAll(AL); } - void setAttributes(AttributeList *AL) { - Attrs.set(AL); - } bool hasAttributes() const { return !Attrs.empty(); } ParsedAttributes &getAttributes() { return Attrs; } const ParsedAttributes &getAttributes() const { return Attrs; } - /// \brief Return the current attribute list and remove them from - /// the DeclSpec so that it doesn't own them. - ParsedAttributes takeAttributes() { - // The non-const "copy" constructor clears the operand automatically. - return Attrs; - } - void takeAttributesFrom(ParsedAttributes &attrs) { Attrs.takeAllFrom(attrs); } @@ -743,7 +735,8 @@ public: /// Finish - This does final analysis of the declspec, issuing diagnostics for /// things like "_Imaginary" (lacking an FP type). After calling this method, /// DeclSpec is guaranteed self-consistent, even if an error occurred. - void Finish(DiagnosticsEngine &D, Preprocessor &PP); + void Finish(DiagnosticsEngine &D, Preprocessor &PP, + const PrintingPolicy &Policy); const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const { return writtenBS; @@ -798,7 +791,7 @@ public: ObjCDeclSpec() : objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr), - GetterName(0), SetterName(0) { } + GetterName(nullptr), SetterName(nullptr) { } ObjCDeclQualifier getObjCDeclQualifier() const { return objcDeclQualifier; } void setObjCDeclQualifier(ObjCDeclQualifier DQVal) { objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal); @@ -821,15 +814,15 @@ public: void setSetterName(IdentifierInfo *name) { SetterName = name; } private: - // FIXME: These two are unrelated and mutially exclusive. So perhaps - // we can put them in a union to reflect their mutual exclusiveness + // FIXME: These two are unrelated and mutually exclusive. So perhaps + // we can put them in a union to reflect their mutual exclusivity // (space saving is negligible). ObjCDeclQualifier objcDeclQualifier : 6; // NOTE: VC++ treats enums as signed, avoid using ObjCPropertyAttributeKind unsigned PropertyAttributes : 12; - IdentifierInfo *GetterName; // getter name of NULL if no getter - IdentifierInfo *SetterName; // setter name of NULL if no setter + IdentifierInfo *GetterName; // getter name or NULL if no getter + IdentifierInfo *SetterName; // setter name or NULL if no setter }; /// \brief Represents a C++ unqualified-id that has been parsed. @@ -912,13 +905,13 @@ public: /// \brief The location of the last token that describes this unqualified-id. SourceLocation EndLocation; - UnqualifiedId() : Kind(IK_Identifier), Identifier(0) { } + UnqualifiedId() : Kind(IK_Identifier), Identifier(nullptr) { } /// \brief Clear out this unqualified-id, setting it to default (invalid) /// state. void clear() { Kind = IK_Identifier; - Identifier = 0; + Identifier = nullptr; StartLocation = SourceLocation(); EndLocation = SourceLocation(); } @@ -1112,7 +1105,8 @@ struct DeclaratorChunk { }; /// ParamInfo - An array of paraminfo objects is allocated whenever a function - /// declarator is parsed. There are two interesting styles of arguments here: + /// declarator is parsed. There are two interesting styles of parameters + /// here: /// K&R-style identifier lists and parameter type lists. K&R-style identifier /// lists will have information about the identifier, but no type information. /// Parameter type lists will have type info (if the actions module provides @@ -1132,7 +1126,7 @@ struct DeclaratorChunk { ParamInfo() {} ParamInfo(IdentifierInfo *ident, SourceLocation iloc, Decl *param, - CachedTokens *DefArgTokens = 0) + CachedTokens *DefArgTokens = nullptr) : Ident(ident), IdentLoc(iloc), Param(param), DefaultArgTokens(DefArgTokens) {} }; @@ -1144,7 +1138,7 @@ struct DeclaratorChunk { struct FunctionTypeInfo : TypeInfoCommon { /// hasPrototype - This is true if the function had at least one typed - /// argument. If the function is () or (a,b,c), then it has no prototype, + /// parameter. If the function is () or (a,b,c), then it has no prototype, /// and is treated as a K&R-style function. unsigned hasPrototype : 1; @@ -1167,8 +1161,8 @@ struct DeclaratorChunk { /// ExceptionSpecType - An ExceptionSpecificationType value. unsigned ExceptionSpecType : 3; - /// DeleteArgInfo - If this is true, we need to delete[] ArgInfo. - unsigned DeleteArgInfo : 1; + /// DeleteParams - If this is true, we need to delete[] Params. + unsigned DeleteParams : 1; /// HasTrailingReturnType - If this is true, a trailing return type was /// specified. @@ -1183,9 +1177,9 @@ struct DeclaratorChunk { /// The location of the right parenthesis in the source. unsigned RParenLoc; - /// NumArgs - This is the number of formal arguments provided for the + /// NumParams - This is the number of formal parameters specified by the /// declarator. - unsigned NumArgs; + unsigned NumParams; /// NumExceptions - This is the number of types in the dynamic-exception- /// decl, if the function has one. @@ -1213,10 +1207,10 @@ struct DeclaratorChunk { /// \brief The location of the keyword introducing the spec, if any. unsigned ExceptionSpecLoc; - /// ArgInfo - This is a pointer to a new[]'d array of ParamInfo objects that - /// describe the arguments for this function declarator. This is null if - /// there are no arguments specified. - ParamInfo *ArgInfo; + /// Params - This is a pointer to a new[]'d array of ParamInfo objects that + /// describe the parameters specified by this function declarator. null if + /// there are no parameters specified. + ParamInfo *Params; union { /// \brief Pointer to a new[]'d array of TypeAndRange objects that @@ -1233,30 +1227,32 @@ struct DeclaratorChunk { /// type specified. UnionParsedType TrailingReturnType; - /// \brief Reset the argument list to having zero arguments. + /// \brief Reset the parameter list to having zero parameters. /// /// This is used in various places for error recovery. - void freeArgs() { - if (DeleteArgInfo) { - delete[] ArgInfo; - DeleteArgInfo = false; + void freeParams() { + for (unsigned I = 0; I < NumParams; ++I) { + delete Params[I].DefaultArgTokens; + Params[I].DefaultArgTokens = nullptr; + } + if (DeleteParams) { + delete[] Params; + DeleteParams = false; } - NumArgs = 0; + NumParams = 0; } void destroy() { - if (DeleteArgInfo) - delete[] ArgInfo; + if (DeleteParams) + delete[] Params; if (getExceptionSpecType() == EST_Dynamic) delete[] Exceptions; } /// isKNRPrototype - Return true if this is a K&R style identifier list, /// like "void foo(a,b,c)". In a function definition, this will be followed - /// by the argument type definitions. - bool isKNRPrototype() const { - return !hasPrototype && NumArgs != 0; - } + /// by the parameter type definitions. + bool isKNRPrototype() const { return !hasPrototype && NumParams != 0; } SourceLocation getLParenLoc() const { return SourceLocation::getFromRawEncoding(LParenLoc); @@ -1388,7 +1384,7 @@ struct DeclaratorChunk { I.Ptr.ConstQualLoc = ConstQualLoc.getRawEncoding(); I.Ptr.VolatileQualLoc = VolatileQualLoc.getRawEncoding(); I.Ptr.RestrictQualLoc = RestrictQualLoc.getRawEncoding(); - I.Ptr.AttrList = 0; + I.Ptr.AttrList = nullptr; return I; } @@ -1400,7 +1396,7 @@ struct DeclaratorChunk { I.Loc = Loc; I.Ref.HasRestrict = (TypeQuals & DeclSpec::TQ_restrict) != 0; I.Ref.LValueRef = lvalue; - I.Ref.AttrList = 0; + I.Ref.AttrList = nullptr; return I; } @@ -1412,7 +1408,7 @@ struct DeclaratorChunk { I.Kind = Array; I.Loc = LBLoc; I.EndLoc = RBLoc; - I.Arr.AttrList = 0; + I.Arr.AttrList = nullptr; I.Arr.TypeQuals = TypeQuals; I.Arr.hasStatic = isStatic; I.Arr.isStar = isStar; @@ -1422,10 +1418,10 @@ struct DeclaratorChunk { /// DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function. /// "TheDeclarator" is the declarator that this will be added to. - static DeclaratorChunk getFunction(bool hasProto, - bool isAmbiguous, + static DeclaratorChunk getFunction(bool HasProto, + bool IsAmbiguous, SourceLocation LParenLoc, - ParamInfo *ArgInfo, unsigned NumArgs, + ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, @@ -1453,7 +1449,7 @@ struct DeclaratorChunk { I.Kind = BlockPointer; I.Loc = Loc; I.Cls.TypeQuals = TypeQuals; - I.Cls.AttrList = 0; + I.Cls.AttrList = nullptr; return I; } @@ -1464,7 +1460,7 @@ struct DeclaratorChunk { I.Kind = MemberPointer; I.Loc = Loc; I.Mem.TypeQuals = TypeQuals; - I.Mem.AttrList = 0; + I.Mem.AttrList = nullptr; new (I.Mem.ScopeMem.Mem) CXXScopeSpec(SS); return I; } @@ -1476,7 +1472,7 @@ struct DeclaratorChunk { I.Kind = Paren; I.Loc = LParenLoc; I.EndLoc = RParenLoc; - I.Common.AttrList = 0; + I.Common.AttrList = nullptr; return I; } @@ -1594,7 +1590,7 @@ public: InvalidType(DS.getTypeSpecType() == DeclSpec::TST_error), GroupingParens(false), FunctionDefinition(FDK_Declaration), Redeclaration(false), - Attrs(ds.getAttributePool().getFactory()), AsmLabel(0), + Attrs(ds.getAttributePool().getFactory()), AsmLabel(nullptr), InlineParamsUsed(false), Extension(false) { } @@ -1671,7 +1667,7 @@ public: DeclTypeInfo[i].destroy(); DeclTypeInfo.clear(); Attrs.clear(); - AsmLabel = 0; + AsmLabel = nullptr; InlineParamsUsed = false; CommaLoc = SourceLocation(); EllipsisLoc = SourceLocation(); @@ -1844,7 +1840,7 @@ public: if (Name.getKind() == UnqualifiedId::IK_Identifier) return Name.Identifier; - return 0; + return nullptr; } SourceLocation getIdentifierLoc() const { return Name.StartLocation; } @@ -1899,7 +1895,7 @@ public: if (!DeclTypeInfo[i].isParen()) return &DeclTypeInfo[i]; } - return 0; + return nullptr; } /// Return the outermost (furthest from the declarator) chunk of @@ -1910,7 +1906,7 @@ public: if (!DeclTypeInfo[i-1].isParen()) return &DeclTypeInfo[i-1]; } - return 0; + return nullptr; } /// isArrayOfUnknownBound - This method returns true if the declarator @@ -2121,7 +2117,7 @@ struct FieldDeclarator { Declarator D; Expr *BitfieldSize; explicit FieldDeclarator(const DeclSpec &DS) - : D(DS, Declarator::MemberContext), BitfieldSize(0) { } + : D(DS, Declarator::MemberContext), BitfieldSize(nullptr) { } }; /// \brief Represents a C++11 virt-specifier-seq. @@ -2139,6 +2135,8 @@ public: bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec); + bool isUnset() const { return Specifiers == 0; } + bool isOverrideSpecified() const { return Specifiers & VS_Override; } SourceLocation getOverrideLoc() const { return VS_overrideLoc; } @@ -2159,25 +2157,23 @@ private: SourceLocation LastLocation; }; -/// \brief An individual capture in a lambda introducer. -struct LambdaCapture { - LambdaCaptureKind Kind; - SourceLocation Loc; - IdentifierInfo *Id; - SourceLocation EllipsisLoc; - ExprResult Init; - ParsedType InitCaptureType; - LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc, - IdentifierInfo* Id, - SourceLocation EllipsisLoc, - ExprResult Init, ParsedType InitCaptureType) - : Kind(Kind), Loc(Loc), Id(Id), EllipsisLoc(EllipsisLoc), Init(Init), - InitCaptureType(InitCaptureType) - {} -}; - /// \brief Represents a complete lambda introducer. struct LambdaIntroducer { + /// \brief An individual capture in a lambda introducer. + struct LambdaCapture { + LambdaCaptureKind Kind; + SourceLocation Loc; + IdentifierInfo *Id; + SourceLocation EllipsisLoc; + ExprResult Init; + ParsedType InitCaptureType; + LambdaCapture(LambdaCaptureKind Kind, SourceLocation Loc, + IdentifierInfo *Id, SourceLocation EllipsisLoc, + ExprResult Init, ParsedType InitCaptureType) + : Kind(Kind), Loc(Loc), Id(Id), EllipsisLoc(EllipsisLoc), Init(Init), + InitCaptureType(InitCaptureType) {} + }; + SourceRange Range; SourceLocation DefaultLoc; LambdaCaptureDefault Default; diff --git a/contrib/llvm/tools/clang/include/clang/Sema/DelayedDiagnostic.h b/contrib/llvm/tools/clang/include/clang/Sema/DelayedDiagnostic.h index 4f4a87f..85551f8 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/DelayedDiagnostic.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/DelayedDiagnostic.h @@ -113,7 +113,7 @@ private: /// the complete parsing of the current declaration. class DelayedDiagnostic { public: - enum DDKind { Deprecation, Access, ForbiddenType }; + enum DDKind { Deprecation, Unavailable, Access, ForbiddenType }; unsigned char Kind; // actually a DDKind bool Triggered; @@ -122,11 +122,14 @@ public: void Destroy(); - static DelayedDiagnostic makeDeprecation(SourceLocation Loc, - const NamedDecl *D, - const ObjCInterfaceDecl *UnknownObjCClass, - const ObjCPropertyDecl *ObjCProperty, - StringRef Msg); + static DelayedDiagnostic makeAvailability(Sema::AvailabilityDiagnostic AD, + SourceLocation Loc, + const NamedDecl *D, + const ObjCInterfaceDecl *UnknownObjCClass, + const ObjCPropertyDecl *ObjCProperty, + StringRef Msg, + bool ObjCPropertyAccess); + static DelayedDiagnostic makeAccess(SourceLocation Loc, const AccessedEntity &Entity) { @@ -162,12 +165,14 @@ public: } const NamedDecl *getDeprecationDecl() const { - assert(Kind == Deprecation && "Not a deprecation diagnostic."); + assert((Kind == Deprecation || Kind == Unavailable) && + "Not a deprecation diagnostic."); return DeprecationData.Decl; } StringRef getDeprecationMessage() const { - assert(Kind == Deprecation && "Not a deprecation diagnostic."); + assert((Kind == Deprecation || Kind == Unavailable) && + "Not a deprecation diagnostic."); return StringRef(DeprecationData.Message, DeprecationData.MessageLen); } @@ -198,6 +203,10 @@ public: const ObjCPropertyDecl *getObjCProperty() const { return DeprecationData.ObjCProperty; } + + bool getObjCPropertyAccess() const { + return DeprecationData.ObjCPropertyAccess; + } private: @@ -207,6 +216,7 @@ private: const ObjCPropertyDecl *ObjCProperty; const char *Message; size_t MessageLen; + bool ObjCPropertyAccess; }; struct FTD { @@ -244,7 +254,7 @@ public: /// Does this pool, or any of its ancestors, contain any diagnostics? bool empty() const { - return (Diagnostics.empty() && (Parent == NULL || Parent->empty())); + return (Diagnostics.empty() && (!Parent || Parent->empty())); } /// Add a diagnostic to this pool. @@ -257,7 +267,7 @@ public: if (pool.Diagnostics.empty()) return; if (Diagnostics.empty()) { - Diagnostics = llvm_move(pool.Diagnostics); + Diagnostics = std::move(pool.Diagnostics); } else { Diagnostics.append(pool.pool_begin(), pool.pool_end()); } diff --git a/contrib/llvm/tools/clang/include/clang/Sema/IdentifierResolver.h b/contrib/llvm/tools/clang/include/clang/Sema/IdentifierResolver.h index 99d94a1..b2404bc 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/IdentifierResolver.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/IdentifierResolver.h @@ -150,11 +150,14 @@ public: /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns /// true if 'D' belongs to the given declaration context. /// - /// \param ExplicitInstantiationOrSpecialization When true, we are checking - /// whether the declaration is in scope for the purposes of explicit template - /// instantiation or specialization. The default is false. - bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S = 0, - bool ExplicitInstantiationOrSpecialization = false) const; + /// \param AllowInlineNamespace If \c true, we are checking whether a prior + /// declaration is in scope in a declaration that requires a prior + /// declaration (because it is either explicitly qualified or is a + /// template instantiation or specialization). In this case, a + /// declaration is in scope if it's in the inline namespace set of the + /// context. + bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S = nullptr, + bool AllowInlineNamespace = false) const; /// AddDecl - Link the decl to its shadowed decl chain. void AddDecl(NamedDecl *D); diff --git a/contrib/llvm/tools/clang/include/clang/Sema/Initialization.h b/contrib/llvm/tools/clang/include/clang/Sema/Initialization.h index 83fb2be..9f342b2 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/Initialization.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/Initialization.h @@ -103,6 +103,9 @@ private: /// \brief The type of the object or reference being initialized. QualType Type; + /// \brief The mangling number for the next reference temporary to be created. + mutable unsigned ManglingNumber; + struct LN { /// \brief When Kind == EK_Result, EK_Exception, EK_New, the /// location of the 'return', 'throw', or 'new' keyword, @@ -155,19 +158,19 @@ private: struct C Capture; }; - InitializedEntity() { } + InitializedEntity() : ManglingNumber(0) {} /// \brief Create the initialization entity for a variable. InitializedEntity(VarDecl *Var) - : Kind(EK_Variable), Parent(0), Type(Var->getType()), - VariableOrMember(Var) { } + : Kind(EK_Variable), Parent(nullptr), Type(Var->getType()), + ManglingNumber(0), VariableOrMember(Var) { } /// \brief Create the initialization entity for the result of a /// function, throwing an object, performing an explicit cast, or /// initializing a parameter for which there is no declaration. InitializedEntity(EntityKind Kind, SourceLocation Loc, QualType Type, bool NRVO = false) - : Kind(Kind), Parent(0), Type(Type) + : Kind(Kind), Parent(nullptr), Type(Type), ManglingNumber(0) { LocAndNRVO.Location = Loc.getRawEncoding(); LocAndNRVO.NRVO = NRVO; @@ -176,7 +179,7 @@ private: /// \brief Create the initialization entity for a member subobject. InitializedEntity(FieldDecl *Member, const InitializedEntity *Parent) : Kind(EK_Member), Parent(Parent), Type(Member->getType()), - VariableOrMember(Member) { } + ManglingNumber(0), VariableOrMember(Member) { } /// \brief Create the initialization entity for an array element. InitializedEntity(ASTContext &Context, unsigned Index, @@ -184,7 +187,8 @@ private: /// \brief Create the initialization entity for a lambda capture. InitializedEntity(IdentifierInfo *VarID, QualType FieldType, SourceLocation Loc) - : Kind(EK_LambdaCapture), Parent(0), Type(FieldType) + : Kind(EK_LambdaCapture), Parent(nullptr), Type(FieldType), + ManglingNumber(0) { Capture.VarID = VarID; Capture.Location = Loc.getRawEncoding(); @@ -214,7 +218,7 @@ public: Entity.Kind = EK_Parameter; Entity.Type = Context.getVariableArrayDecayedType(Type.getUnqualifiedType()); - Entity.Parent = 0; + Entity.Parent = nullptr; Entity.Parameter = (static_cast<uintptr_t>(Consumed) | reinterpret_cast<uintptr_t>(Parm)); return Entity; @@ -228,7 +232,7 @@ public: InitializedEntity Entity; Entity.Kind = EK_Parameter; Entity.Type = Context.getVariableArrayDecayedType(Type); - Entity.Parent = 0; + Entity.Parent = nullptr; Entity.Parameter = (Consumed); return Entity; } @@ -258,7 +262,7 @@ public: /// \brief Create the initialization entity for a temporary. static InitializedEntity InitializeTemporary(QualType Type) { InitializedEntity Result(EK_Temporary, SourceLocation(), Type); - Result.TypeInfo = 0; + Result.TypeInfo = nullptr; return Result; } @@ -290,14 +294,16 @@ public: } /// \brief Create the initialization entity for a member subobject. - static InitializedEntity InitializeMember(FieldDecl *Member, - const InitializedEntity *Parent = 0) { + static InitializedEntity + InitializeMember(FieldDecl *Member, + const InitializedEntity *Parent = nullptr) { return InitializedEntity(Member, Parent); } /// \brief Create the initialization entity for a member subobject. - static InitializedEntity InitializeMember(IndirectFieldDecl *Member, - const InitializedEntity *Parent = 0) { + static InitializedEntity + InitializeMember(IndirectFieldDecl *Member, + const InitializedEntity *Parent = nullptr) { return InitializedEntity(Member->getAnonField(), Parent); } @@ -341,7 +347,7 @@ public: if (Kind == EK_Temporary || Kind == EK_CompoundLiteralInit) return TypeInfo; - return 0; + return nullptr; } /// \brief Retrieve the name of the entity being initialized. @@ -395,6 +401,13 @@ public: return SourceLocation::getFromRawEncoding(LocAndNRVO.Location); } + /// \brief If this is an array, vector, or complex number element, get the + /// element's index. + unsigned getElementIndex() const { + assert(getKind() == EK_ArrayElement || getKind() == EK_VectorElement || + getKind() == EK_ComplexElement); + return Index; + } /// \brief If this is already the initializer for an array or vector /// element, sets the element index. void setElementIndex(unsigned Index) { @@ -418,6 +431,8 @@ public: Kind = EK_Parameter_CF_Audited; } + unsigned allocateManglingNumber() const { return ++ManglingNumber; } + /// Dump a representation of the initialized entity to standard error, /// for debugging purposes. void dump() const; @@ -648,22 +663,25 @@ public: SK_QualificationConversionXValue, /// \brief Perform a qualification conversion, producing an lvalue. SK_QualificationConversionLValue, + /// \brief Perform a conversion adding _Atomic to a type. + SK_AtomicConversion, /// \brief Perform a load from a glvalue, producing an rvalue. SK_LValueToRValue, /// \brief Perform an implicit conversion sequence. SK_ConversionSequence, /// \brief Perform an implicit conversion sequence without narrowing. SK_ConversionSequenceNoNarrowing, - /// \brief Perform list-initialization without a constructor + /// \brief Perform list-initialization without a constructor. SK_ListInitialization, - /// \brief Perform list-initialization with a constructor. - SK_ListConstructorCall, /// \brief Unwrap the single-element initializer list for a reference. SK_UnwrapInitList, /// \brief Rewrap the single-element initializer list for a reference. SK_RewrapInitList, /// \brief Perform initialization via a constructor. SK_ConstructorInitialization, + /// \brief Perform initialization via a constructor, taking arguments from + /// a single InitListExpr. + SK_ConstructorInitializationFromList, /// \brief Zero-initialize the object SK_ZeroInitialization, /// \brief C assignment @@ -687,6 +705,9 @@ public: SK_ProduceObjCObject, /// \brief Construct a std::initializer_list from an initializer list. SK_StdInitializerList, + /// \brief Perform initialization via a constructor taking a single + /// std::initializer_list argument. + SK_StdInitializerListConstructorCall, /// \brief Initialize an OpenCL sampler from an integer. SK_OCLSamplerInit, /// \brief Passing zero to a function where OpenCL event_t is expected. @@ -843,17 +864,17 @@ public: /// /// \param Args the argument(s) provided for initialization. /// - /// \param InInitList true if we are initializing from an expression within - /// an initializer list. This disallows narrowing conversions in C++11 - /// onwards. + /// \param TopLevelOfInitList true if we are initializing from an expression + /// at the top level inside an initializer list. This disallows + /// narrowing conversions in C++11 onwards. InitializationSequence(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, - bool InInitList = false); + bool TopLevelOfInitList = false); void InitializeFrom(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, - bool InInitList); + bool TopLevelOfInitList); ~InitializationSequence(); @@ -882,7 +903,7 @@ public: const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, - QualType *ResultType = 0); + QualType *ResultType = nullptr); /// \brief Diagnose an potentially-invalid initialization sequence. /// @@ -980,7 +1001,11 @@ public: /// given type. void AddQualificationConversionStep(QualType Ty, ExprValueKind Category); - + + /// \brief Add a new step that performs conversion from non-atomic to atomic + /// type. + void AddAtomicConversionStep(QualType Ty); + /// \brief Add a new step that performs a load of the given type. /// /// Although the term "LValueToRValue" is conventional, this applies to both diff --git a/contrib/llvm/tools/clang/include/clang/Sema/Lookup.h b/contrib/llvm/tools/clang/include/clang/Sema/Lookup.h index 105c879..00cc164 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/Lookup.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/Lookup.h @@ -130,8 +130,8 @@ public: Sema::LookupNameKind LookupKind, Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration) : ResultKind(NotFound), - Paths(0), - NamingClass(0), + Paths(nullptr), + NamingClass(nullptr), SemaRef(SemaRef), NameInfo(NameInfo), LookupKind(LookupKind), @@ -152,8 +152,8 @@ public: SourceLocation NameLoc, Sema::LookupNameKind LookupKind, Sema::RedeclarationKind Redecl = Sema::NotForRedeclaration) : ResultKind(NotFound), - Paths(0), - NamingClass(0), + Paths(nullptr), + NamingClass(nullptr), SemaRef(SemaRef), NameInfo(Name, NameLoc), LookupKind(LookupKind), @@ -172,8 +172,8 @@ public: /// disabled. LookupResult(TemporaryToken _, const LookupResult &Other) : ResultKind(NotFound), - Paths(0), - NamingClass(0), + Paths(nullptr), + NamingClass(nullptr), SemaRef(Other.SemaRef), NameInfo(Other.NameInfo), LookupKind(Other.LookupKind), @@ -259,7 +259,7 @@ public: } LookupResultKind getResultKind() const { - sanity(); + assert(sanity()); return ResultKind; } @@ -303,7 +303,7 @@ public: /// if there is one. NamedDecl *getAcceptableDecl(NamedDecl *D) const { if (!D->isInIdentifierNamespace(IDNS)) - return 0; + return nullptr; if (isHiddenDeclarationVisible() || isVisible(SemaRef, D)) return D; @@ -324,7 +324,7 @@ public: /// \brief Returns whether these results arose from performing a /// lookup into a class. bool isClassLookup() const { - return NamingClass != 0; + return NamingClass != nullptr; } /// \brief Returns the 'naming class' for this lookup, i.e. the @@ -421,7 +421,7 @@ public: if (Paths) { deletePaths(Paths); - Paths = 0; + Paths = nullptr; } } else { AmbiguityKind SavedAK = Ambiguity; @@ -434,14 +434,14 @@ public: Ambiguity = SavedAK; } else if (Paths) { deletePaths(Paths); - Paths = 0; + Paths = nullptr; } } } template <class DeclClass> DeclClass *getAsSingle() const { - if (getResultKind() != Found) return 0; + if (getResultKind() != Found) return nullptr; return dyn_cast<DeclClass>(getFoundDecl()); } @@ -491,8 +491,8 @@ public: ResultKind = NotFound; Decls.clear(); if (Paths) deletePaths(Paths); - Paths = NULL; - NamingClass = 0; + Paths = nullptr; + NamingClass = nullptr; Shadowed = false; } @@ -637,13 +637,7 @@ private: void configure(); // Sanity checks. - void sanityImpl() const; - - void sanity() const { -#ifndef NDEBUG - sanityImpl(); -#endif - } + bool sanity() const; bool sanityCheckUnresolved() const { for (iterator I = begin(), E = end(); I != E; ++I) diff --git a/contrib/llvm/tools/clang/include/clang/Sema/LoopHint.h b/contrib/llvm/tools/clang/include/clang/Sema/LoopHint.h new file mode 100644 index 0000000..d4b985d --- /dev/null +++ b/contrib/llvm/tools/clang/include/clang/Sema/LoopHint.h @@ -0,0 +1,40 @@ +//===--- LoopHint.h - Types for LoopHint ------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_SEMA_LOOPHINT_H +#define LLVM_CLANG_SEMA_LOOPHINT_H + +#include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Sema/AttributeList.h" +#include "clang/Sema/Ownership.h" + +namespace clang { + +/// \brief Loop optimization hint for loop and unroll pragmas. +struct LoopHint { + // Source range of the directive. + SourceRange Range; + // Identifier corresponding to the name of the pragma. "loop" for + // "#pragma clang loop" directives and "unroll" for "#pragma unroll" + // hints. + IdentifierLoc *PragmaNameLoc; + // Name of the loop hint. Examples: "unroll", "vectorize". In the + // "#pragma unroll" case, this is identical to PragmaNameLoc. + IdentifierLoc *OptionLoc; + // Identifier for the hint argument. If null, then the hint has no argument + // such as for "#pragma unroll". + IdentifierLoc *ValueLoc; + // Expression for the hint argument if it exists, null otherwise. + Expr *ValueExpr; +}; + +} // end namespace clang + +#endif // LLVM_CLANG_SEMA_LOOPHINT_H diff --git a/contrib/llvm/tools/clang/include/clang/Sema/MultiplexExternalSemaSource.h b/contrib/llvm/tools/clang/include/clang/Sema/MultiplexExternalSemaSource.h index e9ba479..7860b6d 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/MultiplexExternalSemaSource.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/MultiplexExternalSemaSource.h @@ -65,31 +65,35 @@ public: /// \brief Resolve a declaration ID into a declaration, potentially /// building a new declaration. - virtual Decl *GetExternalDecl(uint32_t ID); + Decl *GetExternalDecl(uint32_t ID) override; + + /// \brief Complete the redeclaration chain if it's been extended since the + /// previous generation of the AST source. + void CompleteRedeclChain(const Decl *D) override; /// \brief Resolve a selector ID into a selector. - virtual Selector GetExternalSelector(uint32_t ID); + Selector GetExternalSelector(uint32_t ID) override; /// \brief Returns the number of selectors known to the external AST /// source. - virtual uint32_t GetNumExternalSelectors(); + uint32_t GetNumExternalSelectors() override; /// \brief Resolve the offset of a statement in the decl stream into /// a statement. - virtual Stmt *GetExternalDeclStmt(uint64_t Offset); + Stmt *GetExternalDeclStmt(uint64_t Offset) override; /// \brief Resolve the offset of a set of C++ base specifiers in the decl /// stream into an array of specifiers. - virtual CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset); + CXXBaseSpecifier *GetExternalCXXBaseSpecifiers(uint64_t Offset) override; /// \brief Find all declarations with the given name in the /// given context. - virtual bool - FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name); + bool + FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override; /// \brief Ensures that the table of all visible declarations inside this /// context is up to date. - virtual void completeVisibleDeclsMap(const DeclContext *DC); + void completeVisibleDeclsMap(const DeclContext *DC) override; /// \brief Finds all declarations lexically contained within the given /// DeclContext, after applying an optional filter predicate. @@ -99,9 +103,9 @@ public: /// are returned. /// /// \return an indication of whether the load succeeded or failed. - virtual ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, - bool (*isKindWeWant)(Decl::Kind), - SmallVectorImpl<Decl*> &Result); + ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, + bool (*isKindWeWant)(Decl::Kind), + SmallVectorImpl<Decl*> &Result) override; /// \brief Finds all declarations lexically contained within the given /// DeclContext. @@ -109,7 +113,7 @@ public: /// \return true if an error occurred ExternalLoadResult FindExternalLexicalDecls(const DeclContext *DC, SmallVectorImpl<Decl*> &Result) { - return FindExternalLexicalDecls(DC, 0, Result); + return FindExternalLexicalDecls(DC, nullptr, Result); } template <typename DeclTy> @@ -121,12 +125,12 @@ public: /// \brief Get the decls that are contained in a file in the Offset/Length /// range. \p Length can be 0 to indicate a point at \p Offset instead of /// a range. - virtual void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length, - SmallVectorImpl<Decl *> &Decls); + void FindFileRegionDecls(FileID File, unsigned Offset,unsigned Length, + SmallVectorImpl<Decl *> &Decls) override; /// \brief Gives the external AST source an opportunity to complete /// an incomplete type. - virtual void CompleteType(TagDecl *Tag); + void CompleteType(TagDecl *Tag) override; /// \brief Gives the external AST source an opportunity to complete an /// incomplete Objective-C class. @@ -134,27 +138,27 @@ public: /// This routine will only be invoked if the "externally completed" bit is /// set on the ObjCInterfaceDecl via the function /// \c ObjCInterfaceDecl::setExternallyCompleted(). - virtual void CompleteType(ObjCInterfaceDecl *Class); + void CompleteType(ObjCInterfaceDecl *Class) override; /// \brief Loads comment ranges. - virtual void ReadComments(); + void ReadComments() override; /// \brief Notify ExternalASTSource that we started deserialization of /// a decl or type so until FinishedDeserializing is called there may be /// decls that are initializing. Must be paired with FinishedDeserializing. - virtual void StartedDeserializing(); + void StartedDeserializing() override; /// \brief Notify ExternalASTSource that we finished the deserialization of /// a decl or type. Must be paired with StartedDeserializing. - virtual void FinishedDeserializing(); + void FinishedDeserializing() override; /// \brief Function that will be invoked when we begin parsing a new /// translation unit involving this external AST source. - virtual void StartTranslationUnit(ASTConsumer *Consumer); + void StartTranslationUnit(ASTConsumer *Consumer) override; /// \brief Print any statistics that have been gathered regarding /// the external AST source. - virtual void PrintStats(); + void PrintStats() override; /// \brief Perform layout on the given record. @@ -184,16 +188,17 @@ public: /// be laid out according to the ABI. /// /// \returns true if the record layout was provided, false otherwise. - virtual bool + bool layoutRecordType(const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment, llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets, llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets, - llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets); + llvm::DenseMap<const CXXRecordDecl *, + CharUnits> &VirtualBaseOffsets) override; /// Return the amount of memory used by memory buffers, breaking down /// by heap-backed versus mmap'ed memory. - virtual void getMemoryBufferSizes(MemoryBufferSizes &sizes) const; + void getMemoryBufferSizes(MemoryBufferSizes &sizes) const override; //===--------------------------------------------------------------------===// // ExternalSemaSource. @@ -202,24 +207,25 @@ public: /// \brief Initialize the semantic source with the Sema instance /// being used to perform semantic analysis on the abstract syntax /// tree. - virtual void InitializeSema(Sema &S); + void InitializeSema(Sema &S) override; /// \brief Inform the semantic consumer that Sema is no longer available. - virtual void ForgetSema(); + void ForgetSema() override; /// \brief Load the contents of the global method pool for a given /// selector. - virtual void ReadMethodPool(Selector Sel); + void ReadMethodPool(Selector Sel) override; /// \brief Load the set of namespaces that are known to the external source, /// which will be used during typo correction. - virtual void ReadKnownNamespaces(SmallVectorImpl<NamespaceDecl*> &Namespaces); + void + ReadKnownNamespaces(SmallVectorImpl<NamespaceDecl*> &Namespaces) override; /// \brief Load the set of used but not defined functions or variables with /// internal linkage, or used but not defined inline functions. - virtual void ReadUndefinedButUsed( - llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined); - + void ReadUndefinedButUsed( + llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined) override; + /// \brief Do last resort, unqualified lookup on a LookupResult that /// Sema cannot find. /// @@ -228,7 +234,7 @@ public: /// \param S the Scope of the identifier occurrence. /// /// \return true to tell Sema to recover using the LookupResult. - virtual bool LookupUnqualified(LookupResult &R, Scope *S); + bool LookupUnqualified(LookupResult &R, Scope *S) override; /// \brief Read the set of tentative definitions known to the external Sema /// source. @@ -237,8 +243,8 @@ public: /// given vector of tentative definitions. Note that this routine may be /// invoked multiple times; the external source should take care not to /// introduce the same declarations repeatedly. - virtual void ReadTentativeDefinitions(SmallVectorImpl<VarDecl*> &Defs); - + void ReadTentativeDefinitions(SmallVectorImpl<VarDecl*> &Defs) override; + /// \brief Read the set of unused file-scope declarations known to the /// external Sema source. /// @@ -246,9 +252,9 @@ public: /// given vector of declarations. Note that this routine may be /// invoked multiple times; the external source should take care not to /// introduce the same declarations repeatedly. - virtual void ReadUnusedFileScopedDecls( - SmallVectorImpl<const DeclaratorDecl*> &Decls); - + void ReadUnusedFileScopedDecls( + SmallVectorImpl<const DeclaratorDecl*> &Decls) override; + /// \brief Read the set of delegating constructors known to the /// external Sema source. /// @@ -256,8 +262,8 @@ public: /// given vector of declarations. Note that this routine may be /// invoked multiple times; the external source should take care not to /// introduce the same declarations repeatedly. - virtual void ReadDelegatingConstructors( - SmallVectorImpl<CXXConstructorDecl*> &Decls); + void ReadDelegatingConstructors( + SmallVectorImpl<CXXConstructorDecl*> &Decls) override; /// \brief Read the set of ext_vector type declarations known to the /// external Sema source. @@ -266,7 +272,7 @@ public: /// the given vector of declarations. Note that this routine may be /// invoked multiple times; the external source should take care not to /// introduce the same declarations repeatedly. - virtual void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl*> &Decls); + void ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl*> &Decls) override; /// \brief Read the set of dynamic classes known to the external Sema source. /// @@ -274,7 +280,7 @@ public: /// the given vector of declarations. Note that this routine may be /// invoked multiple times; the external source should take care not to /// introduce the same declarations repeatedly. - virtual void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl*> &Decls); + void ReadDynamicClasses(SmallVectorImpl<CXXRecordDecl*> &Decls) override; /// \brief Read the set of locally-scoped extern "C" declarations known to the /// external Sema source. @@ -283,7 +289,8 @@ public: /// declarations to the given vector of declarations. Note that this routine /// may be invoked multiple times; the external source should take care not /// to introduce the same declarations repeatedly. - virtual void ReadLocallyScopedExternCDecls(SmallVectorImpl<NamedDecl*>&Decls); + void ReadLocallyScopedExternCDecls( + SmallVectorImpl<NamedDecl*> &Decls) override; /// \brief Read the set of referenced selectors known to the /// external Sema source. @@ -292,8 +299,8 @@ public: /// given vector of selectors. Note that this routine /// may be invoked multiple times; the external source should take care not /// to introduce the same selectors repeatedly. - virtual void ReadReferencedSelectors(SmallVectorImpl<std::pair<Selector, - SourceLocation> > &Sels); + void ReadReferencedSelectors(SmallVectorImpl<std::pair<Selector, + SourceLocation> > &Sels) override; /// \brief Read the set of weak, undeclared identifiers known to the /// external Sema source. @@ -302,15 +309,15 @@ public: /// the given vector. Note that this routine may be invoked multiple times; /// the external source should take care not to introduce the same identifiers /// repeatedly. - virtual void ReadWeakUndeclaredIdentifiers( - SmallVectorImpl<std::pair<IdentifierInfo*, WeakInfo> > &WI); + void ReadWeakUndeclaredIdentifiers( + SmallVectorImpl<std::pair<IdentifierInfo*, WeakInfo> > &WI) override; /// \brief Read the set of used vtables known to the external Sema source. /// /// The external source should append its own used vtables to the given /// vector. Note that this routine may be invoked multiple times; the external /// source should take care not to introduce the same vtables repeatedly. - virtual void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables); + void ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) override; /// \brief Read the set of pending instantiations known to the external /// Sema source. @@ -319,8 +326,8 @@ public: /// given vector. Note that this routine may be invoked multiple times; the /// external source should take care not to introduce the same instantiations /// repeatedly. - virtual void ReadPendingInstantiations( - SmallVectorImpl<std::pair<ValueDecl*, SourceLocation> >& Pending); + void ReadPendingInstantiations( + SmallVectorImpl<std::pair<ValueDecl*, SourceLocation> >& Pending) override; /// \brief Read the set of late parsed template functions for this source. /// @@ -328,17 +335,18 @@ public: /// into the map. Note that this routine may be invoked multiple times; the /// external source should take care not to introduce the same map entries /// repeatedly. - virtual void ReadLateParsedTemplates( - llvm::DenseMap<const FunctionDecl *, LateParsedTemplate *> &LPTMap); + void ReadLateParsedTemplates( + llvm::DenseMap<const FunctionDecl *, + LateParsedTemplate *> &LPTMap) override; /// \copydoc ExternalSemaSource::CorrectTypo /// \note Returns the first nonempty correction. - virtual TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, - int LookupKind, Scope *S, CXXScopeSpec *SS, - CorrectionCandidateCallback &CCC, - DeclContext *MemberContext, - bool EnteringContext, - const ObjCObjectPointerType *OPT); + TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, + int LookupKind, Scope *S, CXXScopeSpec *SS, + CorrectionCandidateCallback &CCC, + DeclContext *MemberContext, + bool EnteringContext, + const ObjCObjectPointerType *OPT) override; /// \brief Produces a diagnostic note if one of the attached sources /// contains a complete definition for \p T. Queries the sources in list @@ -350,7 +358,8 @@ public: /// \param T the \c QualType that should have been complete at \p Loc /// /// \return true if a diagnostic was produced, false otherwise. - virtual bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc, QualType T); + bool MaybeDiagnoseMissingCompleteType(SourceLocation Loc, + QualType T) override; // isa/cast/dyn_cast support static bool classof(const MultiplexExternalSemaSource*) { return true; } diff --git a/contrib/llvm/tools/clang/include/clang/Sema/ObjCMethodList.h b/contrib/llvm/tools/clang/include/clang/Sema/ObjCMethodList.h index 94e3807..2003356 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/ObjCMethodList.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/ObjCMethodList.h @@ -26,7 +26,7 @@ struct ObjCMethodList { /// \brief The next list object and 2 bits for extra info. llvm::PointerIntPair<ObjCMethodList *, 2> NextAndExtraBits; - ObjCMethodList() : Method(0) { } + ObjCMethodList() : Method(nullptr) { } ObjCMethodList(ObjCMethodDecl *M, ObjCMethodList *C) : Method(M), NextAndExtraBits(C, 0) { } diff --git a/contrib/llvm/tools/clang/include/clang/Sema/Overload.h b/contrib/llvm/tools/clang/include/clang/Sema/Overload.h index b8bd14a..7c221a2 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/Overload.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/Overload.h @@ -262,7 +262,7 @@ namespace clang { StandardConversionSequence Before; /// EllipsisConversion - When this is true, it means user-defined - /// conversion sequence starts with a ... (elipsis) conversion, instead of + /// conversion sequence starts with a ... (ellipsis) conversion, instead of /// a standard conversion. In this case, 'Before' field must be ignored. // FIXME. I much rather put this as the first field. But there seems to be // a gcc code gen. bug which causes a crash in a test. Putting it here seems @@ -339,7 +339,6 @@ namespace clang { enum FailureKind { no_conversion, unrelated_class, - suppressed_user, bad_qualifiers, lvalue_ref_to_rvalue, rvalue_ref_to_lvalue @@ -364,7 +363,7 @@ namespace clang { } void init(FailureKind K, QualType From, QualType To) { Kind = K; - FromExpr = 0; + FromExpr = nullptr; setFromType(From); setToType(To); } @@ -579,7 +578,11 @@ namespace clang { /// (CUDA) This candidate was not viable because the callee /// was not accessible from the caller's target (i.e. host->device, /// global->host, device->host). - ovl_fail_bad_target + ovl_fail_bad_target, + + /// This candidate function was not viable because an enable_if + /// attribute disabled it. + ovl_fail_enable_if }; /// OverloadCandidate - A single candidate in an overload set (C++ 13.3). @@ -675,11 +678,35 @@ namespace clang { return CanFix; } + + unsigned getNumParams() const { + if (IsSurrogate) { + auto STy = Surrogate->getConversionType(); + while (STy->isPointerType() || STy->isReferenceType()) + STy = STy->getPointeeType(); + return STy->getAs<FunctionProtoType>()->getNumParams(); + } + if (Function) + return Function->getNumParams(); + return ExplicitCallArguments; + } }; /// OverloadCandidateSet - A set of overload candidates, used in C++ /// overload resolution (C++ 13.3). class OverloadCandidateSet { + public: + enum CandidateSetKind { + /// Normal lookup. + CSK_Normal, + /// Lookup for candidates for a call using operator syntax. Candidates + /// that have no parameters of class type will be skipped unless there + /// is a parameter of (reference to) enum type and the corresponding + /// argument is of the same enum type. + CSK_Operator + }; + + private: SmallVector<OverloadCandidate, 16> Candidates; llvm::SmallPtrSet<Decl *, 16> Functions; @@ -688,6 +715,7 @@ namespace clang { llvm::BumpPtrAllocator ConversionSequenceAllocator; SourceLocation Loc; + CandidateSetKind Kind; unsigned NumInlineSequences; char InlineSpace[16 * sizeof(ImplicitConversionSequence)]; @@ -698,10 +726,12 @@ namespace clang { void destroyCandidates(); public: - OverloadCandidateSet(SourceLocation Loc) : Loc(Loc), NumInlineSequences(0){} + OverloadCandidateSet(SourceLocation Loc, CandidateSetKind CSK) + : Loc(Loc), Kind(CSK), NumInlineSequences(0) {} ~OverloadCandidateSet() { destroyCandidates(); } SourceLocation getLocation() const { return Loc; } + CandidateSetKind getKind() const { return Kind; } /// \brief Determine when this overload candidate will be new to the /// overload set. diff --git a/contrib/llvm/tools/clang/include/clang/Sema/Ownership.h b/contrib/llvm/tools/clang/include/clang/Sema/Ownership.h index b7d7710..8031562 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/Ownership.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/Ownership.h @@ -49,7 +49,7 @@ namespace clang { typedef llvm::PointerLikeTypeTraits<PtrTy> Traits; public: - OpaquePtr() : Ptr(0) {} + OpaquePtr() : Ptr(nullptr) {} static OpaquePtr make(PtrTy P) { OpaquePtr OP; OP.set(P); return OP; } @@ -79,7 +79,7 @@ namespace clang { Ptr = Traits::getAsVoidPointer(P); } - LLVM_EXPLICIT operator bool() const { return Ptr != 0; } + LLVM_EXPLICIT operator bool() const { return Ptr != nullptr; } void *getAsOpaquePtr() const { return Ptr; } static OpaquePtr getFromOpaquePtr(void *P) { return OpaquePtr(P); } @@ -158,12 +158,10 @@ namespace clang { bool isInvalid() const { return Invalid; } bool isUsable() const { return !Invalid && Val; } + bool isUnset() const { return !Invalid && !Val; } PtrTy get() const { return Val; } - // FIXME: Replace with get. - PtrTy release() const { return Val; } - PtrTy take() const { return Val; } - template <typename T> T *takeAs() { return static_cast<T*>(get()); } + template <typename T> T *getAs() { return static_cast<T*>(get()); } void set(PtrTy V) { Val = V; } @@ -199,15 +197,13 @@ namespace clang { bool isInvalid() const { return PtrWithInvalid & 0x01; } bool isUsable() const { return PtrWithInvalid > 0x01; } + bool isUnset() const { return PtrWithInvalid == 0; } PtrTy get() const { void *VP = reinterpret_cast<void *>(PtrWithInvalid & ~0x01); return PtrTraits::getFromVoidPointer(VP); } - // FIXME: Replace with get. - PtrTy take() const { return get(); } - PtrTy release() const { return get(); } - template <typename T> T *takeAs() { return static_cast<T*>(get()); } + template <typename T> T *getAs() { return static_cast<T*>(get()); } void set(PtrTy V) { void *VP = PtrTraits::getAsVoidPointer(V); @@ -262,11 +258,11 @@ namespace clang { typedef ActionResult<Decl*> DeclResult; typedef OpaquePtr<TemplateName> ParsedTemplateTy; - typedef llvm::MutableArrayRef<Expr*> MultiExprArg; - typedef llvm::MutableArrayRef<Stmt*> MultiStmtArg; - typedef llvm::MutableArrayRef<ParsedTemplateArgument> ASTTemplateArgsPtr; - typedef llvm::MutableArrayRef<ParsedType> MultiTypeArg; - typedef llvm::MutableArrayRef<TemplateParameterList*> MultiTemplateParamsArg; + typedef MutableArrayRef<Expr*> MultiExprArg; + typedef MutableArrayRef<Stmt*> MultiStmtArg; + typedef MutableArrayRef<ParsedTemplateArgument> ASTTemplateArgsPtr; + typedef MutableArrayRef<ParsedType> MultiTypeArg; + typedef MutableArrayRef<TemplateParameterList*> MultiTemplateParamsArg; inline ExprResult ExprError() { return ExprResult(true); } inline StmtResult StmtError() { return StmtResult(true); } diff --git a/contrib/llvm/tools/clang/include/clang/Sema/ParsedTemplate.h b/contrib/llvm/tools/clang/include/clang/Sema/ParsedTemplate.h index 94db454..b36425f 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/ParsedTemplate.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/ParsedTemplate.h @@ -35,7 +35,7 @@ namespace clang { /// \brief Build an empty template argument. /// /// This template argument is invalid. - ParsedTemplateArgument() : Kind(Type), Arg(0) { } + ParsedTemplateArgument() : Kind(Type), Arg(nullptr) { } /// \brief Create a template type argument or non-type template argument. /// @@ -61,7 +61,7 @@ namespace clang { SS(SS), Loc(TemplateLoc), EllipsisLoc() { } /// \brief Determine whether the given template argument is invalid. - bool isInvalid() const { return Arg == 0; } + bool isInvalid() const { return Arg == nullptr; } /// \brief Determine what kind of template argument we have. KindType getKind() const { return Kind; } diff --git a/contrib/llvm/tools/clang/include/clang/Sema/PrettyDeclStackTrace.h b/contrib/llvm/tools/clang/include/clang/Sema/PrettyDeclStackTrace.h index aa55705..c0c772d 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/PrettyDeclStackTrace.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/PrettyDeclStackTrace.h @@ -39,7 +39,7 @@ public: const char *Msg) : S(S), TheDecl(D), Loc(Loc), Message(Msg) {} - virtual void print(raw_ostream &OS) const; + void print(raw_ostream &OS) const override; }; } diff --git a/contrib/llvm/tools/clang/include/clang/Sema/Scope.h b/contrib/llvm/tools/clang/include/clang/Sema/Scope.h index 249a4c7..8e4e2ef 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/Scope.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/Scope.h @@ -15,13 +15,21 @@ #define LLVM_CLANG_SEMA_SCOPE_H #include "clang/Basic/Diagnostic.h" +#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +namespace llvm { + +class raw_ostream; + +} + namespace clang { class Decl; class UsingDirectiveDecl; +class VarDecl; /// Scope - A scope is a transient data structure that is used while parsing the /// program. It assists with resolving identifiers to the appropriate @@ -93,21 +101,47 @@ public: /// \brief This is the scope for a function-level C++ try or catch scope. FnTryCatchScope = 0x4000, - /// \brief This is the scope of OpenMP executable directive - OpenMPDirectiveScope = 0x8000 + /// \brief This is the scope of OpenMP executable directive. + OpenMPDirectiveScope = 0x8000, + + /// \brief This is the scope of some OpenMP loop directive. + OpenMPLoopDirectiveScope = 0x10000, + + /// \brief This is the scope of some OpenMP simd directive. + /// For example, it is used for 'omp simd', 'omp for simd'. + /// This flag is propagated to children scopes. + OpenMPSimdDirectiveScope = 0x20000, + + /// This scope corresponds to an enum. + EnumScope = 0x40000, + + /// This scope corresponds to a SEH try. + SEHTryScope = 0x80000, }; private: /// The parent scope for this scope. This is null for the translation-unit /// scope. Scope *AnyParent; + /// Flags - This contains a set of ScopeFlags, which indicates how the scope + /// interrelates with other control flow statements. + unsigned Flags; + /// Depth - This is the depth of this scope. The translation-unit scope has /// depth 0. unsigned short Depth; - /// Flags - This contains a set of ScopeFlags, which indicates how the scope - /// interrelates with other control flow statements. - unsigned short Flags; + /// \brief Declarations with static linkage are mangled with the number of + /// scopes seen as a component. + unsigned short MSLocalManglingNumber; + + /// \brief SEH __try blocks get uniquely numbered within a function. This + /// variable holds the index for an SEH try block. + short SEHTryIndex; + + /// \brief SEH __try blocks get uniquely numbered within a function. This + /// variable holds the next free index at a function's scope. + short SEHTryIndexPool; /// PrototypeDepth - This is the number of function prototype scopes /// enclosing this scope, including this scope. @@ -120,6 +154,8 @@ private: /// FnParent - If this scope has a parent scope that is a function body, this /// pointer is non-null and points to it. This is used for label processing. Scope *FnParent; + Scope *MSLocalManglingParent; + Scope *SEHTryParent; /// BreakParent/ContinueParent - This is a direct link to the innermost /// BreakScope/ContinueScope which contains the contents of this scope @@ -156,7 +192,11 @@ private: /// \brief Used to determine if errors occurred in this scope. DiagnosticErrorTrap ErrorTrap; - + + /// A lattice consisting of undefined, a single NRVO candidate variable in + /// this scope, or over-defined. The bit is true when over-defined. + llvm::PointerIntPair<VarDecl *, 1, bool> NRVO; + public: Scope(Scope *Parent, unsigned ScopeFlags, DiagnosticsEngine &Diag) : ErrorTrap(Diag) { @@ -181,6 +221,11 @@ public: const Scope *getFnParent() const { return FnParent; } Scope *getFnParent() { return FnParent; } + const Scope *getMSLocalManglingParent() const { + return MSLocalManglingParent; + } + Scope *getMSLocalManglingParent() { return MSLocalManglingParent; } + /// getContinueParent - Return the closest scope that a continue statement /// would be affected by. Scope *getContinueParent() { @@ -219,10 +264,11 @@ public: return PrototypeIndex++; } - typedef DeclSetTy::iterator decl_iterator; - decl_iterator decl_begin() const { return DeclsInScope.begin(); } - decl_iterator decl_end() const { return DeclsInScope.end(); } - bool decl_empty() const { return DeclsInScope.empty(); } + typedef llvm::iterator_range<DeclSetTy::iterator> decl_range; + decl_range decls() const { + return decl_range(DeclsInScope.begin(), DeclsInScope.end()); + } + bool decl_empty() const { return DeclsInScope.empty(); } void AddDecl(Decl *D) { DeclsInScope.insert(D); @@ -232,6 +278,30 @@ public: DeclsInScope.erase(D); } + void incrementMSLocalManglingNumber() { + if (Scope *MSLMP = getMSLocalManglingParent()) + MSLMP->MSLocalManglingNumber += 1; + } + + void decrementMSLocalManglingNumber() { + if (Scope *MSLMP = getMSLocalManglingParent()) + MSLMP->MSLocalManglingNumber -= 1; + } + + unsigned getMSLocalManglingNumber() const { + if (const Scope *MSLMP = getMSLocalManglingParent()) + return MSLMP->MSLocalManglingNumber; + return 1; + } + + int getSEHTryIndex() { + return SEHTryIndex; + } + + int getSEHTryParentIndex() const { + return SEHTryParent ? SEHTryParent->SEHTryIndex : -1; + } + /// isDeclScope - Return true if this is the scope that the specified decl is /// declared in. bool isDeclScope(Decl *D) { @@ -273,6 +343,18 @@ public: return false; } + /// isInObjcMethodOuterScope - Return true if this scope is an + /// Objective-C method outer most body. + bool isInObjcMethodOuterScope() const { + if (const Scope *S = this) { + // If this scope is an objc method scope, then we succeed. + if (S->getFlags() & ObjCMethodScope) + return true; + } + return false; + } + + /// isTemplateParamScope - Return true if this scope is a C++ /// template parameter scope. bool isTemplateParamScope() const { @@ -309,39 +391,81 @@ public: return (getFlags() & Scope::OpenMPDirectiveScope); } + /// \brief Determine whether this scope is some OpenMP loop directive scope + /// (for example, 'omp for', 'omp simd'). + bool isOpenMPLoopDirectiveScope() const { + if (getFlags() & Scope::OpenMPLoopDirectiveScope) { + assert(isOpenMPDirectiveScope() && + "OpenMP loop directive scope is not a directive scope"); + return true; + } + return false; + } + + /// \brief Determine whether this scope is (or is nested into) some OpenMP + /// loop simd directive scope (for example, 'omp simd', 'omp for simd'). + bool isOpenMPSimdDirectiveScope() const { + return getFlags() & Scope::OpenMPSimdDirectiveScope; + } + + /// \brief Determine whether this scope is a loop having OpenMP loop + /// directive attached. + bool isOpenMPLoopScope() const { + const Scope *P = getParent(); + return P && P->isOpenMPLoopDirectiveScope(); + } + /// \brief Determine whether this scope is a C++ 'try' block. bool isTryScope() const { return getFlags() & Scope::TryScope; } + /// \brief Determine whether this scope is a SEH '__try' block. + bool isSEHTryScope() const { return getFlags() & Scope::SEHTryScope; } + /// containedInPrototypeScope - Return true if this or a parent scope /// is a FunctionPrototypeScope. bool containedInPrototypeScope() const; - typedef UsingDirectivesTy::iterator udir_iterator; - typedef UsingDirectivesTy::const_iterator const_udir_iterator; - void PushUsingDirective(UsingDirectiveDecl *UDir) { UsingDirectives.push_back(UDir); } - udir_iterator using_directives_begin() { - return UsingDirectives.begin(); - } + typedef llvm::iterator_range<UsingDirectivesTy::iterator> + using_directives_range; - udir_iterator using_directives_end() { - return UsingDirectives.end(); + using_directives_range using_directives() { + return using_directives_range(UsingDirectives.begin(), + UsingDirectives.end()); } - const_udir_iterator using_directives_begin() const { - return UsingDirectives.begin(); + void addNRVOCandidate(VarDecl *VD) { + if (NRVO.getInt()) + return; + if (NRVO.getPointer() == nullptr) { + NRVO.setPointer(VD); + return; + } + if (NRVO.getPointer() != VD) + setNoNRVO(); } - const_udir_iterator using_directives_end() const { - return UsingDirectives.end(); + void setNoNRVO() { + NRVO.setInt(1); + NRVO.setPointer(nullptr); } + void mergeNRVOIntoParent(); + /// Init - This is used by the parser to implement scope caching. /// void Init(Scope *parent, unsigned flags); + + /// \brief Sets up the specified scope flags and adjusts the scope state + /// variables accordingly. + /// + void AddFlags(unsigned Flags); + + void dumpImpl(raw_ostream &OS) const; + void dump() const; }; } // end namespace clang diff --git a/contrib/llvm/tools/clang/include/clang/Sema/ScopeInfo.h b/contrib/llvm/tools/clang/include/clang/Sema/ScopeInfo.h index 06afe1a..63427aa 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/ScopeInfo.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/ScopeInfo.h @@ -110,6 +110,21 @@ public: /// with \c __attribute__((objc_requires_super)). bool ObjCShouldCallSuper; + /// True when this is a method marked as a designated initializer. + bool ObjCIsDesignatedInit; + /// This starts true for a method marked as designated initializer and will + /// be set to false if there is an invocation to a designated initializer of + /// the super class. + bool ObjCWarnForNoDesignatedInitChain; + + /// True when this is an initializer method not marked as a designated + /// initializer within a class that has at least one initializer marked as a + /// designated initializer. + bool ObjCIsSecondaryInit; + /// This starts true for a secondary initializer method and will be set to + /// false if there is an invocation of an initializer on 'self'. + bool ObjCWarnForNoInitDelegation; + /// \brief Used to determine if errors occurred in this function or block. DiagnosticErrorTrap ErrorTrap; @@ -318,6 +333,10 @@ public: HasIndirectGoto(false), HasDroppedStmt(false), ObjCShouldCallSuper(false), + ObjCIsDesignatedInit(false), + ObjCWarnForNoDesignatedInitChain(false), + ObjCIsSecondaryInit(false), + ObjCWarnForNoInitDelegation(false), ErrorTrap(Diag) { } virtual ~FunctionScopeInfo(); @@ -386,7 +405,7 @@ public: enum IsThisCapture { ThisCapture }; Capture(IsThisCapture, bool IsNested, SourceLocation Loc, QualType CaptureType, Expr *Cpy) - : VarAndNested(0, IsNested), + : VarAndNested(nullptr, IsNested), InitExprAndCaptureKind(Cpy, Cap_This), Loc(Loc), EllipsisLoc(), CaptureType(CaptureType) {} @@ -644,10 +663,10 @@ public: SourceLocation PotentialThisCaptureLocation; LambdaScopeInfo(DiagnosticsEngine &Diag) - : CapturingScopeInfo(Diag, ImpCap_None), Lambda(0), - CallOperator(0), NumExplicitCaptures(0), Mutable(false), + : CapturingScopeInfo(Diag, ImpCap_None), Lambda(nullptr), + CallOperator(nullptr), NumExplicitCaptures(0), Mutable(false), ExprNeedsCleanups(false), ContainsUnexpandedParameterPack(false), - AutoTemplateParameterDepth(0), GLTemplateParameterList(0) + AutoTemplateParameterDepth(0), GLTemplateParameterList(nullptr) { Kind = SK_Lambda; } @@ -708,10 +727,10 @@ public: /// act of analyzing the enclosing full expression (ActOnFinishFullExpr) /// if we can determine that the full expression is not instantiation- /// dependent, then we can entirely avoid its capture. - ///
- /// const int n = 0;
- /// [&] (auto x) {
- /// (void)+n + x;
+ /// + /// const int n = 0; + /// [&] (auto x) { + /// (void)+n + x; /// }; /// Interestingly, this strategy would involve a capture of n, even though /// it's obviously not odr-used here, because the full-expression is @@ -725,12 +744,12 @@ public: /// Before anyone is tempted to implement a strategy for not-capturing 'n', /// consider the insightful warning in: /// /cfe-commits/Week-of-Mon-20131104/092596.html - /// "The problem is that the set of captures for a lambda is part of the ABI
- /// (since lambda layout can be made visible through inline functions and the
- /// like), and there are no guarantees as to which cases we'll manage to build
- /// an lvalue-to-rvalue conversion in, when parsing a template -- some
- /// seemingly harmless change elsewhere in Sema could cause us to start or stop
- /// building such a node. So we need a rule that anyone can implement and get
+ /// "The problem is that the set of captures for a lambda is part of the ABI + /// (since lambda layout can be made visible through inline functions and the + /// like), and there are no guarantees as to which cases we'll manage to build + /// an lvalue-to-rvalue conversion in, when parsing a template -- some + /// seemingly harmless change elsewhere in Sema could cause us to start or stop + /// building such a node. So we need a rule that anyone can implement and get /// exactly the same result". /// void markVariableExprAsNonODRUsed(Expr *CapturingVarExpr) { @@ -738,7 +757,7 @@ public: || isa<MemberExpr>(CapturingVarExpr)); NonODRUsedCapturingExprs.insert(CapturingVarExpr); } - bool isVariableExprMarkedAsNonODRUsed(Expr *CapturingVarExpr) { + bool isVariableExprMarkedAsNonODRUsed(Expr *CapturingVarExpr) const { assert(isa<DeclRefExpr>(CapturingVarExpr) || isa<MemberExpr>(CapturingVarExpr)); return NonODRUsedCapturingExprs.count(CapturingVarExpr); @@ -761,16 +780,14 @@ public: return getNumPotentialVariableCaptures() || PotentialThisCaptureLocation.isValid(); } - - // When passed the index, returns the VarDecl and Expr associated + + // When passed the index, returns the VarDecl and Expr associated // with the index. - void getPotentialVariableCapture(unsigned Idx, VarDecl *&VD, Expr *&E); - + void getPotentialVariableCapture(unsigned Idx, VarDecl *&VD, Expr *&E) const; }; - FunctionScopeInfo::WeakObjectProfileTy::WeakObjectProfileTy() - : Base(0, false), Property(0) {} + : Base(nullptr, false), Property(nullptr) {} FunctionScopeInfo::WeakObjectProfileTy FunctionScopeInfo::WeakObjectProfileTy::getSentinel() { diff --git a/contrib/llvm/tools/clang/include/clang/Sema/Sema.h b/contrib/llvm/tools/clang/include/clang/Sema/Sema.h index 48794d6..e254afd 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/Sema.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/Sema.h @@ -26,11 +26,11 @@ #include "clang/AST/TypeLoc.h" #include "clang/Basic/ExpressionTraits.h" #include "clang/Basic/LangOptions.h" +#include "clang/Basic/Module.h" #include "clang/Basic/OpenMPKinds.h" #include "clang/Basic/Specifiers.h" #include "clang/Basic/TemplateKinds.h" #include "clang/Basic/TypeTraits.h" -#include "clang/Lex/ModuleLoader.h" #include "clang/Sema/AnalysisBasedWarnings.h" #include "clang/Sema/DeclSpec.h" #include "clang/Sema/ExternalSemaSource.h" @@ -38,17 +38,18 @@ #include "clang/Sema/LocInfoType.h" #include "clang/Sema/ObjCMethodList.h" #include "clang/Sema/Ownership.h" +#include "clang/Sema/Scope.h" #include "clang/Sema/ScopeInfo.h" #include "clang/Sema/TypoCorrection.h" #include "clang/Sema/Weak.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/MC/MCParser/MCAsmParser.h" +#include "llvm/ADT/TinyPtrVector.h" #include <deque> +#include <memory> #include <string> #include <vector> @@ -57,6 +58,7 @@ namespace llvm { template <typename ValueT> struct DenseMapInfo; template <typename ValueT, typename ValueInfoT> class DenseSet; class SmallBitVector; + class InlineAsmIdentifierInfo; } namespace clang { @@ -101,6 +103,7 @@ namespace clang { class DependentDiagnostic; class DesignatedInitExpr; class Designation; + class EnableIfAttr; class EnumConstantDecl; class Expr; class ExtVectorType; @@ -122,6 +125,8 @@ namespace clang { class LocalInstantiationScope; class LookupResult; class MacroInfo; + typedef ArrayRef<std::pair<IdentifierInfo *, SourceLocation>> ModuleIdPath; + class ModuleLoader; class MultiLevelTemplateArgumentList; class NamedDecl; class NonNullAttr; @@ -152,7 +157,6 @@ namespace clang { class Stmt; class StringLiteral; class SwitchStmt; - class TargetAttributesSema; class TemplateArgument; class TemplateArgumentList; class TemplateArgumentLoc; @@ -204,7 +208,6 @@ typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType*, NamedDecl*>, class Sema { Sema(const Sema &) LLVM_DELETED_FUNCTION; void operator=(const Sema &) LLVM_DELETED_FUNCTION; - mutable const TargetAttributesSema* TheTargetAttributesSema; ///\brief Source of additional semantic information. ExternalSemaSource *ExternalSource; @@ -263,9 +266,82 @@ public: bool MSStructPragmaOn; // True when \#pragma ms_struct on + /// \brief Controls member pointer representation format under the MS ABI. + LangOptions::PragmaMSPointersToMembersKind + MSPointerToMemberRepresentationMethod; + + enum PragmaVtorDispKind { + PVDK_Push, ///< #pragma vtordisp(push, mode) + PVDK_Set, ///< #pragma vtordisp(mode) + PVDK_Pop, ///< #pragma vtordisp(pop) + PVDK_Reset ///< #pragma vtordisp() + }; + + enum PragmaMsStackAction { + PSK_Reset, // #pragma () + PSK_Set, // #pragma ("name") + PSK_Push, // #pragma (push[, id]) + PSK_Push_Set, // #pragma (push[, id], "name") + PSK_Pop, // #pragma (pop[, id]) + PSK_Pop_Set, // #pragma (pop[, id], "name") + }; + + /// \brief Whether to insert vtordisps prior to virtual bases in the Microsoft + /// C++ ABI. Possible values are 0, 1, and 2, which mean: + /// + /// 0: Suppress all vtordisps + /// 1: Insert vtordisps in the presence of vbase overrides and non-trivial + /// structors + /// 2: Always insert vtordisps to support RTTI on partially constructed + /// objects + /// + /// The stack always has at least one element in it. + SmallVector<MSVtorDispAttr::Mode, 2> VtorDispModeStack; + + /// \brief Source location for newly created implicit MSInheritanceAttrs + SourceLocation ImplicitMSInheritanceAttrLoc; + + template<typename ValueType> + struct PragmaStack { + struct Slot { + llvm::StringRef StackSlotLabel; + ValueType Value; + SourceLocation PragmaLocation; + Slot(llvm::StringRef StackSlotLabel, + ValueType Value, + SourceLocation PragmaLocation) + : StackSlotLabel(StackSlotLabel), Value(Value), + PragmaLocation(PragmaLocation) {} + }; + void Act(SourceLocation PragmaLocation, + PragmaMsStackAction Action, + llvm::StringRef StackSlotLabel, + ValueType Value); + explicit PragmaStack(const ValueType &Value) + : CurrentValue(Value) {} + SmallVector<Slot, 2> Stack; + ValueType CurrentValue; + SourceLocation CurrentPragmaLocation; + }; + // FIXME: We should serialize / deserialize these if they occur in a PCH (but + // we shouldn't do so if they're in a module). + PragmaStack<StringLiteral *> DataSegStack; + PragmaStack<StringLiteral *> BSSSegStack; + PragmaStack<StringLiteral *> ConstSegStack; + PragmaStack<StringLiteral *> CodeSegStack; + + /// Last section used with #pragma init_seg. + StringLiteral *CurInitSeg; + SourceLocation CurInitSegLoc; + /// VisContext - Manages the stack for \#pragma GCC visibility. void *VisContext; // Really a "PragmaVisStack*" + /// \brief This represents the last location of a "#pragma clang optimize off" + /// directive if such a directive has not been closed by an "on" yet. If + /// optimizations are currently "on", this is set to an invalid location. + SourceLocation OptimizeOffPragmaLocation; + /// \brief Flag indicating if Sema is building a recovery call expression. /// /// This flag is used to avoid building recovery call expressions @@ -307,7 +383,7 @@ public: ExtVectorDeclsType ExtVectorDecls; /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes. - OwningPtr<CXXFieldCollector> FieldCollector; + std::unique_ptr<CXXFieldCollector> FieldCollector; typedef llvm::SmallSetVector<const NamedDecl*, 16> NamedDeclSetType; @@ -319,7 +395,7 @@ public: /// PureVirtualClassDiagSet - a set of class declarations which we have /// emitted a list of pure virtual functions. Used to prevent emitting the /// same list more than once. - OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet; + std::unique_ptr<RecordDeclSetTy> PureVirtualClassDiagSet; /// ParsingInitForAutoVars - a set of declarations with auto types for which /// we are currently parsing the initializer. @@ -426,13 +502,13 @@ public: sema::DelayedDiagnosticPool *CurPool; public: - DelayedDiagnostics() : CurPool(0) {} + DelayedDiagnostics() : CurPool(nullptr) {} /// Adds a delayed diagnostic. void add(const sema::DelayedDiagnostic &diag); // in DelayedDiagnostic.h /// Determines whether diagnostics should be delayed. - bool shouldDelayDiagnostics() { return CurPool != 0; } + bool shouldDelayDiagnostics() { return CurPool != nullptr; } /// Returns the current delayed-diagnostics pool. sema::DelayedDiagnosticPool *getCurrentPool() const { @@ -460,13 +536,13 @@ public: DelayedDiagnosticsState pushUndelayed() { DelayedDiagnosticsState state; state.SavedPool = CurPool; - CurPool = 0; + CurPool = nullptr; return state; } /// Undo a previous pushUndelayed(). void popUndelayed(DelayedDiagnosticsState state) { - assert(CurPool == NULL); + assert(CurPool == nullptr); CurPool = state.SavedPool; } } DelayedDiagnostics; @@ -480,13 +556,15 @@ public: QualType SavedCXXThisTypeOverride; public: - ContextRAII(Sema &S, DeclContext *ContextToPush) + ContextRAII(Sema &S, DeclContext *ContextToPush, bool NewThisContext = true) : S(S), SavedContext(S.CurContext), SavedContextState(S.DelayedDiagnostics.pushUndelayed()), SavedCXXThisTypeOverride(S.CXXThisTypeOverride) { assert(ContextToPush && "pushing null context"); S.CurContext = ContextToPush; + if (NewThisContext) + S.CXXThisTypeOverride = QualType(); } void pop() { @@ -494,7 +572,7 @@ public: S.CurContext = SavedContext; S.DelayedDiagnostics.popUndelayed(SavedContextState); S.CXXThisTypeOverride = SavedCXXThisTypeOverride; - SavedContext = 0; + SavedContext = nullptr; } ~ContextRAII() { @@ -569,7 +647,7 @@ public: RecordDecl *MSVCGuidDecl; /// \brief Caches identifiers/selectors for NSFoundation APIs. - OwningPtr<NSAPI> NSAPIObj; + std::unique_ptr<NSAPI> NSAPIObj; /// \brief The declaration of the Objective-C NSNumber class. ObjCInterfaceDecl *NSNumberDecl; @@ -772,7 +850,7 @@ public: /// \brief The number of SFINAE diagnostics that have been trapped. unsigned NumSFINAEErrors; - typedef llvm::DenseMap<ParmVarDecl *, SmallVector<ParmVarDecl *, 1> > + typedef llvm::DenseMap<ParmVarDecl *, llvm::TinyPtrVector<ParmVarDecl *>> UnparsedDefaultArgInstantiationsMap; /// \brief A mapping from parameters with unparsed default arguments to the @@ -833,6 +911,7 @@ public: /// Private Helper predicate to check for 'self'. bool isSelfExpr(Expr *RExpr); + bool isSelfExpr(Expr *RExpr, const ObjCMethodDecl *Method); /// \brief Cause the active diagnostic on the DiagosticsEngine to be /// emitted. This is closely coupled to the SemaDiagnosticBuilder class and @@ -853,13 +932,12 @@ public: bool OldFPContractState : 1; }; - typedef llvm::MCAsmParserSemaCallback::InlineAsmIdentifierInfo - InlineAsmIdentifierInfo; + void addImplicitTypedef(StringRef Name, QualType T); public: Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind = TU_Complete, - CodeCompleteConsumer *CompletionConsumer = 0); + CodeCompleteConsumer *CompletionConsumer = nullptr); ~Sema(); /// \brief Perform initialization that occurs after the parser has been @@ -872,7 +950,6 @@ public: DiagnosticsEngine &getDiagnostics() const { return Diags; } SourceManager &getSourceManager() const { return SourceMgr; } - const TargetAttributesSema &getTargetAttributesSema() const; Preprocessor &getPreprocessor() const { return PP; } ASTContext &getASTContext() const { return Context; } ASTConsumer &getASTConsumer() const { return Consumer; } @@ -954,9 +1031,11 @@ public: getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const; std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const; - ExprResult Owned(Expr* E) { return E; } - ExprResult Owned(ExprResult R) { return R; } - StmtResult Owned(Stmt* S) { return S; } + /// \brief Calls \c Lexer::getLocForEndOfToken() + SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset = 0); + + /// \brief Retrieve the module loader associated with the preprocessor. + ModuleLoader &getModuleLoader() const; void ActOnEndOfTranslationUnit(); @@ -967,7 +1046,7 @@ public: void PushFunctionScope(); void PushBlockScope(Scope *BlockScope, BlockDecl *Block); sema::LambdaScopeInfo *PushLambdaScope(); - + /// \brief This is used to inform Sema what the current TemplateParameterDepth /// is during Parsing. Currently it is used to pass on the depth /// when parsing generic lambda 'auto' parameters. @@ -976,13 +1055,27 @@ public: void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K); - void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP =0, - const Decl *D = 0, const BlockExpr *blkExpr = 0); + void + PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP = nullptr, + const Decl *D = nullptr, + const BlockExpr *blkExpr = nullptr); sema::FunctionScopeInfo *getCurFunction() const { return FunctionScopes.back(); } + sema::FunctionScopeInfo *getEnclosingFunction() const { + if (FunctionScopes.empty()) + return nullptr; + + for (int e = FunctionScopes.size()-1; e >= 0; --e) { + if (isa<sema::BlockScopeInfo>(FunctionScopes[e])) + continue; + return FunctionScopes[e]; + } + return nullptr; + } + template <typename ExprT> void recordUseOfEvaluatedWeak(const ExprT *E, bool IsRead=true) { if (!isUnevaluatedContext()) @@ -1018,9 +1111,9 @@ public: // QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, - const DeclSpec *DS = 0); + const DeclSpec *DS = nullptr); QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVRA, - const DeclSpec *DS = 0); + const DeclSpec *DS = nullptr); QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity); QualType BuildReferenceType(QualType T, bool LValueRef, @@ -1061,7 +1154,7 @@ public: /// unqualified type will always be a FunctionProtoType. /// Otherwise, returns a NULL type. QualType BuildFunctionType(QualType T, - llvm::MutableArrayRef<QualType> ParamTypes, + MutableArrayRef<QualType> ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI); @@ -1082,10 +1175,13 @@ public: ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo); DeclarationNameInfo GetNameForDeclarator(Declarator &D); DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name); - static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo = 0); + static QualType GetTypeFromParser(ParsedType Ty, + TypeSourceInfo **TInfo = nullptr); CanThrowResult canThrow(const Expr *E); const FunctionProtoType *ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT); + void UpdateExceptionSpec(FunctionDecl *FD, + const FunctionProtoType::ExtProtoInfo &EPI); bool CheckSpecifiedExceptionType(QualType &T, const SourceRange &Range); bool CheckDistantExceptionSpec(QualType T); bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New); @@ -1096,8 +1192,8 @@ public: const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID, const FunctionProtoType *Old, SourceLocation OldLoc, const FunctionProtoType *New, SourceLocation NewLoc, - bool *MissingExceptionSpecification = 0, - bool *MissingEmptyExceptionSpecification = 0, + bool *MissingExceptionSpecification = nullptr, + bool *MissingEmptyExceptionSpecification = nullptr, bool AllowNoexceptAllMatchWithNoSpec = false, bool IsOperatorNew = false); bool CheckExceptionSpecSubset( @@ -1148,7 +1244,7 @@ public: public: BoundTypeDiagnoser1(unsigned DiagID, const T1 &Arg1) : TypeDiagnoser(DiagID == 0), DiagID(DiagID), Arg1(Arg1) { } - virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) { + void diagnose(Sema &S, SourceLocation Loc, QualType T) override { if (Suppressed) return; S.Diag(Loc, DiagID) << getPrintable(Arg1) << T; } @@ -1168,7 +1264,7 @@ public: : TypeDiagnoser(DiagID == 0), DiagID(DiagID), Arg1(Arg1), Arg2(Arg2) { } - virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) { + void diagnose(Sema &S, SourceLocation Loc, QualType T) override { if (Suppressed) return; S.Diag(Loc, DiagID) << getPrintable(Arg1) << getPrintable(Arg2) << T; } @@ -1189,7 +1285,7 @@ public: : TypeDiagnoser(DiagID == 0), DiagID(DiagID), Arg1(Arg1), Arg2(Arg2), Arg3(Arg3) { } - virtual void diagnose(Sema &S, SourceLocation Loc, QualType T) { + void diagnose(Sema &S, SourceLocation Loc, QualType T) override { if (Suppressed) return; S.Diag(Loc, DiagID) << getPrintable(Arg1) << getPrintable(Arg2) << getPrintable(Arg3) << T; @@ -1299,33 +1395,36 @@ public: /// function to pin them on. ActOnFunctionDeclarator reads this list and patches /// them into the FunctionDecl. std::vector<NamedDecl*> DeclsInPrototypeScope; - /// Nonzero if we are currently parsing a function declarator. This is a counter - /// as opposed to a boolean so we can deal with nested function declarators - /// such as: - /// void f(void (*g)(), ...) - unsigned InFunctionDeclarator; - DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = 0); + DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType = nullptr); void DiagnoseUseOfUnimplementedSelectors(); bool isSimpleTypeSpecifier(tok::TokenKind Kind) const; ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, - Scope *S, CXXScopeSpec *SS = 0, + Scope *S, CXXScopeSpec *SS = nullptr, bool isClassName = false, bool HasTrailingDot = false, ParsedType ObjectType = ParsedType(), bool IsCtorOrDtorName = false, bool WantNontrivialTypeSourceInfo = false, - IdentifierInfo **CorrectedII = 0); + IdentifierInfo **CorrectedII = nullptr); TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S); bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S); - bool DiagnoseUnknownTypeName(IdentifierInfo *&II, + void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, - ParsedType &SuggestedType); + ParsedType &SuggestedType, + bool AllowClassTemplates = false); + + /// \brief For compatibility with MSVC, we delay parsing of some default + /// template type arguments until instantiation time. Emits a warning and + /// returns a synthesized DependentNameType that isn't really dependent on any + /// other template arguments. + ParsedType ActOnDelayedDefaultTemplateArg(const IdentifierInfo &II, + SourceLocation NameLoc); /// \brief Describes the result of the name lookup and resolution performed /// by \c ClassifyName(). @@ -1450,7 +1549,7 @@ public: SourceLocation NameLoc, const Token &NextToken, bool IsAddressOfOperand, - CorrectionCandidateCallback *CCC = 0); + CorrectionCandidateCallback *CCC = nullptr); Decl *ActOnDeclarator(Scope *S, Declarator &D); @@ -1461,6 +1560,14 @@ public: bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc); + void + diagnoseIgnoredQualifiers(unsigned DiagID, unsigned Quals, + SourceLocation FallbackLoc, + SourceLocation ConstQualLoc = SourceLocation(), + SourceLocation VolatileQualLoc = SourceLocation(), + SourceLocation RestrictQualLoc = SourceLocation(), + SourceLocation AtomicQualLoc = SourceLocation()); + static bool adjustContextForLocalExternDecl(DeclContext *&DC); void DiagnoseFunctionSpecifiers(const DeclSpec &DS); void CheckShadow(Scope *S, VarDecl *D, const LookupResult& R); @@ -1482,8 +1589,6 @@ public: void CheckVariableDeclarationType(VarDecl *NewVD); void CheckCompleteVariableDeclaration(VarDecl *var); void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D); - void ActOnStartFunctionDeclarator(); - void ActOnEndFunctionDeclarator(); NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, TypeSourceInfo *TInfo, @@ -1491,7 +1596,6 @@ public: MultiTemplateParamsArg TemplateParamLists, bool &AddToScope); bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD); - void checkVoidParamDecl(ParmVarDecl *Param); bool CheckConstexprFunctionDecl(const FunctionDecl *FD); bool CheckConstexprFunctionBody(const FunctionDecl *FD, Stmt *Body); @@ -1521,7 +1625,7 @@ public: void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc); - void ActOnParamDefaultArgumentError(Decl *param); + void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc); bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc); @@ -1530,12 +1634,16 @@ public: void ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto); void ActOnInitializerError(Decl *Dcl); void ActOnCXXForRangeDecl(Decl *D); + StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, + IdentifierInfo *Ident, + ParsedAttributes &Attrs, + SourceLocation AttrEnd); void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc); void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc); void FinalizeDeclaration(Decl *D); DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef<Decl *> Group); - DeclGroupPtrTy BuildDeclaratorGroup(llvm::MutableArrayRef<Decl *> Group, + DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef<Decl *> Group, bool TypeMayContainAuto = true); /// Should be called on all declarations that might have attached @@ -1547,7 +1655,7 @@ public: SourceLocation LocAfterDecls); void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition = - 0); + nullptr); Decl *ActOnStartOfFunctionDef(Scope *S, Declarator &D); Decl *ActOnStartOfFunctionDef(Scope *S, Decl *D); void ActOnStartOfObjCMethodDef(Scope *S, Decl *D); @@ -1555,6 +1663,16 @@ public: return D && isa<ObjCMethodDecl>(D); } + /// \brief Determine whether we can delay parsing the body of a function or + /// function template until it is used, assuming we don't care about emitting + /// code for that function. + /// + /// This will be \c false if we may need the body of the function in the + /// middle of parsing an expression (where it's impractical to switch to + /// parsing a different function), for instance, if it's constexpr in C++11 + /// or has an 'auto' return type in C++14. These cases are essentially bugs. + bool canDelayFunctionBody(const Declarator &D); + /// \brief Determine whether we can skip parsing the body of a function /// definition, assuming we don't care about analyzing its body or emitting /// code for that function. @@ -1568,6 +1686,7 @@ public: Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body); Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation); Decl *ActOnSkippedFunctionBody(Decl *Decl); + void ActOnFinishInlineMethodDef(CXXMethodDecl *D); /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an /// attribute for which parsing is delayed. @@ -1611,12 +1730,13 @@ public: void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod); /// \brief Create an implicit import of the given module at the given - /// source location. + /// source location, for error recovery, if possible. /// - /// This routine is typically used for error recovery, when the entity found - /// by name lookup is actually hidden within a module that we know about but - /// the user has forgotten to import. - void createImplicitModuleImport(SourceLocation Loc, Module *Mod); + /// This routine is typically used when an entity found by name lookup + /// is actually hidden within a module that we know about but the user + /// has forgotten to import. + void createImplicitModuleImportForErrorRecovery(SourceLocation Loc, + Module *Mod); /// \brief Retrieve a suitable printing policy. PrintingPolicy getPrintingPolicy() const { @@ -1640,7 +1760,8 @@ public: Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, - RecordDecl *Record); + RecordDecl *Record, + const PrintingPolicy &Policy); Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record); @@ -1665,7 +1786,8 @@ public: MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, - bool ScopedEnumUsesClassTag, TypeResult UnderlyingType); + bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, + bool IsTypeSpecifier); Decl *ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, @@ -1706,7 +1828,7 @@ public: InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, - Declarator *D = 0); + Declarator *D = nullptr); bool CheckNontrivialField(FieldDecl *FD); void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM); @@ -1823,11 +1945,11 @@ public: /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns /// true if 'D' belongs to the given declaration context. /// - /// \param ExplicitInstantiationOrSpecialization When true, we are checking - /// whether the declaration is in scope for the purposes of explicit template - /// instantiation or specialization. The default is false. - bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = 0, - bool ExplicitInstantiationOrSpecialization = false); + /// \param AllowInlineNamespace If \c true, allow the declaration to be in the + /// enclosing namespace set of the context, rather than contained + /// directly within it. + bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr, + bool AllowInlineNamespace = false); /// Finds the scope corresponding to the given decl context, if it /// happens to be an enclosing scope. Otherwise return NULL. @@ -1858,6 +1980,10 @@ public: unsigned AttrSpellingListIndex); DLLExportAttr *mergeDLLExportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex); + MSInheritanceAttr * + mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, + unsigned AttrSpellingListIndex, + MSInheritanceAttr::Spelling SemanticSpelling); FormatAttr *mergeFormatAttr(Decl *D, SourceRange Range, IdentifierInfo *Format, int FormatIdx, int FirstArg, unsigned AttrSpellingListIndex); @@ -1880,7 +2006,7 @@ public: void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK = AMK_Redeclaration); void MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls); - bool MergeFunctionDecl(FunctionDecl *New, Decl *Old, Scope *S, + bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S, bool MergeTypeWithOld); bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld); @@ -1951,9 +2077,9 @@ public: QualType &ConvertedType); bool IsBlockPointerConversion(QualType FromType, QualType ToType, QualType& ConvertedType); - bool FunctionArgTypesAreEqual(const FunctionProtoType *OldType, - const FunctionProtoType *NewType, - unsigned *ArgPos = 0); + bool FunctionParamTypesAreEqual(const FunctionProtoType *OldType, + const FunctionProtoType *NewType, + unsigned *ArgPos = nullptr); void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType); @@ -2067,10 +2193,10 @@ public: AllowScopedEnumerations(AllowScopedEnumerations) {} /// Match an integral or (possibly scoped) enumeration type. - bool match(QualType T); + bool match(QualType T) override; SemaDiagnosticBuilder - diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) { + diagnoseNoMatch(Sema &S, SourceLocation Loc, QualType T) override { return diagnoseNotInt(S, Loc, T); } @@ -2123,10 +2249,10 @@ public: bool PartialOverloading = false, bool AllowExplicit = false); void AddFunctionCandidates(const UnresolvedSetImpl &Functions, - ArrayRef<Expr *> Args, - OverloadCandidateSet& CandidateSet, - bool SuppressUserConversions = false, - TemplateArgumentListInfo *ExplicitTemplateArgs = 0); + ArrayRef<Expr *> Args, + OverloadCandidateSet &CandidateSet, + bool SuppressUserConversions = false, + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr); void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, @@ -2160,13 +2286,13 @@ public: CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet& CandidateSet, - bool AllowObjCConversionOnExplicit = false); + bool AllowObjCConversionOnExplicit); void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, OverloadCandidateSet &CandidateSet, - bool AllowObjCConversionOnExplicit = false); + bool AllowObjCConversionOnExplicit); void AddSurrogateCandidate(CXXConversionDecl *Conversion, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, @@ -2186,7 +2312,7 @@ public: SourceLocation OpLoc, ArrayRef<Expr *> Args, OverloadCandidateSet& CandidateSet); void AddArgumentDependentLookupCandidates(DeclarationName Name, - bool Operator, SourceLocation Loc, + SourceLocation Loc, ArrayRef<Expr *> Args, TemplateArgumentListInfo *ExplicitTemplateArgs, OverloadCandidateSet& CandidateSet, @@ -2199,6 +2325,11 @@ public: // identified by the expression Expr void NoteAllOverloadCandidates(Expr* E, QualType DestType = QualType()); + /// Check the enable_if expressions on the given function. Returns the first + /// failing attribute, or NULL if they were all successful. + EnableIfAttr *CheckEnableIf(FunctionDecl *Function, ArrayRef<Expr *> Args, + bool MissingImplicitThis = false); + // [PossiblyAFunctionType] --> [Return] // NonFunctionType --> NonFunctionType // R (A) --> R(A) @@ -2212,11 +2343,12 @@ public: QualType TargetType, bool Complain, DeclAccessPair &Found, - bool *pHadMultipleCandidates = 0); + bool *pHadMultipleCandidates = nullptr); - FunctionDecl *ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, - bool Complain = false, - DeclAccessPair* Found = 0); + FunctionDecl * + ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, + bool Complain = false, + DeclAccessPair *Found = nullptr); bool ResolveAndFixSingleFunctionTemplateSpecialization( ExprResult &SrcExpr, @@ -2302,7 +2434,7 @@ public: ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, - bool *NoArrowOperatorFound = 0); + bool *NoArrowOperatorFound = nullptr); /// CheckCallReturnType - Checks that a call expression's return type is /// complete. Returns true on failure. The location passed in is the location @@ -2468,6 +2600,9 @@ public: void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions); + void addOverloadedOperatorToUnresolvedSet(UnresolvedSetImpl &Functions, + DeclAccessPair Operator, + QualType T1, QualType T2); LabelDecl *LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc = SourceLocation()); @@ -2484,6 +2619,7 @@ public: bool RValueThis, unsigned ThisQuals); CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class); + bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id); LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef<QualType> ArgTys, bool AllowRaw, @@ -2491,10 +2627,8 @@ public: bool AllowStringTemplate); bool isKnownName(StringRef name); - void ArgumentDependentLookup(DeclarationName Name, bool Operator, - SourceLocation Loc, - ArrayRef<Expr *> Args, - ADLResult &Functions); + void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, + ArrayRef<Expr *> Args, ADLResult &Functions); void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, @@ -2503,13 +2637,19 @@ public: VisibleDeclConsumer &Consumer, bool IncludeGlobalScope = true); + enum CorrectTypoKind { + CTK_NonError, // CorrectTypo used in a non error recovery situation. + CTK_ErrorRecovery // CorrectTypo used in normal error recovery. + }; + TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, - DeclContext *MemberContext = 0, + CorrectTypoKind Mode, + DeclContext *MemberContext = nullptr, bool EnteringContext = false, - const ObjCObjectPointerType *OPT = 0, + const ObjCObjectPointerType *OPT = nullptr, bool RecordFailure = true); void diagnoseTypo(const TypoCorrection &Correction, @@ -2527,8 +2667,7 @@ public: AssociatedClassSet &AssociatedClasses); void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, - bool ConsiderLinkage, - bool ExplicitInstantiationOrSpecialization); + bool ConsiderLinkage, bool AllowInlineNamespace); void DiagnoseAmbiguousLookup(LookupResult &Result); //@} @@ -2557,11 +2696,14 @@ public: bool CheckRegparmAttr(const AttributeList &attr, unsigned &value); bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC, - const FunctionDecl *FD = 0); + const FunctionDecl *FD = nullptr); bool CheckNoReturnAttr(const AttributeList &attr); bool checkStringLiteralArgumentAttr(const AttributeList &Attr, unsigned ArgNum, StringRef &Str, - SourceLocation *ArgLocation = 0); + SourceLocation *ArgLocation = nullptr); + bool checkMSInheritanceAttrOnDefinition( + CXXRecordDecl *RD, SourceRange Range, bool BestCase, + MSInheritanceAttr::Spelling SemanticSpelling); void CheckAlignasUnderalignment(Decl *D); @@ -2570,6 +2712,11 @@ public: /// function type typedefs and typename template arguments. void adjustMemberFunctionCC(QualType &T, bool IsStatic); + // Check if there is an explicit attribute, but only look through parens. + // The intent is to look for an attribute on the current declarator, but not + // one that came from a typedef. + bool hasExplicitCallingConv(QualType &T); + /// Get the outermost AttributedType node that sets a calling convention. /// Valid types should not have multiple attributes with different CCs. const AttributedType *getCallingConvAttributedType(QualType T) const; @@ -2578,8 +2725,6 @@ public: StmtResult ProcessStmtAttributes(Stmt *Stmt, AttributeList *Attrs, SourceRange Range); - void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method, - bool &IncompleteImpl, unsigned DiagID); void WarnConflictingTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl); @@ -2597,15 +2742,6 @@ public: typedef llvm::SmallPtrSet<Selector, 8> SelectorSet; typedef llvm::DenseMap<Selector, ObjCMethodDecl*> ProtocolsMethodsMap; - /// CheckProtocolMethodDefs - This routine checks unimplemented - /// methods declared in protocol, and those referenced by it. - void CheckProtocolMethodDefs(SourceLocation ImpLoc, - ObjCProtocolDecl *PDecl, - bool& IncompleteImpl, - const SelectorSet &InsMap, - const SelectorSet &ClsMap, - ObjCContainerDecl *CDecl); - /// CheckImplementationIvars - This routine checks if the instance variables /// listed in the implelementation match those listed in the interface. void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, @@ -2621,7 +2757,8 @@ public: /// DiagnoseUnimplementedProperties - This routine warns on those properties /// which must be implemented by this implementation. void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, - ObjCContainerDecl *CDecl); + ObjCContainerDecl *CDecl, + bool SynthesizeProperties); /// DefaultSynthesizeProperties - This routine default synthesizes all /// properties which must be synthesized in the class's \@implementation. @@ -2629,12 +2766,6 @@ public: ObjCInterfaceDecl *IDecl); void DefaultSynthesizeProperties(Scope *S, Decl *D); - /// CollectImmediateProperties - This routine collects all properties in - /// the class and its conforming protocols; but not those it its super class. - void CollectImmediateProperties(ObjCContainerDecl *CDecl, - llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& PropMap, - llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& SuperPropMap); - /// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is /// an ivar synthesized for 'Method' and 'Method' is a property accessor /// declared in class 'IFace'. @@ -2643,7 +2774,8 @@ public: /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which /// backs the property is not used in the property's accessor. - void DiagnoseUnusedBackingIvarInAccessor(Scope *S); + void DiagnoseUnusedBackingIvarInAccessor(Scope *S, + const ObjCImplementationDecl *ImplD); /// GetIvarBackingPropertyAccessor - If method is a property setter/getter and /// it property has a backing ivar, returns this ivar; otherwise, returns NULL. @@ -2682,7 +2814,7 @@ public: const unsigned AttributesAsWritten, TypeSourceInfo *T, tok::ObjCKeywordKind MethodImplKind, - DeclContext *lexicalDC = 0); + DeclContext *lexicalDC = nullptr); /// AtomicPropertySetterGetterRules - This routine enforces the rule (via /// warning) when atomic property has one but not the other user-declared @@ -2692,6 +2824,10 @@ public: void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D); + void DiagnoseMissingDesignatedInitOverrides( + const ObjCImplementationDecl *ImplD, + const ObjCInterfaceDecl *IFD); + void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID); enum MethodMatchStrategy { @@ -2785,12 +2921,6 @@ public: const ObjCMethodDecl *SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType()); - - /// DiagnoseMismatchedMethodsInGlobalPool - This routine goes through list of - /// methods in global pool and issues diagnostic on identical selectors which - /// have mismathched types. - void DiagnoseMismatchedMethodsInGlobalPool(); - /// LookupImplementedMethodInGlobalPool - Returns the method which has an /// implementation. ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel); @@ -2805,7 +2935,7 @@ public: public: class FullExprArg { public: - FullExprArg(Sema &actions) : E(0) { } + FullExprArg(Sema &actions) : E(nullptr) { } // FIXME: The const_cast here is ugly. RValue references would make this // much nicer (or we could duplicate a bunch of the move semantics @@ -2836,13 +2966,13 @@ public: return MakeFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation()); } FullExprArg MakeFullExpr(Expr *Arg, SourceLocation CC) { - return FullExprArg(ActOnFinishFullExpr(Arg, CC).release()); + return FullExprArg(ActOnFinishFullExpr(Arg, CC).get()); } FullExprArg MakeFullDiscardedValueExpr(Expr *Arg) { ExprResult FE = ActOnFinishFullExpr(Arg, Arg ? Arg->getExprLoc() : SourceLocation(), /*DiscardedValue*/ true); - return FullExprArg(FE.release()); + return FullExprArg(FE.get()); } StmtResult ActOnExprStmt(ExprResult Arg); @@ -2957,15 +3087,23 @@ public: void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams); + typedef std::pair<StringRef, QualType> CapturedParamNameType; + void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, + CapturedRegionKind Kind, + ArrayRef<CapturedParamNameType> Params); StmtResult ActOnCapturedRegionEnd(Stmt *S); void ActOnCapturedRegionError(); RecordDecl *CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc, unsigned NumParams); - const VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E, - bool AllowFunctionParameters); - - StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp); + VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E, + bool AllowFunctionParameters); + bool isCopyElisionCandidate(QualType ReturnType, const VarDecl *VD, + bool AllowFunctionParameters); + + StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, + Scope *CurScope); + StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp); StmtResult ActOnCapScopeReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp); StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, @@ -2978,7 +3116,7 @@ public: ExprResult LookupInlineAsmIdentifier(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, - InlineAsmIdentifierInfo &Info, + llvm::InlineAsmIdentifierInfo &Info, bool IsUnevaluatedContext); bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc); @@ -3031,14 +3169,12 @@ public: StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ? SourceLocation TryLoc, Stmt *TryBlock, - Stmt *Handler); - - StmtResult ActOnSEHExceptBlock(SourceLocation Loc, - Expr *FilterExpr, + Stmt *Handler, int HandlerIndex, + int HandlerParentIndex); + StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block); - - StmtResult ActOnSEHFinallyBlock(SourceLocation Loc, - Stmt *Block); + StmtResult ActOnSEHFinallyBlock(SourceLocation Loc, Stmt *Block); + StmtResult ActOnSEHLeaveStmt(SourceLocation Loc, Scope *CurScope); void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock); @@ -3083,12 +3219,16 @@ public: void redelayDiagnostics(sema::DelayedDiagnosticPool &pool); - void EmitDeprecationWarning(NamedDecl *D, StringRef Message, - SourceLocation Loc, - const ObjCInterfaceDecl *UnknownObjCClass, - const ObjCPropertyDecl *ObjCProperty); + enum AvailabilityDiagnostic { AD_Deprecation, AD_Unavailable }; + + void EmitAvailabilityWarning(AvailabilityDiagnostic AD, + NamedDecl *D, StringRef Message, + SourceLocation Loc, + const ObjCInterfaceDecl *UnknownObjCClass, + const ObjCPropertyDecl *ObjCProperty, + bool ObjCPropertyAccess); - void HandleDelayedDeprecationCheck(sema::DelayedDiagnostic &DD, Decl *Ctx); + void HandleDelayedAvailabilityCheck(sema::DelayedDiagnostic &DD, Decl *Ctx); bool makeUnavailableInSystemHeader(SourceLocation loc, StringRef message); @@ -3098,7 +3238,8 @@ public: bool CanUseDecl(NamedDecl *D); bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, - const ObjCInterfaceDecl *UnknownObjCClass=0); + const ObjCInterfaceDecl *UnknownObjCClass=nullptr, + bool ObjCPropertyAccess=false); void NoteDeletedFunction(FunctionDecl *FD); std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD); bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, @@ -3108,7 +3249,7 @@ public: ArrayRef<Expr *> Args); void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, - Decl *LambdaContextDecl = 0, + Decl *LambdaContextDecl = nullptr, bool IsDecltype = false); enum ReuseLambdaContextDecl_t { ReuseLambdaContextDecl }; void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, @@ -3199,7 +3340,7 @@ public: /// emitted; this may also leave the ExprResult invalid. bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain = false, - bool (*IsPlausibleResult)(QualType) = 0); + bool (*IsPlausibleResult)(QualType) = nullptr); /// \brief Figure out if an expression could be turned into a call. bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, @@ -3222,7 +3363,7 @@ public: SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, - CorrectionCandidateCallback *CCC = 0, + CorrectionCandidateCallback *CCC = nullptr, bool IsInlineAsmIdentifier = false); void DecomposeUnqualifiedId(const UnqualifiedId &Id, @@ -3230,10 +3371,11 @@ public: DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs); - bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, - CorrectionCandidateCallback &CCC, - TemplateArgumentListInfo *ExplicitTemplateArgs = 0, - ArrayRef<Expr *> Args = None); + bool + DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, + CorrectionCandidateCallback &CCC, + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr, + ArrayRef<Expr *> Args = None); ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, @@ -3248,18 +3390,20 @@ public: ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, - const CXXScopeSpec *SS = 0); - ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, - const DeclarationNameInfo &NameInfo, - const CXXScopeSpec *SS = 0, NamedDecl *FoundD = 0, - const TemplateArgumentListInfo *TemplateArgs = 0); + const CXXScopeSpec *SS = nullptr); + ExprResult + BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, + const DeclarationNameInfo &NameInfo, + const CXXScopeSpec *SS = nullptr, + NamedDecl *FoundD = nullptr, + const TemplateArgumentListInfo *TemplateArgs = nullptr); ExprResult BuildAnonymousStructUnionMemberReference( const CXXScopeSpec &SS, SourceLocation nameLoc, IndirectFieldDecl *indirectField, - DeclAccessPair FoundDecl = DeclAccessPair::make(0, AS_none), - Expr *baseObjectExpr = 0, + DeclAccessPair FoundDecl = DeclAccessPair::make(nullptr, AS_none), + Expr *baseObjectExpr = nullptr, SourceLocation opLoc = SourceLocation()); ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, @@ -3275,9 +3419,10 @@ public: const LookupResult &R, bool HasTrailingLParen); - ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, - const DeclarationNameInfo &NameInfo, - bool IsAddressOfOperand); + ExprResult BuildQualifiedDeclarationNameExpr( + CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, + bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI = nullptr); + ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, @@ -3288,20 +3433,22 @@ public: bool NeedsADL); ExprResult BuildDeclarationNameExpr( const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, NamedDecl *D, - NamedDecl *FoundD = 0, const TemplateArgumentListInfo *TemplateArgs = 0); + NamedDecl *FoundD = nullptr, + const TemplateArgumentListInfo *TemplateArgs = nullptr); ExprResult BuildLiteralOperatorCall(LookupResult &R, - DeclarationNameInfo &SuffixInfo, - ArrayRef<Expr*> Args, - SourceLocation LitEndLoc, - TemplateArgumentListInfo *ExplicitTemplateArgs = 0); + DeclarationNameInfo &SuffixInfo, + ArrayRef<Expr *> Args, + SourceLocation LitEndLoc, + TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr); ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentType IT); ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind); ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val); - ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = 0); - ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope = 0); + ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope = nullptr); + ExprResult ActOnCharacterConstant(const Token &Tok, + Scope *UDLScope = nullptr); ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E); ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, @@ -3309,8 +3456,8 @@ public: /// ActOnStringLiteral - The specified tokens were lexed as pasted string /// fragments (e.g. "foo" "bar" L"baz"). - ExprResult ActOnStringLiteral(const Token *StringToks, unsigned NumStringToks, - Scope *UDLScope = 0); + ExprResult ActOnStringLiteral(ArrayRef<Token> StringToks, + Scope *UDLScope = nullptr); ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, @@ -3367,14 +3514,6 @@ public: ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc); - ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, - SourceLocation OpLoc, bool IsArrow, - CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - NamedDecl *FirstQualifierInScope, - const DeclarationNameInfo &NameInfo, - const TemplateArgumentListInfo *TemplateArgs); - // This struct is for use by ActOnMemberAccess to allow // BuildMemberReferenceExpr to be able to reinvoke ActOnMemberAccess after // changing the access operator from a '.' to a '->' (to see if that is the @@ -3387,22 +3526,23 @@ public: bool HasTrailingLParen; }; - ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, - SourceLocation OpLoc, bool IsArrow, - const CXXScopeSpec &SS, - SourceLocation TemplateKWLoc, - NamedDecl *FirstQualifierInScope, - LookupResult &R, - const TemplateArgumentListInfo *TemplateArgs, - bool SuppressQualifierCheck = false, - ActOnMemberAccessExtraArgs *ExtraArgs = 0); + ExprResult BuildMemberReferenceExpr( + Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, + CXXScopeSpec &SS, SourceLocation TemplateKWLoc, + NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, + const TemplateArgumentListInfo *TemplateArgs, + ActOnMemberAccessExtraArgs *ExtraArgs = nullptr); + + ExprResult + BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, + bool IsArrow, const CXXScopeSpec &SS, + SourceLocation TemplateKWLoc, + NamedDecl *FirstQualifierInScope, LookupResult &R, + const TemplateArgumentListInfo *TemplateArgs, + bool SuppressQualifierCheck = false, + ActOnMemberAccessExtraArgs *ExtraArgs = nullptr); ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow); - ExprResult LookupMemberExpr(LookupResult &R, ExprResult &Base, - bool &IsArrow, SourceLocation OpLoc, - CXXScopeSpec &SS, - Decl *ObjCImpDecl, - bool HasTemplateArgs); bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, const CXXScopeSpec &SS, @@ -3441,12 +3581,13 @@ public: /// locations. ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, - Expr *ExecConfig = 0, bool IsExecConfig = false); + Expr *ExecConfig = nullptr, + bool IsExecConfig = false); ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef<Expr *> Arg, SourceLocation RParenLoc, - Expr *Config = 0, + Expr *Config = nullptr, bool IsExecConfig = false); ExprResult ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc, @@ -3682,12 +3823,13 @@ public: const LookupResult &Previous); bool CheckUsingDeclQualifier(SourceLocation UsingLoc, const CXXScopeSpec &SS, + const DeclarationNameInfo &NameInfo, SourceLocation NameLoc); NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, CXXScopeSpec &SS, - const DeclarationNameInfo &NameInfo, + DeclarationNameInfo NameInfo, AttributeList *AttrList, bool IsInstantiation, bool HasTypenameKeyword, @@ -3720,16 +3862,18 @@ public: BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, + bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange); - // FIXME: Can re remove this and have the above BuildCXXConstructExpr check if + // FIXME: Can we remove this and have the above BuildCXXConstructExpr check if // the constructor can be elidable? ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, bool Elidable, MultiExprArg Exprs, bool HadMultipleCandidates, - bool IsListInitialization, bool RequiresZeroInit, + bool IsListInitialization, + bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange); /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating @@ -3801,7 +3945,7 @@ public: /// potential exceptions of the special member function contains "any" EPI.ExceptionSpecType = EST_ComputedNoexcept; EPI.NoexceptExpr = Self->ActOnCXXBoolLiteral(SourceLocation(), - tok::kw_false).take(); + tok::kw_false).get(); } } FunctionProtoType::ExtProtoInfo getEPI() const { @@ -4111,7 +4255,7 @@ public: /// \return returns 'true' if failed, 'false' if success. bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit = false, bool BuildAndDiagnose = true, - const unsigned *const FunctionScopeIndexToStopAt = 0); + const unsigned *const FunctionScopeIndexToStopAt = nullptr); /// \brief Determine whether the given type is the type of *this that is used /// outside of the body of a member function for a type that is currently @@ -4208,32 +4352,6 @@ public: ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen); - /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support - /// pseudo-functions. - ExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT, - SourceLocation KWLoc, - ParsedType Ty, - SourceLocation RParen); - - ExprResult BuildUnaryTypeTrait(UnaryTypeTrait OTT, - SourceLocation KWLoc, - TypeSourceInfo *T, - SourceLocation RParen); - - /// ActOnBinaryTypeTrait - Parsed one of the bianry type trait support - /// pseudo-functions. - ExprResult ActOnBinaryTypeTrait(BinaryTypeTrait OTT, - SourceLocation KWLoc, - ParsedType LhsTy, - ParsedType RhsTy, - SourceLocation RParen); - - ExprResult BuildBinaryTypeTrait(BinaryTypeTrait BTT, - SourceLocation KWLoc, - TypeSourceInfo *LhsT, - TypeSourceInfo *RhsT, - SourceLocation RParen); - /// \brief Parsed one of the type trait support pseudo-functions. ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef<ParsedType> Args, @@ -4359,7 +4477,8 @@ public: bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, - bool ErrorRecoveryLookup); + bool ErrorRecoveryLookup, + bool *IsCorrectedToColon = nullptr); /// \brief The parser has parsed a nested-name-specifier 'identifier::'. /// @@ -4382,6 +4501,13 @@ public: /// output parameter (containing the full nested-name-specifier, /// including this new type). /// + /// \param ErrorRecoveryLookup If true, then this method is called to improve + /// error recovery. In this case do not emit error message. + /// + /// \param IsCorrectedToColon If not null, suggestions to replace '::' -> ':' + /// are allowed. The bool value pointed by this parameter is set to 'true' + /// if the identifier is treated as if it was followed by ':', not '::'. + /// /// \returns true if an error occurred, false otherwise. bool ActOnCXXNestedNameSpecifier(Scope *S, IdentifierInfo &Identifier, @@ -4389,7 +4515,9 @@ public: SourceLocation CCLoc, ParsedType ObjectType, bool EnteringContext, - CXXScopeSpec &SS); + CXXScopeSpec &SS, + bool ErrorRecoveryLookup = false, + bool *IsCorrectedToColon = nullptr); ExprResult ActOnDecltypeExpression(Expr *E); @@ -4632,7 +4760,8 @@ public: SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, - SourceLocation RParenLoc); + SourceLocation RParenLoc, + bool WarnMultipleSelectors); /// ParseObjCProtocolExpression - Build protocol expression for \@protocol ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName, @@ -4647,8 +4776,7 @@ public: // Decl *ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, - SourceLocation LangLoc, - StringRef Lang, + Expr *LangStr, SourceLocation LBraceLoc); Decl *ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, @@ -4659,21 +4787,24 @@ public: // C++ Classes // bool isCurrentClassName(const IdentifierInfo &II, Scope *S, - const CXXScopeSpec *SS = 0); + const CXXScopeSpec *SS = nullptr); bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS); bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, - AttributeList *Attrs = 0); + AttributeList *Attrs = nullptr); NamedDecl *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle); - void ActOnCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, - Expr *Init); + + void ActOnStartCXXInClassMemberInitializer(); + void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, + SourceLocation EqualLoc, + Expr *Init); MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, @@ -4799,8 +4930,8 @@ public: AttributeList *AttrList); void ActOnFinishCXXMemberDecls(); - void ActOnReenterTemplateScope(Scope *S, Decl *Template); - void ActOnReenterDeclaratorTemplateScope(Scope *S, DeclaratorDecl *D); + void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param); + unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template); void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record); void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method); void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param); @@ -4879,7 +5010,7 @@ public: bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, - CXXCastPath *BasePath = 0, + CXXCastPath *BasePath = nullptr, bool IgnoreAccess = false); bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, unsigned InaccessibleBaseID, @@ -5067,7 +5198,7 @@ public: void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl); TemplateDecl *AdjustDeclIfTemplate(Decl *&Decl); - Decl *ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis, + Decl *ActOnTypeParameter(Scope *S, bool Typename, SourceLocation EllipsisLoc, SourceLocation KeyLoc, IdentifierInfo *ParamName, @@ -5118,7 +5249,8 @@ public: TemplateParamListContext TPC); TemplateParameterList *MatchTemplateParametersToScopeSpecifier( SourceLocation DeclStartLoc, SourceLocation DeclLoc, - const CXXScopeSpec &SS, ArrayRef<TemplateParameterList *> ParamLists, + const CXXScopeSpec &SS, TemplateIdAnnotation *TemplateId, + ArrayRef<TemplateParameterList *> ParamLists, bool IsFriend, bool &IsExplicitSpecialization, bool &Invalid); DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, @@ -5128,6 +5260,7 @@ public: TemplateParameterList *TemplateParams, AccessSpecifier AS, SourceLocation ModulePrivateLoc, + SourceLocation FriendLoc, unsigned NumOuterTemplateParamLists, TemplateParameterList **OuterTemplateParamLists); @@ -5162,7 +5295,7 @@ public: SourceLocation RAngleLoc); DeclResult ActOnVarTemplateSpecialization( - Scope *S, VarTemplateDecl *VarTemplate, Declarator &D, TypeSourceInfo *DI, + Scope *S, Declarator &D, TypeSourceInfo *DI, SourceLocation TemplateKWLoc, TemplateParameterList *TemplateParams, StorageClass SC, bool IsPartialSpecialization); @@ -5200,12 +5333,7 @@ public: ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, - CXXScopeSpec &SS, - TemplateTy Template, - SourceLocation TemplateNameLoc, - SourceLocation LAngleLoc, - ASTTemplateArgsPtr TemplateArgs, - SourceLocation RAngleLoc, + TemplateIdAnnotation &TemplateId, AttributeList *Attr, MultiTemplateParamsArg TemplateParameterLists); @@ -5290,7 +5418,7 @@ public: }; bool CheckTemplateArgument(NamedDecl *Param, - const TemplateArgumentLoc &Arg, + TemplateArgumentLoc &Arg, NamedDecl *Template, SourceLocation TemplateLoc, SourceLocation RAngleLoc, @@ -5318,21 +5446,15 @@ public: /// \param Converted Will receive the converted, canonicalized template /// arguments. /// - /// - /// \param ExpansionIntoFixedList If non-NULL, will be set true to indicate - /// when the template arguments contain a pack expansion that is being - /// expanded into a fixed parameter list. - /// - /// \returns True if an error occurred, false otherwise. + /// \returns true if an error occurred, false otherwise. bool CheckTemplateArgumentList(TemplateDecl *Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs, - SmallVectorImpl<TemplateArgument> &Converted, - bool *ExpansionIntoFixedList = 0); + SmallVectorImpl<TemplateArgument> &Converted); bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, - const TemplateArgumentLoc &Arg, + TemplateArgumentLoc &Arg, SmallVectorImpl<TemplateArgument> &Converted); bool CheckTemplateArgument(TemplateTypeParmDecl *Param, @@ -5342,7 +5464,7 @@ public: TemplateArgument &Converted, CheckTemplateArgumentKind CTAK = CTAK_Specified); bool CheckTemplateArgument(TemplateTemplateParmDecl *Param, - const TemplateArgumentLoc &Arg, + TemplateArgumentLoc &Arg, unsigned ArgumentPackIndex); ExprResult @@ -5880,7 +6002,7 @@ public: unsigned NumExplicitlySpecified, FunctionDecl *&Specialization, sema::TemplateDeductionInfo &Info, - SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = 0); + SmallVectorImpl<OriginalCallArg> const *OriginalCallArgs = nullptr); TemplateDeductionResult DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, @@ -5977,10 +6099,11 @@ public: // C++ Template Instantiation // - MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, - const TemplateArgumentList *Innermost = 0, - bool RelativeToPrimary = false, - const FunctionDecl *Pattern = 0); + MultiLevelTemplateArgumentList + getTemplateInstantiationArgs(NamedDecl *D, + const TemplateArgumentList *Innermost = nullptr, + bool RelativeToPrimary = false, + const FunctionDecl *Pattern = nullptr); /// \brief A template instantiation that is currently in progress. struct ActiveTemplateInstantiation { @@ -6055,8 +6178,8 @@ public: SourceRange InstantiationRange; ActiveTemplateInstantiation() - : Kind(TemplateInstantiation), Template(0), Entity(0), TemplateArgs(0), - NumTemplateArgs(0), DeductionInfo(0) {} + : Kind(TemplateInstantiation), Template(nullptr), Entity(nullptr), + TemplateArgs(nullptr), NumTemplateArgs(0), DeductionInfo(nullptr) {} /// \brief Determines whether this template is an actual instantiation /// that should be counted toward the maximum instantiation depth. @@ -6249,13 +6372,15 @@ public: SourceRange InstantiationRange = SourceRange()); /// \brief Note that we are substituting prior template arguments into a - /// non-type or template template parameter. + /// non-type parameter. InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, NamedDecl *Template, NonTypeTemplateParmDecl *Param, ArrayRef<TemplateArgument> TemplateArgs, SourceRange InstantiationRange); + /// \brief Note that we are substituting prior template arguments into a + /// template template parameter. InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, NamedDecl *Template, TemplateTemplateParmDecl *Param, @@ -6287,6 +6412,15 @@ public: bool CheckInstantiationDepth(SourceLocation PointOfInstantiation, SourceRange InstantiationRange); + // FIXME: Replace this with a constructor once we can use delegating + // constructors in llvm. + void Initialize( + ActiveTemplateInstantiation::InstantiationKind Kind, + SourceLocation PointOfInstantiation, SourceRange InstantiationRange, + Decl *Entity, NamedDecl *Template = nullptr, + ArrayRef<TemplateArgument> TemplateArgs = ArrayRef<TemplateArgument>(), + sema::TemplateDeductionInfo *DeductionInfo = nullptr); + InstantiatingTemplate(const InstantiatingTemplate&) LLVM_DELETED_FUNCTION; InstantiatingTemplate& @@ -6472,7 +6606,7 @@ public: ParmVarDecl **Params, unsigned NumParams, const MultiLevelTemplateArgumentList &TemplateArgs, SmallVectorImpl<QualType> &ParamTypes, - SmallVectorImpl<ParmVarDecl *> *OutParams = 0); + SmallVectorImpl<ParmVarDecl *> *OutParams = nullptr); ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs); @@ -6536,8 +6670,8 @@ public: void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, const Decl *Pattern, Decl *Inst, - LateInstantiatedAttrVec *LateAttrs = 0, - LocalInstantiationScope *OuterMostScope = 0); + LateInstantiatedAttrVec *LateAttrs = nullptr, + LocalInstantiationScope *OuterMostScope = nullptr); bool InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, @@ -6582,8 +6716,8 @@ public: const TemplateArgumentListInfo &TemplateArgsInfo, SmallVectorImpl<TemplateArgument> &Converted, SourceLocation PointOfInstantiation, void *InsertPos, - LateInstantiatedAttrVec *LateAttrs = 0, - LocalInstantiationScope *StartingScope = 0); + LateInstantiatedAttrVec *LateAttrs = nullptr, + LocalInstantiationScope *StartingScope = nullptr); VarTemplateSpecializationDecl *CompleteVarTemplateSpecializationDecl( VarTemplateSpecializationDecl *VarSpec, VarDecl *PatternDecl, const MultiLevelTemplateArgumentList &TemplateArgs); @@ -6717,8 +6851,8 @@ public: /// \param lexicalDC Container for redeclaredProperty. void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *CD, - ObjCPropertyDecl *redeclaredProperty = 0, - ObjCContainerDecl *lexicalDC = 0); + ObjCPropertyDecl *redeclaredProperty = nullptr, + ObjCContainerDecl *lexicalDC = nullptr); void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, @@ -6739,7 +6873,7 @@ public: Selector GetterSel, Selector SetterSel, bool *OverridingProperty, tok::ObjCKeywordKind MethodImplKind, - DeclContext *lexicalDC = 0); + DeclContext *lexicalDC = nullptr); Decl *ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, @@ -6902,6 +7036,27 @@ public: SourceLocation RParenLoc, Expr *SubExpr); + void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr); + + void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr); + + bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, + CastKind &Kind); + + bool checkObjCBridgeRelatedComponents(SourceLocation Loc, + QualType DestType, QualType SrcType, + ObjCInterfaceDecl *&RelatedClass, + ObjCMethodDecl *&ClassMethod, + ObjCMethodDecl *&InstanceMethod, + TypedefNameDecl *&TDNDecl, + bool CfToNs); + + bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, + QualType DestType, QualType SrcType, + Expr *&SrcExpr); + + bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr); + bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall); /// \brief Check whether the given new method is a valid override of the @@ -6969,6 +7124,69 @@ public: /// \#pragma comment(kind, "arg"). void ActOnPragmaMSComment(PragmaMSCommentKind Kind, StringRef Arg); + /// ActOnPragmaMSPointersToMembers - called on well formed \#pragma + /// pointers_to_members(representation method[, general purpose + /// representation]). + void ActOnPragmaMSPointersToMembers( + LangOptions::PragmaMSPointersToMembersKind Kind, + SourceLocation PragmaLoc); + + /// \brief Called on well formed \#pragma vtordisp(). + void ActOnPragmaMSVtorDisp(PragmaVtorDispKind Kind, SourceLocation PragmaLoc, + MSVtorDispAttr::Mode Value); + + enum PragmaSectionKind { + PSK_DataSeg, + PSK_BSSSeg, + PSK_ConstSeg, + PSK_CodeSeg, + }; + + enum PragmaSectionFlag : unsigned { + PSF_None = 0, + PSF_Read = 0x1, + PSF_Write = 0x2, + PSF_Execute = 0x4, + PSF_Implicit = 0x8, + PSF_Invalid = 0x80000000U, + }; + + struct SectionInfo { + DeclaratorDecl *Decl; + SourceLocation PragmaSectionLocation; + int SectionFlags; + SectionInfo() {} + SectionInfo(DeclaratorDecl *Decl, + SourceLocation PragmaSectionLocation, + int SectionFlags) + : Decl(Decl), + PragmaSectionLocation(PragmaSectionLocation), + SectionFlags(SectionFlags) {} + }; + + llvm::StringMap<SectionInfo> SectionInfos; + bool UnifySection(const StringRef &SectionName, + int SectionFlags, + DeclaratorDecl *TheDecl); + bool UnifySection(const StringRef &SectionName, + int SectionFlags, + SourceLocation PragmaSectionLocation); + + /// \brief Called on well formed \#pragma bss_seg/data_seg/const_seg/code_seg. + void ActOnPragmaMSSeg(SourceLocation PragmaLocation, + PragmaMsStackAction Action, + llvm::StringRef StackSlotLabel, + StringLiteral *SegmentName, + llvm::StringRef PragmaName); + + /// \brief Called on well formed \#pragma section(). + void ActOnPragmaMSSection(SourceLocation PragmaLocation, + int SectionFlags, StringLiteral *SegmentName); + + /// \brief Called on well-formed \#pragma init_seg(). + void ActOnPragmaMSInitSeg(SourceLocation PragmaLocation, + StringLiteral *SegmentName); + /// ActOnPragmaDetectMismatch - Call on well-formed \#pragma detect_mismatch void ActOnPragmaDetectMismatch(StringRef Name, StringRef Value); @@ -7040,6 +7258,25 @@ public: /// the appropriate attribute. void AddCFAuditedAttribute(Decl *D); + /// \brief Called on well formed \#pragma clang optimize. + void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc); + + /// \brief Get the location for the currently active "\#pragma clang optimize + /// off". If this location is invalid, then the state of the pragma is "on". + SourceLocation getOptimizeOffPragmaLocation() const { + return OptimizeOffPragmaLocation; + } + + /// \brief Only called on function definitions; if there is a pragma in scope + /// with the effect of a range-based optnone, consider marking the function + /// with attribute optnone. + void AddRangeBasedOptnone(FunctionDecl *FD); + + /// \brief Adds the 'optnone' attribute to the function declaration if there + /// are no conflicts; Loc represents the location causing the 'optnone' + /// attribute to be added (usually because of a pragma). + void AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD, SourceLocation Loc); + /// AddAlignedAttr - Adds an aligned attribute to a particular declaration. void AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, unsigned SpellingListIndex, bool IsPackExpansion); @@ -7052,11 +7289,15 @@ private: /// \brief Initialization of data-sharing attributes stack. void InitDataSharingAttributesStack(); void DestroyDataSharingAttributesStack(); + ExprResult VerifyPositiveIntegerConstantInClause(Expr *Op, + OpenMPClauseKind CKind); public: + ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc, + Expr *Op); /// \brief Called on start of new data sharing attribute block. void StartOpenMPDSABlock(OpenMPDirectiveKind K, - const DeclarationNameInfo &DirName, - Scope *CurScope); + const DeclarationNameInfo &DirName, Scope *CurScope, + SourceLocation Loc); /// \brief Called on end of data sharing attribute block. void EndOpenMPDSABlock(Stmt *CurDirective); @@ -7070,12 +7311,15 @@ public: DeclGroupPtrTy ActOnOpenMPThreadprivateDirective( SourceLocation Loc, ArrayRef<Expr *> VarList); - // \brief Builds a new OpenMPThreadPrivateDecl and checks its correctness. + /// \brief Builds a new OpenMPThreadPrivateDecl and checks its correctness. OMPThreadPrivateDecl *CheckOMPThreadPrivateDecl( SourceLocation Loc, ArrayRef<Expr *> VarList); + /// \brief Initialization of captured region for OpenMP region. + void ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope); StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, + const DeclarationNameInfo &DirName, ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, @@ -7086,6 +7330,100 @@ public: Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp simd' after parsing + /// of the associated statement. + StmtResult ActOnOpenMPSimdDirective( + ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc, + llvm::DenseMap<VarDecl *, Expr *> &VarsWithImplicitDSA); + /// \brief Called on well-formed '\#pragma omp for' after parsing + /// of the associated statement. + StmtResult ActOnOpenMPForDirective( + ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc, + llvm::DenseMap<VarDecl *, Expr *> &VarsWithImplicitDSA); + /// \brief Called on well-formed '\#pragma omp sections' after parsing + /// of the associated statement. + StmtResult ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp section' after parsing of the + /// associated statement. + StmtResult ActOnOpenMPSectionDirective(Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp single' after parsing of the + /// associated statement. + StmtResult ActOnOpenMPSingleDirective(ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp master' after parsing of the + /// associated statement. + StmtResult ActOnOpenMPMasterDirective(Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp critical' after parsing of the + /// associated statement. + StmtResult ActOnOpenMPCriticalDirective(const DeclarationNameInfo &DirName, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp parallel for' after parsing + /// of the associated statement. + StmtResult ActOnOpenMPParallelForDirective( + ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc, + llvm::DenseMap<VarDecl *, Expr *> &VarsWithImplicitDSA); + /// \brief Called on well-formed '\#pragma omp parallel sections' after + /// parsing of the associated statement. + StmtResult ActOnOpenMPParallelSectionsDirective(ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, + SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp task' after parsing of the + /// associated statement. + StmtResult ActOnOpenMPTaskDirective(ArrayRef<OMPClause *> Clauses, + Stmt *AStmt, SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp taskyield'. + StmtResult ActOnOpenMPTaskyieldDirective(SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp barrier'. + StmtResult ActOnOpenMPBarrierDirective(SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp taskwait'. + StmtResult ActOnOpenMPTaskwaitDirective(SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed '\#pragma omp flush'. + StmtResult ActOnOpenMPFlushDirective(ArrayRef<OMPClause *> Clauses, + SourceLocation StartLoc, + SourceLocation EndLoc); + + OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, + Expr *Expr, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'if' clause. + OMPClause *ActOnOpenMPIfClause(Expr *Condition, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'final' clause. + OMPClause *ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'num_threads' clause. + OMPClause *ActOnOpenMPNumThreadsClause(Expr *NumThreads, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'safelen' clause. + OMPClause *ActOnOpenMPSafelenClause(Expr *Length, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'collapse' clause. + OMPClause *ActOnOpenMPCollapseClause(Expr *NumForLoops, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); OMPClause *ActOnOpenMPSimpleClause(OpenMPClauseKind Kind, unsigned Argument, @@ -7099,12 +7437,50 @@ public: SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); - - OMPClause *ActOnOpenMPVarListClause(OpenMPClauseKind Kind, - ArrayRef<Expr *> Vars, - SourceLocation StartLoc, - SourceLocation LParenLoc, + /// \brief Called on well-formed 'proc_bind' clause. + OMPClause *ActOnOpenMPProcBindClause(OpenMPProcBindClauseKind Kind, + SourceLocation KindLoc, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + + OMPClause *ActOnOpenMPSingleExprWithArgClause(OpenMPClauseKind Kind, + unsigned Argument, Expr *Expr, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation ArgumentLoc, + SourceLocation CommaLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'schedule' clause. + OMPClause *ActOnOpenMPScheduleClause(OpenMPScheduleClauseKind Kind, + Expr *ChunkSize, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation KindLoc, + SourceLocation CommaLoc, + SourceLocation EndLoc); + + OMPClause *ActOnOpenMPClause(OpenMPClauseKind Kind, SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'ordered' clause. + OMPClause *ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc); + /// \brief Called on well-formed 'nowait' clause. + OMPClause *ActOnOpenMPNowaitClause(SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'untied' clause. + OMPClause *ActOnOpenMPUntiedClause(SourceLocation StartLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'mergeable' clause. + OMPClause *ActOnOpenMPMergeableClause(SourceLocation StartLoc, + SourceLocation EndLoc); + + OMPClause * + ActOnOpenMPVarListClause(OpenMPClauseKind Kind, ArrayRef<Expr *> Vars, + Expr *TailExpr, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation ColonLoc, + SourceLocation EndLoc, + CXXScopeSpec &ReductionIdScopeSpec, + const DeclarationNameInfo &ReductionId); /// \brief Called on well-formed 'private' clause. OMPClause *ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList, SourceLocation StartLoc, @@ -7115,11 +7491,52 @@ public: SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); + /// \brief Called on well-formed 'lastprivate' clause. + OMPClause *ActOnOpenMPLastprivateClause(ArrayRef<Expr *> VarList, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); /// \brief Called on well-formed 'shared' clause. OMPClause *ActOnOpenMPSharedClause(ArrayRef<Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc); + /// \brief Called on well-formed 'reduction' clause. + OMPClause * + ActOnOpenMPReductionClause(ArrayRef<Expr *> VarList, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation ColonLoc, + SourceLocation EndLoc, + CXXScopeSpec &ReductionIdScopeSpec, + const DeclarationNameInfo &ReductionId); + /// \brief Called on well-formed 'linear' clause. + OMPClause *ActOnOpenMPLinearClause(ArrayRef<Expr *> VarList, + Expr *Step, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation ColonLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'aligned' clause. + OMPClause *ActOnOpenMPAlignedClause(ArrayRef<Expr *> VarList, + Expr *Alignment, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation ColonLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'copyin' clause. + OMPClause *ActOnOpenMPCopyinClause(ArrayRef<Expr *> VarList, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'copyprivate' clause. + OMPClause *ActOnOpenMPCopyprivateClause(ArrayRef<Expr *> VarList, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); + /// \brief Called on well-formed 'flush' pseudo clause. + OMPClause *ActOnOpenMPFlushClause(ArrayRef<Expr *> VarList, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc); /// \brief The kind of conversion being performed. enum CheckedConversionKind { @@ -7138,7 +7555,7 @@ public: /// If isLvalue, the result of the cast is an lvalue. ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK = VK_RValue, - const CXXCastPath *BasePath = 0, + const CXXCastPath *BasePath = nullptr, CheckedConversionKind CCK = CCK_ImplicitConversion); @@ -7155,6 +7572,10 @@ public: // functions and arrays to their respective pointers (C99 6.3.2.1). ExprResult UsualUnaryConversions(Expr *E); + /// CallExprUnaryConversions - a special case of an unary conversion + /// performed on a function designator of a call expression. + ExprResult CallExprUnaryConversions(Expr *E); + // DefaultFunctionArrayConversion - converts functions and arrays // to their respective pointers (C99 6.3.2.1). ExprResult DefaultFunctionArrayConversion(Expr *E); @@ -7204,13 +7625,14 @@ public: /// function, issuing a diagnostic if not. void checkVariadicArgument(const Expr *E, VariadicCallType CT); + /// Check to see if a given expression could have '.c_str()' called on it. + bool hasCStrMethod(const Expr *E); + /// GatherArgumentsForCall - Collector argument expressions for various /// form of call prototypes. - bool GatherArgumentsForCall(SourceLocation CallLoc, - FunctionDecl *FDecl, + bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, - unsigned FirstProtoArg, - ArrayRef<Expr *> Args, + unsigned FirstParam, ArrayRef<Expr *> Args, SmallVectorImpl<Expr *> &AllArgs, VariadicCallType CallType = VariadicDoesNotApply, bool AllowExplicit = false, @@ -7308,7 +7730,7 @@ public: SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, - bool *Complained = 0); + bool *Complained = nullptr); /// DiagnoseAssignmentEnum - Warn if assignment to enum is a constant /// integer not in the range of enum values. @@ -7379,10 +7801,10 @@ public: bool IsCompAssign = false); QualType CheckAdditionOperands( // C99 6.5.6 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned Opc, - QualType* CompLHSTy = 0); + QualType* CompLHSTy = nullptr); QualType CheckSubtractionOperands( // C99 6.5.6 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, - QualType* CompLHSTy = 0); + QualType* CompLHSTy = nullptr); QualType CheckShiftOperands( // C99 6.5.7 ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned Opc, bool IsCompAssign = false); @@ -7415,15 +7837,15 @@ public: ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc); QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, - bool *NonStandardCompositeType = 0); + bool *NonStandardCompositeType = nullptr); QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, - bool *NonStandardCompositeType = 0) { - Expr *E1Tmp = E1.take(), *E2Tmp = E2.take(); + bool *NonStandardCompositeType = nullptr) { + Expr *E1Tmp = E1.get(), *E2Tmp = E2.get(); QualType Composite = FindCompositePointerType(Loc, E1Tmp, E2Tmp, NonStandardCompositeType); - E1 = Owned(E1Tmp); - E2 = Owned(E2Tmp); + E1 = E1Tmp; + E2 = E2Tmp; return Composite; } @@ -7433,6 +7855,10 @@ public: bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr, SourceLocation QuestionLoc); + void DiagnoseAlwaysNonNullPointer(Expr *E, + Expr::NullPointerConstantKind NullType, + bool IsEqual, SourceRange Range); + /// type checking for vector binary operators. QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign); @@ -7442,6 +7868,8 @@ public: QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc); + bool isLaxVectorConversion(QualType srcType, QualType destType); + /// type checking declaration initializers (C99 6.7.8) bool CheckForConstantInitializer(Expr *e, QualType t); @@ -7514,7 +7942,9 @@ public: ARCConversionResult CheckObjCARCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, - bool DiagnoseCFAudited = false); + bool DiagnoseCFAudited = false, + BinaryOperatorKind Opc = BO_PtrMemD + ); Expr *stripARCUnbridgedCast(Expr *e); void diagnoseARCUnbridgedCast(Expr *e); @@ -7622,7 +8052,8 @@ public: ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, unsigned DiagID, bool AllowFold = true); - ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result=0); + ExprResult VerifyIntegerConstantExpression(Expr *E, + llvm::APSInt *Result = nullptr); /// VerifyBitField - verifies that a bit field expression is an ICE and has /// the correct width, and that the field type is valid. @@ -7630,7 +8061,7 @@ public: /// Can optionally return whether the bit-field is of width 0 ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, - Expr *BitWidth, bool *ZeroWidth = 0); + Expr *BitWidth, bool *ZeroWidth = nullptr); enum CUDAFunctionTarget { CFT_Device, @@ -7754,7 +8185,7 @@ public: void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef<IdentifierInfo *> SelIdents, bool AtArgumentExpression, - ObjCInterfaceDecl *Super = 0); + ObjCInterfaceDecl *Super = nullptr); void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar); void CodeCompleteObjCSelector(Scope *S, @@ -7807,7 +8238,7 @@ public: private: void CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr, - const ArraySubscriptExpr *ASE=0, + const ArraySubscriptExpr *ASE=nullptr, bool AllowOnePastEnd=true, bool IndexNegated=false); void CheckArrayAccess(const Expr *E); // Used to grab the relevant information from a FormatAttr and a @@ -7833,21 +8264,24 @@ private: SourceLocation Loc); void checkCall(NamedDecl *FDecl, ArrayRef<const Expr *> Args, - unsigned NumProtoArgs, bool IsMemberFunction, - SourceLocation Loc, SourceRange Range, - VariadicCallType CallType); - + unsigned NumParams, bool IsMemberFunction, SourceLocation Loc, + SourceRange Range, VariadicCallType CallType); bool CheckObjCString(Expr *Arg); ExprResult CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); - bool CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall); + bool CheckARMBuiltinExclusiveCall(unsigned BuiltinID, CallExpr *TheCall, + unsigned MaxWidth); + bool CheckNeonBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); + bool CheckAArch64BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); bool CheckMipsBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); + bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); bool SemaBuiltinVAStart(CallExpr *TheCall); + bool SemaBuiltinVAStartARM(CallExpr *Call); bool SemaBuiltinUnorderedCompare(CallExpr *TheCall); bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs); @@ -7860,13 +8294,15 @@ public: private: bool SemaBuiltinPrefetch(CallExpr *TheCall); - bool SemaBuiltinObjectSize(CallExpr *TheCall); + bool SemaBuiltinAssume(CallExpr *TheCall); bool SemaBuiltinLongjmp(CallExpr *TheCall); ExprResult SemaBuiltinAtomicOverloaded(ExprResult TheCallResult); ExprResult SemaAtomicOpsOverloaded(ExprResult TheCallResult, AtomicExpr::AtomicOp Op); bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum, llvm::APSInt &Result); + bool SemaBuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, + int Low, int High); public: enum FormatStringType { @@ -7901,9 +8337,9 @@ private: SourceLocation Loc, SourceRange range, llvm::SmallBitVector &CheckedVarArgs); - void CheckNonNullArguments(const NonNullAttr *NonNull, - const Expr * const *ExprArgs, - SourceLocation CallSiteLoc); + void CheckAbsoluteValueFunction(const CallExpr *Call, + const FunctionDecl *FDecl, + IdentifierInfo *FnInfo); void CheckMemaccessArguments(const CallExpr *Call, unsigned BId, @@ -7915,8 +8351,12 @@ private: void CheckStrncatArguments(const CallExpr *Call, IdentifierInfo *FnName); - void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, - SourceLocation ReturnLoc); + void CheckReturnValExpr(Expr *RetValExp, QualType lhsType, + SourceLocation ReturnLoc, + bool isObjCMethod = false, + const AttrVec *Attrs = nullptr, + const FunctionDecl *FD = nullptr); + void CheckFloatComparison(SourceLocation Loc, Expr* LHS, Expr* RHS); void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation()); void CheckForIntOverflow(Expr *E); @@ -7930,6 +8370,10 @@ private: void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field, Expr *Init); + /// \brief Check if the given expression contains 'break' or 'continue' + /// statement that produces control flow different from GCC. + void CheckBreakContinueBinding(Expr *E); + public: /// \brief Register a magic integral constant to be used as a type tag. void RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind, @@ -7958,7 +8402,7 @@ public: private: /// \brief A map from magic value to type information. - OwningPtr<llvm::DenseMap<TypeTagMagicValue, TypeTagData> > + std::unique_ptr<llvm::DenseMap<TypeTagMagicValue, TypeTagData>> TypeTagForDatatypeMagicValues; /// \brief Peform checks on a call of a function with argument_with_type_tag @@ -7991,6 +8435,10 @@ public: /// template substitution or instantiation. Scope *getCurScope() const { return CurScope; } + void incrementMSLocalManglingNumber() const { + return CurScope->incrementMSLocalManglingNumber(); + } + IdentifierInfo *getSuperIdentifier() const; IdentifierInfo *getFloat128Identifier() const; @@ -8018,7 +8466,7 @@ class EnterExpressionEvaluationContext { public: EnterExpressionEvaluationContext(Sema &Actions, Sema::ExpressionEvaluationContext NewContext, - Decl *LambdaContextDecl = 0, + Decl *LambdaContextDecl = nullptr, bool IsDecltype = false) : Actions(Actions) { Actions.PushExpressionEvaluationContext(NewContext, LambdaContextDecl, diff --git a/contrib/llvm/tools/clang/include/clang/Sema/SemaInternal.h b/contrib/llvm/tools/clang/include/clang/Sema/SemaInternal.h index 01d4cc9..9199b0f 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/SemaInternal.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/SemaInternal.h @@ -24,44 +24,68 @@ namespace clang { inline PartialDiagnostic Sema::PDiag(unsigned DiagID) { return PartialDiagnostic(DiagID, Context.getDiagAllocator()); } -
-
-// This requires the variable to be non-dependent and the initializer
-// to not be value dependent.
-inline bool IsVariableAConstantExpression(VarDecl *Var, ASTContext &Context) {
- const VarDecl *DefVD = 0;
- return !isa<ParmVarDecl>(Var) &&
- Var->isUsableInConstantExpressions(Context) &&
- Var->getAnyInitializer(DefVD) && DefVD->checkInitIsICE();
-}
-
-// Directly mark a variable odr-used. Given a choice, prefer to use
-// MarkVariableReferenced since it does additional checks and then
-// calls MarkVarDeclODRUsed.
-// If the variable must be captured:
-// - if FunctionScopeIndexToStopAt is null, capture it in the CurContext
-// - else capture it in the DeclContext that maps to the
-// *FunctionScopeIndexToStopAt on the FunctionScopeInfo stack.
-inline void MarkVarDeclODRUsed(VarDecl *Var,
- SourceLocation Loc, Sema &SemaRef,
- const unsigned *const FunctionScopeIndexToStopAt) {
- // Keep track of used but undefined variables.
- // FIXME: We shouldn't suppress this warning for static data members.
- if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly &&
- !Var->isExternallyVisible() &&
- !(Var->isStaticDataMember() && Var->hasInit())) {
- SourceLocation &old = SemaRef.UndefinedButUsed[Var->getCanonicalDecl()];
- if (old.isInvalid()) old = Loc;
- }
- QualType CaptureType, DeclRefType;
- SemaRef.tryCaptureVariable(Var, Loc, Sema::TryCapture_Implicit,
- /*EllipsisLoc*/ SourceLocation(),
- /*BuildAndDiagnose*/ true,
- CaptureType, DeclRefType,
- FunctionScopeIndexToStopAt);
-
- Var->markUsed(SemaRef.Context);
+ +inline bool +FTIHasSingleVoidParameter(const DeclaratorChunk::FunctionTypeInfo &FTI) { + return FTI.NumParams == 1 && !FTI.isVariadic && + FTI.Params[0].Ident == nullptr && FTI.Params[0].Param && + cast<ParmVarDecl>(FTI.Params[0].Param)->getType()->isVoidType(); +} + +inline bool +FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI) { + // Assume FTI is well-formed. + return FTI.NumParams && !FTIHasSingleVoidParameter(FTI); } + +// This requires the variable to be non-dependent and the initializer +// to not be value dependent. +inline bool IsVariableAConstantExpression(VarDecl *Var, ASTContext &Context) { + const VarDecl *DefVD = nullptr; + return !isa<ParmVarDecl>(Var) && + Var->isUsableInConstantExpressions(Context) && + Var->getAnyInitializer(DefVD) && DefVD->checkInitIsICE(); +} + +// Directly mark a variable odr-used. Given a choice, prefer to use +// MarkVariableReferenced since it does additional checks and then +// calls MarkVarDeclODRUsed. +// If the variable must be captured: +// - if FunctionScopeIndexToStopAt is null, capture it in the CurContext +// - else capture it in the DeclContext that maps to the +// *FunctionScopeIndexToStopAt on the FunctionScopeInfo stack. +inline void MarkVarDeclODRUsed(VarDecl *Var, + SourceLocation Loc, Sema &SemaRef, + const unsigned *const FunctionScopeIndexToStopAt) { + // Keep track of used but undefined variables. + // FIXME: We shouldn't suppress this warning for static data members. + if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly && + !Var->isExternallyVisible() && + !(Var->isStaticDataMember() && Var->hasInit())) { + SourceLocation &old = SemaRef.UndefinedButUsed[Var->getCanonicalDecl()]; + if (old.isInvalid()) old = Loc; + } + QualType CaptureType, DeclRefType; + SemaRef.tryCaptureVariable(Var, Loc, Sema::TryCapture_Implicit, + /*EllipsisLoc*/ SourceLocation(), + /*BuildAndDiagnose*/ true, + CaptureType, DeclRefType, + FunctionScopeIndexToStopAt); + + Var->markUsed(SemaRef.Context); +} + +/// Return a DLL attribute from the declaration. +inline InheritableAttr *getDLLAttr(Decl *D) { + assert(!(D->hasAttr<DLLImportAttr>() && D->hasAttr<DLLExportAttr>()) && + "A declaration cannot be both dllimport and dllexport."); + if (auto *Import = D->getAttr<DLLImportAttr>()) + return Import; + if (auto *Export = D->getAttr<DLLExportAttr>()) + return Export; + return nullptr; +} + } #endif diff --git a/contrib/llvm/tools/clang/include/clang/Sema/SemaLambda.h b/contrib/llvm/tools/clang/include/clang/Sema/SemaLambda.h index cf9fff1..f636750 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/SemaLambda.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/SemaLambda.h @@ -1,39 +1,36 @@ -//===--- SemaLambda.h - Lambda Helper Functions --------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// \brief This file provides some common utility functions for processing
-/// Lambdas.
-///
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_SEMA_LAMBDA_H
-#define LLVM_CLANG_SEMA_LAMBDA_H
-#include "clang/AST/ASTLambda.h"
-#include "clang/Sema/ScopeInfo.h"
-namespace clang {
-
-// Given a lambda's call operator and a variable (or null for 'this'),
-// compute the nearest enclosing lambda that is capture-ready (i.e
-// the enclosing context is not dependent, and all intervening lambdas can
-// either implicitly or explicitly capture Var)
-//
-// Return the CallOperator of the capturable lambda and set function scope
-// index to the correct index within the function scope stack to correspond
-// to the capturable lambda.
-// If VarDecl *VD is null, we check for 'this' capture.
-CXXMethodDecl*
-GetInnermostEnclosingCapturableLambda(
- ArrayRef<sema::FunctionScopeInfo*> FunctionScopes,
- unsigned &FunctionScopeIndex,
- DeclContext *const CurContext, VarDecl *VD, Sema &S);
-
-} // clang
-
-#endif // LLVM_CLANG_SEMA_LAMBDA_H
+//===--- SemaLambda.h - Lambda Helper Functions --------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// \brief This file provides some common utility functions for processing +/// Lambdas. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_SEMA_LAMBDA_H +#define LLVM_CLANG_SEMA_LAMBDA_H +#include "clang/AST/ASTLambda.h" +#include "clang/Sema/ScopeInfo.h" +namespace clang { + + +/// \brief Examines the FunctionScopeInfo stack to determine the nearest +/// enclosing lambda (to the current lambda) that is 'capture-capable' for +/// the variable referenced in the current lambda (i.e. \p VarToCapture). +/// If successful, returns the index into Sema's FunctionScopeInfo stack +/// of the capture-capable lambda's LambdaScopeInfo. +/// See Implementation for more detailed comments. + +Optional<unsigned> getStackIndexOfNearestEnclosingCaptureCapableLambda( + ArrayRef<const sema::FunctionScopeInfo *> FunctionScopes, + VarDecl *VarToCapture, Sema &S); + +} // clang + +#endif // LLVM_CLANG_SEMA_LAMBDA_H diff --git a/contrib/llvm/tools/clang/include/clang/Sema/Template.h b/contrib/llvm/tools/clang/include/clang/Sema/Template.h index 1af61d5..c08a5df 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/Template.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/Template.h @@ -246,7 +246,7 @@ namespace clang { LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false) : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope), Exited(false), CombineWithOuterScope(CombineWithOuterScope), - PartiallySubstitutedPack(0) + PartiallySubstitutedPack(nullptr) { SemaRef.CurrentInstantiationScope = this; } @@ -276,7 +276,7 @@ namespace clang { LocalInstantiationScope *newScope = new LocalInstantiationScope(SemaRef, CombineWithOuterScope); - newScope->Outer = 0; + newScope->Outer = nullptr; if (Outer) newScope->Outer = Outer->cloneScopes(Outermost); @@ -319,7 +319,7 @@ namespace clang { /// \param D The declaration whose instantiation we are searching for. /// /// \returns A pointer to the declaration or argument pack of declarations - /// to which the declaration \c D is instantiataed, if found. Otherwise, + /// to which the declaration \c D is instantiated, if found. Otherwise, /// returns NULL. llvm::PointerUnion<Decl *, DeclArgumentPack *> * findInstantiationOf(const Decl *D); @@ -348,17 +348,17 @@ namespace clang { /// interest. void ResetPartiallySubstitutedPack() { assert(PartiallySubstitutedPack && "No partially-substituted pack"); - PartiallySubstitutedPack = 0; - ArgsInPartiallySubstitutedPack = 0; + PartiallySubstitutedPack = nullptr; + ArgsInPartiallySubstitutedPack = nullptr; NumArgsInPartiallySubstitutedPack = 0; } /// \brief Retrieve the partially-substitued template parameter pack. /// /// If there is no partially-substituted parameter pack, returns NULL. - NamedDecl *getPartiallySubstitutedPack( - const TemplateArgument **ExplicitArgs = 0, - unsigned *NumExplicitArgs = 0) const; + NamedDecl * + getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs = nullptr, + unsigned *NumExplicitArgs = nullptr) const; }; class TemplateDeclInstantiator @@ -391,8 +391,8 @@ namespace clang { const MultiLevelTemplateArgumentList &TemplateArgs) : SemaRef(SemaRef), SubstIndex(SemaRef, SemaRef.ArgumentPackSubstitutionIndex), - Owner(Owner), TemplateArgs(TemplateArgs), LateAttrs(0), StartingScope(0) - { } + Owner(Owner), TemplateArgs(TemplateArgs), LateAttrs(nullptr), + StartingScope(nullptr) {} // Define all the decl visitors using DeclNodes.inc #define DECL(DERIVED, BASE) \ @@ -436,8 +436,8 @@ namespace clang { // Disable late instantiation of attributes. void disableLateAttributeInstantiation() { - LateAttrs = 0; - StartingScope = 0; + LateAttrs = nullptr; + StartingScope = nullptr; } LocalInstantiationScope *getStartingScope() const { return StartingScope; } @@ -493,7 +493,7 @@ namespace clang { Decl *VisitVarTemplateSpecializationDecl( VarTemplateDecl *VarTemplate, VarDecl *FromVar, void *InsertPos, const TemplateArgumentListInfo &TemplateArgsInfo, - llvm::ArrayRef<TemplateArgument> Converted); + ArrayRef<TemplateArgument> Converted); Decl *InstantiateTypedefNameDecl(TypedefNameDecl *D, bool IsTypeAlias); ClassTemplatePartialSpecializationDecl * diff --git a/contrib/llvm/tools/clang/include/clang/Sema/TemplateDeduction.h b/contrib/llvm/tools/clang/include/clang/Sema/TemplateDeduction.h index 1daa689..2c2c36d 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/TemplateDeduction.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/TemplateDeduction.h @@ -19,6 +19,7 @@ namespace clang { +struct DeducedPack; class TemplateArgumentList; class Sema; @@ -48,7 +49,8 @@ class TemplateDeductionInfo { public: TemplateDeductionInfo(SourceLocation Loc) - : Deduced(0), Loc(Loc), HasSFINAEDiagnostic(false), Expression(0) { } + : Deduced(nullptr), Loc(Loc), HasSFINAEDiagnostic(false), + Expression(nullptr) {} /// \brief Returns the location at which template argument is /// occurring. @@ -59,7 +61,7 @@ public: /// \brief Take ownership of the deduced template argument list. TemplateArgumentList *take() { TemplateArgumentList *Result = Deduced; - Deduced = 0; + Deduced = nullptr; return Result; } @@ -161,6 +163,11 @@ public: /// an overloaded function which could not be resolved to a specific /// function. Expr *Expression; + + /// \brief Information on packs that we're currently expanding. + /// + /// FIXME: This should be kept internal to SemaTemplateDeduction. + SmallVector<DeducedPack *, 8> PendingDeducedPacks; }; } // end namespace sema diff --git a/contrib/llvm/tools/clang/include/clang/Sema/TypoCorrection.h b/contrib/llvm/tools/clang/include/clang/Sema/TypoCorrection.h index f0b7726..6cab59c 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/TypoCorrection.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/TypoCorrection.h @@ -39,7 +39,7 @@ public: static const unsigned CallbackDistanceWeight = 150U; TypoCorrection(const DeclarationName &Name, NamedDecl *NameDecl, - NestedNameSpecifier *NNS = 0, unsigned CharDistance = 0, + NestedNameSpecifier *NNS = nullptr, unsigned CharDistance = 0, unsigned QualifierDistance = 0) : CorrectionName(Name), CorrectionNameSpec(NNS), CharDistance(CharDistance), QualifierDistance(QualifierDistance), @@ -49,7 +49,7 @@ public: CorrectionDecls.push_back(NameDecl); } - TypoCorrection(NamedDecl *Name, NestedNameSpecifier *NNS = 0, + TypoCorrection(NamedDecl *Name, NestedNameSpecifier *NNS = nullptr, unsigned CharDistance = 0) : CorrectionName(Name->getDeclName()), CorrectionNameSpec(NNS), CharDistance(CharDistance), QualifierDistance(0), CallbackDistance(0), @@ -58,14 +58,14 @@ public: CorrectionDecls.push_back(Name); } - TypoCorrection(DeclarationName Name, NestedNameSpecifier *NNS = 0, + TypoCorrection(DeclarationName Name, NestedNameSpecifier *NNS = nullptr, unsigned CharDistance = 0) : CorrectionName(Name), CorrectionNameSpec(NNS), CharDistance(CharDistance), QualifierDistance(0), CallbackDistance(0), ForceSpecifierReplacement(false), RequiresImport(false) {} TypoCorrection() - : CorrectionNameSpec(0), CharDistance(0), QualifierDistance(0), + : CorrectionNameSpec(nullptr), CharDistance(0), QualifierDistance(0), CallbackDistance(0), ForceSpecifierReplacement(false), RequiresImport(false) {} @@ -81,7 +81,7 @@ public: } void setCorrectionSpecifier(NestedNameSpecifier* NNS) { CorrectionNameSpec = NNS; - ForceSpecifierReplacement = (NNS != 0); + ForceSpecifierReplacement = (NNS != nullptr); } void WillReplaceSpecifier(bool ForceReplacement) { @@ -130,7 +130,7 @@ public: /// \brief Gets the pointer to the declaration of the typo correction NamedDecl *getCorrectionDecl() const { - return hasCorrectionDecl() ? *(CorrectionDecls.begin()) : 0; + return hasCorrectionDecl() ? *(CorrectionDecls.begin()) : nullptr; } template <class DeclClass> DeclClass *getCorrectionDeclAs() const { @@ -172,7 +172,7 @@ public: /// as the only element in the list to mark this TypoCorrection as a keyword. void makeKeyword() { CorrectionDecls.clear(); - CorrectionDecls.push_back(0); + CorrectionDecls.push_back(nullptr); ForceSpecifierReplacement = true; } @@ -180,7 +180,7 @@ public: // item in CorrectionDecls is NULL. bool isKeyword() const { return !CorrectionDecls.empty() && - CorrectionDecls.front() == 0; + CorrectionDecls.front() == nullptr; } // Check if this TypoCorrection is the given keyword. @@ -250,8 +250,8 @@ public: CorrectionCandidateCallback() : WantTypeSpecifiers(true), WantExpressionKeywords(true), WantCXXNamedCasts(true), WantRemainingKeywords(true), - WantObjCSuper(false), - IsObjCIvarLookup(false) {} + WantObjCSuper(false), IsObjCIvarLookup(false), + IsAddressOfOperand(false) {} virtual ~CorrectionCandidateCallback() {} @@ -287,6 +287,7 @@ public: // Temporary hack for the one case where a CorrectTypoContext enum is used // when looking up results. bool IsObjCIvarLookup; + bool IsAddressOfOperand; }; /// @brief Simple template class for restricting typo correction candidates @@ -294,7 +295,7 @@ public: template <class C> class DeclFilterCCC : public CorrectionCandidateCallback { public: - virtual bool ValidateCandidate(const TypoCorrection &candidate) { + bool ValidateCandidate(const TypoCorrection &candidate) override { return candidate.getCorrectionDeclAs<C>(); } }; @@ -305,13 +306,16 @@ public: class FunctionCallFilterCCC : public CorrectionCandidateCallback { public: FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs, - bool HasExplicitTemplateArgs); + bool HasExplicitTemplateArgs, + MemberExpr *ME = nullptr); - virtual bool ValidateCandidate(const TypoCorrection &candidate); + bool ValidateCandidate(const TypoCorrection &candidate) override; private: unsigned NumArgs; bool HasExplicitTemplateArgs; + DeclContext *CurContext; + MemberExpr *MemberFn; }; // @brief Callback class that effectively disabled typo correction @@ -324,7 +328,7 @@ public: WantRemainingKeywords = false; } - virtual bool ValidateCandidate(const TypoCorrection &candidate) { + bool ValidateCandidate(const TypoCorrection &candidate) override { return false; } }; diff --git a/contrib/llvm/tools/clang/include/clang/Sema/Weak.h b/contrib/llvm/tools/clang/include/clang/Sema/Weak.h index 6d1b64b..9c7212e 100644 --- a/contrib/llvm/tools/clang/include/clang/Sema/Weak.h +++ b/contrib/llvm/tools/clang/include/clang/Sema/Weak.h @@ -28,7 +28,7 @@ class WeakInfo { bool used; // identifier later declared? public: WeakInfo() - : alias(0), loc(SourceLocation()), used(false) {} + : alias(nullptr), loc(SourceLocation()), used(false) {} WeakInfo(IdentifierInfo *Alias, SourceLocation Loc) : alias(Alias), loc(Loc), used(false) {} inline IdentifierInfo * getAlias() const { return alias; } |