clang  10.0.0svn
Macros | Functions
ParseDecl.cpp File Reference
#include "clang/Parse/Parser.h"
#include "clang/Parse/RAIIObjectsForParser.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/PrettyDeclStackTrace.h"
#include "clang/Basic/AddressSpaces.h"
#include "clang/Basic/Attributes.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "clang/Parse/AttrParserStringSwitches.inc"
#include "clang/Basic/OpenCLImageTypes.def"
Include dependency graph for ParseDecl.cpp:

Go to the source code of this file.

Macros

#define CLANG_ATTR_LATE_PARSED_LIST
 
#define CLANG_ATTR_IDENTIFIER_ARG_LIST
 
#define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
 
#define CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
 
#define CLANG_ATTR_TYPE_ARG_LIST
 
#define CLANG_ATTR_ARG_CONTEXT_LIST
 
#define GENERIC_IMAGE_TYPE(ImgType, Id)
 
#define GENERIC_IMAGE_TYPE(ImgType, Id)   case tok::kw_##ImgType##_t:
 
#define GENERIC_IMAGE_TYPE(ImgType, Id)   case tok::kw_##ImgType##_t:
 
#define GENERIC_IMAGE_TYPE(ImgType, Id)   case tok::kw_##ImgType##_t:
 

Functions

static StringRef normalizeAttrName (StringRef Name)
 Normalizes an attribute name by dropping prefixed and suffixed __. More...
 
static bool isAttributeLateParsed (const IdentifierInfo &II)
 isAttributeLateParsed - Return true if the attribute has arguments that require late parsing. More...
 
static bool FindLocsWithCommonFileID (Preprocessor &PP, SourceLocation StartLoc, SourceLocation EndLoc)
 Check if the a start and end source location expand to the same macro. More...
 
static bool attributeHasIdentifierArg (const IdentifierInfo &II)
 Determine whether the given attribute has an identifier argument. More...
 
static bool attributeHasVariadicIdentifierArg (const IdentifierInfo &II)
 Determine whether the given attribute has a variadic identifier argument. More...
 
static bool attributeTreatsKeywordThisAsIdentifier (const IdentifierInfo &II)
 Determine whether the given attribute treats kw_this as an identifier. More...
 
static bool attributeIsTypeArgAttr (const IdentifierInfo &II)
 Determine whether the given attribute parses a type argument. More...
 
static bool attributeParsedArgsUnevaluated (const IdentifierInfo &II)
 Determine whether the given attribute requires parsing its arguments in an unevaluated context or not. More...
 
static bool VersionNumberSeparator (const char Separator)
 
static bool isValidAfterIdentifierInDeclarator (const Token &T)
 isValidAfterIdentifierInDeclaratorAfterDeclSpec - Return true if the specified token is valid after the identifier in a declarator which immediately follows the declspec. More...
 
static void SetupFixedPointError (const LangOptions &LangOpts, const char *&PrevSpec, unsigned &DiagID, bool &isInvalid)
 
static bool isPtrOperatorToken (tok::TokenKind Kind, const LangOptions &Lang, DeclaratorContext TheContext)
 
static bool isPipeDeclerator (const Declarator &D)
 
static SourceLocation getMissingDeclaratorIdLoc (Declarator &D, SourceLocation Loc)
 

Macro Definition Documentation

◆ CLANG_ATTR_ARG_CONTEXT_LIST

#define CLANG_ATTR_ARG_CONTEXT_LIST

◆ CLANG_ATTR_IDENTIFIER_ARG_LIST

#define CLANG_ATTR_IDENTIFIER_ARG_LIST

◆ CLANG_ATTR_LATE_PARSED_LIST

#define CLANG_ATTR_LATE_PARSED_LIST

◆ CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST

#define CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST

◆ CLANG_ATTR_TYPE_ARG_LIST

#define CLANG_ATTR_TYPE_ARG_LIST

◆ CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST

#define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST

◆ GENERIC_IMAGE_TYPE [1/4]

#define GENERIC_IMAGE_TYPE (   ImgType,
  Id 
)
Value:
case tok::kw_##ImgType##_t: \
isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, \
DiagID, Policy); \
break;

◆ GENERIC_IMAGE_TYPE [2/4]

#define GENERIC_IMAGE_TYPE (   ImgType,
  Id 
)    case tok::kw_##ImgType##_t:

◆ GENERIC_IMAGE_TYPE [3/4]

