mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-30 04:35:00 +00:00
Use a real union for IdentifyingPassPtr.
This avoids a nasty const correctness issue (AnalysisIDs are const, Pass* isn't). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179213 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bccd635fba
commit
8f5836510a
@ -50,24 +50,26 @@ class PassConfigImpl;
|
||||
///
|
||||
/// AnalysisID is sadly char*, so PointerIntPair won't work.
|
||||
class IdentifyingPassPtr {
|
||||
void *P;
|
||||
union {
|
||||
AnalysisID ID;
|
||||
Pass *P;
|
||||
};
|
||||
bool IsInstance;
|
||||
public:
|
||||
IdentifyingPassPtr(): P(0), IsInstance(false) {}
|
||||
IdentifyingPassPtr(AnalysisID IDPtr): P((void*)IDPtr), IsInstance(false) {}
|
||||
IdentifyingPassPtr(Pass *InstancePtr)
|
||||
: P((void*)InstancePtr), IsInstance(true) {}
|
||||
IdentifyingPassPtr() : P(0), IsInstance(false) {}
|
||||
IdentifyingPassPtr(AnalysisID IDPtr) : ID(IDPtr), IsInstance(false) {}
|
||||
IdentifyingPassPtr(Pass *InstancePtr) : P(InstancePtr), IsInstance(true) {}
|
||||
|
||||
bool isValid() const { return P; }
|
||||
bool isInstance() const { return IsInstance; }
|
||||
|
||||
AnalysisID getID() const {
|
||||
assert(!IsInstance && "Not a Pass ID");
|
||||
return (AnalysisID)P;
|
||||
return ID;
|
||||
}
|
||||
Pass *getInstance() const {
|
||||
assert(IsInstance && "Not a Pass Instance");
|
||||
return (Pass *)P;
|
||||
return P;
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user