wingo created this revision. wingo added a reviewer: rjmccall. wingo requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This allows a declaration of an Address to be invalid by default, allowing it to be added to e.g. a DenseMap. Will followup with a cleanup. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D108458 Files: clang/lib/CodeGen/Address.h Index: clang/lib/CodeGen/Address.h =================================================================== --- clang/lib/CodeGen/Address.h +++ clang/lib/CodeGen/Address.h @@ -22,16 +22,17 @@ /// An aligned address. class Address { - llvm::Value *Pointer; + llvm::Value *Pointer = nullptr; CharUnits Alignment; public: + Address() { assert(!isValid()); } Address(llvm::Value *pointer, CharUnits alignment) : Pointer(pointer), Alignment(alignment) { assert((!alignment.isZero() || pointer == nullptr) && "creating valid address with invalid alignment"); } - static Address invalid() { return Address(nullptr, CharUnits()); } + static Address invalid() { return Address(); } bool isValid() const { return Pointer != nullptr; } llvm::Value *getPointer() const {
Index: clang/lib/CodeGen/Address.h =================================================================== --- clang/lib/CodeGen/Address.h +++ clang/lib/CodeGen/Address.h @@ -22,16 +22,17 @@ /// An aligned address. class Address { - llvm::Value *Pointer; + llvm::Value *Pointer = nullptr; CharUnits Alignment; public: + Address() { assert(!isValid()); } Address(llvm::Value *pointer, CharUnits alignment) : Pointer(pointer), Alignment(alignment) { assert((!alignment.isZero() || pointer == nullptr) && "creating valid address with invalid alignment"); } - static Address invalid() { return Address(nullptr, CharUnits()); } + static Address invalid() { return Address(); } bool isValid() const { return Pointer != nullptr; } llvm::Value *getPointer() const {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits