diff options
author | Leslie Zhai <lesliezhai@llvm.org.cn> | 2017-06-19 01:55:50 +0000 |
---|---|---|
committer | Leslie Zhai <lesliezhai@llvm.org.cn> | 2017-06-19 01:55:50 +0000 |
commit | d91d19e6dc5fa442c39e4f2b517067c67df74f03 (patch) | |
tree | 4f3afe2e83d9162f9fcd6e5e7e82493d9f0d7547 /clang/lib/Analysis/CloneDetection.cpp | |
parent | 043d3f868291d158f7e24a8a2d9f3ed629aa737b (diff) | |
download | bcm5719-llvm-d91d19e6dc5fa442c39e4f2b517067c67df74f03.tar.gz bcm5719-llvm-d91d19e6dc5fa442c39e4f2b517067c67df74f03.zip |
[analyzer] Teach CloneDetection about Qt Meta-Object Compiler
Reviewers: v.g.vassilev, zaks.anna, NoQ, teemperor
Reviewed By: v.g.vassilev, zaks.anna, NoQ, teemperor
Differential Revision: https://reviews.llvm.org/D31320
llvm-svn: 305659
Diffstat (limited to 'clang/lib/Analysis/CloneDetection.cpp')
-rw-r--r-- | clang/lib/Analysis/CloneDetection.cpp | 19 |
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; |