aboutsummaryrefslogtreecommitdiff
path: root/clang
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2022-04-13 16:58:00 -0700
committerFangrui Song <i@maskray.me>2022-04-13 16:58:00 -0700
commitab8abeaf48abb3addcbdb6136b1975b4afa3b37c (patch)
tree36e96688cf8446c7d63a885890a3e981d23375e5 /clang
parentd3531fc7f0053a7fe68317521ee6491da6e36733 (diff)
downloadllvm-ab8abeaf48abb3addcbdb6136b1975b4afa3b37c.zip
llvm-ab8abeaf48abb3addcbdb6136b1975b4afa3b37c.tar.gz
llvm-ab8abeaf48abb3addcbdb6136b1975b4afa3b37c.tar.bz2
[Driver] Change CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL to affect driver default instead of cc1 default
The current cc1 CLANG_ENABLE_OPAQUE_POINTERS=on default difference is not ideal in that people contribute %clang_cc1 tests may assume the default ON behavior, which will cause failures on systems set to OFF. cc1 option default dependent on CMake options should be used prudently (generally avoided). We prefer to limit target differences to Driver. Change the CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL mechanism introduced in D123122 to use a driver default instead. This is similar to the mechanism used for the -flegacy-pass-manager transition to new PM transition. Reviewed By: #opaque-pointers, rsmith, aeubanks Differential Revision: https://reviews.llvm.org/D123744
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Driver/Options.td2
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp4
-rw-r--r--clang/test/CMakeLists.txt1
-rw-r--r--clang/test/Driver/opaque-pointers-off.c11
-rw-r--r--clang/test/Driver/rewrite-legacy-objc.m6
-rw-r--r--clang/test/Driver/rewrite-objc.m2
-rw-r--r--clang/test/lit.cfg.py3
-rw-r--r--clang/test/lit.site.cfg.py.in1
8 files changed, 25 insertions, 5 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 483f0cc..87b5ef2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5533,7 +5533,7 @@ defm enable_noundef_analysis : BoolOption<"",
defm opaque_pointers : BoolOption<"",
"opaque-pointers",
CodeGenOpts<"OpaquePointers">,
- Default<"CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL">,
+ DefaultTrue,
PosFlag<SetTrue, [], "Enable">,
NegFlag<SetFalse, [], "Disable">,
BothFlags<[], " opaque pointers">>;
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 97b2ded..5cba45d 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -29,6 +29,7 @@
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Distro.h"
#include "clang/Driver/DriverDiagnostic.h"
@@ -6506,6 +6507,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
false))
CmdArgs.push_back("-fmodules-debuginfo");
+ if (!CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL)
+ CmdArgs.push_back("-no-opaque-pointers");
+
ObjCRuntime Runtime = AddObjCRuntimeArgs(Args, Inputs, CmdArgs, rewriteKind);
RenderObjCOptions(TC, D, RawTriple, Args, Runtime, rewriteKind != RK_None,
Input, CmdArgs);
diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 7d050b2..9e8fa9c 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -4,6 +4,7 @@
llvm_canonicalize_cmake_booleans(
CLANG_BUILD_EXAMPLES
CLANG_DEFAULT_PIE_ON_LINUX
+ CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL
CLANG_ENABLE_ARCMT
CLANG_ENABLE_STATIC_ANALYZER
CLANG_PLUGIN_SUPPORT
diff --git a/clang/test/Driver/opaque-pointers-off.c b/clang/test/Driver/opaque-pointers-off.c
new file mode 100644
index 0000000..d498c1a
--- /dev/null
+++ b/clang/test/Driver/opaque-pointers-off.c
@@ -0,0 +1,11 @@
+// UNSUPPORTED: enable-opaque-pointers
+/// Test -DCLANG_ENABLE_OPAQUE_POINTERS=OFF.
+
+// RUN: %clang -### --target=aarch64-linux-gnu %s 2>&1 | FileCheck %s
+/// User -Xclang -opaque-pointers overrides the default.
+// RUN: %clang -### --target=aarch64-linux-gnu -Xclang -opaque-pointers %s 2>&1 | FileCheck %s --check-prefix=CHECK2
+
+// CHECK: "-no-opaque-pointers"
+
+// CHECK2: "-no-opaque-pointers"
+// CHECK2-SAME: "-opaque-pointers"
diff --git a/clang/test/Driver/rewrite-legacy-objc.m b/clang/test/Driver/rewrite-legacy-objc.m
index fb7df4b..3fd35b1 100644
--- a/clang/test/Driver/rewrite-legacy-objc.m
+++ b/clang/test/Driver/rewrite-legacy-objc.m
@@ -3,11 +3,11 @@
// TEST0: clang{{.*}}" "-cc1"
// TEST0: "-rewrite-objc"
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
+// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
// TEST0: rewrite-legacy-objc.m"
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
// RUN: FileCheck -check-prefix=TEST1 %s
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
// RUN: FileCheck -check-prefix=TEST2 %s
-// TEST1: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
-// TEST2: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
+// TEST1: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
+// TEST2: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
diff --git a/clang/test/Driver/rewrite-objc.m b/clang/test/Driver/rewrite-objc.m
index 6073dcd..4753231 100644
--- a/clang/test/Driver/rewrite-objc.m
+++ b/clang/test/Driver/rewrite-objc.m
@@ -3,4 +3,4 @@
// TEST0: clang{{.*}}" "-cc1"
// TEST0: "-rewrite-objc"
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
+// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 3abed15..44b26e7 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -131,6 +131,9 @@ if config.has_plugins and config.llvm_plugin_ext:
if config.clang_default_pie_on_linux:
config.available_features.add('default-pie-on-linux')
+if config.clang_enable_opaque_pointers:
+ config.available_features.add('enable-opaque-pointers')
+
# Set available features we allow tests to conditionalize on.
#
if config.clang_default_cxx_stdlib != '':
diff --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 3725d84..8a9849f 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -23,6 +23,7 @@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
config.have_zlib = @LLVM_ENABLE_ZLIB@
config.clang_arcmt = @CLANG_ENABLE_ARCMT@
config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
+config.clang_enable_opaque_pointers = @CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL@
config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@