diff options
author | Kristof Umann <kristof.umann@ericsson.com> | 2019-09-12 19:52:34 +0000 |
---|---|---|
committer | Kristof Umann <kristof.umann@ericsson.com> | 2019-09-12 19:52:34 +0000 |
commit | 016e799245a32748978475807f9cd1b14cefa0c8 (patch) | |
tree | 284f0051532e91655fdf3e0e4ac635fa38dd3268 /include/clang/Analysis | |
parent | 692350b3324af16d1007a41089b9e5d684230ca3 (diff) |
[CFG] Add dumps for CFGElement and CFGElementRef
Seems like we never had these, so here we go! I also did some refactoring as I
was chasing a bug unrelated to this revision.
Differential Revision: https://reviews.llvm.org/D66715
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@371765 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis')
-rw-r--r-- | include/clang/Analysis/CFG.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/include/clang/Analysis/CFG.h b/include/clang/Analysis/CFG.h index 4c375c7a06..b24e32c966 100644 --- a/include/clang/Analysis/CFG.h +++ b/include/clang/Analysis/CFG.h @@ -121,6 +121,12 @@ public: x |= Data1.getInt(); return (Kind) x; } + + void dumpToStream(llvm::raw_ostream &OS) const; + + void dump() const { + dumpToStream(llvm::errs()); + } }; class CFGStmt : public CFGElement { @@ -650,8 +656,17 @@ class CFGBlock { } bool operator!=(ElementRefImpl Other) const { return !(*this == Other); } - CFGElement operator*() { return (*Parent)[Index]; } - CFGElementPtr operator->() { return &*(Parent->begin() + Index); } + CFGElement operator*() const { return (*Parent)[Index]; } + CFGElementPtr operator->() const { return &*(Parent->begin() + Index); } + + void dumpToStream(llvm::raw_ostream &OS) const { + OS << getIndexInBlock() + 1 << ": "; + (*this)->dumpToStream(OS); + } + + void dump() const { + dumpToStream(llvm::errs()); + } }; template <bool IsReverse, bool IsConst> class ElementRefIterator { |