aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r--llvm/lib/Support/CommandLine.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index c076ae8..056340b 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -2734,6 +2734,52 @@ void cl::PrintHelpMessage(bool Hidden, bool Categorized) {
CommonOptions->CategorizedHiddenPrinter.printHelp();
}
+ArrayRef<StringRef> cl::getCompilerBuildConfig() {
+ static const StringRef Config[] = {
+ // Placeholder to ensure the array always has elements, since it's an
+ // error to have a zero-sized array. Slice this off before returning.
+ "",
+ // Actual compiler build config feature list:
+#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(dataflow_sanitizer)
+ "+dfsan",
+#endif
+#if __has_feature(hwaddress_sanitizer)
+ "+hwasan",
+#endif
+#if __has_feature(memory_sanitizer)
+ "+msan",
+#endif
+#if __has_feature(thread_sanitizer)
+ "+tsan",
+#endif
+#if __has_feature(undefined_behavior_sanitizer)
+ "+ubsan",
+#endif
+ };
+ return ArrayRef(Config).drop_front(1);
+}
+
+// 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::getCompilerBuildConfig(), OS);
+ OS << '\n';
+#endif
+}
+
/// Utility function for printing version number.
void cl::PrintVersionMessage() {
CommonOptions->VersionPrinterInstance.print(CommonOptions->ExtraVersionPrinters);