aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInvocation.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-03-22 08:39:22 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-03-22 08:39:22 +0000
commitc371ff048df8731052976f4e628ed1861cf61cfd (patch)
tree0f88276ac2f3a25c058e0cdd0471c2a5ac6501fa /clang/lib/Frontend/CompilerInvocation.cpp
parenta3ea9a4e09ad7339022cff87fe90ed7f9e53f8e3 (diff)
downloadllvm-c371ff048df8731052976f4e628ed1861cf61cfd.zip
llvm-c371ff048df8731052976f4e628ed1861cf61cfd.tar.gz
llvm-c371ff048df8731052976f4e628ed1861cf61cfd.tar.bz2
MS ABI: Implement driver-level support for thread-safe statics
Decide whether or not to use thread-safe statics depending on whether or not we have an explicit request from the driver. If we don't have an explicit request, infer which behavior to use depending on the compatibility version we are targeting. N.B. CodeGen support is still ongoing. llvm-svn: 232906
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp48
1 files changed, 10 insertions, 38 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 42de57e..5d2cdae 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1282,43 +1282,6 @@ static Visibility parseVisibility(Arg *arg, ArgList &args,
return DefaultVisibility;
}
-static unsigned parseMSCVersion(ArgList &Args, DiagnosticsEngine &Diags) {
- auto Arg = Args.getLastArg(OPT_fms_compatibility_version);
- if (!Arg)
- return 0;
-
- // The MSC versioning scheme involves four versioning components:
- // - Major
- // - Minor
- // - Build
- // - Patch
- //
- // We accept either the old style (_MSC_VER) value, or a _MSC_FULL_VER value.
- // Additionally, the value may be provided in the form of a more readable
- // MM.mm.bbbbb.pp version.
- //
- // Unfortunately, due to the bit-width limitations, we cannot currently encode
- // the value for the patch level.
-
- unsigned VC[4] = {0};
- StringRef Value = Arg->getValue();
- SmallVector<StringRef, 4> Components;
-
- Value.split(Components, ".", llvm::array_lengthof(VC));
- for (unsigned CI = 0,
- CE = std::min(Components.size(), llvm::array_lengthof(VC));
- CI < CE; ++CI) {
- if (Components[CI].getAsInteger(10, VC[CI])) {
- Diags.Report(diag::err_drv_invalid_value)
- << Arg->getAsString(Args) << Value;
- return 0;
- }
- }
-
- // FIXME we cannot encode the patch level
- return VC[0] * 10000000 + VC[1] * 100000 + VC[2];
-}
-
static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
DiagnosticsEngine &Diags) {
// FIXME: Cleanup per-file based stuff.
@@ -1489,7 +1452,16 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Opts.MSVCCompat = Args.hasArg(OPT_fms_compatibility);
Opts.MicrosoftExt = Opts.MSVCCompat || Args.hasArg(OPT_fms_extensions);
Opts.AsmBlocks = Args.hasArg(OPT_fasm_blocks) || Opts.MicrosoftExt;
- Opts.MSCompatibilityVersion = parseMSCVersion(Args, Diags);
+ Opts.MSCompatibilityVersion = 0;
+ if (const Arg *A = Args.getLastArg(OPT_fms_compatibility_version)) {
+ VersionTuple VT;
+ if (VT.tryParse(A->getValue()))
+ Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args)
+ << A->getValue();
+ Opts.MSCompatibilityVersion = VT.getMajor() * 10000000 +
+ VT.getMinor().getValueOr(0) * 100000 +
+ VT.getSubminor().getValueOr(0);
+ }
// Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs
// is specified, or -std is set to a conforming mode.