[llvm] [clang-tools-extra] [clang] [CLANG] Fix : More Detailed "No expected directives found" (PR #78338)
Shourya Goel via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 17 03:10:40 PST 2024
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 <shouryagoel10000 at gmail.com>
Date: Wed, 17 Jan 2024 01:24:17 +0530
Subject: [PATCH 1/5] 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 2f01f6c557a7de7..213d33f8e2d6a56 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 0c7836c2ea569cc..a185c75e418b58b 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 568000106a84dc7..42d2767af6b7081 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 b60dcfaabfd1a4b..0997ac9fa7df042 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 8a3d2286cd168c3..9a26905a76d46bb 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 7d245fe80575e5b..13fd599f530fbec 100644
--- a/clang/test/ARCMT/verify.m
+++ b/clang/test/ARCMT/verify.m
@@ -11,7 +11,7 @@
#error
// expected-error at -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 221b715c19e416e..657a9d3f2bf6bb7 100644
--- a/clang/test/Frontend/verify.c
+++ b/clang/test/Frontend/verify.c
@@ -111,7 +111,7 @@ unexpected b; // expected-error at 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 debaeb6b498678a..77510c8d9b4940d 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 e414c7370fad772..8924619592f5835 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 at -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 <shouryagoel10000 at gmail.com>
Date: Wed, 17 Jan 2024 01:24:44 +0530
Subject: [PATCH 2/5] 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 0997ac9fa7df042..e3b2f1f48ed1e24 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 9a26905a76d46bb..30cd7f47a21c1f8 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 <shouryagoel10000 at gmail.com>
Date: Wed, 17 Jan 2024 02:18:46 +0530
Subject: [PATCH 3/5] [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 c5fcf7523101116..419a1c880272c62 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 <shouryagoel10000 at gmail.com>
Date: Wed, 17 Jan 2024 12:01:50 +0530
Subject: [PATCH 4/5] 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 a185c75e418b58b..7354e20bc2ffc47 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 e3b2f1f48ed1e24..b60dcfaabfd1a4b 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 30cd7f47a21c1f8..6288469eb80b335 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 <shouryagoel10000 at gmail.com>
Date: Wed, 17 Jan 2024 16:40:24 +0530
Subject: [PATCH 5/5] 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 7354e20bc2ffc47..0c7836c2ea569cc 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 419a1c880272c62..c5fcf7523101116 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()
More information about the cfe-commits
mailing list