Added an automatic cast to "std::ostream*" etc. from OStream. We then can

rework the hacks that had us passing OStream in. We pass in std::ostream*
instead, check for null, and then dispatch to the correct print() method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32636 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling
2006-12-17 05:15:13 +00:00
parent 89b0d995d2
commit 5c7e326585
46 changed files with 138 additions and 165 deletions

View File

@@ -156,10 +156,8 @@ public:
iterator end() const { return iterator(); }
bool empty() const { return PtrList == 0; }
void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream());
}
void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
void dump() const;
/// Define an iterator for alias sets... this is just a forward iterator.
@@ -248,10 +246,6 @@ private:
bool aliasesCallSite(CallSite CS, AliasAnalysis &AA) const;
};
inline OStream& operator<<(OStream &OS, const AliasSet &AS) {
AS.print(OS);
return OS;
}
inline std::ostream& operator<<(std::ostream &OS, const AliasSet &AS) {
AS.print(OS);
return OS;
@@ -361,10 +355,8 @@ public:
iterator begin() { return AliasSets.begin(); }
iterator end() { return AliasSets.end(); }
void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream());
}
void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
void dump() const;
private:
@@ -390,10 +382,6 @@ private:
AliasSet *findAliasSetForCallSite(CallSite CS);
};
inline OStream& operator<<(OStream &OS, const AliasSetTracker &AST) {
AST.print(OS);
return OS;
}
inline std::ostream& operator<<(std::ostream &OS, const AliasSetTracker &AST) {
AST.print(OS);
return OS;

View File

@@ -152,10 +152,8 @@ public:
///
void initialize(Module &M);
void print(OStream &o, const Module *M) const {
if (o.stream()) print(*o.stream(), M);
}
virtual void print(std::ostream &o, const Module *M) const;
void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
void dump() const;
// stub - dummy function, just ignore it
@@ -201,10 +199,8 @@ public:
/// dump - Print out this call graph node.
///
void dump() const;
void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream());
}
void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
//===---------------------------------------------------------------------
// Methods to keep a call graph up to date with a function that has been

View File

@@ -144,6 +144,9 @@ public:
/// print - Convert to human readable form
///
virtual void print(std::ostream &OS, const Module* = 0) const;
void print(std::ostream *OS, const Module* M = 0) const {
if (OS) print(*OS, M);
}
};
//===-------------------------------------
@@ -234,6 +237,9 @@ public:
/// print - Convert to human readable form
///
virtual void print(std::ostream &OS, const Module* = 0) const;
void print(std::ostream *OS, const Module* M = 0) const {
if (OS) print(*OS, M);
}
/// dominates - Return true if A dominates B. This performs the special
/// checks necessary if A and B are in the same basic block.
@@ -410,6 +416,9 @@ public:
/// print - Convert to human readable form
///
virtual void print(std::ostream &OS, const Module* = 0) const;
void print(std::ostream *OS, const Module* M = 0) const {
if (OS) print(*OS, M);
}
};
//===-------------------------------------
@@ -546,6 +555,9 @@ public:
/// print - Convert to human readable form
///
virtual void print(std::ostream &OS, const Module* = 0) const;
void print(std::ostream *OS, const Module* M = 0) const {
if (OS) print(*OS, M);
}
protected:
/// getNode - return the (Post)DominatorTree node for the specified basic
/// block. This is the same as using operator[] on this class.
@@ -635,6 +647,9 @@ public:
/// print - Convert to human readable form
///
virtual void print(std::ostream &OS, const Module* = 0) const;
void print(std::ostream *OS, const Module* M = 0) const {
if (OS) print(*OS, M);
}
};

View File

@@ -34,6 +34,7 @@ public:
/// symbol table from the module.
///
void print(std::ostream &o, const Module *M) const;
void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
private:
/// IncorporateType - Incorporate one type and all of its subtypes into the

View File

@@ -99,6 +99,7 @@ public:
/// print - Show contents in human readable format...
void print(std::ostream &O) const;
void print(std::ostream *O) const { if (O) print(*O); }
};
/// succ_begin/succ_end - define methods so that Intervals may be used

View File

