Flip the default for showing include stacks on notes to false. This
required modifying a few tests that specifically use note include stacks
to check the source manager's view of include stacks. I've simply added
the flag to these tests for now, they may have to be more substantially
changed if we decide to remove support for note include stacks
altogether.
Also, add a test for include stacks on notes that was supposed to go in
with the previous commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128390 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index 431f5f4..4c7657e 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -989,12 +989,12 @@
Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
Opts.ShowOptionNames = Args.hasArg(OPT_fdiagnostics_show_option);
- // Default behavior is to show note include stacks.
- Opts.ShowNoteIncludeStack = true;
+ // Default behavior is to not to show note include stacks.
+ Opts.ShowNoteIncludeStack = false;
if (Arg *A = Args.getLastArg(OPT_fdiagnostics_show_note_include_stack,
OPT_fno_diagnostics_show_note_include_stack))
- if (A->getOption().matches(OPT_fno_diagnostics_show_note_include_stack))
- Opts.ShowNoteIncludeStack = false;
+ if (A->getOption().matches(OPT_fdiagnostics_show_note_include_stack))
+ Opts.ShowNoteIncludeStack = true;
llvm::StringRef ShowOverloads =
Args.getLastArgValue(OPT_fshow_overloads_EQ, "all");
diff --git a/test/ASTMerge/var.c b/test/ASTMerge/var.c
index 7f23b9f..e1dde6a 100644
--- a/test/ASTMerge/var.c
+++ b/test/ASTMerge/var.c
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/var1.c
// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/var2.c
-// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -fdiagnostics-show-note-include-stack %s 2>&1 | FileCheck %s
// CHECK: var2.c:2:9: error: external variable 'x1' declared with incompatible types in different translation units ('double *' vs. 'float **')
// CHECK: var1.c:2:9: note: declared here with type 'float **'
diff --git a/test/Misc/Inputs/include.h b/test/Misc/Inputs/include.h
new file mode 100644
index 0000000..d325775
--- /dev/null
+++ b/test/Misc/Inputs/include.h
@@ -0,0 +1 @@
+int foo(int x) { return x; }
diff --git a/test/Misc/include-stack-for-note-flag.cpp b/test/Misc/include-stack-for-note-flag.cpp
new file mode 100644
index 0000000..f8d0080
--- /dev/null
+++ b/test/Misc/include-stack-for-note-flag.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack %s 2>&1 | FileCheck %s -check-prefix=STACK
+// RUN: %clang_cc1 -fsyntax-only -fno-diagnostics-show-note-include-stack %s 2>&1 | FileCheck %s -check-prefix=STACKLESS
+// RUN: %clang_cc1 -fsyntax-only -fno-diagnostics-show-note-include-stack -fdiagnostics-show-note-include-stack %s 2>&1 | FileCheck %s -check-prefix=STACK
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -fno-diagnostics-show-note-include-stack %s 2>&1 | FileCheck %s -check-prefix=STACKLESS
+// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck %s -check-prefix=STACKLESS
+
+#include "Inputs/include.h"
+int test() {
+ return foo(1, 1);
+}
+
+// STACK: error: no matching function for call to 'foo'
+// STACK: In file included from
+// STACK: note: candidate function not viable
+
+// STACKLESS: error: no matching function for call to 'foo'
+// STACKLESS-NOT: In file included from
+// STACKLESS: note: candidate function not viable
diff --git a/test/PCH/source-manager-stack.c b/test/PCH/source-manager-stack.c
index cc85556..8f5da2f 100644
--- a/test/PCH/source-manager-stack.c
+++ b/test/PCH/source-manager-stack.c
@@ -2,9 +2,9 @@
// when using PCH.
// RUN: echo 'int x;' > %t.prefix.h
-// RUN: not %clang_cc1 -fsyntax-only -include %t.prefix.h %s 2> %t.diags.no_pch.txt
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -include %t.prefix.h %s 2> %t.diags.no_pch.txt
// RUN: %clang_cc1 -emit-pch -o %t.prefix.pch %t.prefix.h
-// RUN: not %clang_cc1 -fsyntax-only -include-pch %t.prefix.pch %s 2> %t.diags.pch.txt
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-show-note-include-stack -include-pch %t.prefix.pch %s 2> %t.diags.pch.txt
// RUN: diff %t.diags.no_pch.txt %t.diags.pch.txt
// XFAIL: *
// PR5662