summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-10-24 00:30:41 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-10-24 00:30:41 +0000
commit1f6f455f7cff444f663dbe5d844fe0a8548a083c (patch)
tree8c44f6cca2f037d947253d6d82560397d10982e6
parent1bbd143945ee57c30870cd452e0755dad54ec525 (diff)
downloadbcm5719-llvm-1f6f455f7cff444f663dbe5d844fe0a8548a083c.tar.gz
bcm5719-llvm-1f6f455f7cff444f663dbe5d844fe0a8548a083c.zip
Fix ODR violations: a virtual function must be defined, even if it's never
called. Provide an (asserting) definition of Operator's private destructor. Remove destructors from all classes derived from Operator. We don't need them for safety, because their implicit definitions would be ill-formed (they'd call Operator's private destructor), and we don't need them to avoid emitting vtables, because we don't do anything with Operator subclasses which would trigger vtable instantiation. The Operator hierarchy is still a complete disaster with regard to undefined behavior, but this at least allows LLVM to link when using Clang's -fcatch-undefined-behavior with a new vptr-based type checking mechanism. llvm-svn: 166530
-rw-r--r--llvm/include/llvm/Operator.h24
-rw-r--r--llvm/lib/VMCore/User.cpp9
2 files changed, 13 insertions, 20 deletions
diff --git a/llvm/include/llvm/Operator.h b/llvm/include/llvm/Operator.h
index 462324a6694..41e6db0b961 100644
--- a/llvm/include/llvm/Operator.h
+++ b/llvm/include/llvm/Operator.h
@@ -36,8 +36,10 @@ private:
void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
void *operator new(size_t s) LLVM_DELETED_FUNCTION;
Operator() LLVM_DELETED_FUNCTION;
- // NOTE: cannot use LLVM_DELETED_FUNCTION because it's not legal to delete
- // an overridden method that's not deleted in the base class.
+
+ // NOTE: Cannot use LLVM_DELETED_FUNCTION because it's not legal to delete
+ // an overridden method that's not deleted in the base class. Cannot leave
+ // this unimplemented because that leads to an ODR-violation.
~Operator();
public:
@@ -79,8 +81,6 @@ public:
};
private:
- ~OverflowingBinaryOperator(); // DO NOT IMPLEMENT
-
friend class BinaryOperator;
friend class ConstantExpr;
void setHasNoUnsignedWrap(bool B) {
@@ -132,8 +132,6 @@ public:
};
private:
- ~PossiblyExactOperator(); // DO NOT IMPLEMENT
-
friend class BinaryOperator;
friend class ConstantExpr;
void setIsExact(bool B) {
@@ -168,9 +166,6 @@ public:
/// FPMathOperator - Utility class for floating point operations which can have
/// information about relaxed accuracy requirements attached to them.
class FPMathOperator : public Operator {
-private:
- ~FPMathOperator(); // DO NOT IMPLEMENT
-
public:
/// \brief Get the maximum error permitted by this operation in ULPs. An
@@ -191,7 +186,6 @@ public:
/// opcodes.
template<typename SuperClass, unsigned Opc>
class ConcreteOperator : public SuperClass {
- ~ConcreteOperator(); // DO NOT IMPLEMENT
public:
static inline bool classof(const Instruction *I) {
return I->getOpcode() == Opc;
@@ -207,45 +201,35 @@ public:
class AddOperator
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {
- ~AddOperator(); // DO NOT IMPLEMENT
};
class SubOperator
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Sub> {
- ~SubOperator(); // DO NOT IMPLEMENT
};
class MulOperator
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Mul> {
- ~MulOperator(); // DO NOT IMPLEMENT
};
class ShlOperator
: public ConcreteOperator<OverflowingBinaryOperator, Instruction::Shl> {
- ~ShlOperator(); // DO NOT IMPLEMENT
};
class SDivOperator
: public ConcreteOperator<PossiblyExactOperator, Instruction::SDiv> {
- ~SDivOperator(); // DO NOT IMPLEMENT
};
class UDivOperator
: public ConcreteOperator<PossiblyExactOperator, Instruction::UDiv> {
- ~UDivOperator(); // DO NOT IMPLEMENT
};
class AShrOperator
: public ConcreteOperator<PossiblyExactOperator, Instruction::AShr> {
- ~AShrOperator(); // DO NOT IMPLEMENT
};
class LShrOperator
: public ConcreteOperator<PossiblyExactOperator, Instruction::LShr> {
- ~LShrOperator(); // DO NOT IMPLEMENT
};
class GEPOperator
: public ConcreteOperator<Operator, Instruction::GetElementPtr> {
- ~GEPOperator(); // DO NOT IMPLEMENT
-
enum {
IsInBounds = (1 << 0)
};
diff --git a/llvm/lib/VMCore/User.cpp b/llvm/lib/VMCore/User.cpp
index 5f35ce4b9a4..e847ce6ee5c 100644
--- a/llvm/lib/VMCore/User.cpp
+++ b/llvm/lib/VMCore/User.cpp
@@ -10,6 +10,7 @@
#include "llvm/Constant.h"
#include "llvm/GlobalValue.h"
#include "llvm/User.h"
+#include "llvm/Operator.h"
namespace llvm {
@@ -78,4 +79,12 @@ void User::operator delete(void *Usr) {
::operator delete(Storage);
}
+//===----------------------------------------------------------------------===//
+// Operator Class
+//===----------------------------------------------------------------------===//
+
+Operator::~Operator() {
+ llvm_unreachable("should never destroy an Operator");
+}
+
} // End llvm namespace
OpenPOWER on IntegriCloud