[clang] [llvm] [driver] Make --version show if assertions, etc. are enabled (PR #87585)

Jon Roelofs via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 4 14:51:33 PDT 2024


================
@@ -2734,6 +2734,40 @@ void cl::PrintHelpMessage(bool Hidden, bool Categorized) {
     CommonOptions->CategorizedHiddenPrinter.printHelp();
 }
 
+ArrayRef<StringRef> cl::CompilerBuildConfig = {
+#if LLVM_IS_DEBUG_BUILD
+    "+unoptimized",
+#endif
+#ifndef NDEBUG
+    "+assertions",
+#endif
+#ifdef EXPENSIVE_CHECKS
+    "+expensive-checks",
+#endif
+#if __has_feature(address_sanitizer)
+    "+asan",
+#endif
+#if __has_feature(undefined_behavior_sanitizer)
+    "+ubsan",
+#endif
+#if __has_feature(memory_sanitizer)
+    "+msan",
+#endif
+#if __has_feature(dataflow_sanitizer)
+    "+dfsan",
+#endif
+};
+
+// Utility function for printing the build config.
+void cl::printBuildConfig(raw_ostream &OS) {
+#if LLVM_VERSION_PRINTER_SHOW_BUILD_CONFIG
+  OS << "Build config: ";
+  llvm::interleaveComma(cl::CompilerBuildConfig, OS,
+                        [&OS](const StringRef &Option) { OS << Option; });
----------------
jroelofs wrote:

```suggestion
  llvm::interleaveComma(cl::CompilerBuildConfig, OS);
```

https://github.com/llvm/llvm-project/pull/87585


More information about the cfe-commits mailing list