Skip to content

Commit c2bd657

Browse files
Clarify the relation between BranchCondition and BlockEntrance
1 parent 084d821 commit c2bd657

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

clang/lib/StaticAnalyzer/Checkers/CheckerDocumentation.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,20 @@ class CheckerDocumentation
129129
/// check::PostCall
130130
void checkPostCall(const CallEvent &Call, CheckerContext &C) const {}
131131

132-
/// Pre-visit of the condition statement of a branch (such as IfStmt).
132+
/// Pre-visit of the condition statement of a branch.
133+
/// For example:
134+
/// - logical operators (&&, ||)
135+
/// - if, do, while, for, ranged-for statements
136+
/// - ternary operators (?:), gnu conditionals, gnu choose expressions
137+
/// Interestingly, switch statements don't seem to trigger BranchCondition.
138+
///
139+
/// check::BlockEntrance is a similar callback, which is strictly more
140+
/// generic. Prefer check::BranchCondition to check::BlockEntrance if
141+
/// pre-visiting conditional statements is enough for the checker.
142+
/// Note that check::BlockEntrance is also invoked for leaving basic blocks
143+
/// while entering the next.
144+
///
145+
/// check::BranchCondition
133146
void checkBranchCondition(const Stmt *Condition, CheckerContext &Ctx) const {}
134147

135148
/// Post-visit the C++ operator new's allocation call.
@@ -174,6 +187,10 @@ class CheckerDocumentation
174187
/// and the callee. One will only see the edge between the entry block and
175188
/// the body of the function once inlined.
176189
///
190+
/// check::BranchCondition is a similar callback, which is only invoked for
191+
/// pre-visiting the condition statement of a branch. Prefer that callback if
192+
/// possible.
193+
///
177194
/// \param E The ProgramPoint that describes the transition.
178195
///
179196
/// check::BlockEntrance

0 commit comments

Comments
 (0)