diff options
Diffstat (limited to 'lib/Analysis/CloneDetection.cpp')
-rw-r--r-- | lib/Analysis/CloneDetection.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Analysis/CloneDetection.cpp b/lib/Analysis/CloneDetection.cpp index 5bbcbe4e5722b..ee848ac711d6a 100644 --- a/lib/Analysis/CloneDetection.cpp +++ b/lib/Analysis/CloneDetection.cpp @@ -18,9 +18,9 @@ #include "clang/AST/Stmt.h" #include "clang/AST/StmtVisitor.h" #include "clang/Lex/Lexer.h" -#include "llvm/ADT/StringRef.h" #include "llvm/Support/MD5.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Path.h" using namespace clang; @@ -366,6 +366,23 @@ void OnlyLargestCloneConstraint::constrain( } } +bool FilenamePatternConstraint::isAutoGenerated(const CloneDetector::CloneGroup &Group) { + std::string Error; + if (IgnoredFilesPattern.empty() || Group.empty() || + !IgnoredFilesRegex->isValid(Error)) + return false; + + for (const StmtSequence &S : Group) { + const SourceManager &SM = S.getASTContext().getSourceManager(); + StringRef Filename = llvm::sys::path::filename(SM.getFilename( + S.getContainingDecl()->getLocation())); + if (IgnoredFilesRegex->match(Filename)) + return true; + } + + return false; +} + static size_t createHash(llvm::MD5 &Hash) { size_t HashCode; @@ -618,8 +635,7 @@ void CloneConstraint::splitCloneGroups( if (Indexes[j]) continue; - // If a following StmtSequence belongs to our CloneGroup, we add it to - // it. + // If a following StmtSequence belongs to our CloneGroup, we add it. const StmtSequence &Candidate = HashGroup[j]; if (!Compare(Prototype, Candidate)) |