Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/CodeGen/Address.h
Show All 16 Lines | |||||
#include "llvm/IR/Constants.h" | #include "llvm/IR/Constants.h" | ||||
#include "clang/AST/CharUnits.h" | #include "clang/AST/CharUnits.h" | ||||
namespace clang { | namespace clang { | ||||
namespace CodeGen { | namespace CodeGen { | ||||
/// An aligned address. | /// An aligned address. | ||||
class Address { | class Address { | ||||
llvm::Value *Pointer; | llvm::Value *Pointer = nullptr; | ||||
CharUnits Alignment; | CharUnits Alignment; | ||||
public: | public: | ||||
Address() { assert(!isValid()); } | |||||
Address(llvm::Value *pointer, CharUnits alignment) | Address(llvm::Value *pointer, CharUnits alignment) | ||||
: Pointer(pointer), Alignment(alignment) { | : Pointer(pointer), Alignment(alignment) { | ||||
assert((!alignment.isZero() || pointer == nullptr) && | assert((!alignment.isZero() || pointer == nullptr) && | ||||
wingo: It would be nice to assert(isValid()) here but that's not how Address is used; you can pass in… | |||||
"creating valid address with invalid alignment"); | "creating valid address with invalid alignment"); | ||||
} | } | ||||
static Address invalid() { return Address(nullptr, CharUnits()); } | static Address invalid() { return Address(); } | ||||
bool isValid() const { return Pointer != nullptr; } | bool isValid() const { return Pointer != nullptr; } | ||||
llvm::Value *getPointer() const { | llvm::Value *getPointer() const { | ||||
assert(isValid()); | assert(isValid()); | ||||
return Pointer; | return Pointer; | ||||
} | } | ||||
/// Return the type of the pointer value. | /// Return the type of the pointer value. | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |
It would be nice to assert(isValid()) here but that's not how Address is used; you can pass in a nullptr as the first argument.