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 { 40 virtual void anchor(); 41public: 42 virtual ~Callback() {} 43 virtual void HandleUnreachable(SourceLocation L, SourceRange R1, 44 SourceRange R2) = 0; 45}; 46 47/// ScanReachableFromBlock - Mark all blocks reachable from Start. 48/// Returns the total number of blocks that were marked reachable. 49unsigned ScanReachableFromBlock(const CFGBlock *Start, 50 llvm::BitVector &Reachable); 51 52void FindUnreachableCode(AnalysisDeclContext &AC, Callback &CB); 53 54}} // end namespace clang::reachable_code 55 56#endif 57