|
14 | 14 | #include "clang/Basic/PragmaKinds.h"
|
15 | 15 | #include "clang/Basic/TargetInfo.h"
|
16 | 16 | #include "clang/Lex/Preprocessor.h"
|
| 17 | +#include "clang/Lex/PreprocessorOptions.h" |
17 | 18 | #include "clang/Lex/Token.h"
|
18 | 19 | #include "clang/Parse/LoopHint.h"
|
19 | 20 | #include "clang/Parse/ParseDiagnostic.h"
|
@@ -411,6 +412,19 @@ struct PragmaRISCVHandler : public PragmaHandler {
|
411 | 412 | Sema &Actions;
|
412 | 413 | };
|
413 | 414 |
|
| 415 | +struct PragmaMCFuncHandler : public PragmaHandler { |
| 416 | + PragmaMCFuncHandler(bool ReportError) |
| 417 | + : PragmaHandler("mc_func"), ReportError(ReportError) {} |
| 418 | + void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer, |
| 419 | + Token &Tok) override { |
| 420 | + if (ReportError) |
| 421 | + PP.Diag(Tok, diag::err_pragma_mc_func_not_supported); |
| 422 | + } |
| 423 | + |
| 424 | +private: |
| 425 | + bool ReportError = false; |
| 426 | +}; |
| 427 | + |
414 | 428 | void markAsReinjectedForRelexing(llvm::MutableArrayRef<clang::Token> Toks) {
|
415 | 429 | for (auto &T : Toks)
|
416 | 430 | T.setFlag(clang::Token::IsReinjected);
|
@@ -568,6 +582,12 @@ void Parser::initializePragmaHandlers() {
|
568 | 582 | RISCVPragmaHandler = std::make_unique<PragmaRISCVHandler>(Actions);
|
569 | 583 | PP.AddPragmaHandler("clang", RISCVPragmaHandler.get());
|
570 | 584 | }
|
| 585 | + |
| 586 | + if (getTargetInfo().getTriple().isOSAIX()) { |
| 587 | + MCFuncPragmaHandler = std::make_unique<PragmaMCFuncHandler>( |
| 588 | + PP.getPreprocessorOpts().ErrorOnPragmaMcfuncOnAIX); |
| 589 | + PP.AddPragmaHandler(MCFuncPragmaHandler.get()); |
| 590 | + } |
571 | 591 | }
|
572 | 592 |
|
573 | 593 | void Parser::resetPragmaHandlers() {
|
@@ -702,6 +722,11 @@ void Parser::resetPragmaHandlers() {
|
702 | 722 | PP.RemovePragmaHandler("clang", RISCVPragmaHandler.get());
|
703 | 723 | RISCVPragmaHandler.reset();
|
704 | 724 | }
|
| 725 | + |
| 726 | + if (getTargetInfo().getTriple().isOSAIX()) { |
| 727 | + PP.RemovePragmaHandler(MCFuncPragmaHandler.get()); |
| 728 | + MCFuncPragmaHandler.reset(); |
| 729 | + } |
705 | 730 | }
|
706 | 731 |
|
707 | 732 | /// Handle the annotation token produced for #pragma unused(...)
|
|
0 commit comments