#define GENERIC_IMAGE_TYPE (   ImgType,
  Id 
)    case tok::kw_##ImgType##_t:

◆ GENERIC_IMAGE_TYPE [4/4]

#define GENERIC_IMAGE_TYPE (   ImgType,
  Id 
)    case tok::kw_##ImgType##_t:

Function Documentation

◆ attributeHasIdentifierArg()

static bool attributeHasIdentifierArg ( const IdentifierInfo II)
static

Determine whether the given attribute has an identifier argument.

Definition at line 247 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

Referenced by attributeParsedArgsUnevaluated().

◆ attributeHasVariadicIdentifierArg()

static bool attributeHasVariadicIdentifierArg ( const IdentifierInfo II)
static

Determine whether the given attribute has a variadic identifier argument.

Definition at line 256 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

Referenced by attributeParsedArgsUnevaluated().

◆ attributeIsTypeArgAttr()

static bool attributeIsTypeArgAttr ( const IdentifierInfo II)
static

Determine whether the given attribute parses a type argument.

Definition at line 274 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

Referenced by attributeParsedArgsUnevaluated().

◆ attributeParsedArgsUnevaluated()

static bool attributeParsedArgsUnevaluated ( const IdentifierInfo II)
static

◆ attributeTreatsKeywordThisAsIdentifier()

static bool attributeTreatsKeywordThisAsIdentifier ( const IdentifierInfo II)
static

Determine whether the given attribute treats kw_this as an identifier.

Definition at line 265 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

Referenced by attributeParsedArgsUnevaluated().

◆ FindLocsWithCommonFileID()

static bool FindLocsWithCommonFileID ( Preprocessor PP,
SourceLocation  StartLoc,
SourceLocation  EndLoc 
)
static

◆ getMissingDeclaratorIdLoc()

static SourceLocation getMissingDeclaratorIdLoc ( Declarator D,
SourceLocation  Loc 
)
static

Definition at line 5680 of file ParseDecl.cpp.

