clang API Documentation
00001 //===- ReachableCode.h -----------------------------------------*- C++ --*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // A flow-sensitive, path-insensitive analysis of unreachable code. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #ifndef LLVM_CLANG_REACHABLECODE_H 00015 #define LLVM_CLANG_REACHABLECODE_H 00016 00017 #include "clang/Basic/SourceLocation.h" 00018 00019 //===----------------------------------------------------------------------===// 00020 // Forward declarations. 00021 //===----------------------------------------------------------------------===// 00022 00023 namespace llvm { 00024 class BitVector; 00025 } 00026 00027 namespace clang { 00028 class AnalysisDeclContext; 00029 class CFGBlock; 00030 } 00031 00032 //===----------------------------------------------------------------------===// 00033 // API. 00034 //===----------------------------------------------------------------------===// 00035 00036 namespace clang { 00037 namespace reachable_code { 00038 00039 class Callback { 00040 virtual void anchor(); 00041 public: 00042 virtual ~Callback() {} 00043 virtual void HandleUnreachable(SourceLocation L, SourceRange R1, 00044 SourceRange R2) = 0; 00045 }; 00046 00047 /// ScanReachableFromBlock - Mark all blocks reachable from Start. 00048 /// Returns the total number of blocks that were marked reachable. 00049 unsigned ScanReachableFromBlock(const CFGBlock *Start, 00050 llvm::BitVector &Reachable); 00051 00052 void FindUnreachableCode(AnalysisDeclContext &AC, Callback &CB); 00053 00054 }} // end namespace clang::reachable_code 00055 00056 #endif