File tree 4 files changed +16
-6
lines changed 4 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -589,11 +589,10 @@ void RewriteConsumer::emitRootCauseDiagnostics(ASTContext &Context) {
589
589
if (!File.getError ()) {
590
590
SourceLocation SL =
591
591
SM.translateFileLineCol (*File, PSL.getLineNo (), PSL.getColSNo ());
592
- // Limit emitted root causes to those that effect more than one pointer
593
- // or are in the main file of the TU. Alternatively, don't filter causes
594
- // if -warn-all-root-cause is passed.
592
+ // Limit emitted root causes to those that effect at least one pointer.
593
+ // Alternatively, don't filter causes if -warn-all-root-cause is passed.
595
594
int PtrCount = I.getNumPtrsAffected (WReason.first );
596
- if (_3COpts.WarnAllRootCause || SM. isInMainFile (SL) || PtrCount > 1 ) {
595
+ if (_3COpts.WarnAllRootCause || PtrCount > 0 ) {
597
596
// SL is invalid when the File is not in the current translation unit.
598
597
if (SL.isValid ()) {
599
598
EmittedDiagnostics.insert (PSL);
Original file line number Diff line number Diff line change 1
1
// RUN: cd %S
2
2
// RUN: 3c -use-malloc=my_malloc -alltypes -addcr -output-dir=%t.checked/base_subdir -warn-all-root-cause %s -- -Xclang -verify=unwritable-expected -Wno-everything
3
+ // RUN: 3c -use-malloc=my_malloc -alltypes -addcr -output-dir=%t.checked/base_subdir -warn-root-cause %s -- -Xclang -verify=not-all-unwritable-expected -Wno-everything
4
+ // not-all-unwritable-expected-no-diagnostics
3
5
4
6
#include "../root_cause.c"
Original file line number Diff line number Diff line change 1
1
// RUN: 3c -use-malloc=my_malloc -base-dir=%S -alltypes -warn-all-root-cause %s -- -Xclang -verify -Wno-everything
2
+ // RUN: 3c -use-malloc=my_malloc -base-dir=%S -alltypes -warn-root-cause %s -- -Xclang -verify -Wno-everything
2
3
3
4
// This test is unusual in that it checks for the errors in the code
4
5
@@ -106,5 +107,4 @@ void test_conflict() {
106
107
// expected-note@#as_ptr {{Operand of address-of has PTR lower bound}}
107
108
// expected-note@#as_nt {{Assigning from c to s}}
108
109
109
-
110
-
110
+ #include "root_cause.h"
Original file line number Diff line number Diff line change
1
+ // Test that root cause errors are reported correctly in include header files.
2
+ // Included by root_cause.c
3
+
4
+ void outside_of_main () {
5
+ // expected-warning@+3 {{1 unchecked pointer: Cast from int to int *}}
6
+ // unwritable-expected-warning@+2 {{0 unchecked pointers: Source code in non-writable file}}
7
+ // unwritable-expected-warning@+1 {{0 unchecked pointers: Source code in non-writable file}}
8
+ int * c = 1 ;
9
+ }
You can’t perform that action at this time.
0 commit comments