aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-09-02 09:58:18 +0000
committerJohn McCall <rjmccall@apple.com>2010-09-02 09:58:18 +0000
commit8ed55a54fdcb7a0bb9af26f1fe59e3e7ef688f7a (patch)
tree3350c44942ae4288ee192a202d6f16235a3aa53b /clang/lib/CodeGen/CGCXX.cpp
parent7f1982731e5cda60ceb910b6cddc0825e1f7caa6 (diff)
downloadllvm-8ed55a54fdcb7a0bb9af26f1fe59e3e7ef688f7a.zip
llvm-8ed55a54fdcb7a0bb9af26f1fe59e3e7ef688f7a.tar.gz
llvm-8ed55a54fdcb7a0bb9af26f1fe59e3e7ef688f7a.tar.bz2
Abstract IR generation of array cookies into the C++ ABI class and
implement ARM array cookies. Also fix a few unfortunate bugs: - throwing dtors in deletes prevented the allocation from being deleted - adding the cookie to the new[] size was not being considered for overflow (and, more seriously, was screwing up the earlier checks) - deleting an array via a pointer to array of class type was not causing any destructors to be run and was passing the unadjusted pointer to the deallocator - lots of address-space problems, in case anyone wants to support free store in a variant address space :) llvm-svn: 112814
Diffstat (limited to 'clang/lib/CodeGen/CGCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGCXX.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp
index f8d81fa..179716f 100644
--- a/clang/lib/CodeGen/CGCXX.cpp
+++ b/clang/lib/CodeGen/CGCXX.cpp
@@ -327,7 +327,7 @@ static void ErrorUnsupportedABI(CodeGenFunction &CGF,
llvm::StringRef S) {
Diagnostic &Diags = CGF.CGM.getDiags();
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
- "cannot yet compile %s in this ABI");
+ "cannot yet compile %1 in this ABI");
Diags.Report(CGF.getContext().getFullLoc(CGF.CurCodeDecl->getLocation()),
DiagID)
<< S;
@@ -445,3 +445,27 @@ void CGCXXABI::EmitReturnFromThunk(CodeGenFunction &CGF,
RValue RV, QualType ResultType) {
CGF.EmitReturnOfRValue(RV, ResultType);
}
+
+CharUnits CGCXXABI::GetArrayCookieSize(QualType ElementType) {
+ return CharUnits::Zero();
+}
+
+llvm::Value *CGCXXABI::InitializeArrayCookie(CodeGenFunction &CGF,
+ llvm::Value *NewPtr,
+ llvm::Value *NumElements,
+ QualType ElementType) {
+ // Should never be called.
+ ErrorUnsupportedABI(CGF, "array cookie initialization");
+ return 0;
+}
+
+void CGCXXABI::ReadArrayCookie(CodeGenFunction &CGF, llvm::Value *Ptr,
+ QualType ElementType, llvm::Value *&NumElements,
+ llvm::Value *&AllocPtr, CharUnits &CookieSize) {
+ ErrorUnsupportedABI(CGF, "array cookie reading");
+
+ // This should be enough to avoid assertions.
+ NumElements = 0;
+ AllocPtr = llvm::Constant::getNullValue(CGF.Builder.getInt8PtrTy());
+ CookieSize = CharUnits::Zero();
+}