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;
128 reinterpret_cast<void *
>(
static_cast<uintptr_t>(OOS)));
129 PP.EnterTokenStream(Toks,
true,
135struct PragmaSTDC_CX_LIMITED_RANGEHandler :
public PragmaHandler {
136 PragmaSTDC_CX_LIMITED_RANGEHandler() : PragmaHandler(
"CX_LIMITED_RANGE") {}
138 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
139 Token &
Tok)
override {
144 MutableArrayRef<Token> Toks(
149 reinterpret_cast<void *
>(
static_cast<uintptr_t>(OOS)));
150 PP.EnterTokenStream(Toks,
true,
157 PragmaSTDC_FENV_ROUNDHandler() : PragmaHandler(
"FENV_ROUND") {}
159 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
160 Token &
Tok)
override;
165 PragmaSTDC_UnknownHandler() =
default;
167 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
168 Token &UnknownTok)
override {
170 PP.
Diag(UnknownTok, diag::ext_stdc_pragma_ignored);
175 PragmaFPHandler() : PragmaHandler(
"fp") {}
176 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
177 Token &FirstToken)
override;
183template <diag::kind IgnoredDiag>
185 PragmaNoSupportHandler(StringRef Name) : PragmaHandler(Name) {}
186 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
187 Token &FirstToken)
override;
190struct PragmaNoOpenMPHandler
191 :
public PragmaNoSupportHandler<diag::warn_pragma_omp_ignored> {
192 PragmaNoOpenMPHandler() : PragmaNoSupportHandler(
"omp") {}
195struct PragmaNoOpenACCHandler
196 :
public PragmaNoSupportHandler<diag::warn_pragma_acc_ignored> {
197 PragmaNoOpenACCHandler() : PragmaNoSupportHandler(
"acc") {}
206 PragmaSupportHandler(StringRef Name) : PragmaHandler(Name) {}
207 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
208 Token &FirstToken)
override;
211struct PragmaOpenMPHandler
212 :
public PragmaSupportHandler<tok::annot_pragma_openmp,
213 tok::annot_pragma_openmp_end,
214 diag::err_omp_unexpected_directive> {
215 PragmaOpenMPHandler() : PragmaSupportHandler(
"omp") {}
218struct PragmaOpenACCHandler
219 :
public PragmaSupportHandler<tok::annot_pragma_openacc,
220 tok::annot_pragma_openacc_end,
221 diag::err_acc_unexpected_directive> {
222 PragmaOpenACCHandler() : PragmaSupportHandler(
"acc") {}
227 PragmaCommentHandler(Sema &Actions)
228 : PragmaHandler(
"comment"), Actions(Actions) {}
229 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
230 Token &FirstToken)
override;
234 bool SeenCopyrightInTU =
false;
238 PragmaDetectMismatchHandler(Sema &Actions)
239 : PragmaHandler(
"detect_mismatch"), Actions(Actions) {}
240 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
241 Token &FirstToken)
override;
248 PragmaFloatControlHandler(Sema &Actions)
249 : PragmaHandler(
"float_control") {}
250 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
251 Token &FirstToken)
override;
255 explicit PragmaMSPointersToMembers() : PragmaHandler(
"pointers_to_members") {}
256 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
257 Token &FirstToken)
override;
261 explicit PragmaMSVtorDisp() : PragmaHandler(
"vtordisp") {}
262 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
263 Token &FirstToken)
override;
267 explicit PragmaMSPragma(
const char *name) : PragmaHandler(
name) {}
268 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
269 Token &FirstToken)
override;
274 PragmaOptimizeHandler(Sema &S)
275 : PragmaHandler(
"optimize"), Actions(S) {}
276 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
277 Token &FirstToken)
override;
284 PragmaLoopHintHandler() : PragmaHandler(
"loop") {}
285 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
286 Token &FirstToken)
override;
290 PragmaUnrollHintHandler(
const char *name) : PragmaHandler(
name) {}
291 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
292 Token &FirstToken)
override;
296 PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler(
"runtime_checks") {}
301 PragmaMSFenvAccessHandler() : PragmaHandler(
"fenv_access") {}
302 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
303 Token &FirstToken)
override {
325 if (II->
isStr(
"on")) {
328 }
else if (II->
isStr(
"off")) {
348 MutableArrayRef<Token> Toks(
351 tok::annot_pragma_fenv_access_ms,
353 reinterpret_cast<void *
>(
static_cast<uintptr_t>(OOS)));
354 PP.EnterTokenStream(Toks,
true,
359struct PragmaForceCUDAHostDeviceHandler :
public PragmaHandler {
360 PragmaForceCUDAHostDeviceHandler(Sema &Actions)
361 : PragmaHandler(
"force_cuda_host_device"), Actions(Actions) {}
362 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
363 Token &FirstToken)
override;
371 PragmaAttributeHandler(AttributeFactory &AttrFactory)
372 : PragmaHandler(
"attribute"), AttributesForPragmaAttribute(AttrFactory) {}
373 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
374 Token &FirstToken)
override;
377 ParsedAttributes AttributesForPragmaAttribute;
381 PragmaMaxTokensHereHandler() : PragmaHandler(
"max_tokens_here") {}
382 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
383 Token &FirstToken)
override;
387 PragmaMaxTokensTotalHandler() : PragmaHandler(
"max_tokens_total") {}
388 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
389 Token &FirstToken)
override;
393 explicit PragmaExportHandler() : PragmaHandler(
"export") {}
394 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
395 Token &FirstToken)
override;
399 PragmaRISCVHandler(Sema &Actions)
400 : PragmaHandler(
"riscv"), Actions(Actions) {}
401 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
402 Token &FirstToken)
override;
414void Parser::initializePragmaHandlers() {
415 AlignHandler = std::make_unique<PragmaAlignHandler>();
416 PP.AddPragmaHandler(AlignHandler.get());
418 GCCVisibilityHandler = std::make_unique<PragmaGCCVisibilityHandler>();
419 PP.AddPragmaHandler(
"GCC", GCCVisibilityHandler.get());
421 OptionsHandler = std::make_unique<PragmaOptionsHandler>();
422 PP.AddPragmaHandler(OptionsHandler.get());
424 PackHandler = std::make_unique<PragmaPackHandler>();
425 PP.AddPragmaHandler(PackHandler.get());
427 MSStructHandler = std::make_unique<PragmaMSStructHandler>();
428 PP.AddPragmaHandler(MSStructHandler.get());
430 UnusedHandler = std::make_unique<PragmaUnusedHandler>();
431 PP.AddPragmaHandler(UnusedHandler.get());
433 WeakHandler = std::make_unique<PragmaWeakHandler>();
434 PP.AddPragmaHandler(WeakHandler.get());
436 RedefineExtnameHandler = std::make_unique<PragmaRedefineExtnameHandler>();
437 PP.AddPragmaHandler(RedefineExtnameHandler.get());
439 FPContractHandler = std::make_unique<PragmaFPContractHandler>();
440 PP.AddPragmaHandler(
"STDC", FPContractHandler.get());
442 STDCFenvAccessHandler = std::make_unique<PragmaSTDC_FENV_ACCESSHandler>();
443 PP.AddPragmaHandler(
"STDC", STDCFenvAccessHandler.get());
445 STDCFenvRoundHandler = std::make_unique<PragmaSTDC_FENV_ROUNDHandler>();
446 PP.AddPragmaHandler(
"STDC", STDCFenvRoundHandler.get());
448 STDCCXLIMITHandler = std::make_unique<PragmaSTDC_CX_LIMITED_RANGEHandler>();
449 PP.AddPragmaHandler(
"STDC", STDCCXLIMITHandler.get());
451 STDCUnknownHandler = std::make_unique<PragmaSTDC_UnknownHandler>();
452 PP.AddPragmaHandler(
"STDC", STDCUnknownHandler.get());
454 PCSectionHandler = std::make_unique<PragmaClangSectionHandler>(Actions);
455 PP.AddPragmaHandler(
"clang", PCSectionHandler.get());
458 OpenCLExtensionHandler = std::make_unique<PragmaOpenCLExtensionHandler>();
459 PP.AddPragmaHandler(
"OPENCL", OpenCLExtensionHandler.get());
461 PP.AddPragmaHandler(
"OPENCL", FPContractHandler.get());
464 OpenMPHandler = std::make_unique<PragmaOpenMPHandler>();
466 OpenMPHandler = std::make_unique<PragmaNoOpenMPHandler>();
467 PP.AddPragmaHandler(OpenMPHandler.get());
470 OpenACCHandler = std::make_unique<PragmaOpenACCHandler>();
472 OpenACCHandler = std::make_unique<PragmaNoOpenACCHandler>();
473 PP.AddPragmaHandler(OpenACCHandler.get());
478 MSCommentHandler = std::make_unique<PragmaCommentHandler>(Actions);
479 PP.AddPragmaHandler(MSCommentHandler.get());
482 FloatControlHandler = std::make_unique<PragmaFloatControlHandler>(Actions);
483 PP.AddPragmaHandler(FloatControlHandler.get());
485 MSDetectMismatchHandler =
486 std::make_unique<PragmaDetectMismatchHandler>(Actions);
487 PP.AddPragmaHandler(MSDetectMismatchHandler.get());
488 MSPointersToMembers = std::make_unique<PragmaMSPointersToMembers>();
489 PP.AddPragmaHandler(MSPointersToMembers.get());
490 MSVtorDisp = std::make_unique<PragmaMSVtorDisp>();
491 PP.AddPragmaHandler(MSVtorDisp.get());
492 MSInitSeg = std::make_unique<PragmaMSPragma>(
"init_seg");
493 PP.AddPragmaHandler(MSInitSeg.get());
494 MSDataSeg = std::make_unique<PragmaMSPragma>(
"data_seg");
495 PP.AddPragmaHandler(MSDataSeg.get());
496 MSBSSSeg = std::make_unique<PragmaMSPragma>(
"bss_seg");
497 PP.AddPragmaHandler(MSBSSSeg.get());
498 MSConstSeg = std::make_unique<PragmaMSPragma>(
"const_seg");
499 PP.AddPragmaHandler(MSConstSeg.get());
500 MSCodeSeg = std::make_unique<PragmaMSPragma>(
"code_seg");
501 PP.AddPragmaHandler(MSCodeSeg.get());
502 MSSection = std::make_unique<PragmaMSPragma>(
"section");
503 PP.AddPragmaHandler(MSSection.get());
504 MSStrictGuardStackCheck =
505 std::make_unique<PragmaMSPragma>(
"strict_gs_check");
506 PP.AddPragmaHandler(MSStrictGuardStackCheck.get());
507 MSFunction = std::make_unique<PragmaMSPragma>(
"function");
508 PP.AddPragmaHandler(MSFunction.get());
509 MSAllocText = std::make_unique<PragmaMSPragma>(
"alloc_text");
510 PP.AddPragmaHandler(MSAllocText.get());
511 MSOptimize = std::make_unique<PragmaMSPragma>(
"optimize");
512 PP.AddPragmaHandler(MSOptimize.get());
513 MSRuntimeChecks = std::make_unique<PragmaMSRuntimeChecksHandler>();
514 PP.AddPragmaHandler(MSRuntimeChecks.get());
515 MSIntrinsic = std::make_unique<PragmaMSPragma>(
"intrinsic");
516 PP.AddPragmaHandler(MSIntrinsic.get());
517 MSFenvAccess = std::make_unique<PragmaMSFenvAccessHandler>();
518 PP.AddPragmaHandler(MSFenvAccess.get());
522 CUDAForceHostDeviceHandler =
523 std::make_unique<PragmaForceCUDAHostDeviceHandler>(Actions);
524 PP.AddPragmaHandler(
"clang", CUDAForceHostDeviceHandler.get());
527 OptimizeHandler = std::make_unique<PragmaOptimizeHandler>(Actions);
528 PP.AddPragmaHandler(
"clang", OptimizeHandler.get());
530 LoopHintHandler = std::make_unique<PragmaLoopHintHandler>();
531 PP.AddPragmaHandler(
"clang", LoopHintHandler.get());
533 UnrollHintHandler = std::make_unique<PragmaUnrollHintHandler>(
"unroll");
534 PP.AddPragmaHandler(UnrollHintHandler.get());
535 PP.AddPragmaHandler(
"GCC", UnrollHintHandler.get());
537 NoUnrollHintHandler = std::make_unique<PragmaUnrollHintHandler>(
"nounroll");
538 PP.AddPragmaHandler(NoUnrollHintHandler.get());
539 PP.AddPragmaHandler(
"GCC", NoUnrollHintHandler.get());
541 UnrollAndJamHintHandler =
542 std::make_unique<PragmaUnrollHintHandler>(
"unroll_and_jam");
543 PP.AddPragmaHandler(UnrollAndJamHintHandler.get());
545 NoUnrollAndJamHintHandler =
546 std::make_unique<PragmaUnrollHintHandler>(
"nounroll_and_jam");
547 PP.AddPragmaHandler(NoUnrollAndJamHintHandler.get());
549 FPHandler = std::make_unique<PragmaFPHandler>();
550 PP.AddPragmaHandler(
"clang", FPHandler.get());
552 AttributePragmaHandler =
553 std::make_unique<PragmaAttributeHandler>(AttrFactory);
554 PP.AddPragmaHandler(
"clang", AttributePragmaHandler.get());
556 MaxTokensHerePragmaHandler = std::make_unique<PragmaMaxTokensHereHandler>();
557 PP.AddPragmaHandler(
"clang", MaxTokensHerePragmaHandler.get());
559 MaxTokensTotalPragmaHandler = std::make_unique<PragmaMaxTokensTotalHandler>();
560 PP.AddPragmaHandler(
"clang", MaxTokensTotalPragmaHandler.get());
563 ExportHandler = std::make_unique<PragmaExportHandler>();
564 PP.AddPragmaHandler(ExportHandler.get());
568 RISCVPragmaHandler = std::make_unique<PragmaRISCVHandler>(Actions);
569 PP.AddPragmaHandler(
"clang", RISCVPragmaHandler.get());
573void Parser::resetPragmaHandlers() {
575 PP.RemovePragmaHandler(AlignHandler.get());
576 AlignHandler.reset();
577 PP.RemovePragmaHandler(
"GCC", GCCVisibilityHandler.get());
578 GCCVisibilityHandler.reset();
579 PP.RemovePragmaHandler(OptionsHandler.get());
580 OptionsHandler.reset();
581 PP.RemovePragmaHandler(PackHandler.get());
583 PP.RemovePragmaHandler(MSStructHandler.get());
584 MSStructHandler.reset();
585 PP.RemovePragmaHandler(UnusedHandler.get());
586 UnusedHandler.reset();
587 PP.RemovePragmaHandler(WeakHandler.get());
589 PP.RemovePragmaHandler(RedefineExtnameHandler.get());
590 RedefineExtnameHandler.reset();
593 PP.RemovePragmaHandler(
"OPENCL", OpenCLExtensionHandler.get());
594 OpenCLExtensionHandler.reset();
595 PP.RemovePragmaHandler(
"OPENCL", FPContractHandler.get());
597 PP.RemovePragmaHandler(OpenMPHandler.get());
598 OpenMPHandler.reset();
600 PP.RemovePragmaHandler(OpenACCHandler.get());
601 OpenACCHandler.reset();
606 PP.RemovePragmaHandler(MSCommentHandler.get());
607 MSCommentHandler.reset();
610 PP.RemovePragmaHandler(
"clang", PCSectionHandler.get());
611 PCSectionHandler.reset();
613 PP.RemovePragmaHandler(FloatControlHandler.get());
614 FloatControlHandler.reset();
616 PP.RemovePragmaHandler(MSDetectMismatchHandler.get());
617 MSDetectMismatchHandler.reset();
618 PP.RemovePragmaHandler(MSPointersToMembers.get());
619 MSPointersToMembers.reset();
620 PP.RemovePragmaHandler(MSVtorDisp.get());
622 PP.RemovePragmaHandler(MSInitSeg.get());
624 PP.RemovePragmaHandler(MSDataSeg.get());
626 PP.RemovePragmaHandler(MSBSSSeg.get());
628 PP.RemovePragmaHandler(MSConstSeg.get());
630 PP.RemovePragmaHandler(MSCodeSeg.get());
632 PP.RemovePragmaHandler(MSSection.get());
634 PP.RemovePragmaHandler(MSStrictGuardStackCheck.get());
635 MSStrictGuardStackCheck.reset();
636 PP.RemovePragmaHandler(MSFunction.get());
638 PP.RemovePragmaHandler(MSAllocText.get());
640 PP.RemovePragmaHandler(MSRuntimeChecks.get());
641 MSRuntimeChecks.reset();
642 PP.RemovePragmaHandler(MSIntrinsic.get());
644 PP.RemovePragmaHandler(MSOptimize.get());
646 PP.RemovePragmaHandler(MSFenvAccess.get());
647 MSFenvAccess.reset();
651 PP.RemovePragmaHandler(
"clang", CUDAForceHostDeviceHandler.get());
652 CUDAForceHostDeviceHandler.reset();
655 PP.RemovePragmaHandler(
"STDC", FPContractHandler.get());
656 FPContractHandler.reset();
658 PP.RemovePragmaHandler(
"STDC", STDCFenvAccessHandler.get());
659 STDCFenvAccessHandler.reset();
661 PP.RemovePragmaHandler(
"STDC", STDCFenvRoundHandler.get());
662 STDCFenvRoundHandler.reset();
664 PP.RemovePragmaHandler(
"STDC", STDCCXLIMITHandler.get());
665 STDCCXLIMITHandler.reset();
667 PP.RemovePragmaHandler(
"STDC", STDCUnknownHandler.get());
668 STDCUnknownHandler.reset();
670 PP.RemovePragmaHandler(
"clang", OptimizeHandler.get());
671 OptimizeHandler.reset();
673 PP.RemovePragmaHandler(
"clang", LoopHintHandler.get());
674 LoopHintHandler.reset();
676 PP.RemovePragmaHandler(UnrollHintHandler.get());
677 PP.RemovePragmaHandler(
"GCC", UnrollHintHandler.get());
678 UnrollHintHandler.reset();
680 PP.RemovePragmaHandler(NoUnrollHintHandler.get());
681 PP.RemovePragmaHandler(
"GCC", NoUnrollHintHandler.get());
682 NoUnrollHintHandler.reset();
684 PP.RemovePragmaHandler(UnrollAndJamHintHandler.get());
685 UnrollAndJamHintHandler.reset();
687 PP.RemovePragmaHandler(NoUnrollAndJamHintHandler.get());
688 NoUnrollAndJamHintHandler.reset();
690 PP.RemovePragmaHandler(
"clang", FPHandler.get());
693 PP.RemovePragmaHandler(
"clang", AttributePragmaHandler.get());
694 AttributePragmaHandler.reset();
696 PP.RemovePragmaHandler(
"clang", MaxTokensHerePragmaHandler.get());
697 MaxTokensHerePragmaHandler.reset();
699 PP.RemovePragmaHandler(
"clang", MaxTokensTotalPragmaHandler.get());
700 MaxTokensTotalPragmaHandler.reset();
703 PP.RemovePragmaHandler(ExportHandler.get());
704 ExportHandler.reset();
708 PP.RemovePragmaHandler(
"clang", RISCVPragmaHandler.get());
709 RISCVPragmaHandler.reset();
713void Parser::HandlePragmaUnused() {
714 assert(Tok.is(tok::annot_pragma_unused));
715 SourceLocation UnusedLoc = ConsumeAnnotationToken();
716 Actions.ActOnPragmaUnused(Tok,
getCurScope(), UnusedLoc);
720void Parser::HandlePragmaVisibility() {
721 assert(Tok.is(tok::annot_pragma_vis));
722 const IdentifierInfo *VisType =
723 static_cast<IdentifierInfo *
>(Tok.getAnnotationValue());
724 SourceLocation VisLoc = ConsumeAnnotationToken();
725 Actions.ActOnPragmaVisibility(VisType, VisLoc);
728void Parser::HandlePragmaPack() {
729 assert(Tok.is(tok::annot_pragma_pack));
730 Sema::PragmaPackInfo *Info =
731 static_cast<Sema::PragmaPackInfo *
>(Tok.getAnnotationValue());
732 SourceLocation PragmaLoc = Tok.getLocation();
735 Alignment = Actions.ActOnNumericConstant(Info->
Alignment);
737 ConsumeAnnotationToken();
745 ConsumeAnnotationToken();
748void Parser::HandlePragmaMSStruct() {
749 assert(Tok.is(tok::annot_pragma_msstruct));
751 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
752 Actions.ActOnPragmaMSStruct(Kind);
753 ConsumeAnnotationToken();
756void Parser::HandlePragmaAlign() {
757 assert(Tok.is(tok::annot_pragma_align));
759 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
760 Actions.ActOnPragmaOptionsAlign(Kind, Tok.getLocation());
763 ConsumeAnnotationToken();
766void Parser::HandlePragmaDump() {
767 assert(Tok.is(tok::annot_pragma_dump));
768 ConsumeAnnotationToken();
769 if (Tok.is(tok::eod)) {
770 PP.Diag(Tok, diag::warn_pragma_debug_missing_argument) <<
"dump";
772 if (Tok.isNot(tok::identifier)) {
773 PP.Diag(Tok, diag::warn_pragma_debug_unexpected_argument);
775 ExpectAndConsume(tok::eod);
778 IdentifierInfo *II = Tok.getIdentifierInfo();
779 Actions.ActOnPragmaDump(
getCurScope(), Tok.getLocation(), II);
782 SourceLocation StartLoc = Tok.getLocation();
783 EnterExpressionEvaluationContext Ctx(
789 PP.Diag(StartLoc, diag::warn_pragma_debug_dependent_argument)
791 << SourceRange(StartLoc, Tok.getLocation());
793 Actions.ActOnPragmaDump(E.
get());
797 ExpectAndConsume(tok::eod);
800void Parser::HandlePragmaWeak() {
801 assert(Tok.is(tok::annot_pragma_weak));
802 SourceLocation PragmaLoc = ConsumeAnnotationToken();
803 Actions.ActOnPragmaWeakID(Tok.getIdentifierInfo(), PragmaLoc,
808void Parser::HandlePragmaWeakAlias() {
809 assert(Tok.is(tok::annot_pragma_weakalias));
810 SourceLocation PragmaLoc = ConsumeAnnotationToken();
811 IdentifierInfo *WeakName = Tok.getIdentifierInfo();
812 SourceLocation WeakNameLoc = Tok.getLocation();
814 IdentifierInfo *AliasName = Tok.getIdentifierInfo();
815 SourceLocation AliasNameLoc = Tok.getLocation();
817 Actions.ActOnPragmaWeakAlias(WeakName, AliasName, PragmaLoc,
818 WeakNameLoc, AliasNameLoc);
822void Parser::HandlePragmaRedefineExtname() {
823 assert(Tok.is(tok::annot_pragma_redefine_extname));
824 SourceLocation RedefLoc = ConsumeAnnotationToken();
825 IdentifierInfo *RedefName = Tok.getIdentifierInfo();
826 SourceLocation RedefNameLoc = Tok.getLocation();
828 IdentifierInfo *AliasName = Tok.getIdentifierInfo();
829 SourceLocation AliasNameLoc = Tok.getLocation();
831 Actions.ActOnPragmaRedefineExtname(RedefName, AliasName, RedefLoc,
832 RedefNameLoc, AliasNameLoc);
835void Parser::HandlePragmaFPContract() {
836 assert(Tok.is(tok::annot_pragma_fp_contract));
839 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
859 SourceLocation PragmaLoc = ConsumeAnnotationToken();
860 Actions.ActOnPragmaFPContract(PragmaLoc, FPC);
863void Parser::HandlePragmaFloatControl() {
864 assert(Tok.is(tok::annot_pragma_float_control));
875 SourceLocation PragmaLoc = ConsumeAnnotationToken();
876 Actions.ActOnPragmaFloatControl(PragmaLoc, Action, Kind);
879void Parser::HandlePragmaFEnvAccess() {
880 assert(Tok.is(tok::annot_pragma_fenv_access) ||
881 Tok.is(tok::annot_pragma_fenv_access_ms));
884 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
899 SourceLocation PragmaLoc = ConsumeAnnotationToken();
900 Actions.ActOnPragmaFEnvAccess(PragmaLoc, IsEnabled);
903void Parser::HandlePragmaFEnvRound() {
904 assert(Tok.is(tok::annot_pragma_fenv_round));
905 auto RM =
static_cast<llvm::RoundingMode
>(
906 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
908 SourceLocation PragmaLoc = ConsumeAnnotationToken();
909 Actions.ActOnPragmaFEnvRound(PragmaLoc, RM);
912void Parser::HandlePragmaCXLimitedRange() {
913 assert(Tok.is(tok::annot_pragma_cx_limited_range));
915 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
933 SourceLocation PragmaLoc = ConsumeAnnotationToken();
934 Actions.ActOnPragmaCXLimitedRange(PragmaLoc, Range);
939 assert(Tok.is(tok::annot_pragma_captured));
940 ConsumeAnnotationToken();
942 if (Tok.isNot(tok::l_brace)) {
943 PP.Diag(Tok, diag::err_expected) << tok::l_brace;
947 SourceLocation Loc = Tok.getLocation();
955 CapturedRegionScope.Exit();
958 Actions.ActOnCapturedRegionError();
962 return Actions.ActOnCapturedRegionEnd(
R.get());
966 enum OpenCLExtState :
char {
967 Disable, Enable, Begin, End
969 typedef std::pair<const IdentifierInfo *, OpenCLExtState> OpenCLExtData;
972void Parser::HandlePragmaOpenCLExtension() {
973 assert(Tok.is(tok::annot_pragma_opencl_extension));
974 OpenCLExtData *
Data =
static_cast<OpenCLExtData*
>(Tok.getAnnotationValue());
975 auto State =
Data->second;
976 auto Ident =
Data->first;
977 SourceLocation NameLoc = Tok.getLocation();
978 ConsumeAnnotationToken();
980 auto &Opt = Actions.getOpenCLOptions();
981 auto Name = Ident->getName();
986 if (State == Disable)
989 PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1;
990 }
else if (State == Begin) {
991 if (!Opt.isKnown(Name) || !Opt.isSupported(Name,
getLangOpts())) {
995 Opt.acceptsPragma(Name);
997 }
else if (State == End) {
1000 }
else if (!Opt.isKnown(Name) || !Opt.isWithPragma(Name))
1001 PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << Ident;
1002 else if (Opt.isSupportedExtension(Name,
getLangOpts()))
1003 Opt.enable(Name, State == Enable);
1004 else if (Opt.isSupportedCoreOrOptionalCore(Name,
getLangOpts()))
1005 PP.Diag(NameLoc, diag::warn_pragma_extension_is_core) << Ident;
1007 PP.Diag(NameLoc, diag::warn_pragma_unsupported_extension) << Ident;
1010void Parser::HandlePragmaMSPointersToMembers() {
1011 assert(Tok.is(tok::annot_pragma_ms_pointers_to_members));
1014 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
1015 SourceLocation PragmaLoc = ConsumeAnnotationToken();
1016 Actions.ActOnPragmaMSPointersToMembers(RepresentationMethod, PragmaLoc);
1019void Parser::HandlePragmaMSVtorDisp() {
1020 assert(Tok.is(tok::annot_pragma_ms_vtordisp));
1025 SourceLocation PragmaLoc = ConsumeAnnotationToken();
1026 Actions.ActOnPragmaMSVtorDisp(Action, PragmaLoc, Mode);
1029void Parser::HandlePragmaMSPragma() {
1030 assert(Tok.is(tok::annot_pragma_ms_pragma));
1033 (std::pair<std::unique_ptr<Token[]>,
size_t> *)Tok.getAnnotationValue();
1034 PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second,
true,
1036 SourceLocation PragmaLocation = ConsumeAnnotationToken();
1037 assert(Tok.isAnyIdentifier());
1038 StringRef PragmaName = Tok.getIdentifierInfo()->getName();
1043 typedef bool (
Parser::*PragmaHandler)(StringRef, SourceLocation);
1044 PragmaHandler Handler =
1045 llvm::StringSwitch<PragmaHandler>(PragmaName)
1046 .Case(
"data_seg", &Parser::HandlePragmaMSSegment)
1047 .Case(
"bss_seg", &Parser::HandlePragmaMSSegment)
1048 .Case(
"const_seg", &Parser::HandlePragmaMSSegment)
1049 .Case(
"code_seg", &Parser::HandlePragmaMSSegment)
1050 .Case(
"section", &Parser::HandlePragmaMSSection)
1051 .Case(
"init_seg", &Parser::HandlePragmaMSInitSeg)
1052 .Case(
"strict_gs_check", &Parser::HandlePragmaMSStrictGuardStackCheck)
1053 .Case(
"function", &Parser::HandlePragmaMSFunction)
1054 .Case(
"alloc_text", &Parser::HandlePragmaMSAllocText)
1055 .Case(
"optimize", &Parser::HandlePragmaMSOptimize)
1056 .Case(
"intrinsic", &Parser::HandlePragmaMSIntrinsic);
1058 if (!(this->*Handler)(PragmaName, PragmaLocation)) {
1061 while (Tok.isNot(tok::eof))
1067bool Parser::HandlePragmaMSSection(StringRef PragmaName,
1069 if (Tok.isNot(tok::l_paren)) {
1070 PP.Diag(PragmaLocation, diag::warn_pragma_expected_lparen) << PragmaName;
1075 if (Tok.isNot(tok::string_literal)) {
1076 PP.Diag(PragmaLocation, diag::warn_pragma_expected_section_name)
1085 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1090 bool SectionFlagsAreDefault =
true;
1091 while (Tok.is(tok::comma)) {
1096 if (Tok.is(tok::kw_long) || Tok.is(tok::kw_short)) {
1101 if (!Tok.isAnyIdentifier()) {
1102 PP.Diag(PragmaLocation, diag::warn_pragma_expected_action_or_r_paren)
1107 llvm::StringSwitch<ASTContext::PragmaSectionFlag>(
1108 Tok.getIdentifierInfo()->getName())
1120 ? diag::warn_pragma_invalid_specific_action
1121 : diag::warn_pragma_unsupported_action)
1122 << PragmaName << Tok.getIdentifierInfo()->getName();
1125 SectionFlags |= Flag;
1126 SectionFlagsAreDefault =
false;
1131 if (SectionFlagsAreDefault)
1133 if (Tok.isNot(tok::r_paren)) {
1134 PP.Diag(PragmaLocation, diag::warn_pragma_expected_rparen) << PragmaName;
1138 if (Tok.isNot(tok::eof)) {
1139 PP.Diag(PragmaLocation, diag::warn_pragma_extra_tokens_at_eol)
1144 Actions.ActOnPragmaMSSection(PragmaLocation, SectionFlags, SegmentName);
1148bool Parser::HandlePragmaMSSegment(StringRef PragmaName,
1150 if (Tok.isNot(tok::l_paren)) {
1151 PP.Diag(PragmaLocation, diag::warn_pragma_expected_lparen) << PragmaName;
1156 StringRef SlotLabel;
1157 if (Tok.isAnyIdentifier()) {
1158 StringRef PushPop = Tok.getIdentifierInfo()->getName();
1159 if (PushPop ==
"push")
1161 else if (PushPop ==
"pop")
1164 PP.Diag(PragmaLocation,
1165 diag::warn_pragma_expected_section_push_pop_or_name)
1171 if (Tok.is(tok::comma)) {
1174 if (Tok.isAnyIdentifier()) {
1175 SlotLabel = Tok.getIdentifierInfo()->getName();
1177 if (Tok.is(tok::comma))
1179 else if (Tok.isNot(tok::r_paren)) {
1180 PP.Diag(PragmaLocation, diag::warn_pragma_expected_punc)
1185 }
else if (Tok.isNot(tok::r_paren)) {
1186 PP.Diag(PragmaLocation, diag::warn_pragma_expected_punc) << PragmaName;
1192 StringLiteral *SegmentName =
nullptr;
1193 if (Tok.isNot(tok::r_paren)) {
1194 if (Tok.isNot(tok::string_literal)) {
1196 diag::warn_pragma_expected_section_name :
1197 diag::warn_pragma_expected_section_label_or_name :
1198 diag::warn_pragma_expected_section_push_pop_or_name;
1199 PP.Diag(PragmaLocation, DiagID) << PragmaName;
1207 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1215 if (Tok.isNot(tok::r_paren)) {
1216 PP.Diag(PragmaLocation, diag::warn_pragma_expected_rparen) << PragmaName;
1220 if (Tok.isNot(tok::eof)) {
1221 PP.Diag(PragmaLocation, diag::warn_pragma_extra_tokens_at_eol)
1226 Actions.ActOnPragmaMSSeg(PragmaLocation, Action, SlotLabel,
1227 SegmentName, PragmaName);
1231bool Parser::HandlePragmaMSInitSeg(StringRef PragmaName,
1234 PP.Diag(PragmaLocation, diag::warn_pragma_init_seg_unsupported_target);
1238 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
1243 StringLiteral *SegmentName =
nullptr;
1244 IdentifierLoc *FuncId =
nullptr;
1245 if (Tok.isAnyIdentifier()) {
1246 auto *II = Tok.getIdentifierInfo();
1247 StringRef Section = llvm::StringSwitch<StringRef>(II->
getName())
1248 .Case(
"compiler",
"\".CRT$XCC\"")
1249 .Case(
"lib",
"\".CRT$XCL\"")
1250 .Case(
"user",
"\".CRT$XCU\"")
1253 if (!Section.empty()) {
1257 Token::create(tok::string_literal, Tok.getLocation(), Section.size());
1263 }
else if (Tok.is(tok::string_literal)) {
1269 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1276 if (Tok.is(tok::comma)) {
1278 if (Tok.isNot(tok::identifier)) {
1279 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
1283 FuncId =
new (Actions.Context)
1284 IdentifierLoc(Tok.getLocation(), Tok.getIdentifierInfo());
1289 PP.Diag(PragmaLocation, diag::warn_pragma_expected_init_seg) << PragmaName;
1293 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
1295 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
1299 Actions.ActOnPragmaMSInitSeg(PragmaLocation, SegmentName, FuncId);
1303bool Parser::HandlePragmaMSStrictGuardStackCheck(
1305 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
1310 if (Tok.is(tok::identifier)) {
1311 StringRef PushPop = Tok.getIdentifierInfo()->getName();
1312 if (PushPop ==
"push") {
1315 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_punc,
1318 }
else if (PushPop ==
"pop") {
1326 const IdentifierInfo *II = Tok.getIdentifierInfo();
1327 if (II && II->
isStr(
"off")) {
1330 }
else if (II && II->
isStr(
"on")) {
1334 PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_action)
1341 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
1345 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
1349 Actions.ActOnPragmaMSStrictGuardStackCheck(PragmaLocation, Action,
Value);
1353bool Parser::HandlePragmaMSAllocText(StringRef PragmaName,
1355 Token FirstTok = Tok;
1356 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
1361 if (Tok.is(tok::string_literal)) {
1367 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1372 }
else if (Tok.is(tok::identifier)) {
1373 Section = Tok.getIdentifierInfo()->getName();
1376 PP.Diag(PragmaLocation, diag::warn_pragma_expected_section_name)
1381 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_comma,
1385 SmallVector<std::tuple<IdentifierInfo *, SourceLocation>> Functions;
1387 if (Tok.isNot(tok::identifier)) {
1388 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
1393 IdentifierInfo *II = Tok.getIdentifierInfo();
1394 Functions.emplace_back(II, Tok.getLocation());
1397 if (Tok.isNot(tok::comma))
1402 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
1404 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
1408 Actions.ActOnPragmaMSAllocText(FirstTok.
getLocation(), Section, Functions);
1413 assert(Tok.is(PragmaKind));
1415 StringRef PragmaName =
"export";
1417 using namespace clang::charinfo;
1418 auto *TheTokens =
static_cast<std::pair<std::unique_ptr<Token[]>,
size_t> *>(
1419 Tok.getAnnotationValue());
1420 PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second,
true,
1422 Tok.setAnnotationValue(
nullptr);
1423 ConsumeAnnotationToken();
1425 llvm::scope_exit OnReturn([
this]() {
1426 while (Tok.isNot(tok::eof))
1433 if (Tok.isNot(tok::l_paren)) {
1434 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen)
1440 if (Tok.isNot(tok::identifier)) {
1441 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
1446 IdentifierInfo *IdentName = Tok.getIdentifierInfo();
1447 SourceLocation IdentNameLoc = Tok.getLocation();
1450 if (Tok.isNot(tok::r_paren)) {
1451 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_rparen)
1457 Actions.ActOnPragmaExport(IdentName, IdentNameLoc,
getCurScope());
1460 if (Tok.is(tok::identifier) || Tok.is(tok::kw_export)) {
1461 PragmaName = Tok.getIdentifierInfo()->getName();
1462 if (PragmaName !=
"export")
1463 PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1465 }
else if (Tok.isNot(tok::eof)) {
1466 PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1470 }
while (Tok.isNot(tok::eof));
1474void Parser::HandlePragmaExport() {
1475 assert(Tok.is(tok::annot_pragma_export));
1477 zOSHandlePragmaHelper(tok::annot_pragma_export);
1482 std::string ClangLoopStr(
"clang loop ");
1485 return std::string(llvm::StringSwitch<StringRef>(Str)
1486 .Case(
"loop", ClangLoopStr)
1487 .Case(
"unroll_and_jam", Str)
1488 .Case(
"unroll", Str)
1492bool Parser::HandlePragmaLoopHint(
LoopHint &Hint) {
1493 assert(Tok.is(tok::annot_pragma_loop_hint));
1494 PragmaLoopHintInfo *Info =
1495 static_cast<PragmaLoopHintInfo *
>(Tok.getAnnotationValue());
1503 IdentifierInfo *OptionInfo = Info->
Option.
is(tok::identifier)
1509 llvm::ArrayRef<Token> Toks = Info->
Toks;
1514 llvm::StringSwitch<bool>(PragmaNameInfo->
getName())
1515 .Cases({
"unroll",
"nounroll",
"unroll_and_jam",
"nounroll_and_jam"},
1519 if (Toks.empty() && IsLoopHint) {
1520 ConsumeAnnotationToken();
1527 assert(!Toks.empty() &&
1528 "PragmaLoopHintInfo::Toks must contain at least one token.");
1531 bool OptionUnroll =
false;
1532 bool OptionUnrollAndJam =
false;
1533 bool OptionDistribute =
false;
1534 bool OptionPipelineDisabled =
false;
1535 bool OptionLICMDisabled =
false;
1536 bool StateOption =
false;
1538 OptionUnroll = OptionInfo->
isStr(
"unroll");
1539 OptionUnrollAndJam = OptionInfo->
isStr(
"unroll_and_jam");
1540 OptionDistribute = OptionInfo->
isStr(
"distribute");
1541 OptionPipelineDisabled = OptionInfo->
isStr(
"pipeline");
1542 OptionLICMDisabled = OptionInfo->
isStr(
"licm");
1543 StateOption = llvm::StringSwitch<bool>(OptionInfo->
getName())
1544 .Case(
"vectorize",
true)
1545 .Case(
"interleave",
true)
1546 .Case(
"vectorize_predicate",
true)
1548 OptionUnroll || OptionUnrollAndJam || OptionDistribute ||
1549 OptionPipelineDisabled || OptionLICMDisabled;
1552 bool AssumeSafetyArg = !OptionUnroll && !OptionUnrollAndJam &&
1553 !OptionDistribute && !OptionPipelineDisabled &&
1554 !OptionLICMDisabled;
1556 if (Toks[0].
is(tok::eof)) {
1557 ConsumeAnnotationToken();
1558 Diag(Toks[0].getLocation(), diag::err_pragma_loop_missing_argument)
1560 << (OptionUnroll || OptionUnrollAndJam)
1567 ConsumeAnnotationToken();
1568 SourceLocation StateLoc = Toks[0].getLocation();
1569 IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
1573 llvm::StringSwitch<bool>(StateInfo->
getName())
1574 .Case(
"disable",
true)
1575 .Case(
"enable", !OptionPipelineDisabled && !OptionLICMDisabled)
1576 .Case(
"full", OptionUnroll || OptionUnrollAndJam)
1577 .Case(
"assume_safety", AssumeSafetyArg)
1580 if (OptionPipelineDisabled || OptionLICMDisabled) {
1581 Diag(Toks[0].getLocation(), diag::err_pragma_pipeline_invalid_keyword);
1583 Diag(Toks[0].getLocation(), diag::err_pragma_invalid_keyword)
1584 << (OptionUnroll || OptionUnrollAndJam)
1589 if (Toks.size() > 2)
1590 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1592 Hint.
StateLoc =
new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1593 }
else if (OptionInfo && OptionInfo->
getName() ==
"vectorize_width") {
1594 PP.EnterTokenStream(Toks,
false,
1596 ConsumeAnnotationToken();
1598 SourceLocation StateLoc = Toks[0].getLocation();
1599 IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
1600 StringRef IsScalableStr = StateInfo ? StateInfo->
getName() :
"";
1603 if (IsScalableStr ==
"scalable" || IsScalableStr ==
"fixed") {
1606 if (Toks.size() > 2) {
1607 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1609 while (Tok.isNot(tok::eof))
1613 Hint.
StateLoc =
new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1620 if (
R.isInvalid() && !Tok.is(tok::comma))
1621 Diag(Toks[0].getLocation(),
1622 diag::note_pragma_loop_invalid_vectorize_option);
1624 bool Arg2Error =
false;
1625 if (Tok.is(tok::comma)) {
1628 StateInfo = Tok.getIdentifierInfo();
1629 IsScalableStr = StateInfo ? StateInfo->
getName() :
"";
1631 if (IsScalableStr !=
"scalable" && IsScalableStr !=
"fixed") {
1632 Diag(Tok.getLocation(),
1633 diag::err_pragma_loop_invalid_vectorize_option);
1637 new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1644 if (Tok.isNot(tok::eof)) {
1645 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1647 while (Tok.isNot(tok::eof))
1653 if (Arg2Error ||
R.isInvalid() ||
1654 Actions.CheckLoopHintExpr(
R.get(), Toks[0].getLocation(),
1663 PP.EnterTokenStream(Toks,
false,
1665 ConsumeAnnotationToken();
1670 if (Tok.isNot(tok::eof)) {
1671 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1673 while (Tok.isNot(tok::eof))
1679 if (
R.isInvalid() ||
1680 Actions.CheckLoopHintExpr(
R.get(), Toks[0].getLocation(),
1689 Info->
Toks.back().getLocation());
1694struct PragmaAttributeInfo {
1695 enum ActionType { Push,
Pop, Attribute };
1696 ParsedAttributes &Attributes;
1698 const IdentifierInfo *
Namespace =
nullptr;
1699 ArrayRef<Token> Tokens;
1701 PragmaAttributeInfo(ParsedAttributes &Attributes) : Attributes(Attributes) {}
1704#include "clang/Parse/AttrSubMatchRulesParserStringSwitches.inc"
1709 if (
Tok.is(tok::identifier))
1710 return Tok.getIdentifierInfo()->getName();
1718 using namespace attr;
1720#define ATTR_MATCH_RULE(Value, Spelling, IsAbstract) \
1723#include "clang/Basic/AttrSubMatchRulesList.inc"
1725 llvm_unreachable(
"Invalid attribute subject match rule");
1733 PRef.
Diag(SubRuleLoc,
1734 diag::err_pragma_attribute_expected_subject_sub_identifier)
1736 if (
const char *SubRules = validAttributeSubjectMatchSubRules(PrimaryRule))
1747 PRef.
Diag(SubRuleLoc, diag::err_pragma_attribute_unknown_subject_sub_rule)
1748 << SubRuleName << PrimaryRuleName;
1749 if (
const char *SubRules = validAttributeSubjectMatchSubRules(PrimaryRule))
1755bool Parser::ParsePragmaAttributeSubjectMatchRuleSet(
1763 if (AnyParens.expectAndConsume())
1771 Diag(Tok, diag::err_pragma_attribute_expected_subject_identifier);
1774 std::pair<std::optional<attr::SubjectMatchRule>,
1775 std::optional<attr::SubjectMatchRule> (*)(StringRef,
bool)>
1776 Rule = isAttributeSubjectMatchRule(Name);
1778 Diag(Tok, diag::err_pragma_attribute_unknown_subject_rule) << Name;
1786 if (
Parens.expectAndConsume())
1788 }
else if (
Parens.consumeOpen()) {
1789 if (!SubjectMatchRules
1791 std::make_pair(PrimaryRule, SourceRange(RuleLoc, RuleLoc)))
1793 Diag(RuleLoc, diag::err_pragma_attribute_duplicate_subject)
1796 RuleLoc, Tok.is(tok::comma) ? Tok.getLocation() : RuleLoc));
1797 LastMatchRuleEndLoc = RuleLoc;
1803 if (SubRuleName.empty()) {
1809 if (SubRuleName ==
"unless") {
1812 if (
Parens.expectAndConsume())
1815 if (SubRuleName.empty()) {
1820 auto SubRuleOrNone =
Rule.second(SubRuleName,
true);
1821 if (!SubRuleOrNone) {
1822 std::string SubRuleUnlessName =
"unless(" + SubRuleName.str() +
")";
1824 SubRuleUnlessName, SubRuleLoc);
1827 SubRule = *SubRuleOrNone;
1829 if (
Parens.consumeClose())
1832 auto SubRuleOrNone =
Rule.second(SubRuleName,
false);
1833 if (!SubRuleOrNone) {
1835 SubRuleName, Tok.getLocation());
1838 SubRule = *SubRuleOrNone;
1841 SourceLocation RuleEndLoc = Tok.getLocation();
1842 LastMatchRuleEndLoc = RuleEndLoc;
1843 if (
Parens.consumeClose())
1845 if (!SubjectMatchRules
1846 .insert(std::make_pair(SubRule, SourceRange(RuleLoc, RuleEndLoc)))
1848 Diag(RuleLoc, diag::err_pragma_attribute_duplicate_subject)
1851 RuleLoc, Tok.is(tok::comma) ? Tok.getLocation() : RuleEndLoc));
1857 if (AnyParens.consumeClose())
1866enum class MissingAttributeSubjectRulesRecoveryPoint {
1874MissingAttributeSubjectRulesRecoveryPoint
1875getAttributeSubjectRulesRecoveryPointForToken(
const Token &
Tok) {
1877 if (II->
isStr(
"apply_to"))
1878 return MissingAttributeSubjectRulesRecoveryPoint::ApplyTo;
1879 if (II->
isStr(
"any"))
1880 return MissingAttributeSubjectRulesRecoveryPoint::Any;
1882 if (
Tok.
is(tok::equal))
1883 return MissingAttributeSubjectRulesRecoveryPoint::Equals;
1884 return MissingAttributeSubjectRulesRecoveryPoint::None;
1892 MissingAttributeSubjectRulesRecoveryPoint Point,
Parser &PRef) {
1898 MissingAttributeSubjectRulesRecoveryPoint EndPoint =
1899 getAttributeSubjectRulesRecoveryPointForToken(PRef.
getCurToken());
1900 if (Point == MissingAttributeSubjectRulesRecoveryPoint::Comma)
1902 if (Point <= MissingAttributeSubjectRulesRecoveryPoint::ApplyTo &&
1903 EndPoint > MissingAttributeSubjectRulesRecoveryPoint::ApplyTo)
1904 FixIt +=
"apply_to";
1905 if (Point <= MissingAttributeSubjectRulesRecoveryPoint::Equals &&
1906 EndPoint > MissingAttributeSubjectRulesRecoveryPoint::Equals)
1909 if (EndPoint == MissingAttributeSubjectRulesRecoveryPoint::None) {
1916 Attribute.getMatchRules(PRef.
getLangOpts(), MatchRules);
1918 for (
const auto &Rule : MatchRules) {
1923 IsSupported[
Rule.first] =
true;
1925 IsMatchRuleAvailable &= IsSupported;
1927 if (IsMatchRuleAvailable.count() == 0) {
1933 bool NeedsComma =
false;
1935 if (!IsMatchRuleAvailable[I])
1949 if (FixItRange.getBegin() == FixItRange.getEnd())
1959void Parser::HandlePragmaAttribute() {
1960 assert(Tok.is(tok::annot_pragma_attribute) &&
1961 "Expected #pragma attribute annotation token");
1962 SourceLocation PragmaLoc = Tok.getLocation();
1963 auto *Info =
static_cast<PragmaAttributeInfo *
>(Tok.getAnnotationValue());
1964 if (Info->Action == PragmaAttributeInfo::Pop) {
1965 ConsumeAnnotationToken();
1966 Actions.ActOnPragmaAttributePop(PragmaLoc, Info->Namespace);
1970 assert((Info->Action == PragmaAttributeInfo::Push ||
1971 Info->Action == PragmaAttributeInfo::Attribute) &&
1972 "Unexpected #pragma attribute command");
1974 if (Info->Action == PragmaAttributeInfo::Push && Info->Tokens.empty()) {
1975 ConsumeAnnotationToken();
1976 Actions.ActOnPragmaAttributeEmptyPush(PragmaLoc, Info->Namespace);
1980 PP.EnterTokenStream(Info->Tokens,
false,
1982 ConsumeAnnotationToken();
1984 ParsedAttributes &Attrs = Info->Attributes;
1987 auto SkipToEnd = [
this]() {
1992 if ((Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) ||
1993 Tok.isRegularKeywordAttribute()) {
1995 SourceLocation EndLoc = Tok.getLocation();
1996 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
1997 }
else if (Tok.is(tok::kw___attribute)) {
1999 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
2002 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"("))
2007 if (Tok.is(tok::code_completion)) {
2010 Actions.CodeCompletion().CodeCompleteAttribute(
2017 if (Tok.isNot(tok::identifier)) {
2018 Diag(Tok, diag::err_pragma_attribute_expected_attribute_name);
2022 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
2025 if (Tok.isNot(tok::l_paren))
2026 Attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0,
2027 ParsedAttr::Form::GNU());
2029 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs,
nullptr,
2032 ParsedAttr::Form::GNU(),
2036 if (ExpectAndConsume(tok::r_paren))
2038 if (ExpectAndConsume(tok::r_paren))
2040 }
else if (Tok.is(tok::kw___declspec)) {
2041 ParseMicrosoftDeclSpecs(Attrs);
2043 Diag(Tok, diag::err_pragma_attribute_expected_attribute_syntax);
2044 if (Tok.getIdentifierInfo()) {
2048 Tok.getIdentifierInfo(),
nullptr,
2050 SourceLocation InsertStartLoc = Tok.getLocation();
2052 if (Tok.is(tok::l_paren)) {
2055 if (Tok.isNot(tok::r_paren))
2058 Diag(Tok, diag::note_pragma_attribute_use_attribute_kw)
2067 if (Attrs.
empty() || Attrs.
begin()->isInvalid()) {
2072 for (
const ParsedAttr &Attribute : Attrs) {
2073 if (!Attribute.isSupportedByPragmaAttribute()) {
2074 Diag(PragmaLoc, diag::err_pragma_attribute_unsupported_attribute)
2083 createExpectedAttributeSubjectRulesTokenDiagnostic(
2084 diag::err_expected, Attrs,
2085 MissingAttributeSubjectRulesRecoveryPoint::Comma, *
this)
2091 if (Tok.isNot(tok::identifier)) {
2092 createExpectedAttributeSubjectRulesTokenDiagnostic(
2093 diag::err_pragma_attribute_invalid_subject_set_specifier, Attrs,
2094 MissingAttributeSubjectRulesRecoveryPoint::ApplyTo, *
this);
2098 const IdentifierInfo *II = Tok.getIdentifierInfo();
2099 if (!II->
isStr(
"apply_to")) {
2100 createExpectedAttributeSubjectRulesTokenDiagnostic(
2101 diag::err_pragma_attribute_invalid_subject_set_specifier, Attrs,
2102 MissingAttributeSubjectRulesRecoveryPoint::ApplyTo, *
this);
2109 createExpectedAttributeSubjectRulesTokenDiagnostic(
2110 diag::err_expected, Attrs,
2111 MissingAttributeSubjectRulesRecoveryPoint::Equals, *
this)
2118 SourceLocation AnyLoc, LastMatchRuleEndLoc;
2119 if (ParsePragmaAttributeSubjectMatchRuleSet(SubjectMatchRules, AnyLoc,
2120 LastMatchRuleEndLoc)) {
2127 if (Tok.isNot(tok::eof)) {
2128 Diag(Tok, diag::err_pragma_attribute_extra_tokens_after_attribute);
2137 if (Info->Action == PragmaAttributeInfo::Push)
2138 Actions.ActOnPragmaAttributeEmptyPush(PragmaLoc, Info->Namespace);
2140 for (ParsedAttr &Attribute : Attrs) {
2141 Actions.ActOnPragmaAttributeAttribute(Attribute, PragmaLoc,
2149void PragmaGCCVisibilityHandler::HandlePragma(
Preprocessor &PP,
2160 if (PushPop && PushPop->
isStr(
"pop")) {
2162 }
else if (PushPop && PushPop->
isStr(
"push")) {
2195 auto Toks = std::make_unique<Token[]>(1);
2197 tok::annot_pragma_vis,
SourceRange(VisLoc, EndLoc),
2198 const_cast<void *
>(
static_cast<const void *
>(VisType)));
2199 PP.EnterTokenStream(std::move(Toks), 1,
true,
2221 StringRef SlotLabel;
2225 if (
Tok.
is(tok::numeric_constant)) {
2236 }
else if (
Tok.
is(tok::identifier)) {
2238 auto MapPack = [&](
const char *
Literal) {
2241 Alignment.
setKind(tok::numeric_constant);
2247 if (II->
isStr(
"show")) {
2267 if (II->
isStr(
"push")) {
2269 }
else if (II->
isStr(
"pop")) {
2277 if (
Tok.
is(tok::comma)) {
2280 if (
Tok.
is(tok::numeric_constant)) {
2285 }
else if (
Tok.
is(tok::identifier)) {
2289 if (
Tok.
is(tok::comma)) {
2292 if (
Tok.
isNot(tok::numeric_constant)) {
2339 static_cast<void *
>(Info));
2340 PP.EnterTokenStream(Toks,
true,
2346void PragmaMSStructHandler::HandlePragma(
Preprocessor &PP,
2348 Token &MSStructTok) {
2359 if (II->
isStr(
"on")) {
2363 else if (II->
isStr(
"off") || II->
isStr(
"reset"))
2379 tok::annot_pragma_msstruct,
2381 reinterpret_cast<void *
>(
static_cast<uintptr_t>(Kind)));
2382 PP.EnterTokenStream(Toks,
true,
2387void PragmaClangSectionHandler::HandlePragma(
Preprocessor &PP,
2389 Token &FirstToken) {
2397 PP.
Diag(
Tok.
getLocation(), diag::err_pragma_expected_clang_section_name) <<
"clang section";
2402 if (SecType->
isStr(
"bss"))
2404 else if (SecType->
isStr(
"data"))
2406 else if (SecType->
isStr(
"rodata"))
2408 else if (SecType->
isStr(
"relro"))
2410 else if (SecType->
isStr(
"text"))
2413 PP.
Diag(
Tok.
getLocation(), diag::err_pragma_expected_clang_section_name) <<
"clang section";
2425 std::string SecName;
2429 Actions.ActOnPragmaClangSection(PragmaLocation,
2446 if (
Tok.isNot(tok::identifier) ||
2447 !
Tok.getIdentifierInfo()->isStr(
"align")) {
2448 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_options_expected_align);
2455 if (
Tok.isNot(tok::l_paren)) {
2456 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_lparen) <<
"align";
2459 }
else if (
Tok.isNot(tok::equal)) {
2460 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_align_expected_equal)
2466 if (
Tok.isNot(tok::identifier)) {
2467 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_identifier)
2468 << (IsOptions ?
"options" :
"align");
2474 if (II->
isStr(
"native"))
2476 else if (II->
isStr(
"natural"))
2478 else if (II->
isStr(
"packed"))
2480 else if (II->
isStr(
"power"))
2482 else if (II->
isStr(
"mac68k"))
2484 else if (II->
isStr(
"reset"))
2487 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_align_invalid_option)
2494 if (
Tok.isNot(tok::r_paren)) {
2495 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_rparen) <<
"align";
2502 if (
Tok.isNot(tok::eod)) {
2503 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
2504 << (IsOptions ?
"options" :
"align");
2512 reinterpret_cast<void *
>(
static_cast<uintptr_t>(Kind)));
2513 PP.EnterTokenStream(Toks,
true,
2523void PragmaOptionsHandler::HandlePragma(
Preprocessor &PP,
2525 Token &OptionsTok) {
2530void PragmaUnusedHandler::HandlePragma(
Preprocessor &PP,
2553 if (
Tok.
is(tok::identifier)) {
2554 Identifiers.push_back(
Tok);
2565 if (
Tok.
is(tok::comma)) {
2570 if (
Tok.
is(tok::r_paren)) {
2588 assert(RParenLoc.
isValid() &&
"Valid '#pragma unused' must have ')'");
2589 assert(!Identifiers.empty() &&
"Valid '#pragma unused' must have arguments");
2598 2 * Identifiers.size());
2599 for (
unsigned i=0; i != Identifiers.size(); i++) {
2600 Token &pragmaUnusedTok = Toks[2*i], &idTok = Toks[2*i+1];
2603 idTok = Identifiers[i];
2605 PP.EnterTokenStream(Toks,
true,
2624 bool HasAlias =
false;
2628 if (
Tok.
is(tok::equal)) {
2648 Token &pragmaUnusedTok = Toks[0];
2653 Toks[2] = AliasName;
2654 PP.EnterTokenStream(Toks,
true,
2659 Token &pragmaUnusedTok = Toks[0];
2662 PP.EnterTokenStream(Toks,
true,
2668void PragmaRedefineExtnameHandler::HandlePragma(
Preprocessor &PP,
2670 Token &RedefToken) {
2686 <<
"redefine_extname";
2701 Token &pragmaRedefTok = Toks[0];
2705 Toks[1] = RedefName;
2706 Toks[2] = AliasName;
2707 PP.EnterTokenStream(Toks,
true,
2711void PragmaFPContractHandler::HandlePragma(
Preprocessor &PP,
2722 reinterpret_cast<void *
>(
static_cast<uintptr_t>(OOS)));
2723 PP.EnterTokenStream(Toks,
true,
2727void PragmaOpenCLExtensionHandler::HandlePragma(
Preprocessor &PP,
2752 OpenCLExtState State;
2753 if (Pred->
isStr(
"enable")) {
2755 }
else if (Pred->
isStr(
"disable")) {
2757 }
else if (Pred->
isStr(
"begin"))
2759 else if (Pred->
isStr(
"end"))
2763 << Ext->
isStr(
"all");
2777 Info->second = State;
2782 static_cast<void *
>(Info));
2783 PP.EnterTokenStream(Toks,
true,
2793template <diag::kind IgnoredDiag>
2794void PragmaNoSupportHandler<IgnoredDiag>::HandlePragma(
2797 PP.
Diag(FirstTok, IgnoredDiag);
2808void PragmaSupportHandler<StartTok, EndTok, UnexpectedDiag>::HandlePragma(
2814 Pragma.push_back(
Tok);
2816 if (
Tok.
is(StartTok)) {
2817 PP.
Diag(
Tok, UnexpectedDiag) << 0;
2818 unsigned InnerPragmaCnt = 1;
2819 while (InnerPragmaCnt != 0) {
2821 if (
Tok.
is(StartTok))
2823 else if (
Tok.
is(EndTok))
2831 Pragma.push_back(
Tok);
2833 auto Toks = std::make_unique<Token[]>(Pragma.size());
2834 std::copy(Pragma.begin(), Pragma.end(), Toks.get());
2835 PP.EnterTokenStream(std::move(Toks), Pragma.size(),
2847void PragmaMSPointersToMembers::HandlePragma(
Preprocessor &PP,
2853 PP.
Diag(PointersToMembersLoc, diag::warn_pragma_expected_lparen)
2854 <<
"pointers_to_members";
2861 <<
"pointers_to_members";
2867 if (Arg->
isStr(
"best_case")) {
2870 if (Arg->
isStr(
"full_generality")) {
2871 if (
Tok.
is(tok::comma)) {
2877 diag::err_pragma_pointers_to_members_unknown_kind)
2882 }
else if (
Tok.
is(tok::r_paren)) {
2889 <<
"full_generality";
2895 if (Arg->
isStr(
"single_inheritance")) {
2896 RepresentationMethod =
2898 }
else if (Arg->
isStr(
"multiple_inheritance")) {
2899 RepresentationMethod =
2901 }
else if (Arg->
isStr(
"virtual_inheritance")) {
2902 RepresentationMethod =
2906 diag::err_pragma_pointers_to_members_unknown_kind)
2915 << (Arg ? Arg->
getName() :
"full_generality");
2923 <<
"pointers_to_members";
2928 tok::annot_pragma_ms_pointers_to_members,
2930 reinterpret_cast<void *
>(
static_cast<uintptr_t>(RepresentationMethod)));
2947 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_lparen) <<
"vtordisp";
2955 if (II->
isStr(
"push")) {
2959 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_punc) <<
"vtordisp";
2965 }
else if (II->
isStr(
"pop")) {
2972 if (
Tok.
is(tok::r_paren)) {
2982 if (II && II->
isStr(
"off")) {
2985 }
else if (II && II->
isStr(
"on")) {
2988 }
else if (
Tok.
is(tok::numeric_constant) &&
2992 << 0 << 2 <<
"vtordisp";
3004 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_rparen) <<
"vtordisp";
3017 tok::annot_pragma_ms_vtordisp,
SourceRange(VtorDispLoc, EndLoc),
3018 reinterpret_cast<void *
>(
3033 TokenVector.push_back(
Tok);
3037 TokenVector.push_back(EoF);
3040 markAsReinjectedForRelexing(TokenVector);
3041 auto TokenArray = std::make_unique<Token[]>(TokenVector.size());
3042 std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
3044 std::pair<std::unique_ptr<Token[]>,
size_t>(std::move(TokenArray),
3045 TokenVector.size());
3061void PragmaFloatControlHandler::HandlePragma(
Preprocessor &PP,
3074 PP.
Diag(FloatControlLoc, diag::err_expected) << tok::l_paren;
3088 llvm::StringSwitch<PragmaFloatControlKind>(II->
getName())
3106 if (
Tok.
is(tok::r_paren))
3119 if (PushOnOff ==
"on")
3122 else if (PushOnOff ==
"off") {
3127 }
else if (PushOnOff ==
"push") {
3134 if (
Tok.
is(tok::comma)) {
3141 if (ExpectedPush ==
"push") {
3166 auto TokenArray = std::make_unique<Token[]>(1);
3170 tok::annot_pragma_float_control,
SourceRange(FloatControlLoc, EndLoc),
3171 reinterpret_cast<void *
>(
3172 static_cast<uintptr_t>((Action << 16) | (Kind & 0xFFFF))));
3173 PP.EnterTokenStream(std::move(TokenArray), 1,
3187void PragmaDetectMismatchHandler::HandlePragma(
Preprocessor &PP,
3193 PP.
Diag(DetectMismatchLoc, diag::err_expected) << tok::l_paren;
3198 std::string NameString;
3200 "pragma detect_mismatch",
3205 std::string ValueString;
3231 Actions.ActOnPragmaDetectMismatch(DetectMismatchLoc, NameString, ValueString);
3245void PragmaCommentHandler::HandlePragma(
Preprocessor &PP,
3251 PP.
Diag(CommentLoc, diag::err_pragma_comment_malformed);
3258 PP.
Diag(CommentLoc, diag::err_pragma_comment_malformed);
3265 llvm::StringSwitch<PragmaMSCommentKind>(II->
getName())
3294 if (SeenCopyrightInTU) {
3300 SeenCopyrightInTU =
true;
3305 std::string ArgumentString;
3337 Actions.ActOnPragmaMSComment(CommentLoc, Kind, ArgumentString);
3342void PragmaOptimizeHandler::HandlePragma(
Preprocessor &PP,
3344 Token &FirstToken) {
3347 if (
Tok.
is(tok::eod)) {
3349 <<
"clang optimize" <<
true <<
"'on' or 'off'";
3360 if (II->
isStr(
"on")) {
3362 }
else if (!II->
isStr(
"off")) {
3375 Actions.ActOnPragmaOptimize(IsOn, FirstToken.
getLocation());
3380struct TokFPAnnotValue {
3381 enum FlagValues {
On,
Off, Fast };
3383 std::optional<LangOptions::FPModeKind> ContractValue;
3384 std::optional<LangOptions::FPModeKind> ReassociateValue;
3385 std::optional<LangOptions::FPModeKind> ReciprocalValue;
3386 std::optional<LangOptions::FPExceptionModeKind> ExceptionsValue;
3387 std::optional<LangOptions::FPEvalMethodKind> EvalMethodValue;
3405 while (
Tok.
is(tok::identifier)) {
3409 llvm::StringSwitch<std::optional<PragmaFPKind>>(OptionInfo->
getName())
3415 .Default(std::nullopt);
3418 <<
false << OptionInfo;
3429 bool isEvalMethodDouble =
3433 if (
Tok.
isNot(tok::identifier) && !isEvalMethodDouble) {
3436 <<
static_cast<int>(*FlagKind);
3442 AnnotValue->ContractValue =
3443 llvm::StringSwitch<std::optional<LangOptions::FPModeKind>>(
3448 .Default(std::nullopt);
3449 if (!AnnotValue->ContractValue) {
3456 : AnnotValue->ReciprocalValue;
3457 Value = llvm::StringSwitch<std::optional<LangOptions::FPModeKind>>(
3461 .Default(std::nullopt);
3468 AnnotValue->ExceptionsValue =
3469 llvm::StringSwitch<std::optional<LangOptions::FPExceptionModeKind>>(
3474 .Default(std::nullopt);
3475 if (!AnnotValue->ExceptionsValue) {
3481 AnnotValue->EvalMethodValue =
3482 llvm::StringSwitch<std::optional<LangOptions::FPEvalMethodKind>>(
3487 .Default(std::nullopt);
3488 if (!AnnotValue->EvalMethodValue) {
3512 reinterpret_cast<void *
>(AnnotValue));
3513 TokenList.push_back(FPTok);
3515 auto TokenArray = std::make_unique<Token[]>(TokenList.size());
3516 std::copy(TokenList.begin(), TokenList.end(), TokenArray.get());
3518 PP.EnterTokenStream(std::move(TokenArray), TokenList.size(),
3522void PragmaSTDC_FENV_ROUNDHandler::HandlePragma(
Preprocessor &PP,
3541 llvm::StringSwitch<llvm::RoundingMode>(II->
getName())
3542 .Case(
"FE_TOWARDZERO", llvm::RoundingMode::TowardZero)
3543 .Case(
"FE_TONEAREST", llvm::RoundingMode::NearestTiesToEven)
3544 .Case(
"FE_UPWARD", llvm::RoundingMode::TowardPositive)
3545 .Case(
"FE_DOWNWARD", llvm::RoundingMode::TowardNegative)
3546 .Case(
"FE_TONEARESTFROMZERO", llvm::RoundingMode::NearestTiesToAway)
3547 .Case(
"FE_DYNAMIC", llvm::RoundingMode::Dynamic)
3548 .Default(llvm::RoundingMode::Invalid);
3549 if (RM == llvm::RoundingMode::Invalid) {
3557 <<
"STDC FENV_ROUND";
3568 reinterpret_cast<void *
>(
static_cast<uintptr_t>(RM)));
3569 PP.EnterTokenStream(Toks,
true,
3573void Parser::HandlePragmaFP() {
3574 assert(Tok.is(tok::annot_pragma_fp));
3576 reinterpret_cast<TokFPAnnotValue *
>(Tok.getAnnotationValue());
3578 if (AnnotValue->ReassociateValue)
3579 Actions.ActOnPragmaFPValueChangingOption(
3583 if (AnnotValue->ReciprocalValue)
3584 Actions.ActOnPragmaFPValueChangingOption(
3588 if (AnnotValue->ContractValue)
3589 Actions.ActOnPragmaFPContract(Tok.getLocation(),
3590 *AnnotValue->ContractValue);
3591 if (AnnotValue->ExceptionsValue)
3592 Actions.ActOnPragmaFPExceptions(Tok.getLocation(),
3593 *AnnotValue->ExceptionsValue);
3594 if (AnnotValue->EvalMethodValue)
3595 Actions.ActOnPragmaFPEvalMethod(Tok.getLocation(),
3596 *AnnotValue->EvalMethodValue);
3597 ConsumeAnnotationToken();
3602 Token Option,
bool ValueInParens,
3605 int OpenParens = ValueInParens ? 1 : 0;
3607 while (
Tok.isNot(tok::eod)) {
3608 if (
Tok.is(tok::l_paren))
3610 else if (
Tok.is(tok::r_paren)) {
3612 if (OpenParens == 0 && ValueInParens)
3620 if (ValueInParens) {
3622 if (
Tok.isNot(tok::r_paren)) {
3623 PP.
Diag(
Tok.getLocation(), diag::err_expected) << tok::r_paren;
3688void PragmaLoopHintHandler::HandlePragma(
Preprocessor &PP,
3703 while (
Tok.
is(tok::identifier)) {
3707 bool OptionValid = llvm::StringSwitch<bool>(OptionInfo->
getName())
3708 .Case(
"vectorize",
true)
3709 .Case(
"interleave",
true)
3710 .Case(
"unroll",
true)
3711 .Case(
"distribute",
true)
3712 .Case(
"vectorize_predicate",
true)
3713 .Case(
"vectorize_width",
true)
3714 .Case(
"interleave_count",
true)
3715 .Case(
"unroll_count",
true)
3716 .Case(
"pipeline",
true)
3717 .Case(
"pipeline_initiation_interval",
true)
3722 <<
false << OptionInfo;
3741 tok::annot_pragma_loop_hint,
3743 static_cast<void *
>(Info));
3744 TokenList.push_back(LoopHintTok);
3753 auto TokenArray = std::make_unique<Token[]>(TokenList.size());
3754 std::copy(TokenList.begin(), TokenList.end(), TokenArray.get());
3756 PP.EnterTokenStream(std::move(TokenArray), TokenList.size(),
3781void PragmaUnrollHintHandler::HandlePragma(
Preprocessor &PP,
3789 if (
Tok.
is(tok::eod)) {
3791 Info->PragmaName = PragmaName;
3792 Info->Option.startToken();
3802 bool ValueInParens =
Tok.
is(tok::l_paren);
3814 PP.
Diag(Info->Toks[0].getLocation(),
3815 diag::warn_pragma_unroll_cuda_value_in_parens);
3825 auto TokenArray = std::make_unique<Token[]>(1);
3827 tok::annot_pragma_loop_hint,
3829 static_cast<void *
>(Info));
3830 PP.EnterTokenStream(std::move(TokenArray), 1,
3834bool Parser::HandlePragmaMSFunction(StringRef PragmaName,
3836 Token FirstTok = Tok;
3838 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3842 bool SuggestIntrinH = !PP.isMacroDefined(
"__INTRIN_H");
3844 llvm::SmallVector<StringRef> NoBuiltins;
3845 while (Tok.is(tok::identifier)) {
3846 IdentifierInfo *II = Tok.getIdentifierInfo();
3848 PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
3849 << II << SuggestIntrinH;
3851 NoBuiltins.emplace_back(II->
getName());
3854 if (Tok.isNot(tok::comma))
3859 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3861 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3865 Actions.ActOnPragmaMSFunction(FirstTok.
getLocation(), NoBuiltins);
3869bool Parser::HandlePragmaMSOptimize(StringRef PragmaName,
3871 Token FirstTok = Tok;
3872 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3876 if (Tok.isNot(tok::string_literal)) {
3877 PP.Diag(PragmaLocation, diag::warn_pragma_expected_string) << PragmaName;
3885 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
3890 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_comma,
3894 if (Tok.is(tok::eof) || Tok.is(tok::r_paren)) {
3895 PP.Diag(PragmaLocation, diag::warn_pragma_missing_argument)
3896 << PragmaName <<
true <<
"'on' or 'off'";
3899 IdentifierInfo *II = Tok.getIdentifierInfo();
3900 if (!II || (!II->
isStr(
"on") && !II->
isStr(
"off"))) {
3901 PP.Diag(PragmaLocation, diag::warn_pragma_invalid_argument)
3902 << PP.getSpelling(Tok) << PragmaName <<
true
3906 bool IsOn = II->
isStr(
"on");
3909 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3914 if (!OptimizationList->
getString().empty()) {
3915 PP.Diag(PragmaLocation, diag::warn_pragma_invalid_argument)
3916 << OptimizationList->
getString() << PragmaName <<
true
3921 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3925 Actions.ActOnPragmaMSOptimize(FirstTok.
getLocation(), IsOn);
3942bool Parser::HandlePragmaMSIntrinsic(StringRef PragmaName,
3944 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3948 bool SuggestIntrinH = !PP.isMacroDefined(
"__INTRIN_H");
3950 while (Tok.is(tok::identifier)) {
3951 IdentifierInfo *II = Tok.getIdentifierInfo();
3953 PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
3954 << II << SuggestIntrinH;
3956 DeclarationNameInfo NameInfo(II, Tok.getLocation());
3959 Actions.LookupName(
Previous, Actions.getCurScope(),
3962 Actions.LazilyCreateBuiltin(II, II->
getBuiltinID(), Actions.getCurScope(),
3963 true, Tok.getLocation());
3965 if (Tok.isNot(tok::comma))
3969 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3973 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3979void PragmaForceCUDAHostDeviceHandler::HandlePragma(
3985 if (!Info || (!Info->
isStr(
"begin") && !Info->
isStr(
"end"))) {
3987 diag::warn_pragma_force_cuda_host_device_bad_arg);
3991 if (Info->
isStr(
"begin"))
3992 Actions.CUDA().PushForceHostDevice();
3993 else if (!Actions.CUDA().PopForceHostDevice())
3995 diag::err_pragma_cannot_end_force_cuda_host_device);
3998 if (!
Tok.
is(tok::eod))
4000 diag::warn_pragma_force_cuda_host_device_bad_arg);
4030void PragmaAttributeHandler::HandlePragma(
Preprocessor &PP,
4032 Token &FirstToken) {
4036 PragmaAttributeInfo(AttributesForPragmaAttribute);
4039 if (
Tok.
is(tok::identifier)) {
4041 if (!II->
isStr(
"push") && !II->
isStr(
"pop")) {
4042 Info->Namespace = II;
4045 if (!
Tok.
is(tok::period)) {
4054 if (!
Tok.
isOneOf(tok::identifier, tok::l_paren)) {
4056 diag::err_pragma_attribute_expected_push_pop_paren);
4061 if (
Tok.
is(tok::l_paren)) {
4062 if (Info->Namespace) {
4064 diag::err_pragma_attribute_namespace_on_attribute);
4066 diag::note_pragma_attribute_namespace_on_attribute);
4069 Info->Action = PragmaAttributeInfo::Attribute;
4072 if (II->
isStr(
"push"))
4073 Info->Action = PragmaAttributeInfo::Push;
4074 else if (II->
isStr(
"pop"))
4075 Info->Action = PragmaAttributeInfo::Pop;
4086 if ((Info->Action == PragmaAttributeInfo::Push &&
Tok.
isNot(tok::eod)) ||
4087 Info->Action == PragmaAttributeInfo::Attribute) {
4098 if (
Tok.
is(tok::l_paren))
4100 else if (
Tok.
is(tok::r_paren)) {
4102 if (OpenParens == 0)
4106 AttributeTokens.push_back(
Tok);
4110 if (AttributeTokens.empty()) {
4123 AttributeTokens.push_back(EOFTok);
4125 markAsReinjectedForRelexing(AttributeTokens);
4132 <<
"clang attribute";
4135 auto TokenArray = std::make_unique<Token[]>(1);
4138 static_cast<void *
>(Info));
4139 PP.EnterTokenStream(std::move(TokenArray), 1,
4144void PragmaMaxTokensHereHandler::HandlePragma(
Preprocessor &PP,
4148 if (
Tok.
is(tok::eod)) {
4150 <<
"clang max_tokens_here" <<
true <<
"integer";
4156 if (
Tok.
isNot(tok::numeric_constant) ||
4159 <<
"clang max_tokens_here";
4165 <<
"clang max_tokens_here";
4170 PP.
Diag(Loc, diag::warn_max_tokens)
4176void PragmaMaxTokensTotalHandler::HandlePragma(
Preprocessor &PP,
4180 if (
Tok.
is(tok::eod)) {
4182 <<
"clang max_tokens_total" <<
true <<
"integer";
4188 if (
Tok.
isNot(tok::numeric_constant) ||
4191 <<
"clang max_tokens_total";
4197 <<
"clang max_tokens_total";
4209 for (;
Tok.isNot(tok::eod); PP.
Lex(
Tok)) {
4210 TokenVector.push_back(
Tok);
4215 TokenVector.push_back(EoF);
4218 markAsReinjectedForRelexing(TokenVector);
4219 auto TokenArray = std::make_unique<Token[]>(TokenVector.size());
4220 std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
4222 std::pair<std::unique_ptr<Token[]>,
size_t>(std::move(TokenArray),
4223 TokenVector.size());
4229void PragmaExportHandler::HandlePragma(
Preprocessor &PP,
4231 Token &FirstToken) {
4240 Token &FirstToken) {
4245 if (!II || !II->
isStr(
"intrinsic")) {
4253 if (!II || !(II->
isStr(
"vector") || II->
isStr(
"sifive_vector") ||
4254 II->
isStr(
"andes_vector"))) {
4257 <<
"'vector', 'sifive_vector' or 'andes_vector'";
4264 <<
"clang riscv intrinsic";
4268 if (II->
isStr(
"vector"))
4269 Actions.RISCV().DeclareRVVBuiltins =
true;
4270 else if (II->
isStr(
"sifive_vector"))
4271 Actions.RISCV().DeclareSiFiveVectorBuiltins =
true;
4272 else if (II->
isStr(
"andes_vector"))
4273 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)
static Token create(tok::TokenKind Kind, SourceLocation Loc, unsigned Length=0)
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)
static Token createEof(SourceLocation Loc=SourceLocation(), const void *Data=nullptr)
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
static Token createAnnotation(tok::TokenKind Kind, SourceRange Range, void *Value=nullptr)
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/")
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).
Top level wrappers for InstallAPI frontend operations.
@ Default
Set to the current date and time.
const FunctionProtoType * T
MSVtorDispMode
In the Microsoft ABI, this controls the placement of virtual displacement members used to implement v...
@ On
Always emit colors regardless of the output stream.
@ Off
Never emit colors regardless of the output stream.
U cast(CodeGen::Address addr)
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