Lines Matching +full:method +full:- +full:complexity
1 //===--- CloneDetection.cpp - Finds code clones in an AST -------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
28 assert(EndIndex <= Stmt->size() && "Given array too big for this Stmt"); in StmtSequence()
64 return CS->body_begin() + StartIndex; in begin()
72 return CS->body_begin() + EndIndex; in end()
77 return D->getASTContext(); in getASTContext()
81 return front()->getBeginLoc(); in getBeginLoc()
84 SourceLocation StmtSequence::getEndLoc() const { return back()->getEndLoc(); } in getEndLoc()
92 assert(D->hasBody()); in analyzeCodeBody()
94 Sequences.push_back(StmtSequence(D->getBody(), D)); in analyzeCodeBody()
158 !IgnoredFilesRegex->isValid()) in isAutoGenerated()
164 SM.getFilename(S.getContainingDecl()->getLocation())); in isAutoGenerated()
165 if (IgnoredFilesRegex->match(Filename)) in isAutoGenerated()
177 /// The data consumer class needs to provide a member method with the signature:
195 this->Visit(S); in CloneTypeIIStmtDataCollector()
198 // Define a visit method for each class to collect data and subsequently visit
247 /// If the given Stmt is a CompoundStmt, this method will also generate
253 ASTContext &Context = D->getASTContext(); in saveHash()
260 for (const Stmt *Child : S->children()) { in saveHash()
275 for (unsigned Pos = 0; Pos < CS->size(); ++Pos) { in saveHash()
280 for (unsigned Length = 1; Length <= CS->size() - Pos; ++Length) { in saveHash()
282 // -1 on the index because we start counting the length at 1. in saveHash()
283 size_t ChildHash = ChildHashes[Pos + Length - 1]; in saveHash()
324 for (const Stmt *Child : S->children()) { in CollectStmtSequenceData()
340 // prevents any false-positives due to hash code collisions. in areSequencesClones()
353 // FIXME: Maybe we can do this in-place and don't need this additional vector. in constrain()
357 // We assume in the following code that the Group is non-empty, so we in constrain()
374 // Note: The 'size - 1 ' in the condition is safe because we check for an in constrain()
376 for (unsigned i = 0; i < StmtsByHash.size() - 1; ++i) { in constrain()
394 --i; in constrain()
425 size_t Complexity = 1; in calculateStmtComplexity() local
436 // statement, we reduce the initial complexity of this statement to zero. in calculateStmtComplexity()
438 // macro expansion will only increase the total complexity by one. in calculateStmtComplexity()
439 // Note: This is not the final complexity of this statement as we still in calculateStmtComplexity()
440 // add the complexity of the child statements to the complexity value. in calculateStmtComplexity()
442 Complexity = 0; in calculateStmtComplexity()
445 // Iterate over the Stmts in the StmtSequence and add their complexity values in calculateStmtComplexity()
446 // to the current complexity value. in calculateStmtComplexity()
449 Complexity += calculateStmtComplexity( in calculateStmtComplexity()
451 if (Complexity >= Limit) in calculateStmtComplexity()
455 for (const Stmt *S : Seq.front()->children()) { in calculateStmtComplexity()
456 Complexity += calculateStmtComplexity( in calculateStmtComplexity()
458 if (Complexity >= Limit) in calculateStmtComplexity()
462 return Complexity; in calculateStmtComplexity()
552 if (auto VD = dyn_cast<VarDecl>(D->getDecl()->getCanonicalDecl())) in addVariables()
557 for (const Stmt *Child : S->children()) { in addVariables()
594 FirstMismatch->FirstCloneInfo = in countPatternDifferences()
607 FirstMismatch->SecondCloneInfo = in countPatternDifferences()
617 if (!FirstMismatch->FirstCloneInfo.Suggestion) in countPatternDifferences()
618 std::swap(FirstMismatch->FirstCloneInfo, FirstMismatch->SecondCloneInfo); in countPatternDifferences()
621 assert(FirstMismatch->FirstCloneInfo.Suggestion); in countPatternDifferences()