https://github.com/Sh0g0-1758 updated https://github.com/llvm/llvm-project/pull/78338
>From b98f02d4c155b5be9bd4f5b2e4bf73720a81f39a Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Wed, 17 Jan 2024 01:24:17 +0530 Subject: [PATCH 01/22] Fix : more detailed no expected directive message --- clang-tools-extra/clangd/test/indexer.test | 2 +- clang/include/clang/Basic/Diagnostic.h | 4 +++- clang/include/clang/Basic/DiagnosticFrontendKinds.td | 2 +- clang/lib/AST/ASTContext.cpp | 2 +- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 4 +++- clang/test/ARCMT/verify.m | 2 +- clang/test/Frontend/verify.c | 2 +- clang/test/Frontend/verify2.c | 2 +- clang/test/Frontend/verify3.c | 4 ++-- 9 files changed, 14 insertions(+), 10 deletions(-) diff --git a/clang-tools-extra/clangd/test/indexer.test b/clang-tools-extra/clangd/test/indexer.test index 2f01f6c557a7de..213d33f8e2d6a5 100644 --- a/clang-tools-extra/clangd/test/indexer.test +++ b/clang-tools-extra/clangd/test/indexer.test @@ -5,5 +5,5 @@ # `.ii` file and `-verify` triggers extra diagnostics generation. Clangd should # strip those. # RUN: clangd-indexer %t.cpp -- -Xclang -verify --save-temps -- 2>&1 | FileCheck %s -# CHECK-NOT: error: no expected directives found: consider use of 'expected-no-diagnostics' +# CHECK-NOT: error: no expected directives found: consider use of {{.*}}-no-diagnostics # RUN: not ls %t.ii diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index 0c7836c2ea569c..a185c75e418b58 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -9,7 +9,9 @@ /// \file /// Defines the Diagnostic-related interfaces. // -//===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===//] + +// look into this file as well #ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H #define LLVM_CLANG_BASIC_DIAGNOSTIC_H diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index 568000106a84dc..42d2767af6b708 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -179,7 +179,7 @@ def err_verify_invalid_no_diags : Error< "%select{expected|'expected-no-diagnostics'}0 directive cannot follow " "%select{'expected-no-diagnostics' directive|other expected directives}0">; def err_verify_no_directives : Error< - "no expected directives found: consider use of 'expected-no-diagnostics'">; + "no expected directives found: consider use of '%0'-no-diagnostics">; def err_verify_nonconst_addrspace : Error< "qualifier 'const' is needed for variables in address space '%0'">; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index b60dcfaabfd1a4..0997ac9fa7df04 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1404,7 +1404,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target, getTranslationUnitDecl()->addDecl(MSGuidTagDecl); } } - +// maybe change here also. DiagnosticsEngine &ASTContext::getDiagnostics() const { return SourceMgr.getDiagnostics(); } diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 8a3d2286cd168c..9a26905a76d46b 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1098,7 +1098,9 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Produce an error if no expected-* directives could be found in the // source file(s) processed. if (Status == HasNoDirectives) { - Diags.Report(diag::err_verify_no_directives).setForceEmit(); + // change here + std::string directives = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); + Diags.Report(diag::err_verify_no_directives).setForceEmit() << directives; ++NumErrors; Status = HasNoDirectivesReported; } diff --git a/clang/test/ARCMT/verify.m b/clang/test/ARCMT/verify.m index 7d245fe80575e5..13fd599f530fbe 100644 --- a/clang/test/ARCMT/verify.m +++ b/clang/test/ARCMT/verify.m @@ -11,7 +11,7 @@ #error // expected-error@-1 {{}} -// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics' +// CHECK: error: no expected directives found: consider use of {{.*}}-no-diagnostics // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected: // CHECK-NEXT: (frontend): error reading '{{.*}}verify.m.tmp.invalid' // CHECK-NEXT: 2 errors generated. diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c index 221b715c19e416..657a9d3f2bf6bb 100644 --- a/clang/test/Frontend/verify.c +++ b/clang/test/Frontend/verify.c @@ -111,7 +111,7 @@ unexpected b; // expected-error@33 1-1 {{unknown type}} #if 0 // RUN: not %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s -// CHECK6: error: no expected directives found: consider use of 'expected-no-diagnostics' +// CHECK6: error: no expected directives found: consider use of {{.*}}-no-diagnostics // CHECK6-NEXT: error: 'expected-error' diagnostics seen but not expected: // CHECK6-NEXT: (frontend): error reading '{{.*}}verify.c.tmp.invalid' // CHECK6-NEXT: 2 errors generated. diff --git a/clang/test/Frontend/verify2.c b/clang/test/Frontend/verify2.c index debaeb6b498678..77510c8d9b4940 100644 --- a/clang/test/Frontend/verify2.c +++ b/clang/test/Frontend/verify2.c @@ -12,7 +12,7 @@ #if 0 // expected-error {{should be ignored}} -// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics' +// CHECK: error: no expected directives found: consider use of {{.*}}-no-diagnostics // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected: // CHECK-NEXT: Line 5: header // CHECK-NEXT: Line 10: source diff --git a/clang/test/Frontend/verify3.c b/clang/test/Frontend/verify3.c index e414c7370fad77..8924619592f583 100644 --- a/clang/test/Frontend/verify3.c +++ b/clang/test/Frontend/verify3.c @@ -28,7 +28,7 @@ #ifdef TEST3 // no directives -// CHECK3: error: no expected directives found: consider use of 'expected-no-diagnostics' +// CHECK3: error: no expected directives found: consider use of {{.*}}-no-diagnostics // CHECK3-NEXT: 1 error generated. #endif @@ -37,5 +37,5 @@ #warning X // expected-warning@-1 {{X}} -// CHECK4-NOT: error: no expected directives found: consider use of 'expected-no-diagnostics' +// CHECK4-NOT: error: no expected directives found: consider use of {{.*}}-no-diagnostics #endif >From 6074d28853f7b7e5c9fffa04300129aef328faa4 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Wed, 17 Jan 2024 01:24:44 +0530 Subject: [PATCH 02/22] ran git clang formatter --- clang/lib/AST/ASTContext.cpp | 2 +- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 0997ac9fa7df04..e3b2f1f48ed1e2 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1404,7 +1404,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target, getTranslationUnitDecl()->addDecl(MSGuidTagDecl); } } -// maybe change here also. +// maybe change here also. DiagnosticsEngine &ASTContext::getDiagnostics() const { return SourceMgr.getDiagnostics(); } diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 9a26905a76d46b..30cd7f47a21c1f 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1099,7 +1099,8 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // source file(s) processed. if (Status == HasNoDirectives) { // change here - std::string directives = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); + std::string directives = + *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); Diags.Report(diag::err_verify_no_directives).setForceEmit() << directives; ++NumErrors; Status = HasNoDirectivesReported; >From ab3c0f7cba57a6d5c0da5c361607b0b61bd42213 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Wed, 17 Jan 2024 02:18:46 +0530 Subject: [PATCH 03/22] [Github Automation] : Add support for optional colon after /cherry-pick and /branch --- llvm/utils/git/github-automation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py index c5fcf752310111..419a1c880272c6 100755 --- a/llvm/utils/git/github-automation.py +++ b/llvm/utils/git/github-automation.py @@ -635,16 +635,16 @@ def execute_command(self) -> bool: """ This function reads lines from STDIN and executes the first command that it finds. The 2 supported commands are: - /cherry-pick commit0 <commit1> <commit2> <...> - /branch <owner>/<repo>/<branch> + /cherry-pick<:> commit0 <commit1> <commit2> <...> + /branch<:> <owner>/<repo>/<branch> """ for line in sys.stdin: line.rstrip() - m = re.search(r"/([a-z-]+)\s(.+)", line) + m = re.search(r"/([a-z-]+)(:?)(?:\s(.+))?", line) if not m: continue command = m.group(1) - args = m.group(2) + args = m.group(3) if command == "cherry-pick": arg_list = args.split() >From 53a25bfd2d39860c616a7b43fb74d20d4109b0d2 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Wed, 17 Jan 2024 12:01:50 +0530 Subject: [PATCH 04/22] Removed Unnecesary Comments --- clang/include/clang/Basic/Diagnostic.h | 2 -- clang/lib/AST/ASTContext.cpp | 2 +- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index a185c75e418b58..7354e20bc2ffc4 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -11,8 +11,6 @@ // //===----------------------------------------------------------------------===//] -// look into this file as well - #ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H #define LLVM_CLANG_BASIC_DIAGNOSTIC_H diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index e3b2f1f48ed1e2..b60dcfaabfd1a4 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1404,7 +1404,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target, getTranslationUnitDecl()->addDecl(MSGuidTagDecl); } } -// maybe change here also. + DiagnosticsEngine &ASTContext::getDiagnostics() const { return SourceMgr.getDiagnostics(); } diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 30cd7f47a21c1f..6288469eb80b33 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1098,7 +1098,6 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Produce an error if no expected-* directives could be found in the // source file(s) processed. if (Status == HasNoDirectives) { - // change here std::string directives = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); Diags.Report(diag::err_verify_no_directives).setForceEmit() << directives; >From 727b479f575fcc5808e2af79becf64a3b2b22ee6 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Wed, 17 Jan 2024 16:40:24 +0530 Subject: [PATCH 05/22] Removed Unrelated Changes --- clang/include/clang/Basic/Diagnostic.h | 2 +- llvm/utils/git/github-automation.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h index 7354e20bc2ffc4..0c7836c2ea569c 100644 --- a/clang/include/clang/Basic/Diagnostic.h +++ b/clang/include/clang/Basic/Diagnostic.h @@ -9,7 +9,7 @@ /// \file /// Defines the Diagnostic-related interfaces. // -//===----------------------------------------------------------------------===//] +//===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_BASIC_DIAGNOSTIC_H #define LLVM_CLANG_BASIC_DIAGNOSTIC_H diff --git a/llvm/utils/git/github-automation.py b/llvm/utils/git/github-automation.py index 419a1c880272c6..c5fcf752310111 100755 --- a/llvm/utils/git/github-automation.py +++ b/llvm/utils/git/github-automation.py @@ -635,16 +635,16 @@ def execute_command(self) -> bool: """ This function reads lines from STDIN and executes the first command that it finds. The 2 supported commands are: - /cherry-pick<:> commit0 <commit1> <commit2> <...> - /branch<:> <owner>/<repo>/<branch> + /cherry-pick commit0 <commit1> <commit2> <...> + /branch <owner>/<repo>/<branch> """ for line in sys.stdin: line.rstrip() - m = re.search(r"/([a-z-]+)(:?)(?:\s(.+))?", line) + m = re.search(r"/([a-z-]+)\s(.+)", line) if not m: continue command = m.group(1) - args = m.group(3) + args = m.group(2) if command == "cherry-pick": arg_list = args.split() >From 56a4212b8b54bf1146de959b80a340c1149d3d86 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Wed, 17 Jan 2024 20:04:09 +0530 Subject: [PATCH 06/22] refactor : Change position of '' and revert tests in indexer.test --- clang-tools-extra/clangd/test/indexer.test | 2 +- clang/include/clang/Basic/DiagnosticFrontendKinds.td | 2 +- clang/test/ARCMT/verify.m | 2 +- clang/test/Frontend/verify.c | 2 +- clang/test/Frontend/verify2.c | 2 +- clang/test/Frontend/verify3.c | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/clang-tools-extra/clangd/test/indexer.test b/clang-tools-extra/clangd/test/indexer.test index 213d33f8e2d6a5..2f01f6c557a7de 100644 --- a/clang-tools-extra/clangd/test/indexer.test +++ b/clang-tools-extra/clangd/test/indexer.test @@ -5,5 +5,5 @@ # `.ii` file and `-verify` triggers extra diagnostics generation. Clangd should # strip those. # RUN: clangd-indexer %t.cpp -- -Xclang -verify --save-temps -- 2>&1 | FileCheck %s -# CHECK-NOT: error: no expected directives found: consider use of {{.*}}-no-diagnostics +# CHECK-NOT: error: no expected directives found: consider use of 'expected-no-diagnostics' # RUN: not ls %t.ii diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index 42d2767af6b708..56a79d7bf42263 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -179,7 +179,7 @@ def err_verify_invalid_no_diags : Error< "%select{expected|'expected-no-diagnostics'}0 directive cannot follow " "%select{'expected-no-diagnostics' directive|other expected directives}0">; def err_verify_no_directives : Error< - "no expected directives found: consider use of '%0'-no-diagnostics">; + "no expected directives found: consider use of '%0-no-diagnostics'">; def err_verify_nonconst_addrspace : Error< "qualifier 'const' is needed for variables in address space '%0'">; diff --git a/clang/test/ARCMT/verify.m b/clang/test/ARCMT/verify.m index 13fd599f530fbe..06a5a528efd4b9 100644 --- a/clang/test/ARCMT/verify.m +++ b/clang/test/ARCMT/verify.m @@ -11,7 +11,7 @@ #error // expected-error@-1 {{}} -// CHECK: error: no expected directives found: consider use of {{.*}}-no-diagnostics +// CHECK: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected: // CHECK-NEXT: (frontend): error reading '{{.*}}verify.m.tmp.invalid' // CHECK-NEXT: 2 errors generated. diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c index 657a9d3f2bf6bb..f24ebda29a22ea 100644 --- a/clang/test/Frontend/verify.c +++ b/clang/test/Frontend/verify.c @@ -111,7 +111,7 @@ unexpected b; // expected-error@33 1-1 {{unknown type}} #if 0 // RUN: not %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s -// CHECK6: error: no expected directives found: consider use of {{.*}}-no-diagnostics +// CHECK6: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' // CHECK6-NEXT: error: 'expected-error' diagnostics seen but not expected: // CHECK6-NEXT: (frontend): error reading '{{.*}}verify.c.tmp.invalid' // CHECK6-NEXT: 2 errors generated. diff --git a/clang/test/Frontend/verify2.c b/clang/test/Frontend/verify2.c index 77510c8d9b4940..41ccac4a43fc3e 100644 --- a/clang/test/Frontend/verify2.c +++ b/clang/test/Frontend/verify2.c @@ -12,7 +12,7 @@ #if 0 // expected-error {{should be ignored}} -// CHECK: error: no expected directives found: consider use of {{.*}}-no-diagnostics +// CHECK: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected: // CHECK-NEXT: Line 5: header // CHECK-NEXT: Line 10: source diff --git a/clang/test/Frontend/verify3.c b/clang/test/Frontend/verify3.c index 8924619592f583..cf781a93fa8a5b 100644 --- a/clang/test/Frontend/verify3.c +++ b/clang/test/Frontend/verify3.c @@ -28,7 +28,7 @@ #ifdef TEST3 // no directives -// CHECK3: error: no expected directives found: consider use of {{.*}}-no-diagnostics +// CHECK3: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' // CHECK3-NEXT: 1 error generated. #endif @@ -37,5 +37,5 @@ #warning X // expected-warning@-1 {{X}} -// CHECK4-NOT: error: no expected directives found: consider use of {{.*}}-no-diagnostics +// CHECK4-NOT: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' #endif >From 75c02dbdc6ce9ba6a7b9df47ff9540943f543f9f Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Sat, 20 Jan 2024 00:20:53 +0530 Subject: [PATCH 07/22] Fix : Added Support for -verify= and -verify={multi diagnostics}, revert changes in only -verify= test cases in verify files --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 11 +++++++++-- clang/test/ARCMT/verify.m | 2 +- clang/test/Frontend/verify.c | 2 +- clang/test/Frontend/verify2.c | 2 +- clang/test/Frontend/verify3.c | 4 ++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 6288469eb80b33..1233ce872ffb0e 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1098,8 +1098,15 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Produce an error if no expected-* directives could be found in the // source file(s) processed. if (Status == HasNoDirectives) { - std::string directives = - *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); + std::string directives; + for(auto &Prefix : Diags.getDiagnosticOptions().VerifyPrefixes) { + directives = directives + Prefix + ","; + } + if(directives.empty()) { + directives = "expected"; + } else { + directives.pop_back(); + } Diags.Report(diag::err_verify_no_directives).setForceEmit() << directives; ++NumErrors; Status = HasNoDirectivesReported; diff --git a/clang/test/ARCMT/verify.m b/clang/test/ARCMT/verify.m index 06a5a528efd4b9..7d245fe80575e5 100644 --- a/clang/test/ARCMT/verify.m +++ b/clang/test/ARCMT/verify.m @@ -11,7 +11,7 @@ #error // expected-error@-1 {{}} -// CHECK: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' +// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics' // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected: // CHECK-NEXT: (frontend): error reading '{{.*}}verify.m.tmp.invalid' // CHECK-NEXT: 2 errors generated. diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c index f24ebda29a22ea..221b715c19e416 100644 --- a/clang/test/Frontend/verify.c +++ b/clang/test/Frontend/verify.c @@ -111,7 +111,7 @@ unexpected b; // expected-error@33 1-1 {{unknown type}} #if 0 // RUN: not %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s -// CHECK6: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' +// CHECK6: error: no expected directives found: consider use of 'expected-no-diagnostics' // CHECK6-NEXT: error: 'expected-error' diagnostics seen but not expected: // CHECK6-NEXT: (frontend): error reading '{{.*}}verify.c.tmp.invalid' // CHECK6-NEXT: 2 errors generated. diff --git a/clang/test/Frontend/verify2.c b/clang/test/Frontend/verify2.c index 41ccac4a43fc3e..debaeb6b498678 100644 --- a/clang/test/Frontend/verify2.c +++ b/clang/test/Frontend/verify2.c @@ -12,7 +12,7 @@ #if 0 // expected-error {{should be ignored}} -// CHECK: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' +// CHECK: error: no expected directives found: consider use of 'expected-no-diagnostics' // CHECK-NEXT: error: 'expected-error' diagnostics seen but not expected: // CHECK-NEXT: Line 5: header // CHECK-NEXT: Line 10: source diff --git a/clang/test/Frontend/verify3.c b/clang/test/Frontend/verify3.c index cf781a93fa8a5b..e414c7370fad77 100644 --- a/clang/test/Frontend/verify3.c +++ b/clang/test/Frontend/verify3.c @@ -28,7 +28,7 @@ #ifdef TEST3 // no directives -// CHECK3: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' +// CHECK3: error: no expected directives found: consider use of 'expected-no-diagnostics' // CHECK3-NEXT: 1 error generated. #endif @@ -37,5 +37,5 @@ #warning X // expected-warning@-1 {{X}} -// CHECK4-NOT: error: no expected directives found: consider use of '{{.*}}-no-diagnostics' +// CHECK4-NOT: error: no expected directives found: consider use of 'expected-no-diagnostics' #endif >From b8fd4abf1173216e838ee7bdf764179378fb8049 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Sat, 20 Jan 2024 00:28:28 +0530 Subject: [PATCH 08/22] Ran clang formatter --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 1233ce872ffb0e..2c989c15e4e506 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1099,10 +1099,10 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // source file(s) processed. if (Status == HasNoDirectives) { std::string directives; - for(auto &Prefix : Diags.getDiagnosticOptions().VerifyPrefixes) { + for (auto &Prefix : Diags.getDiagnosticOptions().VerifyPrefixes) { directives = directives + Prefix + ","; } - if(directives.empty()) { + if (directives.empty()) { directives = "expected"; } else { directives.pop_back(); >From e61fef0f81da0bd8202be35dd84586d95f21ed1e Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Tue, 23 Jan 2024 18:00:03 +0530 Subject: [PATCH 09/22] Updated Diagnostic error string builder logic --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 2c989c15e4e506..b82b88042b6394 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1099,13 +1099,10 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // source file(s) processed. if (Status == HasNoDirectives) { std::string directives; - for (auto &Prefix : Diags.getDiagnosticOptions().VerifyPrefixes) { - directives = directives + Prefix + ","; - } - if (directives.empty()) { + if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) { directives = "expected"; } else { - directives.pop_back(); + directives = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); } Diags.Report(diag::err_verify_no_directives).setForceEmit() << directives; ++NumErrors; >From ac5d2da76f5e7163d0aae8e2466903fefa5e3306 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Wed, 24 Jan 2024 18:02:37 +0530 Subject: [PATCH 10/22] Updated directives to Directive --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index b82b88042b6394..2c6c5d526edb3b 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1098,13 +1098,13 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Produce an error if no expected-* directives could be found in the // source file(s) processed. if (Status == HasNoDirectives) { - std::string directives; + std::string Directive; if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) { - directives = "expected"; + Directive = "expected"; } else { - directives = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); + Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); } - Diags.Report(diag::err_verify_no_directives).setForceEmit() << directives; + Diags.Report(diag::err_verify_no_directives).setForceEmit() << Directive; ++NumErrors; Status = HasNoDirectivesReported; } >From c192bddaea15ea6cbe59516233daa932cb80866f Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Sat, 27 Jan 2024 00:47:11 +0530 Subject: [PATCH 12/22] Reformat Directive to Err_Directive to get checks passed --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 2c6c5d526edb3b..dfcdbd5a38667a 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1098,13 +1098,13 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Produce an error if no expected-* directives could be found in the // source file(s) processed. if (Status == HasNoDirectives) { - std::string Directive; + std::string Err_Directive; if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) { - Directive = "expected"; + Err_Directive = "expected"; } else { - Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); + Err_Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); } - Diags.Report(diag::err_verify_no_directives).setForceEmit() << Directive; + Diags.Report(diag::err_verify_no_directives).setForceEmit() << Err_Directive; ++NumErrors; Status = HasNoDirectivesReported; } >From ed752f6327020b8fd8401b205043141b6c8a301d Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Sat, 27 Jan 2024 00:48:13 +0530 Subject: [PATCH 13/22] Revert --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index dfcdbd5a38667a..2c6c5d526edb3b 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1098,13 +1098,13 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Produce an error if no expected-* directives could be found in the // source file(s) processed. if (Status == HasNoDirectives) { - std::string Err_Directive; + std::string Directive; if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) { - Err_Directive = "expected"; + Directive = "expected"; } else { - Err_Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); + Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); } - Diags.Report(diag::err_verify_no_directives).setForceEmit() << Err_Directive; + Diags.Report(diag::err_verify_no_directives).setForceEmit() << Directive; ++NumErrors; Status = HasNoDirectivesReported; } >From 73809903e3f9fce7bc150fbeca9eb26fea55f575 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Sat, 27 Jan 2024 00:49:11 +0530 Subject: [PATCH 14/22] Revert back to original change --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 2c6c5d526edb3b..dfcdbd5a38667a 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1098,13 +1098,13 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Produce an error if no expected-* directives could be found in the // source file(s) processed. if (Status == HasNoDirectives) { - std::string Directive; + std::string Err_Directive; if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) { - Directive = "expected"; + Err_Directive = "expected"; } else { - Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); + Err_Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); } - Diags.Report(diag::err_verify_no_directives).setForceEmit() << Directive; + Diags.Report(diag::err_verify_no_directives).setForceEmit() << Err_Directive; ++NumErrors; Status = HasNoDirectivesReported; } >From 55d8f401e36313f1077e80894ba2f8721ad69143 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Sat, 27 Jan 2024 00:49:34 +0530 Subject: [PATCH 15/22] Ran clang formatter --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index dfcdbd5a38667a..6e6397b6c57a59 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1104,7 +1104,8 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { } else { Err_Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); } - Diags.Report(diag::err_verify_no_directives).setForceEmit() << Err_Directive; + Diags.Report(diag::err_verify_no_directives).setForceEmit() + << Err_Directive; ++NumErrors; Status = HasNoDirectivesReported; } >From d52d4330ed40fd396b579f80d4d0003f17231636 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Wed, 31 Jan 2024 23:47:33 +0530 Subject: [PATCH 16/22] Removed {} in the logic builder --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index c13f294449312b..979297f50411ef 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -1104,14 +1104,13 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Produce an error if no expected-* directives could be found in the // source file(s) processed. if (Status == HasNoDirectives) { - std::string Err_Directive; - if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) { - Err_Directive = "expected"; - } else { - Err_Directive = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); - } + std::string ErrDirective; + if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) + ErrDirective = "expected"; + else + ErrDirective = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); Diags.Report(diag::err_verify_no_directives).setForceEmit() - << Err_Directive; + << ErrDirective; ++NumErrors; Status = HasNoDirectivesReported; } >From cadac6c71db4d07c80704850816d98d2c3636639 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Thu, 1 Feb 2024 00:45:22 +0530 Subject: [PATCH 17/22] Added test for changes --- clang/test/Frontend/verify.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c index c549011d7b7a9a..9785788f559603 100644 --- a/clang/test/Frontend/verify.c +++ b/clang/test/Frontend/verify.c @@ -158,6 +158,12 @@ unexpected b; // expected-error@33 1-1 {{unknown type}} // CHECK9: error: 'what-error' diagnostics expected but not seen: #endif +#ifdef TEST10 +// RUN : not %clang_cc1 -DTEST10 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK10 %s + +// CHECK10: error: no expected directives found: consider use of 'foo-no-diagnostics' +#endif + #ifdef TEST_WIDE_DELIM // RUN: not %clang_cc1 -DTEST_WIDE_DELIM -verify %s 2>&1 | FileCheck -check-prefix=CHECK-WIDE-DELIM %s >From a938283ac1f5fc68a859edf419f8cb88b722807a Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Thu, 1 Feb 2024 01:43:01 +0530 Subject: [PATCH 18/22] Refactored Tests --- clang/test/Frontend/verify.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c index 9785788f559603..afcbb00e54fc15 100644 --- a/clang/test/Frontend/verify.c +++ b/clang/test/Frontend/verify.c @@ -158,12 +158,6 @@ unexpected b; // expected-error@33 1-1 {{unknown type}} // CHECK9: error: 'what-error' diagnostics expected but not seen: #endif -#ifdef TEST10 -// RUN : not %clang_cc1 -DTEST10 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK10 %s - -// CHECK10: error: no expected directives found: consider use of 'foo-no-diagnostics' -#endif - #ifdef TEST_WIDE_DELIM // RUN: not %clang_cc1 -DTEST_WIDE_DELIM -verify %s 2>&1 | FileCheck -check-prefix=CHECK-WIDE-DELIM %s @@ -193,3 +187,9 @@ unexpected b; // expected-error@33 1-1 {{unknown type}} #endif #endif + +#ifdef TEST10 +// RUN : not %clang_cc1 -DTEST10 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK10 %s + +// CHECK10: error: no expected directives found: consider use of 'foo-no-diagnostics' +#endif >From 36e8691a6b9649a5abb988d83cdc25bcafaea80d Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Tue, 6 Feb 2024 22:18:48 +0530 Subject: [PATCH 19/22] Templated the error message err_verify_invalid_no_diags --- .../clang/Basic/DiagnosticFrontendKinds.td | 4 +-- .../lib/Frontend/VerifyDiagnosticConsumer.cpp | 20 +++++++++------ clang/test/Frontend/verify.c | 25 ++++++++++++++++++- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index 9e467321e1d293..b1a282f5164a2a 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -176,8 +176,8 @@ def err_verify_inconsistent_diags : Error< "'%0' diagnostics %select{expected|seen}1 but not %select{seen|expected}1: " "%2">; def err_verify_invalid_no_diags : Error< - "%select{expected|'expected-no-diagnostics'}0 directive cannot follow " - "%select{'expected-no-diagnostics' directive|other expected directives}0">; + "%select{expected|'%0-no-diagnostics'}1 directive cannot follow " + "%select{'%0-no-diagnostics' directive|other expected directives}1">; def err_verify_no_directives : Error< "no expected directives found: consider use of '%0-no-diagnostics'">; def err_verify_nonconst_addrspace : Error< diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 979297f50411ef..63162161fd0909 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -396,6 +396,15 @@ class VerifyDiagnosticConsumer::MarkerTracker { } }; +std::string DetailedErrorString (DiagnosticsEngine &Diags) { + std::string ErrDirective; + if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) + ErrDirective = "expected"; + else + ErrDirective = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); + return ErrDirective; +} + /// ParseDirective - Go through the comment and see if it indicates expected /// diagnostics. If so, then put them in the appropriate directive list. /// @@ -477,14 +486,14 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM, if (NoDiag) { if (Status == VerifyDiagnosticConsumer::HasOtherExpectedDirectives) - Diags.Report(Pos, diag::err_verify_invalid_no_diags) + Diags.Report(Pos, diag::err_verify_invalid_no_diags) << DetailedErrorString(Diags) << /*IsExpectedNoDiagnostics=*/true; else Status = VerifyDiagnosticConsumer::HasExpectedNoDiagnostics; continue; } if (Status == VerifyDiagnosticConsumer::HasExpectedNoDiagnostics) { - Diags.Report(Pos, diag::err_verify_invalid_no_diags) + Diags.Report(Pos, diag::err_verify_invalid_no_diags) << DetailedErrorString(Diags) << /*IsExpectedNoDiagnostics=*/false; continue; } @@ -1104,13 +1113,8 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { // Produce an error if no expected-* directives could be found in the // source file(s) processed. if (Status == HasNoDirectives) { - std::string ErrDirective; - if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) - ErrDirective = "expected"; - else - ErrDirective = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); Diags.Report(diag::err_verify_no_directives).setForceEmit() - << ErrDirective; + << DetailedErrorString(Diags); ++NumErrors; Status = HasNoDirectivesReported; } diff --git a/clang/test/Frontend/verify.c b/clang/test/Frontend/verify.c index afcbb00e54fc15..afd1c7d6907e20 100644 --- a/clang/test/Frontend/verify.c +++ b/clang/test/Frontend/verify.c @@ -189,7 +189,30 @@ unexpected b; // expected-error@33 1-1 {{unknown type}} #endif #ifdef TEST10 -// RUN : not %clang_cc1 -DTEST10 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK10 %s +// RUN: not %clang_cc1 -DTEST10 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK10 %s // CHECK10: error: no expected directives found: consider use of 'foo-no-diagnostics' #endif + +#ifdef TEST11 +// RUN: not %clang_cc1 -DTEST11 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK11 %s + +// foo-no-diagnostics +// foo-note {{}} + +// CHECK11: error: 'foo-error' diagnostics seen but not expected: +// CHECK11-NEXT: Line 201: expected directive cannot follow 'foo-no-diagnostics' directive +// CHECK11-NEXT: 1 error generated. +#endif + +#ifdef TEST12 +// RUN: not %clang_cc1 -DTEST12 -verify=foo %s 2>&1 | FileCheck -check-prefix=CHECK12 %s + +#warning X +// foo-warning@-1 {{X}} +// foo-no-diagnostics + +// CHECK12: error: 'foo-error' diagnostics seen but not expected: +// CHECK12-NEXT: Line 213: 'foo-no-diagnostics' directive cannot follow other expected directives +// CHECK12-NEXT: 1 error generated. +#endif >From 2f5789d4b9cb29529e3c53ba7ac27111f4418f54 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Tue, 6 Feb 2024 22:19:34 +0530 Subject: [PATCH 20/22] Ran clang formatter --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 63162161fd0909..2f40dd3ce862a5 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -396,7 +396,7 @@ class VerifyDiagnosticConsumer::MarkerTracker { } }; -std::string DetailedErrorString (DiagnosticsEngine &Diags) { +std::string DetailedErrorString(DiagnosticsEngine &Diags) { std::string ErrDirective; if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) ErrDirective = "expected"; @@ -486,15 +486,15 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM, if (NoDiag) { if (Status == VerifyDiagnosticConsumer::HasOtherExpectedDirectives) - Diags.Report(Pos, diag::err_verify_invalid_no_diags) << DetailedErrorString(Diags) - << /*IsExpectedNoDiagnostics=*/true; + Diags.Report(Pos, diag::err_verify_invalid_no_diags) + << DetailedErrorString(Diags) << /*IsExpectedNoDiagnostics=*/true; else Status = VerifyDiagnosticConsumer::HasExpectedNoDiagnostics; continue; } if (Status == VerifyDiagnosticConsumer::HasExpectedNoDiagnostics) { - Diags.Report(Pos, diag::err_verify_invalid_no_diags) << DetailedErrorString(Diags) - << /*IsExpectedNoDiagnostics=*/false; + Diags.Report(Pos, diag::err_verify_invalid_no_diags) + << DetailedErrorString(Diags) << /*IsExpectedNoDiagnostics=*/false; continue; } Status = VerifyDiagnosticConsumer::HasOtherExpectedDirectives; >From 0ab2604857cbb46aa9e4ac7a8fe89c46c90a4821 Mon Sep 17 00:00:00 2001 From: Sh0g0-1758 <shouryagoel10...@gmail.com> Date: Wed, 7 Feb 2024 02:11:59 +0530 Subject: [PATCH 21/22] Refactored DetailedErrorString Function --- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 2f40dd3ce862a5..48330e93617181 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -396,13 +396,10 @@ class VerifyDiagnosticConsumer::MarkerTracker { } }; -std::string DetailedErrorString(DiagnosticsEngine &Diags) { - std::string ErrDirective; +static std::string DetailedErrorString(const DiagnosticsEngine &Diags) { if (Diags.getDiagnosticOptions().VerifyPrefixes.empty()) - ErrDirective = "expected"; - else - ErrDirective = *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); - return ErrDirective; + return "expected"; + return *Diags.getDiagnosticOptions().VerifyPrefixes.begin(); } /// ParseDirective - Go through the comment and see if it indicates expected _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits