diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 931eecd9c968171a2adbd9a02ea97ebaff929563..3a77e7b0c8d607281db8822de547c7f648ebe25f 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -247,6 +247,17 @@ set(CLANG_SPAWN_CC1 OFF CACHE BOOL option(CLANG_DEFAULT_PIE_ON_LINUX "Default to -fPIE and -pie on linux-gnu" ON) +# Manually handle default so we can change the meaning of a cached default. +set(CLANG_ENABLE_OPAQUE_POINTERS "DEFAULT" CACHE STRING + "Enable opaque pointers by default") +if(CLANG_ENABLE_OPAQUE_POINTERS STREQUAL "DEFAULT") + set(CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL OFF) +elseif(CLANG_ENABLE_OPAQUE_POINTERS) + set(CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL ON) +else() + set(CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL OFF) +endif() + # TODO: verify the values against LangStandards.def? set(CLANG_DEFAULT_STD_C "" CACHE STRING "Default standard to use for C/ObjC code (IDENT from LangStandards.def, empty for platform default)") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 10a93293c05122d9d93f51f5d644f63699617057..680cc7310f76d0cc515dfa74b8bf597769d7fc44 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -89,4 +89,7 @@ /* Spawn a new process clang.exe for the CC1 tool invocation, when necessary */ #cmakedefine01 CLANG_SPAWN_CC1 +/* Whether to enable opaque pointers by default */ +#cmakedefine01 CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL + #endif diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 486276546770a9a68662d0572652fadbcb65bd02..0f7cfa7eb883f9ee90d1340bfffd643394a7639c 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5507,7 +5507,7 @@ defm enable_noundef_analysis : BoolOption<"", defm opaque_pointers : BoolOption<"", "opaque-pointers", CodeGenOpts<"OpaquePointers">, - DefaultFalse, + Default<"CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL">, PosFlag<SetTrue, [], "Enable">, NegFlag<SetFalse, [], "Disable">, BothFlags<[], " opaque pointers">>;