clang 20.0.0git
|
Analyzes the pattern of the referenced variables in a statement. More...
#include "clang/Analysis/CloneDetection.h"
Classes | |
struct | SuspiciousClonePair |
Describes two clones that reference their variables in a different pattern which could indicate a programming error. More... | |
Public Member Functions | |
VariablePattern (const StmtSequence &Sequence) | |
Creates an VariablePattern object with information about the given StmtSequence. | |
unsigned | countPatternDifferences (const VariablePattern &Other, VariablePattern::SuspiciousClonePair *FirstMismatch=nullptr) |
Counts the differences between this pattern and the given one. | |
Analyzes the pattern of the referenced variables in a statement.
Definition at line 343 of file CloneDetection.h.
|
inline |
Creates an VariablePattern object with information about the given StmtSequence.
Definition at line 373 of file CloneDetection.h.
unsigned VariablePattern::countPatternDifferences | ( | const VariablePattern & | Other, |
VariablePattern::SuspiciousClonePair * | FirstMismatch = nullptr |
||
) |
Counts the differences between this pattern and the given one.
Other | The given VariablePattern to compare with. |
FirstMismatch | Output parameter that will be filled with information about the first difference between the two patterns. This parameter can be a nullptr, in which case it will be ignored. |
For example, the following statements all have the same pattern and this function would return zero:
if (a < b) return a; return b; if (x < y) return x; return y; if (u2 < u1) return u2; return u1;
But the following statement has a different pattern (note the changed variables in the return statements) and would have two differences when compared with one of the statements above.
if (a < b) return b; return a;
This function should only be called if the related statements of the given pattern and the statements of this objects are clones of each other.
Definition at line 561 of file CloneDetection.cpp.
References clang::VariablePattern::SuspiciousClonePair::FirstCloneInfo, clang::Other, clang::VariablePattern::SuspiciousClonePair::SecondCloneInfo, and clang::VariablePattern::SuspiciousClonePair::SuspiciousCloneInfo::Suggestion.
Referenced by clang::MatchingVariablePatternConstraint::constrain().