summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-02-11 21:05:00 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-02-11 21:05:00 +0000
commit86c318f4962fb18383c184a380e294e2b5589456 (patch)
tree37594f81afbd01917ec6706c169d0fb222d2aa8c /clang/lib
parent7422074df096e7a21e3b02f1a6088edf2459a765 (diff)
downloadbcm5719-llvm-86c318f4962fb18383c184a380e294e2b5589456.tar.gz
bcm5719-llvm-86c318f4962fb18383c184a380e294e2b5589456.zip
MS ABI: Add support for the -vm{b,g,s,m,v} flags
These flags control the inheritance model initially used by the translation unit. Differential Revision: http://llvm-reviews.chandlerc.com/D2741 llvm-svn: 201175
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/Tools.cpp27
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp18
-rw-r--r--clang/lib/Parse/ParsePragma.cpp19
-rw-r--r--clang/lib/Sema/Sema.cpp4
-rw-r--r--clang/lib/Sema/SemaAttr.cpp2
-rw-r--r--clang/lib/Sema/SemaType.cpp10
6 files changed, 65 insertions, 15 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index ecb6184d19f..b3a2b865441 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -4021,6 +4021,33 @@ void Clang::AddClangCLArgs(const ArgList &Args, ArgStringList &CmdArgs) const {
if (Arg *A = Args.getLastArg(options::OPT_show_includes))
A->render(Args, CmdArgs);
+ const Driver &D = getToolChain().getDriver();
+ Arg *MostGeneralArg = Args.getLastArg(options::OPT__SLASH_vmg);
+ Arg *BestCaseArg = Args.getLastArg(options::OPT__SLASH_vmb);
+ if (MostGeneralArg && BestCaseArg)
+ D.Diag(clang::diag::err_drv_argument_not_allowed_with)
+ << MostGeneralArg->getAsString(Args) << BestCaseArg->getAsString(Args);
+
+ if (MostGeneralArg) {
+ Arg *SingleArg = Args.getLastArg(options::OPT__SLASH_vms);
+ Arg *MultipleArg = Args.getLastArg(options::OPT__SLASH_vmm);
+ Arg *VirtualArg = Args.getLastArg(options::OPT__SLASH_vmv);
+
+ Arg *FirstConflict = SingleArg ? SingleArg : MultipleArg;
+ Arg *SecondConflict = VirtualArg ? VirtualArg : MultipleArg;
+ if (FirstConflict && SecondConflict && FirstConflict != SecondConflict)
+ D.Diag(clang::diag::err_drv_argument_not_allowed_with)
+ << FirstConflict->getAsString(Args)
+ << SecondConflict->getAsString(Args);
+
+ if (SingleArg)
+ CmdArgs.push_back("-fms-memptr-rep=single");
+ else if (MultipleArg)
+ CmdArgs.push_back("-fms-memptr-rep=multiple");
+ else
+ CmdArgs.push_back("-fms-memptr-rep=virtual");
+ }
+
if (!Args.hasArg(options::OPT_fdiagnostics_format_EQ)) {
CmdArgs.push_back("-fdiagnostics-format");
if (Args.hasArg(options::OPT__SLASH_fallback))
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 034730fe187..5320415ecb4 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1402,6 +1402,24 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
}
}
+ if (Arg *A = Args.getLastArg(OPT_fms_memptr_rep_EQ)) {
+ LangOptions::PragmaMSPointersToMembersKind InheritanceModel =
+ llvm::StringSwitch<LangOptions::PragmaMSPointersToMembersKind>(
+ A->getValue())
+ .Case("single",
+ LangOptions::PPTMK_FullGeneralitySingleInheritance)
+ .Case("multiple",
+ LangOptions::PPTMK_FullGeneralityMultipleInheritance)
+ .Case("virtual",
+ LangOptions::PPTMK_FullGeneralityVirtualInheritance)
+ .Default(LangOptions::PPTMK_BestCase);
+ if (InheritanceModel == LangOptions::PPTMK_BestCase)
+ Diags.Report(diag::err_drv_invalid_value)
+ << "-fms-memptr-rep=" << A->getValue();
+
+ Opts.setMSPointerToMemberRepresentationMethod(InheritanceModel);
+ }
+
// Check if -fopenmp is specified.
Opts.OpenMP = Args.hasArg(OPT_fopenmp);
diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index 2655996a1ff..8cf2b3f1d26 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -182,8 +182,8 @@ void Parser::HandlePragmaOpenCLExtension() {
void Parser::HandlePragmaMSPointersToMembers() {
assert(Tok.is(tok::annot_pragma_ms_pointers_to_members));
- Sema::PragmaMSPointersToMembersKind RepresentationMethod =
- static_cast<Sema::PragmaMSPointersToMembersKind>(
+ LangOptions::PragmaMSPointersToMembersKind RepresentationMethod =
+ static_cast<LangOptions::PragmaMSPointersToMembersKind>(
reinterpret_cast<uintptr_t>(Tok.getAnnotationValue()));
SourceLocation PragmaLoc = ConsumeToken(); // The annotation token.
Actions.ActOnPragmaMSPointersToMembers(RepresentationMethod, PragmaLoc);
@@ -834,9 +834,9 @@ void PragmaMSPointersToMembers::HandlePragma(Preprocessor &PP,
}
PP.Lex(Tok);
- Sema::PragmaMSPointersToMembersKind RepresentationMethod;
+ LangOptions::PragmaMSPointersToMembersKind RepresentationMethod;
if (Arg->isStr("best_case")) {
- RepresentationMethod = Sema::PPTMK_BestCase;
+ RepresentationMethod = LangOptions::PPTMK_BestCase;
} else {
if (Arg->isStr("full_generality")) {
if (Tok.is(tok::comma)) {
@@ -854,7 +854,7 @@ void PragmaMSPointersToMembers::HandlePragma(Preprocessor &PP,
// #pragma pointers_to_members(full_generality) implicitly specifies
// virtual_inheritance.
Arg = 0;
- RepresentationMethod = Sema::PPTMK_FullGeneralityVirtualInheritance;
+ RepresentationMethod = LangOptions::PPTMK_FullGeneralityVirtualInheritance;
} else {
PP.Diag(Tok.getLocation(), diag::err_expected_punc)
<< "full_generality";
@@ -864,11 +864,14 @@ void PragmaMSPointersToMembers::HandlePragma(Preprocessor &PP,
if (Arg) {
if (Arg->isStr("single_inheritance")) {
- RepresentationMethod = Sema::PPTMK_FullGeneralitySingleInheritance;
+ RepresentationMethod =
+ LangOptions::PPTMK_FullGeneralitySingleInheritance;
} else if (Arg->isStr("multiple_inheritance")) {
- RepresentationMethod = Sema::PPTMK_FullGeneralityMultipleInheritance;
+ RepresentationMethod =
+ LangOptions::PPTMK_FullGeneralityMultipleInheritance;
} else if (Arg->isStr("virtual_inheritance")) {
- RepresentationMethod = Sema::PPTMK_FullGeneralityVirtualInheritance;
+ RepresentationMethod =
+ LangOptions::PPTMK_FullGeneralityVirtualInheritance;
} else {
PP.Diag(Tok.getLocation(),
diag::err_pragma_pointers_to_members_unknown_kind)
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index b2cf59b1c84..871e1c97d77 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -76,7 +76,9 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
CollectStats(false), CodeCompleter(CodeCompleter),
CurContext(0), OriginalLexicalContext(0),
PackContext(0), MSStructPragmaOn(false),
- MSPointerToMemberRepresentationMethod(PPTMK_BestCase), VisContext(0),
+ MSPointerToMemberRepresentationMethod(
+ pp.getLangOpts().getMSPointerToMemberRepresentationMethod()),
+ VisContext(0),
IsBuildingRecoveryCallExpr(false),
ExprNeedsCleanups(false), LateTemplateParser(0), OpaqueParser(0),
IdResolver(pp), StdInitializerList(0), CXXTypeInfoDecl(0), MSVCGuidDecl(0),
diff --git a/clang/lib/Sema/SemaAttr.cpp b/clang/lib/Sema/SemaAttr.cpp
index 9f0eb91d2e4..4da14ec1d1d 100644
--- a/clang/lib/Sema/SemaAttr.cpp
+++ b/clang/lib/Sema/SemaAttr.cpp
@@ -288,7 +288,7 @@ void Sema::ActOnPragmaDetectMismatch(StringRef Name, StringRef Value) {
}
void Sema::ActOnPragmaMSPointersToMembers(
- PragmaMSPointersToMembersKind RepresentationMethod,
+ LangOptions::PragmaMSPointersToMembersKind RepresentationMethod,
SourceLocation PragmaLoc) {
MSPointerToMemberRepresentationMethod = RepresentationMethod;
ImplicitMSInheritanceAttrLoc = PragmaLoc;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 606a4c09078..edf119486d9 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -5087,17 +5087,17 @@ bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
MSInheritanceAttr::Spelling InheritanceModel;
switch (MSPointerToMemberRepresentationMethod) {
- case PPTMK_BestCase:
+ case LangOptions::PPTMK_BestCase:
InheritanceModel = RD->calculateInheritanceModel();
break;
- case PPTMK_FullGeneralitySingleInheritance:
+ case LangOptions::PPTMK_FullGeneralitySingleInheritance:
InheritanceModel = MSInheritanceAttr::Keyword_single_inheritance;
break;
- case PPTMK_FullGeneralityMultipleInheritance:
+ case LangOptions::PPTMK_FullGeneralityMultipleInheritance:
InheritanceModel =
MSInheritanceAttr::Keyword_multiple_inheritance;
break;
- case PPTMK_FullGeneralityVirtualInheritance:
+ case LangOptions::PPTMK_FullGeneralityVirtualInheritance:
InheritanceModel =
MSInheritanceAttr::Keyword_unspecified_inheritance;
break;
@@ -5106,7 +5106,7 @@ bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
RD->addAttr(MSInheritanceAttr::CreateImplicit(
getASTContext(), InheritanceModel,
/*BestCase=*/MSPointerToMemberRepresentationMethod ==
- PPTMK_BestCase,
+ LangOptions::PPTMK_BestCase,
ImplicitMSInheritanceAttrLoc.isValid()
? ImplicitMSInheritanceAttrLoc
: RD->getSourceRange()));
OpenPOWER on IntegriCloud