diff options
Diffstat (limited to 'include/clang/Sema/DeclSpec.h')
-rw-r--r-- | include/clang/Sema/DeclSpec.h | 110 |
1 files changed, 92 insertions, 18 deletions
diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index a66649955c8c..3260a70ebb4f 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -34,7 +34,7 @@ namespace clang { class ASTContext; class TypeLoc; class LangOptions; - class Diagnostic; + class DiagnosticsEngine; class IdentifierInfo; class NamespaceAliasDecl; class NamespaceDecl; @@ -42,6 +42,7 @@ namespace clang { class NestedNameSpecifierLoc; class ObjCDeclSpec; class Preprocessor; + class Sema; class Declarator; struct TemplateIdAnnotation; @@ -242,6 +243,7 @@ public: static const TST TST_char16 = clang::TST_char16; static const TST TST_char32 = clang::TST_char32; static const TST TST_int = clang::TST_int; + static const TST TST_half = clang::TST_half; static const TST TST_float = clang::TST_float; static const TST TST_double = clang::TST_double; static const TST TST_bool = clang::TST_bool; @@ -259,6 +261,7 @@ public: static const TST TST_underlyingType = clang::TST_underlyingType; 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_error = clang::TST_error; // type-qualifiers @@ -345,7 +348,7 @@ private: SourceRange TypeofParensRange; SourceLocation TQ_constLoc, TQ_restrictLoc, TQ_volatileLoc; SourceLocation FS_inlineLoc, FS_virtualLoc, FS_explicitLoc; - SourceLocation FriendLoc, ConstexprLoc; + SourceLocation FriendLoc, ModulePrivateLoc, ConstexprLoc; WrittenBuiltinSpecs writtenBS; void SaveWrittenBuiltinSpecs(); @@ -355,7 +358,7 @@ private: static bool isTypeRep(TST T) { return (T == TST_typename || T == TST_typeofType || - T == TST_underlyingType); + T == TST_underlyingType || T == TST_atomic); } static bool isExprRep(TST T) { return (T == TST_typeofExpr || T == TST_decltype); @@ -381,7 +384,7 @@ public: TypeAltiVecPixel(false), TypeAltiVecBool(false), TypeSpecOwned(false), - TypeQualifiers(TSS_unspecified), + TypeQualifiers(TQ_unspecified), FS_inline_specified(false), FS_virtual_specified(false), FS_explicit_specified(false), @@ -537,8 +540,8 @@ public: /// /// TODO: use a more general approach that still allows these /// diagnostics to be ignored when desired. - bool SetStorageClassSpec(SCS S, SourceLocation Loc, const char *&PrevSpec, - unsigned &DiagID, const LangOptions &Lang); + bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, + const char *&PrevSpec, unsigned &DiagID); bool SetStorageClassSpecThread(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); bool SetTypeSpecWidth(TSW W, SourceLocation Loc, const char *&PrevSpec, @@ -592,13 +595,17 @@ public: bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); - + bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, + unsigned &DiagID); bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID); bool isFriendSpecified() const { return Friend_specified; } SourceLocation getFriendSpecLoc() const { return FriendLoc; } + bool isModulePrivateSpecified() const { return ModulePrivateLoc.isValid(); } + SourceLocation getModulePrivateSpecLoc() const { return ModulePrivateLoc; } + bool isConstexprSpecified() const { return Constexpr_specified; } SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; } @@ -657,7 +664,7 @@ 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(Diagnostic &D, Preprocessor &PP); + void Finish(DiagnosticsEngine &D, Preprocessor &PP); const WrittenBuiltinSpecs& getWrittenBuiltinSpecs() const { return writtenBS; @@ -732,6 +739,7 @@ public: const IdentifierInfo *getSetterName() const { return SetterName; } IdentifierInfo *getSetterName() { return SetterName; } 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 @@ -961,7 +969,7 @@ public: /// CachedTokens - A set of tokens that has been cached for later /// parsing. -typedef llvm::SmallVector<Token, 4> CachedTokens; +typedef SmallVector<Token, 4> CachedTokens; /// DeclaratorChunk - One instance of this struct is used for each type in a /// declarator that is parsed. @@ -1222,7 +1230,7 @@ struct DeclaratorChunk { void destroy() { switch (Kind) { - default: assert(0 && "Unknown decl type!"); + default: llvm_unreachable("Unknown decl type!"); case DeclaratorChunk::Function: return Fun.destroy(); case DeclaratorChunk::Pointer: return Ptr.destroy(); case DeclaratorChunk::BlockPointer: return Cls.destroy(); @@ -1364,7 +1372,8 @@ public: enum TheContext { FileContext, // File scope declaration. PrototypeContext, // Within a function prototype. - ObjCPrototypeContext,// Within a method prototype. + ObjCResultContext, // An ObjC method result type. + ObjCParameterContext,// An ObjC method parameter type. KNRTypeListContext, // K&R type definition list for formals. TypeNameContext, // Abstract declarator for types. MemberContext, // Struct/Union field. @@ -1395,7 +1404,7 @@ private: /// parsed. This is pushed from the identifier out, which means that element /// #0 will be the most closely bound to the identifier, and /// DeclTypeInfo.back() will be the least closely bound. - llvm::SmallVector<DeclaratorChunk, 8> DeclTypeInfo; + SmallVector<DeclaratorChunk, 8> DeclTypeInfo; /// InvalidType - Set by Sema::GetTypeForDeclarator(). bool InvalidType : 1; @@ -1403,6 +1412,12 @@ private: /// GroupingParens - Set by Parser::ParseParenDeclarator(). bool GroupingParens : 1; + /// FunctionDefinition - Is this Declarator for a function or member defintion + bool FunctionDefinition : 1; + + // Redeclaration - Is this Declarator is a redeclaration. + bool Redeclaration : 1; + /// Attrs - Attributes. ParsedAttributes Attrs; @@ -1428,8 +1443,9 @@ public: Declarator(const DeclSpec &ds, TheContext C) : DS(ds), Range(ds.getSourceRange()), Context(C), InvalidType(DS.getTypeSpecType() == DeclSpec::TST_error), - GroupingParens(false), Attrs(ds.getAttributePool().getFactory()), - AsmLabel(0), InlineParamsUsed(false), Extension(false) { + GroupingParens(false), FunctionDefinition(false), Redeclaration(false), + Attrs(ds.getAttributePool().getFactory()), AsmLabel(0), + InlineParamsUsed(false), Extension(false) { } ~Declarator() { @@ -1462,7 +1478,9 @@ public: TheContext getContext() const { return Context; } bool isPrototypeContext() const { - return (Context == PrototypeContext || Context == ObjCPrototypeContext); + return (Context == PrototypeContext || + Context == ObjCParameterContext || + Context == ObjCResultContext); } /// getSourceRange - Get the source range that spans this declarator. @@ -1522,7 +1540,8 @@ public: case AliasDeclContext: case AliasTemplateContext: case PrototypeContext: - case ObjCPrototypeContext: + case ObjCParameterContext: + case ObjCResultContext: case TemplateParamContext: case CXXNewContext: case CXXCatchContext: @@ -1555,7 +1574,8 @@ public: case CXXNewContext: case AliasDeclContext: case AliasTemplateContext: - case ObjCPrototypeContext: + case ObjCParameterContext: + case ObjCResultContext: case BlockLiteralContext: case TemplateTypeArgContext: return false; @@ -1578,7 +1598,8 @@ public: case MemberContext: case ConditionContext: case PrototypeContext: - case ObjCPrototypeContext: + case ObjCParameterContext: + case ObjCResultContext: case TemplateParamContext: case CXXCatchContext: case ObjCCatchContext: @@ -1783,6 +1804,12 @@ public: bool hasEllipsis() const { return EllipsisLoc.isValid(); } SourceLocation getEllipsisLoc() const { return EllipsisLoc; } void setEllipsisLoc(SourceLocation EL) { EllipsisLoc = EL; } + + void setFunctionDefinition(bool Val) { FunctionDefinition = Val; } + bool isFunctionDefinition() const { return FunctionDefinition; } + + void setRedeclaration(bool Val) { Redeclaration = Val; } + bool isRedeclaration() const { return Redeclaration; } }; /// FieldDeclarator - This little struct is used to capture information about @@ -1828,6 +1855,53 @@ private: SourceLocation LastLocation; }; +/// LambdaCaptureDefault - The default, if any, capture method for a +/// lambda expression. +enum LambdaCaptureDefault { + LCD_None, + LCD_ByCopy, + LCD_ByRef +}; + +/// LambdaCaptureKind - The different capture forms in a lambda +/// introducer: 'this' or a copied or referenced variable. +enum LambdaCaptureKind { + LCK_This, + LCK_ByCopy, + LCK_ByRef +}; + +/// LambdaCapture - An individual capture in a lambda introducer. +struct LambdaCapture { + LambdaCaptureKind Kind; + SourceLocation Loc; + IdentifierInfo* Id; + + LambdaCapture(LambdaCaptureKind Kind, + SourceLocation Loc, + IdentifierInfo* Id = 0) + : Kind(Kind), Loc(Loc), Id(Id) + {} +}; + +/// LambdaIntroducer - Represents a complete lambda introducer. +struct LambdaIntroducer { + SourceRange Range; + LambdaCaptureDefault Default; + llvm::SmallVector<LambdaCapture, 4> Captures; + + LambdaIntroducer() + : Default(LCD_None) {} + + /// addCapture - Append a capture in a lambda introducer. + void addCapture(LambdaCaptureKind Kind, + SourceLocation Loc, + IdentifierInfo* Id = 0) { + Captures.push_back(LambdaCapture(Kind, Loc, Id)); + } + +}; + } // end namespace clang #endif |