22 #include "llvm/Support/Path.h" 23 using namespace clang;
33 explicit ActionCommentHandler(
Sema &S) : S(S) { }
44 if (!Ident__except && (getLangOpts().MicrosoftExt || getLangOpts().Borland))
45 Ident__except = PP.getIdentifierInfo(
"__except");
51 : PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
52 GreaterThanIsOperator(
true), ColonIsSacred(
false),
53 InMessageExpression(
false), TemplateParameterDepth(0),
54 ParsingInObjCContainer(
false) {
58 Actions.CurScope =
nullptr;
60 CurParsedObjCImpl =
nullptr;
64 initializePragmaHandlers();
66 CommentSemaHandler.reset(
new ActionCommentHandler(actions));
73 return Diags.
Report(Loc, DiagID);
102 switch (ExpectedTok) {
104 return Tok.
is(tok::colon) || Tok.
is(tok::comma);
105 default:
return false;
109 bool Parser::ExpectAndConsume(
tok::TokenKind ExpectedTok,
unsigned DiagID,
111 if (Tok.
is(ExpectedTok) || Tok.
is(tok::code_completion)) {
123 if (DiagID == diag::err_expected)
125 else if (DiagID == diag::err_expected_after)
126 DB << Msg << ExpectedTok;
137 const char *Spelling =
nullptr;
145 if (DiagID == diag::err_expected)
147 else if (DiagID == diag::err_expected_after)
148 DB << Msg << ExpectedTok;
155 bool Parser::ExpectAndConsumeSemi(
unsigned DiagID) {
159 if (Tok.
is(tok::code_completion)) {
160 handleUnexpectedCodeCompletionToken();
164 if ((Tok.
is(tok::r_paren) || Tok.
is(tok::r_square)) &&
166 Diag(Tok, diag::err_extraneous_token_before_semi)
174 return ExpectAndConsume(tok::semi, DiagID);
178 if (!Tok.
is(tok::semi))
return;
180 bool HadMultipleSemis =
false;
186 HadMultipleSemis =
true;
195 Diag(StartLoc, diag::warn_cxx98_compat_top_level_semi)
198 Diag(StartLoc, diag::ext_extra_semi_cxx11)
203 if (Kind != AfterMemberFunctionDefinition || HadMultipleSemis)
204 Diag(StartLoc, diag::ext_extra_semi)
210 Diag(StartLoc, diag::warn_extra_semi_after_mem_fn_def)
214 bool Parser::expectIdentifier() {
215 if (Tok.
is(tok::identifier))
219 Diag(Tok, diag::err_expected_token_instead_of_objcxx_keyword)
225 Diag(Tok, diag::err_expected) << tok::identifier;
234 return (static_cast<unsigned>(L) & static_cast<unsigned>(R)) != 0;
248 bool isFirstTokenSkipped =
true;
251 for (
unsigned i = 0, NumToks = Toks.size(); i != NumToks; ++i) {
252 if (Tok.
is(Toks[i])) {
265 if (Toks.size() == 1 && Toks[0] ==
tok::eof &&
278 case tok::annot_pragma_openmp:
279 case tok::annot_pragma_openmp_end:
281 if (OpenMPDirectiveParsing)
283 ConsumeAnnotationToken();
285 case tok::annot_module_begin:
286 case tok::annot_module_end:
287 case tok::annot_module_include:
293 case tok::code_completion:
295 handleUnexpectedCodeCompletionToken();
337 if (ParenCount && !isFirstTokenSkipped)
342 if (BracketCount && !isFirstTokenSkipped)
347 if (BraceCount && !isFirstTokenSkipped)
361 isFirstTokenSkipped =
false;
371 if (NumCachedScopes) {
372 Scope *N = ScopeCache[--NumCachedScopes];
374 Actions.CurScope = N;
389 Actions.CurScope = OldScope->
getParent();
391 if (NumCachedScopes == ScopeCacheSize)
394 ScopeCache[NumCachedScopes++] = OldScope;
399 Parser::ParseScopeFlags::ParseScopeFlags(
Parser *Self,
unsigned ScopeFlags,
401 : CurScope(ManageFlags ? Self->
getCurScope() :
nullptr) {
403 OldFlags = CurScope->getFlags();
404 CurScope->setFlags(ScopeFlags);
410 Parser::ParseScopeFlags::~ParseScopeFlags() {
412 CurScope->setFlags(OldFlags);
423 Actions.CurScope =
nullptr;
426 for (
unsigned i = 0, e = NumCachedScopes; i != e; ++i)
427 delete ScopeCache[i];
429 resetPragmaHandlers();
444 assert(TemplateIds.empty() &&
"Still alive TemplateIdAnnotations around?");
451 assert(
getCurScope() ==
nullptr &&
"A scope is already active?");
466 ObjCTypeQuals[objc_null_unspecified]
470 Ident_instancetype =
nullptr;
471 Ident_final =
nullptr;
472 Ident_sealed =
nullptr;
473 Ident_override =
nullptr;
474 Ident_GNU_final =
nullptr;
475 Ident_import =
nullptr;
476 Ident_module =
nullptr;
480 Ident_vector =
nullptr;
481 Ident_bool =
nullptr;
482 Ident_pixel =
nullptr;
490 Ident_introduced =
nullptr;
491 Ident_deprecated =
nullptr;
492 Ident_obsoleted =
nullptr;
493 Ident_unavailable =
nullptr;
494 Ident_strict =
nullptr;
495 Ident_replacement =
nullptr;
497 Ident_language = Ident_defined_in = Ident_generated_declaration =
nullptr;
499 Ident__except =
nullptr;
501 Ident__exception_code = Ident__exception_info =
nullptr;
502 Ident__abnormal_termination = Ident___exception_code =
nullptr;
503 Ident___exception_info = Ident___abnormal_termination =
nullptr;
504 Ident_GetExceptionCode = Ident_GetExceptionInfo =
nullptr;
505 Ident_AbnormalTermination =
nullptr;
518 PP.
SetPoisonReason(Ident__exception_code,diag::err_seh___except_block);
519 PP.
SetPoisonReason(Ident___exception_code,diag::err_seh___except_block);
520 PP.
SetPoisonReason(Ident_GetExceptionCode,diag::err_seh___except_block);
521 PP.
SetPoisonReason(Ident__exception_info,diag::err_seh___except_filter);
522 PP.
SetPoisonReason(Ident___exception_info,diag::err_seh___except_filter);
523 PP.
SetPoisonReason(Ident_GetExceptionInfo,diag::err_seh___except_filter);
524 PP.
SetPoisonReason(Ident__abnormal_termination,diag::err_seh___finally_block);
525 PP.
SetPoisonReason(Ident___abnormal_termination,diag::err_seh___finally_block);
526 PP.
SetPoisonReason(Ident_AbnormalTermination,diag::err_seh___finally_block);
540 void Parser::LateTemplateParserCleanupCallback(
void *
P) {
567 Diag(diag::ext_empty_translation_unit);
569 return NoTopLevelDecls;
588 case tok::annot_pragma_unused:
589 HandlePragmaUnused();
603 case tok::identifier: {
605 if ((II == Ident_module || II == Ident_import) &&
606 GetLookAheadToken(2).isNot(tok::coloncolon)) {
607 if (II == Ident_module)
622 Result = ParseModuleDecl(IsFirstDecl);
633 case tok::annot_module_include:
635 reinterpret_cast<Module *
>(
637 ConsumeAnnotationToken();
640 case tok::annot_module_begin:
643 ConsumeAnnotationToken();
646 case tok::annot_module_end:
649 ConsumeAnnotationToken();
657 LateTemplateParserCleanupCallback :
nullptr,
664 case tok::identifier:
683 ParsedAttributesWithRange attrs(AttrFactory);
684 MaybeParseCXX11Attributes(attrs);
686 Result = ParseExternalDeclaration(attrs);
717 Parser::ParseExternalDeclaration(ParsedAttributesWithRange &attrs,
727 Decl *SingleDecl =
nullptr;
729 case tok::annot_pragma_vis:
730 HandlePragmaVisibility();
732 case tok::annot_pragma_pack:
735 case tok::annot_pragma_msstruct:
736 HandlePragmaMSStruct();
738 case tok::annot_pragma_align:
741 case tok::annot_pragma_weak:
744 case tok::annot_pragma_weakalias:
745 HandlePragmaWeakAlias();
747 case tok::annot_pragma_redefine_extname:
748 HandlePragmaRedefineExtname();
750 case tok::annot_pragma_fp_contract:
751 HandlePragmaFPContract();
753 case tok::annot_pragma_fenv_access:
754 HandlePragmaFEnvAccess();
756 case tok::annot_pragma_fp:
759 case tok::annot_pragma_opencl_extension:
760 HandlePragmaOpenCLExtension();
762 case tok::annot_pragma_openmp: {
764 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, attrs);
766 case tok::annot_pragma_ms_pointers_to_members:
767 HandlePragmaMSPointersToMembers();
769 case tok::annot_pragma_ms_vtordisp:
770 HandlePragmaMSVtorDisp();
772 case tok::annot_pragma_ms_pragma:
773 HandlePragmaMSPragma();
775 case tok::annot_pragma_dump:
778 case tok::annot_pragma_attribute:
779 HandlePragmaAttribute();
785 ConsumeExtraSemi(OutsideFunction);
788 Diag(Tok, diag::err_extraneous_closing_brace);
792 Diag(Tok, diag::err_expected_external_declaration);
794 case tok::kw___extension__: {
798 return ParseExternalDeclaration(attrs);
801 ProhibitAttributes(attrs);
812 const auto *SL = cast<StringLiteral>(Result.
get());
813 if (!SL->getString().trim().empty())
814 Diag(StartLoc, diag::err_gnu_inline_asm_disabled);
817 ExpectAndConsume(tok::semi, diag::err_expected_after,
818 "top-level asm block");
826 return ParseObjCAtDirectives(attrs);
830 Diag(Tok, diag::err_expected_external_declaration);
834 SingleDecl = ParseObjCMethodDefinition();
836 case tok::code_completion:
837 if (CurParsedObjCImpl) {
853 SingleDecl = ParseExportDeclaration();
860 case tok::kw_namespace:
861 case tok::kw_typedef:
862 case tok::kw_template:
863 case tok::kw_static_assert:
864 case tok::kw__Static_assert:
887 if (NextKind == tok::kw_namespace) {
894 if (NextKind == tok::kw_template) {
909 diag::warn_cxx98_compat_extern_template :
910 diag::ext_extern_template) <<
SourceRange(ExternLoc, TemplateLoc);
914 TemplateLoc, DeclEnd, attrs));
918 case tok::kw___if_exists:
919 case tok::kw___if_not_exists:
920 ParseMicrosoftIfExistsExternalDeclaration();
924 Diag(Tok, diag::err_unexpected_module_decl);
935 return ParseDeclarationOrFunctionDefinition(attrs, DS);
945 bool Parser::isDeclarationAfterDeclarator() {
949 if (KW.
is(tok::kw_default) || KW.
is(tok::kw_delete))
953 return Tok.
is(tok::equal) ||
954 Tok.
is(tok::comma) ||
956 Tok.
is(tok::kw_asm) ||
957 Tok.
is(tok::kw___attribute) ||
959 Tok.
is(tok::l_paren));
966 if (Tok.
is(tok::l_brace))
972 return isDeclarationSpecifier();
976 return KW.
is(tok::kw_default) || KW.
is(tok::kw_delete);
979 return Tok.
is(tok::colon) ||
1000 Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
1005 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS,
1006 DeclSpecContext::DSC_top_level);
1011 DS, AS, DeclSpecContext::DSC_top_level))
1016 if (Tok.
is(tok::semi)) {
1031 llvm_unreachable(
"we only expect to get the length of the class/struct/union/enum");
1041 ProhibitAttributes(attrs, CorrectLocationForAttributes);
1050 Decl* decls[] = {AnonRecord, TheDecl};
1066 Diag(Tok, diag::err_objc_unexpected_attr);
1073 const char *PrevSpec =
nullptr;
1077 Diag(AtLoc, DiagID) << PrevSpec;
1080 return ParseObjCAtProtocolDeclaration(AtLoc, DS.
getAttributes());
1083 return ParseObjCAtImplementationDeclaration(AtLoc, DS.
getAttributes());
1086 ParseObjCAtInterfaceDeclaration(AtLoc, DS.
getAttributes()));
1092 if (
getLangOpts().CPlusPlus && isTokenStringLiteral() &&
1103 Parser::ParseDeclarationOrFunctionDefinition(ParsedAttributesWithRange &attrs,
1107 return ParseDeclOrFunctionDefInternal(attrs, *DS, AS);
1115 return ParseDeclOrFunctionDefInternal(attrs, PDS, AS);
1134 const ParsedTemplateInfo &TemplateInfo,
1135 LateParsedAttrList *LateParsedAttrs) {
1139 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1145 const char *PrevSpec;
1159 ParseKNRParamDeclarations(D);
1163 if (Tok.
isNot(tok::l_brace) &&
1165 (Tok.
isNot(tok::colon) && Tok.
isNot(tok::kw_try) &&
1166 Tok.
isNot(tok::equal)))) {
1167 Diag(Tok, diag::err_expected_fn_body);
1173 if (Tok.
isNot(tok::l_brace))
1179 if (Tok.
isNot(tok::equal)) {
1181 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
1182 Diag(AL.getLoc(), diag::warn_attribute_on_function_definition) << AL;
1188 TemplateInfo.Kind == ParsedTemplateInfo::Template &&
1198 TemplateParameterLists);
1203 trySkippingFunctionBody()) {
1209 LexTemplateFunctionForLateParsing(Toks);
1218 else if (CurParsedObjCImpl &&
1219 !TemplateInfo.TemplateParams &&
1220 (Tok.
is(tok::l_brace) || Tok.
is(tok::kw_try) ||
1221 Tok.
is(tok::colon)) &&
1234 StashAwayMethodOrFunctionBodyTokens(FuncDecl);
1235 CurParsedObjCImpl->HasCFunction =
true;
1249 TemplateInfo.TemplateParams
1250 ? *TemplateInfo.TemplateParams
1268 if (
auto *Template = dyn_cast_or_null<FunctionTemplateDecl>(Res))
1269 if (Template->isAbbreviated() &&
1270 Template->getTemplateParameters()->getParam(0)->isImplicit())
1273 CurTemplateDepthTracker.addDepth(1);
1282 ? diag::warn_cxx98_compat_defaulted_deleted_function
1283 : diag::ext_defaulted_deleted_function)
1289 ? diag::warn_cxx98_compat_defaulted_deleted_function
1290 : diag::ext_defaulted_deleted_function)
1294 llvm_unreachable(
"function definition after = not 'delete' or 'default'");
1297 if (Tok.
is(tok::comma)) {
1298 Diag(KWLoc, diag::err_default_delete_in_multiple_declaration)
1301 }
else if (ExpectAndConsume(tok::semi, diag::err_expected_after,
1302 Delete ?
"delete" :
"default")) {
1306 Stmt *GeneratedBody = Res ? Res->
getBody() :
nullptr;
1312 trySkippingFunctionBody()) {
1318 if (Tok.
is(tok::kw_try))
1319 return ParseFunctionTryBlock(Res, BodyScope);
1323 if (Tok.
is(tok::colon)) {
1324 ParseConstructorInitializer(Res);
1327 if (!Tok.
is(tok::l_brace)) {
1336 if (LateParsedAttrs)
1337 ParseLexedAttributeList(*LateParsedAttrs, Res,
false,
true);
1339 return ParseFunctionStatementBody(Res, BodyScope);
1342 void Parser::SkipFunctionBody() {
1343 if (Tok.
is(tok::equal)) {
1348 bool IsFunctionTryBlock = Tok.
is(tok::kw_try);
1349 if (IsFunctionTryBlock)
1353 if (ConsumeAndStoreFunctionPrologue(Skipped))
1357 while (IsFunctionTryBlock && Tok.
is(tok::kw_catch)) {
1366 void Parser::ParseKNRParamDeclarations(Declarator &D) {
1376 while (isDeclarationSpecifier()) {
1381 ParseDeclarationSpecifiers(DS);
1389 Diag(DSStart, diag::err_declaration_does_not_declare_param);
1398 diag::err_invalid_storage_class_in_func_decl);
1403 diag::err_invalid_storage_class_in_func_decl);
1409 ParseDeclarator(ParmDeclarator);
1414 MaybeParseGNUAttributes(ParmDeclarator);
1426 for (
unsigned i = 0; ; ++i) {
1439 diag::err_param_redefinition)
1451 if (Tok.
isNot(tok::comma))
1454 ParmDeclarator.
clear();
1460 ParseDeclarator(ParmDeclarator);
1464 if (!ExpectAndConsumeSemi(diag::err_expected_semi_declaration))
1487 ExprResult Parser::ParseAsmStringLiteral(
bool ForAsmLabel) {
1488 if (!isTokenStringLiteral()) {
1489 Diag(Tok, diag::err_expected_string_literal)
1494 ExprResult AsmString(ParseStringLiteralExpression());
1496 const auto *SL = cast<StringLiteral>(AsmString.
get());
1497 if (!SL->isAscii()) {
1498 Diag(Tok, diag::err_asm_operand_wide_string_literal)
1500 << SL->getSourceRange();
1503 if (ForAsmLabel && SL->getString().empty()) {
1504 Diag(Tok, diag::err_asm_operand_wide_string_literal)
1505 << 2 << SL->getSourceRange();
1518 assert(Tok.
is(tok::kw_asm) &&
"Not an asm!");
1521 if (Tok.
is(tok::kw_volatile)) {
1526 Diag(Tok, diag::warn_file_asm_volatile)
1533 Diag(Tok, diag::err_expected_lparen_after) <<
"asm";
1557 assert(tok.
is(tok::annot_template_id) &&
"Expected template-id token");
1563 void Parser::AnnotateScopeToken(
CXXScopeSpec &SS,
bool IsNewAnnotation) {
1570 Tok.
setKind(tok::annot_cxxscope);
1577 if (IsNewAnnotation)
1588 Parser::AnnotatedNameKind
1590 assert(Tok.
is(tok::identifier) || Tok.
is(tok::annot_cxxscope));
1592 const bool EnteringContext =
false;
1593 const bool WasScopeAnnotation = Tok.
is(tok::annot_cxxscope);
1597 ParseOptionalCXXScopeSpecifier(SS,
nullptr, EnteringContext))
1603 return ANK_Unresolved;
1611 if (isTentativelyDeclared(Name)) {
1616 return Tok.
is(tok::annot_typename) ? ANK_Success : ANK_TentativeDecl;
1633 isTemplateArgumentList(1) == TPResult::False) {
1635 Token FakeNext = Next;
1636 FakeNext.
setKind(tok::unknown);
1639 SS.
isEmpty() ? CCC :
nullptr);
1642 switch (Classification.
getKind()) {
1652 AnnotateScopeToken(SS, !WasScopeAnnotation);
1675 = parseObjCTypeArgsAndProtocolQualifiers(IdentifierLoc, Ty,
1684 Tok.
setKind(tok::annot_typename);
1685 setTypeAnnotation(Tok, Ty);
1693 Tok.
setKind(tok::annot_primary_expr);
1702 Tok.
setKind(tok::annot_non_type);
1708 AnnotateScopeToken(SS, !WasScopeAnnotation);
1714 ? tok::annot_non_type_undeclared
1715 : tok::annot_non_type_dependent);
1716 setIdentifierAnnotation(Tok, Name);
1721 AnnotateScopeToken(SS, !WasScopeAnnotation);
1725 if (Next.
isNot(tok::less)) {
1728 AnnotateScopeToken(SS, !WasScopeAnnotation);
1729 return ANK_TemplateName;
1739 if (AnnotateTemplateIdToken(
1748 if (Next.
is(tok::less))
1752 if (AnnotateTemplateIdToken(
1763 AnnotateScopeToken(SS, !WasScopeAnnotation);
1764 return ANK_Unresolved;
1767 bool Parser::TryKeywordIdentFallback(
bool DisableKeyword) {
1768 assert(Tok.
isNot(tok::identifier));
1769 Diag(Tok, diag::ext_keyword_as_ident)
1801 assert((Tok.
is(tok::identifier) || Tok.
is(tok::coloncolon) ||
1802 Tok.
is(tok::kw_typename) || Tok.
is(tok::annot_cxxscope) ||
1803 Tok.
is(tok::kw_decltype) || Tok.
is(tok::annot_template_id) ||
1804 Tok.
is(tok::kw___super)) &&
1805 "Cannot be a type or scope token!");
1807 if (Tok.
is(tok::kw_typename)) {
1816 PP.
Lex(TypedefToken);
1821 Diag(Tok.
getLocation(), diag::warn_expected_qualified_after_typename);
1833 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1838 if (Tok.
is(tok::identifier) || Tok.
is(tok::annot_template_id) ||
1839 Tok.
is(tok::annot_decltype)) {
1841 if (Tok.
is(tok::annot_decltype) ||
1843 unsigned DiagID = diag::err_expected_qualified_after_typename;
1847 DiagID = diag::warn_expected_qualified_after_typename;
1860 if (Tok.
is(tok::identifier)) {
1865 }
else if (Tok.
is(tok::annot_template_id)) {
1870 Diag(Tok, diag::err_typename_refers_to_non_type_template)
1887 Diag(Tok, diag::err_expected_type_name_after_typename)
1893 Tok.
setKind(tok::annot_typename);
1894 setTypeAnnotation(Tok, Ty.
isInvalid() ? nullptr : Ty.
get());
1902 bool WasScopeAnnotation = Tok.
is(tok::annot_cxxscope);
1906 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false))
1917 if (Tok.
is(tok::identifier)) {
1932 (Ty.get()->isObjCObjectType() ||
1933 Ty.get()->isObjCObjectPointerType())) {
1938 = parseObjCTypeArgsAndProtocolQualifiers(IdentifierLoc, Ty,
1949 Tok.
setKind(tok::annot_typename);
1950 setTypeAnnotation(Tok, Ty);
1974 bool MemberOfUnknownSpecialization;
1977 false, TemplateName,
1978 nullptr,
false, Template,
1979 MemberOfUnknownSpecialization)) {
1983 isTemplateArgumentList(1) != TPResult::False) {
2003 if (Tok.
is(tok::annot_template_id)) {
2010 AnnotateTemplateIdTokenAsType(SS);
2019 AnnotateScopeToken(SS, IsNewScope);
2031 "Call sites of this function should be guarded by checking for C++");
2035 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr, EnteringContext))
2040 AnnotateScopeToken(SS,
true);
2044 bool Parser::isTokenEqualOrEqualTypo() {
2050 case tok::starequal:
2051 case tok::plusequal:
2052 case tok::minusequal:
2053 case tok::exclaimequal:
2054 case tok::slashequal:
2055 case tok::percentequal:
2056 case tok::lessequal:
2057 case tok::lesslessequal:
2058 case tok::greaterequal:
2059 case tok::greatergreaterequal:
2060 case tok::caretequal:
2061 case tok::pipeequal:
2062 case tok::equalequal:
2063 Diag(Tok, diag::err_invalid_token_after_declarator_suggest_equal)
2073 assert(Tok.
is(tok::code_completion));
2081 return PrevTokLocation;
2087 return PrevTokLocation;
2093 return PrevTokLocation;
2098 void Parser::CodeCompleteDirective(
bool InConditional) {
2102 void Parser::CodeCompleteInConditionalExclusion() {
2106 void Parser::CodeCompleteMacroName(
bool IsDefinition) {
2110 void Parser::CodeCompletePreprocessorExpression() {
2116 unsigned ArgumentIndex) {
2121 void Parser::CodeCompleteIncludedFile(llvm::StringRef Dir,
bool IsAngled) {
2125 void Parser::CodeCompleteNaturalLanguage() {
2129 bool Parser::ParseMicrosoftIfExistsCondition(IfExistsCondition&
Result) {
2130 assert((Tok.
is(tok::kw___if_exists) || Tok.
is(tok::kw___if_not_exists)) &&
2131 "Expected '__if_exists' or '__if_not_exists'");
2132 Result.IsIfExists = Tok.
is(tok::kw___if_exists);
2137 Diag(Tok, diag::err_expected_lparen_after)
2138 << (Result.IsIfExists?
"__if_exists" :
"__if_not_exists");
2144 ParseOptionalCXXScopeSpecifier(Result.SS,
nullptr,
2148 if (Result.SS.isInvalid()) {
2156 Result.SS,
false,
true,
2157 true,
false,
nullptr,
2158 &TemplateKWLoc, Result.Name)) {
2168 Result.IsIfExists, Result.SS,
2171 Result.Behavior = Result.IsIfExists ? IEB_Parse : IEB_Skip;
2175 Result.Behavior = !Result.IsIfExists ? IEB_Parse : IEB_Skip;
2179 Result.Behavior = IEB_Dependent;
2189 void Parser::ParseMicrosoftIfExistsExternalDeclaration() {
2190 IfExistsCondition
Result;
2191 if (ParseMicrosoftIfExistsCondition(Result))
2196 Diag(Tok, diag::err_expected) << tok::l_brace;
2200 switch (Result.Behavior) {
2206 llvm_unreachable(
"Cannot have a dependent external declaration");
2215 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
2216 ParsedAttributesWithRange attrs(AttrFactory);
2217 MaybeParseCXX11Attributes(attrs);
2246 (Tok.
is(tok::kw_module) ||
2248 "not a module declaration");
2253 DiagnoseAndSkipCXX11Attributes();
2259 Diag(StartLoc, diag::err_global_module_introducer_not_at_start)
2264 Diag(StartLoc, diag::err_module_fragment_exported)
2274 Diag(StartLoc, diag::err_module_fragment_exported)
2279 DiagnoseAndSkipCXX11Attributes();
2280 ExpectAndConsumeSemi(diag::err_private_module_fragment_expected_semi);
2285 if (ParseModuleName(ModuleLoc, Path,
false))
2289 if (Tok.
is(tok::colon)) {
2292 if (ParseModuleName(ModuleLoc, Partition,
false))
2296 Diag(ColonLoc, diag::err_unsupported_module_partition)
2297 <<
SourceRange(ColonLoc, Partition.back().second);
2302 ParsedAttributesWithRange Attrs(AttrFactory);
2303 MaybeParseCXX11Attributes(Attrs);
2304 ProhibitCXX11Attributes(Attrs, diag::err_attribute_not_module_attr);
2306 ExpectAndConsumeSemi(diag::err_module_expected_semi);
2308 return Actions.
ActOnModuleDecl(StartLoc, ModuleLoc, MDK, Path, IsFirstDecl);
2334 "Improper start to module import");
2339 Module *HeaderUnit =
nullptr;
2341 if (Tok.
is(tok::header_name)) {
2346 }
else if (Tok.
is(tok::annot_header_unit)) {
2349 ConsumeAnnotationToken();
2350 }
else if (
getLangOpts().CPlusPlusModules && Tok.
is(tok::colon)) {
2352 if (ParseModuleName(ImportLoc, Path,
true))
2356 Diag(ColonLoc, diag::err_unsupported_module_partition)
2360 if (ParseModuleName(ImportLoc, Path,
true))
2364 ParsedAttributesWithRange Attrs(AttrFactory);
2365 MaybeParseCXX11Attributes(Attrs);
2367 ProhibitCXX11Attributes(Attrs, diag::err_attribute_not_import_attr);
2379 else if (!Path.empty())
2381 ExpectAndConsumeSemi(diag::err_module_expected_semi);
2387 if (IsObjCAtImport && AtLoc.
isValid()) {
2390 if (FE && llvm::sys::path::parent_path(FE->getDir()->getName())
2391 .endswith(
".framework"))
2392 Diags.
Report(AtLoc, diag::warn_atimport_in_framework_header);
2395 return Import.
get();
2405 bool Parser::ParseModuleName(
2411 if (!Tok.
is(tok::identifier)) {
2412 if (Tok.
is(tok::code_completion)) {
2418 Diag(Tok, diag::err_module_expected_ident) << IsImport;
2427 if (Tok.
isNot(tok::period))
2438 bool Parser::parseMisplacedModuleImport() {
2441 case tok::annot_module_end:
2445 if (MisplacedModuleBeginCount) {
2446 --MisplacedModuleBeginCount;
2448 reinterpret_cast<Module *
>(
2450 ConsumeAnnotationToken();
2457 case tok::annot_module_begin:
2460 reinterpret_cast<Module *
>(
2462 ConsumeAnnotationToken();
2463 ++MisplacedModuleBeginCount;
2465 case tok::annot_module_include:
2469 reinterpret_cast<Module *
>(
2471 ConsumeAnnotationToken();
2481 bool BalancedDelimiterTracker::diagnoseOverflow() {
2482 P.Diag(P.Tok, diag::err_bracket_depth_exceeded)
2483 << P.getLangOpts().BracketDepth;
2484 P.Diag(P.Tok, diag::note_bracket_depth);
2492 LOpen = P.Tok.getLocation();
2493 if (P.ExpectAndConsume(Kind, DiagID, Msg)) {
2494 if (SkipToTok != tok::unknown)
2499 if (getDepth() < P.getLangOpts().BracketDepth)
2502 return diagnoseOverflow();
2505 bool BalancedDelimiterTracker::diagnoseMissingClose() {
2506 assert(!P.Tok.is(Close) &&
"Should have consumed closing delimiter");
2508 if (P.Tok.is(tok::annot_module_end))
2509 P.Diag(P.Tok, diag::err_missing_before_module_end) << Close;
2511 P.Diag(P.Tok, diag::err_expected) << Close;
2512 P.Diag(LOpen, diag::note_matching) <<
Kind;
2516 if (P.Tok.isNot(tok::r_paren) && P.Tok.isNot(tok::r_brace) &&
2517 P.Tok.isNot(tok::r_square) &&
2518 P.SkipUntil(Close, FinalToken,
2521 LClose = P.ConsumeAnyToken();
The name denotes a member of a dependent type that could not be resolved.
Defines the clang::ASTContext interface.
The name was classified as a variable template name.
Represents a function declaration or definition.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
ParseScope - Introduces a new scope for parsing.
This is a scope that corresponds to the parameters within a function prototype.
void clear()
Reset the contents of this Declarator.
DeclResult ActOnModuleImport(SourceLocation StartLoc, SourceLocation ExportLoc, SourceLocation ImportLoc, ModuleIdPath Path)
The parser has processed a module import declaration.
void Initialize()
Perform initialization that occurs after the parser has been initialized but before it parses anythin...
void Initialize()
Initialize - Warm up the parser.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
Code completion occurs within a class, struct, or union.
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
DeclGroupPtrTy ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc, SourceLocation PrivateLoc)
The parser has processed a private-module-fragment declaration that begins the definition of the priv...
virtual Stmt * getBody() const
getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...
The name was classified as an ADL-only function template name.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
Stmt - This represents one statement.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
The name refers to a dependent template name:
bool isEmpty() const
No scope specifier.
Decl - This represents one declaration (or definition), e.g.
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
Defines the C++ template declaration subclasses.
void CodeCompleteNaturalLanguage()
Classification failed; an error has been produced.
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
SourceLocation getCloseLocation() const
This indicates that the scope corresponds to a function, which means that labels are set here...
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
TemplateNameKind Kind
The kind of template that Template refers to.
Wrapper for void* pointer.
Parser - This implements a parser for the C family of languages.
TSCS getThreadStorageClassSpec() const
NameClassificationKind getKind() const
const ParsedAttributes & getAttributes() const
void * SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS)
Given a C++ nested-name-specifier, produce an annotation value that the parser can use later to recon...
bool isKNRPrototype() const
isKNRPrototype - Return true if this is a K&R style identifier list, like "void foo(a,b,c)".
bool hadModuleLoaderFatalFailure() const
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
static const TSCS TSCS_unspecified
bool MightBeCXXScopeToken()
Information about one declarator, including the parsed type information and the identifier.
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
TypeSpecifierType
Specifies the kind of type.
static const TST TST_interface
RAIIObject to destroy the contents of a SmallVector of TemplateIdAnnotation pointers and clear the ve...
Describes how types, statements, expressions, and declarations should be printed. ...
Code completion occurs within an Objective-C implementation or category implementation.
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing...
Decl * ActOnParamDeclarator(Scope *S, Declarator &D)
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
friend class ObjCDeclContextSwitch
The name was classified as a non-type, and an expression representing that name has been formed...
void MarkAsLateParsedTemplate(FunctionDecl *FD, Decl *FnD, CachedTokens &Toks)
tok::TokenKind getKind() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
Information about a template-id annotation token.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
Represents a struct/union/class.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
void SetPoisonReason(IdentifierInfo *II, unsigned DiagID)
Specifies the reason for poisoning an identifier.
One of these records is kept for each identifier that is lexed.
Lookup for the name failed, but we're assuming it was a template name anyway.
SourceLocation getTypeSpecTypeLoc() const
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
static const TST TST_class
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
Token - This structure provides full information about a lexed token.
static const TST TST_enum
void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned Argument)
TemplateName getTemplateName() const
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
void removeCommentHandler(CommentHandler *Handler)
Remove the specified comment handler.
bool hasTagDefinition() const
void ClearStorageClassSpecs()
Describes a module or submodule.
The name was classified as a type.
Code completion occurs at top-level or namespace context.
static bool HasFlagsSet(Parser::SkipUntilFlags L, Parser::SkipUntilFlags R)
The name was classified as a template whose specializations are types.
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
Code completion occurs within the body of a function on a recovery path, where we do not have a speci...
Represents a C++ unqualified-id that has been parsed.
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
void SetRangeBegin(SourceLocation Loc)
SetRangeBegin - Set the start of the source range to Loc, unless it's invalid.
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl *> Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
ExprResult getExpression() const
const clang::PrintingPolicy & getPrintingPolicy() const
void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path)
The name has been typo-corrected to a keyword.
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
IfExistsResult CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS, const DeclarationNameInfo &TargetNameInfo)
const ParsingDeclSpec & getDeclSpec() const
void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
The parser has processed a module import translated from a #include or similar preprocessing directiv...
Scope - A scope is a transient data structure that is used while parsing the program.
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
Represents a C++ nested-name-specifier or a global scope specifier.
void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled)
void setCodeCompletionHandler(CodeCompletionHandler &Handler)
Set the code completion handler to the given object.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type...
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
SourceRange getSourceRange() const LLVM_READONLY
IdentifierInfo * getIdentifier() const
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
Sema - This implements semantic analysis and AST building for C.
A little helper class used to produce diagnostics.
A class for parsing a declarator.
void clearCodeCompletionHandler()
Clear out the code completion handler.
The name was classified as a function template name.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
SourceRange getRange() const
void setAnnotationRange(SourceRange R)
TST getTypeSpecType() const
static bool isDeclRep(TST T)
void setAnnotationValue(void *val)
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
void CodeCompleteObjCMethodDecl(Scope *S, Optional< bool > IsInstanceMethod, ParsedType ReturnType)
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e...
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, ParsedType ObjectType, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
The name was classified as a specific non-type, non-template declaration.
void RevertCachedTokens(unsigned N)
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens...
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
SourceLocation getBeginLoc() const
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
Represents a C++ template name within the type system.
This is a compound statement scope.
void CodeCompletePreprocessorExpression()
SourceLocation getStorageClassSpecLoc() const
const char * getPunctuatorSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple punctuation tokens like '!' or '', and returns NULL for literal and...
NamedDecl * getNonTypeDecl() const
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
SourceLocation getEnd() const
Wraps an identifier and optional source location for the identifier.
The result type of a method or function.
const LangOptions & getLangOpts() const
This is a scope that corresponds to the parameters within a function prototype for a function declara...
SourceManager & getSourceManager() const
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, CorrectionCandidateCallback *CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
Decl * ActOnSkippedFunctionBody(Decl *Decl)
A class for parsing a DeclSpec.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
void TypoCorrectToken(const Token &Tok)
Update the current token to represent the provided identifier, in order to cache an action performed ...
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
SCS getStorageClassSpec() const
ASTContext & getASTContext() const
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void setCurrentOpenCLExtensionForDecl(Decl *FD)
Set current OpenCL extensions for a declaration which can only be used when these OpenCL extensions a...
bool TryAnnotateTypeOrScopeToken()
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
void ExitScope()
ExitScope - Pop a scope off the scope stack.
static const TST TST_union
IdentifierInfo * getIdentifierInfo() const
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies)
void setAnnotationEndLoc(SourceLocation L)
IdentifierTable & getIdentifierTable()
ParsedAttr - Represents a syntactic attribute.
ParsedType getType() const
void setIdentifierInfo(IdentifierInfo *II)
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them...
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used...
void CodeCompletePreprocessorDirective(bool InConditional)
void Lex(Token &Result)
Lex the next token for this preprocessor.
TemplateNameKind getTemplateNameKind() const
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
This name is not a type or template in this context, but might be something else. ...
DeclGroupPtrTy ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc)
The parser has processed a global-module-fragment declaration that begins the definition of the globa...
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
bool isObjCObjectPointerType() const
static bool IsCommonTypo(tok::TokenKind ExpectedTok, const Token &Tok)
void SetLateTemplateParser(LateTemplateParserCB *LTP, LateTemplateParserCleanupCB *LTPCleanup, void *P)
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
Scope * getCurScope() const
The name is a dependent name, so the results will differ from one instantiation to the next...
void Init(Scope *parent, unsigned flags)
Init - This is used by the parser to implement scope caching.
void ActOnStartOfTranslationUnit()
This is called before the very first declaration in the translation unit is parsed.
ASTConsumer & getASTConsumer() const
bool isInvalid() const
An error occurred during parsing of the scope specifier.
void CodeCompletePreprocessorMacroName(bool IsDefinition)
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
Describes a module import declaration, which makes the contents of the named module visible in the cu...
The scope of a struct/union/class definition.
bool isNot(tok::TokenKind K) const
bool isBacktrackEnabled() const
True if EnableBacktrackAtThisPos() was called and caching of tokens is on.
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
'export module X;'
bool expectAndConsume(unsigned DiagID=diag::err_expected, const char *Msg="", tok::TokenKind SkipToTok=tok::unknown)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
void addCommentHandler(CommentHandler *Handler)
Add the specified comment handler to the preprocessor.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod)
The parsed has entered a submodule.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
SkipUntilFlags
Control flags for SkipUntil functions.
TypeResult ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, const CXXScopeSpec &SS, const IdentifierInfo &II, SourceLocation IdLoc)
Called when the parser has parsed a C++ typename specifier, e.g., "typename T::type".
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
The name refers to a template whose specialization produces a type.
static const TST TST_unspecified
Encapsulates the data about a macro definition (e.g.
void takeAttributesFrom(ParsedAttributes &attrs)
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
The name was classified as an ADL-only function name.
DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc, ModuleDeclKind MDK, ModuleIdPath Path, bool IsFirstDecl)
The parser has processed a module-declaration that begins the definition of a module interface or imp...
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
This is a scope that can contain a declaration.
bool isObjCObjectType() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
SourceLocation getIdentifierLoc() const
void ActOnTranslationUnitScope(Scope *S)
The name was classified as a concept name.
ParsingDeclSpec & getMutableDeclSpec() const
Captures information about "declaration specifiers".
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
SourceLocation getLastLoc() const
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void ActOnPopScope(SourceLocation Loc, Scope *S)
Scope actions.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
bool isIncrementalProcessingEnabled() const
Returns true if incremental processing is enabled.
bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS, bool IsNewScope)
Try to annotate a type or scope token, having already parsed an optional scope specifier.
static Decl::Kind getKind(const Decl *D)
void ActOnComment(SourceRange Comment)
static OpaquePtr make(TemplateName P)
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
static const TST TST_struct
void setLocation(SourceLocation L)
void ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod)
The parser has left a submodule.
A trivial tuple used to represent a source range.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isTranslationUnit() const
bool isEditorPlaceholder() const
Returns true if this token is an editor placeholder.
unsigned NumArgs
NumArgs - The number of template arguments.
void * getAnnotationValue() const
SourceLocation getBegin() const
SourceLocation ColonLoc
Location of ':'.
void setCommaLoc(SourceLocation CL)
The symbol does not exist.
void CodeCompleteInPreprocessorConditionalExclusion(Scope *S)
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
ParsedAttributes & getAttributes()
void startToken()
Reset all flags to cleared.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
bool ParseFirstTopLevelDecl(DeclGroupPtrTy &Result)
Parse the first top-level declaration in a translation unit.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Stop skipping at specified token, but don't skip the token itself.