summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authorJonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de>2016-02-12 07:48:37 +0000
committerJonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de>2016-02-12 07:48:37 +0000
commitaae837400443a7eab8e51579bc899c80eb6c8a60 (patch)
tree0708391d324afd878cc3b4cf47cdc590f8942dc6 /clang/lib/Driver/ToolChain.cpp
parent91924a6f636046c074c8fca82979155b7d48de28 (diff)
downloadbcm5719-llvm-aae837400443a7eab8e51579bc899c80eb6c8a60.tar.gz
bcm5719-llvm-aae837400443a7eab8e51579bc899c80eb6c8a60.zip
[CMake] Add option to switch default C++ stdlib
With this option one can optionally override the architecture dependent default library to use if no -stdlib= is provided on compiler invocation. Differential Revision: http://reviews.llvm.org/D15920 llvm-svn: 260662
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r--clang/lib/Driver/ToolChain.cpp35
1 files changed, 26 insertions, 9 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index cbbd485a9b7..6158612b271 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -9,6 +9,7 @@
#include "Tools.h"
#include "clang/Basic/ObjCRuntime.h"
+#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
@@ -533,18 +534,34 @@ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
return GetDefaultRuntimeLibType();
}
+static bool ParseCXXStdlibType(const StringRef& Name,
+ ToolChain::CXXStdlibType& Type) {
+ if (Name == "libc++")
+ Type = ToolChain::CST_Libcxx;
+ else if (Name == "libstdc++")
+ Type = ToolChain::CST_Libstdcxx;
+ else
+ return false;
+
+ return true;
+}
+
ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{
- if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) {
- StringRef Value = A->getValue();
- if (Value == "libc++")
- return ToolChain::CST_Libcxx;
- if (Value == "libstdc++")
- return ToolChain::CST_Libstdcxx;
- getDriver().Diag(diag::err_drv_invalid_stdlib_name)
- << A->getAsString(Args);
+ ToolChain::CXXStdlibType Type;
+ bool HasValidType = false;
+
+ const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
+ if (A) {
+ HasValidType = ParseCXXStdlibType(A->getValue(), Type);
+ if (!HasValidType)
+ getDriver().Diag(diag::err_drv_invalid_stdlib_name)
+ << A->getAsString(Args);
}
- return ToolChain::CST_Libstdcxx;
+ if (!HasValidType && !ParseCXXStdlibType(CLANG_DEFAULT_CXX_STDLIB, Type))
+ Type = GetDefaultCXXStdlibType();
+
+ return Type;
}
/// \brief Utility function to add a system include directory to CC1 arguments.
OpenPOWER on IntegriCloud