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,
1238 if (
getTargetInfo().getTriple().getEnvironment() != llvm::Triple::MSVC) {
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 StateOption =
false;
1531 OptionUnroll = OptionInfo->
isStr(
"unroll");
1532 OptionUnrollAndJam = OptionInfo->
isStr(
"unroll_and_jam");
1533 OptionDistribute = OptionInfo->
isStr(
"distribute");
1534 OptionPipelineDisabled = OptionInfo->
isStr(
"pipeline");
1535 StateOption = llvm::StringSwitch<bool>(OptionInfo->
getName())
1536 .Case(
"vectorize",
true)
1537 .Case(
"interleave",
true)
1538 .Case(
"vectorize_predicate",
true)
1540 OptionUnroll || OptionUnrollAndJam || OptionDistribute ||
1541 OptionPipelineDisabled;
1544 bool AssumeSafetyArg = !OptionUnroll && !OptionUnrollAndJam &&
1545 !OptionDistribute && !OptionPipelineDisabled;
1547 if (Toks[0].
is(tok::eof)) {
1548 ConsumeAnnotationToken();
1549 Diag(Toks[0].getLocation(), diag::err_pragma_loop_missing_argument)
1551 << (OptionUnroll || OptionUnrollAndJam)
1558 ConsumeAnnotationToken();
1559 SourceLocation StateLoc = Toks[0].getLocation();
1560 IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
1562 bool Valid = StateInfo &&
1563 llvm::StringSwitch<bool>(StateInfo->
getName())
1564 .Case(
"disable",
true)
1565 .Case(
"enable", !OptionPipelineDisabled)
1566 .Case(
"full", OptionUnroll || OptionUnrollAndJam)
1567 .Case(
"assume_safety", AssumeSafetyArg)
1570 if (OptionPipelineDisabled) {
1571 Diag(Toks[0].getLocation(), diag::err_pragma_pipeline_invalid_keyword);
1573 Diag(Toks[0].getLocation(), diag::err_pragma_invalid_keyword)
1574 << (OptionUnroll || OptionUnrollAndJam)
1579 if (Toks.size() > 2)
1580 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1582 Hint.
StateLoc =
new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1583 }
else if (OptionInfo && OptionInfo->
getName() ==
"vectorize_width") {
1584 PP.EnterTokenStream(Toks,
false,
1586 ConsumeAnnotationToken();
1588 SourceLocation StateLoc = Toks[0].getLocation();
1589 IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
1590 StringRef IsScalableStr = StateInfo ? StateInfo->
getName() :
"";
1593 if (IsScalableStr ==
"scalable" || IsScalableStr ==
"fixed") {
1596 if (Toks.size() > 2) {
1597 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1599 while (Tok.isNot(tok::eof))
1603 Hint.
StateLoc =
new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1610 if (R.
isInvalid() && !Tok.is(tok::comma))
1611 Diag(Toks[0].getLocation(),
1612 diag::note_pragma_loop_invalid_vectorize_option);
1614 bool Arg2Error =
false;
1615 if (Tok.is(tok::comma)) {
1618 StateInfo = Tok.getIdentifierInfo();
1619 IsScalableStr = StateInfo ? StateInfo->
getName() :
"";
1621 if (IsScalableStr !=
"scalable" && IsScalableStr !=
"fixed") {
1622 Diag(Tok.getLocation(),
1623 diag::err_pragma_loop_invalid_vectorize_option);
1627 new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1634 if (Tok.isNot(tok::eof)) {
1635 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1637 while (Tok.isNot(tok::eof))
1644 Actions.CheckLoopHintExpr(R.
get(), Toks[0].getLocation(),
1653 PP.EnterTokenStream(Toks,
false,
1655 ConsumeAnnotationToken();
1660 if (Tok.isNot(tok::eof)) {
1661 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1663 while (Tok.isNot(tok::eof))
1670 Actions.CheckLoopHintExpr(R.
get(), Toks[0].getLocation(),
1679 Info->
Toks.back().getLocation());
1684struct PragmaAttributeInfo {
1685 enum ActionType { Push,
Pop, Attribute };
1686 ParsedAttributes &Attributes;
1688 const IdentifierInfo *
Namespace =
nullptr;
1689 ArrayRef<Token> Tokens;
1691 PragmaAttributeInfo(ParsedAttributes &Attributes) : Attributes(Attributes) {}
1694#include "clang/Parse/AttrSubMatchRulesParserStringSwitches.inc"
1699 if (
Tok.is(tok::identifier))
1700 return Tok.getIdentifierInfo()->getName();
1708 using namespace attr;
1710#define ATTR_MATCH_RULE(Value, Spelling, IsAbstract) \
1713#include "clang/Basic/AttrSubMatchRulesList.inc"
1715 llvm_unreachable(
"Invalid attribute subject match rule");
1723 PRef.
Diag(SubRuleLoc,
1724 diag::err_pragma_attribute_expected_subject_sub_identifier)
1726 if (
const char *SubRules = validAttributeSubjectMatchSubRules(PrimaryRule))
1737 PRef.
Diag(SubRuleLoc, diag::err_pragma_attribute_unknown_subject_sub_rule)
1738 << SubRuleName << PrimaryRuleName;
1739 if (
const char *SubRules = validAttributeSubjectMatchSubRules(PrimaryRule))
1745bool Parser::ParsePragmaAttributeSubjectMatchRuleSet(
1753 if (AnyParens.expectAndConsume())
1761 Diag(Tok, diag::err_pragma_attribute_expected_subject_identifier);
1764 std::pair<std::optional<attr::SubjectMatchRule>,
1765 std::optional<attr::SubjectMatchRule> (*)(StringRef,
bool)>
1766 Rule = isAttributeSubjectMatchRule(Name);
1768 Diag(Tok, diag::err_pragma_attribute_unknown_subject_rule) << Name;
1776 if (
Parens.expectAndConsume())
1778 }
else if (
Parens.consumeOpen()) {
1779 if (!SubjectMatchRules
1781 std::make_pair(PrimaryRule, SourceRange(RuleLoc, RuleLoc)))
1783 Diag(RuleLoc, diag::err_pragma_attribute_duplicate_subject)
1786 RuleLoc, Tok.is(tok::comma) ? Tok.getLocation() : RuleLoc));
1787 LastMatchRuleEndLoc = RuleLoc;
1793 if (SubRuleName.empty()) {
1799 if (SubRuleName ==
"unless") {
1802 if (
Parens.expectAndConsume())
1805 if (SubRuleName.empty()) {
1810 auto SubRuleOrNone =
Rule.second(SubRuleName,
true);
1811 if (!SubRuleOrNone) {
1812 std::string SubRuleUnlessName =
"unless(" + SubRuleName.str() +
")";
1814 SubRuleUnlessName, SubRuleLoc);
1817 SubRule = *SubRuleOrNone;
1819 if (
Parens.consumeClose())
1822 auto SubRuleOrNone =
Rule.second(SubRuleName,
false);
1823 if (!SubRuleOrNone) {
1825 SubRuleName, Tok.getLocation());
1828 SubRule = *SubRuleOrNone;
1831 SourceLocation RuleEndLoc = Tok.getLocation();
1832 LastMatchRuleEndLoc = RuleEndLoc;
1833 if (
Parens.consumeClose())
1835 if (!SubjectMatchRules
1836 .insert(std::make_pair(SubRule, SourceRange(RuleLoc, RuleEndLoc)))
1838 Diag(RuleLoc, diag::err_pragma_attribute_duplicate_subject)
1841 RuleLoc, Tok.is(tok::comma) ? Tok.getLocation() : RuleEndLoc));
1847 if (AnyParens.consumeClose())
1856enum class MissingAttributeSubjectRulesRecoveryPoint {
1864MissingAttributeSubjectRulesRecoveryPoint
1865getAttributeSubjectRulesRecoveryPointForToken(
const Token &
Tok) {
1867 if (II->
isStr(
"apply_to"))
1868 return MissingAttributeSubjectRulesRecoveryPoint::ApplyTo;
1869 if (II->
isStr(
"any"))
1870 return MissingAttributeSubjectRulesRecoveryPoint::Any;
1872 if (
Tok.
is(tok::equal))
1873 return MissingAttributeSubjectRulesRecoveryPoint::Equals;
1874 return MissingAttributeSubjectRulesRecoveryPoint::None;
1882 MissingAttributeSubjectRulesRecoveryPoint Point,
Parser &PRef) {
1888 MissingAttributeSubjectRulesRecoveryPoint EndPoint =
1889 getAttributeSubjectRulesRecoveryPointForToken(PRef.
getCurToken());
1890 if (Point == MissingAttributeSubjectRulesRecoveryPoint::Comma)
1892 if (Point <= MissingAttributeSubjectRulesRecoveryPoint::ApplyTo &&
1893 EndPoint > MissingAttributeSubjectRulesRecoveryPoint::ApplyTo)
1894 FixIt +=
"apply_to";
1895 if (Point <= MissingAttributeSubjectRulesRecoveryPoint::Equals &&
1896 EndPoint > MissingAttributeSubjectRulesRecoveryPoint::Equals)
1899 if (EndPoint == MissingAttributeSubjectRulesRecoveryPoint::None) {
1906 Attribute.getMatchRules(PRef.
getLangOpts(), MatchRules);
1908 for (
const auto &Rule : MatchRules) {
1913 IsSupported[
Rule.first] =
true;
1915 IsMatchRuleAvailable &= IsSupported;
1917 if (IsMatchRuleAvailable.count() == 0) {
1923 bool NeedsComma =
false;
1925 if (!IsMatchRuleAvailable[I])
1939 if (FixItRange.getBegin() == FixItRange.getEnd())
1949void Parser::HandlePragmaAttribute() {
1950 assert(Tok.is(tok::annot_pragma_attribute) &&
1951 "Expected #pragma attribute annotation token");
1952 SourceLocation PragmaLoc = Tok.getLocation();
1953 auto *Info =
static_cast<PragmaAttributeInfo *
>(Tok.getAnnotationValue());
1954 if (Info->Action == PragmaAttributeInfo::Pop) {
1955 ConsumeAnnotationToken();
1956 Actions.ActOnPragmaAttributePop(PragmaLoc, Info->Namespace);
1960 assert((Info->Action == PragmaAttributeInfo::Push ||
1961 Info->Action == PragmaAttributeInfo::Attribute) &&
1962 "Unexpected #pragma attribute command");
1964 if (Info->Action == PragmaAttributeInfo::Push && Info->Tokens.empty()) {
1965 ConsumeAnnotationToken();
1966 Actions.ActOnPragmaAttributeEmptyPush(PragmaLoc, Info->Namespace);
1970 PP.EnterTokenStream(Info->Tokens,
false,
1972 ConsumeAnnotationToken();
1974 ParsedAttributes &Attrs = Info->Attributes;
1977 auto SkipToEnd = [
this]() {
1982 if ((Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) ||
1983 Tok.isRegularKeywordAttribute()) {
1985 ParseCXX11AttributeSpecifier(Attrs);
1986 }
else if (Tok.is(tok::kw___attribute)) {
1988 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
1991 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"("))
1996 if (Tok.is(tok::code_completion)) {
1999 Actions.CodeCompletion().CodeCompleteAttribute(
2006 if (Tok.isNot(tok::identifier)) {
2007 Diag(Tok, diag::err_pragma_attribute_expected_attribute_name);
2011 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
2014 if (Tok.isNot(tok::l_paren))
2015 Attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0,
2016 ParsedAttr::Form::GNU());
2018 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs,
nullptr,
2021 ParsedAttr::Form::GNU(),
2025 if (ExpectAndConsume(tok::r_paren))
2027 if (ExpectAndConsume(tok::r_paren))
2029 }
else if (Tok.is(tok::kw___declspec)) {
2030 ParseMicrosoftDeclSpecs(Attrs);
2032 Diag(Tok, diag::err_pragma_attribute_expected_attribute_syntax);
2033 if (Tok.getIdentifierInfo()) {
2037 Tok.getIdentifierInfo(),
nullptr,
2039 SourceLocation InsertStartLoc = Tok.getLocation();
2041 if (Tok.is(tok::l_paren)) {
2044 if (Tok.isNot(tok::r_paren))
2047 Diag(Tok, diag::note_pragma_attribute_use_attribute_kw)
2056 if (Attrs.
empty() || Attrs.
begin()->isInvalid()) {
2061 for (
const ParsedAttr &Attribute : Attrs) {
2062 if (!Attribute.isSupportedByPragmaAttribute()) {
2063 Diag(PragmaLoc, diag::err_pragma_attribute_unsupported_attribute)
2072 createExpectedAttributeSubjectRulesTokenDiagnostic(
2073 diag::err_expected, Attrs,
2074 MissingAttributeSubjectRulesRecoveryPoint::Comma, *
this)
2080 if (Tok.isNot(tok::identifier)) {
2081 createExpectedAttributeSubjectRulesTokenDiagnostic(
2082 diag::err_pragma_attribute_invalid_subject_set_specifier, Attrs,
2083 MissingAttributeSubjectRulesRecoveryPoint::ApplyTo, *
this);
2087 const IdentifierInfo *II = Tok.getIdentifierInfo();
2088 if (!II->
isStr(
"apply_to")) {
2089 createExpectedAttributeSubjectRulesTokenDiagnostic(
2090 diag::err_pragma_attribute_invalid_subject_set_specifier, Attrs,
2091 MissingAttributeSubjectRulesRecoveryPoint::ApplyTo, *
this);
2098 createExpectedAttributeSubjectRulesTokenDiagnostic(
2099 diag::err_expected, Attrs,
2100 MissingAttributeSubjectRulesRecoveryPoint::Equals, *
this)
2107 SourceLocation AnyLoc, LastMatchRuleEndLoc;
2108 if (ParsePragmaAttributeSubjectMatchRuleSet(SubjectMatchRules, AnyLoc,
2109 LastMatchRuleEndLoc)) {
2116 if (Tok.isNot(tok::eof)) {
2117 Diag(Tok, diag::err_pragma_attribute_extra_tokens_after_attribute);
2126 if (Info->Action == PragmaAttributeInfo::Push)
2127 Actions.ActOnPragmaAttributeEmptyPush(PragmaLoc, Info->Namespace);
2129 for (ParsedAttr &Attribute : Attrs) {
2130 Actions.ActOnPragmaAttributeAttribute(Attribute, PragmaLoc,
2138void PragmaGCCVisibilityHandler::HandlePragma(
Preprocessor &PP,
2149 if (PushPop && PushPop->
isStr(
"pop")) {
2151 }
else if (PushPop && PushPop->
isStr(
"push")) {
2184 auto Toks = std::make_unique<Token[]>(1);
2185 Toks[0].startToken();
2186 Toks[0].setKind(tok::annot_pragma_vis);
2187 Toks[0].setLocation(VisLoc);
2188 Toks[0].setAnnotationEndLoc(EndLoc);
2189 Toks[0].setAnnotationValue(
2190 const_cast<void *
>(
static_cast<const void *
>(VisType)));
2191 PP.EnterTokenStream(std::move(Toks), 1,
true,
2213 StringRef SlotLabel;
2217 if (
Tok.
is(tok::numeric_constant)) {
2228 }
else if (
Tok.
is(tok::identifier)) {
2230 auto MapPack = [&](
const char *
Literal) {
2233 Alignment.
setKind(tok::numeric_constant);
2239 if (II->
isStr(
"show")) {
2259 if (II->
isStr(
"push")) {
2261 }
else if (II->
isStr(
"pop")) {
2269 if (
Tok.
is(tok::comma)) {
2272 if (
Tok.
is(tok::numeric_constant)) {
2277 }
else if (
Tok.
is(tok::identifier)) {
2281 if (
Tok.
is(tok::comma)) {
2284 if (
Tok.
isNot(tok::numeric_constant)) {
2329 Toks[0].startToken();
2330 Toks[0].setKind(tok::annot_pragma_pack);
2331 Toks[0].setLocation(PackLoc);
2332 Toks[0].setAnnotationEndLoc(RParenLoc);
2333 Toks[0].setAnnotationValue(
static_cast<void*
>(Info));
2334 PP.EnterTokenStream(Toks,
true,
2340void PragmaMSStructHandler::HandlePragma(
Preprocessor &PP,
2342 Token &MSStructTok) {
2353 if (II->
isStr(
"on")) {
2357 else if (II->
isStr(
"off") || II->
isStr(
"reset"))
2372 Toks[0].startToken();
2373 Toks[0].setKind(tok::annot_pragma_msstruct);
2375 Toks[0].setAnnotationEndLoc(EndLoc);
2376 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
2378 PP.EnterTokenStream(Toks,
true,
2383void PragmaClangSectionHandler::HandlePragma(
Preprocessor &PP,
2385 Token &FirstToken) {
2393 PP.
Diag(
Tok.
getLocation(), diag::err_pragma_expected_clang_section_name) <<
"clang section";
2398 if (SecType->
isStr(
"bss"))
2400 else if (SecType->
isStr(
"data"))
2402 else if (SecType->
isStr(
"rodata"))
2404 else if (SecType->
isStr(
"relro"))
2406 else if (SecType->
isStr(
"text"))
2409 PP.
Diag(
Tok.
getLocation(), diag::err_pragma_expected_clang_section_name) <<
"clang section";
2421 std::string SecName;
2425 Actions.ActOnPragmaClangSection(PragmaLocation,
2442 if (
Tok.isNot(tok::identifier) ||
2443 !
Tok.getIdentifierInfo()->isStr(
"align")) {
2444 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_options_expected_align);
2451 if (
Tok.isNot(tok::l_paren)) {
2452 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_lparen) <<
"align";
2455 }
else if (
Tok.isNot(tok::equal)) {
2456 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_align_expected_equal)
2462 if (
Tok.isNot(tok::identifier)) {
2463 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_identifier)
2464 << (IsOptions ?
"options" :
"align");
2470 if (II->
isStr(
"native"))
2472 else if (II->
isStr(
"natural"))
2474 else if (II->
isStr(
"packed"))
2476 else if (II->
isStr(
"power"))
2478 else if (II->
isStr(
"mac68k"))
2480 else if (II->
isStr(
"reset"))
2483 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_align_invalid_option)
2490 if (
Tok.isNot(tok::r_paren)) {
2491 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_rparen) <<
"align";
2498 if (
Tok.isNot(tok::eod)) {
2499 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
2500 << (IsOptions ?
"options" :
"align");
2506 Toks[0].startToken();
2507 Toks[0].setKind(tok::annot_pragma_align);
2509 Toks[0].setAnnotationEndLoc(EndLoc);
2510 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
2512 PP.EnterTokenStream(Toks,
true,
2522void PragmaOptionsHandler::HandlePragma(
Preprocessor &PP,
2524 Token &OptionsTok) {
2529void PragmaUnusedHandler::HandlePragma(
Preprocessor &PP,
2552 if (
Tok.
is(tok::identifier)) {
2553 Identifiers.push_back(
Tok);
2564 if (
Tok.
is(tok::comma)) {
2569 if (
Tok.
is(tok::r_paren)) {
2587 assert(RParenLoc.
isValid() &&
"Valid '#pragma unused' must have ')'");
2588 assert(!Identifiers.empty() &&
"Valid '#pragma unused' must have arguments");
2597 2 * Identifiers.size());
2598 for (
unsigned i=0; i != Identifiers.size(); i++) {
2599 Token &pragmaUnusedTok = Toks[2*i], &idTok = Toks[2*i+1];
2601 pragmaUnusedTok.
setKind(tok::annot_pragma_unused);
2603 idTok = Identifiers[i];
2605 PP.EnterTokenStream(Toks,
true,
2624 bool HasAlias =
false;
2628 if (
Tok.
is(tok::equal)) {
2648 Token &pragmaUnusedTok = Toks[0];
2650 pragmaUnusedTok.
setKind(tok::annot_pragma_weakalias);
2654 Toks[2] = AliasName;
2655 PP.EnterTokenStream(Toks,
true,
2660 Token &pragmaUnusedTok = Toks[0];
2662 pragmaUnusedTok.
setKind(tok::annot_pragma_weak);
2666 PP.EnterTokenStream(Toks,
true,
2672void PragmaRedefineExtnameHandler::HandlePragma(
Preprocessor &PP,
2674 Token &RedefToken) {
2690 <<
"redefine_extname";
2705 Token &pragmaRedefTok = Toks[0];
2707 pragmaRedefTok.
setKind(tok::annot_pragma_redefine_extname);
2710 Toks[1] = RedefName;
2711 Toks[2] = AliasName;
2712 PP.EnterTokenStream(Toks,
true,
2716void PragmaFPContractHandler::HandlePragma(
Preprocessor &PP,
2725 Toks[0].startToken();
2726 Toks[0].setKind(tok::annot_pragma_fp_contract);
2729 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
2731 PP.EnterTokenStream(Toks,
true,
2735void PragmaOpenCLExtensionHandler::HandlePragma(
Preprocessor &PP,
2760 OpenCLExtState State;
2761 if (Pred->
isStr(
"enable")) {
2763 }
else if (Pred->
isStr(
"disable")) {
2765 }
else if (Pred->
isStr(
"begin"))
2767 else if (Pred->
isStr(
"end"))
2771 << Ext->
isStr(
"all");
2785 Info->second = State;
2788 Toks[0].startToken();
2789 Toks[0].setKind(tok::annot_pragma_opencl_extension);
2790 Toks[0].setLocation(NameLoc);
2791 Toks[0].setAnnotationValue(
static_cast<void*
>(Info));
2792 Toks[0].setAnnotationEndLoc(StateLoc);
2793 PP.EnterTokenStream(Toks,
true,
2803template <diag::kind IgnoredDiag>
2804void PragmaNoSupportHandler<IgnoredDiag>::HandlePragma(
2807 PP.
Diag(FirstTok, IgnoredDiag);
2818void PragmaSupportHandler<StartTok, EndTok, UnexpectedDiag>::HandlePragma(
2827 Pragma.push_back(
Tok);
2829 if (
Tok.
is(StartTok)) {
2830 PP.
Diag(
Tok, UnexpectedDiag) << 0;
2831 unsigned InnerPragmaCnt = 1;
2832 while (InnerPragmaCnt != 0) {
2834 if (
Tok.
is(StartTok))
2836 else if (
Tok.
is(EndTok))
2846 Pragma.push_back(
Tok);
2848 auto Toks = std::make_unique<Token[]>(Pragma.size());
2849 std::copy(Pragma.begin(), Pragma.end(), Toks.get());
2850 PP.EnterTokenStream(std::move(Toks), Pragma.size(),
2862void PragmaMSPointersToMembers::HandlePragma(
Preprocessor &PP,
2868 PP.
Diag(PointersToMembersLoc, diag::warn_pragma_expected_lparen)
2869 <<
"pointers_to_members";
2876 <<
"pointers_to_members";
2882 if (Arg->
isStr(
"best_case")) {
2885 if (Arg->
isStr(
"full_generality")) {
2886 if (
Tok.
is(tok::comma)) {
2892 diag::err_pragma_pointers_to_members_unknown_kind)
2897 }
else if (
Tok.
is(tok::r_paren)) {
2904 <<
"full_generality";
2910 if (Arg->
isStr(
"single_inheritance")) {
2911 RepresentationMethod =
2913 }
else if (Arg->
isStr(
"multiple_inheritance")) {
2914 RepresentationMethod =
2916 }
else if (Arg->
isStr(
"virtual_inheritance")) {
2917 RepresentationMethod =
2921 diag::err_pragma_pointers_to_members_unknown_kind)
2930 << (Arg ? Arg->
getName() :
"full_generality");
2938 <<
"pointers_to_members";
2944 AnnotTok.
setKind(tok::annot_pragma_ms_pointers_to_members);
2948 reinterpret_cast<void *
>(
static_cast<uintptr_t>(RepresentationMethod)));
2965 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_lparen) <<
"vtordisp";
2973 if (II->
isStr(
"push")) {
2977 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_punc) <<
"vtordisp";
2983 }
else if (II->
isStr(
"pop")) {
2990 if (
Tok.
is(tok::r_paren)) {
3000 if (II && II->
isStr(
"off")) {
3003 }
else if (II && II->
isStr(
"on")) {
3006 }
else if (
Tok.
is(tok::numeric_constant) &&
3010 << 0 << 2 <<
"vtordisp";
3022 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_rparen) <<
"vtordisp";
3036 AnnotTok.
setKind(tok::annot_pragma_ms_vtordisp);
3048 Token EoF, AnnotTok;
3052 AnnotTok.
setKind(tok::annot_pragma_ms_pragma);
3058 TokenVector.push_back(
Tok);
3062 TokenVector.push_back(EoF);
3065 markAsReinjectedForRelexing(TokenVector);
3066 auto TokenArray = std::make_unique<Token[]>(TokenVector.size());
3067 std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
3069 std::pair<std::unique_ptr<Token[]>,
size_t>(std::move(TokenArray),
3070 TokenVector.size());
3086void PragmaFloatControlHandler::HandlePragma(
Preprocessor &PP,
3099 PP.
Diag(FloatControlLoc, diag::err_expected) << tok::l_paren;
3113 llvm::StringSwitch<PragmaFloatControlKind>(II->
getName())
3131 if (
Tok.
is(tok::r_paren))
3144 if (PushOnOff ==
"on")
3147 else if (PushOnOff ==
"off") {
3152 }
else if (PushOnOff ==
"push") {
3159 if (
Tok.
is(tok::comma)) {
3166 if (ExpectedPush ==
"push") {
3191 auto TokenArray = std::make_unique<Token[]>(1);
3192 TokenArray[0].startToken();
3193 TokenArray[0].setKind(tok::annot_pragma_float_control);
3194 TokenArray[0].setLocation(FloatControlLoc);
3195 TokenArray[0].setAnnotationEndLoc(EndLoc);
3198 TokenArray[0].setAnnotationValue(
reinterpret_cast<void *
>(
3199 static_cast<uintptr_t>((Action << 16) | (Kind & 0xFFFF))));
3200 PP.EnterTokenStream(std::move(TokenArray), 1,
3214void PragmaDetectMismatchHandler::HandlePragma(
Preprocessor &PP,
3220 PP.
Diag(DetectMismatchLoc, diag::err_expected) << tok::l_paren;
3225 std::string NameString;
3227 "pragma detect_mismatch",
3232 std::string ValueString;
3258 Actions.ActOnPragmaDetectMismatch(DetectMismatchLoc, NameString, ValueString);
3270void PragmaCommentHandler::HandlePragma(
Preprocessor &PP,
3276 PP.
Diag(CommentLoc, diag::err_pragma_comment_malformed);
3283 PP.
Diag(CommentLoc, diag::err_pragma_comment_malformed);
3290 llvm::StringSwitch<PragmaMSCommentKind>(II->
getName())
3310 std::string ArgumentString;
3338 Actions.ActOnPragmaMSComment(CommentLoc, Kind, ArgumentString);
3343void PragmaOptimizeHandler::HandlePragma(
Preprocessor &PP,
3345 Token &FirstToken) {
3348 if (
Tok.
is(tok::eod)) {
3350 <<
"clang optimize" <<
true <<
"'on' or 'off'";
3361 if (II->
isStr(
"on")) {
3363 }
else if (!II->
isStr(
"off")) {
3376 Actions.ActOnPragmaOptimize(IsOn, FirstToken.
getLocation());
3381struct TokFPAnnotValue {
3382 enum FlagValues { On, Off, Fast };
3384 std::optional<LangOptions::FPModeKind> ContractValue;
3385 std::optional<LangOptions::FPModeKind> ReassociateValue;
3386 std::optional<LangOptions::FPModeKind> ReciprocalValue;
3387 std::optional<LangOptions::FPExceptionModeKind> ExceptionsValue;
3388 std::optional<LangOptions::FPEvalMethodKind> EvalMethodValue;
3406 while (
Tok.
is(tok::identifier)) {
3410 llvm::StringSwitch<std::optional<PragmaFPKind>>(OptionInfo->
getName())
3416 .Default(std::nullopt);
3419 <<
false << OptionInfo;
3430 bool isEvalMethodDouble =
3434 if (
Tok.
isNot(tok::identifier) && !isEvalMethodDouble) {
3437 <<
static_cast<int>(*FlagKind);
3443 AnnotValue->ContractValue =
3444 llvm::StringSwitch<std::optional<LangOptions::FPModeKind>>(
3449 .Default(std::nullopt);
3450 if (!AnnotValue->ContractValue) {
3457 : AnnotValue->ReciprocalValue;
3458 Value = llvm::StringSwitch<std::optional<LangOptions::FPModeKind>>(
3462 .Default(std::nullopt);
3469 AnnotValue->ExceptionsValue =
3470 llvm::StringSwitch<std::optional<LangOptions::FPExceptionModeKind>>(
3475 .Default(std::nullopt);
3476 if (!AnnotValue->ExceptionsValue) {
3482 AnnotValue->EvalMethodValue =
3483 llvm::StringSwitch<std::optional<LangOptions::FPEvalMethodKind>>(
3488 .Default(std::nullopt);
3489 if (!AnnotValue->EvalMethodValue) {
3513 FPTok.
setKind(tok::annot_pragma_fp);
3517 TokenList.push_back(FPTok);
3519 auto TokenArray = std::make_unique<Token[]>(TokenList.size());
3520 std::copy(TokenList.begin(), TokenList.end(), TokenArray.get());
3522 PP.EnterTokenStream(std::move(TokenArray), TokenList.size(),
3526void PragmaSTDC_FENV_ROUNDHandler::HandlePragma(
Preprocessor &PP,
3545 llvm::StringSwitch<llvm::RoundingMode>(II->
getName())
3546 .Case(
"FE_TOWARDZERO", llvm::RoundingMode::TowardZero)
3547 .Case(
"FE_TONEAREST", llvm::RoundingMode::NearestTiesToEven)
3548 .Case(
"FE_UPWARD", llvm::RoundingMode::TowardPositive)
3549 .Case(
"FE_DOWNWARD", llvm::RoundingMode::TowardNegative)
3550 .Case(
"FE_TONEARESTFROMZERO", llvm::RoundingMode::NearestTiesToAway)
3551 .Case(
"FE_DYNAMIC", llvm::RoundingMode::Dynamic)
3552 .Default(llvm::RoundingMode::Invalid);
3553 if (RM == llvm::RoundingMode::Invalid) {
3561 <<
"STDC FENV_ROUND";
3570 Toks[0].startToken();
3571 Toks[0].setKind(tok::annot_pragma_fenv_round);
3574 Toks[0].setAnnotationValue(
3575 reinterpret_cast<void *
>(
static_cast<uintptr_t>(RM)));
3576 PP.EnterTokenStream(Toks,
true,
3580void Parser::HandlePragmaFP() {
3581 assert(Tok.is(tok::annot_pragma_fp));
3583 reinterpret_cast<TokFPAnnotValue *
>(Tok.getAnnotationValue());
3585 if (AnnotValue->ReassociateValue)
3586 Actions.ActOnPragmaFPValueChangingOption(
3590 if (AnnotValue->ReciprocalValue)
3591 Actions.ActOnPragmaFPValueChangingOption(
3595 if (AnnotValue->ContractValue)
3596 Actions.ActOnPragmaFPContract(Tok.getLocation(),
3597 *AnnotValue->ContractValue);
3598 if (AnnotValue->ExceptionsValue)
3599 Actions.ActOnPragmaFPExceptions(Tok.getLocation(),
3600 *AnnotValue->ExceptionsValue);
3601 if (AnnotValue->EvalMethodValue)
3602 Actions.ActOnPragmaFPEvalMethod(Tok.getLocation(),
3603 *AnnotValue->EvalMethodValue);
3604 ConsumeAnnotationToken();
3609 Token Option,
bool ValueInParens,
3612 int OpenParens = ValueInParens ? 1 : 0;
3614 while (
Tok.isNot(tok::eod)) {
3615 if (
Tok.is(tok::l_paren))
3617 else if (
Tok.is(tok::r_paren)) {
3619 if (OpenParens == 0 && ValueInParens)
3627 if (ValueInParens) {
3629 if (
Tok.isNot(tok::r_paren)) {
3630 PP.
Diag(
Tok.getLocation(), diag::err_expected) << tok::r_paren;
3698void PragmaLoopHintHandler::HandlePragma(
Preprocessor &PP,
3713 while (
Tok.
is(tok::identifier)) {
3717 bool OptionValid = llvm::StringSwitch<bool>(OptionInfo->
getName())
3718 .Case(
"vectorize",
true)
3719 .Case(
"interleave",
true)
3720 .Case(
"unroll",
true)
3721 .Case(
"distribute",
true)
3722 .Case(
"vectorize_predicate",
true)
3723 .Case(
"vectorize_width",
true)
3724 .Case(
"interleave_count",
true)
3725 .Case(
"unroll_count",
true)
3726 .Case(
"pipeline",
true)
3727 .Case(
"pipeline_initiation_interval",
true)
3731 <<
false << OptionInfo;
3751 LoopHintTok.
setKind(tok::annot_pragma_loop_hint);
3755 TokenList.push_back(LoopHintTok);
3764 auto TokenArray = std::make_unique<Token[]>(TokenList.size());
3765 std::copy(TokenList.begin(), TokenList.end(), TokenArray.get());
3767 PP.EnterTokenStream(std::move(TokenArray), TokenList.size(),
3792void PragmaUnrollHintHandler::HandlePragma(
Preprocessor &PP,
3800 if (
Tok.
is(tok::eod)) {
3802 Info->PragmaName = PragmaName;
3803 Info->Option.startToken();
3813 bool ValueInParens =
Tok.
is(tok::l_paren);
3825 PP.
Diag(Info->Toks[0].getLocation(),
3826 diag::warn_pragma_unroll_cuda_value_in_parens);
3836 auto TokenArray = std::make_unique<Token[]>(1);
3837 TokenArray[0].startToken();
3838 TokenArray[0].setKind(tok::annot_pragma_loop_hint);
3839 TokenArray[0].setLocation(Introducer.
Loc);
3840 TokenArray[0].setAnnotationEndLoc(PragmaName.
getLocation());
3841 TokenArray[0].setAnnotationValue(
static_cast<void *
>(Info));
3842 PP.EnterTokenStream(std::move(TokenArray), 1,
3846bool Parser::HandlePragmaMSFunction(StringRef PragmaName,
3848 Token FirstTok = Tok;
3850 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3854 bool SuggestIntrinH = !PP.isMacroDefined(
"__INTRIN_H");
3856 llvm::SmallVector<StringRef> NoBuiltins;
3857 while (Tok.is(tok::identifier)) {
3858 IdentifierInfo *II = Tok.getIdentifierInfo();
3860 PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
3861 << II << SuggestIntrinH;
3863 NoBuiltins.emplace_back(II->
getName());
3866 if (Tok.isNot(tok::comma))
3871 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3873 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3877 Actions.ActOnPragmaMSFunction(FirstTok.
getLocation(), NoBuiltins);
3881bool Parser::HandlePragmaMSOptimize(StringRef PragmaName,
3883 Token FirstTok = Tok;
3884 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3888 if (Tok.isNot(tok::string_literal)) {
3889 PP.Diag(PragmaLocation, diag::warn_pragma_expected_string) << PragmaName;
3897 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
3902 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_comma,
3906 if (Tok.is(tok::eof) || Tok.is(tok::r_paren)) {
3907 PP.Diag(PragmaLocation, diag::warn_pragma_missing_argument)
3908 << PragmaName <<
true <<
"'on' or 'off'";
3911 IdentifierInfo *II = Tok.getIdentifierInfo();
3912 if (!II || (!II->
isStr(
"on") && !II->
isStr(
"off"))) {
3913 PP.Diag(PragmaLocation, diag::warn_pragma_invalid_argument)
3914 << PP.getSpelling(Tok) << PragmaName <<
true
3918 bool IsOn = II->
isStr(
"on");
3921 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3926 if (!OptimizationList->
getString().empty()) {
3927 PP.Diag(PragmaLocation, diag::warn_pragma_invalid_argument)
3928 << OptimizationList->
getString() << PragmaName <<
true
3933 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3937 Actions.ActOnPragmaMSOptimize(FirstTok.
getLocation(), IsOn);
3954bool Parser::HandlePragmaMSIntrinsic(StringRef PragmaName,
3956 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3960 bool SuggestIntrinH = !PP.isMacroDefined(
"__INTRIN_H");
3962 while (Tok.is(tok::identifier)) {
3963 IdentifierInfo *II = Tok.getIdentifierInfo();
3965 PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
3966 << II << SuggestIntrinH;
3968 DeclarationNameInfo NameInfo(II, Tok.getLocation());
3971 Actions.LookupName(
Previous, Actions.getCurScope(),
3974 Actions.LazilyCreateBuiltin(II, II->
getBuiltinID(), Actions.getCurScope(),
3975 true, Tok.getLocation());
3977 if (Tok.isNot(tok::comma))
3981 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3985 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3991void PragmaForceCUDAHostDeviceHandler::HandlePragma(
3997 if (!Info || (!Info->
isStr(
"begin") && !Info->
isStr(
"end"))) {
3999 diag::warn_pragma_force_cuda_host_device_bad_arg);
4003 if (Info->
isStr(
"begin"))
4004 Actions.CUDA().PushForceHostDevice();
4005 else if (!Actions.CUDA().PopForceHostDevice())
4007 diag::err_pragma_cannot_end_force_cuda_host_device);
4010 if (!
Tok.
is(tok::eod))
4012 diag::warn_pragma_force_cuda_host_device_bad_arg);
4042void PragmaAttributeHandler::HandlePragma(
Preprocessor &PP,
4044 Token &FirstToken) {
4048 PragmaAttributeInfo(AttributesForPragmaAttribute);
4051 if (
Tok.
is(tok::identifier)) {
4053 if (!II->
isStr(
"push") && !II->
isStr(
"pop")) {
4054 Info->Namespace = II;
4057 if (!
Tok.
is(tok::period)) {
4066 if (!
Tok.
isOneOf(tok::identifier, tok::l_paren)) {
4068 diag::err_pragma_attribute_expected_push_pop_paren);
4073 if (
Tok.
is(tok::l_paren)) {
4074 if (Info->Namespace) {
4076 diag::err_pragma_attribute_namespace_on_attribute);
4078 diag::note_pragma_attribute_namespace_on_attribute);
4081 Info->Action = PragmaAttributeInfo::Attribute;
4084 if (II->
isStr(
"push"))
4085 Info->Action = PragmaAttributeInfo::Push;
4086 else if (II->
isStr(
"pop"))
4087 Info->Action = PragmaAttributeInfo::Pop;
4098 if ((Info->Action == PragmaAttributeInfo::Push &&
Tok.
isNot(tok::eod)) ||
4099 Info->Action == PragmaAttributeInfo::Attribute) {
4110 if (
Tok.
is(tok::l_paren))
4112 else if (
Tok.
is(tok::r_paren)) {
4114 if (OpenParens == 0)
4118 AttributeTokens.push_back(
Tok);
4122 if (AttributeTokens.empty()) {
4138 AttributeTokens.push_back(EOFTok);
4140 markAsReinjectedForRelexing(AttributeTokens);
4147 <<
"clang attribute";
4150 auto TokenArray = std::make_unique<Token[]>(1);
4151 TokenArray[0].startToken();
4152 TokenArray[0].setKind(tok::annot_pragma_attribute);
4153 TokenArray[0].setLocation(FirstToken.
getLocation());
4154 TokenArray[0].setAnnotationEndLoc(FirstToken.
getLocation());
4155 TokenArray[0].setAnnotationValue(
static_cast<void *
>(Info));
4156 PP.EnterTokenStream(std::move(TokenArray), 1,
4161void PragmaMaxTokensHereHandler::HandlePragma(
Preprocessor &PP,
4165 if (
Tok.
is(tok::eod)) {
4167 <<
"clang max_tokens_here" <<
true <<
"integer";
4173 if (
Tok.
isNot(tok::numeric_constant) ||
4176 <<
"clang max_tokens_here";
4182 <<
"clang max_tokens_here";
4187 PP.
Diag(Loc, diag::warn_max_tokens)
4193void PragmaMaxTokensTotalHandler::HandlePragma(
Preprocessor &PP,
4197 if (
Tok.
is(tok::eod)) {
4199 <<
"clang max_tokens_total" <<
true <<
"integer";
4205 if (
Tok.
isNot(tok::numeric_constant) ||
4208 <<
"clang max_tokens_total";
4214 <<
"clang max_tokens_total";
4230 for (;
Tok.isNot(tok::eod); PP.
Lex(
Tok)) {
4231 TokenVector.push_back(
Tok);
4239 TokenVector.push_back(EoF);
4242 markAsReinjectedForRelexing(TokenVector);
4243 auto TokenArray = std::make_unique<Token[]>(TokenVector.size());
4244 std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
4246 std::pair<std::unique_ptr<Token[]>,
size_t>(std::move(TokenArray),
4247 TokenVector.size());
4253void PragmaExportHandler::HandlePragma(
Preprocessor &PP,
4255 Token &FirstToken) {
4264 Token &FirstToken) {
4269 if (!II || !II->
isStr(
"intrinsic")) {
4277 if (!II || !(II->
isStr(
"vector") || II->
isStr(
"sifive_vector") ||
4278 II->
isStr(
"andes_vector"))) {
4281 <<
"'vector', 'sifive_vector' or 'andes_vector'";
4288 <<
"clang riscv intrinsic";
4292 if (II->
isStr(
"vector"))
4293 Actions.RISCV().DeclareRVVBuiltins =
true;
4294 else if (II->
isStr(
"sifive_vector"))
4295 Actions.RISCV().DeclareSiFiveVectorBuiltins =
true;
4296 else if (II->
isStr(
"andes_vector"))
4297 Actions.RISCV().DeclareAndesVectorBuiltins =
true;
Defines the clang::ASTContext interface.
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.
const FunctionProtoType * T
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