summaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/BugReporter.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-06-03 23:00:09 +0000
committerJordan Rose <jordan_rose@apple.com>2013-06-03 23:00:09 +0000
commite624524705ab660eb8d1feb9870ef2989fb2bdf4 (patch)
tree7d2298f12a0e61dfc8ca82240934144d9ed92d48 /lib/StaticAnalyzer/Core/BugReporter.cpp
parent22b0ad2d2a9c723bcdc94525a091fdbfbaa480fa (diff)
downloadclang-e624524705ab660eb8d1feb9870ef2989fb2bdf4.tar.gz
clang-e624524705ab660eb8d1feb9870ef2989fb2bdf4.tar.bz2
clang-e624524705ab660eb8d1feb9870ef2989fb2bdf4.tar.xz
[analyzer; new edges] Omit subexpression back-edges that span multiple lines.
A.1 -> A -> B becomes A.1 -> B This only applies if there's an edge from a subexpression to its parent expression, and that is immediately followed by another edge from the parent expression to a subsequent expression. Normally this is useful for bringing the edges back to the left side of the code, but when the subexpression is on a different line the backedge ends up looking strange, and may even obscure code. In these cases, it's better to just continue to the next top-level statement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183164 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/BugReporter.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index c19e12ca82..305450aaea 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2092,7 +2092,7 @@ static void simplifySimpleBranches(PathPieces &pieces) {
}
}
-/// Returns the number of bytes in the given SourceRange.
+/// Returns the number of bytes in the given (character-based) SourceRange.
///
/// If the locations in the range are not on the same line, returns None.
///
@@ -2413,6 +2413,21 @@ static bool optimizeEdges(PathPieces &path, SourceManager &SM,
!lexicalContains(PM, s1End, s1Start)) {
removeEdge = true;
}
+ // Trim edges from a subexpression back to the top level if the
+ // subexpression is on a different line.
+ //
+ // A.1 -> A -> B
+ // becomes
+ // A.1 -> B
+ //
+ // These edges just look ugly and don't usually add anything.
+ else if (s1Start && s2End &&
+ lexicalContains(PM, s1Start, s1End)) {
+ SourceRange EdgeRange(PieceI->getEndLocation().asLocation(),
+ PieceI->getStartLocation().asLocation());
+ if (!getLengthOnSingleLine(SM, EdgeRange).hasValue())
+ removeEdge = true;
+ }
}
if (removeEdge) {