summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/CloneDetection.cpp
diff options
context:
space:
mode:
authorVitaly Buka <vitalybuka@google.com>2016-10-04 02:40:35 +0000
committerVitaly Buka <vitalybuka@google.com>2016-10-04 02:40:35 +0000
commit1a8d52d1aef01644b5597d410a3e450e293c12b3 (patch)
tree55337e2b28c890eecdcdb913343759862ed69935 /clang/lib/Analysis/CloneDetection.cpp
parentb3814f6f38cc0b3d0d9662c01b8a6d49a6543219 (diff)
downloadbcm5719-llvm-1a8d52d1aef01644b5597d410a3e450e293c12b3.tar.gz
bcm5719-llvm-1a8d52d1aef01644b5597d410a3e450e293c12b3.zip
Revert "[analyzer] Improve CloneChecker diagnostics" as its depends on reverted r283092
This reverts commit r283094. llvm-svn: 283182
Diffstat (limited to 'clang/lib/Analysis/CloneDetection.cpp')
-rw-r--r--clang/lib/Analysis/CloneDetection.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/clang/lib/Analysis/CloneDetection.cpp b/clang/lib/Analysis/CloneDetection.cpp
index 4fdac5abbd4..1b43cfb2741 100644
--- a/clang/lib/Analysis/CloneDetection.cpp
+++ b/clang/lib/Analysis/CloneDetection.cpp
@@ -82,10 +82,6 @@ SourceLocation StmtSequence::getStartLoc() const {
SourceLocation StmtSequence::getEndLoc() const { return back()->getLocEnd(); }
-SourceRange StmtSequence::getSourceRange() const {
- return SourceRange(getStartLoc(), getEndLoc());
-}
-
namespace {
/// \brief Analyzes the pattern of the referenced variables in a statement.
@@ -95,11 +91,11 @@ class VariablePattern {
struct VariableOccurence {
/// The index of the associated VarDecl in the Variables vector.
size_t KindID;
- /// The statement in the code where the variable was referenced.
- const Stmt *Mention;
+ /// The source range in the code where the variable was referenced.
+ SourceRange Range;
- VariableOccurence(size_t KindID, const Stmt *Mention)
- : KindID(KindID), Mention(Mention) {}
+ VariableOccurence(size_t KindID, SourceRange Range)
+ : KindID(KindID), Range(Range) {}
};
/// All occurences of referenced variables in the order of appearance.
@@ -111,19 +107,19 @@ class VariablePattern {
/// \brief Adds a new variable referenced to this pattern.
/// \param VarDecl The declaration of the variable that is referenced.
/// \param Mention The statement in the code where the variable was referenced.
- void addVariableOccurence(const VarDecl *VarDecl, const Stmt *Mention) {
+ void addVariableOccurence(const VarDecl *VarDecl, SourceRange Range) {
// First check if we already reference this variable
for (size_t KindIndex = 0; KindIndex < Variables.size(); ++KindIndex) {
if (Variables[KindIndex] == VarDecl) {
// If yes, add a new occurence that points to the existing entry in
// the Variables vector.
- Occurences.emplace_back(KindIndex, Mention);
+ Occurences.emplace_back(KindIndex, Range);
return;
}
}
// If this variable wasn't already referenced, add it to the list of
// referenced variables and add a occurence that points to this new entry.
- Occurences.emplace_back(Variables.size(), Mention);
+ Occurences.emplace_back(Variables.size(), Range);
Variables.push_back(VarDecl);
}
@@ -138,7 +134,7 @@ class VariablePattern {
// Check if S is a reference to a variable. If yes, add it to the pattern.
if (auto D = dyn_cast<DeclRefExpr>(S)) {
if (auto VD = dyn_cast<VarDecl>(D->getDecl()->getCanonicalDecl()))
- addVariableOccurence(VD, D);
+ addVariableOccurence(VD, D->getSourceRange());
}
// Recursively check all children of the given statement.
@@ -212,7 +208,7 @@ public:
// Store information about the first clone.
FirstMismatch->FirstCloneInfo =
CloneDetector::SuspiciousClonePair::SuspiciousCloneInfo(
- Variables[ThisOccurence.KindID], ThisOccurence.Mention,
+ Variables[ThisOccurence.KindID], ThisOccurence.Range,
FirstSuggestion);
// Same as above but with the other clone. We do this for both clones as
@@ -225,7 +221,7 @@ public:
// Store information about the second clone.
FirstMismatch->SecondCloneInfo =
CloneDetector::SuspiciousClonePair::SuspiciousCloneInfo(
- Other.Variables[OtherOccurence.KindID], OtherOccurence.Mention,
+ Variables[ThisOccurence.KindID], OtherOccurence.Range,
SecondSuggestion);
// SuspiciousClonePair guarantees that the first clone always has a
OpenPOWER on IntegriCloud