clang 19.0.0git
Macros | Functions
CloneDetection.cpp File Reference
#include "clang/Analysis/CloneDetection.h"
#include "clang/AST/Attr.h"
#include "clang/AST/DataCollection.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/Path.h"
#include "clang/AST/StmtDataCollectors.inc"

Go to the source code of this file.

Macros

#define DEF_ADD_DATA(CLASS, CODE)
 
#define SKIP(CLASS)
 

Functions

static bool containsAnyInGroup (StmtSequence &Seq, CloneDetector::CloneGroup &Group)
 Returns true if and only if Stmt contains at least one other sequence in the Group.
 
static bool containsGroup (CloneDetector::CloneGroup &Group, CloneDetector::CloneGroup &OtherGroup)
 Returns true if and only if all sequences in OtherGroup are contained by a sequence in Group.
 
static size_t createHash (llvm::MD5 &Hash)
 
static size_t saveHash (const Stmt *S, const Decl *D, std::vector< std::pair< size_t, StmtSequence > > &StmtsByHash)
 Generates and saves a hash code for the given Stmt.
 
static void CollectStmtSequenceData (const StmtSequence &Sequence, FoldingSetNodeIDWrapper &OutputData)
 Writes the relevant data from all statements and child statements in the given StmtSequence into the given FoldingSetNodeID.
 
static bool areSequencesClones (const StmtSequence &LHS, const StmtSequence &RHS)
 Returns true if both sequences are clones of each other.
 

Macro Definition Documentation

◆ DEF_ADD_DATA

#define DEF_ADD_DATA (   CLASS,
  CODE 
)
Value:
template <class = void> void Visit##CLASS(const CLASS *S) { \
CODE; \
}
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Definition: StmtVisitor.h:195

Definition at line 200 of file CloneDetection.cpp.

◆ SKIP

#define SKIP (   CLASS)
Value:
void Visit##CLASS(const CLASS *S) { \
}

Definition at line 209 of file CloneDetection.cpp.

Function Documentation

◆ areSequencesClones()

static bool areSequencesClones ( const StmtSequence LHS,
const StmtSequence RHS 
)
static

Returns true if both sequences are clones of each other.

Definition at line 334 of file CloneDetection.cpp.

References CollectStmtSequenceData().

Referenced by clang::RecursiveCloneTypeIIVerifyConstraint::constrain().

◆ CollectStmtSequenceData()

static void CollectStmtSequenceData ( const StmtSequence Sequence,
FoldingSetNodeIDWrapper &  OutputData 
)
static

Writes the relevant data from all statements and child statements in the given StmtSequence into the given FoldingSetNodeID.

Definition at line 317 of file CloneDetection.cpp.

References CollectStmtSequenceData(), clang::StmtSequence::getASTContext(), and clang::StmtSequence::getContainingDecl().

Referenced by areSequencesClones(), and CollectStmtSequenceData().

◆ containsAnyInGroup()

static bool containsAnyInGroup ( StmtSequence Seq,
CloneDetector::CloneGroup Group 
)
static

Returns true if and only if Stmt contains at least one other sequence in the Group.

Definition at line 99 of file CloneDetection.cpp.

References clang::Seq.

Referenced by containsGroup().

◆ containsGroup()

static bool containsGroup ( CloneDetector::CloneGroup Group,
CloneDetector::CloneGroup OtherGroup 
)
static

Returns true if and only if all sequences in OtherGroup are contained by a sequence in Group.

Definition at line 110 of file CloneDetection.cpp.

References containsAnyInGroup().

Referenced by clang::OnlyLargestCloneConstraint::constrain().

◆ createHash()

static size_t createHash ( llvm::MD5 &  Hash)
static

Definition at line 224 of file CloneDetection.cpp.

Referenced by saveHash().

◆ saveHash()

static size_t saveHash ( const Stmt S,
const Decl D,
std::vector< std::pair< size_t, StmtSequence > > &  StmtsByHash 
)
static

Generates and saves a hash code for the given Stmt.

Parameters
SThe given Stmt.
DThe Decl containing S.
StmtsByHashOutput parameter that will contain the hash codes for each StmtSequence in the given Stmt.
Returns
The hash code of the given Stmt.

If the given Stmt is a CompoundStmt, this method will also generate hashes for all possible StmtSequences in the children of this Stmt.

Definition at line 249 of file CloneDetection.cpp.

References createHash(), clang::Decl::getASTContext(), and saveHash().

Referenced by clang::RecursiveCloneTypeIIHashConstraint::constrain(), and saveHash().