aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2010-01-21 23:49:01 +0000
committerMike Stump <mrs@apple.com>2010-01-21 23:49:01 +0000
commit4a415670481424a210df419a9f96e29db9939106 (patch)
treeb9caf9aa724b38b8c01722c25339f7ffd06051b6 /lib
parenta59e390ed6d722f0eaaa9f7eb106eaaf470df3f1 (diff)
Wire up the new range reporting for unreachable code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94118 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Sema/SemaChecking.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 608f4345b1..6ff8b1d753 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -2198,6 +2198,16 @@ static int LineCmp(const void *p1, const void *p2) {
return !(*Line1 < *Line2);
}
+namespace {
+ struct ErrLoc {
+ SourceLocation Loc;
+ SourceRange R1;
+ SourceRange R2;
+ ErrLoc(SourceLocation l, SourceRange r1, SourceRange r2)
+ : Loc(l), R1(r1), R2(r2) { }
+ };
+}
+
/// CheckUnreachable - Check for unreachable code.
void Sema::CheckUnreachable(AnalysisContext &AC) {
unsigned count;
@@ -2222,7 +2232,7 @@ void Sema::CheckUnreachable(AnalysisContext &AC) {
SourceRange R1, R2;
- llvm::SmallVector<SourceLocation, 24> lines;
+ llvm::SmallVector<ErrLoc, 24> lines;
bool AddEHEdges = AC.getAddEHEdges();
// First, give warnings for blocks with no predecessors, as they
// can't be part of a loop.
@@ -2245,7 +2255,7 @@ void Sema::CheckUnreachable(AnalysisContext &AC) {
++count;
continue;
}
- lines.push_back(c);
+ lines.push_back(ErrLoc(c, R1, R2));
// Avoid excessive errors by marking everything reachable from here
count += MarkLive(&b, live);
}
@@ -2258,17 +2268,17 @@ void Sema::CheckUnreachable(AnalysisContext &AC) {
CFGBlock &b = **I;
if (!live[b.getBlockID()])
// Avoid excessive errors by marking everything reachable from here
- lines.push_back(MarkLiveTop(&b, live, Context.getSourceManager()));
+ lines.push_back(ErrLoc(MarkLiveTop(&b, live, Context.getSourceManager()), SourceRange(), SourceRange()));
}
}
llvm::array_pod_sort(lines.begin(), lines.end(), LineCmp);
- for (llvm::SmallVector<SourceLocation, 24>::iterator I = lines.begin(),
+ for (llvm::SmallVector<ErrLoc, 24>::iterator I = lines.begin(),
E = lines.end();
I != E;
++I)
- if (I->isValid())
- Diag(*I, diag::warn_unreachable);
+ if (I->Loc.isValid())
+ Diag(I->Loc, diag::warn_unreachable) << I->R1 << I->R2;
}
/// CheckFallThrough - Check that we don't fall off the end of a