Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:23

0001 //===- ReachableCode.h -----------------------------------------*- C++ --*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // A flow-sensitive, path-insensitive analysis of unreachable code.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_REACHABLECODE_H
0014 #define LLVM_CLANG_ANALYSIS_ANALYSES_REACHABLECODE_H
0015 
0016 #include "clang/Basic/SourceLocation.h"
0017 
0018 //===----------------------------------------------------------------------===//
0019 // Forward declarations.
0020 //===----------------------------------------------------------------------===//
0021 
0022 namespace llvm {
0023   class BitVector;
0024 }
0025 
0026 namespace clang {
0027   class AnalysisDeclContext;
0028   class CFGBlock;
0029   class Preprocessor;
0030 }
0031 
0032 //===----------------------------------------------------------------------===//
0033 // API.
0034 //===----------------------------------------------------------------------===//
0035 
0036 namespace clang {
0037 namespace reachable_code {
0038 
0039 /// Classifications of unreachable code.
0040 enum UnreachableKind {
0041   UK_Return,
0042   UK_Break,
0043   UK_Loop_Increment,
0044   UK_Other
0045 };
0046 
0047 class Callback {
0048   virtual void anchor();
0049 public:
0050   virtual ~Callback() {}
0051   virtual void HandleUnreachable(UnreachableKind UK, SourceLocation L,
0052                                  SourceRange ConditionVal, SourceRange R1,
0053                                  SourceRange R2, bool HasFallThroughAttr) = 0;
0054 };
0055 
0056 /// ScanReachableFromBlock - Mark all blocks reachable from Start.
0057 /// Returns the total number of blocks that were marked reachable.
0058 unsigned ScanReachableFromBlock(const CFGBlock *Start,
0059                                 llvm::BitVector &Reachable);
0060 
0061 void FindUnreachableCode(AnalysisDeclContext &AC, Preprocessor &PP,
0062                          Callback &CB);
0063 
0064 }} // end namespace clang::reachable_code
0065 
0066 #endif