summaryrefslogtreecommitdiffstats
path: root/lib/Sema/AnalysisBasedWarnings.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2014-02-18 22:12:10 +0000
committerTed Kremenek <kremenek@apple.com>2014-02-18 22:12:10 +0000
commita0b067779b6be8c15709555fc17847ba294253c6 (patch)
treedfcdb52bea151c88e88c370ae469e3b54d1b8ff1 /lib/Sema/AnalysisBasedWarnings.cpp
parent06bf1dda55b5db4ab6f583be1c2adf8af00109e3 (diff)
Experiment with making -Wunreachable-code more immediately useful by restricting warnings to those issued in the main file.
This warning has a whole bunch of known false positives, much of them due to code that is "sometimes unreachable". This can caused by code that is conditionally generated by the preprocessor, branches that are defined in terms of architecture-specific details (e.g., the size of a type), and so on. While these are all good things to address one by one, the reality is that this warning has received little love lately. By restricting its purvue, we can focus on the top issues effecting main files, which should be smaller, and then gradually widen the scope. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201607 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r--lib/Sema/AnalysisBasedWarnings.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index b13831908b..f1b25753ab 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -66,6 +66,12 @@ namespace {
UnreachableCodeHandler(Sema &s) : S(s) {}
void HandleUnreachable(SourceLocation L, SourceRange R1, SourceRange R2) {
+ // As a heuristic prune all diagnostics not in the main file. Currently
+ // the majority of warnings in headers are false positives. These
+ // are largely caused by configuration state, e.g. preprocessor
+ // defined code, etc.
+ if (!S.getSourceManager().isInMainFile(L))
+ return;
S.Diag(L, diag::warn_unreachable) << R1 << R2;
}
};