[cfe-commits] r94118 - /cfe/trunk/lib/Sema/SemaChecking.cpp
Mike Stump
mrs at apple.com
Thu Jan 21 15:49:01 PST 2010
Author: mrs
Date: Thu Jan 21 17:49:01 2010
New Revision: 94118
URL: http://llvm.org/viewvc/llvm-project?rev=94118&view=rev
Log:
Wire up the new range reporting for unreachable code.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=94118&r1=94117&r2=94118&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jan 21 17:49:01 2010
@@ -2198,6 +2198,16 @@
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 @@
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 @@
++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 @@
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
More information about the cfe-commits
mailing list