diff options
author | Ted Kremenek <kremenek@apple.com> | 2014-02-27 00:24:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2014-02-27 00:24:00 +0000 |
commit | 4b6fee6cc4f367bf6a6728cd8ae02928a422d8ce (patch) | |
tree | cbfb44fa698024af9f3c0a051f642ed3cecfd3dc /clang/lib/Analysis/UninitializedValues.cpp | |
parent | 2eab2bd86d82637df6df12a3792e5f0513a88e35 (diff) | |
download | llvm-4b6fee6cc4f367bf6a6728cd8ae02928a422d8ce.zip llvm-4b6fee6cc4f367bf6a6728cd8ae02928a422d8ce.tar.gz llvm-4b6fee6cc4f367bf6a6728cd8ae02928a422d8ce.tar.bz2 |
Rework CFG edges to encode potentially unreachable edges, instead of just making them NULL.
This is to support some analyses, like -Wunreachable-code, that
will need to recover the original unprunned CFG edges in order
to suppress issues that aren't really bugs in practice.
There are two important changes here:
- AdjacentBlock replaces CFGBlock* for CFG successors/predecessors.
This has the size of 2 pointers, instead of 1. This is unlikely
to have a significant memory impact on Sema since a single
CFG usually exists at one time, but could impact the memory
usage of the static analyzer. This could possibly be optimized
down to a single pointer with some cleverness.
- Predecessors can now contain null predecessors, which means
some analyses doing a reverse traversal will need to take into
account. This already exists for successors, which contain
successor slots for specific branch kinds (e.g., 'if') that
expect a fixed number of successors, even if a branch is
not reachable.
llvm-svn: 202325
Diffstat (limited to 'clang/lib/Analysis/UninitializedValues.cpp')
-rw-r--r-- | clang/lib/Analysis/UninitializedValues.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp index 332c02c..8e8ccb0 100644 --- a/clang/lib/Analysis/UninitializedValues.cpp +++ b/clang/lib/Analysis/UninitializedValues.cpp @@ -535,6 +535,9 @@ public: for (CFGBlock::const_pred_iterator I = B->pred_begin(), E = B->pred_end(); I != E; ++I) { const CFGBlock *Pred = *I; + if (!Pred) + continue; + Value AtPredExit = vals.getValue(Pred, B, vd); if (AtPredExit == Initialized) // This block initializes the variable. @@ -751,6 +754,8 @@ static bool runOnBlock(const CFGBlock *block, const CFG &cfg, for (CFGBlock::const_pred_iterator I = block->pred_begin(), E = block->pred_end(); I != E; ++I) { const CFGBlock *pred = *I; + if (!pred) + continue; if (wasAnalyzed[pred->getBlockID()]) { vals.mergeIntoScratch(vals.getValueVector(pred), isFirst); isFirst = false; |