diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-01-29 22:07:36 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-01-29 22:07:36 +0000 |
commit | 2c4e00ac1cc8a35cc7631e03a144765d264168e8 (patch) | |
tree | e0ff7007365105e1bb84dd61c7202d0aec749188 /clang/lib/AST/MicrosoftCXXABI.cpp | |
parent | fb8dd0085ee1a157540b20539b5278e472740999 (diff) | |
download | bcm5719-llvm-2c4e00ac1cc8a35cc7631e03a144765d264168e8.tar.gz bcm5719-llvm-2c4e00ac1cc8a35cc7631e03a144765d264168e8.zip |
Sema: Diagnose improper application of inheritance keywords
We would previously allow inappropriate inheritance keywords to appear
on class declarations. We would also allow inheritance keywords on
templates which were not fully specialized; this was divergent from
MSVC.
Differential Revision: http://llvm-reviews.chandlerc.com/D2585
llvm-svn: 200423
Diffstat (limited to 'clang/lib/AST/MicrosoftCXXABI.cpp')
-rw-r--r-- | clang/lib/AST/MicrosoftCXXABI.cpp | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/clang/lib/AST/MicrosoftCXXABI.cpp b/clang/lib/AST/MicrosoftCXXABI.cpp index c3478747a69..ee96e13e4b1 100644 --- a/clang/lib/AST/MicrosoftCXXABI.cpp +++ b/clang/lib/AST/MicrosoftCXXABI.cpp @@ -92,26 +92,12 @@ static bool usesMultipleInheritanceModel(const CXXRecordDecl *RD) { return false; } -static MSInheritanceAttr::Spelling -MSInheritanceAttrToModel(const MSInheritanceAttr *Attr) { - if (Attr->IsSingle()) - return MSInheritanceAttr::Keyword_single_inheritance; - else if (Attr->IsMultiple()) - return MSInheritanceAttr::Keyword_multiple_inheritance; - else if (Attr->IsVirtual()) - return MSInheritanceAttr::Keyword_virtual_inheritance; - - assert(Attr->IsUnspecified() && "Expected unspecified inheritance attr"); - return MSInheritanceAttr::Keyword_unspecified_inheritance; -} - -static MSInheritanceAttr::Spelling -calculateInheritanceModel(const CXXRecordDecl *RD) { - if (!RD->hasDefinition()) +MSInheritanceAttr::Spelling CXXRecordDecl::calculateInheritanceModel() const { + if (!hasDefinition()) return MSInheritanceAttr::Keyword_unspecified_inheritance; - if (RD->getNumVBases() > 0) + if (getNumVBases() > 0) return MSInheritanceAttr::Keyword_virtual_inheritance; - if (usesMultipleInheritanceModel(RD)) + if (usesMultipleInheritanceModel(this)) return MSInheritanceAttr::Keyword_multiple_inheritance; return MSInheritanceAttr::Keyword_single_inheritance; } @@ -120,7 +106,7 @@ MSInheritanceAttr::Spelling CXXRecordDecl::getMSInheritanceModel() const { MSInheritanceAttr *IA = getAttr<MSInheritanceAttr>(); assert(IA && "Expected MSInheritanceAttr on the CXXRecordDecl!"); - return MSInheritanceAttrToModel(IA); + return IA->getSemanticSpelling(); } void CXXRecordDecl::setMSInheritanceModel() { @@ -128,7 +114,7 @@ void CXXRecordDecl::setMSInheritanceModel() { return; addAttr(MSInheritanceAttr::CreateImplicit( - getASTContext(), calculateInheritanceModel(this), getSourceRange())); + getASTContext(), calculateInheritanceModel(), getSourceRange())); } // Returns the number of pointer and integer slots used to represent a member |