From: Leslie Zhai Date: Tue, 20 Jun 2017 06:44:46 +0000 (+0000) Subject: [analyzer] Teach CloneDetection about Qt Meta-Object Compiler to filter auto generate... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1efca534de495c59164aed80313323d56a0e773;p=clang [analyzer] Teach CloneDetection about Qt Meta-Object Compiler to filter auto generated files Reviewers: v.g.vassilev, teemperor Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D34353 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305774 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/CloneDetection.h b/include/clang/Analysis/CloneDetection.h index 3398a1f40a..1ca3514e69 100644 --- a/include/clang/Analysis/CloneDetection.h +++ b/include/clang/Analysis/CloneDetection.h @@ -321,11 +321,11 @@ struct OnlyLargestCloneConstraint { void constrain(std::vector &Result); }; -struct AutoGeneratedCloneConstraint { +struct FilenamePatternConstraint { StringRef IgnoredFilesPattern; std::shared_ptr IgnoredFilesRegex; - AutoGeneratedCloneConstraint(StringRef IgnoredFilesPattern) + FilenamePatternConstraint(StringRef IgnoredFilesPattern) : IgnoredFilesPattern(IgnoredFilesPattern) { IgnoredFilesRegex = std::make_shared("^(" + IgnoredFilesPattern.str() + "$)"); diff --git a/lib/Analysis/CloneDetection.cpp b/lib/Analysis/CloneDetection.cpp index 3b44fab9d7..e86293a1dd 100644 --- a/lib/Analysis/CloneDetection.cpp +++ b/lib/Analysis/CloneDetection.cpp @@ -366,7 +366,7 @@ void OnlyLargestCloneConstraint::constrain( } } -bool AutoGeneratedCloneConstraint::isAutoGenerated(const CloneDetector::CloneGroup &Group) { +bool FilenamePatternConstraint::isAutoGenerated(const CloneDetector::CloneGroup &Group) { std::string Error; if (IgnoredFilesPattern.empty() || Group.empty() || !IgnoredFilesRegex->isValid(Error)) diff --git a/lib/StaticAnalyzer/Checkers/CloneChecker.cpp b/lib/StaticAnalyzer/Checkers/CloneChecker.cpp index d0898adf49..83955c586b 100644 --- a/lib/StaticAnalyzer/Checkers/CloneChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CloneChecker.cpp @@ -82,7 +82,7 @@ void CloneChecker::checkEndOfTranslationUnit(const TranslationUnitDecl *TU, std::vector AllCloneGroups; Detector.findClones(AllCloneGroups, - AutoGeneratedCloneConstraint(IgnoredFilesPattern), + FilenamePatternConstraint(IgnoredFilesPattern), RecursiveCloneTypeIIConstraint(), MinComplexityConstraint(MinComplexity), MinGroupSizeConstraint(2), OnlyLargestCloneConstraint());