@@ -61,6 +61,9 @@ public:
// print - Show contents in human readable format...
virtual void print(std::ostream &O, const Module* = 0) const;
void print(std::ostream *O, const Module* M = 0) const {
if (O) print(*O, M);
}
// getRootInterval() - Return the root interval that contains the starting
// block of the function.

View File

@@ -217,10 +217,10 @@ public:
/// the mapping in the LoopInfo class.
void removeBlockFromLoop(BasicBlock *BB);
void print(OStream &O, unsigned Depth = 0) const {
if (O.stream()) print(*O.stream(), Depth);
}
void print(std::ostream &O, unsigned Depth = 0) const;
void print(std::ostream *O, unsigned Depth = 0) const {
if (O) print(*O, Depth);
}
void dump() const;
private:
friend class LoopInfo;
@@ -283,10 +283,11 @@ public:
virtual bool runOnFunction(Function &F);
virtual void releaseMemory();
void print(OStream &O, const Module* = 0) const {
if (O.stream()) print(*O.stream());
}
void print(std::ostream &O, const Module* = 0) const;
void print(std::ostream *O, const Module* M = 0) const {
if (O) print(*O, M);
}
virtual void getAnalysisUsage(AnalysisUsage &AU) const;

View File

@@ -97,20 +97,14 @@ namespace llvm {
/// print - Print out the internal representation of this scalar to the
/// specified stream. This should really only be used for debugging
/// purposes.
void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream());
}
virtual void print(std::ostream &OS) const = 0;
void print(std::ostream *OS) const { if (OS) print(*OS); }
/// dump - This method is used for debugging.
///
void dump() const;
};
inline OStream &operator<<(OStream &OS, const SCEV &S) {
S.print(OS);
return OS;
}
inline std::ostream &operator<<(std::ostream &OS, const SCEV &S) {
S.print(OS);
return OS;
@@ -128,10 +122,8 @@ namespace llvm {
virtual bool isLoopInvariant(const Loop *L) const;
virtual const Type *getType() const;
virtual bool hasComputableLoopEvolution(const Loop *L) const;
void print(OStream &OS) const {
if (OS.stream()) print(*OS.stream());
}
virtual void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
virtual SCEVHandle
replaceSymbolicValuesWithConcrete(const SCEVHandle &Sym,
const SCEVHandle &Conc) const;
@@ -242,10 +234,10 @@ namespace llvm {
virtual bool runOnFunction(Function &F);
virtual void releaseMemory();
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
void print(OStream &OS, const Module* = 0) const {
if (OS.stream()) print(*OS.stream());
}
virtual void print(std::ostream &OS, const Module* = 0) const;
void print(std::ostream *OS, const Module* M = 0) const {
if (OS) print(*OS, M);
}
};
}

View File

@@ -62,6 +62,7 @@ namespace llvm {
}
virtual void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SCEVConstant *S) { return true; }
@@ -108,6 +109,7 @@ namespace llvm {
virtual ConstantRange getValueRange() const;
virtual void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SCEVTruncateExpr *S) { return true; }
@@ -154,6 +156,7 @@ namespace llvm {
}
virtual void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SCEVZeroExtendExpr *S) { return true; }
@@ -218,6 +221,7 @@ namespace llvm {
virtual const Type *getType() const { return getOperand(0)->getType(); }
virtual void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SCEVCommutativeExpr *S) { return true; }
@@ -332,6 +336,7 @@ namespace llvm {
virtual const Type *getType() const;
void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SCEVSDivExpr *S) { return true; }
@@ -428,6 +433,7 @@ namespace llvm {
const SCEVHandle &Conc) const;
virtual void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SCEVAddRecExpr *S) { return true; }
@@ -472,6 +478,7 @@ namespace llvm {
virtual const Type *getType() const;
virtual void print(std::ostream &OS) const;
void print(std::ostream *OS) const { if (OS) print(*OS); }
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SCEVUnknown *S) { return true; }

View File

@@ -106,7 +106,8 @@ public:
/// print - Write trace to output stream.
///
void print (OStream &O) const;
void print (std::ostream &O) const;
void print (std::ostream *O) const { if (O) print(*O); }
/// dump - Debugger convenience method; writes trace to standard error
/// output stream.