diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/DeclarationName.h | 2 | ||||
-rw-r--r-- | include/clang/AST/Expr.h | 28 | ||||
-rw-r--r-- | include/clang/AST/ExprCXX.h | 168 | ||||
-rw-r--r-- | include/clang/AST/ExprObjC.h | 167 | ||||
-rw-r--r-- | include/clang/AST/Mangle.h | 3 | ||||
-rw-r--r-- | include/clang/AST/OpenMPClause.h | 87 | ||||
-rw-r--r-- | include/clang/Basic/Builtins.h | 4 | ||||
-rw-r--r-- | include/clang/Basic/BuiltinsX86.def | 10 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticDriverKinds.td | 3 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticParseKinds.td | 4 | ||||
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 8 | ||||
-rw-r--r-- | include/clang/Basic/LangOptions.def | 2 | ||||
-rw-r--r-- | include/clang/Basic/LangOptions.h | 17 | ||||
-rw-r--r-- | include/clang/Basic/OpenMPKinds.def | 2 | ||||
-rw-r--r-- | include/clang/Driver/CC1Options.td | 9 | ||||
-rw-r--r-- | include/clang/Driver/Options.td | 8 | ||||
-rw-r--r-- | include/clang/Frontend/CodeGenOptions.h | 11 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 4 | ||||
-rw-r--r-- | include/clang/Sema/TemplateDeduction.h | 33 |
19 files changed, 340 insertions, 230 deletions
diff --git a/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h index ec0fb0b..9482e83e 100644 --- a/include/clang/AST/DeclarationName.h +++ b/include/clang/AST/DeclarationName.h @@ -395,7 +395,7 @@ struct DeclarationNameLoc { // Locations (if any) for the tilde (destructor) or operator keyword // (conversion) are stored elsewhere. struct NT { - TypeSourceInfo* TInfo; + TypeSourceInfo *TInfo; }; // The location (if any) of the operator keyword is stored elsewhere. diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index f9f1995..095dd6a 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -2190,7 +2190,8 @@ public: return reinterpret_cast<Expr **>(SubExprs+getNumPreArgs()+PREARGS_START); } const Expr *const *getArgs() const { - return const_cast<CallExpr*>(this)->getArgs(); + return reinterpret_cast<Expr **>(SubExprs + getNumPreArgs() + + PREARGS_START); } /// getArg - Return the specified argument. @@ -3926,7 +3927,9 @@ public: /// which covers @c [2].y=1.0. This DesignatedInitExpr will have two /// designators, one array designator for @c [2] followed by one field /// designator for @c .y. The initialization expression will be 1.0. -class DesignatedInitExpr : public Expr { +class DesignatedInitExpr final + : public Expr, + private llvm::TrailingObjects<DesignatedInitExpr, Stmt *> { public: /// \brief Forward declaration of the Designator class. class Designator; @@ -4206,12 +4209,12 @@ public: Expr *getSubExpr(unsigned Idx) const { assert(Idx < NumSubExprs && "Subscript out of range"); - return cast<Expr>(reinterpret_cast<Stmt *const *>(this + 1)[Idx]); + return cast<Expr>(getTrailingObjects<Stmt *>()[Idx]); } void setSubExpr(unsigned Idx, Expr *E) { assert(Idx < NumSubExprs && "Subscript out of range"); - reinterpret_cast<Stmt **>(this + 1)[Idx] = E; + getTrailingObjects<Stmt *>()[Idx] = E; } /// \brief Replaces the designator at index @p Idx with the series @@ -4230,9 +4233,11 @@ public: // Iterators child_range children() { - Stmt **begin = reinterpret_cast<Stmt**>(this + 1); + Stmt **begin = getTrailingObjects<Stmt *>(); return child_range(begin, begin + NumSubExprs); } + + friend TrailingObjects; }; /// \brief Represents a place-holder for an object not to be initialized by @@ -4683,7 +4688,9 @@ public: /// equivalent to a particular message send, and this is very much /// part of the user model. The name of this class encourages this /// modelling design. -class PseudoObjectExpr : public Expr { +class PseudoObjectExpr final + : public Expr, + private llvm::TrailingObjects<PseudoObjectExpr, Expr *> { // PseudoObjectExprBits.NumSubExprs - The number of sub-expressions. // Always at least two, because the first sub-expression is the // syntactic form. @@ -4695,13 +4702,11 @@ class PseudoObjectExpr : public Expr { // in to Create, which is an index within the semantic forms. // Note also that ASTStmtWriter assumes this encoding. - Expr **getSubExprsBuffer() { return reinterpret_cast<Expr**>(this + 1); } + Expr **getSubExprsBuffer() { return getTrailingObjects<Expr *>(); } const Expr * const *getSubExprsBuffer() const { - return reinterpret_cast<const Expr * const *>(this + 1); + return getTrailingObjects<Expr *>(); } - friend class ASTStmtReader; - PseudoObjectExpr(QualType type, ExprValueKind VK, Expr *syntactic, ArrayRef<Expr*> semantic, unsigned resultIndex); @@ -4798,6 +4803,9 @@ public: static bool classof(const Stmt *T) { return T->getStmtClass() == PseudoObjectExprClass; } + + friend TrailingObjects; + friend class ASTStmtReader; }; /// AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h index 707aeed..0608aba 100644 --- a/include/clang/AST/ExprCXX.h +++ b/include/clang/AST/ExprCXX.h @@ -951,7 +951,9 @@ public: /// This wraps up a function call argument that was created from the /// corresponding parameter's default argument, when the call did not /// explicitly supply arguments for all of the parameters. -class CXXDefaultArgExpr : public Expr { +class CXXDefaultArgExpr final + : public Expr, + private llvm::TrailingObjects<CXXDefaultArgExpr, Expr *> { /// \brief The parameter whose default is being used. /// /// When the bit is set, the subexpression is stored after the @@ -977,7 +979,7 @@ class CXXDefaultArgExpr : public Expr { SubExpr->getValueKind(), SubExpr->getObjectKind(), false, false, false, false), Param(param, true), Loc(Loc) { - *reinterpret_cast<Expr **>(this + 1) = SubExpr; + *getTrailingObjects<Expr *>() = SubExpr; } public: @@ -1002,12 +1004,12 @@ public: // Retrieve the actual argument to the function call. const Expr *getExpr() const { if (Param.getInt()) - return *reinterpret_cast<Expr const * const*> (this + 1); + return *getTrailingObjects<Expr *>(); return getParam()->getDefaultArg(); } Expr *getExpr() { if (Param.getInt()) - return *reinterpret_cast<Expr **> (this + 1); + return *getTrailingObjects<Expr *>(); return getParam()->getDefaultArg(); } @@ -1031,6 +1033,7 @@ public: return child_range(child_iterator(), child_iterator()); } + friend TrailingObjects; friend class ASTStmtReader; friend class ASTStmtWriter; }; @@ -1441,7 +1444,9 @@ public: /// C++1y introduces a new form of "capture" called an init-capture that /// includes an initializing expression (rather than capturing a variable), /// and which can never occur implicitly. -class LambdaExpr : public Expr { +class LambdaExpr final + : public Expr, + private llvm::TrailingObjects<LambdaExpr, Stmt *, unsigned, VarDecl *> { /// \brief The source range that covers the lambda introducer ([...]). SourceRange IntroducerRange; @@ -1476,23 +1481,21 @@ class LambdaExpr : public Expr { /// module file just to determine the source range. SourceLocation ClosingBrace; - // Note: The capture initializers are stored directly after the lambda - // expression, along with the index variables used to initialize by-copy - // array captures. + size_t numTrailingObjects(OverloadToken<Stmt *>) const { + return NumCaptures + 1; + } - typedef LambdaCapture Capture; + size_t numTrailingObjects(OverloadToken<unsigned>) const { + return HasArrayIndexVars ? NumCaptures + 1 : 0; + } /// \brief Construct a lambda expression. LambdaExpr(QualType T, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, - SourceLocation CaptureDefaultLoc, - ArrayRef<Capture> Captures, - bool ExplicitParams, - bool ExplicitResultType, - ArrayRef<Expr *> CaptureInits, - ArrayRef<VarDecl *> ArrayIndexVars, - ArrayRef<unsigned> ArrayIndexStarts, - SourceLocation ClosingBrace, + SourceLocation CaptureDefaultLoc, ArrayRef<LambdaCapture> Captures, + bool ExplicitParams, bool ExplicitResultType, + ArrayRef<Expr *> CaptureInits, ArrayRef<VarDecl *> ArrayIndexVars, + ArrayRef<unsigned> ArrayIndexStarts, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack); /// \brief Construct an empty lambda expression. @@ -1503,53 +1506,35 @@ class LambdaExpr : public Expr { getStoredStmts()[NumCaptures] = nullptr; } - Stmt **getStoredStmts() { return reinterpret_cast<Stmt **>(this + 1); } + Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); } - Stmt *const *getStoredStmts() const { - return reinterpret_cast<Stmt *const *>(this + 1); - } + Stmt *const *getStoredStmts() const { return getTrailingObjects<Stmt *>(); } /// \brief Retrieve the mapping from captures to the first array index /// variable. - unsigned *getArrayIndexStarts() { - return reinterpret_cast<unsigned *>(getStoredStmts() + NumCaptures + 1); - } + unsigned *getArrayIndexStarts() { return getTrailingObjects<unsigned>(); } const unsigned *getArrayIndexStarts() const { - return reinterpret_cast<const unsigned *>(getStoredStmts() + NumCaptures + - 1); + return getTrailingObjects<unsigned>(); } /// \brief Retrieve the complete set of array-index variables. - VarDecl **getArrayIndexVars() { - unsigned ArrayIndexSize = llvm::RoundUpToAlignment( - sizeof(unsigned) * (NumCaptures + 1), llvm::alignOf<VarDecl *>()); - return reinterpret_cast<VarDecl **>( - reinterpret_cast<char *>(getArrayIndexStarts()) + ArrayIndexSize); - } + VarDecl **getArrayIndexVars() { return getTrailingObjects<VarDecl *>(); } VarDecl *const *getArrayIndexVars() const { - unsigned ArrayIndexSize = llvm::RoundUpToAlignment( - sizeof(unsigned) * (NumCaptures + 1), llvm::alignOf<VarDecl *>()); - return reinterpret_cast<VarDecl *const *>( - reinterpret_cast<const char *>(getArrayIndexStarts()) + ArrayIndexSize); + return getTrailingObjects<VarDecl *>(); } public: /// \brief Construct a new lambda expression. - static LambdaExpr *Create(const ASTContext &C, - CXXRecordDecl *Class, - SourceRange IntroducerRange, - LambdaCaptureDefault CaptureDefault, - SourceLocation CaptureDefaultLoc, - ArrayRef<Capture> Captures, - bool ExplicitParams, - bool ExplicitResultType, - ArrayRef<Expr *> CaptureInits, - ArrayRef<VarDecl *> ArrayIndexVars, - ArrayRef<unsigned> ArrayIndexStarts, - SourceLocation ClosingBrace, - bool ContainsUnexpandedParameterPack); + static LambdaExpr * + Create(const ASTContext &C, CXXRecordDecl *Class, SourceRange IntroducerRange, + LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, + ArrayRef<LambdaCapture> Captures, bool ExplicitParams, + bool ExplicitResultType, ArrayRef<Expr *> CaptureInits, + ArrayRef<VarDecl *> ArrayIndexVars, + ArrayRef<unsigned> ArrayIndexStarts, SourceLocation ClosingBrace, + bool ContainsUnexpandedParameterPack); /// \brief Construct a new lambda expression that will be deserialized from /// an external source. @@ -1572,7 +1557,7 @@ public: /// \brief An iterator that walks over the captures of the lambda, /// both implicit and explicit. - typedef const Capture *capture_iterator; + typedef const LambdaCapture *capture_iterator; /// \brief An iterator over a range of lambda captures. typedef llvm::iterator_range<capture_iterator> capture_range; @@ -1709,9 +1694,11 @@ public: SourceLocation getLocEnd() const LLVM_READONLY { return ClosingBrace; } child_range children() { + // Includes initialization exprs plus body stmt return child_range(getStoredStmts(), getStoredStmts() + NumCaptures + 1); } + friend TrailingObjects; friend class ASTStmtReader; friend class ASTStmtWriter; }; @@ -2226,7 +2213,9 @@ public: /// __is_enum(std::string) == false /// __is_trivially_constructible(vector<int>, int*, int*) /// \endcode -class TypeTraitExpr : public Expr { +class TypeTraitExpr final + : public Expr, + private llvm::TrailingObjects<TypeTraitExpr, TypeSourceInfo *> { /// \brief The location of the type trait keyword. SourceLocation Loc; @@ -2243,16 +2232,10 @@ class TypeTraitExpr : public Expr { TypeTraitExpr(EmptyShell Empty) : Expr(TypeTraitExprClass, Empty) { } - /// \brief Retrieve the argument types. - TypeSourceInfo **getTypeSourceInfos() { - return reinterpret_cast<TypeSourceInfo **>(this+1); - } - - /// \brief Retrieve the argument types. - TypeSourceInfo * const *getTypeSourceInfos() const { - return reinterpret_cast<TypeSourceInfo * const*>(this+1); + size_t numTrailingObjects(OverloadToken<TypeSourceInfo *>) const { + return getNumArgs(); } - + public: /// \brief Create a new type trait expression. static TypeTraitExpr *Create(const ASTContext &C, QualType T, @@ -2284,22 +2267,9 @@ public: } /// \brief Retrieve the argument types. - ArrayRef<TypeSourceInfo *> getArgs() const { - return llvm::makeArrayRef(getTypeSourceInfos(), getNumArgs()); - } - - typedef TypeSourceInfo **arg_iterator; - arg_iterator arg_begin() { - return getTypeSourceInfos(); - } - arg_iterator arg_end() { - return getTypeSourceInfos() + getNumArgs(); - } - - typedef TypeSourceInfo const * const *arg_const_iterator; - arg_const_iterator arg_begin() const { return getTypeSourceInfos(); } - arg_const_iterator arg_end() const { - return getTypeSourceInfos() + getNumArgs(); + ArrayRef<TypeSourceInfo *> getArgs() const { + return llvm::makeArrayRef(getTrailingObjects<TypeSourceInfo *>(), + getNumArgs()); } SourceLocation getLocStart() const LLVM_READONLY { return Loc; } @@ -2314,9 +2284,9 @@ public: return child_range(child_iterator(), child_iterator()); } + friend TrailingObjects; friend class ASTStmtReader; friend class ASTStmtWriter; - }; /// \brief An Embarcadero array type trait, as used in the implementation of @@ -2899,7 +2869,9 @@ public: /// This expression also tracks whether the sub-expression contains a /// potentially-evaluated block literal. The lifetime of a block /// literal is the extent of the enclosing scope. -class ExprWithCleanups : public Expr { +class ExprWithCleanups final + : public Expr, + private llvm::TrailingObjects<ExprWithCleanups, BlockDecl *> { public: /// The type of objects that are kept in the cleanup. /// It's useful to remember the set of blocks; we could also @@ -2913,12 +2885,7 @@ private: ExprWithCleanups(EmptyShell, unsigned NumObjects); ExprWithCleanups(Expr *SubExpr, ArrayRef<CleanupObject> Objects); - CleanupObject *getObjectsBuffer() { - return reinterpret_cast<CleanupObject*>(this + 1); - } - const CleanupObject *getObjectsBuffer() const { - return reinterpret_cast<const CleanupObject*>(this + 1); - } + friend TrailingObjects; friend class ASTStmtReader; public: @@ -2929,7 +2896,8 @@ public: ArrayRef<CleanupObject> objects); ArrayRef<CleanupObject> getObjects() const { - return llvm::makeArrayRef(getObjectsBuffer(), getNumObjects()); + return llvm::makeArrayRef(getTrailingObjects<CleanupObject>(), + getNumObjects()); } unsigned getNumObjects() const { return ExprWithCleanupsBits.NumObjects; } @@ -2981,7 +2949,9 @@ public: /// When the returned expression is instantiated, it may resolve to a /// constructor call, conversion function call, or some kind of type /// conversion. -class CXXUnresolvedConstructExpr : public Expr { +class CXXUnresolvedConstructExpr final + : public Expr, + private llvm::TrailingObjects<CXXUnresolvedConstructExpr, Expr *> { /// \brief The type being constructed. TypeSourceInfo *Type; @@ -3002,6 +2972,7 @@ class CXXUnresolvedConstructExpr : public Expr { CXXUnresolvedConstructExpr(EmptyShell Empty, unsigned NumArgs) : Expr(CXXUnresolvedConstructExprClass, Empty), Type(), NumArgs(NumArgs) { } + friend TrailingObjects; friend class ASTStmtReader; public: @@ -3036,13 +3007,11 @@ public: unsigned arg_size() const { return NumArgs; } typedef Expr** arg_iterator; - arg_iterator arg_begin() { return reinterpret_cast<Expr**>(this + 1); } + arg_iterator arg_begin() { return getTrailingObjects<Expr *>(); } arg_iterator arg_end() { return arg_begin() + NumArgs; } typedef const Expr* const * const_arg_iterator; - const_arg_iterator arg_begin() const { - return reinterpret_cast<const Expr* const *>(this + 1); - } + const_arg_iterator arg_begin() const { return getTrailingObjects<Expr *>(); } const_arg_iterator arg_end() const { return arg_begin() + NumArgs; } @@ -3075,7 +3044,7 @@ public: // Iterators child_range children() { - Stmt **begin = reinterpret_cast<Stmt**>(this+1); + Stmt **begin = reinterpret_cast<Stmt **>(arg_begin()); return child_range(begin, begin + NumArgs); } }; @@ -3608,7 +3577,9 @@ public: /// static const unsigned value = sizeof...(Types); /// }; /// \endcode -class SizeOfPackExpr : public Expr { +class SizeOfPackExpr final + : public Expr, + private llvm::TrailingObjects<SizeOfPackExpr, TemplateArgument> { /// \brief The location of the \c sizeof keyword. SourceLocation OperatorLoc; @@ -3633,6 +3604,7 @@ class SizeOfPackExpr : public Expr { /// \brief The parameter pack. NamedDecl *Pack; + friend TrailingObjects; friend class ASTStmtReader; friend class ASTStmtWriter; @@ -3649,7 +3621,7 @@ class SizeOfPackExpr : public Expr { Length(Length ? *Length : PartialArgs.size()), Pack(Pack) { assert((!Length || PartialArgs.empty()) && "have partial args for non-dependent sizeof... expression"); - TemplateArgument *Args = reinterpret_cast<TemplateArgument *>(this + 1); + TemplateArgument *Args = getTrailingObjects<TemplateArgument>(); std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args); } @@ -3700,8 +3672,7 @@ public: /// \brief Get ArrayRef<TemplateArgument> getPartialArguments() const { assert(isPartiallySubstituted()); - const TemplateArgument *Args = - reinterpret_cast<const TemplateArgument *>(this + 1); + const TemplateArgument *Args = getTrailingObjects<TemplateArgument>(); return llvm::makeArrayRef(Args, Args + Length); } @@ -3837,7 +3808,9 @@ public: /// }; /// template struct S<int, int>; /// \endcode -class FunctionParmPackExpr : public Expr { +class FunctionParmPackExpr final + : public Expr, + private llvm::TrailingObjects<FunctionParmPackExpr, ParmVarDecl *> { /// \brief The function parameter pack which was referenced. ParmVarDecl *ParamPack; @@ -3851,6 +3824,7 @@ class FunctionParmPackExpr : public Expr { SourceLocation NameLoc, unsigned NumParams, ParmVarDecl *const *Params); + friend TrailingObjects; friend class ASTReader; friend class ASTStmtReader; @@ -3871,7 +3845,7 @@ public: /// \brief Iterators over the parameters which the parameter pack expanded /// into. typedef ParmVarDecl * const *iterator; - iterator begin() const { return reinterpret_cast<iterator>(this+1); } + iterator begin() const { return getTrailingObjects<ParmVarDecl *>(); } iterator end() const { return begin() + NumParameters; } /// \brief Get the number of parameters in this parameter pack. diff --git a/include/clang/AST/ExprObjC.h b/include/clang/AST/ExprObjC.h index 38fa718..61e6383 100644 --- a/include/clang/AST/ExprObjC.h +++ b/include/clang/AST/ExprObjC.h @@ -141,15 +141,17 @@ public: /// ObjCArrayLiteral - used for objective-c array containers; as in: /// @[@"Hello", NSApp, [NSNumber numberWithInt:42]]; -class ObjCArrayLiteral : public Expr { +class ObjCArrayLiteral final + : public Expr, + private llvm::TrailingObjects<ObjCArrayLiteral, Expr *> { unsigned NumElements; SourceRange Range; ObjCMethodDecl *ArrayWithObjectsMethod; - + ObjCArrayLiteral(ArrayRef<Expr *> Elements, QualType T, ObjCMethodDecl * Method, SourceRange SR); - + explicit ObjCArrayLiteral(EmptyShell Empty, unsigned NumElements) : Expr(ObjCArrayLiteralClass, Empty), NumElements(NumElements) {} @@ -171,11 +173,11 @@ public: } /// \brief Retrieve elements of array of literals. - Expr **getElements() { return reinterpret_cast<Expr **>(this + 1); } + Expr **getElements() { return getTrailingObjects<Expr *>(); } /// \brief Retrieve elements of array of literals. - const Expr * const *getElements() const { - return reinterpret_cast<const Expr * const*>(this + 1); + const Expr * const *getElements() const { + return getTrailingObjects<Expr *>(); } /// getNumElements - Return number of elements of objective-c array literal. @@ -196,11 +198,12 @@ public: } // Iterators - child_range children() { - return child_range((Stmt **)getElements(), - (Stmt **)getElements() + NumElements); + child_range children() { + return child_range(reinterpret_cast<Stmt **>(getElements()), + reinterpret_cast<Stmt **>(getElements()) + NumElements); } - + + friend TrailingObjects; friend class ASTStmtReader; }; @@ -230,32 +233,35 @@ template <> struct isPodLike<clang::ObjCDictionaryElement> : std::true_type {}; } namespace clang { -/// ObjCDictionaryLiteral - AST node to represent objective-c dictionary -/// literals; as in: @{@"name" : NSUserName(), @"date" : [NSDate date] }; -class ObjCDictionaryLiteral : public Expr { - /// \brief Key/value pair used to store the key and value of a given element. - /// - /// Objects of this type are stored directly after the expression. - struct KeyValuePair { - Expr *Key; - Expr *Value; - }; - - /// \brief Data that describes an element that is a pack expansion, used if any - /// of the elements in the dictionary literal are pack expansions. - struct ExpansionData { - /// \brief The location of the ellipsis, if this element is a pack - /// expansion. - SourceLocation EllipsisLoc; - - /// \brief If non-zero, the number of elements that this pack - /// expansion will expand to (+1). - unsigned NumExpansionsPlusOne; - }; +/// \brief Internal struct for storing Key/value pair. +struct ObjCDictionaryLiteral_KeyValuePair { + Expr *Key; + Expr *Value; +}; + +/// \brief Internal struct to describes an element that is a pack +/// expansion, used if any of the elements in the dictionary literal +/// are pack expansions. +struct ObjCDictionaryLiteral_ExpansionData { + /// \brief The location of the ellipsis, if this element is a pack + /// expansion. + SourceLocation EllipsisLoc; + /// \brief If non-zero, the number of elements that this pack + /// expansion will expand to (+1). + unsigned NumExpansionsPlusOne; +}; + +/// ObjCDictionaryLiteral - AST node to represent objective-c dictionary +/// literals; as in: @{@"name" : NSUserName(), @"date" : [NSDate date] }; +class ObjCDictionaryLiteral final + : public Expr, + private llvm::TrailingObjects<ObjCDictionaryLiteral, + ObjCDictionaryLiteral_KeyValuePair, + ObjCDictionaryLiteral_ExpansionData> { /// \brief The number of elements in this dictionary literal. unsigned NumElements : 31; - + /// \brief Determine whether this dictionary literal has any pack expansions. /// /// If the dictionary literal has pack expansions, then there will @@ -264,10 +270,17 @@ class ObjCDictionaryLiteral : public Expr { /// any) and number of elements in the expansion (if known). If /// there are no pack expansions, we optimize away this storage. unsigned HasPackExpansions : 1; - + SourceRange Range; ObjCMethodDecl *DictWithObjectsMethod; - + + typedef ObjCDictionaryLiteral_KeyValuePair KeyValuePair; + typedef ObjCDictionaryLiteral_ExpansionData ExpansionData; + + size_t numTrailingObjects(OverloadToken<KeyValuePair>) const { + return NumElements; + } + ObjCDictionaryLiteral(ArrayRef<ObjCDictionaryElement> VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, @@ -278,28 +291,6 @@ class ObjCDictionaryLiteral : public Expr { : Expr(ObjCDictionaryLiteralClass, Empty), NumElements(NumElements), HasPackExpansions(HasPackExpansions) {} - KeyValuePair *getKeyValues() { - return reinterpret_cast<KeyValuePair *>(this + 1); - } - - const KeyValuePair *getKeyValues() const { - return reinterpret_cast<const KeyValuePair *>(this + 1); - } - - ExpansionData *getExpansionData() { - if (!HasPackExpansions) - return nullptr; - - return reinterpret_cast<ExpansionData *>(getKeyValues() + NumElements); - } - - const ExpansionData *getExpansionData() const { - if (!HasPackExpansions) - return nullptr; - - return reinterpret_cast<const ExpansionData *>(getKeyValues()+NumElements); - } - public: static ObjCDictionaryLiteral *Create(const ASTContext &C, ArrayRef<ObjCDictionaryElement> VK, @@ -317,10 +308,11 @@ public: ObjCDictionaryElement getKeyValueElement(unsigned Index) const { assert((Index < NumElements) && "Arg access out of range!"); - const KeyValuePair &KV = getKeyValues()[Index]; + const KeyValuePair &KV = getTrailingObjects<KeyValuePair>()[Index]; ObjCDictionaryElement Result = { KV.Key, KV.Value, SourceLocation(), None }; if (HasPackExpansions) { - const ExpansionData &Expansion = getExpansionData()[Index]; + const ExpansionData &Expansion = + getTrailingObjects<ExpansionData>()[Index]; Result.EllipsisLoc = Expansion.EllipsisLoc; if (Expansion.NumExpansionsPlusOne > 0) Result.NumExpansions = Expansion.NumExpansionsPlusOne - 1; @@ -340,17 +332,20 @@ public: } // Iterators - child_range children() { + child_range children() { // Note: we're taking advantage of the layout of the KeyValuePair struct // here. If that struct changes, this code will need to change as well. static_assert(sizeof(KeyValuePair) == sizeof(Stmt *) * 2, "KeyValuePair is expected size"); - return child_range(reinterpret_cast<Stmt **>(this + 1), - reinterpret_cast<Stmt **>(this + 1) + NumElements * 2); + return child_range( + reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()), + reinterpret_cast<Stmt **>(getTrailingObjects<KeyValuePair>()) + + NumElements * 2); } friend class ASTStmtReader; friend class ASTStmtWriter; + friend TrailingObjects; }; @@ -797,13 +792,6 @@ public: explicit ObjCSubscriptRefExpr(EmptyShell Empty) : Expr(ObjCSubscriptRefExprClass, Empty) {} - static ObjCSubscriptRefExpr *Create(const ASTContext &C, - Expr *base, - Expr *key, QualType T, - ObjCMethodDecl *getMethod, - ObjCMethodDecl *setMethod, - SourceLocation RB); - SourceLocation getRBracket() const { return RBracket; } void setRBracket(SourceLocation RB) { RBracket = RB; } @@ -865,7 +853,13 @@ private: /// All four kinds of message sends are modeled by the ObjCMessageExpr /// class, and can be distinguished via \c getReceiverKind(). Example: /// -class ObjCMessageExpr : public Expr { +/// The "void *" trailing objects are actually ONE void * (the +/// receiver pointer), and NumArgs Expr *. But due to the +/// implementation of children(), these must be together contiguously. + +class ObjCMessageExpr final + : public Expr, + private llvm::TrailingObjects<ObjCMessageExpr, void *, SourceLocation> { /// \brief Stores either the selector that this message is sending /// to (when \c HasMethod is zero) or an \c ObjCMethodDecl pointer /// referring to the method that we type-checked against. @@ -877,11 +871,6 @@ class ObjCMessageExpr : public Expr { /// including the receiver. unsigned NumArgs : NumArgsBitWidth; - void setNumArgs(unsigned Num) { - assert((Num >> NumArgsBitWidth) == 0 && "Num of args is out of range!"); - NumArgs = Num; - } - /// \brief The kind of message send this is, which is one of the /// ReceiverKind values. /// @@ -915,6 +904,13 @@ class ObjCMessageExpr : public Expr { /// brackets ('[' and ']', respectively). SourceLocation LBracLoc, RBracLoc; + size_t numTrailingObjects(OverloadToken<void *>) const { return NumArgs + 1; } + + void setNumArgs(unsigned Num) { + assert((Num >> NumArgsBitWidth) == 0 && "Num of args is out of range!"); + NumArgs = Num; + } + ObjCMessageExpr(EmptyShell Empty, unsigned NumArgs) : Expr(ObjCMessageExprClass, Empty), SelectorOrMethod(0), Kind(0), HasMethod(0), IsDelegateInitCall(0), IsImplicit(0), SelLocsKind(0) { @@ -959,14 +955,11 @@ class ObjCMessageExpr : public Expr { SelectorLocationsKind SelLocsK); /// \brief Retrieve the pointer value of the message receiver. - void *getReceiverPointer() const { - return *const_cast<void **>( - reinterpret_cast<const void * const*>(this + 1)); - } + void *getReceiverPointer() const { return *getTrailingObjects<void *>(); } /// \brief Set the pointer value of the message receiver. void setReceiverPointer(void *Value) { - *reinterpret_cast<void **>(this + 1) = Value; + *getTrailingObjects<void *>() = Value; } SelectorLocationsKind getSelLocsKind() const { @@ -979,10 +972,10 @@ class ObjCMessageExpr : public Expr { /// \brief Get a pointer to the stored selector identifiers locations array. /// No locations will be stored if HasStandardSelLocs is true. SourceLocation *getStoredSelLocs() { - return reinterpret_cast<SourceLocation*>(getArgs() + getNumArgs()); + return getTrailingObjects<SourceLocation>(); } const SourceLocation *getStoredSelLocs() const { - return reinterpret_cast<const SourceLocation*>(getArgs() + getNumArgs()); + return getTrailingObjects<SourceLocation>(); } /// \brief Get the number of stored selector identifiers locations. @@ -1286,20 +1279,21 @@ public: /// \brief Retrieve the arguments to this message, not including the /// receiver. Expr **getArgs() { - return reinterpret_cast<Expr **>(this + 1) + 1; + return reinterpret_cast<Expr **>(getTrailingObjects<void *>() + 1); } const Expr * const *getArgs() const { - return reinterpret_cast<const Expr * const *>(this + 1) + 1; + return reinterpret_cast<const Expr *const *>(getTrailingObjects<void *>() + + 1); } /// getArg - Return the specified argument. Expr *getArg(unsigned Arg) { assert(Arg < NumArgs && "Arg access out of range!"); - return cast<Expr>(getArgs()[Arg]); + return getArgs()[Arg]; } const Expr *getArg(unsigned Arg) const { assert(Arg < NumArgs && "Arg access out of range!"); - return cast<Expr>(getArgs()[Arg]); + return getArgs()[Arg]; } /// setArg - Set the specified argument. void setArg(unsigned Arg, Expr *ArgExpr) { @@ -1379,6 +1373,7 @@ public: return reinterpret_cast<Stmt const * const*>(getArgs() + NumArgs); } + friend TrailingObjects; friend class ASTStmtReader; friend class ASTStmtWriter; }; diff --git a/include/clang/AST/Mangle.h b/include/clang/AST/Mangle.h index 7b725b6..4872738 100644 --- a/include/clang/AST/Mangle.h +++ b/include/clang/AST/Mangle.h @@ -216,9 +216,6 @@ public: uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex, raw_ostream &Out) = 0; - virtual void mangleCXXCatchHandlerType(QualType T, uint32_t Flags, - raw_ostream &Out) = 0; - virtual void mangleCXXRTTIBaseClassDescriptor( const CXXRecordDecl *Derived, uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBTableOffset, uint32_t Flags, raw_ostream &Out) = 0; diff --git a/include/clang/AST/OpenMPClause.h b/include/clang/AST/OpenMPClause.h index bb982f3..7632a4b 100644 --- a/include/clang/AST/OpenMPClause.h +++ b/include/clang/AST/OpenMPClause.h @@ -84,21 +84,15 @@ protected: /// \brief Fetches list of variables associated with this clause. MutableArrayRef<Expr *> getVarRefs() { return MutableArrayRef<Expr *>( - reinterpret_cast<Expr **>( - reinterpret_cast<char *>(this) + - llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<Expr *>())), - NumVars); + static_cast<T *>(this)->template getTrailingObjects<Expr *>(), NumVars); } /// \brief Sets the list of variables for this clause. void setVarRefs(ArrayRef<Expr *> VL) { assert(VL.size() == NumVars && "Number of variables is not the same as the preallocated buffer"); - std::copy( - VL.begin(), VL.end(), - reinterpret_cast<Expr **>( - reinterpret_cast<char *>(this) + - llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<Expr *>()))); + std::copy(VL.begin(), VL.end(), + static_cast<T *>(this)->template getTrailingObjects<Expr *>()); } /// \brief Build a clause with \a N variables @@ -142,9 +136,7 @@ public: /// \brief Fetches list of all variables in the clause. ArrayRef<const Expr *> getVarRefs() const { return llvm::makeArrayRef( - reinterpret_cast<const Expr *const *>( - reinterpret_cast<const char *>(this) + - llvm::RoundUpToAlignment(sizeof(T), llvm::alignOf<const Expr *>())), + static_cast<const T *>(this)->template getTrailingObjects<Expr *>(), NumVars); } }; @@ -1160,7 +1152,11 @@ public: /// In this example directive '#pragma omp parallel' has clause 'private' /// with the variables 'a' and 'b'. /// -class OMPPrivateClause : public OMPVarListClause<OMPPrivateClause> { +class OMPPrivateClause final + : public OMPVarListClause<OMPPrivateClause>, + private llvm::TrailingObjects<OMPPrivateClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Build clause with number of variables \a N. /// @@ -1252,7 +1248,11 @@ public: /// In this example directive '#pragma omp parallel' has clause 'firstprivate' /// with the variables 'a' and 'b'. /// -class OMPFirstprivateClause : public OMPVarListClause<OMPFirstprivateClause> { +class OMPFirstprivateClause final + : public OMPVarListClause<OMPFirstprivateClause>, + private llvm::TrailingObjects<OMPFirstprivateClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Build clause with number of variables \a N. @@ -1372,7 +1372,9 @@ public: /// \endcode /// In this example directive '#pragma omp simd' has clause 'lastprivate' /// with the variables 'a' and 'b'. -class OMPLastprivateClause : public OMPVarListClause<OMPLastprivateClause> { +class OMPLastprivateClause final + : public OMPVarListClause<OMPLastprivateClause>, + private llvm::TrailingObjects<OMPLastprivateClause, Expr *> { // There are 4 additional tail-allocated arrays at the end of the class: // 1. Contains list of pseudo variables with the default initialization for // each non-firstprivate variables. Used in codegen for initialization of @@ -1390,6 +1392,8 @@ class OMPLastprivateClause : public OMPVarListClause<OMPLastprivateClause> { // Required for proper codegen of final assignment performed by the // lastprivate clause. // + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Build clause with number of variables \a N. @@ -1557,7 +1561,11 @@ public: /// In this example directive '#pragma omp parallel' has clause 'shared' /// with the variables 'a' and 'b'. /// -class OMPSharedClause : public OMPVarListClause<OMPSharedClause> { +class OMPSharedClause final + : public OMPVarListClause<OMPSharedClause>, + private llvm::TrailingObjects<OMPSharedClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; /// \brief Build clause with number of variables \a N. /// /// \param StartLoc Starting location of the clause. @@ -1617,7 +1625,11 @@ public: /// In this example directive '#pragma omp parallel' has clause 'reduction' /// with operator '+' and the variables 'a' and 'b'. /// -class OMPReductionClause : public OMPVarListClause<OMPReductionClause> { +class OMPReductionClause final + : public OMPVarListClause<OMPReductionClause>, + private llvm::TrailingObjects<OMPReductionClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Location of ':'. SourceLocation ColonLoc; @@ -1819,7 +1831,11 @@ public: /// In this example directive '#pragma omp simd' has clause 'linear' /// with variables 'a', 'b' and linear step '2'. /// -class OMPLinearClause : public OMPVarListClause<OMPLinearClause> { +class OMPLinearClause final + : public OMPVarListClause<OMPLinearClause>, + private llvm::TrailingObjects<OMPLinearClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Modifier of 'linear' clause. OpenMPLinearClauseKind Modifier; @@ -2039,7 +2055,11 @@ public: /// In this example directive '#pragma omp simd' has clause 'aligned' /// with variables 'a', 'b' and alignment '8'. /// -class OMPAlignedClause : public OMPVarListClause<OMPAlignedClause> { +class OMPAlignedClause final + : public OMPVarListClause<OMPAlignedClause>, + private llvm::TrailingObjects<OMPAlignedClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Location of ':'. SourceLocation ColonLoc; @@ -2123,7 +2143,9 @@ public: /// In this example directive '#pragma omp parallel' has clause 'copyin' /// with the variables 'a' and 'b'. /// -class OMPCopyinClause : public OMPVarListClause<OMPCopyinClause> { +class OMPCopyinClause final + : public OMPVarListClause<OMPCopyinClause>, + private llvm::TrailingObjects<OMPCopyinClause, Expr *> { // Class has 3 additional tail allocated arrays: // 1. List of helper expressions for proper generation of assignment operation // required for copyin clause. This list represents sources. @@ -2137,6 +2159,8 @@ class OMPCopyinClause : public OMPVarListClause<OMPCopyinClause> { // threadprivate variables to local instances of that variables in other // implicit threads. + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Build clause with number of variables \a N. /// @@ -2282,7 +2306,11 @@ public: /// In this example directive '#pragma omp single' has clause 'copyprivate' /// with the variables 'a' and 'b'. /// -class OMPCopyprivateClause : public OMPVarListClause<OMPCopyprivateClause> { +class OMPCopyprivateClause final + : public OMPVarListClause<OMPCopyprivateClause>, + private llvm::TrailingObjects<OMPCopyprivateClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Build clause with number of variables \a N. /// @@ -2431,7 +2459,11 @@ public: /// In this example directive '#pragma omp flush' has implicit clause 'flush' /// with the variables 'a' and 'b'. /// -class OMPFlushClause : public OMPVarListClause<OMPFlushClause> { +class OMPFlushClause final + : public OMPVarListClause<OMPFlushClause>, + private llvm::TrailingObjects<OMPFlushClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; /// \brief Build clause with number of variables \a N. /// /// \param StartLoc Starting location of the clause. @@ -2491,7 +2523,11 @@ public: /// In this example directive '#pragma omp task' with clause 'depend' with the /// variables 'a' and 'b' with dependency 'in'. /// -class OMPDependClause : public OMPVarListClause<OMPDependClause> { +class OMPDependClause final + : public OMPVarListClause<OMPDependClause>, + private llvm::TrailingObjects<OMPDependClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Dependency type (one of in, out, inout). OpenMPDependClauseKind DepKind; @@ -2695,7 +2731,10 @@ public: /// In this example directive '#pragma omp target' has clause 'map' /// with the variables 'a' and 'b'. /// -class OMPMapClause : public OMPVarListClause<OMPMapClause> { +class OMPMapClause final : public OMPVarListClause<OMPMapClause>, + private llvm::TrailingObjects<OMPMapClause, Expr *> { + friend TrailingObjects; + friend OMPVarListClause; friend class OMPClauseReader; /// \brief Map type modifier for the 'map' clause. diff --git a/include/clang/Basic/Builtins.h b/include/clang/Basic/Builtins.h index 41f19e7..c0a6af9 100644 --- a/include/clang/Basic/Builtins.h +++ b/include/clang/Basic/Builtins.h @@ -192,6 +192,10 @@ public: /// for AuxTarget). unsigned getAuxBuiltinID(unsigned ID) const { return ID - TSRecords.size(); } + /// Returns true if this is a libc/libm function without the '__builtin_' + /// prefix. + static bool isBuiltinFunc(const char *Name); + private: const Info &getRecord(unsigned ID) const; diff --git a/include/clang/Basic/BuiltinsX86.def b/include/clang/Basic/BuiltinsX86.def index 91111f6..f738cc1 100644 --- a/include/clang/Basic/BuiltinsX86.def +++ b/include/clang/Basic/BuiltinsX86.def @@ -41,6 +41,13 @@ TARGET_BUILTIN(__builtin_ia32_undef128, "V2d", "nc", "") TARGET_BUILTIN(__builtin_ia32_undef256, "V4d", "nc", "") TARGET_BUILTIN(__builtin_ia32_undef512, "V8d", "nc", "") +// FLAGS +// +TARGET_BUILTIN(__builtin_ia32_readeflags_u32, "Ui", "n", "") +TARGET_BUILTIN(__builtin_ia32_readeflags_u64, "ULLi", "n", "") +TARGET_BUILTIN(__builtin_ia32_writeeflags_u32, "vUi", "n", "") +TARGET_BUILTIN(__builtin_ia32_writeeflags_u64, "vULLi", "n", "") + // 3DNow! // TARGET_BUILTIN(__builtin_ia32_femms, "v", "", "3dnow") @@ -917,6 +924,9 @@ TARGET_BUILTIN(__builtin_ia32_xtest, "i", "", "rtm") BUILTIN(__builtin_ia32_rdpmc, "ULLii", "") BUILTIN(__builtin_ia32_rdtsc, "ULLi", "") BUILTIN(__builtin_ia32_rdtscp, "ULLiUi*", "") +// PKU +TARGET_BUILTIN(__builtin_ia32_rdpkru, "Ui", "", "pku") +TARGET_BUILTIN(__builtin_ia32_wrpkru, "vUi", "", "pku") // AVX-512 TARGET_BUILTIN(__builtin_ia32_sqrtpd512_mask, "V8dV8dV8dUcIi", "", "avx512f") diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index 7a71285..ce270bf 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -123,6 +123,9 @@ def err_drv_emit_llvm_link : Error< def err_drv_optimization_remark_pattern : Error< "%0 in '%1'">; def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, please use [no]simd instead">; +def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">; +def err_drv_omp_host_ir_file_not_found : Error< + "The provided host compiler IR file '%0' is required to generate code for OpenMP target regions but cannot be found.">; def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup<Deprecated>; def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed dir not found; using 'ld' default search path instead">, diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td index 446852a..f8dee2f 100644 --- a/include/clang/Basic/DiagnosticParseKinds.td +++ b/include/clang/Basic/DiagnosticParseKinds.td @@ -910,6 +910,10 @@ def warn_pragma_expected_enable_disable : Warning< def warn_pragma_unknown_extension : Warning< "unknown OpenCL extension %0 - ignoring">, InGroup<IgnoredPragmas>; +// OpenCL error +def err_opencl_taking_function_address_parser : Error< + "taking address of function is not allowed">; + // OpenMP support. def warn_pragma_omp_ignored : Warning< "unexpected '#pragma omp ...' in program">, InGroup<SourceUsesOpenMP>, DefaultIgnore; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 1f2791c..59f5095 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2400,6 +2400,8 @@ def warn_attribute_dll_instantiated_base_class : Warning< "propagating dll attribute to %select{already instantiated|explicitly specialized}0 " "base class template without dll attribute is not supported">, InGroup<DiagGroup<"unsupported-dll-base-class-template">>, DefaultIgnore; +def err_attribute_dll_ambiguous_default_ctor : Error< + "'__declspec(dllexport)' cannot be applied to more than one default constructor in %0">; def err_attribute_weakref_not_static : Error< "weakref declaration must have internal linkage">; def err_attribute_weakref_not_global_context : Error< @@ -3112,6 +3114,10 @@ def note_addrof_ovl_candidate_disabled_by_enable_if_attr : Note< def note_ovl_candidate_failed_overload_resolution : Note< "candidate template ignored: couldn't resolve reference to overloaded " "function %0">; +def note_ovl_candidate_deduced_mismatch : Note< + "candidate template ignored: deduced type " + "%diff{$ of %ordinal0 parameter does not match adjusted type $ of argument" + "|of %ordinal0 parameter does not match adjusted type of argument}1,2%3">; def note_ovl_candidate_non_deduced_mismatch : Note< "candidate template ignored: could not match %diff{$ against $|types}0,1">; // This note is needed because the above note would sometimes print two @@ -7969,6 +7975,8 @@ def err_omp_schedule_nonmonotonic_static : Error< "'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind">; def err_omp_schedule_nonmonotonic_ordered : Error< "'schedule' clause with 'nonmonotonic' modifier cannot be specified if an 'ordered' clause is specified">; +def err_omp_ordered_simd : Error< + "'ordered' clause with a parameter can not be specified in '#pragma omp %0' directive">; } // end of OpenMP category let CategoryName = "Related Result Type Issue" in { diff --git a/include/clang/Basic/LangOptions.def b/include/clang/Basic/LangOptions.def index fdf7e49..cc70d62 100644 --- a/include/clang/Basic/LangOptions.def +++ b/include/clang/Basic/LangOptions.def @@ -165,6 +165,8 @@ LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns") LANGOPT(CUDA , 1, 0, "CUDA") LANGOPT(OpenMP , 1, 0, "OpenMP support") LANGOPT(OpenMPUseTLS , 1, 0, "Use TLS for threadprivates or runtime calls") +LANGOPT(OpenMPIsDevice , 1, 0, "Generate code only for OpenMP target device") + LANGOPT(CUDAIsDevice , 1, 0, "Compiling for CUDA device") LANGOPT(CUDAAllowHostCallsFromHostDevice, 1, 0, "Allow host device functions to call host functions") LANGOPT(CUDADisableTargetCallChecks, 1, 0, "Disable checks for call targets (host, device, etc.)") diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index 3c9d23e..736d4e0 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -108,7 +108,18 @@ public: /// \brief Options for parsing comments. CommentOptions CommentOpts; - + + /// \brief A list of all -fno-builtin-* function names (e.g., memset). + std::vector<std::string> NoBuiltinFuncs; + + /// \brief Triples of the OpenMP targets that the host code codegen should + /// take into account in order to generate accurate offloading descriptors. + std::vector<llvm::Triple> OMPTargetTriples; + + /// \brief Name of the IR file that contains the result of the OpenMP target + /// host code generation. + std::string OMPHostIRFile; + LangOptions(); // Define accessors/mutators for language options of enumeration type. @@ -134,6 +145,10 @@ public: /// \brief Reset all of the options that are not considered when building a /// module. void resetNonModularOptions(); + + /// \brief Is this a libc/libm function that is no longer recognized as a + /// builtin because a -fno-builtin-* option has been specified? + bool isNoBuiltinFunc(const char *Name) const; }; /// \brief Floating point control options diff --git a/include/clang/Basic/OpenMPKinds.def b/include/clang/Basic/OpenMPKinds.def index 313e1c1..44f77ad 100644 --- a/include/clang/Basic/OpenMPKinds.def +++ b/include/clang/Basic/OpenMPKinds.def @@ -220,6 +220,7 @@ OPENMP_FOR_SIMD_CLAUSE(safelen) OPENMP_FOR_SIMD_CLAUSE(simdlen) OPENMP_FOR_SIMD_CLAUSE(linear) OPENMP_FOR_SIMD_CLAUSE(aligned) +OPENMP_FOR_SIMD_CLAUSE(ordered) // Clauses allowed for OpenMP directive 'omp sections'. OPENMP_SECTIONS_CLAUSE(private) @@ -303,6 +304,7 @@ OPENMP_PARALLEL_FOR_SIMD_CLAUSE(safelen) OPENMP_PARALLEL_FOR_SIMD_CLAUSE(simdlen) OPENMP_PARALLEL_FOR_SIMD_CLAUSE(linear) OPENMP_PARALLEL_FOR_SIMD_CLAUSE(aligned) +OPENMP_PARALLEL_FOR_SIMD_CLAUSE(ordered) // Clauses allowed for OpenMP directive 'parallel sections'. OPENMP_PARALLEL_SECTIONS_CLAUSE(if) diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index d7f42a9..051f903 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -677,6 +677,15 @@ def fcuda_include_gpubinary : Separate<["-"], "fcuda-include-gpubinary">, def fcuda_target_overloads : Flag<["-"], "fcuda-target-overloads">, HelpText<"Enable function overloads based on CUDA target attributes.">; +//===----------------------------------------------------------------------===// +// OpenMP Options +//===----------------------------------------------------------------------===// + +def fopenmp_is_device : Flag<["-"], "fopenmp-is-device">, + HelpText<"Generate code only for an OpenMP target device.">; +def omp_host_ir_file_path : Separate<["-"], "omp-host-ir-file-path">, + HelpText<"Path to the IR file produced by the frontend for the host.">; + } // let Flags = [CC1Option] diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 3dbe43f..e219a9b 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -814,7 +814,7 @@ def fno_blocks : Flag<["-"], "fno-blocks">, Group<f_Group>; def fno_borland_extensions : Flag<["-"], "fno-borland-extensions">, Group<f_Group>; def fno_builtin : Flag<["-"], "fno-builtin">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Disable implicit builtin knowledge of functions">; -def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group<clang_ignored_f_Group>, +def fno_builtin_ : Joined<["-"], "fno-builtin-">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Disable implicit builtin knowledge of a specific function">; def fno_math_builtin : Flag<["-"], "fno-math-builtin">, Group<f_Group>, Flags<[CC1Option]>, HelpText<"Disable implicit builtin knowledge of math functions">; @@ -1369,6 +1369,7 @@ def mno_xsave : Flag<["-"], "mno-xsave">, Group<m_x86_Features_Group>; def mno_xsaveopt : Flag<["-"], "mno-xsaveopt">, Group<m_x86_Features_Group>; def mno_xsavec : Flag<["-"], "mno-xsavec">, Group<m_x86_Features_Group>; def mno_xsaves : Flag<["-"], "mno-xsaves">, Group<m_x86_Features_Group>; +def mno_pku : Flag<["-"], "mno-pku">, Group<m_x86_Features_Group>; def munaligned_access : Flag<["-"], "munaligned-access">, Group<m_arm_Features_Group>, HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">; @@ -1384,6 +1385,8 @@ def mno_restrict_it: Flag<["-"], "mno-restrict-it">, Group<m_arm_Features_Group> def marm : Flag<["-"], "marm">, Alias<mno_thumb>; def ffixed_r9 : Flag<["-"], "ffixed-r9">, Group<m_arm_Features_Group>, HelpText<"Reserve the r9 register (ARM only)">; +def mno_movt : Flag<["-"], "mno-movt">, Group<m_arm_Features_Group>, + HelpText<"Disallow use of movt/movw pairs (ARM only)">; def mcrc : Flag<["-"], "mcrc">, Group<m_arm_Features_Group>, HelpText<"Allow use of CRC instructions (ARM only)">; def mnocrc : Flag<["-"], "mnocrc">, Group<m_arm_Features_Group>, @@ -1520,6 +1523,7 @@ def mf16c : Flag<["-"], "mf16c">, Group<m_x86_Features_Group>; def mrtm : Flag<["-"], "mrtm">, Group<m_x86_Features_Group>; def mprfchw : Flag<["-"], "mprfchw">, Group<m_x86_Features_Group>; def mrdseed : Flag<["-"], "mrdseed">, Group<m_x86_Features_Group>; +def mpku : Flag<["-"], "mpku">, Group<m_x86_Features_Group>; def madx : Flag<["-"], "madx">, Group<m_x86_Features_Group>; def msha : Flag<["-"], "msha">, Group<m_x86_Features_Group>; def mcx16 : Flag<["-"], "mcx16">, Group<m_x86_Features_Group>; @@ -1647,6 +1651,8 @@ def nostdlib : Flag<["-"], "nostdlib">; def object : Flag<["-"], "object">; def o : JoinedOrSeparate<["-"], "o">, Flags<[DriverOption, RenderAsInput, CC1Option, CC1AsOption]>, HelpText<"Write output to <file>">, MetaVarName<"<file>">; +def omptargets_EQ : CommaJoined<["-"], "omptargets=">, Flags<[DriverOption, CC1Option]>, + HelpText<"Specify comma-separated list of triples OpenMP offloading targets to be supported">; def pagezero__size : JoinedOrSeparate<["-"], "pagezero_size">; def pass_exit_codes : Flag<["-", "--"], "pass-exit-codes">, Flags<[Unsupported]>; def pedantic_errors : Flag<["-", "--"], "pedantic-errors">, Group<pedantic_Group>, Flags<[CC1Option]>; diff --git a/include/clang/Frontend/CodeGenOptions.h b/include/clang/Frontend/CodeGenOptions.h index fac6f1a..7550e6f 100644 --- a/include/clang/Frontend/CodeGenOptions.h +++ b/include/clang/Frontend/CodeGenOptions.h @@ -218,6 +218,9 @@ public: /// Set of sanitizer checks that trap rather than diagnose. SanitizerSet SanitizeTrap; + /// \brief A list of all -fno-builtin-* function names (e.g., memset). + std::vector<std::string> NoBuiltinFuncs; + public: // Define accessors/mutators for code generation options of enumeration type. #define CODEGENOPT(Name, Bits, Default) @@ -227,6 +230,14 @@ public: #include "clang/Frontend/CodeGenOptions.def" CodeGenOptions(); + + /// \brief Is this a libc/libm function that is no longer recognized as a + /// builtin because a -fno-builtin-* option has been specified? + bool isNoBuiltinFunc(const char *Name) const; + + const std::vector<std::string> &getNoBuiltinFuncs() const { + return NoBuiltinFuncs; + } }; } // end namespace clang diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 7873843..77d06f2 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -3416,7 +3416,6 @@ public: bool LookupInlineAsmField(StringRef Base, StringRef Member, unsigned &Offset, SourceLocation AsmLoc); ExprResult LookupInlineAsmVarDeclField(Expr *RefExpr, StringRef Member, - unsigned &Offset, llvm::InlineAsmIdentifierInfo &Info, SourceLocation AsmLoc); StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, @@ -6302,6 +6301,9 @@ public: /// \brief Substitution of the deduced template argument values /// resulted in an error. TDK_SubstitutionFailure, + /// \brief After substituting deduced template arguments, a dependent + /// parameter type did not match the corresponding argument. + TDK_DeducedMismatch, /// \brief A non-depnedent component of the parameter did not match the /// corresponding component of the argument. TDK_NonDeducedMismatch, diff --git a/include/clang/Sema/TemplateDeduction.h b/include/clang/Sema/TemplateDeduction.h index 9315ddd..c22c703 100644 --- a/include/clang/Sema/TemplateDeduction.h +++ b/include/clang/Sema/TemplateDeduction.h @@ -140,6 +140,9 @@ public: /// TDK_SubstitutionFailure: this argument is the template /// argument we were instantiating when we encountered an error. /// + /// TDK_DeducedMismatch: this is the parameter type, after substituting + /// deduced arguments. + /// /// TDK_NonDeducedMismatch: this is the component of the 'parameter' /// of the deduction, directly provided in the source code. TemplateArgument FirstArg; @@ -147,18 +150,32 @@ public: /// \brief The second template argument to which the template /// argument deduction failure refers. /// + /// TDK_Inconsistent: this argument is the second value deduced + /// for the corresponding template parameter. + /// + /// TDK_DeducedMismatch: this is the (adjusted) call argument type. + /// /// TDK_NonDeducedMismatch: this is the mismatching component of the /// 'argument' of the deduction, from which we are deducing arguments. /// /// FIXME: Finish documenting this. TemplateArgument SecondArg; - /// \brief The expression which caused a deduction failure. - /// - /// TDK_FailedOverloadResolution: this argument is the reference to - /// an overloaded function which could not be resolved to a specific - /// function. - Expr *Expression; + union { + /// \brief The expression which caused a deduction failure. + /// + /// TDK_FailedOverloadResolution: this argument is the reference to + /// an overloaded function which could not be resolved to a specific + /// function. + Expr *Expression; + + /// \brief The index of the function argument that caused a deduction + /// failure. + /// + /// TDK_DeducedMismatch: this is the index of the argument that had a + /// different argument type from its substituted parameter type. + unsigned CallArgIndex; + }; /// \brief Information on packs that we're currently expanding. /// @@ -211,6 +228,10 @@ struct DeductionFailureInfo { /// if any. Expr *getExpr(); + /// \brief Return the index of the call argument that this deduction + /// failure refers to, if any. + llvm::Optional<unsigned> getCallArgIndex(); + /// \brief Free any memory associated with this deduction failure. void Destroy(); }; |