References clang::Qualifiers::addConst(), clang::Declarator::AddTypeInfo(), clang::AliasDeclContext, clang::AliasTemplateContext, clang::DeclaratorChunk::Array, clang::BlockLiteralContext, clang::DeclaratorChunk::BlockPointer, clang::Sema::ConstantEvaluated, clang::BalancedDelimiterTracker::consumeClose(), clang::BalancedDelimiterTracker::consumeOpen(), clang::Parser::ConsumeToken(), clang::CPlusPlus, clang::CPlusPlus11, clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateInsertionFromRange(), clang::FixItHint::CreateRemoval(), clang::Scope::DeclScope, clang::Default, clang::Parser::Diag(), clang::UnqualifiedId::EndLocation, clang::comments::tok::eof, clang::EST_None, clang::FileContext, clang::ForContext, clang::Qualifiers::fromCVRUMask(), clang::DeclaratorChunk::Function, clang::Scope::FunctionDeclarationScope, clang::Scope::FunctionPrototypeScope, clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::DeclaratorChunk::getArray(), clang::DeclSpec::getAttributes(), clang::SourceRange::getBegin(), clang::BalancedDelimiterTracker::getCloseLocation(), clang::Declarator::getContext(), clang::Parser::getCurScope(), clang::Declarator::getCXXScopeSpec(), clang::Declarator::getDeclSpec(), clang::Declarator::getEllipsisLoc(), clang::SourceRange::getEnd(), clang::CXXScopeSpec::getEndLoc(), clang::Declarator::getEndLoc(), clang::Parser::getEndOfPreviousToken(), clang::DeclaratorChunk::getFunction(), clang::Declarator::getIdentifier(), clang::Token::getIdentifierInfo(), clang::Token::getKind(), clang::Parser::getLangOpts(), clang::Token::getLocation(), clang::Declarator::getName(), clang::Declarator::getNumTypeObjects(), clang::Parser::getObjCDeclContext(), clang::BalancedDelimiterTracker::getOpenLocation(), clang::DeclaratorChunk::getParen(), clang::BalancedDelimiterTracker::getRange(), clang::DeclSpec::getSourceRange(), clang::UnqualifiedId::getSourceRange(), clang::Declarator::getSourceRange(), clang::DeclSpec::getStorageClassSpec(), clang::Declarator::getTypeObject(), clang::DeclSpec::getTypeQualifiers(), clang::DeclSpec::getTypeSpecType(), clang::DeclSpec::getTypeSpecTypeLoc(), clang::DeclSpec::hasConstexprSpecifier(), clang::Declarator::hasEllipsis(), clang::Declarator::hasGroupingParens(), clang::Declarator::hasName(), clang::DeclSpec::hasTypeSpecifier(), clang::Token::is(), clang::Token::isAtStartOfLine(), clang::IdentifierInfo::isCPlusPlusKeyword(), clang::CXXScopeSpec::isEmpty(), clang::DeclSpec::isEmpty(), clang::Declarator::isFirstDeclarationOfMember(), clang::DeclSpec::isFriendSpecified(), clang::Declarator::isFunctionDeclaratorAFunctionDeclaration(), clang::SourceLocation::isInvalid(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::CXXScopeSpec::isInvalid(), clang::Declarator::isInvalidType(), clang::Token::isNot(), clang::CXXScopeSpec::isNotEmpty(), isOneOf(), clang::Token::isOneOf(), clang::Declarator::isPastIdentifier(), isPtrOperatorToken(), clang::CXXScopeSpec::isSet(), clang::ActionResult< PtrTy, CompressInvalid >::isUsable(), clang::SourceLocation::isValid(), clang::CXXScopeSpec::isValid(), clang::LambdaExprContext, clang::LambdaExprParameterContext, clang::Declarator::mayBeFollowedByCXXDirectInit(), clang::Declarator::mayHaveIdentifier(), clang::Declarator::mayOmitIdentifier(), clang::MemberContext, clang::DeclaratorChunk::MemberPointer, clang::Parser::NextToken(), clang::DeclaratorChunk::Paren, clang::Parser::ParseAssignmentExpression(), clang::Parser::ParseConstantExpression(), clang::Parser::ParseTypeName(), clang::Parser::ParseUnqualifiedId(), clang::DeclaratorChunk::Pipe, clang::DeclaratorChunk::Pointer, clang::Sema::PotentiallyEvaluatedIfUsed, clang::PrototypeContext, clang::DeclaratorChunk::Reference, clang::Result, clang::Sema::ReuseLambdaContextDecl, clang::DeclSpec::SCS_typedef, clang::Declarator::setDecompositionBindings(), clang::Declarator::setEllipsisLoc(), clang::Declarator::setGroupingParens(), clang::Declarator::SetIdentifier(), clang::Declarator::setInvalidType(), clang::Declarator::SetRangeBegin(), clang::DeclSpec::SetRangeEnd(), clang::Declarator::SetRangeEnd(), clang::DeclSpec::setTypeofParensRange(), clang::DeclSpec::SetTypeSpecError(), clang::DeclSpec::SetTypeSpecType(), clang::BalancedDelimiterTracker::skipToEnd(), clang::Parser::SkipUntil(), clang::UnqualifiedId::StartLocation, clang::Parser::StopAtSemi, clang::Parser::StopBeforeMatch, clang::DeclSpec::takeAttributesFrom(), clang::TemplateArgContext, clang::TrailingReturnContext, clang::TrailingReturnVarContext, clang::Parser::TryAnnotateTypeOrScopeToken(), clang::Parser::TryConsumeToken(), clang::DeclSpec::TST_atomic, clang::TST_auto, clang::DeclSpec::TST_typeofExpr, clang::DeclSpec::TST_typeofType, clang::Sema::Unevaluated, and X.

◆ isAttributeLateParsed()

static bool isAttributeLateParsed ( const IdentifierInfo II)
static

isAttributeLateParsed - Return true if the attribute has arguments that require late parsing.

Definition at line 80 of file ParseDecl.cpp.

References clang::IdentifierInfo::getName(), and normalizeAttrName().

Referenced by FindLocsWithCommonFileID().

◆ isPipeDeclerator()

static bool isPipeDeclerator ( const Declarator D)
static

Definition at line 5482 of file ParseDecl.cpp.

References clang::Declarator::AddTypeInfo(), clang::Parser::ConsumeToken(), clang::CPlusPlus, clang::CPlusPlus11, clang::CXXNewContext, clang::Parser::Diag(), clang::Declarator::ExtendWithDeclSpec(), clang::FileContext, clang::DeclSpec::getAtomicSpecLoc(), clang::DeclSpec::getAttributes(), clang::DeclaratorChunk::getBlockPointer(), clang::DeclSpec::getConstSpecLoc(), clang::Declarator::getContext(), clang::Declarator::getCXXScopeSpec(), clang::Declarator::getDeclSpec(), clang::DeclSpec::getEndLoc(), clang::Declarator::getIdentifier(), clang::Token::getKind(), clang::Parser::getLangOpts(), clang::DeclaratorChunk::getMemberPointer(), clang::Declarator::getNumTypeObjects(), clang::DeclaratorChunk::getPipe(), clang::DeclSpec::getPipeLoc(), clang::DeclaratorChunk::getPointer(), clang::DeclaratorChunk::getReference(), clang::DeclSpec::getRestrictSpecLoc(), clang::Declarator::getTypeObject(), clang::DeclSpec::getTypeQualifiers(), clang::DeclSpec::getUnalignedSpecLoc(), clang::DeclSpec::getVolatileSpecLoc(), clang::Token::is(), clang::Token::isNot(), clang::CXXScopeSpec::isNotEmpty(), isPtrOperatorToken(), clang::DeclSpec::isTypeSpecPipe(), clang::DeclaratorChunk::Kind, clang::DeclaratorChunk::Loc, clang::Declarator::mayHaveIdentifier(), clang::Declarator::mayOmitIdentifier(), clang::MemberContext, clang::Parser::NextToken(), clang::DeclaratorChunk::Pipe, clang::DeclaratorChunk::Reference, clang::Declarator::setExtension(), clang::Declarator::SetRangeEnd(), clang::DeclSpec::TQ_atomic, clang::DeclSpec::TQ_const, clang::DeclSpec::TQ_unspecified, and clang::DeclSpec::TQ_volatile.

◆ isPtrOperatorToken()

static bool isPtrOperatorToken ( tok::TokenKind  Kind,
const LangOptions Lang,
DeclaratorContext  TheContext 
)
static

Definition at line 5453 of file ParseDecl.cpp.

References clang::ConversionIdContext, and clang::CXXNewContext.

Referenced by getMissingDeclaratorIdLoc(), and isPipeDeclerator().

◆ isValidAfterIdentifierInDeclarator()

static bool isValidAfterIdentifierInDeclarator ( const Token T)
static

isValidAfterIdentifierInDeclaratorAfterDeclSpec - Return true if the specified token is valid after the identifier in a declarator which immediately follows the declspec.

For example, these things are valid:

int x [ 4]; // direct-declarator int x ( int y); // direct-declarator int(int x ) // direct-declarator int x ; // simple-declaration int x = 17; // init-declarator-list int x , y; // init-declarator-list int x asm ("foo"); // init-declarator-list int x : 4; // struct-declarator int x { 5}; // C++'0x unified initializers

This is not, because 'x' does not immediately follow the declspec (though ')' happens to be valid anyway). int (x)

Definition at line 2542 of file ParseDecl.cpp.

References clang::LookupResult::begin(), clang::Parser::ConsumeToken(), clang::CPlusPlus, clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateReplacement(), clang::Parser::Diag(), clang::LookupResult::end(), clang::Parser::getCurScope(), getKind(), clang::Parser::getLangOpts(), clang::IdentifierInfo::getName(), clang::DeclSpec::getStorageClassSpec(), clang::IdentifierInfo::getTokenID(), clang::DeclSpec::hasTypeSpecifier(), clang::Token::is(), clang::format::FormatToken::is(), clang::CXXScopeSpec::isEmpty(), clang::Token::isOneOf(), clang::DeclSpec::isTypeSpecPipe(), clang::Sema::LookupOrdinaryName, clang::Parser::NextToken(), clang::DeclSpec::SCS_auto, clang::DeclSpec::SetRangeEnd(), clang::DeclSpec::SetTypeSpecError(), clang::DeclSpec::SetTypeSpecType(), clang::DeclSpec::TST_class, clang::DeclSpec::TST_enum, clang::DeclSpec::TST_interface, clang::DeclSpec::TST_struct, clang::DeclSpec::TST_typename, and clang::DeclSpec::TST_union.

◆ normalizeAttrName()

static StringRef normalizeAttrName ( StringRef  Name)
static

◆ SetupFixedPointError()

static void SetupFixedPointError ( const LangOptions LangOpts,
const char *&  PrevSpec,
unsigned &  DiagID,
bool isInvalid 
)
static

◆ VersionNumberSeparator()

static bool VersionNumberSeparator ( const char  Separator)
static