Simple hack to do unreachable code analysis on template patterns.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148774 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index e2d1e8c..5f1d8cc 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -782,8 +782,7 @@
     return;
 
   // For code in dependent contexts, we'll do this at instantiation time.
-  if (cast<DeclContext>(D)->isDependentContext())
-    return;
+  bool Dependent = cast<DeclContext>(D)->isDependentContext();
 
   if (Diags.hasErrorOccurred() || Diags.hasFatalErrorOccurred()) {
     // Flush out any possibly unreachable diagnostics.
@@ -826,7 +825,7 @@
   // Construct the analysis context with the specified CFG build options.
   
   // Emit delayed diagnostics.
-  if (!fscope->PossiblyUnreachableDiags.empty()) {
+  if (!fscope->PossiblyUnreachableDiags.empty() && !Dependent) {
     bool analyzed = false;
 
     // Register the expressions with the CFGBuilder.
@@ -874,7 +873,7 @@
   
   
   // Warning: check missing 'return'
-  if (P.enableCheckFallThrough) {
+  if (P.enableCheckFallThrough && !Dependent) {
     const CheckFallThroughDiagnostics &CD =
       (isa<BlockDecl>(D) ? CheckFallThroughDiagnostics::MakeForBlock()
                          : CheckFallThroughDiagnostics::MakeForFunction(D));
@@ -895,7 +894,7 @@
   }
 
   // Check for thread safety violations
-  if (P.enableThreadSafetyAnalysis) {
+  if (P.enableThreadSafetyAnalysis && !Dependent) {
     SourceLocation FL = AC.getDecl()->getLocation();
     thread_safety::ThreadSafetyReporter Reporter(S, FL);
     thread_safety::runThreadSafetyAnalysis(AC, Reporter);