[PATCH] D25669: [Driver] Simplify ToolChain::GetCXXStdlibType (NFC)
Jonas Hahnfeld via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 17 23:32:52 PDT 2016
Hahnfeld updated this revision to Diff 74948.
Hahnfeld marked an inline comment as done.
Hahnfeld added a comment.
Update comments to express that `platform` should only be used in tests
https://reviews.llvm.org/D25669
Files:
lib/Driver/ToolChain.cpp
Index: lib/Driver/ToolChain.cpp
===================================================================
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -532,7 +532,7 @@
const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
- // "platform" is only used in tests to override CLANG_DEFAULT_RTLIB
+ // Only use "platform" in tests to override CLANG_DEFAULT_RTLIB!
if (LibName == "compiler-rt")
return ToolChain::RLT_CompilerRT;
else if (LibName == "libgcc")
@@ -546,43 +546,22 @@
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{
- ToolChain::CXXStdlibType Type;
- bool HasValidType = false;
- bool ForcePlatformDefault = false;
-
const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
- if (A) {
- StringRef Value = A->getValue();
- HasValidType = ParseCXXStdlibType(Value, Type);
-
- // Only use in tests to override CLANG_DEFAULT_CXX_STDLIB!
- if (Value == "platform")
- ForcePlatformDefault = true;
- else if (!HasValidType)
- getDriver().Diag(diag::err_drv_invalid_stdlib_name)
- << A->getAsString(Args);
- }
+ StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;
- // If no argument was provided or its value was invalid, look for the
- // default unless forced or configured to take the platform default.
- if (!HasValidType && (ForcePlatformDefault ||
- !ParseCXXStdlibType(CLANG_DEFAULT_CXX_STDLIB, Type)))
- Type = GetDefaultCXXStdlibType();
+ // 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();
+
+ if (A)
+ getDriver().Diag(diag::err_drv_invalid_stdlib_name) << A->getAsString(Args);
- return Type;
+ return GetDefaultCXXStdlibType();
}
/// \brief Utility function to add a system include directory to CC1 arguments.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25669.74948.patch
Type: text/x-patch
Size: 2404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161018/8ea48e63/attachment.bin>
More information about the cfe-commits
mailing list