diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-26 20:33:12 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-26 20:33:12 +0000 |
commit | ef915aab0ac566c55bfb0d7a9f6635bb5d94d4af (patch) | |
tree | ac935cfa19985d33098fc13e288b5ac830672dba /lib/Analysis/CloneDetection.cpp | |
parent | 325377b57338e700317f5e423e5b0f1c08d99a39 (diff) | |
download | src-ef915aab0ac566c55bfb0d7a9f6635bb5d94d4af.tar.gz src-ef915aab0ac566c55bfb0d7a9f6635bb5d94d4af.zip |
Vendor import of clang trunk r306325:vendor/clang/clang-trunk-r306325
Notes
Notes:
svn path=/vendor/clang/dist/; revision=320376
svn path=/vendor/clang/clang-trunk-r306325/; revision=320377; tag=vendor/clang/clang-trunk-r306325
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 5bbcbe4e5722..ee848ac711d6 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)) |