27#include "llvm/ADT/ArrayRef.h"
28#include "llvm/ADT/ScopeExit.h"
29#include "llvm/ADT/StringSwitch.h"
36 explicit PragmaAlignHandler() : PragmaHandler(
"align") {}
37 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
38 Token &FirstToken)
override;
42 explicit PragmaGCCVisibilityHandler() : PragmaHandler(
"visibility") {}
43 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
44 Token &FirstToken)
override;
48 explicit PragmaOptionsHandler() : PragmaHandler(
"options") {}
49 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
50 Token &FirstToken)
override;
54 explicit PragmaPackHandler() : PragmaHandler(
"pack") {}
55 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
56 Token &FirstToken)
override;
60 explicit PragmaClangSectionHandler(Sema &S)
61 : PragmaHandler(
"section"), Actions(S) {}
62 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
63 Token &FirstToken)
override;
70 explicit PragmaMSStructHandler() : PragmaHandler(
"ms_struct") {}
71 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
72 Token &FirstToken)
override;
76 PragmaUnusedHandler() : PragmaHandler(
"unused") {}
77 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
78 Token &FirstToken)
override;
82 explicit PragmaWeakHandler() : PragmaHandler(
"weak") {}
83 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
84 Token &FirstToken)
override;
88 explicit PragmaRedefineExtnameHandler() : PragmaHandler(
"redefine_extname") {}
89 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
90 Token &FirstToken)
override;
94 PragmaOpenCLExtensionHandler() : PragmaHandler(
"EXTENSION") {}
95 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
96 Token &FirstToken)
override;
101 PragmaFPContractHandler() : PragmaHandler(
"FP_CONTRACT") {}
102 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
103 Token &FirstToken)
override;
110 PragmaSTDC_FENV_ACCESSHandler() : PragmaHandler(
"FENV_ACCESS") {}
112 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
113 Token &
Tok)
override {
114 Token PragmaName =
Tok;
126 Toks[0].startToken();
127 Toks[0].setKind(tok::annot_pragma_fenv_access);
130 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
132 PP.EnterTokenStream(Toks,
true,
138struct PragmaSTDC_CX_LIMITED_RANGEHandler :
public PragmaHandler {
139 PragmaSTDC_CX_LIMITED_RANGEHandler() : PragmaHandler(
"CX_LIMITED_RANGE") {}
141 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
142 Token &
Tok)
override {
147 MutableArrayRef<Token> Toks(
150 Toks[0].startToken();
151 Toks[0].setKind(tok::annot_pragma_cx_limited_range);
154 Toks[0].setAnnotationValue(
155 reinterpret_cast<void *
>(
static_cast<uintptr_t>(OOS)));
156 PP.EnterTokenStream(Toks,
true,
163 PragmaSTDC_FENV_ROUNDHandler() : PragmaHandler(
"FENV_ROUND") {}
165 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
166 Token &
Tok)
override;
171 PragmaSTDC_UnknownHandler() =
default;
173 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
174 Token &UnknownTok)
override {
176 PP.
Diag(UnknownTok, diag::ext_stdc_pragma_ignored);
181 PragmaFPHandler() : PragmaHandler(
"fp") {}
182 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
183 Token &FirstToken)
override;
189template <diag::kind IgnoredDiag>
191 PragmaNoSupportHandler(StringRef Name) : PragmaHandler(Name) {}
192 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
193 Token &FirstToken)
override;
196struct PragmaNoOpenMPHandler
197 :
public PragmaNoSupportHandler<diag::warn_pragma_omp_ignored> {
198 PragmaNoOpenMPHandler() : PragmaNoSupportHandler(
"omp") {}
201struct PragmaNoOpenACCHandler
202 :
public PragmaNoSupportHandler<diag::warn_pragma_acc_ignored> {
203 PragmaNoOpenACCHandler() : PragmaNoSupportHandler(
"acc") {}
212 PragmaSupportHandler(StringRef Name) : PragmaHandler(Name) {}
213 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
214 Token &FirstToken)
override;
217struct PragmaOpenMPHandler
218 :
public PragmaSupportHandler<tok::annot_pragma_openmp,
219 tok::annot_pragma_openmp_end,
220 diag::err_omp_unexpected_directive> {
221 PragmaOpenMPHandler() : PragmaSupportHandler(
"omp") {}
224struct PragmaOpenACCHandler
225 :
public PragmaSupportHandler<tok::annot_pragma_openacc,
226 tok::annot_pragma_openacc_end,
227 diag::err_acc_unexpected_directive> {
228 PragmaOpenACCHandler() : PragmaSupportHandler(
"acc") {}
233 PragmaCommentHandler(Sema &Actions)
234 : PragmaHandler(
"comment"), Actions(Actions) {}
235 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
236 Token &FirstToken)
override;
243 PragmaDetectMismatchHandler(Sema &Actions)
244 : PragmaHandler(
"detect_mismatch"), Actions(Actions) {}
245 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
246 Token &FirstToken)
override;
253 PragmaFloatControlHandler(Sema &Actions)
254 : PragmaHandler(
"float_control") {}
255 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
256 Token &FirstToken)
override;
260 explicit PragmaMSPointersToMembers() : PragmaHandler(
"pointers_to_members") {}
261 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
262 Token &FirstToken)
override;
266 explicit PragmaMSVtorDisp() : PragmaHandler(
"vtordisp") {}
267 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
268 Token &FirstToken)
override;
272 explicit PragmaMSPragma(
const char *name) : PragmaHandler(
name) {}
273 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
274 Token &FirstToken)
override;
279 PragmaOptimizeHandler(Sema &S)
280 : PragmaHandler(
"optimize"), Actions(S) {}
281 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
282 Token &FirstToken)
override;
289 PragmaLoopHintHandler() : PragmaHandler(
"loop") {}
290 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
291 Token &FirstToken)
override;
295 PragmaUnrollHintHandler(
const char *name) : PragmaHandler(
name) {}
296 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
297 Token &FirstToken)
override;
301 PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler(
"runtime_checks") {}
306 PragmaMSFenvAccessHandler() : PragmaHandler(
"fenv_access") {}
307 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
308 Token &FirstToken)
override {
330 if (II->
isStr(
"on")) {
333 }
else if (II->
isStr(
"off")) {
353 MutableArrayRef<Token> Toks(
355 Toks[0].startToken();
356 Toks[0].setKind(tok::annot_pragma_fenv_access_ms);
359 Toks[0].setAnnotationValue(
360 reinterpret_cast<void*
>(
static_cast<uintptr_t>(OOS)));
361 PP.EnterTokenStream(Toks,
true,
366struct PragmaForceCUDAHostDeviceHandler :
public PragmaHandler {
367 PragmaForceCUDAHostDeviceHandler(Sema &Actions)
368 : PragmaHandler(
"force_cuda_host_device"), Actions(Actions) {}
369 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
370 Token &FirstToken)
override;
378 PragmaAttributeHandler(AttributeFactory &AttrFactory)
379 : PragmaHandler(
"attribute"), AttributesForPragmaAttribute(AttrFactory) {}
380 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
381 Token &FirstToken)
override;
384 ParsedAttributes AttributesForPragmaAttribute;
388 PragmaMaxTokensHereHandler() : PragmaHandler(
"max_tokens_here") {}
389 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
390 Token &FirstToken)
override;
394 PragmaMaxTokensTotalHandler() : PragmaHandler(
"max_tokens_total") {}
395 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
396 Token &FirstToken)
override;
400 explicit PragmaExportHandler() : PragmaHandler(
"export") {}
401 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
402 Token &FirstToken)
override;
406 PragmaRISCVHandler(Sema &Actions)
407 : PragmaHandler(
"riscv"), Actions(Actions) {}
408 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
409 Token &FirstToken)
override;
421void Parser::initializePragmaHandlers() {
422 AlignHandler = std::make_unique<PragmaAlignHandler>();
423 PP.AddPragmaHandler(AlignHandler.get());
425 GCCVisibilityHandler = std::make_unique<PragmaGCCVisibilityHandler>();
426 PP.AddPragmaHandler(
"GCC", GCCVisibilityHandler.get());
428 OptionsHandler = std::make_unique<PragmaOptionsHandler>();
429 PP.AddPragmaHandler(OptionsHandler.get());
431 PackHandler = std::make_unique<PragmaPackHandler>();
432 PP.AddPragmaHandler(PackHandler.get());
434 MSStructHandler = std::make_unique<PragmaMSStructHandler>();
435 PP.AddPragmaHandler(MSStructHandler.get());
437 UnusedHandler = std::make_unique<PragmaUnusedHandler>();
438 PP.AddPragmaHandler(UnusedHandler.get());
440 WeakHandler = std::make_unique<PragmaWeakHandler>();
441 PP.AddPragmaHandler(WeakHandler.get());
443 RedefineExtnameHandler = std::make_unique<PragmaRedefineExtnameHandler>();
444 PP.AddPragmaHandler(RedefineExtnameHandler.get());
446 FPContractHandler = std::make_unique<PragmaFPContractHandler>();
447 PP.AddPragmaHandler(
"STDC", FPContractHandler.get());
449 STDCFenvAccessHandler = std::make_unique<PragmaSTDC_FENV_ACCESSHandler>();
450 PP.AddPragmaHandler(
"STDC", STDCFenvAccessHandler.get());
452 STDCFenvRoundHandler = std::make_unique<PragmaSTDC_FENV_ROUNDHandler>();
453 PP.AddPragmaHandler(
"STDC", STDCFenvRoundHandler.get());
455 STDCCXLIMITHandler = std::make_unique<PragmaSTDC_CX_LIMITED_RANGEHandler>();
456 PP.AddPragmaHandler(
"STDC", STDCCXLIMITHandler.get());
458 STDCUnknownHandler = std::make_unique<PragmaSTDC_UnknownHandler>();
459 PP.AddPragmaHandler(
"STDC", STDCUnknownHandler.get());
461 PCSectionHandler = std::make_unique<PragmaClangSectionHandler>(Actions);
462 PP.AddPragmaHandler(
"clang", PCSectionHandler.get());
465 OpenCLExtensionHandler = std::make_unique<PragmaOpenCLExtensionHandler>();
466 PP.AddPragmaHandler(
"OPENCL", OpenCLExtensionHandler.get());
468 PP.AddPragmaHandler(
"OPENCL", FPContractHandler.get());
471 OpenMPHandler = std::make_unique<PragmaOpenMPHandler>();
473 OpenMPHandler = std::make_unique<PragmaNoOpenMPHandler>();
474 PP.AddPragmaHandler(OpenMPHandler.get());
477 OpenACCHandler = std::make_unique<PragmaOpenACCHandler>();
479 OpenACCHandler = std::make_unique<PragmaNoOpenACCHandler>();
480 PP.AddPragmaHandler(OpenACCHandler.get());
484 MSCommentHandler = std::make_unique<PragmaCommentHandler>(Actions);
485 PP.AddPragmaHandler(MSCommentHandler.get());
488 FloatControlHandler = std::make_unique<PragmaFloatControlHandler>(Actions);
489 PP.AddPragmaHandler(FloatControlHandler.get());
491 MSDetectMismatchHandler =
492 std::make_unique<PragmaDetectMismatchHandler>(Actions);
493 PP.AddPragmaHandler(MSDetectMismatchHandler.get());
494 MSPointersToMembers = std::make_unique<PragmaMSPointersToMembers>();
495 PP.AddPragmaHandler(MSPointersToMembers.get());
496 MSVtorDisp = std::make_unique<PragmaMSVtorDisp>();
497 PP.AddPragmaHandler(MSVtorDisp.get());
498 MSInitSeg = std::make_unique<PragmaMSPragma>(
"init_seg");
499 PP.AddPragmaHandler(MSInitSeg.get());
500 MSDataSeg = std::make_unique<PragmaMSPragma>(
"data_seg");
501 PP.AddPragmaHandler(MSDataSeg.get());
502 MSBSSSeg = std::make_unique<PragmaMSPragma>(
"bss_seg");
503 PP.AddPragmaHandler(MSBSSSeg.get());
504 MSConstSeg = std::make_unique<PragmaMSPragma>(
"const_seg");
505 PP.AddPragmaHandler(MSConstSeg.get());
506 MSCodeSeg = std::make_unique<PragmaMSPragma>(
"code_seg");
507 PP.AddPragmaHandler(MSCodeSeg.get());
508 MSSection = std::make_unique<PragmaMSPragma>(
"section");
509 PP.AddPragmaHandler(MSSection.get());
510 MSStrictGuardStackCheck =
511 std::make_unique<PragmaMSPragma>(
"strict_gs_check");
512 PP.AddPragmaHandler(MSStrictGuardStackCheck.get());
513 MSFunction = std::make_unique<PragmaMSPragma>(
"function");
514 PP.AddPragmaHandler(MSFunction.get());
515 MSAllocText = std::make_unique<PragmaMSPragma>(
"alloc_text");
516 PP.AddPragmaHandler(MSAllocText.get());
517 MSOptimize = std::make_unique<PragmaMSPragma>(
"optimize");
518 PP.AddPragmaHandler(MSOptimize.get());
519 MSRuntimeChecks = std::make_unique<PragmaMSRuntimeChecksHandler>();
520 PP.AddPragmaHandler(MSRuntimeChecks.get());
521 MSIntrinsic = std::make_unique<PragmaMSPragma>(
"intrinsic");
522 PP.AddPragmaHandler(MSIntrinsic.get());
523 MSFenvAccess = std::make_unique<PragmaMSFenvAccessHandler>();
524 PP.AddPragmaHandler(MSFenvAccess.get());
528 CUDAForceHostDeviceHandler =
529 std::make_unique<PragmaForceCUDAHostDeviceHandler>(Actions);
530 PP.AddPragmaHandler(
"clang", CUDAForceHostDeviceHandler.get());
533 OptimizeHandler = std::make_unique<PragmaOptimizeHandler>(Actions);
534 PP.AddPragmaHandler(
"clang", OptimizeHandler.get());
536 LoopHintHandler = std::make_unique<PragmaLoopHintHandler>();
537 PP.AddPragmaHandler(
"clang", LoopHintHandler.get());
539 UnrollHintHandler = std::make_unique<PragmaUnrollHintHandler>(
"unroll");
540 PP.AddPragmaHandler(UnrollHintHandler.get());
541 PP.AddPragmaHandler(
"GCC", UnrollHintHandler.get());
543 NoUnrollHintHandler = std::make_unique<PragmaUnrollHintHandler>(
"nounroll");
544 PP.AddPragmaHandler(NoUnrollHintHandler.get());
545 PP.AddPragmaHandler(
"GCC", NoUnrollHintHandler.get());
547 UnrollAndJamHintHandler =
548 std::make_unique<PragmaUnrollHintHandler>(
"unroll_and_jam");
549 PP.AddPragmaHandler(UnrollAndJamHintHandler.get());
551 NoUnrollAndJamHintHandler =
552 std::make_unique<PragmaUnrollHintHandler>(
"nounroll_and_jam");
553 PP.AddPragmaHandler(NoUnrollAndJamHintHandler.get());
555 FPHandler = std::make_unique<PragmaFPHandler>();
556 PP.AddPragmaHandler(
"clang", FPHandler.get());
558 AttributePragmaHandler =
559 std::make_unique<PragmaAttributeHandler>(AttrFactory);
560 PP.AddPragmaHandler(
"clang", AttributePragmaHandler.get());
562 MaxTokensHerePragmaHandler = std::make_unique<PragmaMaxTokensHereHandler>();
563 PP.AddPragmaHandler(
"clang", MaxTokensHerePragmaHandler.get());
565 MaxTokensTotalPragmaHandler = std::make_unique<PragmaMaxTokensTotalHandler>();
566 PP.AddPragmaHandler(
"clang", MaxTokensTotalPragmaHandler.get());
569 ExportHandler = std::make_unique<PragmaExportHandler>();
570 PP.AddPragmaHandler(ExportHandler.get());
574 RISCVPragmaHandler = std::make_unique<PragmaRISCVHandler>(Actions);
575 PP.AddPragmaHandler(
"clang", RISCVPragmaHandler.get());
579void Parser::resetPragmaHandlers() {
581 PP.RemovePragmaHandler(AlignHandler.get());
582 AlignHandler.reset();
583 PP.RemovePragmaHandler(
"GCC", GCCVisibilityHandler.get());
584 GCCVisibilityHandler.reset();
585 PP.RemovePragmaHandler(OptionsHandler.get());
586 OptionsHandler.reset();
587 PP.RemovePragmaHandler(PackHandler.get());
589 PP.RemovePragmaHandler(MSStructHandler.get());
590 MSStructHandler.reset();
591 PP.RemovePragmaHandler(UnusedHandler.get());
592 UnusedHandler.reset();
593 PP.RemovePragmaHandler(WeakHandler.get());
595 PP.RemovePragmaHandler(RedefineExtnameHandler.get());
596 RedefineExtnameHandler.reset();
599 PP.RemovePragmaHandler(
"OPENCL", OpenCLExtensionHandler.get());
600 OpenCLExtensionHandler.reset();
601 PP.RemovePragmaHandler(
"OPENCL", FPContractHandler.get());
603 PP.RemovePragmaHandler(OpenMPHandler.get());
604 OpenMPHandler.reset();
606 PP.RemovePragmaHandler(OpenACCHandler.get());
607 OpenACCHandler.reset();
611 PP.RemovePragmaHandler(MSCommentHandler.get());
612 MSCommentHandler.reset();
615 PP.RemovePragmaHandler(
"clang", PCSectionHandler.get());
616 PCSectionHandler.reset();
618 PP.RemovePragmaHandler(FloatControlHandler.get());
619 FloatControlHandler.reset();
621 PP.RemovePragmaHandler(MSDetectMismatchHandler.get());
622 MSDetectMismatchHandler.reset();
623 PP.RemovePragmaHandler(MSPointersToMembers.get());
624 MSPointersToMembers.reset();
625 PP.RemovePragmaHandler(MSVtorDisp.get());
627 PP.RemovePragmaHandler(MSInitSeg.get());
629 PP.RemovePragmaHandler(MSDataSeg.get());
631 PP.RemovePragmaHandler(MSBSSSeg.get());
633 PP.RemovePragmaHandler(MSConstSeg.get());
635 PP.RemovePragmaHandler(MSCodeSeg.get());
637 PP.RemovePragmaHandler(MSSection.get());
639 PP.RemovePragmaHandler(MSStrictGuardStackCheck.get());
640 MSStrictGuardStackCheck.reset();
641 PP.RemovePragmaHandler(MSFunction.get());
643 PP.RemovePragmaHandler(MSAllocText.get());
645 PP.RemovePragmaHandler(MSRuntimeChecks.get());
646 MSRuntimeChecks.reset();
647 PP.RemovePragmaHandler(MSIntrinsic.get());
649 PP.RemovePragmaHandler(MSOptimize.get());
651 PP.RemovePragmaHandler(MSFenvAccess.get());
652 MSFenvAccess.reset();
656 PP.RemovePragmaHandler(
"clang", CUDAForceHostDeviceHandler.get());
657 CUDAForceHostDeviceHandler.reset();
660 PP.RemovePragmaHandler(
"STDC", FPContractHandler.get());
661 FPContractHandler.reset();
663 PP.RemovePragmaHandler(
"STDC", STDCFenvAccessHandler.get());
664 STDCFenvAccessHandler.reset();
666 PP.RemovePragmaHandler(
"STDC", STDCFenvRoundHandler.get());
667 STDCFenvRoundHandler.reset();
669 PP.RemovePragmaHandler(
"STDC", STDCCXLIMITHandler.get());
670 STDCCXLIMITHandler.reset();
672 PP.RemovePragmaHandler(
"STDC", STDCUnknownHandler.get());
673 STDCUnknownHandler.reset();
675 PP.RemovePragmaHandler(
"clang", OptimizeHandler.get());
676 OptimizeHandler.reset();
678 PP.RemovePragmaHandler(
"clang", LoopHintHandler.get());
679 LoopHintHandler.reset();
681 PP.RemovePragmaHandler(UnrollHintHandler.get());
682 PP.RemovePragmaHandler(
"GCC", UnrollHintHandler.get());
683 UnrollHintHandler.reset();
685 PP.RemovePragmaHandler(NoUnrollHintHandler.get());
686 PP.RemovePragmaHandler(
"GCC", NoUnrollHintHandler.get());
687 NoUnrollHintHandler.reset();
689 PP.RemovePragmaHandler(UnrollAndJamHintHandler.get());
690 UnrollAndJamHintHandler.reset();
692 PP.RemovePragmaHandler(NoUnrollAndJamHintHandler.get());
693 NoUnrollAndJamHintHandler.reset();
695 PP.RemovePragmaHandler(
"clang", FPHandler.get());
698 PP.RemovePragmaHandler(
"clang", AttributePragmaHandler.get());
699 AttributePragmaHandler.reset();
701 PP.RemovePragmaHandler(
"clang", MaxTokensHerePragmaHandler.get());
702 MaxTokensHerePragmaHandler.reset();
704 PP.RemovePragmaHandler(
"clang", MaxTokensTotalPragmaHandler.get());
705 MaxTokensTotalPragmaHandler.reset();
708 PP.RemovePragmaHandler(ExportHandler.get());
709 ExportHandler.reset();
713 PP.RemovePragmaHandler(
"clang", RISCVPragmaHandler.get());
714 RISCVPragmaHandler.reset();
718void Parser::HandlePragmaUnused() {
719 assert(Tok.is(tok::annot_pragma_unused));
720 SourceLocation UnusedLoc = ConsumeAnnotationToken();
721 Actions.ActOnPragmaUnused(Tok,
getCurScope(), UnusedLoc);
725void Parser::HandlePragmaVisibility() {
726 assert(Tok.is(tok::annot_pragma_vis));
727 const IdentifierInfo *VisType =
728 static_cast<IdentifierInfo *
>(Tok.getAnnotationValue());
729 SourceLocation VisLoc = ConsumeAnnotationToken();
730 Actions.ActOnPragmaVisibility(VisType, VisLoc);
733void Parser::HandlePragmaPack() {
734 assert(Tok.is(tok::annot_pragma_pack));
735 Sema::PragmaPackInfo *Info =
736 static_cast<Sema::PragmaPackInfo *
>(Tok.getAnnotationValue());
737 SourceLocation PragmaLoc = Tok.getLocation();
740 Alignment = Actions.ActOnNumericConstant(Info->
Alignment);
742 ConsumeAnnotationToken();
750 ConsumeAnnotationToken();
753void Parser::HandlePragmaMSStruct() {
754 assert(Tok.is(tok::annot_pragma_msstruct));
756 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
757 Actions.ActOnPragmaMSStruct(Kind);
758 ConsumeAnnotationToken();
761void Parser::HandlePragmaAlign() {
762 assert(Tok.is(tok::annot_pragma_align));
764 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
765 Actions.ActOnPragmaOptionsAlign(Kind, Tok.getLocation());
768 ConsumeAnnotationToken();
771void Parser::HandlePragmaDump() {
772 assert(Tok.is(tok::annot_pragma_dump));
773 ConsumeAnnotationToken();
774 if (Tok.is(tok::eod)) {
775 PP.Diag(Tok, diag::warn_pragma_debug_missing_argument) <<
"dump";
777 if (Tok.isNot(tok::identifier)) {
778 PP.Diag(Tok, diag::warn_pragma_debug_unexpected_argument);
780 ExpectAndConsume(tok::eod);
783 IdentifierInfo *II = Tok.getIdentifierInfo();
784 Actions.ActOnPragmaDump(
getCurScope(), Tok.getLocation(), II);
787 SourceLocation StartLoc = Tok.getLocation();
788 EnterExpressionEvaluationContext Ctx(
794 PP.Diag(StartLoc, diag::warn_pragma_debug_dependent_argument)
796 << SourceRange(StartLoc, Tok.getLocation());
798 Actions.ActOnPragmaDump(E.
get());
802 ExpectAndConsume(tok::eod);
805void Parser::HandlePragmaWeak() {
806 assert(Tok.is(tok::annot_pragma_weak));
807 SourceLocation PragmaLoc = ConsumeAnnotationToken();
808 Actions.ActOnPragmaWeakID(Tok.getIdentifierInfo(), PragmaLoc,
813void Parser::HandlePragmaWeakAlias() {
814 assert(Tok.is(tok::annot_pragma_weakalias));
815 SourceLocation PragmaLoc = ConsumeAnnotationToken();
816 IdentifierInfo *WeakName = Tok.getIdentifierInfo();
817 SourceLocation WeakNameLoc = Tok.getLocation();
819 IdentifierInfo *AliasName = Tok.getIdentifierInfo();
820 SourceLocation AliasNameLoc = Tok.getLocation();
822 Actions.ActOnPragmaWeakAlias(WeakName, AliasName, PragmaLoc,
823 WeakNameLoc, AliasNameLoc);
827void Parser::HandlePragmaRedefineExtname() {
828 assert(Tok.is(tok::annot_pragma_redefine_extname));
829 SourceLocation RedefLoc = ConsumeAnnotationToken();
830 IdentifierInfo *RedefName = Tok.getIdentifierInfo();
831 SourceLocation RedefNameLoc = Tok.getLocation();
833 IdentifierInfo *AliasName = Tok.getIdentifierInfo();
834 SourceLocation AliasNameLoc = Tok.getLocation();
836 Actions.ActOnPragmaRedefineExtname(RedefName, AliasName, RedefLoc,
837 RedefNameLoc, AliasNameLoc);
840void Parser::HandlePragmaFPContract() {
841 assert(Tok.is(tok::annot_pragma_fp_contract));
844 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
864 SourceLocation PragmaLoc = ConsumeAnnotationToken();
865 Actions.ActOnPragmaFPContract(PragmaLoc, FPC);
868void Parser::HandlePragmaFloatControl() {
869 assert(Tok.is(tok::annot_pragma_float_control));
880 SourceLocation PragmaLoc = ConsumeAnnotationToken();
881 Actions.ActOnPragmaFloatControl(PragmaLoc, Action, Kind);
884void Parser::HandlePragmaFEnvAccess() {
885 assert(Tok.is(tok::annot_pragma_fenv_access) ||
886 Tok.is(tok::annot_pragma_fenv_access_ms));
889 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
904 SourceLocation PragmaLoc = ConsumeAnnotationToken();
905 Actions.ActOnPragmaFEnvAccess(PragmaLoc, IsEnabled);
908void Parser::HandlePragmaFEnvRound() {
909 assert(Tok.is(tok::annot_pragma_fenv_round));
910 auto RM =
static_cast<llvm::RoundingMode
>(
911 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
913 SourceLocation PragmaLoc = ConsumeAnnotationToken();
914 Actions.ActOnPragmaFEnvRound(PragmaLoc, RM);
917void Parser::HandlePragmaCXLimitedRange() {
918 assert(Tok.is(tok::annot_pragma_cx_limited_range));
920 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
938 SourceLocation PragmaLoc = ConsumeAnnotationToken();
939 Actions.ActOnPragmaCXLimitedRange(PragmaLoc, Range);
944 assert(Tok.is(tok::annot_pragma_captured));
945 ConsumeAnnotationToken();
947 if (Tok.isNot(tok::l_brace)) {
948 PP.Diag(Tok, diag::err_expected) << tok::l_brace;
952 SourceLocation Loc = Tok.getLocation();
960 CapturedRegionScope.Exit();
963 Actions.ActOnCapturedRegionError();
967 return Actions.ActOnCapturedRegionEnd(
R.get());
971 enum OpenCLExtState :
char {
972 Disable, Enable, Begin, End
974 typedef std::pair<const IdentifierInfo *, OpenCLExtState> OpenCLExtData;
977void Parser::HandlePragmaOpenCLExtension() {
978 assert(Tok.is(tok::annot_pragma_opencl_extension));
979 OpenCLExtData *
Data =
static_cast<OpenCLExtData*
>(Tok.getAnnotationValue());
980 auto State =
Data->second;
981 auto Ident =
Data->first;
982 SourceLocation NameLoc = Tok.getLocation();
983 ConsumeAnnotationToken();
985 auto &Opt = Actions.getOpenCLOptions();
986 auto Name = Ident->getName();
991 if (State == Disable)
994 PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1;
995 }
else if (State == Begin) {
996 if (!Opt.isKnown(Name) || !Opt.isSupported(Name,
getLangOpts())) {
1000 Opt.acceptsPragma(Name);
1002 }
else if (State == End) {
1005 }
else if (!Opt.isKnown(Name) || !Opt.isWithPragma(Name))
1006 PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << Ident;
1007 else if (Opt.isSupportedExtension(Name,
getLangOpts()))
1008 Opt.enable(Name, State == Enable);
1009 else if (Opt.isSupportedCoreOrOptionalCore(Name,
getLangOpts()))
1010 PP.Diag(NameLoc, diag::warn_pragma_extension_is_core) << Ident;
1012 PP.Diag(NameLoc, diag::warn_pragma_unsupported_extension) << Ident;
1015void Parser::HandlePragmaMSPointersToMembers() {
1016 assert(Tok.is(tok::annot_pragma_ms_pointers_to_members));
1019 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
1020 SourceLocation PragmaLoc = ConsumeAnnotationToken();
1021 Actions.ActOnPragmaMSPointersToMembers(RepresentationMethod, PragmaLoc);
1024void Parser::HandlePragmaMSVtorDisp() {
1025 assert(Tok.is(tok::annot_pragma_ms_vtordisp));
1030 SourceLocation PragmaLoc = ConsumeAnnotationToken();
1031 Actions.ActOnPragmaMSVtorDisp(Action, PragmaLoc, Mode);
1034void Parser::HandlePragmaMSPragma() {
1035 assert(Tok.is(tok::annot_pragma_ms_pragma));
1038 (std::pair<std::unique_ptr<Token[]>,
size_t> *)Tok.getAnnotationValue();
1039 PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second,
true,
1041 SourceLocation PragmaLocation = ConsumeAnnotationToken();
1042 assert(Tok.isAnyIdentifier());
1043 StringRef PragmaName = Tok.getIdentifierInfo()->getName();
1048 typedef bool (
Parser::*PragmaHandler)(StringRef, SourceLocation);
1049 PragmaHandler Handler =
1050 llvm::StringSwitch<PragmaHandler>(PragmaName)
1051 .Case(
"data_seg", &Parser::HandlePragmaMSSegment)
1052 .Case(
"bss_seg", &Parser::HandlePragmaMSSegment)
1053 .Case(
"const_seg", &Parser::HandlePragmaMSSegment)
1054 .Case(
"code_seg", &Parser::HandlePragmaMSSegment)
1055 .Case(
"section", &Parser::HandlePragmaMSSection)
1056 .Case(
"init_seg", &Parser::HandlePragmaMSInitSeg)
1057 .Case(
"strict_gs_check", &Parser::HandlePragmaMSStrictGuardStackCheck)
1058 .Case(
"function", &Parser::HandlePragmaMSFunction)
1059 .Case(
"alloc_text", &Parser::HandlePragmaMSAllocText)
1060 .Case(
"optimize", &Parser::HandlePragmaMSOptimize)
1061 .Case(
"intrinsic", &Parser::HandlePragmaMSIntrinsic);
1063 if (!(this->*Handler)(PragmaName, PragmaLocation)) {
1066 while (Tok.isNot(tok::eof))
1072bool Parser::HandlePragmaMSSection(StringRef PragmaName,
1074 if (Tok.isNot(tok::l_paren)) {
1075 PP.Diag(PragmaLocation, diag::warn_pragma_expected_lparen) << PragmaName;
1080 if (Tok.isNot(tok::string_literal)) {
1081 PP.Diag(PragmaLocation, diag::warn_pragma_expected_section_name)
1090 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1095 bool SectionFlagsAreDefault =
true;
1096 while (Tok.is(tok::comma)) {
1101 if (Tok.is(tok::kw_long) || Tok.is(tok::kw_short)) {
1106 if (!Tok.isAnyIdentifier()) {
1107 PP.Diag(PragmaLocation, diag::warn_pragma_expected_action_or_r_paren)
1112 llvm::StringSwitch<ASTContext::PragmaSectionFlag>(
1113 Tok.getIdentifierInfo()->getName())
1125 ? diag::warn_pragma_invalid_specific_action
1126 : diag::warn_pragma_unsupported_action)
1127 << PragmaName << Tok.getIdentifierInfo()->getName();
1130 SectionFlags |= Flag;
1131 SectionFlagsAreDefault =
false;
1136 if (SectionFlagsAreDefault)
1138 if (Tok.isNot(tok::r_paren)) {
1139 PP.Diag(PragmaLocation, diag::warn_pragma_expected_rparen) << PragmaName;
1143 if (Tok.isNot(tok::eof)) {
1144 PP.Diag(PragmaLocation, diag::warn_pragma_extra_tokens_at_eol)
1149 Actions.ActOnPragmaMSSection(PragmaLocation, SectionFlags, SegmentName);
1153bool Parser::HandlePragmaMSSegment(StringRef PragmaName,
1155 if (Tok.isNot(tok::l_paren)) {
1156 PP.Diag(PragmaLocation, diag::warn_pragma_expected_lparen) << PragmaName;
1161 StringRef SlotLabel;
1162 if (Tok.isAnyIdentifier()) {
1163 StringRef PushPop = Tok.getIdentifierInfo()->getName();
1164 if (PushPop ==
"push")
1166 else if (PushPop ==
"pop")
1169 PP.Diag(PragmaLocation,
1170 diag::warn_pragma_expected_section_push_pop_or_name)
1176 if (Tok.is(tok::comma)) {
1179 if (Tok.isAnyIdentifier()) {
1180 SlotLabel = Tok.getIdentifierInfo()->getName();
1182 if (Tok.is(tok::comma))
1184 else if (Tok.isNot(tok::r_paren)) {
1185 PP.Diag(PragmaLocation, diag::warn_pragma_expected_punc)
1190 }
else if (Tok.isNot(tok::r_paren)) {
1191 PP.Diag(PragmaLocation, diag::warn_pragma_expected_punc) << PragmaName;
1197 StringLiteral *SegmentName =
nullptr;
1198 if (Tok.isNot(tok::r_paren)) {
1199 if (Tok.isNot(tok::string_literal)) {
1201 diag::warn_pragma_expected_section_name :
1202 diag::warn_pragma_expected_section_label_or_name :
1203 diag::warn_pragma_expected_section_push_pop_or_name;
1204 PP.Diag(PragmaLocation, DiagID) << PragmaName;
1212 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1220 if (Tok.isNot(tok::r_paren)) {
1221 PP.Diag(PragmaLocation, diag::warn_pragma_expected_rparen) << PragmaName;
1225 if (Tok.isNot(tok::eof)) {
1226 PP.Diag(PragmaLocation, diag::warn_pragma_extra_tokens_at_eol)
1231 Actions.ActOnPragmaMSSeg(PragmaLocation, Action, SlotLabel,
1232 SegmentName, PragmaName);
1236bool Parser::HandlePragmaMSInitSeg(StringRef PragmaName,
1239 PP.Diag(PragmaLocation, diag::warn_pragma_init_seg_unsupported_target);
1243 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
1248 StringLiteral *SegmentName =
nullptr;
1249 if (Tok.isAnyIdentifier()) {
1250 auto *II = Tok.getIdentifierInfo();
1251 StringRef Section = llvm::StringSwitch<StringRef>(II->
getName())
1252 .Case(
"compiler",
"\".CRT$XCC\"")
1253 .Case(
"lib",
"\".CRT$XCL\"")
1254 .Case(
"user",
"\".CRT$XCU\"")
1257 if (!Section.empty()) {
1261 Toks[0].
setKind(tok::string_literal);
1269 }
else if (Tok.is(tok::string_literal)) {
1275 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1283 PP.Diag(PragmaLocation, diag::warn_pragma_expected_init_seg) << PragmaName;
1287 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
1289 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
1293 Actions.ActOnPragmaMSInitSeg(PragmaLocation, SegmentName);
1297bool Parser::HandlePragmaMSStrictGuardStackCheck(
1299 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
1304 if (Tok.is(tok::identifier)) {
1305 StringRef PushPop = Tok.getIdentifierInfo()->getName();
1306 if (PushPop ==
"push") {
1309 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_punc,
1312 }
else if (PushPop ==
"pop") {
1320 const IdentifierInfo *II = Tok.getIdentifierInfo();
1321 if (II && II->
isStr(
"off")) {
1324 }
else if (II && II->
isStr(
"on")) {
1328 PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_action)
1335 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
1339 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
1343 Actions.ActOnPragmaMSStrictGuardStackCheck(PragmaLocation, Action,
Value);
1347bool Parser::HandlePragmaMSAllocText(StringRef PragmaName,
1349 Token FirstTok = Tok;
1350 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
1355 if (Tok.is(tok::string_literal)) {
1361 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1366 }
else if (Tok.is(tok::identifier)) {
1367 Section = Tok.getIdentifierInfo()->getName();
1370 PP.Diag(PragmaLocation, diag::warn_pragma_expected_section_name)
1375 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_comma,
1379 SmallVector<std::tuple<IdentifierInfo *, SourceLocation>> Functions;
1381 if (Tok.isNot(tok::identifier)) {
1382 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
1387 IdentifierInfo *II = Tok.getIdentifierInfo();
1388 Functions.emplace_back(II, Tok.getLocation());
1391 if (Tok.isNot(tok::comma))
1396 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
1398 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
1402 Actions.ActOnPragmaMSAllocText(FirstTok.
getLocation(), Section, Functions);
1407 assert(Tok.is(PragmaKind));
1409 StringRef PragmaName =
"export";
1411 using namespace clang::charinfo;
1412 auto *TheTokens =
static_cast<std::pair<std::unique_ptr<Token[]>,
size_t> *>(
1413 Tok.getAnnotationValue());
1414 PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second,
true,
1416 Tok.setAnnotationValue(
nullptr);
1417 ConsumeAnnotationToken();
1419 llvm::scope_exit OnReturn([
this]() {
1420 while (Tok.isNot(tok::eof))
1427 if (Tok.isNot(tok::l_paren)) {
1428 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen)
1434 if (Tok.isNot(tok::identifier)) {
1435 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
1440 IdentifierInfo *IdentName = Tok.getIdentifierInfo();
1441 SourceLocation IdentNameLoc = Tok.getLocation();
1444 if (Tok.isNot(tok::r_paren)) {
1445 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_rparen)
1451 Actions.ActOnPragmaExport(IdentName, IdentNameLoc,
getCurScope());
1454 if (Tok.is(tok::identifier) || Tok.is(tok::kw_export)) {
1455 PragmaName = Tok.getIdentifierInfo()->getName();
1456 if (PragmaName !=
"export")
1457 PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1459 }
else if (Tok.isNot(tok::eof)) {
1460 PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1464 }
while (Tok.isNot(tok::eof));
1468void Parser::HandlePragmaExport() {
1469 assert(Tok.is(tok::annot_pragma_export));
1471 zOSHandlePragmaHelper(tok::annot_pragma_export);
1476 std::string ClangLoopStr(
"clang loop ");
1479 return std::string(llvm::StringSwitch<StringRef>(Str)
1480 .Case(
"loop", ClangLoopStr)
1481 .Case(
"unroll_and_jam", Str)
1482 .Case(
"unroll", Str)
1486bool Parser::HandlePragmaLoopHint(
LoopHint &Hint) {
1487 assert(Tok.is(tok::annot_pragma_loop_hint));
1488 PragmaLoopHintInfo *Info =
1489 static_cast<PragmaLoopHintInfo *
>(Tok.getAnnotationValue());
1497 IdentifierInfo *OptionInfo = Info->
Option.
is(tok::identifier)
1503 llvm::ArrayRef<Token> Toks = Info->
Toks;
1508 llvm::StringSwitch<bool>(PragmaNameInfo->
getName())
1509 .Cases({
"unroll",
"nounroll",
"unroll_and_jam",
"nounroll_and_jam"},
1513 if (Toks.empty() && IsLoopHint) {
1514 ConsumeAnnotationToken();
1521 assert(!Toks.empty() &&
1522 "PragmaLoopHintInfo::Toks must contain at least one token.");
1525 bool OptionUnroll =
false;
1526 bool OptionUnrollAndJam =
false;
1527 bool OptionDistribute =
false;
1528 bool OptionPipelineDisabled =
false;
1529 bool OptionLICMDisabled =
false;
1530 bool StateOption =
false;
1532 OptionUnroll = OptionInfo->
isStr(
"unroll");
1533 OptionUnrollAndJam = OptionInfo->
isStr(
"unroll_and_jam");
1534 OptionDistribute = OptionInfo->
isStr(
"distribute");
1535 OptionPipelineDisabled = OptionInfo->
isStr(
"pipeline");
1536 OptionLICMDisabled = OptionInfo->
isStr(
"licm");
1537 StateOption = llvm::StringSwitch<bool>(OptionInfo->
getName())
1538 .Case(
"vectorize",
true)
1539 .Case(
"interleave",
true)
1540 .Case(
"vectorize_predicate",
true)
1542 OptionUnroll || OptionUnrollAndJam || OptionDistribute ||
1543 OptionPipelineDisabled || OptionLICMDisabled;
1546 bool AssumeSafetyArg = !OptionUnroll && !OptionUnrollAndJam &&
1547 !OptionDistribute && !OptionPipelineDisabled &&
1548 !OptionLICMDisabled;
1550 if (Toks[0].
is(tok::eof)) {
1551 ConsumeAnnotationToken();
1552 Diag(Toks[0].getLocation(), diag::err_pragma_loop_missing_argument)
1554 << (OptionUnroll || OptionUnrollAndJam)
1561 ConsumeAnnotationToken();
1562 SourceLocation StateLoc = Toks[0].getLocation();
1563 IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
1567 llvm::StringSwitch<bool>(StateInfo->
getName())
1568 .Case(
"disable",
true)
1569 .Case(
"enable", !OptionPipelineDisabled && !OptionLICMDisabled)
1570 .Case(
"full", OptionUnroll || OptionUnrollAndJam)
1571 .Case(
"assume_safety", AssumeSafetyArg)
1574 if (OptionPipelineDisabled || OptionLICMDisabled) {
1575 Diag(Toks[0].getLocation(), diag::err_pragma_pipeline_invalid_keyword);
1577 Diag(Toks[0].getLocation(), diag::err_pragma_invalid_keyword)
1578 << (OptionUnroll || OptionUnrollAndJam)
1583 if (Toks.size() > 2)
1584 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1586 Hint.
StateLoc =
new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1587 }
else if (OptionInfo && OptionInfo->
getName() ==
"vectorize_width") {
1588 PP.EnterTokenStream(Toks,
false,
1590 ConsumeAnnotationToken();
1592 SourceLocation StateLoc = Toks[0].getLocation();
1593 IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
1594 StringRef IsScalableStr = StateInfo ? StateInfo->
getName() :
"";
1597 if (IsScalableStr ==
"scalable" || IsScalableStr ==
"fixed") {
1600 if (Toks.size() > 2) {
1601 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1603 while (Tok.isNot(tok::eof))
1607 Hint.
StateLoc =
new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1614 if (
R.isInvalid() && !Tok.is(tok::comma))
1615 Diag(Toks[0].getLocation(),
1616 diag::note_pragma_loop_invalid_vectorize_option);
1618 bool Arg2Error =
false;
1619 if (Tok.is(tok::comma)) {
1622 StateInfo = Tok.getIdentifierInfo();
1623 IsScalableStr = StateInfo ? StateInfo->
getName() :
"";
1625 if (IsScalableStr !=
"scalable" && IsScalableStr !=
"fixed") {
1626 Diag(Tok.getLocation(),
1627 diag::err_pragma_loop_invalid_vectorize_option);
1631 new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1638 if (Tok.isNot(tok::eof)) {
1639 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1641 while (Tok.isNot(tok::eof))
1647 if (Arg2Error ||
R.isInvalid() ||
1648 Actions.CheckLoopHintExpr(
R.get(), Toks[0].getLocation(),
1657 PP.EnterTokenStream(Toks,
false,
1659 ConsumeAnnotationToken();
1664 if (Tok.isNot(tok::eof)) {
1665 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1667 while (Tok.isNot(tok::eof))
1673 if (
R.isInvalid() ||
1674 Actions.CheckLoopHintExpr(
R.get(), Toks[0].getLocation(),
1683 Info->
Toks.back().getLocation());
1688struct PragmaAttributeInfo {
1689 enum ActionType { Push,
Pop, Attribute };
1690 ParsedAttributes &Attributes;
1692 const IdentifierInfo *
Namespace =
nullptr;
1693 ArrayRef<Token> Tokens;
1695 PragmaAttributeInfo(ParsedAttributes &Attributes) : Attributes(Attributes) {}
1698#include "clang/Parse/AttrSubMatchRulesParserStringSwitches.inc"
1703 if (
Tok.is(tok::identifier))
1704 return Tok.getIdentifierInfo()->getName();
1712 using namespace attr;
1714#define ATTR_MATCH_RULE(Value, Spelling, IsAbstract) \
1717#include "clang/Basic/AttrSubMatchRulesList.inc"
1719 llvm_unreachable(
"Invalid attribute subject match rule");
1727 PRef.
Diag(SubRuleLoc,
1728 diag::err_pragma_attribute_expected_subject_sub_identifier)
1730 if (
const char *SubRules = validAttributeSubjectMatchSubRules(PrimaryRule))
1741 PRef.
Diag(SubRuleLoc, diag::err_pragma_attribute_unknown_subject_sub_rule)
1742 << SubRuleName << PrimaryRuleName;
1743 if (
const char *SubRules = validAttributeSubjectMatchSubRules(PrimaryRule))
1749bool Parser::ParsePragmaAttributeSubjectMatchRuleSet(
1757 if (AnyParens.expectAndConsume())
1765 Diag(Tok, diag::err_pragma_attribute_expected_subject_identifier);
1768 std::pair<std::optional<attr::SubjectMatchRule>,
1769 std::optional<attr::SubjectMatchRule> (*)(StringRef,
bool)>
1770 Rule = isAttributeSubjectMatchRule(Name);
1772 Diag(Tok, diag::err_pragma_attribute_unknown_subject_rule) << Name;
1780 if (
Parens.expectAndConsume())
1782 }
else if (
Parens.consumeOpen()) {
1783 if (!SubjectMatchRules
1785 std::make_pair(PrimaryRule, SourceRange(RuleLoc, RuleLoc)))
1787 Diag(RuleLoc, diag::err_pragma_attribute_duplicate_subject)
1790 RuleLoc, Tok.is(tok::comma) ? Tok.getLocation() : RuleLoc));
1791 LastMatchRuleEndLoc = RuleLoc;
1797 if (SubRuleName.empty()) {
1803 if (SubRuleName ==
"unless") {
1806 if (
Parens.expectAndConsume())
1809 if (SubRuleName.empty()) {
1814 auto SubRuleOrNone =
Rule.second(SubRuleName,
true);
1815 if (!SubRuleOrNone) {
1816 std::string SubRuleUnlessName =
"unless(" + SubRuleName.str() +
")";
1818 SubRuleUnlessName, SubRuleLoc);
1821 SubRule = *SubRuleOrNone;
1823 if (
Parens.consumeClose())
1826 auto SubRuleOrNone =
Rule.second(SubRuleName,
false);
1827 if (!SubRuleOrNone) {
1829 SubRuleName, Tok.getLocation());
1832 SubRule = *SubRuleOrNone;
1835 SourceLocation RuleEndLoc = Tok.getLocation();
1836 LastMatchRuleEndLoc = RuleEndLoc;
1837 if (
Parens.consumeClose())
1839 if (!SubjectMatchRules
1840 .insert(std::make_pair(SubRule, SourceRange(RuleLoc, RuleEndLoc)))
1842 Diag(RuleLoc, diag::err_pragma_attribute_duplicate_subject)
1845 RuleLoc, Tok.is(tok::comma) ? Tok.getLocation() : RuleEndLoc));
1851 if (AnyParens.consumeClose())
1860enum class MissingAttributeSubjectRulesRecoveryPoint {
1868MissingAttributeSubjectRulesRecoveryPoint
1869getAttributeSubjectRulesRecoveryPointForToken(
const Token &
Tok) {
1871 if (II->
isStr(
"apply_to"))
1872 return MissingAttributeSubjectRulesRecoveryPoint::ApplyTo;
1873 if (II->
isStr(
"any"))
1874 return MissingAttributeSubjectRulesRecoveryPoint::Any;
1876 if (
Tok.
is(tok::equal))
1877 return MissingAttributeSubjectRulesRecoveryPoint::Equals;
1878 return MissingAttributeSubjectRulesRecoveryPoint::None;
1886 MissingAttributeSubjectRulesRecoveryPoint Point,
Parser &PRef) {
1892 MissingAttributeSubjectRulesRecoveryPoint EndPoint =
1893 getAttributeSubjectRulesRecoveryPointForToken(PRef.
getCurToken());
1894 if (Point == MissingAttributeSubjectRulesRecoveryPoint::Comma)
1896 if (Point <= MissingAttributeSubjectRulesRecoveryPoint::ApplyTo &&
1897 EndPoint > MissingAttributeSubjectRulesRecoveryPoint::ApplyTo)
1898 FixIt +=
"apply_to";
1899 if (Point <= MissingAttributeSubjectRulesRecoveryPoint::Equals &&
1900 EndPoint > MissingAttributeSubjectRulesRecoveryPoint::Equals)
1903 if (EndPoint == MissingAttributeSubjectRulesRecoveryPoint::None) {
1910 Attribute.getMatchRules(PRef.
getLangOpts(), MatchRules);
1912 for (
const auto &Rule : MatchRules) {
1917 IsSupported[
Rule.first] =
true;
1919 IsMatchRuleAvailable &= IsSupported;
1921 if (IsMatchRuleAvailable.count() == 0) {
1927 bool NeedsComma =
false;
1929 if (!IsMatchRuleAvailable[I])
1943 if (FixItRange.getBegin() == FixItRange.getEnd())
1953void Parser::HandlePragmaAttribute() {
1954 assert(Tok.is(tok::annot_pragma_attribute) &&
1955 "Expected #pragma attribute annotation token");
1956 SourceLocation PragmaLoc = Tok.getLocation();
1957 auto *Info =
static_cast<PragmaAttributeInfo *
>(Tok.getAnnotationValue());
1958 if (Info->Action == PragmaAttributeInfo::Pop) {
1959 ConsumeAnnotationToken();
1960 Actions.ActOnPragmaAttributePop(PragmaLoc, Info->Namespace);
1964 assert((Info->Action == PragmaAttributeInfo::Push ||
1965 Info->Action == PragmaAttributeInfo::Attribute) &&
1966 "Unexpected #pragma attribute command");
1968 if (Info->Action == PragmaAttributeInfo::Push && Info->Tokens.empty()) {
1969 ConsumeAnnotationToken();
1970 Actions.ActOnPragmaAttributeEmptyPush(PragmaLoc, Info->Namespace);
1974 PP.EnterTokenStream(Info->Tokens,
false,
1976 ConsumeAnnotationToken();
1978 ParsedAttributes &Attrs = Info->Attributes;
1981 auto SkipToEnd = [
this]() {
1986 if ((Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) ||
1987 Tok.isRegularKeywordAttribute()) {
1989 SourceLocation EndLoc = Tok.getLocation();
1990 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
1991 }
else if (Tok.is(tok::kw___attribute)) {
1993 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
1996 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"("))
2001 if (Tok.is(tok::code_completion)) {
2004 Actions.CodeCompletion().CodeCompleteAttribute(
2011 if (Tok.isNot(tok::identifier)) {
2012 Diag(Tok, diag::err_pragma_attribute_expected_attribute_name);
2016 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
2019 if (Tok.isNot(tok::l_paren))
2020 Attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0,
2021 ParsedAttr::Form::GNU());
2023 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs,
nullptr,
2026 ParsedAttr::Form::GNU(),
2030 if (ExpectAndConsume(tok::r_paren))
2032 if (ExpectAndConsume(tok::r_paren))
2034 }
else if (Tok.is(tok::kw___declspec)) {
2035 ParseMicrosoftDeclSpecs(Attrs);
2037 Diag(Tok, diag::err_pragma_attribute_expected_attribute_syntax);
2038 if (Tok.getIdentifierInfo()) {
2042 Tok.getIdentifierInfo(),
nullptr,
2044 SourceLocation InsertStartLoc = Tok.getLocation();
2046 if (Tok.is(tok::l_paren)) {
2049 if (Tok.isNot(tok::r_paren))
2052 Diag(Tok, diag::note_pragma_attribute_use_attribute_kw)
2061 if (Attrs.
empty() || Attrs.
begin()->isInvalid()) {
2066 for (
const ParsedAttr &Attribute : Attrs) {
2067 if (!Attribute.isSupportedByPragmaAttribute()) {
2068 Diag(PragmaLoc, diag::err_pragma_attribute_unsupported_attribute)
2077 createExpectedAttributeSubjectRulesTokenDiagnostic(
2078 diag::err_expected, Attrs,
2079 MissingAttributeSubjectRulesRecoveryPoint::Comma, *
this)
2085 if (Tok.isNot(tok::identifier)) {
2086 createExpectedAttributeSubjectRulesTokenDiagnostic(
2087 diag::err_pragma_attribute_invalid_subject_set_specifier, Attrs,
2088 MissingAttributeSubjectRulesRecoveryPoint::ApplyTo, *
this);
2092 const IdentifierInfo *II = Tok.getIdentifierInfo();
2093 if (!II->
isStr(
"apply_to")) {
2094 createExpectedAttributeSubjectRulesTokenDiagnostic(
2095 diag::err_pragma_attribute_invalid_subject_set_specifier, Attrs,
2096 MissingAttributeSubjectRulesRecoveryPoint::ApplyTo, *
this);
2103 createExpectedAttributeSubjectRulesTokenDiagnostic(
2104 diag::err_expected, Attrs,
2105 MissingAttributeSubjectRulesRecoveryPoint::Equals, *
this)
2112 SourceLocation AnyLoc, LastMatchRuleEndLoc;
2113 if (ParsePragmaAttributeSubjectMatchRuleSet(SubjectMatchRules, AnyLoc,
2114 LastMatchRuleEndLoc)) {
2121 if (Tok.isNot(tok::eof)) {
2122 Diag(Tok, diag::err_pragma_attribute_extra_tokens_after_attribute);
2131 if (Info->Action == PragmaAttributeInfo::Push)
2132 Actions.ActOnPragmaAttributeEmptyPush(PragmaLoc, Info->Namespace);
2134 for (ParsedAttr &Attribute : Attrs) {
2135 Actions.ActOnPragmaAttributeAttribute(Attribute, PragmaLoc,
2143void PragmaGCCVisibilityHandler::HandlePragma(
Preprocessor &PP,
2154 if (PushPop && PushPop->
isStr(
"pop")) {
2156 }
else if (PushPop && PushPop->
isStr(
"push")) {
2189 auto Toks = std::make_unique<Token[]>(1);
2190 Toks[0].startToken();
2191 Toks[0].setKind(tok::annot_pragma_vis);
2192 Toks[0].setLocation(VisLoc);
2193 Toks[0].setAnnotationEndLoc(EndLoc);
2194 Toks[0].setAnnotationValue(
2195 const_cast<void *
>(
static_cast<const void *
>(VisType)));
2196 PP.EnterTokenStream(std::move(Toks), 1,
true,
2218 StringRef SlotLabel;
2222 if (
Tok.
is(tok::numeric_constant)) {
2233 }
else if (
Tok.
is(tok::identifier)) {
2235 auto MapPack = [&](
const char *
Literal) {
2238 Alignment.
setKind(tok::numeric_constant);
2244 if (II->
isStr(
"show")) {
2264 if (II->
isStr(
"push")) {
2266 }
else if (II->
isStr(
"pop")) {
2274 if (
Tok.
is(tok::comma)) {
2277 if (
Tok.
is(tok::numeric_constant)) {
2282 }
else if (
Tok.
is(tok::identifier)) {
2286 if (
Tok.
is(tok::comma)) {
2289 if (
Tok.
isNot(tok::numeric_constant)) {
2334 Toks[0].startToken();
2335 Toks[0].setKind(tok::annot_pragma_pack);
2336 Toks[0].setLocation(PackLoc);
2337 Toks[0].setAnnotationEndLoc(RParenLoc);
2338 Toks[0].setAnnotationValue(
static_cast<void*
>(Info));
2339 PP.EnterTokenStream(Toks,
true,
2345void PragmaMSStructHandler::HandlePragma(
Preprocessor &PP,
2347 Token &MSStructTok) {
2358 if (II->
isStr(
"on")) {
2362 else if (II->
isStr(
"off") || II->
isStr(
"reset"))
2377 Toks[0].startToken();
2378 Toks[0].setKind(tok::annot_pragma_msstruct);
2380 Toks[0].setAnnotationEndLoc(EndLoc);
2381 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
2383 PP.EnterTokenStream(Toks,
true,
2388void PragmaClangSectionHandler::HandlePragma(
Preprocessor &PP,
2390 Token &FirstToken) {
2398 PP.
Diag(
Tok.
getLocation(), diag::err_pragma_expected_clang_section_name) <<
"clang section";
2403 if (SecType->
isStr(
"bss"))
2405 else if (SecType->
isStr(
"data"))
2407 else if (SecType->
isStr(
"rodata"))
2409 else if (SecType->
isStr(
"relro"))
2411 else if (SecType->
isStr(
"text"))
2414 PP.
Diag(
Tok.
getLocation(), diag::err_pragma_expected_clang_section_name) <<
"clang section";
2426 std::string SecName;
2430 Actions.ActOnPragmaClangSection(PragmaLocation,
2447 if (
Tok.isNot(tok::identifier) ||
2448 !
Tok.getIdentifierInfo()->isStr(
"align")) {
2449 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_options_expected_align);
2456 if (
Tok.isNot(tok::l_paren)) {
2457 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_lparen) <<
"align";
2460 }
else if (
Tok.isNot(tok::equal)) {
2461 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_align_expected_equal)
2467 if (
Tok.isNot(tok::identifier)) {
2468 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_identifier)
2469 << (IsOptions ?
"options" :
"align");
2475 if (II->
isStr(
"native"))
2477 else if (II->
isStr(
"natural"))
2479 else if (II->
isStr(
"packed"))
2481 else if (II->
isStr(
"power"))
2483 else if (II->
isStr(
"mac68k"))
2485 else if (II->
isStr(
"reset"))
2488 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_align_invalid_option)
2495 if (
Tok.isNot(tok::r_paren)) {
2496 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_rparen) <<
"align";
2503 if (
Tok.isNot(tok::eod)) {
2504 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
2505 << (IsOptions ?
"options" :
"align");
2511 Toks[0].startToken();
2512 Toks[0].setKind(tok::annot_pragma_align);
2514 Toks[0].setAnnotationEndLoc(EndLoc);
2515 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
2517 PP.EnterTokenStream(Toks,
true,
2527void PragmaOptionsHandler::HandlePragma(
Preprocessor &PP,
2529 Token &OptionsTok) {
2534void PragmaUnusedHandler::HandlePragma(
Preprocessor &PP,
2557 if (
Tok.
is(tok::identifier)) {
2558 Identifiers.push_back(
Tok);
2569 if (
Tok.
is(tok::comma)) {
2574 if (
Tok.
is(tok::r_paren)) {
2592 assert(RParenLoc.
isValid() &&
"Valid '#pragma unused' must have ')'");
2593 assert(!Identifiers.empty() &&
"Valid '#pragma unused' must have arguments");
2602 2 * Identifiers.size());
2603 for (
unsigned i=0; i != Identifiers.size(); i++) {
2604 Token &pragmaUnusedTok = Toks[2*i], &idTok = Toks[2*i+1];
2606 pragmaUnusedTok.
setKind(tok::annot_pragma_unused);
2608 idTok = Identifiers[i];
2610 PP.EnterTokenStream(Toks,
true,
2629 bool HasAlias =
false;
2633 if (
Tok.
is(tok::equal)) {
2653 Token &pragmaUnusedTok = Toks[0];
2655 pragmaUnusedTok.
setKind(tok::annot_pragma_weakalias);
2659 Toks[2] = AliasName;
2660 PP.EnterTokenStream(Toks,
true,
2665 Token &pragmaUnusedTok = Toks[0];
2667 pragmaUnusedTok.
setKind(tok::annot_pragma_weak);
2671 PP.EnterTokenStream(Toks,
true,
2677void PragmaRedefineExtnameHandler::HandlePragma(
Preprocessor &PP,
2679 Token &RedefToken) {
2695 <<
"redefine_extname";
2710 Token &pragmaRedefTok = Toks[0];
2712 pragmaRedefTok.
setKind(tok::annot_pragma_redefine_extname);
2715 Toks[1] = RedefName;
2716 Toks[2] = AliasName;
2717 PP.EnterTokenStream(Toks,
true,
2721void PragmaFPContractHandler::HandlePragma(
Preprocessor &PP,
2730 Toks[0].startToken();
2731 Toks[0].setKind(tok::annot_pragma_fp_contract);
2734 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
2736 PP.EnterTokenStream(Toks,
true,
2740void PragmaOpenCLExtensionHandler::HandlePragma(
Preprocessor &PP,
2765 OpenCLExtState State;
2766 if (Pred->
isStr(
"enable")) {
2768 }
else if (Pred->
isStr(
"disable")) {
2770 }
else if (Pred->
isStr(
"begin"))
2772 else if (Pred->
isStr(
"end"))
2776 << Ext->
isStr(
"all");
2790 Info->second = State;
2793 Toks[0].startToken();
2794 Toks[0].setKind(tok::annot_pragma_opencl_extension);
2795 Toks[0].setLocation(NameLoc);
2796 Toks[0].setAnnotationValue(
static_cast<void*
>(Info));
2797 Toks[0].setAnnotationEndLoc(StateLoc);
2798 PP.EnterTokenStream(Toks,
true,
2808template <diag::kind IgnoredDiag>
2809void PragmaNoSupportHandler<IgnoredDiag>::HandlePragma(
2812 PP.
Diag(FirstTok, IgnoredDiag);
2823void PragmaSupportHandler<StartTok, EndTok, UnexpectedDiag>::HandlePragma(
2832 Pragma.push_back(
Tok);
2834 if (
Tok.
is(StartTok)) {
2835 PP.
Diag(
Tok, UnexpectedDiag) << 0;
2836 unsigned InnerPragmaCnt = 1;
2837 while (InnerPragmaCnt != 0) {
2839 if (
Tok.
is(StartTok))
2841 else if (
Tok.
is(EndTok))
2851 Pragma.push_back(
Tok);
2853 auto Toks = std::make_unique<Token[]>(Pragma.size());
2854 std::copy(Pragma.begin(), Pragma.end(), Toks.get());
2855 PP.EnterTokenStream(std::move(Toks), Pragma.size(),
2867void PragmaMSPointersToMembers::HandlePragma(
Preprocessor &PP,
2873 PP.
Diag(PointersToMembersLoc, diag::warn_pragma_expected_lparen)
2874 <<
"pointers_to_members";
2881 <<
"pointers_to_members";
2887 if (Arg->
isStr(
"best_case")) {
2890 if (Arg->
isStr(
"full_generality")) {
2891 if (
Tok.
is(tok::comma)) {
2897 diag::err_pragma_pointers_to_members_unknown_kind)
2902 }
else if (
Tok.
is(tok::r_paren)) {
2909 <<
"full_generality";
2915 if (Arg->
isStr(
"single_inheritance")) {
2916 RepresentationMethod =
2918 }
else if (Arg->
isStr(
"multiple_inheritance")) {
2919 RepresentationMethod =
2921 }
else if (Arg->
isStr(
"virtual_inheritance")) {
2922 RepresentationMethod =
2926 diag::err_pragma_pointers_to_members_unknown_kind)
2935 << (Arg ? Arg->
getName() :
"full_generality");
2943 <<
"pointers_to_members";
2949 AnnotTok.
setKind(tok::annot_pragma_ms_pointers_to_members);
2953 reinterpret_cast<void *
>(
static_cast<uintptr_t>(RepresentationMethod)));
2970 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_lparen) <<
"vtordisp";
2978 if (II->
isStr(
"push")) {
2982 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_punc) <<
"vtordisp";
2988 }
else if (II->
isStr(
"pop")) {
2995 if (
Tok.
is(tok::r_paren)) {
3005 if (II && II->
isStr(
"off")) {
3008 }
else if (II && II->
isStr(
"on")) {
3011 }
else if (
Tok.
is(tok::numeric_constant) &&
3015 << 0 << 2 <<
"vtordisp";
3027 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_rparen) <<
"vtordisp";
3041 AnnotTok.
setKind(tok::annot_pragma_ms_vtordisp);
3053 Token EoF, AnnotTok;
3057 AnnotTok.
setKind(tok::annot_pragma_ms_pragma);
3063 TokenVector.push_back(
Tok);
3067 TokenVector.push_back(EoF);
3070 markAsReinjectedForRelexing(TokenVector);
3071 auto TokenArray = std::make_unique<Token[]>(TokenVector.size());
3072 std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
3074 std::pair<std::unique_ptr<Token[]>,
size_t>(std::move(TokenArray),
3075 TokenVector.size());
3091void PragmaFloatControlHandler::HandlePragma(
Preprocessor &PP,
3104 PP.
Diag(FloatControlLoc, diag::err_expected) << tok::l_paren;
3118 llvm::StringSwitch<PragmaFloatControlKind>(II->
getName())
3136 if (
Tok.
is(tok::r_paren))
3149 if (PushOnOff ==
"on")
3152 else if (PushOnOff ==
"off") {
3157 }
else if (PushOnOff ==
"push") {
3164 if (
Tok.
is(tok::comma)) {
3171 if (ExpectedPush ==
"push") {
3196 auto TokenArray = std::make_unique<Token[]>(1);
3197 TokenArray[0].startToken();
3198 TokenArray[0].setKind(tok::annot_pragma_float_control);
3199 TokenArray[0].setLocation(FloatControlLoc);
3200 TokenArray[0].setAnnotationEndLoc(EndLoc);
3203 TokenArray[0].setAnnotationValue(
reinterpret_cast<void *
>(
3204 static_cast<uintptr_t>((Action << 16) | (Kind & 0xFFFF))));
3205 PP.EnterTokenStream(std::move(TokenArray), 1,
3219void PragmaDetectMismatchHandler::HandlePragma(
Preprocessor &PP,
3225 PP.
Diag(DetectMismatchLoc, diag::err_expected) << tok::l_paren;
3230 std::string NameString;
3232 "pragma detect_mismatch",
3237 std::string ValueString;
3263 Actions.ActOnPragmaDetectMismatch(DetectMismatchLoc, NameString, ValueString);
3275void PragmaCommentHandler::HandlePragma(
Preprocessor &PP,
3281 PP.
Diag(CommentLoc, diag::err_pragma_comment_malformed);
3288 PP.
Diag(CommentLoc, diag::err_pragma_comment_malformed);
3295 llvm::StringSwitch<PragmaMSCommentKind>(II->
getName())
3315 std::string ArgumentString;
3343 Actions.ActOnPragmaMSComment(CommentLoc, Kind, ArgumentString);
3348void PragmaOptimizeHandler::HandlePragma(
Preprocessor &PP,
3350 Token &FirstToken) {
3353 if (
Tok.
is(tok::eod)) {
3355 <<
"clang optimize" <<
true <<
"'on' or 'off'";
3366 if (II->
isStr(
"on")) {
3368 }
else if (!II->
isStr(
"off")) {
3381 Actions.ActOnPragmaOptimize(IsOn, FirstToken.
getLocation());
3386struct TokFPAnnotValue {
3387 enum FlagValues { On, Off, Fast };
3389 std::optional<LangOptions::FPModeKind> ContractValue;
3390 std::optional<LangOptions::FPModeKind> ReassociateValue;
3391 std::optional<LangOptions::FPModeKind> ReciprocalValue;
3392 std::optional<LangOptions::FPExceptionModeKind> ExceptionsValue;
3393 std::optional<LangOptions::FPEvalMethodKind> EvalMethodValue;
3411 while (
Tok.
is(tok::identifier)) {
3415 llvm::StringSwitch<std::optional<PragmaFPKind>>(OptionInfo->
getName())
3421 .Default(std::nullopt);
3424 <<
false << OptionInfo;
3435 bool isEvalMethodDouble =
3439 if (
Tok.
isNot(tok::identifier) && !isEvalMethodDouble) {
3442 <<
static_cast<int>(*FlagKind);
3448 AnnotValue->ContractValue =
3449 llvm::StringSwitch<std::optional<LangOptions::FPModeKind>>(
3454 .Default(std::nullopt);
3455 if (!AnnotValue->ContractValue) {
3462 : AnnotValue->ReciprocalValue;
3463 Value = llvm::StringSwitch<std::optional<LangOptions::FPModeKind>>(
3467 .Default(std::nullopt);
3474 AnnotValue->ExceptionsValue =
3475 llvm::StringSwitch<std::optional<LangOptions::FPExceptionModeKind>>(
3480 .Default(std::nullopt);
3481 if (!AnnotValue->ExceptionsValue) {
3487 AnnotValue->EvalMethodValue =
3488 llvm::StringSwitch<std::optional<LangOptions::FPEvalMethodKind>>(
3493 .Default(std::nullopt);
3494 if (!AnnotValue->EvalMethodValue) {
3518 FPTok.
setKind(tok::annot_pragma_fp);
3522 TokenList.push_back(FPTok);
3524 auto TokenArray = std::make_unique<Token[]>(TokenList.size());
3525 std::copy(TokenList.begin(), TokenList.end(), TokenArray.get());
3527 PP.EnterTokenStream(std::move(TokenArray), TokenList.size(),
3531void PragmaSTDC_FENV_ROUNDHandler::HandlePragma(
Preprocessor &PP,
3550 llvm::StringSwitch<llvm::RoundingMode>(II->
getName())
3551 .Case(
"FE_TOWARDZERO", llvm::RoundingMode::TowardZero)
3552 .Case(
"FE_TONEAREST", llvm::RoundingMode::NearestTiesToEven)
3553 .Case(
"FE_UPWARD", llvm::RoundingMode::TowardPositive)
3554 .Case(
"FE_DOWNWARD", llvm::RoundingMode::TowardNegative)
3555 .Case(
"FE_TONEARESTFROMZERO", llvm::RoundingMode::NearestTiesToAway)
3556 .Case(
"FE_DYNAMIC", llvm::RoundingMode::Dynamic)
3557 .Default(llvm::RoundingMode::Invalid);
3558 if (RM == llvm::RoundingMode::Invalid) {
3566 <<
"STDC FENV_ROUND";
3575 Toks[0].startToken();
3576 Toks[0].setKind(tok::annot_pragma_fenv_round);
3579 Toks[0].setAnnotationValue(
3580 reinterpret_cast<void *
>(
static_cast<uintptr_t>(RM)));
3581 PP.EnterTokenStream(Toks,
true,
3585void Parser::HandlePragmaFP() {
3586 assert(Tok.is(tok::annot_pragma_fp));
3588 reinterpret_cast<TokFPAnnotValue *
>(Tok.getAnnotationValue());
3590 if (AnnotValue->ReassociateValue)
3591 Actions.ActOnPragmaFPValueChangingOption(
3595 if (AnnotValue->ReciprocalValue)
3596 Actions.ActOnPragmaFPValueChangingOption(
3600 if (AnnotValue->ContractValue)
3601 Actions.ActOnPragmaFPContract(Tok.getLocation(),
3602 *AnnotValue->ContractValue);
3603 if (AnnotValue->ExceptionsValue)
3604 Actions.ActOnPragmaFPExceptions(Tok.getLocation(),
3605 *AnnotValue->ExceptionsValue);
3606 if (AnnotValue->EvalMethodValue)
3607 Actions.ActOnPragmaFPEvalMethod(Tok.getLocation(),
3608 *AnnotValue->EvalMethodValue);
3609 ConsumeAnnotationToken();
3614 Token Option,
bool ValueInParens,
3617 int OpenParens = ValueInParens ? 1 : 0;
3619 while (
Tok.isNot(tok::eod)) {
3620 if (
Tok.is(tok::l_paren))
3622 else if (
Tok.is(tok::r_paren)) {
3624 if (OpenParens == 0 && ValueInParens)
3632 if (ValueInParens) {
3634 if (
Tok.isNot(tok::r_paren)) {
3635 PP.
Diag(
Tok.getLocation(), diag::err_expected) << tok::r_paren;
3703void PragmaLoopHintHandler::HandlePragma(
Preprocessor &PP,
3718 while (
Tok.
is(tok::identifier)) {
3722 bool OptionValid = llvm::StringSwitch<bool>(OptionInfo->
getName())
3723 .Case(
"vectorize",
true)
3724 .Case(
"interleave",
true)
3725 .Case(
"unroll",
true)
3726 .Case(
"distribute",
true)
3727 .Case(
"vectorize_predicate",
true)
3728 .Case(
"vectorize_width",
true)
3729 .Case(
"interleave_count",
true)
3730 .Case(
"unroll_count",
true)
3731 .Case(
"pipeline",
true)
3732 .Case(
"pipeline_initiation_interval",
true)
3737 <<
false << OptionInfo;
3757 LoopHintTok.
setKind(tok::annot_pragma_loop_hint);
3761 TokenList.push_back(LoopHintTok);
3770 auto TokenArray = std::make_unique<Token[]>(TokenList.size());
3771 std::copy(TokenList.begin(), TokenList.end(), TokenArray.get());
3773 PP.EnterTokenStream(std::move(TokenArray), TokenList.size(),
3798void PragmaUnrollHintHandler::HandlePragma(
Preprocessor &PP,
3806 if (
Tok.
is(tok::eod)) {
3808 Info->PragmaName = PragmaName;
3809 Info->Option.startToken();
3819 bool ValueInParens =
Tok.
is(tok::l_paren);
3831 PP.
Diag(Info->Toks[0].getLocation(),
3832 diag::warn_pragma_unroll_cuda_value_in_parens);
3842 auto TokenArray = std::make_unique<Token[]>(1);
3843 TokenArray[0].startToken();
3844 TokenArray[0].setKind(tok::annot_pragma_loop_hint);
3845 TokenArray[0].setLocation(Introducer.
Loc);
3846 TokenArray[0].setAnnotationEndLoc(PragmaName.
getLocation());
3847 TokenArray[0].setAnnotationValue(
static_cast<void *
>(Info));
3848 PP.EnterTokenStream(std::move(TokenArray), 1,
3852bool Parser::HandlePragmaMSFunction(StringRef PragmaName,
3854 Token FirstTok = Tok;
3856 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3860 bool SuggestIntrinH = !PP.isMacroDefined(
"__INTRIN_H");
3862 llvm::SmallVector<StringRef> NoBuiltins;
3863 while (Tok.is(tok::identifier)) {
3864 IdentifierInfo *II = Tok.getIdentifierInfo();
3866 PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
3867 << II << SuggestIntrinH;
3869 NoBuiltins.emplace_back(II->
getName());
3872 if (Tok.isNot(tok::comma))
3877 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3879 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3883 Actions.ActOnPragmaMSFunction(FirstTok.
getLocation(), NoBuiltins);
3887bool Parser::HandlePragmaMSOptimize(StringRef PragmaName,
3889 Token FirstTok = Tok;
3890 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3894 if (Tok.isNot(tok::string_literal)) {
3895 PP.Diag(PragmaLocation, diag::warn_pragma_expected_string) << PragmaName;
3903 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
3908 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_comma,
3912 if (Tok.is(tok::eof) || Tok.is(tok::r_paren)) {
3913 PP.Diag(PragmaLocation, diag::warn_pragma_missing_argument)
3914 << PragmaName <<
true <<
"'on' or 'off'";
3917 IdentifierInfo *II = Tok.getIdentifierInfo();
3918 if (!II || (!II->
isStr(
"on") && !II->
isStr(
"off"))) {
3919 PP.Diag(PragmaLocation, diag::warn_pragma_invalid_argument)
3920 << PP.getSpelling(Tok) << PragmaName <<
true
3924 bool IsOn = II->
isStr(
"on");
3927 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3932 if (!OptimizationList->
getString().empty()) {
3933 PP.Diag(PragmaLocation, diag::warn_pragma_invalid_argument)
3934 << OptimizationList->
getString() << PragmaName <<
true
3939 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3943 Actions.ActOnPragmaMSOptimize(FirstTok.
getLocation(), IsOn);
3960bool Parser::HandlePragmaMSIntrinsic(StringRef PragmaName,
3962 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3966 bool SuggestIntrinH = !PP.isMacroDefined(
"__INTRIN_H");
3968 while (Tok.is(tok::identifier)) {
3969 IdentifierInfo *II = Tok.getIdentifierInfo();
3971 PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
3972 << II << SuggestIntrinH;
3974 DeclarationNameInfo NameInfo(II, Tok.getLocation());
3977 Actions.LookupName(
Previous, Actions.getCurScope(),
3980 Actions.LazilyCreateBuiltin(II, II->
getBuiltinID(), Actions.getCurScope(),
3981 true, Tok.getLocation());
3983 if (Tok.isNot(tok::comma))
3987 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3991 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3997void PragmaForceCUDAHostDeviceHandler::HandlePragma(
4003 if (!Info || (!Info->
isStr(
"begin") && !Info->
isStr(
"end"))) {
4005 diag::warn_pragma_force_cuda_host_device_bad_arg);
4009 if (Info->
isStr(
"begin"))
4010 Actions.CUDA().PushForceHostDevice();
4011 else if (!Actions.CUDA().PopForceHostDevice())
4013 diag::err_pragma_cannot_end_force_cuda_host_device);
4016 if (!
Tok.
is(tok::eod))
4018 diag::warn_pragma_force_cuda_host_device_bad_arg);
4048void PragmaAttributeHandler::HandlePragma(
Preprocessor &PP,
4050 Token &FirstToken) {
4054 PragmaAttributeInfo(AttributesForPragmaAttribute);
4057 if (
Tok.
is(tok::identifier)) {
4059 if (!II->
isStr(
"push") && !II->
isStr(
"pop")) {
4060 Info->Namespace = II;
4063 if (!
Tok.
is(tok::period)) {
4072 if (!
Tok.
isOneOf(tok::identifier, tok::l_paren)) {
4074 diag::err_pragma_attribute_expected_push_pop_paren);
4079 if (
Tok.
is(tok::l_paren)) {
4080 if (Info->Namespace) {
4082 diag::err_pragma_attribute_namespace_on_attribute);
4084 diag::note_pragma_attribute_namespace_on_attribute);
4087 Info->Action = PragmaAttributeInfo::Attribute;
4090 if (II->
isStr(
"push"))
4091 Info->Action = PragmaAttributeInfo::Push;
4092 else if (II->
isStr(
"pop"))
4093 Info->Action = PragmaAttributeInfo::Pop;
4104 if ((Info->Action == PragmaAttributeInfo::Push &&
Tok.
isNot(tok::eod)) ||
4105 Info->Action == PragmaAttributeInfo::Attribute) {
4116 if (
Tok.
is(tok::l_paren))
4118 else if (
Tok.
is(tok::r_paren)) {
4120 if (OpenParens == 0)
4124 AttributeTokens.push_back(
Tok);
4128 if (AttributeTokens.empty()) {
4144 AttributeTokens.push_back(EOFTok);
4146 markAsReinjectedForRelexing(AttributeTokens);
4153 <<
"clang attribute";
4156 auto TokenArray = std::make_unique<Token[]>(1);
4157 TokenArray[0].startToken();
4158 TokenArray[0].setKind(tok::annot_pragma_attribute);
4159 TokenArray[0].setLocation(FirstToken.
getLocation());
4160 TokenArray[0].setAnnotationEndLoc(FirstToken.
getLocation());
4161 TokenArray[0].setAnnotationValue(
static_cast<void *
>(Info));
4162 PP.EnterTokenStream(std::move(TokenArray), 1,
4167void PragmaMaxTokensHereHandler::HandlePragma(
Preprocessor &PP,
4171 if (
Tok.
is(tok::eod)) {
4173 <<
"clang max_tokens_here" <<
true <<
"integer";
4179 if (
Tok.
isNot(tok::numeric_constant) ||
4182 <<
"clang max_tokens_here";
4188 <<
"clang max_tokens_here";
4193 PP.
Diag(Loc, diag::warn_max_tokens)
4199void PragmaMaxTokensTotalHandler::HandlePragma(
Preprocessor &PP,
4203 if (
Tok.
is(tok::eod)) {
4205 <<
"clang max_tokens_total" <<
true <<
"integer";
4211 if (
Tok.
isNot(tok::numeric_constant) ||
4214 <<
"clang max_tokens_total";
4220 <<
"clang max_tokens_total";
4236 for (;
Tok.isNot(tok::eod); PP.
Lex(
Tok)) {
4237 TokenVector.push_back(
Tok);
4245 TokenVector.push_back(EoF);
4248 markAsReinjectedForRelexing(TokenVector);
4249 auto TokenArray = std::make_unique<Token[]>(TokenVector.size());
4250 std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
4252 std::pair<std::unique_ptr<Token[]>,
size_t>(std::move(TokenArray),
4253 TokenVector.size());
4259void PragmaExportHandler::HandlePragma(
Preprocessor &PP,
4261 Token &FirstToken) {
4270 Token &FirstToken) {
4275 if (!II || !II->
isStr(
"intrinsic")) {
4283 if (!II || !(II->
isStr(
"vector") || II->
isStr(
"sifive_vector") ||
4284 II->
isStr(
"andes_vector"))) {
4287 <<
"'vector', 'sifive_vector' or 'andes_vector'";
4294 <<
"clang riscv intrinsic";
4298 if (II->
isStr(
"vector"))
4299 Actions.RISCV().DeclareRVVBuiltins =
true;
4300 else if (II->
isStr(
"sifive_vector"))
4301 Actions.RISCV().DeclareSiFiveVectorBuiltins =
true;
4302 else if (II->
isStr(
"andes_vector"))
4303 Actions.RISCV().DeclareAndesVectorBuiltins =
true;
Defines the clang::ASTContext interface.
static StringRef getTriple(const Command &Job)
static void ParseAlignPragma(Preprocessor &PP, Token &FirstTok, bool IsOptions)
static void diagnoseUnknownAttributeSubjectSubRule(Parser &PRef, attr::SubjectMatchRule PrimaryRule, StringRef PrimaryRuleName, StringRef SubRuleName, SourceLocation SubRuleLoc)
static void zOSPragmaHandlerHelper(Preprocessor &PP, Token &Tok, tok::TokenKind TokKind)
static bool ParseLoopHintValue(Preprocessor &PP, Token &Tok, Token PragmaName, Token Option, bool ValueInParens, PragmaLoopHintInfo &Info)
Parses loop or unroll pragma hint value and fills in Info.
static void diagnoseExpectedAttributeSubjectSubRule(Parser &PRef, attr::SubjectMatchRule PrimaryRule, StringRef PrimaryRuleName, SourceLocation SubRuleLoc)
static bool isAbstractAttrMatcherRule(attr::SubjectMatchRule Rule)
static StringRef getIdentifier(const Token &Tok)
static std::string PragmaLoopHintString(Token PragmaName, Token Option)
Defines the clang::Preprocessor interface.
ArrayRef< SVal > ValueList
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
This file declares semantic analysis for CUDA constructs.
This file declares facilities that support code completion.
This file declares semantic analysis functions specific to RISC-V.
Kind getParsedKind() const
static CharSourceRange getCharRange(SourceRange R)
A little helper class used to produce diagnostics.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc)
This allows the client to specify that certain warnings are ignored.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
EmptyPragmaHandler - A pragma handler which takes no action, which can be used to ignore particular p...
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
ExprDependence getDependence() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
One of these records is kept for each identifier that is lexed.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
@ FEM_Extended
Use extended type for fp arithmetic.
@ FEM_Double
Use the type double for fp arithmetic.
@ FEM_Source
Use the declared type for fp arithmetic.
ComplexRangeKind
Controls the various implementations for complex multiplication and.
@ CX_Full
Implementation of complex division and multiplication using a call to runtime library functions(gener...
@ CX_Basic
Implementation of complex division and multiplication using algebraic formulas at source precision.
PragmaMSPointersToMembersKind
@ PPTMK_FullGeneralityMultipleInheritance
@ PPTMK_FullGeneralityVirtualInheritance
@ PPTMK_FullGeneralitySingleInheritance
@ FPE_Strict
Strictly preserve the floating-point exception semantics.
@ FPE_MayTrap
Transformations do not cause new exceptions but may hide some.
@ FPE_Ignore
Assume that floating-point exceptions are masked.
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str)
Callback invoked when a #pragma comment directive is read.
virtual void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State)
Called when an OpenCL extension is either disabled or enabled with a pragma.
virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
Callback invoked when a #pragma detect_mismatch directive is read.
ParsedAttr - Represents a syntactic attribute.
ParsedAttributes - A collection of parsed attributes.
ParsedAttr * addNew(IdentifierInfo *attrName, SourceRange attrRange, AttributeScopeInfo scope, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
ParseScope - Introduces a new scope for parsing.
Parser - This implements a parser for the C family of languages.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation getEndOfPreviousToken() const
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
ParseStringLiteralExpression - This handles the various token types that form string literals,...
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies)
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
const TargetInfo & getTargetInfo() 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 ...
const Token & getCurToken() const
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
friend class BalancedDelimiterTracker
PragmaHandler - Instances of this interface defined to handle the various pragmas that the language f...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
PPCallbacks * getPPCallbacks() const
SourceRange DiscardUntilEndOfDirective(SmallVectorImpl< Token > *DiscardedToks=nullptr)
Read and discard all tokens remaining on the current line until the tok::eod token is found.
void overrideMaxTokens(unsigned Value, SourceLocation Loc)
void Lex(Token &Result)
Lex the next token for this preprocessor.
bool LexOnOffSwitch(tok::OnOffSwitch &Result)
Lex an on-off-switch (C99 6.10.6p2) and verify that it is followed by EOD.
unsigned getTokenCount() const
Get the number of tokens processed so far.
const TargetInfo & getTargetInfo() const
bool parseSimpleIntegerLiteral(Token &Tok, uint64_t &Value)
Parses a simple integer literal to get its numeric value.
void LexUnexpandedToken(Token &Result)
Just like Lex, but disables macro expansion of identifier tokens.
llvm::BumpPtrAllocator & getPreprocessorAllocator()
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 ...
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
bool LexStringLiteral(Token &Result, std::string &String, const char *DiagnosticTag, bool AllowMacroExpansion)
Lex a string literal, which may be the concatenation of multiple string literals and may even come fr...
@ CompoundStmtScope
This is a compound statement scope.
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ DeclScope
This is a scope that can contain a declaration.
Sema - This implements semantic analysis and AST building for C.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
unsigned getLength() const
StringRef getString() const
unsigned getCharByteWidth() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual bool hasStrictFP() const
Determine whether constrained floating point is supported on this target.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
void setLiteralData(const char *Ptr)
bool isAnyIdentifier() const
Return true if this is a raw identifier (when lexing in raw mode) or a non-keyword identifier (when l...
void setAnnotationEndLoc(SourceLocation L)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
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)) {....
tok::TokenKind getKind() const
bool isOneOf(Ts... Ks) const
void setLocation(SourceLocation L)
bool isNot(tok::TokenKind K) const
void setAnnotationValue(void *val)
void startToken()
Reset all flags to cleared.
Defines the clang::TargetInfo interface.
SubjectMatchRule
A list of all the recognized kinds of attributes.
const char * getSubjectMatchRuleSpelling(SubjectMatchRule Rule)
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
uint32_t Literal
Literals are represented as positive integers.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
@ Ignored
Do not present this diagnostic, ignore it.
@ FixIt
Parse and apply any fixits to the source.
const Regex Rule("(.+)/(.+)\\.framework/")
bool Pop(InterpState &S, CodePtr OpPC)
const char * getKeywordSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple keyword and contextual keyword tokens like 'int' and 'dynamic_cast'...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
OnOffSwitch
Defines the possible values of an on-off-switch (C99 6.10.6p2).
The JSON file list parser is used to communicate input to InstallAPI.
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
U cast(CodeGen::Address addr)
@ None
The alignment was not explicit in code.
ActionResult< Expr * > ExprResult
@ Parens
New-expression has a C++98 paren-delimited initializer.
ActionResult< Stmt * > StmtResult
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
Loop optimization hint for loop and unroll pragmas.
IdentifierLoc * OptionLoc
IdentifierLoc * PragmaNameLoc
Describes how and where the pragma was introduced.
PragmaMsStackAction Action