summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@google.com>2016-05-10 17:44:55 +0000
committerDerek Schuff <dschuff@google.com>2016-05-10 17:44:55 +0000
commit8179be4897db025dd7256bbee7c0d9e5794a2b34 (patch)
tree78dc08b1c3578d7505ee2565cc1f8939f6a93c50 /clang/lib/CodeGen
parent09b2492387267439d20f59725bd8caf0a24d0a41 (diff)
downloadbcm5719-llvm-8179be4897db025dd7256bbee7c0d9e5794a2b34.tar.gz
bcm5719-llvm-8179be4897db025dd7256bbee7c0d9e5794a2b34.zip
Introduce CGCXXABI::canCallMismatchedFunctionType
llvm-svn: 269089
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGCXXABI.h10
-rw-r--r--clang/lib/CodeGen/CGDeclCXX.cpp9
-rw-r--r--clang/lib/CodeGen/ItaniumCXXABI.cpp1
3 files changed, 16 insertions, 4 deletions
diff --git a/clang/lib/CodeGen/CGCXXABI.h b/clang/lib/CodeGen/CGCXXABI.h
index 3f240b1802b..8c0f6c2efd5 100644
--- a/clang/lib/CodeGen/CGCXXABI.h
+++ b/clang/lib/CodeGen/CGCXXABI.h
@@ -106,6 +106,16 @@ public:
virtual bool hasMostDerivedReturn(GlobalDecl GD) const { return false; }
+ /// Returns true if the target allows calling a function through a pointer
+ /// with a different signature than the actual function (or equivalently,
+ /// bitcasting a function or function pointer to a different function type).
+ /// In principle in the most general case this could depend on the target, the
+ /// calling convention, and the actual types of the arguments and return
+ /// value. Here it just means whether the signature mismatch could *ever* be
+ /// allowed; in other words, does the target do strict checking of signatures
+ /// for all calls.
+ virtual bool canCallMismatchedFunctionType() const { return true; }
+
/// If the C++ ABI requires the given type be returned in a particular way,
/// this method sets RetAI and returns true.
virtual bool classifyReturnType(CGFunctionInfo &FI) const = 0;
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 46d92ec46c4..89d142e44b4 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -88,11 +88,12 @@ static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D,
// Special-case non-array C++ destructors, if they have the right signature.
// Under some ABIs, destructors return this instead of void, and cannot be
- // passed directly to __cxa_atexit.
+ // passed directly to __cxa_atexit if the target does not allow this mismatch.
const CXXRecordDecl *Record = type->getAsCXXRecordDecl();
- bool CanRegisterDestructor = Record &&
- !CGM.getCXXABI().HasThisReturn(GlobalDecl(
- Record->getDestructor(), Dtor_Complete));
+ bool CanRegisterDestructor =
+ Record && (!CGM.getCXXABI().HasThisReturn(
+ GlobalDecl(Record->getDestructor(), Dtor_Complete)) ||
+ CGM.getCXXABI().canCallMismatchedFunctionType());
// If __cxa_atexit is disabled via a flag, a different helper function is
// generated elsewhere which uses atexit instead, and it takes the destructor
// directly.
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 52e519f3044..4da7b9498f6 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -443,6 +443,7 @@ private:
(isa<CXXDestructorDecl>(GD.getDecl()) &&
GD.getDtorType() != Dtor_Deleting);
}
+ bool canCallMismatchedFunctionType() const override { return false; }
};
}
OpenPOWER on IntegriCloud