summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-04-23 08:08:49 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-04-23 08:08:49 +0000
commit07c2241e45915922e0c7bede9558dcd6f318ebdc (patch)
treef6247323c0744a90476058bc8fabbe55fc3e5c68 /include
parent3890a42255db18888bfd16abe1b210b8bfd21645 (diff)
downloadllvm-07c2241e45915922e0c7bede9558dcd6f318ebdc.tar.gz
llvm-07c2241e45915922e0c7bede9558dcd6f318ebdc.tar.bz2
llvm-07c2241e45915922e0c7bede9558dcd6f318ebdc.tar.xz
[LCG] Add a unittest for the LazyCallGraph. I had a weak moment and
resisted this for too long. Just with the basic testing here I was able to exercise the analysis in more detail and sift out both type signature bugs in the API and a bug in the DFS numbering. All of these are fixed here as well. The unittests will be much more important for the mutation support where it is necessary to craft minimal mutations and then inspect the state of the graph. There is just no way to do that with a standard FileCheck test. However, unittesting these kinds of analyses is really quite easy, especially as they're designed with the new pass manager where there is essentially no infrastructure required to rig up the core logic and exercise it at an API level. As a minor aside about the DFS numbering bug, the DFS numbering used in LCG is a bit unusual. Rather than numbering from 0, we number from 1, and use 0 as the sentinel "unvisited" state. Other implementations often use '-1' for this, but I find it easier to deal with 0 and it shouldn't make any real difference provided someone doesn't write silly bugs like forgetting to actually initialize the DFS numbering. Oops. ;] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206954 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/LazyCallGraph.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/llvm/Analysis/LazyCallGraph.h b/include/llvm/Analysis/LazyCallGraph.h
index 26eac3180d..ecb2f1530e 100644
--- a/include/llvm/Analysis/LazyCallGraph.h
+++ b/include/llvm/Analysis/LazyCallGraph.h
@@ -134,8 +134,8 @@ public:
: G(&G), NI(Nodes.end()) {}
public:
- bool operator==(const iterator &Arg) { return NI == Arg.NI; }
- bool operator!=(const iterator &Arg) { return !operator==(Arg); }
+ bool operator==(const iterator &Arg) const { return NI == Arg.NI; }
+ bool operator!=(const iterator &Arg) const { return !operator==(Arg); }
reference operator*() const {
if (NI->is<Node *>())
@@ -260,10 +260,10 @@ public:
: G(&G), C(nullptr) {}
public:
- bool operator==(const postorder_scc_iterator &Arg) {
+ bool operator==(const postorder_scc_iterator &Arg) const {
return G == Arg.G && C == Arg.C;
}
- bool operator!=(const postorder_scc_iterator &Arg) {
+ bool operator!=(const postorder_scc_iterator &Arg) const {
return !operator==(Arg);
}