Last active
June 12, 2017 03:54
-
-
Save yamaguchi1024/661ef1f6bfa403dba1aaef63fdf85933 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td | |
index 3833f0f..c401198 100644 | |
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td | |
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td | |
@@ -45,7 +45,7 @@ def err_drv_invalid_rtlib_name : Error< | |
def err_drv_unsupported_rtlib_for_platform : Error< | |
"unsupported runtime library '%0' for platform '%1'">; | |
def err_drv_invalid_stdlib_name : Error< | |
- "invalid library name in argument '%0'">; | |
+ "invalid library name in argument '%0'. Do you mean "%1"? ">; | |
def err_drv_invalid_output_with_multiple_archs : Error< | |
"cannot use '%0' output with multiple -arch options">; | |
def err_drv_no_input_files : Error<"no input files">; | |
diff --git a/clang/include/clang/Driver/Options.h b/clang/include/clang/Driver/Options.h | |
index 57e4452..f539f41 100644 | |
--- a/clang/include/clang/Driver/Options.h | |
+++ b/clang/include/clang/Driver/Options.h | |
@@ -21,6 +21,12 @@ class OptTable; | |
namespace clang { | |
namespace driver { | |
+namespace ArgValues { | |
+ enum class stdlib { | |
+ libcxx, stdlibcxx, platform | |
+ } | |
+} | |
+ | |
namespace options { | |
/// Flags specifically for clang options. Must not overlap with | |
/// llvm::opt::DriverFlag. | |
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp | |
index f36deff..a8e1e4b 100644 | |
--- a/clang/lib/Driver/Driver.cpp | |
+++ b/clang/lib/Driver/Driver.cpp | |
@@ -443,22 +443,21 @@ void Driver::setLTOMode(const llvm::opt::ArgList &Args) { | |
options::OPT_fno_lto, false)) | |
return; | |
- StringRef LTOName("full"); | |
- | |
+ OptValue LTOName = options::VAL_lto_full; | |
const Arg *A = Args.getLastArg(options::OPT_flto_EQ); | |
if (A) | |
- LTOName = A->getValue(); | |
- | |
- LTOMode = llvm::StringSwitch<LTOKind>(LTOName) | |
- .Case("full", LTOK_Full) | |
- .Case("thin", LTOK_Thin) | |
- .Default(LTOK_Unknown); | |
+ LTOName = A->getEnumValue(); | |
- if (LTOMode == LTOK_Unknown) { | |
- assert(A); | |
- Diag(diag::err_drv_unsupported_option_argument) << A->getOption().getName() | |
+ switch (LTOName) { | |
+ case VAL_lto_full: | |
+ return LTOK_Full; | |
+ case VAL_lto_thin: | |
+ return LTOK_Thin; | |
+ default: | |
+ assert(A); | |
+ Diag(diag::err_drv_unsupported_option_argument) << A->getOption().getName() | |
<< A->getValue(); | |
- } | |
+ } | |
} | |
/// Compute the desired OpenMP runtime from the flags provided. | |
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp | |
index 4f82503..8122e90 100644 | |
--- a/clang/lib/Driver/ToolChain.cpp | |
+++ b/clang/lib/Driver/ToolChain.cpp | |
@@ -581,15 +581,15 @@ ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ | |
StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB; | |
// Only use "platform" in tests to override CLANG_DEFAULT_CXX_STDLIB! | |
- if (LibName == "libc++") | |
- return ToolChain::CST_Libcxx; | |
- else if (LibName == "libstdc++") | |
- return ToolChain::CST_Libstdcxx; | |
- else if (LibName == "platform") | |
- return GetDefaultCXXStdlibType(); | |
+ switch(LibName) { | |
+ ArgValues::stdlib::libcxx : return ToolChain::CST_Libcxx; break; | |
+ ArgValues::stdlib::stdlibcxx : return ToolChain::CST_Libcstdxx; break; | |
+ ArgValues::stdlib::platform : return GetDefaultCXXStdlibType(); break; | |
+ } | |
if (A) | |
- getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args); | |
+ getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args) | |
+ << ArgValues::stdlib::libcxx ; | |
return GetDefaultCXXStdlibType(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment