summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-02-22 19:33:13 +0000
committerJordan Rose <jordan_rose@apple.com>2013-02-22 19:33:13 +0000
commit893d73b7e924a343d51363332c4c57fd858a9ecc (patch)
tree51b4ccada365f5aa44fbaa7c044cfa9f078de619 /clang/test
parentf32b3f2c55ece0c7ed62035604de04620e0cb2b5 (diff)
downloadbcm5719-llvm-893d73b7e924a343d51363332c4c57fd858a9ecc.tar.gz
bcm5719-llvm-893d73b7e924a343d51363332c4c57fd858a9ecc.zip
[analyzer] Don't canonicalize the RecordDecl used in CXXBaseObjectRegion.
This Decl shouldn't be the canonical Decl; it should be the Decl used by the CXXBaseSpecifier in the subclass. Unfortunately, that means continuing to throw getCanonicalDecl() on all comparisons. This fixes MemRegion::getAsOffset's use of ASTRecordLayout when redeclarations are involved. llvm-svn: 175913
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Analysis/derived-to-base.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/Analysis/derived-to-base.cpp b/clang/test/Analysis/derived-to-base.cpp
index 6e4a3fa87a8..b846d2c28bb 100644
--- a/clang/test/Analysis/derived-to-base.cpp
+++ b/clang/test/Analysis/derived-to-base.cpp
@@ -333,3 +333,33 @@ namespace LazyBindings {
}
#endif
}
+
+namespace Redeclaration {
+ class Base;
+
+ class Base {
+ public:
+ virtual int foo();
+ int get() { return value; }
+
+ int value;
+ };
+
+ class Derived : public Base {
+ public:
+ virtual int bar();
+ };
+
+ void test(Derived d) {
+ d.foo(); // don't crash
+ d.bar(); // sanity check
+
+ Base &b = d;
+ b.foo(); // don't crash
+
+ d.value = 42; // don't crash
+ clang_analyzer_eval(d.get() == 42); // expected-warning{{TRUE}}
+ clang_analyzer_eval(b.get() == 42); // expected-warning{{TRUE}}
+ }
+};
+
OpenPOWER on IntegriCloud