r216503 - [modules] Don't assert when merging virtual functions that override other
Richard Smith
richard-llvm at metafoo.co.uk
Tue Aug 26 16:29:11 PDT 2014
Author: rsmith
Date: Tue Aug 26 18:29:11 2014
New Revision: 216503
URL: http://llvm.org/viewvc/llvm-project?rev=216503&view=rev
Log:
[modules] Don't assert when merging virtual functions that override other
functions. Also don't needlessly pull in non-canonical declarations of the
overridden virtual functions.
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h
cfe/trunk/test/Modules/Inputs/cxx-decls-merged.h
cfe/trunk/test/Modules/cxx-decls.cpp
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=216503&r1=216502&r2=216503&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Aug 26 18:29:11 2014
@@ -1504,12 +1504,19 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CX
void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {
VisitFunctionDecl(D);
+
unsigned NumOverridenMethods = Record[Idx++];
- while (NumOverridenMethods--) {
- // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
- // MD may be initializing.
- if (CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>(Record, Idx))
- Reader.getContext().addOverriddenMethod(D, MD);
+ if (D->isCanonicalDecl()) {
+ while (NumOverridenMethods--) {
+ // Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
+ // MD may be initializing.
+ if (CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>(Record, Idx))
+ Reader.getContext().addOverriddenMethod(D, MD->getCanonicalDecl());
+ }
+ } else {
+ // We don't care about which declarations this used to override; we get
+ // the relevant information from the canonical declaration.
+ Idx += NumOverridenMethods;
}
}
Modified: cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h?rev=216503&r1=216502&r2=216503&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h Tue Aug 26 18:29:11 2014
@@ -28,3 +28,10 @@ typedef struct {
int n;
int m;
} NameForLinkage;
+
+struct HasVirtualFunctions {
+ virtual void f();
+};
+struct OverridesVirtualFunctions : HasVirtualFunctions {
+ void f();
+};
Modified: cfe/trunk/test/Modules/Inputs/cxx-decls-merged.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-decls-merged.h?rev=216503&r1=216502&r2=216503&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/cxx-decls-merged.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-decls-merged.h Tue Aug 26 18:29:11 2014
@@ -5,3 +5,11 @@ typedef struct {
int m;
} NameForLinkage;
extern NameForLinkage name_for_linkage;
+
+struct HasVirtualFunctions {
+ virtual void f();
+};
+struct OverridesVirtualFunctions : HasVirtualFunctions {
+ void f();
+};
+extern OverridesVirtualFunctions overrides_virtual_functions;
Modified: cfe/trunk/test/Modules/cxx-decls.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/cxx-decls.cpp?rev=216503&r1=216502&r2=216503&view=diff
==============================================================================
--- cfe/trunk/test/Modules/cxx-decls.cpp (original)
+++ cfe/trunk/test/Modules/cxx-decls.cpp Tue Aug 26 18:29:11 2014
@@ -33,10 +33,13 @@ int importMergeUsedFlag = getMergeUsedFl
int use_name_for_linkage(NameForLinkage &nfl) {
return nfl.n + nfl.m;
}
+int use_overrides_virtual_functions(OverridesVirtualFunctions ovf) { return 0; }
@import cxx_decls_merged;
int name_for_linkage_test = use_name_for_linkage(name_for_linkage);
+int overrides_virtual_functions_test =
+ use_overrides_virtual_functions(overrides_virtual_functions);
// CHECK: VarDecl [[mergeUsedFlag:0x[0-9a-f]*]] {{.*}} in cxx_decls.imported used mergeUsedFlag
// CHECK: VarDecl {{0x[0-9a-f]*}} prev [[mergeUsedFlag]] {{.*}} in cxx_decls_merged used mergeUsedFlag
More information about the cfe-commits
mailing list