summaryrefslogtreecommitdiffstats
path: root/lib/AST
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-03-21 06:57:19 +0000
committerJohn McCall <rjmccall@apple.com>2012-03-21 06:57:19 +0000
commit260a3e4370a15bc3da9d2d9461b6f179c68dd348 (patch)
treeda5fb2598d2ed3a5f09761ee962cb502900a7a4b /lib/AST
parent247c7196526110ced1c08ebda1079201b6108d78 (diff)
For the annals of subtle but terrible bugs: fix a longstanding bug
in vtable layout where virtual methods inherited from virtual bases could be assigned the same vcall adjustment slot if they shared a name and parameter signature but differed in their cv-qualification. The code was already trying to handle this case, but unfortunately used the ordinary type qualifiers (which are always empty here) instead of the method qualifiers. This seems like something that the API should discourage, but I don't know how to carry that principle out in this instance. Eliminate this function's need for an ASTContext while we're at it. This bug affects the ABI, and fixing it brings us into accord with the Itanium ABI (and GCC's implementation of it), but, obviously, technically breaks full compatibility with previous releases of Clang. Just letting you know. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/VTableBuilder.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/AST/VTableBuilder.cpp b/lib/AST/VTableBuilder.cpp
index 35f84ff483..7a45972649 100644
--- a/lib/AST/VTableBuilder.cpp
+++ b/lib/AST/VTableBuilder.cpp
@@ -466,10 +466,10 @@ public:
static bool HasSameVirtualSignature(const CXXMethodDecl *LHS,
const CXXMethodDecl *RHS) {
- ASTContext &C = LHS->getASTContext(); // TODO: thread this down
- CanQual<FunctionProtoType>
- LT = C.getCanonicalType(LHS->getType()).getAs<FunctionProtoType>(),
- RT = C.getCanonicalType(RHS->getType()).getAs<FunctionProtoType>();
+ const FunctionProtoType *LT =
+ cast<FunctionProtoType>(LHS->getType().getCanonicalType());
+ const FunctionProtoType *RT =
+ cast<FunctionProtoType>(RHS->getType().getCanonicalType());
// Fast-path matches in the canonical types.
if (LT == RT) return true;
@@ -477,7 +477,7 @@ static bool HasSameVirtualSignature(const CXXMethodDecl *LHS,
// Force the signatures to match. We can't rely on the overrides
// list here because there isn't necessarily an inheritance
// relationship between the two methods.
- if (LT.getQualifiers() != RT.getQualifiers() ||
+ if (LT->getTypeQuals() != RT->getTypeQuals() ||
LT->getNumArgs() != RT->getNumArgs())
return false;
for (unsigned I = 0, E = LT->getNumArgs(); I != E; ++I)