clang  13.0.0git
ReachableCode.h
Go to the documentation of this file.
1 //===- ReachableCode.h -----------------------------------------*- C++ --*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // A flow-sensitive, path-insensitive analysis of unreachable code.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_ANALYSIS_ANALYSES_REACHABLECODE_H
14 #define LLVM_CLANG_ANALYSIS_ANALYSES_REACHABLECODE_H
15 
17 
18 //===----------------------------------------------------------------------===//
19 // Forward declarations.
20 //===----------------------------------------------------------------------===//
21 
22 namespace llvm {
23  class BitVector;
24 }
25 
26 namespace clang {
27  class AnalysisDeclContext;
28  class CFGBlock;
29  class Preprocessor;
30 }
31 
32 //===----------------------------------------------------------------------===//
33 // API.
34 //===----------------------------------------------------------------------===//
35 
36 namespace clang {
37 namespace reachable_code {
38 
39 /// Classifications of unreachable code.
45 };
46 
47 class Callback {
48  virtual void anchor();
49 public:
50  virtual ~Callback() {}
51  virtual void HandleUnreachable(UnreachableKind UK,
53  SourceRange ConditionVal,
54  SourceRange R1,
55  SourceRange R2) = 0;
56 };
57 
58 /// ScanReachableFromBlock - Mark all blocks reachable from Start.
59 /// Returns the total number of blocks that were marked reachable.
60 unsigned ScanReachableFromBlock(const CFGBlock *Start,
61  llvm::BitVector &Reachable);
62 
64  Callback &CB);
65 
66 }} // end namespace clang::reachable_code
67 
68 #endif
llvm
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion.
Definition: Dominators.h:30
clang::reachable_code::FindUnreachableCode
void FindUnreachableCode(AnalysisDeclContext &AC, Preprocessor &PP, Callback &CB)
Definition: ReachableCode.cpp:679
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:212
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:89
clang::reachable_code::UK_Loop_Increment
@ UK_Loop_Increment
Definition: ReachableCode.h:43
clang::AnalysisDeclContext
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Definition: AnalysisDeclContext.h:72
clang::reachable_code::UnreachableKind
UnreachableKind
Classifications of unreachable code.
Definition: ReachableCode.h:40
clang::CFGBlock
Represents a single basic block in a source-level CFG.
Definition: CFG.h:576
clang::reachable_code::Callback::~Callback
virtual ~Callback()
Definition: ReachableCode.h:50
SourceLocation.h
clang::reachable_code::Callback
Definition: ReachableCode.h:47
clang::reachable_code::UK_Return
@ UK_Return
Definition: ReachableCode.h:41
clang::reachable_code::Callback::HandleUnreachable
virtual void HandleUnreachable(UnreachableKind UK, SourceLocation L, SourceRange ConditionVal, SourceRange R1, SourceRange R2)=0
clang
Dataflow Directional Tag Classes.
Definition: CalledOnceCheck.h:17
clang::reachable_code::UK_Other
@ UK_Other
Definition: ReachableCode.h:44
clang::reachable_code::UK_Break
@ UK_Break
Definition: ReachableCode.h:42
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:129
clang::reachable_code::ScanReachableFromBlock
unsigned ScanReachableFromBlock(const CFGBlock *Start, llvm::BitVector &Reachable)
ScanReachableFromBlock - Mark all blocks reachable from Start.
Definition: ReachableCode.cpp:674