[PATCH] D42248: [LangOpts] Add a LangOpt to represent "#pragma region" support.
Matt Davis via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 18 10:05:40 PST 2018
mattd created this revision.
mattd added reviewers: rnk, rsmith.
Both MS and PS4 targets are capable of recognizing the
existence of: #pragma region, #pragma endregion.
This patch adds a LangOpt and sets the value based on target
information or MS compatibility. In the case of PS4 or MS we
should avoid emitting "unknown pragma" warnings for regions.
This change prevents that situation.
https://reviews.llvm.org/D42248
Files:
include/clang/Basic/LangOptions.def
lib/Frontend/CompilerInvocation.cpp
lib/Lex/Pragma.cpp
test/Frontend/region-pragmas.c
Index: test/Frontend/region-pragmas.c
===================================================================
--- test/Frontend/region-pragmas.c
+++ test/Frontend/region-pragmas.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-scei-ps4 -Wall -verify %s
+// RUN: %clang_cc1 -fms-compatibility -Wall -verify %s
+// RUN: %clang_cc1 -Wall -Wno-unknown-pragmas -verify %s
+// expected-no-diagnostics
+
+#pragma region foo
+#pragma endregion foo
Index: lib/Lex/Pragma.cpp
===================================================================
--- lib/Lex/Pragma.cpp
+++ lib/Lex/Pragma.cpp
@@ -1781,6 +1781,10 @@
if (LangOpts.MicrosoftExt) {
AddPragmaHandler(new PragmaWarningHandler());
AddPragmaHandler(new PragmaIncludeAliasHandler());
+ }
+
+ // Region support.
+ if (LangOpts.MicrosoftPragmaRegion) {
AddPragmaHandler(new PragmaRegionHandler("region"));
AddPragmaHandler(new PragmaRegionHandler("endregion"));
}
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2160,6 +2160,7 @@
Opts.MSVCCompat = Args.hasArg(OPT_fms_compatibility);
Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
+ Opts.MicrosoftPragmaRegion = Opts.MicrosoftExt || T.isPS4();
Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
Opts.MSCompatibilityVersion = 0;
if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
Index: include/clang/Basic/LangOptions.def
===================================================================
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -85,6 +85,7 @@
LANGOPT(C17 , 1, 0, "C17")
LANGOPT(MSVCCompat , 1, 0, "Microsoft Visual C++ full compatibility mode")
LANGOPT(MicrosoftExt , 1, 0, "Microsoft C++ extensions")
+BENIGN_LANGOPT(MicrosoftPragmaRegion, 1, 0, "region pragma support")
LANGOPT(AsmBlocks , 1, 0, "Microsoft inline asm blocks")
LANGOPT(Borland , 1, 0, "Borland extensions")
LANGOPT(CPlusPlus , 1, 0, "C++")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42248.130434.patch
Type: text/x-patch
Size: 2158 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180118/a9573c2b/attachment.bin>
More information about the cfe-commits
mailing list