diff options
author | David Blaikie <dblaikie@gmail.com> | 2012-11-14 01:52:05 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2012-11-14 01:52:05 +0000 |
commit | 095deba5336bfaf275f4837a5f229e58f9a927c0 (patch) | |
tree | 443f55dab57c503f362b220c6622157e105b40fd /clang/lib/AST/Decl.cpp | |
parent | 5f265fb124f30a7179f4f65f7c4c37262f9f6d4e (diff) | |
download | bcm5719-llvm-095deba5336bfaf275f4837a5f229e58f9a927c0.tar.gz bcm5719-llvm-095deba5336bfaf275f4837a5f229e58f9a927c0.zip |
Provide the correct mangling and linkage for certain unnamed nested classes.
This corrects the mangling and linkage of classes (& their member functions) in
cases like this:
struct foo {
struct {
void func() { ... }
} x;
};
we were accidentally giving this nested unnamed struct 'no' linkage where it
should've had the linkage of the outer class. The mangling was incorrecty too,
mangling as TU-wide unnamed type mangling of $_X rather than class-scoped
mangling of UtX_.
This also fixes -Wunused-member-function which would incorrectly diagnose
'func' as unused due to it having no linkage & thus appearing to be TU-local
when in fact it might be correctly used in another TU.
Similar mangling should be applied to function local classes in similar cases
but I've deferred that for a subsequent patch.
Review/discussion by Richard Smith, John McCall, & especially Eli Friedman.
llvm-svn: 167906
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 74abbaa492d..9569841a568 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -480,8 +480,7 @@ static LinkageInfo getLVForClassMember(const NamedDecl *D, bool OnlyTemplate) { if (!(isa<CXXMethodDecl>(D) || isa<VarDecl>(D) || isa<FieldDecl>(D) || - (isa<TagDecl>(D) && - (D->getDeclName() || cast<TagDecl>(D)->getTypedefNameForAnonDecl())))) + isa<TagDecl>(D))) return LinkageInfo::none(); LinkageInfo LV; @@ -2561,8 +2560,7 @@ void TagDecl::setTypedefNameForAnonDecl(TypedefNameDecl *TDD) { void TagDecl::startDefinition() { IsBeingDefined = true; - if (isa<CXXRecordDecl>(this)) { - CXXRecordDecl *D = cast<CXXRecordDecl>(this); + if (CXXRecordDecl *D = dyn_cast<CXXRecordDecl>(this)) { struct CXXRecordDecl::DefinitionData *Data = new (getASTContext()) struct CXXRecordDecl::DefinitionData(D); for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) |