[PATCH] D124974: [clang] Include clang config.h in LangStandards.cpp
Cassie Jones via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 13 09:31:36 PDT 2022
porglezomp updated this revision to Diff 429274.
porglezomp added a comment.
Arcanist accidentally threw away the first commit in the sequence...
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124974/new/
https://reviews.llvm.org/D124974
Files:
clang/include/clang/Config/config.h.cmake
clang/lib/Basic/LangStandards.cpp
Index: clang/lib/Basic/LangStandards.cpp
===================================================================
--- clang/lib/Basic/LangStandards.cpp
+++ clang/lib/Basic/LangStandards.cpp
@@ -58,27 +58,24 @@
return LangStandard::lang_cuda;
case Language::Asm:
case Language::C:
-#if defined(CLANG_DEFAULT_STD_C)
- return CLANG_DEFAULT_STD_C;
-#else
+ if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified)
+ return CLANG_DEFAULT_STD_C;
+
// The PS4 uses C99 as the default C standard.
if (T.isPS4())
return LangStandard::lang_gnu99;
return LangStandard::lang_gnu17;
-#endif
case Language::ObjC:
-#if defined(CLANG_DEFAULT_STD_C)
- return CLANG_DEFAULT_STD_C;
-#else
+ if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified)
+ return CLANG_DEFAULT_STD_C;
+
return LangStandard::lang_gnu11;
-#endif
case Language::CXX:
case Language::ObjCXX:
-#if defined(CLANG_DEFAULT_STD_CXX)
- return CLANG_DEFAULT_STD_CXX;
-#else
+ if (CLANG_DEFAULT_STD_CXX != LangStandard::lang_unspecified)
+ return CLANG_DEFAULT_STD_CXX;
+
return LangStandard::lang_gnucxx14;
-#endif
case Language::RenderScript:
return LangStandard::lang_c99;
case Language::HIP:
Index: clang/include/clang/Config/config.h.cmake
===================================================================
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -16,9 +16,19 @@
/* Default C/ObjC standard to use. */
#cmakedefine CLANG_DEFAULT_STD_C LangStandard::lang_${CLANG_DEFAULT_STD_C}
+// Always #define something so that missing the config.h #include at use sites
+// becomes a compile error.
+#ifndef CLANG_DEFAULT_STD_C
+#define CLANG_DEFAULT_STD_C LangStandard::lang_unspecified
+#endif
/* Default C++/ObjC++ standard to use. */
#cmakedefine CLANG_DEFAULT_STD_CXX LangStandard::lang_${CLANG_DEFAULT_STD_CXX}
+// Always #define something so that missing the config.h #include at use sites
+// becomes a compile error.
+#ifndef CLANG_DEFAULT_STD_CXX
+#define CLANG_DEFAULT_STD_CXX LangStandard::lang_unspecified
+#endif
/* Default C++ stdlib to use. */
#define CLANG_DEFAULT_CXX_STDLIB "${CLANG_DEFAULT_CXX_STDLIB}"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124974.429274.patch
Type: text/x-patch
Size: 2222 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220513/4eea26fc/attachment.bin>
More information about the cfe-commits
mailing list