clang  6.0.0svn
Macros | Functions
CloneDetection.cpp File Reference
#include "clang/Analysis/CloneDetection.h"
#include "clang/AST/DataCollection.h"
#include "clang/AST/DeclTemplate.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/Path.h"
#include "clang/AST/StmtDataCollectors.inc"
Include dependency graph for CloneDetection.cpp:

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. More...
 
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. More...
 
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. More...
 
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. More...
 
static bool areSequencesClones (const StmtSequence &LHS, const StmtSequence &RHS)
 Returns true if both sequences are clones of each other. More...
 

Macro Definition Documentation

◆ DEF_ADD_DATA

#define DEF_ADD_DATA (   CLASS,
  CODE 
)
Value:
template <class = void> void Visit##CLASS(const CLASS *S) { \
CODE; \
ConstStmtVisitor<CloneTypeIIStmtDataCollector<T>>::Visit##CLASS(S); \
}

Definition at line 202 of file CloneDetection.cpp.

◆ SKIP

#define SKIP (   CLASS)
Value:
void Visit##CLASS(const CLASS *S) { \
ConstStmtVisitor<CloneTypeIIStmtDataCollector<T>>::Visit##CLASS(S); \
}

Definition at line 211 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 336 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 319 of file CloneDetection.cpp.

References clang::Sema::getASTContext(), and clang::StmtSequence::StmtSequence().

Referenced by areSequencesClones().

◆ 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::StmtSequence::contains().

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 226 of file CloneDetection.cpp.

References min().

◆ 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 251 of file CloneDetection.cpp.

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