ReachableCode.h revision 1d26f48dc2eea1c07431ca1519d7034a21b9bcff
1//===- ReachableCode.h -----------------------------------------*- C++ --*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// A flow-sensitive, path-insensitive analysis of unreachable code.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_REACHABLECODE_H
15#define LLVM_CLANG_REACHABLECODE_H
16
17#include "clang/Basic/SourceLocation.h"
18
19//===----------------------------------------------------------------------===//
20// Forward declarations.
21//===----------------------------------------------------------------------===//
22
23namespace llvm {
24  class BitVector;
25}
26
27namespace clang {
28  class AnalysisDeclContext;
29  class CFGBlock;
30}
31
32//===----------------------------------------------------------------------===//
33// API.
34//===----------------------------------------------------------------------===//
35
36namespace clang {
37namespace reachable_code {
38
39class Callback {
40public:
41  virtual ~Callback() {}
42  virtual void HandleUnreachable(SourceLocation L, SourceRange R1,
43                                 SourceRange R2) = 0;
44};
45
46/// ScanReachableFromBlock - Mark all blocks reachable from Start.
47/// Returns the total number of blocks that were marked reachable.
48unsigned ScanReachableFromBlock(const CFGBlock *Start,
49                                llvm::BitVector &Reachable);
50
51void FindUnreachableCode(AnalysisDeclContext &AC, Callback &CB);
52
53}} // end namespace clang::reachable_code
54
55#endif
56