From: David Majnemer Date: Mon, 11 May 2015 03:57:49 +0000 (+0000) Subject: Give isCompatibleWithMSVC a better interface X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35ec179e2b2b5c10b7aca77e565853a5a4c447e3;p=clang Give isCompatibleWithMSVC a better interface We now use an enum which maps the marketing name (almost always a year) to the major version number. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236967 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/LangOptions.h b/include/clang/Basic/LangOptions.h index 3631704646..84836eb4e5 100644 --- a/include/clang/Basic/LangOptions.h +++ b/include/clang/Basic/LangOptions.h @@ -67,6 +67,13 @@ public: enum AddrSpaceMapMangling { ASMM_Target, ASMM_On, ASMM_Off }; + enum MSVCMajorVersion { + MSVC2010 = 16, + MSVC2012 = 17, + MSVC2013 = 18, + MSVC2015 = 19 + }; + public: /// \brief Set of enabled sanitizers. SanitizerSet Sanitize; @@ -118,7 +125,7 @@ public: !ObjCSubscriptingLegacyRuntime; } - bool isCompatibleWithMSVC(unsigned MajorVersion) const { + bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const { return MSCompatibilityVersion >= MajorVersion * 10000000U; } diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp index bac3472e68..b8327af6fa 100644 --- a/lib/AST/MicrosoftMangle.cpp +++ b/lib/AST/MicrosoftMangle.cpp @@ -1210,7 +1210,8 @@ void MicrosoftCXXNameMangler::mangleTemplateArg(const TemplateDecl *TD, isa(Parm)) // MSVC 2015 changed the mangling for empty expanded template packs, // use the old mangling for link compatibility for old versions. - Out << (Context.getASTContext().getLangOpts().isCompatibleWithMSVC(19) + Out << (Context.getASTContext().getLangOpts().isCompatibleWithMSVC( + LangOptions::MSVC2015) ? "$$V" : "$$$V"); else if (isa(Parm)) diff --git a/lib/Basic/IdentifierTable.cpp b/lib/Basic/IdentifierTable.cpp index bd2840db4c..0a27c6a889 100644 --- a/lib/Basic/IdentifierTable.cpp +++ b/lib/Basic/IdentifierTable.cpp @@ -157,7 +157,7 @@ static void AddKeyword(StringRef Keyword, // Don't add this keyword under MSVCCompat. if (LangOpts.MSVCCompat && (Flags & KEYNOMS18) && - !LangOpts.isCompatibleWithMSVC(19)) + !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2015)) return; // Don't add this keyword under OpenCL. diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index b39cd1eea5..44584c4501 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -657,7 +657,7 @@ protected: // FIXME We cannot encode the revision information into 32-bits Builder.defineMacro("_MSC_BUILD", Twine(1)); - if (Opts.CPlusPlus11 && Opts.isCompatibleWithMSVC(19)) + if (Opts.CPlusPlus11 && Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1)); } diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index 6e0bdd24a7..a518443889 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -60,7 +60,7 @@ llvm::Constant *CodeGenModule::getTerminateFn() { name = "_ZSt9terminatev"; } else if (getLangOpts().CPlusPlus && getTarget().getCXXABI().isMicrosoft()) { - if (getLangOpts().isCompatibleWithMSVC(19)) + if (getLangOpts().isCompatibleWithMSVC(LangOptions::MSVC2015)) name = "__std_terminate"; else name = "\01?terminate@@YAXXZ"; diff --git a/lib/Frontend/TextDiagnostic.cpp b/lib/Frontend/TextDiagnostic.cpp index 17e41f614a..aaf17a9833 100644 --- a/lib/Frontend/TextDiagnostic.cpp +++ b/lib/Frontend/TextDiagnostic.cpp @@ -810,7 +810,7 @@ void TextDiagnostic::emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc, OS << ','; // Visual Studio 2010 or earlier expects column number to be off by one if (LangOpts.MSCompatibilityVersion && - LangOpts.MSCompatibilityVersion < 170000000) + !LangOpts.isCompatibleWithMSVC(LangOptions::MSVC2012)) ColNo--; } else OS << ':'; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index bc31d4612e..ac8f57698b 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3450,8 +3450,9 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, // We will pick our mangling number depending on which version of MSVC is being // targeted. static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S) { - return LO.isCompatibleWithMSVC(19) ? S->getMSCurManglingNumber() - : S->getMSLastManglingNumber(); + return LO.isCompatibleWithMSVC(LangOptions::MSVC2015) + ? S->getMSCurManglingNumber() + : S->getMSLastManglingNumber(); } void Sema::handleTagNumbering(const TagDecl *Tag, Scope *TagScope) { diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index baa05c334f..c5d5d8f2e6 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -4799,7 +4799,7 @@ static void checkDLLAttribute(Sema &S, CXXRecordDecl *Class) { // MSVC versions before 2015 don't export the move assignment operators, // so don't attempt to import them if we have a definition. if (ClassImported && MD->isMoveAssignmentOperator() && - !S.getLangOpts().isCompatibleWithMSVC(19)) + !S.getLangOpts().isCompatibleWithMSVC(LangOptions::MSVC2015)) continue; } }