clang  6.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/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/PrettyDeclStackTrace.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ScopedPrinter.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_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 attributeHasIdentifierArg (const IdentifierInfo &II)
 Determine whether the given attribute has an identifier argument. 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 bool isPtrOperatorToken (tok::TokenKind Kind, const LangOptions &Lang, unsigned 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_TYPE_ARG_LIST

#define CLANG_ATTR_TYPE_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 211 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 220 of file ParseDecl.cpp.

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

◆ attributeParsedArgsUnevaluated()

static bool attributeParsedArgsUnevaluated ( const IdentifierInfo II)
static

◆ getMissingDeclaratorIdLoc()

static SourceLocation getMissingDeclaratorIdLoc ( Declarator D,
SourceLocation  Loc 
)
static

Definition at line 5400 of file ParseDecl.cpp.

References clang::Declarator::AddTypeInfo(), clang::Declarator::AliasDeclContext, clang::Declarator::AliasTemplateContext, clang::DeclaratorChunk::Array, clang::DeclaratorChunk::TypeInfoCommon::AttrList, clang::Declarator::BlockLiteralContext, clang::DeclaratorChunk::BlockPointer, clang::DeclaratorChunk::Common, clang::Qualifiers::Const, clang::Sema::ConstantEvaluated, clang::BalancedDelimiterTracker::consumeClose(), clang::BalancedDelimiterTracker::consumeOpen(), clang::Parser::ConsumeToken(), clang::frontend::CPlusPlus, clang::frontend::CPlusPlus11, clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateInsertionFromRange(), clang::FixItHint::CreateRemoval(), clang::Scope::DeclScope, clang::Parser::Diag(), clang::UnqualifiedId::EndLocation, clang::comments::tok::eof, clang::EST_None, clang::Declarator::FileContext, clang::Declarator::ForContext, 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::DeclSpec::getConstSpecLoc(), clang::Declarator::getContext(), clang::Parser::getCurScope(), clang::Declarator::getCXXScopeSpec(), clang::Declarator::getDeclSpec(), clang::Declarator::getEllipsisLoc(), clang::SourceRange::getEnd(), clang::CXXScopeSpec::getEndLoc(), clang::Parser::getEndOfPreviousToken(), clang::DeclaratorChunk::getFunction(), clang::Declarator::getIdentifier(), clang::Token::getIdentifierInfo(), clang::Token::getKind(), clang::Parser::getLangOpts(), clang::Token::getLocation(), clang::Declarator::getLocEnd(), clang::Declarator::getName(), clang::Declarator::getNumTypeObjects(), clang::Parser::getObjCDeclContext(), clang::BalancedDelimiterTracker::getOpenLocation(), clang::DeclaratorChunk::getParen(), clang::BalancedDelimiterTracker::getRange(), clang::DeclSpec::getRestrictSpecLoc(), 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::getVolatileSpecLoc(), clang::Declarator::hasEllipsis(), clang::Declarator::hasGroupingParens(), clang::Declarator::hasName(), clang::DeclSpec::hasTypeSpecifier(), clang::Token::is(), clang::Token::isAtStartOfLine(), clang::DeclSpec::isConstexprSpecified(), 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(), clang::Token::isOneOf(), clang::Declarator::isPastIdentifier(), isPtrOperatorToken(), clang::CXXScopeSpec::isSet(), clang::ActionResult< PtrTy, CompressInvalid >::isUsable(), clang::SourceLocation::isValid(), clang::CXXScopeSpec::isValid(), clang::Declarator::LambdaExprContext, clang::Declarator::LambdaExprParameterContext, clang::Declarator::mayBeFollowedByCXXDirectInit(), clang::Declarator::mayHaveIdentifier(), clang::Declarator::mayOmitIdentifier(), clang::Declarator::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::Declarator::PrototypeContext, clang::DeclaratorChunk::Reference, clang::Result, clang::Sema::ReuseLambdaContextDecl, clang::DeclSpec::SCS_typedef, clang::ParsedAttributes::set(), 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::T, clang::DeclSpec::takeAttributesFrom(), clang::Declarator::TemplateTypeArgContext, clang::Declarator::TrailingReturnContext, 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

◆ isPipeDeclerator()

static bool isPipeDeclerator ( const Declarator D)
static

Definition at line 5198 of file ParseDecl.cpp.

References clang::Declarator::AddTypeInfo(), clang::Parser::ConsumeToken(), clang::frontend::CPlusPlus, clang::frontend::CPlusPlus11, clang::Declarator::CXXNewContext, clang::Parser::Diag(), clang::Declarator::ExtendWithDeclSpec(), clang::Declarator::FileContext, clang::DeclSpec::getAtomicSpecLoc(), clang::DeclSpec::getAttributes(), clang::DeclaratorChunk::getBlockPointer(), clang::DeclSpec::getConstSpecLoc(), clang::Declarator::getContext(), clang::Declarator::getCXXScopeSpec(), clang::Declarator::getDeclSpec(), clang::Declarator::getIdentifier(), clang::Token::getKind(), clang::Parser::getLangOpts(), clang::DeclSpec::getLocEnd(), 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::Declarator::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,
unsigned  TheContext 
)
static

◆ 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 2418 of file ParseDecl.cpp.

References clang::Parser::ConsumeToken(), clang::frontend::CPlusPlus, clang::FixItHint::CreateInsertion(), clang::Parser::Diag(), clang::Parser::getCurScope(), clang::Parser::getLangOpts(), clang::DeclSpec::getStorageClassSpec(), clang::DeclSpec::hasTypeSpecifier(), clang::format::FormatToken::is(), clang::CXXScopeSpec::isEmpty(), clang::Token::isOneOf(), clang::Sema::LookupOrdinaryName, clang::Parser::NextToken(), clang::DeclSpec::SCS_auto, clang::DeclSpec::SetRangeEnd(), clang::DeclSpec::SetTypeSpecType(), clang::T, 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

Normalizes an attribute name by dropping prefixed and suffixed __.

Definition at line 75 of file ParseDecl.cpp.

Referenced by attributeHasIdentifierArg(), attributeIsTypeArgAttr(), attributeParsedArgsUnevaluated(), and isAttributeLateParsed().

◆ VersionNumberSeparator()

static bool VersionNumberSeparator ( const char  Separator)
static