class VariablePattern
Declaration
class VariablePattern { /* full declaration omitted */ };
Description
Analyzes the pattern of the referenced variables in a statement.
Declared at: clang/include/clang/Analysis/CloneDetection.h:343
Member Variables
- private std::vector<VariableOccurence> Occurences
- All occurrences of referenced variables in the order of appearance.
- private std::vector<const VarDecl*> Variables
- List of referenced variables in the order of appearance. Every item in this list is unique.
Method Overview
- public VariablePattern(const clang::StmtSequence & Sequence)
- private void addVariableOccurence(const clang::VarDecl * VarDecl, const clang::Stmt * Mention)
- private void addVariables(const clang::Stmt * S)
- public unsigned int countPatternDifferences(const clang::VariablePattern & Other, VariablePattern::SuspiciousClonePair * FirstMismatch = nullptr)
Methods
¶VariablePattern(
const clang::StmtSequence& Sequence)
VariablePattern(
const clang::StmtSequence& Sequence)
Description
Creates an VariablePattern object with information about the given StmtSequence.
Declared at: clang/include/clang/Analysis/CloneDetection.h:373
Parameters
- const clang::StmtSequence& Sequence
¶void addVariableOccurence(
const clang::VarDecl* VarDecl,
const clang::Stmt* Mention)
void addVariableOccurence(
const clang::VarDecl* VarDecl,
const clang::Stmt* Mention)
Description
Adds a new variable referenced to this pattern.
Declared at: clang/include/clang/Analysis/CloneDetection.h:365
Parameters
- const clang::VarDecl* VarDecl
- The declaration of the variable that is referenced.
- const clang::Stmt* Mention
- The SourceRange where this variable is referenced.
¶void addVariables(const clang::Stmt* S)
void addVariables(const clang::Stmt* S)
Description
Adds each referenced variable from the given statement.
Declared at: clang/include/clang/Analysis/CloneDetection.h:368
Parameters
- const clang::Stmt* S
¶unsigned int countPatternDifferences(
const clang::VariablePattern& Other,
VariablePattern::SuspiciousClonePair*
FirstMismatch = nullptr)
unsigned int countPatternDifferences(
const clang::VariablePattern& Other,
VariablePattern::SuspiciousClonePair*
FirstMismatch = nullptr)
Description
Counts the differences between this pattern and the given one. 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.
Declared at: clang/include/clang/Analysis/CloneDetection.h:426
Parameters
- const clang::VariablePattern& Other
- The given VariablePattern to compare with.
- VariablePattern::SuspiciousClonePair* FirstMismatch = nullptr
- 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.
Returns
Returns the number of differences between the pattern this object is following and the given VariablePattern.