summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/MicrosoftCXXABI.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-01-27 02:46:02 +0000
committerJohn McCall <rjmccall@apple.com>2011-01-27 02:46:02 +0000
commit2903675929d83e60083d84f4d2620093ffc0ccb2 (patch)
tree4ded46f80b4e988221c682be06908a157491f672 /clang/lib/CodeGen/MicrosoftCXXABI.cpp
parenta148c59231add155298555996e3d01b521c2628a (diff)
downloadbcm5719-llvm-2903675929d83e60083d84f4d2620093ffc0ccb2.tar.gz
bcm5719-llvm-2903675929d83e60083d84f4d2620093ffc0ccb2.zip
Notes on dynamic array cookies in MSVC.
My thanks to chapuni for his help in investigating this. llvm-svn: 124351
Diffstat (limited to 'clang/lib/CodeGen/MicrosoftCXXABI.cpp')
-rw-r--r--clang/lib/CodeGen/MicrosoftCXXABI.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index ea2e55fcb28..3a63eba3974 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -55,6 +55,29 @@ public:
EmitThisParam(CGF);
// TODO: 'for base' flag
}
+
+ // ==== Notes on array cookies =========
+ //
+ // MSVC seems to only use cookies when the class has a destructor; a
+ // two-argument usual array deallocation function isn't sufficient.
+ //
+ // For example, this code prints "100" and "1":
+ // struct A {
+ // char x;
+ // void *operator new[](size_t sz) {
+ // printf("%u\n", sz);
+ // return malloc(sz);
+ // }
+ // void operator delete[](void *p, size_t sz) {
+ // printf("%u\n", sz);
+ // free(p);
+ // }
+ // };
+ // int main() {
+ // A *p = new A[100];
+ // delete[] p;
+ // }
+ // Whereas it prints "104" and "104" if you give A a destructor.
};
}
OpenPOWER on IntegriCloud