clang 8.0.0

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_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:

## 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 | attributeHasVariadicIdentifierArg (const IdentifierInfo &II)
| Determine whether the given attribute has a variadic 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 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_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 209 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 218 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 227 of file ParseDecl.cpp.

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

## ◆ attributeParsedArgsUnevaluated()

static bool attributeParsedArgsUnevaluated | ( | const IdentifierInfo & | II | ) |
| static

Determine whether the given attribute requires parsing its arguments in an unevaluated context or not.

Definition at line 237 of file ParseDecl.cpp.

References clang::ParsedAttributes::addNew(), clang::ParsedAttributes::addNewTypeAttr(), attributeHasIdentifierArg(), attributeHasVariadicIdentifierArg(), clang::BalancedDelimiterTracker::consumeClose(), clang::BalancedDelimiterTracker::consumeOpen(), clang::Parser::ConsumeToken(), clang::Sema::Context, clang::IdentifierLoc::create(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::BalancedDelimiterTracker::getCloseLocation(), clang::Token::getIdentifierInfo(), clang::ParsedAttr::getKind(), clang::Token::getLocation(), clang::IdentifierInfo::getName(), clang::ParsedAttr::IgnoredAttribute, clang::Token::is(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::Token::isNot(), clang::ActionResult< PtrTy, CompressInvalid >::isUsable(), normalizeAttrName(), clang::Parser::ParseTypeName(), and clang::ParsedAttr::UnknownAttribute.

## ◆ getMissingDeclaratorIdLoc()

static SourceLocation getMissingDeclaratorIdLoc | ( | Declarator & | D,
|  | SourceLocation | Loc
| ) |  |
| static

Definition at line 5506 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::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::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::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(), 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 81 of file ParseDecl.cpp.

References clang::ParsedAttributes::addNew(), clang::ParsedAttr::AS_GNU, clang::Parser::ConsumeToken(), clang::Token::getIdentifierInfo(), clang::Token::getLocation(), clang::IdentifierInfo::getName(), clang::Token::is(), clang::Token::isAnnotation(), clang::Token::isNot(), normalizeAttrName(), clang::Token::setLocation(), clang::Parser::SkipUntil(), clang::Token::startToken(), clang::Parser::StopAtSemi, and clang::Parser::TryConsumeToken().

## ◆ isPipeDeclerator()

static bool isPipeDeclerator | ( | const Declarator & | D | ) |
| static

Definition at line 5308 of file ParseDecl.cpp.

References clang::Declarator::AddTypeInfo(), clang::Parser::ConsumeToken(), clang::frontend::CPlusPlus, clang::frontend::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 5280 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 2453 of file ParseDecl.cpp.

References clang::LookupResult::begin(), clang::Parser::ConsumeToken(), clang::frontend::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::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

Normalizes an attribute name by dropping prefixed and suffixed __.

Definition at line 73 of file ParseDecl.cpp.

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

## ◆ SetupFixedPointError()

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

Definition at line 2885 of file ParseDecl.cpp.

References clang::Scope::AtCatchScope, clang::Scope::BlockScope, clang::Scope::ControlScope, clang::DeclSpec::Finish(), clang::Scope::FunctionPrototypeScope, clang::Parser::getCurScope(), clang::Scope::getFlags(), clang::Parser::getLangOpts(), clang::DeclSpec::getSourceRange(), clang::DeclSpec::getStorageClassSpec(), clang::DeclSpec::hasTypeSpecifier(), clang::format::FormatToken::is(), clang::DeclSpec::isFriendSpecified(), clang::SourceRange::isInvalid(), isInvalid(), clang::DeclSpec::isTypeAltiVecVector(), clang::Sema::PCC_Class, clang::Sema::PCC_LocalDeclarationSpecifiers, clang::Sema::PCC_MemberTemplate, clang::Sema::PCC_Namespace, clang::Sema::PCC_ObjCImplementation, clang::Sema::PCC_Template, clang::DeclSpec::SCS_typedef, clang::DeclSpec::SetRangeEnd(), clang::DeclSpec::SetRangeStart(), clang::DeclSpec::SetTypeSpecError(), clang::DeclSpec::takeAttributesFrom(), clang::Scope::TemplateParamScope, and clang::Parser::TryAnnotateCXXScopeToken().

## ◆ VersionNumberSeparator()

static bool VersionNumberSeparator | ( | const char | Separator | ) |
| static

Definition at line 769 of file ParseDecl.cpp.

References clang::BalancedDelimiterTracker::consumeOpen(), clang::Parser::ConsumeToken(), clang::Parser::Diag(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Token::getEndLoc(), clang::Token::getIdentifierInfo(), clang::Preprocessor::getIdentifierInfo(), clang::Token::getLength(), clang::Token::getLocation(), clang::IdentifierInfo::getName(), clang::Preprocessor::getSpelling(), clang::IdentifierLoc::Ident, clang::Token::is(), clang::isDigit(), clang::Token::isNot(), clang::IdentifierInfo::isStr(), clang::SourceLocation::isValid(), clang::AvailabilityChange::KeywordLoc, clang::Parser::SkipUntil(), clang::Parser::StopAtCodeCompletion, clang::Parser::StopAtSemi, clang::Parser::StopBeforeMatch, and clang::AvailabilityChange::Version.