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;
240 bool SeenCopyrightInTU =
false;
244 PragmaDetectMismatchHandler(Sema &Actions)
245 : PragmaHandler(
"detect_mismatch"), Actions(Actions) {}
246 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
247 Token &FirstToken)
override;
254 PragmaFloatControlHandler(Sema &Actions)
255 : PragmaHandler(
"float_control") {}
256 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
257 Token &FirstToken)
override;
261 explicit PragmaMSPointersToMembers() : PragmaHandler(
"pointers_to_members") {}
262 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
263 Token &FirstToken)
override;
267 explicit PragmaMSVtorDisp() : PragmaHandler(
"vtordisp") {}
268 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
269 Token &FirstToken)
override;
273 explicit PragmaMSPragma(
const char *name) : PragmaHandler(
name) {}
274 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
275 Token &FirstToken)
override;
280 PragmaOptimizeHandler(Sema &S)
281 : PragmaHandler(
"optimize"), Actions(S) {}
282 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
283 Token &FirstToken)
override;
290 PragmaLoopHintHandler() : PragmaHandler(
"loop") {}
291 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
292 Token &FirstToken)
override;
296 PragmaUnrollHintHandler(
const char *name) : PragmaHandler(
name) {}
297 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
298 Token &FirstToken)
override;
302 PragmaMSRuntimeChecksHandler() : EmptyPragmaHandler(
"runtime_checks") {}
307 PragmaMSFenvAccessHandler() : PragmaHandler(
"fenv_access") {}
308 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
309 Token &FirstToken)
override {
331 if (II->
isStr(
"on")) {
334 }
else if (II->
isStr(
"off")) {
354 MutableArrayRef<Token> Toks(
356 Toks[0].startToken();
357 Toks[0].setKind(tok::annot_pragma_fenv_access_ms);
360 Toks[0].setAnnotationValue(
361 reinterpret_cast<void*
>(
static_cast<uintptr_t>(OOS)));
362 PP.EnterTokenStream(Toks,
true,
367struct PragmaForceCUDAHostDeviceHandler :
public PragmaHandler {
368 PragmaForceCUDAHostDeviceHandler(Sema &Actions)
369 : PragmaHandler(
"force_cuda_host_device"), Actions(Actions) {}
370 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
371 Token &FirstToken)
override;
379 PragmaAttributeHandler(AttributeFactory &AttrFactory)
380 : PragmaHandler(
"attribute"), AttributesForPragmaAttribute(AttrFactory) {}
381 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
382 Token &FirstToken)
override;
385 ParsedAttributes AttributesForPragmaAttribute;
389 PragmaMaxTokensHereHandler() : PragmaHandler(
"max_tokens_here") {}
390 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
391 Token &FirstToken)
override;
395 PragmaMaxTokensTotalHandler() : PragmaHandler(
"max_tokens_total") {}
396 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
397 Token &FirstToken)
override;
401 explicit PragmaExportHandler() : PragmaHandler(
"export") {}
402 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
403 Token &FirstToken)
override;
407 PragmaRISCVHandler(Sema &Actions)
408 : PragmaHandler(
"riscv"), Actions(Actions) {}
409 void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
410 Token &FirstToken)
override;
422void Parser::initializePragmaHandlers() {
423 AlignHandler = std::make_unique<PragmaAlignHandler>();
424 PP.AddPragmaHandler(AlignHandler.get());
426 GCCVisibilityHandler = std::make_unique<PragmaGCCVisibilityHandler>();
427 PP.AddPragmaHandler(
"GCC", GCCVisibilityHandler.get());
429 OptionsHandler = std::make_unique<PragmaOptionsHandler>();
430 PP.AddPragmaHandler(OptionsHandler.get());
432 PackHandler = std::make_unique<PragmaPackHandler>();
433 PP.AddPragmaHandler(PackHandler.get());
435 MSStructHandler = std::make_unique<PragmaMSStructHandler>();
436 PP.AddPragmaHandler(MSStructHandler.get());
438 UnusedHandler = std::make_unique<PragmaUnusedHandler>();
439 PP.AddPragmaHandler(UnusedHandler.get());
441 WeakHandler = std::make_unique<PragmaWeakHandler>();
442 PP.AddPragmaHandler(WeakHandler.get());
444 RedefineExtnameHandler = std::make_unique<PragmaRedefineExtnameHandler>();
445 PP.AddPragmaHandler(RedefineExtnameHandler.get());
447 FPContractHandler = std::make_unique<PragmaFPContractHandler>();
448 PP.AddPragmaHandler(
"STDC", FPContractHandler.get());
450 STDCFenvAccessHandler = std::make_unique<PragmaSTDC_FENV_ACCESSHandler>();
451 PP.AddPragmaHandler(
"STDC", STDCFenvAccessHandler.get());
453 STDCFenvRoundHandler = std::make_unique<PragmaSTDC_FENV_ROUNDHandler>();
454 PP.AddPragmaHandler(
"STDC", STDCFenvRoundHandler.get());
456 STDCCXLIMITHandler = std::make_unique<PragmaSTDC_CX_LIMITED_RANGEHandler>();
457 PP.AddPragmaHandler(
"STDC", STDCCXLIMITHandler.get());
459 STDCUnknownHandler = std::make_unique<PragmaSTDC_UnknownHandler>();
460 PP.AddPragmaHandler(
"STDC", STDCUnknownHandler.get());
462 PCSectionHandler = std::make_unique<PragmaClangSectionHandler>(Actions);
463 PP.AddPragmaHandler(
"clang", PCSectionHandler.get());
466 OpenCLExtensionHandler = std::make_unique<PragmaOpenCLExtensionHandler>();
467 PP.AddPragmaHandler(
"OPENCL", OpenCLExtensionHandler.get());
469 PP.AddPragmaHandler(
"OPENCL", FPContractHandler.get());
472 OpenMPHandler = std::make_unique<PragmaOpenMPHandler>();
474 OpenMPHandler = std::make_unique<PragmaNoOpenMPHandler>();
475 PP.AddPragmaHandler(OpenMPHandler.get());
478 OpenACCHandler = std::make_unique<PragmaOpenACCHandler>();
480 OpenACCHandler = std::make_unique<PragmaNoOpenACCHandler>();
481 PP.AddPragmaHandler(OpenACCHandler.get());
486 MSCommentHandler = std::make_unique<PragmaCommentHandler>(Actions);
487 PP.AddPragmaHandler(MSCommentHandler.get());
490 FloatControlHandler = std::make_unique<PragmaFloatControlHandler>(Actions);
491 PP.AddPragmaHandler(FloatControlHandler.get());
493 MSDetectMismatchHandler =
494 std::make_unique<PragmaDetectMismatchHandler>(Actions);
495 PP.AddPragmaHandler(MSDetectMismatchHandler.get());
496 MSPointersToMembers = std::make_unique<PragmaMSPointersToMembers>();
497 PP.AddPragmaHandler(MSPointersToMembers.get());
498 MSVtorDisp = std::make_unique<PragmaMSVtorDisp>();
499 PP.AddPragmaHandler(MSVtorDisp.get());
500 MSInitSeg = std::make_unique<PragmaMSPragma>(
"init_seg");
501 PP.AddPragmaHandler(MSInitSeg.get());
502 MSDataSeg = std::make_unique<PragmaMSPragma>(
"data_seg");
503 PP.AddPragmaHandler(MSDataSeg.get());
504 MSBSSSeg = std::make_unique<PragmaMSPragma>(
"bss_seg");
505 PP.AddPragmaHandler(MSBSSSeg.get());
506 MSConstSeg = std::make_unique<PragmaMSPragma>(
"const_seg");
507 PP.AddPragmaHandler(MSConstSeg.get());
508 MSCodeSeg = std::make_unique<PragmaMSPragma>(
"code_seg");
509 PP.AddPragmaHandler(MSCodeSeg.get());
510 MSSection = std::make_unique<PragmaMSPragma>(
"section");
511 PP.AddPragmaHandler(MSSection.get());
512 MSStrictGuardStackCheck =
513 std::make_unique<PragmaMSPragma>(
"strict_gs_check");
514 PP.AddPragmaHandler(MSStrictGuardStackCheck.get());
515 MSFunction = std::make_unique<PragmaMSPragma>(
"function");
516 PP.AddPragmaHandler(MSFunction.get());
517 MSAllocText = std::make_unique<PragmaMSPragma>(
"alloc_text");
518 PP.AddPragmaHandler(MSAllocText.get());
519 MSOptimize = std::make_unique<PragmaMSPragma>(
"optimize");
520 PP.AddPragmaHandler(MSOptimize.get());
521 MSRuntimeChecks = std::make_unique<PragmaMSRuntimeChecksHandler>();
522 PP.AddPragmaHandler(MSRuntimeChecks.get());
523 MSIntrinsic = std::make_unique<PragmaMSPragma>(
"intrinsic");
524 PP.AddPragmaHandler(MSIntrinsic.get());
525 MSFenvAccess = std::make_unique<PragmaMSFenvAccessHandler>();
526 PP.AddPragmaHandler(MSFenvAccess.get());
530 CUDAForceHostDeviceHandler =
531 std::make_unique<PragmaForceCUDAHostDeviceHandler>(Actions);
532 PP.AddPragmaHandler(
"clang", CUDAForceHostDeviceHandler.get());
535 OptimizeHandler = std::make_unique<PragmaOptimizeHandler>(Actions);
536 PP.AddPragmaHandler(
"clang", OptimizeHandler.get());
538 LoopHintHandler = std::make_unique<PragmaLoopHintHandler>();
539 PP.AddPragmaHandler(
"clang", LoopHintHandler.get());
541 UnrollHintHandler = std::make_unique<PragmaUnrollHintHandler>(
"unroll");
542 PP.AddPragmaHandler(UnrollHintHandler.get());
543 PP.AddPragmaHandler(
"GCC", UnrollHintHandler.get());
545 NoUnrollHintHandler = std::make_unique<PragmaUnrollHintHandler>(
"nounroll");
546 PP.AddPragmaHandler(NoUnrollHintHandler.get());
547 PP.AddPragmaHandler(
"GCC", NoUnrollHintHandler.get());
549 UnrollAndJamHintHandler =
550 std::make_unique<PragmaUnrollHintHandler>(
"unroll_and_jam");
551 PP.AddPragmaHandler(UnrollAndJamHintHandler.get());
553 NoUnrollAndJamHintHandler =
554 std::make_unique<PragmaUnrollHintHandler>(
"nounroll_and_jam");
555 PP.AddPragmaHandler(NoUnrollAndJamHintHandler.get());
557 FPHandler = std::make_unique<PragmaFPHandler>();
558 PP.AddPragmaHandler(
"clang", FPHandler.get());
560 AttributePragmaHandler =
561 std::make_unique<PragmaAttributeHandler>(AttrFactory);
562 PP.AddPragmaHandler(
"clang", AttributePragmaHandler.get());
564 MaxTokensHerePragmaHandler = std::make_unique<PragmaMaxTokensHereHandler>();
565 PP.AddPragmaHandler(
"clang", MaxTokensHerePragmaHandler.get());
567 MaxTokensTotalPragmaHandler = std::make_unique<PragmaMaxTokensTotalHandler>();
568 PP.AddPragmaHandler(
"clang", MaxTokensTotalPragmaHandler.get());
571 ExportHandler = std::make_unique<PragmaExportHandler>();
572 PP.AddPragmaHandler(ExportHandler.get());
576 RISCVPragmaHandler = std::make_unique<PragmaRISCVHandler>(Actions);
577 PP.AddPragmaHandler(
"clang", RISCVPragmaHandler.get());
581void Parser::resetPragmaHandlers() {
583 PP.RemovePragmaHandler(AlignHandler.get());
584 AlignHandler.reset();
585 PP.RemovePragmaHandler(
"GCC", GCCVisibilityHandler.get());
586 GCCVisibilityHandler.reset();
587 PP.RemovePragmaHandler(OptionsHandler.get());
588 OptionsHandler.reset();
589 PP.RemovePragmaHandler(PackHandler.get());
591 PP.RemovePragmaHandler(MSStructHandler.get());
592 MSStructHandler.reset();
593 PP.RemovePragmaHandler(UnusedHandler.get());
594 UnusedHandler.reset();
595 PP.RemovePragmaHandler(WeakHandler.get());
597 PP.RemovePragmaHandler(RedefineExtnameHandler.get());
598 RedefineExtnameHandler.reset();
601 PP.RemovePragmaHandler(
"OPENCL", OpenCLExtensionHandler.get());
602 OpenCLExtensionHandler.reset();
603 PP.RemovePragmaHandler(
"OPENCL", FPContractHandler.get());
605 PP.RemovePragmaHandler(OpenMPHandler.get());
606 OpenMPHandler.reset();
608 PP.RemovePragmaHandler(OpenACCHandler.get());
609 OpenACCHandler.reset();
614 PP.RemovePragmaHandler(MSCommentHandler.get());
615 MSCommentHandler.reset();
618 PP.RemovePragmaHandler(
"clang", PCSectionHandler.get());
619 PCSectionHandler.reset();
621 PP.RemovePragmaHandler(FloatControlHandler.get());
622 FloatControlHandler.reset();
624 PP.RemovePragmaHandler(MSDetectMismatchHandler.get());
625 MSDetectMismatchHandler.reset();
626 PP.RemovePragmaHandler(MSPointersToMembers.get());
627 MSPointersToMembers.reset();
628 PP.RemovePragmaHandler(MSVtorDisp.get());
630 PP.RemovePragmaHandler(MSInitSeg.get());
632 PP.RemovePragmaHandler(MSDataSeg.get());
634 PP.RemovePragmaHandler(MSBSSSeg.get());
636 PP.RemovePragmaHandler(MSConstSeg.get());
638 PP.RemovePragmaHandler(MSCodeSeg.get());
640 PP.RemovePragmaHandler(MSSection.get());
642 PP.RemovePragmaHandler(MSStrictGuardStackCheck.get());
643 MSStrictGuardStackCheck.reset();
644 PP.RemovePragmaHandler(MSFunction.get());
646 PP.RemovePragmaHandler(MSAllocText.get());
648 PP.RemovePragmaHandler(MSRuntimeChecks.get());
649 MSRuntimeChecks.reset();
650 PP.RemovePragmaHandler(MSIntrinsic.get());
652 PP.RemovePragmaHandler(MSOptimize.get());
654 PP.RemovePragmaHandler(MSFenvAccess.get());
655 MSFenvAccess.reset();
659 PP.RemovePragmaHandler(
"clang", CUDAForceHostDeviceHandler.get());
660 CUDAForceHostDeviceHandler.reset();
663 PP.RemovePragmaHandler(
"STDC", FPContractHandler.get());
664 FPContractHandler.reset();
666 PP.RemovePragmaHandler(
"STDC", STDCFenvAccessHandler.get());
667 STDCFenvAccessHandler.reset();
669 PP.RemovePragmaHandler(
"STDC", STDCFenvRoundHandler.get());
670 STDCFenvRoundHandler.reset();
672 PP.RemovePragmaHandler(
"STDC", STDCCXLIMITHandler.get());
673 STDCCXLIMITHandler.reset();
675 PP.RemovePragmaHandler(
"STDC", STDCUnknownHandler.get());
676 STDCUnknownHandler.reset();
678 PP.RemovePragmaHandler(
"clang", OptimizeHandler.get());
679 OptimizeHandler.reset();
681 PP.RemovePragmaHandler(
"clang", LoopHintHandler.get());
682 LoopHintHandler.reset();
684 PP.RemovePragmaHandler(UnrollHintHandler.get());
685 PP.RemovePragmaHandler(
"GCC", UnrollHintHandler.get());
686 UnrollHintHandler.reset();
688 PP.RemovePragmaHandler(NoUnrollHintHandler.get());
689 PP.RemovePragmaHandler(
"GCC", NoUnrollHintHandler.get());
690 NoUnrollHintHandler.reset();
692 PP.RemovePragmaHandler(UnrollAndJamHintHandler.get());
693 UnrollAndJamHintHandler.reset();
695 PP.RemovePragmaHandler(NoUnrollAndJamHintHandler.get());
696 NoUnrollAndJamHintHandler.reset();
698 PP.RemovePragmaHandler(
"clang", FPHandler.get());
701 PP.RemovePragmaHandler(
"clang", AttributePragmaHandler.get());
702 AttributePragmaHandler.reset();
704 PP.RemovePragmaHandler(
"clang", MaxTokensHerePragmaHandler.get());
705 MaxTokensHerePragmaHandler.reset();
707 PP.RemovePragmaHandler(
"clang", MaxTokensTotalPragmaHandler.get());
708 MaxTokensTotalPragmaHandler.reset();
711 PP.RemovePragmaHandler(ExportHandler.get());
712 ExportHandler.reset();
716 PP.RemovePragmaHandler(
"clang", RISCVPragmaHandler.get());
717 RISCVPragmaHandler.reset();
721void Parser::HandlePragmaUnused() {
722 assert(Tok.is(tok::annot_pragma_unused));
723 SourceLocation UnusedLoc = ConsumeAnnotationToken();
724 Actions.ActOnPragmaUnused(Tok,
getCurScope(), UnusedLoc);
728void Parser::HandlePragmaVisibility() {
729 assert(Tok.is(tok::annot_pragma_vis));
730 const IdentifierInfo *VisType =
731 static_cast<IdentifierInfo *
>(Tok.getAnnotationValue());
732 SourceLocation VisLoc = ConsumeAnnotationToken();
733 Actions.ActOnPragmaVisibility(VisType, VisLoc);
736void Parser::HandlePragmaPack() {
737 assert(Tok.is(tok::annot_pragma_pack));
738 Sema::PragmaPackInfo *Info =
739 static_cast<Sema::PragmaPackInfo *
>(Tok.getAnnotationValue());
740 SourceLocation PragmaLoc = Tok.getLocation();
743 Alignment = Actions.ActOnNumericConstant(Info->
Alignment);
745 ConsumeAnnotationToken();
753 ConsumeAnnotationToken();
756void Parser::HandlePragmaMSStruct() {
757 assert(Tok.is(tok::annot_pragma_msstruct));
759 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
760 Actions.ActOnPragmaMSStruct(Kind);
761 ConsumeAnnotationToken();
764void Parser::HandlePragmaAlign() {
765 assert(Tok.is(tok::annot_pragma_align));
767 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
768 Actions.ActOnPragmaOptionsAlign(Kind, Tok.getLocation());
771 ConsumeAnnotationToken();
774void Parser::HandlePragmaDump() {
775 assert(Tok.is(tok::annot_pragma_dump));
776 ConsumeAnnotationToken();
777 if (Tok.is(tok::eod)) {
778 PP.Diag(Tok, diag::warn_pragma_debug_missing_argument) <<
"dump";
780 if (Tok.isNot(tok::identifier)) {
781 PP.Diag(Tok, diag::warn_pragma_debug_unexpected_argument);
783 ExpectAndConsume(tok::eod);
786 IdentifierInfo *II = Tok.getIdentifierInfo();
787 Actions.ActOnPragmaDump(
getCurScope(), Tok.getLocation(), II);
790 SourceLocation StartLoc = Tok.getLocation();
791 EnterExpressionEvaluationContext Ctx(
797 PP.Diag(StartLoc, diag::warn_pragma_debug_dependent_argument)
799 << SourceRange(StartLoc, Tok.getLocation());
801 Actions.ActOnPragmaDump(E.
get());
805 ExpectAndConsume(tok::eod);
808void Parser::HandlePragmaWeak() {
809 assert(Tok.is(tok::annot_pragma_weak));
810 SourceLocation PragmaLoc = ConsumeAnnotationToken();
811 Actions.ActOnPragmaWeakID(Tok.getIdentifierInfo(), PragmaLoc,
816void Parser::HandlePragmaWeakAlias() {
817 assert(Tok.is(tok::annot_pragma_weakalias));
818 SourceLocation PragmaLoc = ConsumeAnnotationToken();
819 IdentifierInfo *WeakName = Tok.getIdentifierInfo();
820 SourceLocation WeakNameLoc = Tok.getLocation();
822 IdentifierInfo *AliasName = Tok.getIdentifierInfo();
823 SourceLocation AliasNameLoc = Tok.getLocation();
825 Actions.ActOnPragmaWeakAlias(WeakName, AliasName, PragmaLoc,
826 WeakNameLoc, AliasNameLoc);
830void Parser::HandlePragmaRedefineExtname() {
831 assert(Tok.is(tok::annot_pragma_redefine_extname));
832 SourceLocation RedefLoc = ConsumeAnnotationToken();
833 IdentifierInfo *RedefName = Tok.getIdentifierInfo();
834 SourceLocation RedefNameLoc = Tok.getLocation();
836 IdentifierInfo *AliasName = Tok.getIdentifierInfo();
837 SourceLocation AliasNameLoc = Tok.getLocation();
839 Actions.ActOnPragmaRedefineExtname(RedefName, AliasName, RedefLoc,
840 RedefNameLoc, AliasNameLoc);
843void Parser::HandlePragmaFPContract() {
844 assert(Tok.is(tok::annot_pragma_fp_contract));
847 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
867 SourceLocation PragmaLoc = ConsumeAnnotationToken();
868 Actions.ActOnPragmaFPContract(PragmaLoc, FPC);
871void Parser::HandlePragmaFloatControl() {
872 assert(Tok.is(tok::annot_pragma_float_control));
883 SourceLocation PragmaLoc = ConsumeAnnotationToken();
884 Actions.ActOnPragmaFloatControl(PragmaLoc, Action, Kind);
887void Parser::HandlePragmaFEnvAccess() {
888 assert(Tok.is(tok::annot_pragma_fenv_access) ||
889 Tok.is(tok::annot_pragma_fenv_access_ms));
892 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
907 SourceLocation PragmaLoc = ConsumeAnnotationToken();
908 Actions.ActOnPragmaFEnvAccess(PragmaLoc, IsEnabled);
911void Parser::HandlePragmaFEnvRound() {
912 assert(Tok.is(tok::annot_pragma_fenv_round));
913 auto RM =
static_cast<llvm::RoundingMode
>(
914 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
916 SourceLocation PragmaLoc = ConsumeAnnotationToken();
917 Actions.ActOnPragmaFEnvRound(PragmaLoc, RM);
920void Parser::HandlePragmaCXLimitedRange() {
921 assert(Tok.is(tok::annot_pragma_cx_limited_range));
923 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
941 SourceLocation PragmaLoc = ConsumeAnnotationToken();
942 Actions.ActOnPragmaCXLimitedRange(PragmaLoc, Range);
947 assert(Tok.is(tok::annot_pragma_captured));
948 ConsumeAnnotationToken();
950 if (Tok.isNot(tok::l_brace)) {
951 PP.Diag(Tok, diag::err_expected) << tok::l_brace;
955 SourceLocation Loc = Tok.getLocation();
963 CapturedRegionScope.Exit();
966 Actions.ActOnCapturedRegionError();
970 return Actions.ActOnCapturedRegionEnd(
R.get());
974 enum OpenCLExtState :
char {
975 Disable, Enable, Begin, End
977 typedef std::pair<const IdentifierInfo *, OpenCLExtState> OpenCLExtData;
980void Parser::HandlePragmaOpenCLExtension() {
981 assert(Tok.is(tok::annot_pragma_opencl_extension));
982 OpenCLExtData *
Data =
static_cast<OpenCLExtData*
>(Tok.getAnnotationValue());
983 auto State =
Data->second;
984 auto Ident =
Data->first;
985 SourceLocation NameLoc = Tok.getLocation();
986 ConsumeAnnotationToken();
988 auto &Opt = Actions.getOpenCLOptions();
989 auto Name = Ident->getName();
994 if (State == Disable)
997 PP.Diag(NameLoc, diag::warn_pragma_expected_predicate) << 1;
998 }
else if (State == Begin) {
999 if (!Opt.isKnown(Name) || !Opt.isSupported(Name,
getLangOpts())) {
1003 Opt.acceptsPragma(Name);
1005 }
else if (State == End) {
1008 }
else if (!Opt.isKnown(Name) || !Opt.isWithPragma(Name))
1009 PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << Ident;
1010 else if (Opt.isSupportedExtension(Name,
getLangOpts()))
1011 Opt.enable(Name, State == Enable);
1012 else if (Opt.isSupportedCoreOrOptionalCore(Name,
getLangOpts()))
1013 PP.Diag(NameLoc, diag::warn_pragma_extension_is_core) << Ident;
1015 PP.Diag(NameLoc, diag::warn_pragma_unsupported_extension) << Ident;
1018void Parser::HandlePragmaMSPointersToMembers() {
1019 assert(Tok.is(tok::annot_pragma_ms_pointers_to_members));
1022 reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
1023 SourceLocation PragmaLoc = ConsumeAnnotationToken();
1024 Actions.ActOnPragmaMSPointersToMembers(RepresentationMethod, PragmaLoc);
1027void Parser::HandlePragmaMSVtorDisp() {
1028 assert(Tok.is(tok::annot_pragma_ms_vtordisp));
1033 SourceLocation PragmaLoc = ConsumeAnnotationToken();
1034 Actions.ActOnPragmaMSVtorDisp(Action, PragmaLoc, Mode);
1037void Parser::HandlePragmaMSPragma() {
1038 assert(Tok.is(tok::annot_pragma_ms_pragma));
1041 (std::pair<std::unique_ptr<Token[]>,
size_t> *)Tok.getAnnotationValue();
1042 PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second,
true,
1044 SourceLocation PragmaLocation = ConsumeAnnotationToken();
1045 assert(Tok.isAnyIdentifier());
1046 StringRef PragmaName = Tok.getIdentifierInfo()->getName();
1051 typedef bool (
Parser::*PragmaHandler)(StringRef, SourceLocation);
1052 PragmaHandler Handler =
1053 llvm::StringSwitch<PragmaHandler>(PragmaName)
1054 .Case(
"data_seg", &Parser::HandlePragmaMSSegment)
1055 .Case(
"bss_seg", &Parser::HandlePragmaMSSegment)
1056 .Case(
"const_seg", &Parser::HandlePragmaMSSegment)
1057 .Case(
"code_seg", &Parser::HandlePragmaMSSegment)
1058 .Case(
"section", &Parser::HandlePragmaMSSection)
1059 .Case(
"init_seg", &Parser::HandlePragmaMSInitSeg)
1060 .Case(
"strict_gs_check", &Parser::HandlePragmaMSStrictGuardStackCheck)
1061 .Case(
"function", &Parser::HandlePragmaMSFunction)
1062 .Case(
"alloc_text", &Parser::HandlePragmaMSAllocText)
1063 .Case(
"optimize", &Parser::HandlePragmaMSOptimize)
1064 .Case(
"intrinsic", &Parser::HandlePragmaMSIntrinsic);
1066 if (!(this->*Handler)(PragmaName, PragmaLocation)) {
1069 while (Tok.isNot(tok::eof))
1075bool Parser::HandlePragmaMSSection(StringRef PragmaName,
1077 if (Tok.isNot(tok::l_paren)) {
1078 PP.Diag(PragmaLocation, diag::warn_pragma_expected_lparen) << PragmaName;
1083 if (Tok.isNot(tok::string_literal)) {
1084 PP.Diag(PragmaLocation, diag::warn_pragma_expected_section_name)
1093 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1098 bool SectionFlagsAreDefault =
true;
1099 while (Tok.is(tok::comma)) {
1104 if (Tok.is(tok::kw_long) || Tok.is(tok::kw_short)) {
1109 if (!Tok.isAnyIdentifier()) {
1110 PP.Diag(PragmaLocation, diag::warn_pragma_expected_action_or_r_paren)
1115 llvm::StringSwitch<ASTContext::PragmaSectionFlag>(
1116 Tok.getIdentifierInfo()->getName())
1128 ? diag::warn_pragma_invalid_specific_action
1129 : diag::warn_pragma_unsupported_action)
1130 << PragmaName << Tok.getIdentifierInfo()->getName();
1133 SectionFlags |= Flag;
1134 SectionFlagsAreDefault =
false;
1139 if (SectionFlagsAreDefault)
1141 if (Tok.isNot(tok::r_paren)) {
1142 PP.Diag(PragmaLocation, diag::warn_pragma_expected_rparen) << PragmaName;
1146 if (Tok.isNot(tok::eof)) {
1147 PP.Diag(PragmaLocation, diag::warn_pragma_extra_tokens_at_eol)
1152 Actions.ActOnPragmaMSSection(PragmaLocation, SectionFlags, SegmentName);
1156bool Parser::HandlePragmaMSSegment(StringRef PragmaName,
1158 if (Tok.isNot(tok::l_paren)) {
1159 PP.Diag(PragmaLocation, diag::warn_pragma_expected_lparen) << PragmaName;
1164 StringRef SlotLabel;
1165 if (Tok.isAnyIdentifier()) {
1166 StringRef PushPop = Tok.getIdentifierInfo()->getName();
1167 if (PushPop ==
"push")
1169 else if (PushPop ==
"pop")
1172 PP.Diag(PragmaLocation,
1173 diag::warn_pragma_expected_section_push_pop_or_name)
1179 if (Tok.is(tok::comma)) {
1182 if (Tok.isAnyIdentifier()) {
1183 SlotLabel = Tok.getIdentifierInfo()->getName();
1185 if (Tok.is(tok::comma))
1187 else if (Tok.isNot(tok::r_paren)) {
1188 PP.Diag(PragmaLocation, diag::warn_pragma_expected_punc)
1193 }
else if (Tok.isNot(tok::r_paren)) {
1194 PP.Diag(PragmaLocation, diag::warn_pragma_expected_punc) << PragmaName;
1200 StringLiteral *SegmentName =
nullptr;
1201 if (Tok.isNot(tok::r_paren)) {
1202 if (Tok.isNot(tok::string_literal)) {
1204 diag::warn_pragma_expected_section_name :
1205 diag::warn_pragma_expected_section_label_or_name :
1206 diag::warn_pragma_expected_section_push_pop_or_name;
1207 PP.Diag(PragmaLocation, DiagID) << PragmaName;
1215 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1223 if (Tok.isNot(tok::r_paren)) {
1224 PP.Diag(PragmaLocation, diag::warn_pragma_expected_rparen) << PragmaName;
1228 if (Tok.isNot(tok::eof)) {
1229 PP.Diag(PragmaLocation, diag::warn_pragma_extra_tokens_at_eol)
1234 Actions.ActOnPragmaMSSeg(PragmaLocation, Action, SlotLabel,
1235 SegmentName, PragmaName);
1239bool Parser::HandlePragmaMSInitSeg(StringRef PragmaName,
1242 PP.Diag(PragmaLocation, diag::warn_pragma_init_seg_unsupported_target);
1246 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
1251 StringLiteral *SegmentName =
nullptr;
1252 if (Tok.isAnyIdentifier()) {
1253 auto *II = Tok.getIdentifierInfo();
1254 StringRef Section = llvm::StringSwitch<StringRef>(II->
getName())
1255 .Case(
"compiler",
"\".CRT$XCC\"")
1256 .Case(
"lib",
"\".CRT$XCL\"")
1257 .Case(
"user",
"\".CRT$XCU\"")
1260 if (!Section.empty()) {
1264 Toks[0].
setKind(tok::string_literal);
1272 }
else if (Tok.is(tok::string_literal)) {
1278 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1286 PP.Diag(PragmaLocation, diag::warn_pragma_expected_init_seg) << PragmaName;
1290 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
1292 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
1296 Actions.ActOnPragmaMSInitSeg(PragmaLocation, SegmentName);
1300bool Parser::HandlePragmaMSStrictGuardStackCheck(
1302 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
1307 if (Tok.is(tok::identifier)) {
1308 StringRef PushPop = Tok.getIdentifierInfo()->getName();
1309 if (PushPop ==
"push") {
1312 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_punc,
1315 }
else if (PushPop ==
"pop") {
1323 const IdentifierInfo *II = Tok.getIdentifierInfo();
1324 if (II && II->
isStr(
"off")) {
1327 }
else if (II && II->
isStr(
"on")) {
1331 PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_action)
1338 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
1342 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
1346 Actions.ActOnPragmaMSStrictGuardStackCheck(PragmaLocation, Action,
Value);
1350bool Parser::HandlePragmaMSAllocText(StringRef PragmaName,
1352 Token FirstTok = Tok;
1353 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
1358 if (Tok.is(tok::string_literal)) {
1364 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
1369 }
else if (Tok.is(tok::identifier)) {
1370 Section = Tok.getIdentifierInfo()->getName();
1373 PP.Diag(PragmaLocation, diag::warn_pragma_expected_section_name)
1378 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_comma,
1382 SmallVector<std::tuple<IdentifierInfo *, SourceLocation>> Functions;
1384 if (Tok.isNot(tok::identifier)) {
1385 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
1390 IdentifierInfo *II = Tok.getIdentifierInfo();
1391 Functions.emplace_back(II, Tok.getLocation());
1394 if (Tok.isNot(tok::comma))
1399 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
1401 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
1405 Actions.ActOnPragmaMSAllocText(FirstTok.
getLocation(), Section, Functions);
1410 assert(Tok.is(PragmaKind));
1412 StringRef PragmaName =
"export";
1414 using namespace clang::charinfo;
1415 auto *TheTokens =
static_cast<std::pair<std::unique_ptr<Token[]>,
size_t> *>(
1416 Tok.getAnnotationValue());
1417 PP.EnterTokenStream(std::move(TheTokens->first), TheTokens->second,
true,
1419 Tok.setAnnotationValue(
nullptr);
1420 ConsumeAnnotationToken();
1422 llvm::scope_exit OnReturn([
this]() {
1423 while (Tok.isNot(tok::eof))
1430 if (Tok.isNot(tok::l_paren)) {
1431 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen)
1437 if (Tok.isNot(tok::identifier)) {
1438 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_identifier)
1443 IdentifierInfo *IdentName = Tok.getIdentifierInfo();
1444 SourceLocation IdentNameLoc = Tok.getLocation();
1447 if (Tok.isNot(tok::r_paren)) {
1448 PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_rparen)
1454 Actions.ActOnPragmaExport(IdentName, IdentNameLoc,
getCurScope());
1457 if (Tok.is(tok::identifier) || Tok.is(tok::kw_export)) {
1458 PragmaName = Tok.getIdentifierInfo()->getName();
1459 if (PragmaName !=
"export")
1460 PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1462 }
else if (Tok.isNot(tok::eof)) {
1463 PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1467 }
while (Tok.isNot(tok::eof));
1471void Parser::HandlePragmaExport() {
1472 assert(Tok.is(tok::annot_pragma_export));
1474 zOSHandlePragmaHelper(tok::annot_pragma_export);
1479 std::string ClangLoopStr(
"clang loop ");
1482 return std::string(llvm::StringSwitch<StringRef>(Str)
1483 .Case(
"loop", ClangLoopStr)
1484 .Case(
"unroll_and_jam", Str)
1485 .Case(
"unroll", Str)
1489bool Parser::HandlePragmaLoopHint(
LoopHint &Hint) {
1490 assert(Tok.is(tok::annot_pragma_loop_hint));
1491 PragmaLoopHintInfo *Info =
1492 static_cast<PragmaLoopHintInfo *
>(Tok.getAnnotationValue());
1500 IdentifierInfo *OptionInfo = Info->
Option.
is(tok::identifier)
1506 llvm::ArrayRef<Token> Toks = Info->
Toks;
1511 llvm::StringSwitch<bool>(PragmaNameInfo->
getName())
1512 .Cases({
"unroll",
"nounroll",
"unroll_and_jam",
"nounroll_and_jam"},
1516 if (Toks.empty() && IsLoopHint) {
1517 ConsumeAnnotationToken();
1524 assert(!Toks.empty() &&
1525 "PragmaLoopHintInfo::Toks must contain at least one token.");
1528 bool OptionUnroll =
false;
1529 bool OptionUnrollAndJam =
false;
1530 bool OptionDistribute =
false;
1531 bool OptionPipelineDisabled =
false;
1532 bool OptionLICMDisabled =
false;
1533 bool StateOption =
false;
1535 OptionUnroll = OptionInfo->
isStr(
"unroll");
1536 OptionUnrollAndJam = OptionInfo->
isStr(
"unroll_and_jam");
1537 OptionDistribute = OptionInfo->
isStr(
"distribute");
1538 OptionPipelineDisabled = OptionInfo->
isStr(
"pipeline");
1539 OptionLICMDisabled = OptionInfo->
isStr(
"licm");
1540 StateOption = llvm::StringSwitch<bool>(OptionInfo->
getName())
1541 .Case(
"vectorize",
true)
1542 .Case(
"interleave",
true)
1543 .Case(
"vectorize_predicate",
true)
1545 OptionUnroll || OptionUnrollAndJam || OptionDistribute ||
1546 OptionPipelineDisabled || OptionLICMDisabled;
1549 bool AssumeSafetyArg = !OptionUnroll && !OptionUnrollAndJam &&
1550 !OptionDistribute && !OptionPipelineDisabled &&
1551 !OptionLICMDisabled;
1553 if (Toks[0].
is(tok::eof)) {
1554 ConsumeAnnotationToken();
1555 Diag(Toks[0].getLocation(), diag::err_pragma_loop_missing_argument)
1557 << (OptionUnroll || OptionUnrollAndJam)
1564 ConsumeAnnotationToken();
1565 SourceLocation StateLoc = Toks[0].getLocation();
1566 IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
1570 llvm::StringSwitch<bool>(StateInfo->
getName())
1571 .Case(
"disable",
true)
1572 .Case(
"enable", !OptionPipelineDisabled && !OptionLICMDisabled)
1573 .Case(
"full", OptionUnroll || OptionUnrollAndJam)
1574 .Case(
"assume_safety", AssumeSafetyArg)
1577 if (OptionPipelineDisabled || OptionLICMDisabled) {
1578 Diag(Toks[0].getLocation(), diag::err_pragma_pipeline_invalid_keyword);
1580 Diag(Toks[0].getLocation(), diag::err_pragma_invalid_keyword)
1581 << (OptionUnroll || OptionUnrollAndJam)
1586 if (Toks.size() > 2)
1587 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1589 Hint.
StateLoc =
new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1590 }
else if (OptionInfo && OptionInfo->
getName() ==
"vectorize_width") {
1591 PP.EnterTokenStream(Toks,
false,
1593 ConsumeAnnotationToken();
1595 SourceLocation StateLoc = Toks[0].getLocation();
1596 IdentifierInfo *StateInfo = Toks[0].getIdentifierInfo();
1597 StringRef IsScalableStr = StateInfo ? StateInfo->
getName() :
"";
1600 if (IsScalableStr ==
"scalable" || IsScalableStr ==
"fixed") {
1603 if (Toks.size() > 2) {
1604 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1606 while (Tok.isNot(tok::eof))
1610 Hint.
StateLoc =
new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1617 if (
R.isInvalid() && !Tok.is(tok::comma))
1618 Diag(Toks[0].getLocation(),
1619 diag::note_pragma_loop_invalid_vectorize_option);
1621 bool Arg2Error =
false;
1622 if (Tok.is(tok::comma)) {
1625 StateInfo = Tok.getIdentifierInfo();
1626 IsScalableStr = StateInfo ? StateInfo->
getName() :
"";
1628 if (IsScalableStr !=
"scalable" && IsScalableStr !=
"fixed") {
1629 Diag(Tok.getLocation(),
1630 diag::err_pragma_loop_invalid_vectorize_option);
1634 new (Actions.Context) IdentifierLoc(StateLoc, StateInfo);
1641 if (Tok.isNot(tok::eof)) {
1642 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1644 while (Tok.isNot(tok::eof))
1650 if (Arg2Error ||
R.isInvalid() ||
1651 Actions.CheckLoopHintExpr(
R.get(), Toks[0].getLocation(),
1660 PP.EnterTokenStream(Toks,
false,
1662 ConsumeAnnotationToken();
1667 if (Tok.isNot(tok::eof)) {
1668 Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
1670 while (Tok.isNot(tok::eof))
1676 if (
R.isInvalid() ||
1677 Actions.CheckLoopHintExpr(
R.get(), Toks[0].getLocation(),
1686 Info->
Toks.back().getLocation());
1691struct PragmaAttributeInfo {
1692 enum ActionType { Push,
Pop, Attribute };
1693 ParsedAttributes &Attributes;
1695 const IdentifierInfo *
Namespace =
nullptr;
1696 ArrayRef<Token> Tokens;
1698 PragmaAttributeInfo(ParsedAttributes &Attributes) : Attributes(Attributes) {}
1701#include "clang/Parse/AttrSubMatchRulesParserStringSwitches.inc"
1706 if (
Tok.is(tok::identifier))
1707 return Tok.getIdentifierInfo()->getName();
1715 using namespace attr;
1717#define ATTR_MATCH_RULE(Value, Spelling, IsAbstract) \
1720#include "clang/Basic/AttrSubMatchRulesList.inc"
1722 llvm_unreachable(
"Invalid attribute subject match rule");
1730 PRef.
Diag(SubRuleLoc,
1731 diag::err_pragma_attribute_expected_subject_sub_identifier)
1733 if (
const char *SubRules = validAttributeSubjectMatchSubRules(PrimaryRule))
1744 PRef.
Diag(SubRuleLoc, diag::err_pragma_attribute_unknown_subject_sub_rule)
1745 << SubRuleName << PrimaryRuleName;
1746 if (
const char *SubRules = validAttributeSubjectMatchSubRules(PrimaryRule))
1752bool Parser::ParsePragmaAttributeSubjectMatchRuleSet(
1760 if (AnyParens.expectAndConsume())
1768 Diag(Tok, diag::err_pragma_attribute_expected_subject_identifier);
1771 std::pair<std::optional<attr::SubjectMatchRule>,
1772 std::optional<attr::SubjectMatchRule> (*)(StringRef,
bool)>
1773 Rule = isAttributeSubjectMatchRule(Name);
1775 Diag(Tok, diag::err_pragma_attribute_unknown_subject_rule) << Name;
1783 if (
Parens.expectAndConsume())
1785 }
else if (
Parens.consumeOpen()) {
1786 if (!SubjectMatchRules
1788 std::make_pair(PrimaryRule, SourceRange(RuleLoc, RuleLoc)))
1790 Diag(RuleLoc, diag::err_pragma_attribute_duplicate_subject)
1793 RuleLoc, Tok.is(tok::comma) ? Tok.getLocation() : RuleLoc));
1794 LastMatchRuleEndLoc = RuleLoc;
1800 if (SubRuleName.empty()) {
1806 if (SubRuleName ==
"unless") {
1809 if (
Parens.expectAndConsume())
1812 if (SubRuleName.empty()) {
1817 auto SubRuleOrNone =
Rule.second(SubRuleName,
true);
1818 if (!SubRuleOrNone) {
1819 std::string SubRuleUnlessName =
"unless(" + SubRuleName.str() +
")";
1821 SubRuleUnlessName, SubRuleLoc);
1824 SubRule = *SubRuleOrNone;
1826 if (
Parens.consumeClose())
1829 auto SubRuleOrNone =
Rule.second(SubRuleName,
false);
1830 if (!SubRuleOrNone) {
1832 SubRuleName, Tok.getLocation());
1835 SubRule = *SubRuleOrNone;
1838 SourceLocation RuleEndLoc = Tok.getLocation();
1839 LastMatchRuleEndLoc = RuleEndLoc;
1840 if (
Parens.consumeClose())
1842 if (!SubjectMatchRules
1843 .insert(std::make_pair(SubRule, SourceRange(RuleLoc, RuleEndLoc)))
1845 Diag(RuleLoc, diag::err_pragma_attribute_duplicate_subject)
1848 RuleLoc, Tok.is(tok::comma) ? Tok.getLocation() : RuleEndLoc));
1854 if (AnyParens.consumeClose())
1863enum class MissingAttributeSubjectRulesRecoveryPoint {
1871MissingAttributeSubjectRulesRecoveryPoint
1872getAttributeSubjectRulesRecoveryPointForToken(
const Token &
Tok) {
1874 if (II->
isStr(
"apply_to"))
1875 return MissingAttributeSubjectRulesRecoveryPoint::ApplyTo;
1876 if (II->
isStr(
"any"))
1877 return MissingAttributeSubjectRulesRecoveryPoint::Any;
1879 if (
Tok.
is(tok::equal))
1880 return MissingAttributeSubjectRulesRecoveryPoint::Equals;
1881 return MissingAttributeSubjectRulesRecoveryPoint::None;
1889 MissingAttributeSubjectRulesRecoveryPoint Point,
Parser &PRef) {
1895 MissingAttributeSubjectRulesRecoveryPoint EndPoint =
1896 getAttributeSubjectRulesRecoveryPointForToken(PRef.
getCurToken());
1897 if (Point == MissingAttributeSubjectRulesRecoveryPoint::Comma)
1899 if (Point <= MissingAttributeSubjectRulesRecoveryPoint::ApplyTo &&
1900 EndPoint > MissingAttributeSubjectRulesRecoveryPoint::ApplyTo)
1901 FixIt +=
"apply_to";
1902 if (Point <= MissingAttributeSubjectRulesRecoveryPoint::Equals &&
1903 EndPoint > MissingAttributeSubjectRulesRecoveryPoint::Equals)
1906 if (EndPoint == MissingAttributeSubjectRulesRecoveryPoint::None) {
1913 Attribute.getMatchRules(PRef.
getLangOpts(), MatchRules);
1915 for (
const auto &Rule : MatchRules) {
1920 IsSupported[
Rule.first] =
true;
1922 IsMatchRuleAvailable &= IsSupported;
1924 if (IsMatchRuleAvailable.count() == 0) {
1930 bool NeedsComma =
false;
1932 if (!IsMatchRuleAvailable[I])
1946 if (FixItRange.getBegin() == FixItRange.getEnd())
1956void Parser::HandlePragmaAttribute() {
1957 assert(Tok.is(tok::annot_pragma_attribute) &&
1958 "Expected #pragma attribute annotation token");
1959 SourceLocation PragmaLoc = Tok.getLocation();
1960 auto *Info =
static_cast<PragmaAttributeInfo *
>(Tok.getAnnotationValue());
1961 if (Info->Action == PragmaAttributeInfo::Pop) {
1962 ConsumeAnnotationToken();
1963 Actions.ActOnPragmaAttributePop(PragmaLoc, Info->Namespace);
1967 assert((Info->Action == PragmaAttributeInfo::Push ||
1968 Info->Action == PragmaAttributeInfo::Attribute) &&
1969 "Unexpected #pragma attribute command");
1971 if (Info->Action == PragmaAttributeInfo::Push && Info->Tokens.empty()) {
1972 ConsumeAnnotationToken();
1973 Actions.ActOnPragmaAttributeEmptyPush(PragmaLoc, Info->Namespace);
1977 PP.EnterTokenStream(Info->Tokens,
false,
1979 ConsumeAnnotationToken();
1981 ParsedAttributes &Attrs = Info->Attributes;
1984 auto SkipToEnd = [
this]() {
1989 if ((Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) ||
1990 Tok.isRegularKeywordAttribute()) {
1992 SourceLocation EndLoc = Tok.getLocation();
1993 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
1994 }
else if (Tok.is(tok::kw___attribute)) {
1996 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
1999 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"("))
2004 if (Tok.is(tok::code_completion)) {
2007 Actions.CodeCompletion().CodeCompleteAttribute(
2014 if (Tok.isNot(tok::identifier)) {
2015 Diag(Tok, diag::err_pragma_attribute_expected_attribute_name);
2019 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
2022 if (Tok.isNot(tok::l_paren))
2023 Attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0,
2024 ParsedAttr::Form::GNU());
2026 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs,
nullptr,
2029 ParsedAttr::Form::GNU(),
2033 if (ExpectAndConsume(tok::r_paren))
2035 if (ExpectAndConsume(tok::r_paren))
2037 }
else if (Tok.is(tok::kw___declspec)) {
2038 ParseMicrosoftDeclSpecs(Attrs);
2040 Diag(Tok, diag::err_pragma_attribute_expected_attribute_syntax);
2041 if (Tok.getIdentifierInfo()) {
2045 Tok.getIdentifierInfo(),
nullptr,
2047 SourceLocation InsertStartLoc = Tok.getLocation();
2049 if (Tok.is(tok::l_paren)) {
2052 if (Tok.isNot(tok::r_paren))
2055 Diag(Tok, diag::note_pragma_attribute_use_attribute_kw)
2064 if (Attrs.
empty() || Attrs.
begin()->isInvalid()) {
2069 for (
const ParsedAttr &Attribute : Attrs) {
2070 if (!Attribute.isSupportedByPragmaAttribute()) {
2071 Diag(PragmaLoc, diag::err_pragma_attribute_unsupported_attribute)
2080 createExpectedAttributeSubjectRulesTokenDiagnostic(
2081 diag::err_expected, Attrs,
2082 MissingAttributeSubjectRulesRecoveryPoint::Comma, *
this)
2088 if (Tok.isNot(tok::identifier)) {
2089 createExpectedAttributeSubjectRulesTokenDiagnostic(
2090 diag::err_pragma_attribute_invalid_subject_set_specifier, Attrs,
2091 MissingAttributeSubjectRulesRecoveryPoint::ApplyTo, *
this);
2095 const IdentifierInfo *II = Tok.getIdentifierInfo();
2096 if (!II->
isStr(
"apply_to")) {
2097 createExpectedAttributeSubjectRulesTokenDiagnostic(
2098 diag::err_pragma_attribute_invalid_subject_set_specifier, Attrs,
2099 MissingAttributeSubjectRulesRecoveryPoint::ApplyTo, *
this);
2106 createExpectedAttributeSubjectRulesTokenDiagnostic(
2107 diag::err_expected, Attrs,
2108 MissingAttributeSubjectRulesRecoveryPoint::Equals, *
this)
2115 SourceLocation AnyLoc, LastMatchRuleEndLoc;
2116 if (ParsePragmaAttributeSubjectMatchRuleSet(SubjectMatchRules, AnyLoc,
2117 LastMatchRuleEndLoc)) {
2124 if (Tok.isNot(tok::eof)) {
2125 Diag(Tok, diag::err_pragma_attribute_extra_tokens_after_attribute);
2134 if (Info->Action == PragmaAttributeInfo::Push)
2135 Actions.ActOnPragmaAttributeEmptyPush(PragmaLoc, Info->Namespace);
2137 for (ParsedAttr &Attribute : Attrs) {
2138 Actions.ActOnPragmaAttributeAttribute(Attribute, PragmaLoc,
2146void PragmaGCCVisibilityHandler::HandlePragma(
Preprocessor &PP,
2157 if (PushPop && PushPop->
isStr(
"pop")) {
2159 }
else if (PushPop && PushPop->
isStr(
"push")) {
2192 auto Toks = std::make_unique<Token[]>(1);
2193 Toks[0].startToken();
2194 Toks[0].setKind(tok::annot_pragma_vis);
2195 Toks[0].setLocation(VisLoc);
2196 Toks[0].setAnnotationEndLoc(EndLoc);
2197 Toks[0].setAnnotationValue(
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)) {
2337 Toks[0].startToken();
2338 Toks[0].setKind(tok::annot_pragma_pack);
2339 Toks[0].setLocation(PackLoc);
2340 Toks[0].setAnnotationEndLoc(RParenLoc);
2341 Toks[0].setAnnotationValue(
static_cast<void*
>(Info));
2342 PP.EnterTokenStream(Toks,
true,
2348void PragmaMSStructHandler::HandlePragma(
Preprocessor &PP,
2350 Token &MSStructTok) {
2361 if (II->
isStr(
"on")) {
2365 else if (II->
isStr(
"off") || II->
isStr(
"reset"))
2380 Toks[0].startToken();
2381 Toks[0].setKind(tok::annot_pragma_msstruct);
2383 Toks[0].setAnnotationEndLoc(EndLoc);
2384 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
2386 PP.EnterTokenStream(Toks,
true,
2391void PragmaClangSectionHandler::HandlePragma(
Preprocessor &PP,
2393 Token &FirstToken) {
2401 PP.
Diag(
Tok.
getLocation(), diag::err_pragma_expected_clang_section_name) <<
"clang section";
2406 if (SecType->
isStr(
"bss"))
2408 else if (SecType->
isStr(
"data"))
2410 else if (SecType->
isStr(
"rodata"))
2412 else if (SecType->
isStr(
"relro"))
2414 else if (SecType->
isStr(
"text"))
2417 PP.
Diag(
Tok.
getLocation(), diag::err_pragma_expected_clang_section_name) <<
"clang section";
2429 std::string SecName;
2433 Actions.ActOnPragmaClangSection(PragmaLocation,
2450 if (
Tok.isNot(tok::identifier) ||
2451 !
Tok.getIdentifierInfo()->isStr(
"align")) {
2452 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_options_expected_align);
2459 if (
Tok.isNot(tok::l_paren)) {
2460 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_lparen) <<
"align";
2463 }
else if (
Tok.isNot(tok::equal)) {
2464 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_align_expected_equal)
2470 if (
Tok.isNot(tok::identifier)) {
2471 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_identifier)
2472 << (IsOptions ?
"options" :
"align");
2478 if (II->
isStr(
"native"))
2480 else if (II->
isStr(
"natural"))
2482 else if (II->
isStr(
"packed"))
2484 else if (II->
isStr(
"power"))
2486 else if (II->
isStr(
"mac68k"))
2488 else if (II->
isStr(
"reset"))
2491 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_align_invalid_option)
2498 if (
Tok.isNot(tok::r_paren)) {
2499 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_expected_rparen) <<
"align";
2506 if (
Tok.isNot(tok::eod)) {
2507 PP.
Diag(
Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
2508 << (IsOptions ?
"options" :
"align");
2514 Toks[0].startToken();
2515 Toks[0].setKind(tok::annot_pragma_align);
2517 Toks[0].setAnnotationEndLoc(EndLoc);
2518 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
2520 PP.EnterTokenStream(Toks,
true,
2530void PragmaOptionsHandler::HandlePragma(
Preprocessor &PP,
2532 Token &OptionsTok) {
2537void PragmaUnusedHandler::HandlePragma(
Preprocessor &PP,
2560 if (
Tok.
is(tok::identifier)) {
2561 Identifiers.push_back(
Tok);
2572 if (
Tok.
is(tok::comma)) {
2577 if (
Tok.
is(tok::r_paren)) {
2595 assert(RParenLoc.
isValid() &&
"Valid '#pragma unused' must have ')'");
2596 assert(!Identifiers.empty() &&
"Valid '#pragma unused' must have arguments");
2605 2 * Identifiers.size());
2606 for (
unsigned i=0; i != Identifiers.size(); i++) {
2607 Token &pragmaUnusedTok = Toks[2*i], &idTok = Toks[2*i+1];
2609 pragmaUnusedTok.
setKind(tok::annot_pragma_unused);
2611 idTok = Identifiers[i];
2613 PP.EnterTokenStream(Toks,
true,
2632 bool HasAlias =
false;
2636 if (
Tok.
is(tok::equal)) {
2656 Token &pragmaUnusedTok = Toks[0];
2658 pragmaUnusedTok.
setKind(tok::annot_pragma_weakalias);
2662 Toks[2] = AliasName;
2663 PP.EnterTokenStream(Toks,
true,
2668 Token &pragmaUnusedTok = Toks[0];
2670 pragmaUnusedTok.
setKind(tok::annot_pragma_weak);
2674 PP.EnterTokenStream(Toks,
true,
2680void PragmaRedefineExtnameHandler::HandlePragma(
Preprocessor &PP,
2682 Token &RedefToken) {
2698 <<
"redefine_extname";
2713 Token &pragmaRedefTok = Toks[0];
2715 pragmaRedefTok.
setKind(tok::annot_pragma_redefine_extname);
2718 Toks[1] = RedefName;
2719 Toks[2] = AliasName;
2720 PP.EnterTokenStream(Toks,
true,
2724void PragmaFPContractHandler::HandlePragma(
Preprocessor &PP,
2733 Toks[0].startToken();
2734 Toks[0].setKind(tok::annot_pragma_fp_contract);
2737 Toks[0].setAnnotationValue(
reinterpret_cast<void*
>(
2739 PP.EnterTokenStream(Toks,
true,
2743void PragmaOpenCLExtensionHandler::HandlePragma(
Preprocessor &PP,
2768 OpenCLExtState State;
2769 if (Pred->
isStr(
"enable")) {
2771 }
else if (Pred->
isStr(
"disable")) {
2773 }
else if (Pred->
isStr(
"begin"))
2775 else if (Pred->
isStr(
"end"))
2779 << Ext->
isStr(
"all");
2793 Info->second = State;
2796 Toks[0].startToken();
2797 Toks[0].setKind(tok::annot_pragma_opencl_extension);
2798 Toks[0].setLocation(NameLoc);
2799 Toks[0].setAnnotationValue(
static_cast<void*
>(Info));
2800 Toks[0].setAnnotationEndLoc(StateLoc);
2801 PP.EnterTokenStream(Toks,
true,
2811template <diag::kind IgnoredDiag>
2812void PragmaNoSupportHandler<IgnoredDiag>::HandlePragma(
2815 PP.
Diag(FirstTok, IgnoredDiag);
2826void PragmaSupportHandler<StartTok, EndTok, UnexpectedDiag>::HandlePragma(
2835 Pragma.push_back(
Tok);
2837 if (
Tok.
is(StartTok)) {
2838 PP.
Diag(
Tok, UnexpectedDiag) << 0;
2839 unsigned InnerPragmaCnt = 1;
2840 while (InnerPragmaCnt != 0) {
2842 if (
Tok.
is(StartTok))
2844 else if (
Tok.
is(EndTok))
2854 Pragma.push_back(
Tok);
2856 auto Toks = std::make_unique<Token[]>(Pragma.size());
2857 std::copy(Pragma.begin(), Pragma.end(), Toks.get());
2858 PP.EnterTokenStream(std::move(Toks), Pragma.size(),
2870void PragmaMSPointersToMembers::HandlePragma(
Preprocessor &PP,
2876 PP.
Diag(PointersToMembersLoc, diag::warn_pragma_expected_lparen)
2877 <<
"pointers_to_members";
2884 <<
"pointers_to_members";
2890 if (Arg->
isStr(
"best_case")) {
2893 if (Arg->
isStr(
"full_generality")) {
2894 if (
Tok.
is(tok::comma)) {
2900 diag::err_pragma_pointers_to_members_unknown_kind)
2905 }
else if (
Tok.
is(tok::r_paren)) {
2912 <<
"full_generality";
2918 if (Arg->
isStr(
"single_inheritance")) {
2919 RepresentationMethod =
2921 }
else if (Arg->
isStr(
"multiple_inheritance")) {
2922 RepresentationMethod =
2924 }
else if (Arg->
isStr(
"virtual_inheritance")) {
2925 RepresentationMethod =
2929 diag::err_pragma_pointers_to_members_unknown_kind)
2938 << (Arg ? Arg->
getName() :
"full_generality");
2946 <<
"pointers_to_members";
2952 AnnotTok.
setKind(tok::annot_pragma_ms_pointers_to_members);
2956 reinterpret_cast<void *
>(
static_cast<uintptr_t>(RepresentationMethod)));
2973 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_lparen) <<
"vtordisp";
2981 if (II->
isStr(
"push")) {
2985 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_punc) <<
"vtordisp";
2991 }
else if (II->
isStr(
"pop")) {
2998 if (
Tok.
is(tok::r_paren)) {
3008 if (II && II->
isStr(
"off")) {
3011 }
else if (II && II->
isStr(
"on")) {
3014 }
else if (
Tok.
is(tok::numeric_constant) &&
3018 << 0 << 2 <<
"vtordisp";
3030 PP.
Diag(VtorDispLoc, diag::warn_pragma_expected_rparen) <<
"vtordisp";
3044 AnnotTok.
setKind(tok::annot_pragma_ms_vtordisp);
3056 Token EoF, AnnotTok;
3060 AnnotTok.
setKind(tok::annot_pragma_ms_pragma);
3066 TokenVector.push_back(
Tok);
3070 TokenVector.push_back(EoF);
3073 markAsReinjectedForRelexing(TokenVector);
3074 auto TokenArray = std::make_unique<Token[]>(TokenVector.size());
3075 std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
3077 std::pair<std::unique_ptr<Token[]>,
size_t>(std::move(TokenArray),
3078 TokenVector.size());
3094void PragmaFloatControlHandler::HandlePragma(
Preprocessor &PP,
3107 PP.
Diag(FloatControlLoc, diag::err_expected) << tok::l_paren;
3121 llvm::StringSwitch<PragmaFloatControlKind>(II->
getName())
3139 if (
Tok.
is(tok::r_paren))
3152 if (PushOnOff ==
"on")
3155 else if (PushOnOff ==
"off") {
3160 }
else if (PushOnOff ==
"push") {
3167 if (
Tok.
is(tok::comma)) {
3174 if (ExpectedPush ==
"push") {
3199 auto TokenArray = std::make_unique<Token[]>(1);
3200 TokenArray[0].startToken();
3201 TokenArray[0].setKind(tok::annot_pragma_float_control);
3202 TokenArray[0].setLocation(FloatControlLoc);
3203 TokenArray[0].setAnnotationEndLoc(EndLoc);
3206 TokenArray[0].setAnnotationValue(
reinterpret_cast<void *
>(
3207 static_cast<uintptr_t>((Action << 16) | (Kind & 0xFFFF))));
3208 PP.EnterTokenStream(std::move(TokenArray), 1,
3222void PragmaDetectMismatchHandler::HandlePragma(
Preprocessor &PP,
3228 PP.
Diag(DetectMismatchLoc, diag::err_expected) << tok::l_paren;
3233 std::string NameString;
3235 "pragma detect_mismatch",
3240 std::string ValueString;
3266 Actions.ActOnPragmaDetectMismatch(DetectMismatchLoc, NameString, ValueString);
3280void PragmaCommentHandler::HandlePragma(
Preprocessor &PP,
3286 PP.
Diag(CommentLoc, diag::err_pragma_comment_malformed);
3293 PP.
Diag(CommentLoc, diag::err_pragma_comment_malformed);
3300 llvm::StringSwitch<PragmaMSCommentKind>(II->
getName())
3329 if (SeenCopyrightInTU) {
3335 SeenCopyrightInTU =
true;
3340 std::string ArgumentString;
3372 Actions.ActOnPragmaMSComment(CommentLoc, Kind, ArgumentString);
3377void PragmaOptimizeHandler::HandlePragma(
Preprocessor &PP,
3379 Token &FirstToken) {
3382 if (
Tok.
is(tok::eod)) {
3384 <<
"clang optimize" <<
true <<
"'on' or 'off'";
3395 if (II->
isStr(
"on")) {
3397 }
else if (!II->
isStr(
"off")) {
3410 Actions.ActOnPragmaOptimize(IsOn, FirstToken.
getLocation());
3415struct TokFPAnnotValue {
3416 enum FlagValues { On, Off, Fast };
3418 std::optional<LangOptions::FPModeKind> ContractValue;
3419 std::optional<LangOptions::FPModeKind> ReassociateValue;
3420 std::optional<LangOptions::FPModeKind> ReciprocalValue;
3421 std::optional<LangOptions::FPExceptionModeKind> ExceptionsValue;
3422 std::optional<LangOptions::FPEvalMethodKind> EvalMethodValue;
3440 while (
Tok.
is(tok::identifier)) {
3444 llvm::StringSwitch<std::optional<PragmaFPKind>>(OptionInfo->
getName())
3450 .Default(std::nullopt);
3453 <<
false << OptionInfo;
3464 bool isEvalMethodDouble =
3468 if (
Tok.
isNot(tok::identifier) && !isEvalMethodDouble) {
3471 <<
static_cast<int>(*FlagKind);
3477 AnnotValue->ContractValue =
3478 llvm::StringSwitch<std::optional<LangOptions::FPModeKind>>(
3483 .Default(std::nullopt);
3484 if (!AnnotValue->ContractValue) {
3491 : AnnotValue->ReciprocalValue;
3492 Value = llvm::StringSwitch<std::optional<LangOptions::FPModeKind>>(
3496 .Default(std::nullopt);
3503 AnnotValue->ExceptionsValue =
3504 llvm::StringSwitch<std::optional<LangOptions::FPExceptionModeKind>>(
3509 .Default(std::nullopt);
3510 if (!AnnotValue->ExceptionsValue) {
3516 AnnotValue->EvalMethodValue =
3517 llvm::StringSwitch<std::optional<LangOptions::FPEvalMethodKind>>(
3522 .Default(std::nullopt);
3523 if (!AnnotValue->EvalMethodValue) {
3547 FPTok.
setKind(tok::annot_pragma_fp);
3551 TokenList.push_back(FPTok);
3553 auto TokenArray = std::make_unique<Token[]>(TokenList.size());
3554 std::copy(TokenList.begin(), TokenList.end(), TokenArray.get());
3556 PP.EnterTokenStream(std::move(TokenArray), TokenList.size(),
3560void PragmaSTDC_FENV_ROUNDHandler::HandlePragma(
Preprocessor &PP,
3579 llvm::StringSwitch<llvm::RoundingMode>(II->
getName())
3580 .Case(
"FE_TOWARDZERO", llvm::RoundingMode::TowardZero)
3581 .Case(
"FE_TONEAREST", llvm::RoundingMode::NearestTiesToEven)
3582 .Case(
"FE_UPWARD", llvm::RoundingMode::TowardPositive)
3583 .Case(
"FE_DOWNWARD", llvm::RoundingMode::TowardNegative)
3584 .Case(
"FE_TONEARESTFROMZERO", llvm::RoundingMode::NearestTiesToAway)
3585 .Case(
"FE_DYNAMIC", llvm::RoundingMode::Dynamic)
3586 .Default(llvm::RoundingMode::Invalid);
3587 if (RM == llvm::RoundingMode::Invalid) {
3595 <<
"STDC FENV_ROUND";
3604 Toks[0].startToken();
3605 Toks[0].setKind(tok::annot_pragma_fenv_round);
3608 Toks[0].setAnnotationValue(
3609 reinterpret_cast<void *
>(
static_cast<uintptr_t>(RM)));
3610 PP.EnterTokenStream(Toks,
true,
3614void Parser::HandlePragmaFP() {
3615 assert(Tok.is(tok::annot_pragma_fp));
3617 reinterpret_cast<TokFPAnnotValue *
>(Tok.getAnnotationValue());
3619 if (AnnotValue->ReassociateValue)
3620 Actions.ActOnPragmaFPValueChangingOption(
3624 if (AnnotValue->ReciprocalValue)
3625 Actions.ActOnPragmaFPValueChangingOption(
3629 if (AnnotValue->ContractValue)
3630 Actions.ActOnPragmaFPContract(Tok.getLocation(),
3631 *AnnotValue->ContractValue);
3632 if (AnnotValue->ExceptionsValue)
3633 Actions.ActOnPragmaFPExceptions(Tok.getLocation(),
3634 *AnnotValue->ExceptionsValue);
3635 if (AnnotValue->EvalMethodValue)
3636 Actions.ActOnPragmaFPEvalMethod(Tok.getLocation(),
3637 *AnnotValue->EvalMethodValue);
3638 ConsumeAnnotationToken();
3643 Token Option,
bool ValueInParens,
3646 int OpenParens = ValueInParens ? 1 : 0;
3648 while (
Tok.isNot(tok::eod)) {
3649 if (
Tok.is(tok::l_paren))
3651 else if (
Tok.is(tok::r_paren)) {
3653 if (OpenParens == 0 && ValueInParens)
3661 if (ValueInParens) {
3663 if (
Tok.isNot(tok::r_paren)) {
3664 PP.
Diag(
Tok.getLocation(), diag::err_expected) << tok::r_paren;
3732void PragmaLoopHintHandler::HandlePragma(
Preprocessor &PP,
3747 while (
Tok.
is(tok::identifier)) {
3751 bool OptionValid = llvm::StringSwitch<bool>(OptionInfo->
getName())
3752 .Case(
"vectorize",
true)
3753 .Case(
"interleave",
true)
3754 .Case(
"unroll",
true)
3755 .Case(
"distribute",
true)
3756 .Case(
"vectorize_predicate",
true)
3757 .Case(
"vectorize_width",
true)
3758 .Case(
"interleave_count",
true)
3759 .Case(
"unroll_count",
true)
3760 .Case(
"pipeline",
true)
3761 .Case(
"pipeline_initiation_interval",
true)
3766 <<
false << OptionInfo;
3786 LoopHintTok.
setKind(tok::annot_pragma_loop_hint);
3790 TokenList.push_back(LoopHintTok);
3799 auto TokenArray = std::make_unique<Token[]>(TokenList.size());
3800 std::copy(TokenList.begin(), TokenList.end(), TokenArray.get());
3802 PP.EnterTokenStream(std::move(TokenArray), TokenList.size(),
3827void PragmaUnrollHintHandler::HandlePragma(
Preprocessor &PP,
3835 if (
Tok.
is(tok::eod)) {
3837 Info->PragmaName = PragmaName;
3838 Info->Option.startToken();
3848 bool ValueInParens =
Tok.
is(tok::l_paren);
3860 PP.
Diag(Info->Toks[0].getLocation(),
3861 diag::warn_pragma_unroll_cuda_value_in_parens);
3871 auto TokenArray = std::make_unique<Token[]>(1);
3872 TokenArray[0].startToken();
3873 TokenArray[0].setKind(tok::annot_pragma_loop_hint);
3874 TokenArray[0].setLocation(Introducer.
Loc);
3875 TokenArray[0].setAnnotationEndLoc(PragmaName.
getLocation());
3876 TokenArray[0].setAnnotationValue(
static_cast<void *
>(Info));
3877 PP.EnterTokenStream(std::move(TokenArray), 1,
3881bool Parser::HandlePragmaMSFunction(StringRef PragmaName,
3883 Token FirstTok = Tok;
3885 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3889 bool SuggestIntrinH = !PP.isMacroDefined(
"__INTRIN_H");
3891 llvm::SmallVector<StringRef> NoBuiltins;
3892 while (Tok.is(tok::identifier)) {
3893 IdentifierInfo *II = Tok.getIdentifierInfo();
3895 PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
3896 << II << SuggestIntrinH;
3898 NoBuiltins.emplace_back(II->
getName());
3901 if (Tok.isNot(tok::comma))
3906 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3908 ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3912 Actions.ActOnPragmaMSFunction(FirstTok.
getLocation(), NoBuiltins);
3916bool Parser::HandlePragmaMSOptimize(StringRef PragmaName,
3918 Token FirstTok = Tok;
3919 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3923 if (Tok.isNot(tok::string_literal)) {
3924 PP.Diag(PragmaLocation, diag::warn_pragma_expected_string) << PragmaName;
3932 PP.Diag(PragmaLocation, diag::warn_pragma_expected_non_wide_string)
3937 if (ExpectAndConsume(tok::comma, diag::warn_pragma_expected_comma,
3941 if (Tok.is(tok::eof) || Tok.is(tok::r_paren)) {
3942 PP.Diag(PragmaLocation, diag::warn_pragma_missing_argument)
3943 << PragmaName <<
true <<
"'on' or 'off'";
3946 IdentifierInfo *II = Tok.getIdentifierInfo();
3947 if (!II || (!II->
isStr(
"on") && !II->
isStr(
"off"))) {
3948 PP.Diag(PragmaLocation, diag::warn_pragma_invalid_argument)
3949 << PP.getSpelling(Tok) << PragmaName <<
true
3953 bool IsOn = II->
isStr(
"on");
3956 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
3961 if (!OptimizationList->
getString().empty()) {
3962 PP.Diag(PragmaLocation, diag::warn_pragma_invalid_argument)
3963 << OptimizationList->
getString() << PragmaName <<
true
3968 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
3972 Actions.ActOnPragmaMSOptimize(FirstTok.
getLocation(), IsOn);
3989bool Parser::HandlePragmaMSIntrinsic(StringRef PragmaName,
3991 if (ExpectAndConsume(tok::l_paren, diag::warn_pragma_expected_lparen,
3995 bool SuggestIntrinH = !PP.isMacroDefined(
"__INTRIN_H");
3997 while (Tok.is(tok::identifier)) {
3998 IdentifierInfo *II = Tok.getIdentifierInfo();
4000 PP.Diag(Tok.getLocation(), diag::warn_pragma_intrinsic_builtin)
4001 << II << SuggestIntrinH;
4003 DeclarationNameInfo NameInfo(II, Tok.getLocation());
4006 Actions.LookupName(
Previous, Actions.getCurScope(),
4009 Actions.LazilyCreateBuiltin(II, II->
getBuiltinID(), Actions.getCurScope(),
4010 true, Tok.getLocation());
4012 if (Tok.isNot(tok::comma))
4016 if (ExpectAndConsume(tok::r_paren, diag::warn_pragma_expected_rparen,
4020 if (ExpectAndConsume(tok::eof, diag::warn_pragma_extra_tokens_at_eol,
4026void PragmaForceCUDAHostDeviceHandler::HandlePragma(
4032 if (!Info || (!Info->
isStr(
"begin") && !Info->
isStr(
"end"))) {
4034 diag::warn_pragma_force_cuda_host_device_bad_arg);
4038 if (Info->
isStr(
"begin"))
4039 Actions.CUDA().PushForceHostDevice();
4040 else if (!Actions.CUDA().PopForceHostDevice())
4042 diag::err_pragma_cannot_end_force_cuda_host_device);
4045 if (!
Tok.
is(tok::eod))
4047 diag::warn_pragma_force_cuda_host_device_bad_arg);
4077void PragmaAttributeHandler::HandlePragma(
Preprocessor &PP,
4079 Token &FirstToken) {
4083 PragmaAttributeInfo(AttributesForPragmaAttribute);
4086 if (
Tok.
is(tok::identifier)) {
4088 if (!II->
isStr(
"push") && !II->
isStr(
"pop")) {
4089 Info->Namespace = II;
4092 if (!
Tok.
is(tok::period)) {
4101 if (!
Tok.
isOneOf(tok::identifier, tok::l_paren)) {
4103 diag::err_pragma_attribute_expected_push_pop_paren);
4108 if (
Tok.
is(tok::l_paren)) {
4109 if (Info->Namespace) {
4111 diag::err_pragma_attribute_namespace_on_attribute);
4113 diag::note_pragma_attribute_namespace_on_attribute);
4116 Info->Action = PragmaAttributeInfo::Attribute;
4119 if (II->
isStr(
"push"))
4120 Info->Action = PragmaAttributeInfo::Push;
4121 else if (II->
isStr(
"pop"))
4122 Info->Action = PragmaAttributeInfo::Pop;
4133 if ((Info->Action == PragmaAttributeInfo::Push &&
Tok.
isNot(tok::eod)) ||
4134 Info->Action == PragmaAttributeInfo::Attribute) {
4145 if (
Tok.
is(tok::l_paren))
4147 else if (
Tok.
is(tok::r_paren)) {
4149 if (OpenParens == 0)
4153 AttributeTokens.push_back(
Tok);
4157 if (AttributeTokens.empty()) {
4173 AttributeTokens.push_back(EOFTok);
4175 markAsReinjectedForRelexing(AttributeTokens);
4182 <<
"clang attribute";
4185 auto TokenArray = std::make_unique<Token[]>(1);
4186 TokenArray[0].startToken();
4187 TokenArray[0].setKind(tok::annot_pragma_attribute);
4188 TokenArray[0].setLocation(FirstToken.
getLocation());
4189 TokenArray[0].setAnnotationEndLoc(FirstToken.
getLocation());
4190 TokenArray[0].setAnnotationValue(
static_cast<void *
>(Info));
4191 PP.EnterTokenStream(std::move(TokenArray), 1,
4196void PragmaMaxTokensHereHandler::HandlePragma(
Preprocessor &PP,
4200 if (
Tok.
is(tok::eod)) {
4202 <<
"clang max_tokens_here" <<
true <<
"integer";
4208 if (
Tok.
isNot(tok::numeric_constant) ||
4211 <<
"clang max_tokens_here";
4217 <<
"clang max_tokens_here";
4222 PP.
Diag(Loc, diag::warn_max_tokens)
4228void PragmaMaxTokensTotalHandler::HandlePragma(
Preprocessor &PP,
4232 if (
Tok.
is(tok::eod)) {
4234 <<
"clang max_tokens_total" <<
true <<
"integer";
4240 if (
Tok.
isNot(tok::numeric_constant) ||
4243 <<
"clang max_tokens_total";
4249 <<
"clang max_tokens_total";
4265 for (;
Tok.isNot(tok::eod); PP.
Lex(
Tok)) {
4266 TokenVector.push_back(
Tok);
4274 TokenVector.push_back(EoF);
4277 markAsReinjectedForRelexing(TokenVector);
4278 auto TokenArray = std::make_unique<Token[]>(TokenVector.size());
4279 std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
4281 std::pair<std::unique_ptr<Token[]>,
size_t>(std::move(TokenArray),
4282 TokenVector.size());
4288void PragmaExportHandler::HandlePragma(
Preprocessor &PP,
4290 Token &FirstToken) {
4299 Token &FirstToken) {
4304 if (!II || !II->
isStr(
"intrinsic")) {
4312 if (!II || !(II->
isStr(
"vector") || II->
isStr(
"sifive_vector") ||
4313 II->
isStr(
"andes_vector"))) {
4316 <<
"'vector', 'sifive_vector' or 'andes_vector'";
4323 <<
"clang riscv intrinsic";
4327 if (II->
isStr(
"vector"))
4328 Actions.RISCV().DeclareRVVBuiltins =
true;
4329 else if (II->
isStr(
"sifive_vector"))
4330 Actions.RISCV().DeclareSiFiveVectorBuiltins =
true;
4331 else if (II->
isStr(
"andes_vector"))
4332 Actions.RISCV().DeclareAndesVectorBuiltins =
true;
Defines the clang::ASTContext interface.
static StringRef getTriple(const Command &Job)
static void ParseAlignPragma(Preprocessor &PP, Token &FirstTok, bool IsOptions)
static void diagnoseUnknownAttributeSubjectSubRule(Parser &PRef, attr::SubjectMatchRule PrimaryRule, StringRef PrimaryRuleName, StringRef SubRuleName, SourceLocation SubRuleLoc)
static void zOSPragmaHandlerHelper(Preprocessor &PP, Token &Tok, tok::TokenKind TokKind)
static bool ParseLoopHintValue(Preprocessor &PP, Token &Tok, Token PragmaName, Token Option, bool ValueInParens, PragmaLoopHintInfo &Info)
Parses loop or unroll pragma hint value and fills in Info.
static void diagnoseExpectedAttributeSubjectSubRule(Parser &PRef, attr::SubjectMatchRule PrimaryRule, StringRef PrimaryRuleName, SourceLocation SubRuleLoc)
static bool isAbstractAttrMatcherRule(attr::SubjectMatchRule Rule)
static StringRef getIdentifier(const Token &Tok)
static std::string PragmaLoopHintString(Token PragmaName, Token Option)
Defines the clang::Preprocessor interface.
ArrayRef< SVal > ValueList
@ NotForRedeclaration
The lookup is a reference to this name that is not for the purpose of redeclaring the name.
This file declares semantic analysis for CUDA constructs.
This file declares facilities that support code completion.
This file declares semantic analysis functions specific to RISC-V.
Kind getParsedKind() const
static CharSourceRange getCharRange(SourceRange R)
A little helper class used to produce diagnostics.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
void setSeverity(diag::kind Diag, diag::Severity Map, SourceLocation Loc)
This allows the client to specify that certain warnings are ignored.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
EmptyPragmaHandler - A pragma handler which takes no action, which can be used to ignore particular p...
bool isTypeDependent() const
Determines whether the type of this expression depends on.
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
ExprDependence getDependence() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
One of these records is kept for each identifier that is lexed.
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
@ FEM_Extended
Use extended type for fp arithmetic.
@ FEM_Double
Use the type double for fp arithmetic.
@ FEM_Source
Use the declared type for fp arithmetic.
ComplexRangeKind
Controls the various implementations for complex multiplication and.
@ CX_Full
Implementation of complex division and multiplication using a call to runtime library functions(gener...
@ CX_Basic
Implementation of complex division and multiplication using algebraic formulas at source precision.
PragmaMSPointersToMembersKind
@ PPTMK_FullGeneralityMultipleInheritance
@ PPTMK_FullGeneralityVirtualInheritance
@ PPTMK_FullGeneralitySingleInheritance
@ FPE_Strict
Strictly preserve the floating-point exception semantics.
@ FPE_MayTrap
Transformations do not cause new exceptions but may hide some.
@ FPE_Ignore
Assume that floating-point exceptions are masked.
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, StringRef Str)
Callback invoked when a #pragma comment directive is read.
virtual void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, SourceLocation StateLoc, unsigned State)
Called when an OpenCL extension is either disabled or enabled with a pragma.
virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name, StringRef Value)
Callback invoked when a #pragma detect_mismatch directive is read.
ParsedAttr - Represents a syntactic attribute.
ParsedAttributes - A collection of parsed attributes.
ParsedAttr * addNew(IdentifierInfo *attrName, SourceRange attrRange, AttributeScopeInfo scope, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
ParseScope - Introduces a new scope for parsing.
Parser - This implements a parser for the C family of languages.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation getEndOfPreviousToken() const
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
ParseStringLiteralExpression - This handles the various token types that form string literals,...
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies)
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
const TargetInfo & getTargetInfo() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
const Token & getCurToken() const
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
friend class BalancedDelimiterTracker
PragmaHandler - Instances of this interface defined to handle the various pragmas that the language f...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
PPCallbacks * getPPCallbacks() const
SourceRange DiscardUntilEndOfDirective(SmallVectorImpl< Token > *DiscardedToks=nullptr)
Read and discard all tokens remaining on the current line until the tok::eod token is found.
void overrideMaxTokens(unsigned Value, SourceLocation Loc)
void Lex(Token &Result)
Lex the next token for this preprocessor.
bool LexOnOffSwitch(tok::OnOffSwitch &Result)
Lex an on-off-switch (C99 6.10.6p2) and verify that it is followed by EOD.
unsigned getTokenCount() const
Get the number of tokens processed so far.
const TargetInfo & getTargetInfo() const
bool parseSimpleIntegerLiteral(Token &Tok, uint64_t &Value)
Parses a simple integer literal to get its numeric value.
void LexUnexpandedToken(Token &Result)
Just like Lex, but disables macro expansion of identifier tokens.
llvm::BumpPtrAllocator & getPreprocessorAllocator()
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
bool LexStringLiteral(Token &Result, std::string &String, const char *DiagnosticTag, bool AllowMacroExpansion)
Lex a string literal, which may be the concatenation of multiple string literals and may even come fr...
@ CompoundStmtScope
This is a compound statement scope.
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ DeclScope
This is a scope that can contain a declaration.
Sema - This implements semantic analysis and AST building for C.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
unsigned getLength() const
StringRef getString() const
unsigned getCharByteWidth() const
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual bool hasStrictFP() const
Determine whether constrained floating point is supported on this target.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
void setLiteralData(const char *Ptr)
bool isAnyIdentifier() const
Return true if this is a raw identifier (when lexing in raw mode) or a non-keyword identifier (when l...
void setAnnotationEndLoc(SourceLocation L)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
tok::TokenKind getKind() const
bool isOneOf(Ts... Ks) const
void setLocation(SourceLocation L)
bool isNot(tok::TokenKind K) const
void setAnnotationValue(void *val)
void startToken()
Reset all flags to cleared.
Defines the clang::TargetInfo interface.
SubjectMatchRule
A list of all the recognized kinds of attributes.
const char * getSubjectMatchRuleSpelling(SubjectMatchRule Rule)
llvm::DenseMap< int, SourceRange > ParsedSubjectMatchRuleSet
uint32_t Literal
Literals are represented as positive integers.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
@ Ignored
Do not present this diagnostic, ignore it.
@ FixIt
Parse and apply any fixits to the source.
const Regex Rule("(.+)/(.+)\\.framework/")
bool Pop(InterpState &S, CodePtr OpPC)
const char * getKeywordSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple keyword and contextual keyword tokens like 'int' and 'dynamic_cast'...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
OnOffSwitch
Defines the possible values of an on-off-switch (C99 6.10.6p2).
The JSON file list parser is used to communicate input to InstallAPI.
@ Default
Set to the current date and time.
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