comparison clang/lib/Parse/Parser.cpp @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 0572611fdcc8
children dd44ba33042e 5f17cb93ff66
comparison
equal deleted inserted replaced
173:0572611fdcc8 207:2e18cbf3894f
47 47
48 return Ident__except; 48 return Ident__except;
49 } 49 }
50 50
51 Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies) 51 Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
52 : PP(pp), Actions(actions), Diags(PP.getDiagnostics()), 52 : PP(pp), PreferredType(pp.isCodeCompletionEnabled()), Actions(actions),
53 GreaterThanIsOperator(true), ColonIsSacred(false), 53 Diags(PP.getDiagnostics()), GreaterThanIsOperator(true),
54 InMessageExpression(false), TemplateParameterDepth(0), 54 ColonIsSacred(false), InMessageExpression(false),
55 ParsingInObjCContainer(false) { 55 TemplateParameterDepth(0), ParsingInObjCContainer(false) {
56 SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies; 56 SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies;
57 Tok.startToken(); 57 Tok.startToken();
58 Tok.setKind(tok::eof); 58 Tok.setKind(tok::eof);
59 Actions.CurScope = nullptr; 59 Actions.CurScope = nullptr;
60 NumCachedScopes = 0; 60 NumCachedScopes = 0;
223 return false; 223 return false;
224 } 224 }
225 } 225 }
226 Diag(Tok, diag::err_expected) << tok::identifier; 226 Diag(Tok, diag::err_expected) << tok::identifier;
227 return true; 227 return true;
228 }
229
230 void Parser::checkCompoundToken(SourceLocation FirstTokLoc,
231 tok::TokenKind FirstTokKind, CompoundToken Op) {
232 if (FirstTokLoc.isInvalid())
233 return;
234 SourceLocation SecondTokLoc = Tok.getLocation();
235
236 // If either token is in a macro, we expect both tokens to come from the same
237 // macro expansion.
238 if ((FirstTokLoc.isMacroID() || SecondTokLoc.isMacroID()) &&
239 PP.getSourceManager().getFileID(FirstTokLoc) !=
240 PP.getSourceManager().getFileID(SecondTokLoc)) {
241 Diag(FirstTokLoc, diag::warn_compound_token_split_by_macro)
242 << (FirstTokKind == Tok.getKind()) << FirstTokKind << Tok.getKind()
243 << static_cast<int>(Op) << SourceRange(FirstTokLoc);
244 Diag(SecondTokLoc, diag::note_compound_token_split_second_token_here)
245 << (FirstTokKind == Tok.getKind()) << Tok.getKind()
246 << SourceRange(SecondTokLoc);
247 return;
248 }
249
250 // We expect the tokens to abut.
251 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
252 SourceLocation SpaceLoc = PP.getLocForEndOfToken(FirstTokLoc);
253 if (SpaceLoc.isInvalid())
254 SpaceLoc = FirstTokLoc;
255 Diag(SpaceLoc, diag::warn_compound_token_split_by_whitespace)
256 << (FirstTokKind == Tok.getKind()) << FirstTokKind << Tok.getKind()
257 << static_cast<int>(Op) << SourceRange(FirstTokLoc, SecondTokLoc);
258 return;
259 }
228 } 260 }
229 261
230 //===----------------------------------------------------------------------===// 262 //===----------------------------------------------------------------------===//
231 // Error recovery. 263 // Error recovery.
232 //===----------------------------------------------------------------------===// 264 //===----------------------------------------------------------------------===//
460 } 492 }
461 493
462 Ident_instancetype = nullptr; 494 Ident_instancetype = nullptr;
463 Ident_final = nullptr; 495 Ident_final = nullptr;
464 Ident_sealed = nullptr; 496 Ident_sealed = nullptr;
497 Ident_abstract = nullptr;
465 Ident_override = nullptr; 498 Ident_override = nullptr;
466 Ident_GNU_final = nullptr; 499 Ident_GNU_final = nullptr;
467 Ident_import = nullptr; 500 Ident_import = nullptr;
468 Ident_module = nullptr; 501 Ident_module = nullptr;
469 502
470 Ident_super = &PP.getIdentifierTable().get("super"); 503 Ident_super = &PP.getIdentifierTable().get("super");
471 504
472 Ident_vector = nullptr; 505 Ident_vector = nullptr;
473 Ident_bool = nullptr; 506 Ident_bool = nullptr;
507 Ident_Bool = nullptr;
474 Ident_pixel = nullptr; 508 Ident_pixel = nullptr;
475 if (getLangOpts().AltiVec || getLangOpts().ZVector) { 509 if (getLangOpts().AltiVec || getLangOpts().ZVector) {
476 Ident_vector = &PP.getIdentifierTable().get("vector"); 510 Ident_vector = &PP.getIdentifierTable().get("vector");
477 Ident_bool = &PP.getIdentifierTable().get("bool"); 511 Ident_bool = &PP.getIdentifierTable().get("bool");
512 Ident_Bool = &PP.getIdentifierTable().get("_Bool");
478 } 513 }
479 if (getLangOpts().AltiVec) 514 if (getLangOpts().AltiVec)
480 Ident_pixel = &PP.getIdentifierTable().get("pixel"); 515 Ident_pixel = &PP.getIdentifierTable().get("pixel");
481 516
482 Ident_introduced = nullptr; 517 Ident_introduced = nullptr;
550 585
551 // C11 6.9p1 says translation units must have at least one top-level 586 // C11 6.9p1 says translation units must have at least one top-level
552 // declaration. C++ doesn't have this restriction. We also don't want to 587 // declaration. C++ doesn't have this restriction. We also don't want to
553 // complain if we have a precompiled header, although technically if the PCH 588 // complain if we have a precompiled header, although technically if the PCH
554 // is empty we should still emit the (pedantic) diagnostic. 589 // is empty we should still emit the (pedantic) diagnostic.
590 // If the main file is a header, we're only pretending it's a TU; don't warn.
555 bool NoTopLevelDecls = ParseTopLevelDecl(Result, true); 591 bool NoTopLevelDecls = ParseTopLevelDecl(Result, true);
556 if (NoTopLevelDecls && !Actions.getASTContext().getExternalSource() && 592 if (NoTopLevelDecls && !Actions.getASTContext().getExternalSource() &&
557 !getLangOpts().CPlusPlus) 593 !getLangOpts().CPlusPlus && !getLangOpts().IsHeaderFile)
558 Diag(diag::ext_empty_translation_unit); 594 Diag(diag::ext_empty_translation_unit);
559 595
560 return NoTopLevelDecls; 596 return NoTopLevelDecls;
561 } 597 }
562 598
650 PP.Diag(OverrideLoc, diag::note_max_tokens_total_override); 686 PP.Diag(OverrideLoc, diag::note_max_tokens_total_override);
651 } 687 }
652 } 688 }
653 689
654 // Late template parsing can begin. 690 // Late template parsing can begin.
655 if (getLangOpts().DelayedTemplateParsing) 691 Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr, this);
656 Actions.SetLateTemplateParser(LateTemplateParserCallback, nullptr,
657 this);
658 if (!PP.isIncrementalProcessingEnabled()) 692 if (!PP.isIncrementalProcessingEnabled())
659 Actions.ActOnEndOfTranslationUnit(); 693 Actions.ActOnEndOfTranslationUnit();
660 //else don't tell Sema that we ended parsing: more input might come. 694 //else don't tell Sema that we ended parsing: more input might come.
661 return true; 695 return true;
662 696
750 HandlePragmaFPContract(); 784 HandlePragmaFPContract();
751 return nullptr; 785 return nullptr;
752 case tok::annot_pragma_fenv_access: 786 case tok::annot_pragma_fenv_access:
753 HandlePragmaFEnvAccess(); 787 HandlePragmaFEnvAccess();
754 return nullptr; 788 return nullptr;
789 case tok::annot_pragma_fenv_round:
790 HandlePragmaFEnvRound();
791 return nullptr;
755 case tok::annot_pragma_float_control: 792 case tok::annot_pragma_float_control:
756 HandlePragmaFloatControl(); 793 HandlePragmaFloatControl();
757 return nullptr; 794 return nullptr;
758 case tok::annot_pragma_fp: 795 case tok::annot_pragma_fp:
759 HandlePragmaFP(); 796 HandlePragmaFP();
834 return nullptr; 871 return nullptr;
835 } 872 }
836 SingleDecl = ParseObjCMethodDefinition(); 873 SingleDecl = ParseObjCMethodDefinition();
837 break; 874 break;
838 case tok::code_completion: 875 case tok::code_completion:
876 cutOffParsing();
839 if (CurParsedObjCImpl) { 877 if (CurParsedObjCImpl) {
840 // Code-complete Objective-C methods even without leading '-'/'+' prefix. 878 // Code-complete Objective-C methods even without leading '-'/'+' prefix.
841 Actions.CodeCompleteObjCMethodDecl(getCurScope(), 879 Actions.CodeCompleteObjCMethodDecl(getCurScope(),
842 /*IsInstanceMethod=*/None, 880 /*IsInstanceMethod=*/None,
843 /*ReturnType=*/nullptr); 881 /*ReturnType=*/nullptr);
844 } 882 }
845 Actions.CodeCompleteOrdinaryName( 883 Actions.CodeCompleteOrdinaryName(
846 getCurScope(), 884 getCurScope(),
847 CurParsedObjCImpl ? Sema::PCC_ObjCImplementation : Sema::PCC_Namespace); 885 CurParsedObjCImpl ? Sema::PCC_ObjCImplementation : Sema::PCC_Namespace);
848 cutOffParsing();
849 return nullptr; 886 return nullptr;
850 case tok::kw_import: 887 case tok::kw_import:
851 SingleDecl = ParseModuleImport(SourceLocation()); 888 SingleDecl = ParseModuleImport(SourceLocation());
852 break; 889 break;
853 case tok::kw_export: 890 case tok::kw_export:
865 case tok::kw_static_assert: 902 case tok::kw_static_assert:
866 case tok::kw__Static_assert: 903 case tok::kw__Static_assert:
867 // A function definition cannot start with any of these keywords. 904 // A function definition cannot start with any of these keywords.
868 { 905 {
869 SourceLocation DeclEnd; 906 SourceLocation DeclEnd;
870 return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); 907 return ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs);
871 } 908 }
872 909
873 case tok::kw_static: 910 case tok::kw_static:
874 // Parse (then ignore) 'static' prior to a template instantiation. This is 911 // Parse (then ignore) 'static' prior to a template instantiation. This is
875 // a GCC extension that we intentionally do not support. 912 // a GCC extension that we intentionally do not support.
876 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) { 913 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_template)) {
877 Diag(ConsumeToken(), diag::warn_static_inline_explicit_inst_ignored) 914 Diag(ConsumeToken(), diag::warn_static_inline_explicit_inst_ignored)
878 << 0; 915 << 0;
879 SourceLocation DeclEnd; 916 SourceLocation DeclEnd;
880 return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); 917 return ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs);
881 } 918 }
882 goto dont_know; 919 goto dont_know;
883 920
884 case tok::kw_inline: 921 case tok::kw_inline:
885 if (getLangOpts().CPlusPlus) { 922 if (getLangOpts().CPlusPlus) {
886 tok::TokenKind NextKind = NextToken().getKind(); 923 tok::TokenKind NextKind = NextToken().getKind();
887 924
888 // Inline namespaces. Allowed as an extension even in C++03. 925 // Inline namespaces. Allowed as an extension even in C++03.
889 if (NextKind == tok::kw_namespace) { 926 if (NextKind == tok::kw_namespace) {
890 SourceLocation DeclEnd; 927 SourceLocation DeclEnd;
891 return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); 928 return ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs);
892 } 929 }
893 930
894 // Parse (then ignore) 'inline' prior to a template instantiation. This is 931 // Parse (then ignore) 'inline' prior to a template instantiation. This is
895 // a GCC extension that we intentionally do not support. 932 // a GCC extension that we intentionally do not support.
896 if (NextKind == tok::kw_template) { 933 if (NextKind == tok::kw_template) {
897 Diag(ConsumeToken(), diag::warn_static_inline_explicit_inst_ignored) 934 Diag(ConsumeToken(), diag::warn_static_inline_explicit_inst_ignored)
898 << 1; 935 << 1;
899 SourceLocation DeclEnd; 936 SourceLocation DeclEnd;
900 return ParseDeclaration(DeclaratorContext::FileContext, DeclEnd, attrs); 937 return ParseDeclaration(DeclaratorContext::File, DeclEnd, attrs);
901 } 938 }
902 } 939 }
903 goto dont_know; 940 goto dont_know;
904 941
905 case tok::kw_extern: 942 case tok::kw_extern:
909 SourceLocation TemplateLoc = ConsumeToken(); 946 SourceLocation TemplateLoc = ConsumeToken();
910 Diag(ExternLoc, getLangOpts().CPlusPlus11 ? 947 Diag(ExternLoc, getLangOpts().CPlusPlus11 ?
911 diag::warn_cxx98_compat_extern_template : 948 diag::warn_cxx98_compat_extern_template :
912 diag::ext_extern_template) << SourceRange(ExternLoc, TemplateLoc); 949 diag::ext_extern_template) << SourceRange(ExternLoc, TemplateLoc);
913 SourceLocation DeclEnd; 950 SourceLocation DeclEnd;
914 return Actions.ConvertDeclToDeclGroup( 951 return Actions.ConvertDeclToDeclGroup(ParseExplicitInstantiation(
915 ParseExplicitInstantiation(DeclaratorContext::FileContext, ExternLoc, 952 DeclaratorContext::File, ExternLoc, TemplateLoc, DeclEnd, attrs));
916 TemplateLoc, DeclEnd, attrs));
917 } 953 }
918 goto dont_know; 954 goto dont_know;
919 955
920 case tok::kw___if_exists: 956 case tok::kw___if_exists:
921 case tok::kw___if_not_exists: 957 case tok::kw___if_not_exists:
1044 ConsumeToken(); 1080 ConsumeToken();
1045 RecordDecl *AnonRecord = nullptr; 1081 RecordDecl *AnonRecord = nullptr;
1046 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none, 1082 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none,
1047 DS, AnonRecord); 1083 DS, AnonRecord);
1048 DS.complete(TheDecl); 1084 DS.complete(TheDecl);
1049 if (getLangOpts().OpenCL)
1050 Actions.setCurrentOpenCLExtensionForDecl(TheDecl);
1051 if (AnonRecord) { 1085 if (AnonRecord) {
1052 Decl* decls[] = {AnonRecord, TheDecl}; 1086 Decl* decls[] = {AnonRecord, TheDecl};
1053 return Actions.BuildDeclaratorGroup(decls); 1087 return Actions.BuildDeclaratorGroup(decls);
1054 } 1088 }
1055 return Actions.ConvertDeclToDeclGroup(TheDecl); 1089 return Actions.ConvertDeclToDeclGroup(TheDecl);
1092 // literal following it, this must be a C++ linkage specifier like 1126 // literal following it, this must be a C++ linkage specifier like
1093 // 'extern "C"'. 1127 // 'extern "C"'.
1094 if (getLangOpts().CPlusPlus && isTokenStringLiteral() && 1128 if (getLangOpts().CPlusPlus && isTokenStringLiteral() &&
1095 DS.getStorageClassSpec() == DeclSpec::SCS_extern && 1129 DS.getStorageClassSpec() == DeclSpec::SCS_extern &&
1096 DS.getParsedSpecifiers() == DeclSpec::PQ_StorageClassSpecifier) { 1130 DS.getParsedSpecifiers() == DeclSpec::PQ_StorageClassSpecifier) {
1097 Decl *TheDecl = ParseLinkage(DS, DeclaratorContext::FileContext); 1131 Decl *TheDecl = ParseLinkage(DS, DeclaratorContext::File);
1098 return Actions.ConvertDeclToDeclGroup(TheDecl); 1132 return Actions.ConvertDeclToDeclGroup(TheDecl);
1099 } 1133 }
1100 1134
1101 return ParseDeclGroup(DS, DeclaratorContext::FileContext); 1135 return ParseDeclGroup(DS, DeclaratorContext::File);
1102 } 1136 }
1103 1137
1104 Parser::DeclGroupPtrTy 1138 Parser::DeclGroupPtrTy
1105 Parser::ParseDeclarationOrFunctionDefinition(ParsedAttributesWithRange &attrs, 1139 Parser::ParseDeclarationOrFunctionDefinition(ParsedAttributesWithRange &attrs,
1106 ParsingDeclSpec *DS, 1140 ParsingDeclSpec *DS,
1193 1227
1194 ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope | 1228 ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope |
1195 Scope::CompoundStmtScope); 1229 Scope::CompoundStmtScope);
1196 Scope *ParentScope = getCurScope()->getParent(); 1230 Scope *ParentScope = getCurScope()->getParent();
1197 1231
1198 D.setFunctionDefinitionKind(FDK_Definition); 1232 D.setFunctionDefinitionKind(FunctionDefinitionKind::Definition);
1199 Decl *DP = Actions.HandleDeclarator(ParentScope, D, 1233 Decl *DP = Actions.HandleDeclarator(ParentScope, D,
1200 TemplateParameterLists); 1234 TemplateParameterLists);
1201 D.complete(DP); 1235 D.complete(DP);
1202 D.getMutableDeclSpec().abort(); 1236 D.getMutableDeclSpec().abort();
1203 1237
1224 Actions.CurContext->isTranslationUnit()) { 1258 Actions.CurContext->isTranslationUnit()) {
1225 ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope | 1259 ParseScope BodyScope(this, Scope::FnScope | Scope::DeclScope |
1226 Scope::CompoundStmtScope); 1260 Scope::CompoundStmtScope);
1227 Scope *ParentScope = getCurScope()->getParent(); 1261 Scope *ParentScope = getCurScope()->getParent();
1228 1262
1229 D.setFunctionDefinitionKind(FDK_Definition); 1263 D.setFunctionDefinitionKind(FunctionDefinitionKind::Definition);
1230 Decl *FuncDecl = Actions.HandleDeclarator(ParentScope, D, 1264 Decl *FuncDecl = Actions.HandleDeclarator(ParentScope, D,
1231 MultiTemplateParamsArg()); 1265 MultiTemplateParamsArg());
1232 D.complete(FuncDecl); 1266 D.complete(FuncDecl);
1233 D.getMutableDeclSpec().abort(); 1267 D.getMutableDeclSpec().abort();
1234 if (FuncDecl) { 1268 if (FuncDecl) {
1405 diag::err_invalid_storage_class_in_func_decl); 1439 diag::err_invalid_storage_class_in_func_decl);
1406 DS.ClearStorageClassSpecs(); 1440 DS.ClearStorageClassSpecs();
1407 } 1441 }
1408 1442
1409 // Parse the first declarator attached to this declspec. 1443 // Parse the first declarator attached to this declspec.
1410 Declarator ParmDeclarator(DS, DeclaratorContext::KNRTypeListContext); 1444 Declarator ParmDeclarator(DS, DeclaratorContext::KNRTypeList);
1411 ParseDeclarator(ParmDeclarator); 1445 ParseDeclarator(ParmDeclarator);
1412 1446
1413 // Handle the full declarator list. 1447 // Handle the full declarator list.
1414 while (1) { 1448 while (1) {
1415 // If attributes are present, parse them. 1449 // If attributes are present, parse them.
1660 case Sema::NC_Unknown: 1694 case Sema::NC_Unknown:
1661 // It's not something we know about. Leave it unannotated. 1695 // It's not something we know about. Leave it unannotated.
1662 break; 1696 break;
1663 1697
1664 case Sema::NC_Type: { 1698 case Sema::NC_Type: {
1699 if (TryAltiVecVectorToken())
1700 // vector has been found as a type id when altivec is enabled but
1701 // this is followed by a declaration specifier so this is really the
1702 // altivec vector token. Leave it unannotated.
1703 break;
1665 SourceLocation BeginLoc = NameLoc; 1704 SourceLocation BeginLoc = NameLoc;
1666 if (SS.isNotEmpty()) 1705 if (SS.isNotEmpty())
1667 BeginLoc = SS.getBeginLoc(); 1706 BeginLoc = SS.getBeginLoc();
1668 1707
1669 /// An Objective-C object type followed by '<' is a specialization of 1708 /// An Objective-C object type followed by '<' is a specialization of
1691 Tok.setLocation(BeginLoc); 1730 Tok.setLocation(BeginLoc);
1692 PP.AnnotateCachedTokens(Tok); 1731 PP.AnnotateCachedTokens(Tok);
1693 return ANK_Success; 1732 return ANK_Success;
1694 } 1733 }
1695 1734
1696 case Sema::NC_ContextIndependentExpr: 1735 case Sema::NC_OverloadSet:
1697 Tok.setKind(tok::annot_primary_expr); 1736 Tok.setKind(tok::annot_overload_set);
1698 setExprAnnotation(Tok, Classification.getExpression()); 1737 setExprAnnotation(Tok, Classification.getExpression());
1699 Tok.setAnnotationEndLoc(NameLoc); 1738 Tok.setAnnotationEndLoc(NameLoc);
1700 if (SS.isNotEmpty()) 1739 if (SS.isNotEmpty())
1701 Tok.setLocation(SS.getBeginLoc()); 1740 Tok.setLocation(SS.getBeginLoc());
1702 PP.AnnotateCachedTokens(Tok); 1741 PP.AnnotateCachedTokens(Tok);
1703 return ANK_Success; 1742 return ANK_Success;
1704 1743
1705 case Sema::NC_NonType: 1744 case Sema::NC_NonType:
1745 if (TryAltiVecVectorToken())
1746 // vector has been found as a non-type id when altivec is enabled but
1747 // this is followed by a declaration specifier so this is really the
1748 // altivec vector token. Leave it unannotated.
1749 break;
1706 Tok.setKind(tok::annot_non_type); 1750 Tok.setKind(tok::annot_non_type);
1707 setNonTypeAnnotation(Tok, Classification.getNonTypeDecl()); 1751 setNonTypeAnnotation(Tok, Classification.getNonTypeDecl());
1708 Tok.setLocation(NameLoc); 1752 Tok.setLocation(NameLoc);
1709 Tok.setAnnotationEndLoc(NameLoc); 1753 Tok.setAnnotationEndLoc(NameLoc);
1710 PP.AnnotateCachedTokens(Tok); 1754 PP.AnnotateCachedTokens(Tok);
2079 assert(Tok.is(tok::code_completion)); 2123 assert(Tok.is(tok::code_completion));
2080 PrevTokLocation = Tok.getLocation(); 2124 PrevTokLocation = Tok.getLocation();
2081 2125
2082 for (Scope *S = getCurScope(); S; S = S->getParent()) { 2126 for (Scope *S = getCurScope(); S; S = S->getParent()) {
2083 if (S->getFlags() & Scope::FnScope) { 2127 if (S->getFlags() & Scope::FnScope) {
2128 cutOffParsing();
2084 Actions.CodeCompleteOrdinaryName(getCurScope(), 2129 Actions.CodeCompleteOrdinaryName(getCurScope(),
2085 Sema::PCC_RecoveryInFunction); 2130 Sema::PCC_RecoveryInFunction);
2131 return PrevTokLocation;
2132 }
2133
2134 if (S->getFlags() & Scope::ClassScope) {
2086 cutOffParsing(); 2135 cutOffParsing();
2136 Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Class);
2087 return PrevTokLocation; 2137 return PrevTokLocation;
2088 } 2138 }
2089 2139 }
2090 if (S->getFlags() & Scope::ClassScope) { 2140
2091 Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Class); 2141 cutOffParsing();
2092 cutOffParsing();
2093 return PrevTokLocation;
2094 }
2095 }
2096
2097 Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace); 2142 Actions.CodeCompleteOrdinaryName(getCurScope(), Sema::PCC_Namespace);
2098 cutOffParsing();
2099 return PrevTokLocation; 2143 return PrevTokLocation;
2100 } 2144 }
2101 2145
2102 // Code-completion pass-through functions 2146 // Code-completion pass-through functions
2103 2147
2417 bool IsImport) { 2461 bool IsImport) {
2418 // Parse the module path. 2462 // Parse the module path.
2419 while (true) { 2463 while (true) {
2420 if (!Tok.is(tok::identifier)) { 2464 if (!Tok.is(tok::identifier)) {
2421 if (Tok.is(tok::code_completion)) { 2465 if (Tok.is(tok::code_completion)) {
2466 cutOffParsing();
2422 Actions.CodeCompleteModuleImport(UseLoc, Path); 2467 Actions.CodeCompleteModuleImport(UseLoc, Path);
2423 cutOffParsing();
2424 return true; 2468 return true;
2425 } 2469 }
2426 2470
2427 Diag(Tok, diag::err_module_expected_ident) << IsImport; 2471 Diag(Tok, diag::err_module_expected_ident) << IsImport;
2428 SkipUntil(tok::semi); 2472 SkipUntil(tok::semi);