summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CloneDetection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Analysis/CloneDetection.cpp')
-rw-r--r--clang/lib/Analysis/CloneDetection.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CloneDetection.cpp b/clang/lib/Analysis/CloneDetection.cpp
index 5bbcbe4e572..3b44fab9d74 100644
--- a/clang/lib/Analysis/CloneDetection.cpp
+++ b/clang/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 AutoGeneratedCloneConstraint::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;
OpenPOWER on IntegriCloud