|
@@ -220,6 +220,12 @@ struct PragmaMSIntrinsicHandler : public PragmaHandler {
|
|
|
Token &FirstToken) override;
|
|
|
};
|
|
|
|
|
|
+struct PragmaMSOptimizeHandler : public PragmaHandler {
|
|
|
+ PragmaMSOptimizeHandler() : PragmaHandler("optimize") {}
|
|
|
+ void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
|
|
|
+ Token &FirstToken) override;
|
|
|
+};
|
|
|
+
|
|
|
struct PragmaForceCUDAHostDeviceHandler : public PragmaHandler {
|
|
|
PragmaForceCUDAHostDeviceHandler(Sema &Actions)
|
|
|
: PragmaHandler("force_cuda_host_device"), Actions(Actions) {}
|
|
@@ -324,6 +330,8 @@ void Parser::initializePragmaHandlers() {
|
|
|
PP.AddPragmaHandler(MSRuntimeChecks.get());
|
|
|
MSIntrinsic.reset(new PragmaMSIntrinsicHandler());
|
|
|
PP.AddPragmaHandler(MSIntrinsic.get());
|
|
|
+ MSOptimize.reset(new PragmaMSOptimizeHandler());
|
|
|
+ PP.AddPragmaHandler(MSOptimize.get());
|
|
|
}
|
|
|
|
|
|
if (getLangOpts().CUDA) {
|
|
@@ -410,6 +418,8 @@ void Parser::resetPragmaHandlers() {
|
|
|
MSRuntimeChecks.reset();
|
|
|
PP.RemovePragmaHandler(MSIntrinsic.get());
|
|
|
MSIntrinsic.reset();
|
|
|
+ PP.RemovePragmaHandler(MSOptimize.get());
|
|
|
+ MSOptimize.reset();
|
|
|
}
|
|
|
|
|
|
if (getLangOpts().CUDA) {
|
|
@@ -2949,6 +2959,61 @@ void PragmaMSIntrinsicHandler::HandlePragma(Preprocessor &PP,
|
|
|
PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
|
|
|
<< "intrinsic";
|
|
|
}
|
|
|
+
|
|
|
+// #pragma optimize("gsty", on|off)
|
|
|
+void PragmaMSOptimizeHandler::HandlePragma(Preprocessor &PP,
|
|
|
+ PragmaIntroducerKind Introducer,
|
|
|
+ Token &Tok) {
|
|
|
+ SourceLocation StartLoc = Tok.getLocation();
|
|
|
+ PP.Lex(Tok);
|
|
|
+
|
|
|
+ if (Tok.isNot(tok::l_paren)) {
|
|
|
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_lparen) << "optimize";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PP.Lex(Tok);
|
|
|
+
|
|
|
+ if (Tok.isNot(tok::string_literal)) {
|
|
|
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_string) << "optimize";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // We could syntax check the string but it's probably not worth the effort.
|
|
|
+ PP.Lex(Tok);
|
|
|
+
|
|
|
+ if (Tok.isNot(tok::comma)) {
|
|
|
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_comma) << "optimize";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PP.Lex(Tok);
|
|
|
+
|
|
|
+ if (Tok.is(tok::eod) || Tok.is(tok::r_paren)) {
|
|
|
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_missing_argument)
|
|
|
+ << "optimize" << /*Expected=*/true << "'on' or 'off'";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ IdentifierInfo *II = Tok.getIdentifierInfo();
|
|
|
+ if (!II || (!II->isStr("on") && !II->isStr("off"))) {
|
|
|
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
|
|
|
+ << PP.getSpelling(Tok) << "optimize" << /*Expected=*/true
|
|
|
+ << "'on' or 'off'";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PP.Lex(Tok);
|
|
|
+
|
|
|
+ if (Tok.isNot(tok::r_paren)) {
|
|
|
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_expected_rparen) << "optimize";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PP.Lex(Tok);
|
|
|
+
|
|
|
+ if (Tok.isNot(tok::eod)) {
|
|
|
+ PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol)
|
|
|
+ << "optimize";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ PP.Diag(StartLoc, diag::warn_pragma_optimize);
|
|
|
+}
|
|
|
+
|
|
|
void PragmaForceCUDAHostDeviceHandler::HandlePragma(
|
|
|
Preprocessor &PP, PragmaIntroducerKind Introducer, Token &Tok) {
|
|
|
Token FirstTok = Tok;
|