mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:40:10 +01:00
Reduce clangd-displayed errors for def files (#4957)
When I open a .def file, there are often 4 errors: - The #error - The #define is not defined - Missing `;` - Identifier naming This PR is meant to disable all of these, since they can be distracting from fixable diagnostics.
This commit is contained in:
@@ -9,3 +9,13 @@ Diagnostics:
|
||||
# `unused-includes`: has false positives, reporting includes unused when
|
||||
# they are used.
|
||||
Suppress: [unused-includes]
|
||||
|
||||
---
|
||||
|
||||
# Suppress common diagnostics for x-macro files.
|
||||
If:
|
||||
PathMatch: .*\.def
|
||||
Diagnostics:
|
||||
Suppress:
|
||||
# The `#error` requiring a macro definition.
|
||||
- pp_hash_error
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#ifndef CARBON_ENUM_BASE_TEST_KIND
|
||||
#error "Must define the x-macro to use this file."
|
||||
#define CARBON_ENUM_BASE_TEST_KIND(Name)
|
||||
#endif
|
||||
|
||||
CARBON_ENUM_BASE_TEST_KIND(Beep)
|
||||
|
||||
@@ -43,7 +43,7 @@ def load_diagnostic_kind() -> Set[str]:
|
||||
"""
|
||||
path = Path("toolchain/diagnostics/diagnostic_kind.def")
|
||||
content = path.read_text()
|
||||
decls = set(re.findall(r"CARBON_DIAGNOSTIC_KIND\((.+)\)", content))
|
||||
decls = set(re.findall(r"^\s+CARBON_DIAGNOSTIC_KIND\((.+)\)", content))
|
||||
return decls.difference(IGNORED)
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#ifndef CARBON_DIAGNOSTIC_KIND
|
||||
#error "Must define the x-macro to use this file."
|
||||
#define CARBON_DIAGNOSTIC_KIND(Name)
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#if !defined(CARBON_PARSE_NODE_KIND)
|
||||
#error "Must define CARBON_PARSE_NODE_KIND family x-macros to use this file."
|
||||
#define CARBON_PARSE_NODE_KIND(Name)
|
||||
#endif
|
||||
|
||||
// This is expected to be used with something like:
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#ifndef CARBON_PARSE_STATE
|
||||
#error "Must define the x-macro to use this file."
|
||||
#define CARBON_PARSE_STATE(Name)
|
||||
#endif
|
||||
|
||||
// Use CARBON_PARSE_STATE_VARIANTSN(State, Variant1, Variant2, ...) to generate
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#if !defined(CARBON_SEM_IR_BUILTIN_FUNCTION_KIND)
|
||||
#error \
|
||||
"Must define CARBON_SEM_IR_BUILTIN_FUNCTION_KIND x-macro to use this file."
|
||||
#define CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(Name)
|
||||
#endif
|
||||
|
||||
CARBON_SEM_IR_BUILTIN_FUNCTION_KIND(None)
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#ifndef CARBON_SEM_IR_INST_KIND
|
||||
#error "Must define the x-macro to use this file."
|
||||
#define CARBON_SEM_IR_INST_KIND(Name)
|
||||
#endif
|
||||
|
||||
// For each instruction kind declared here there is a matching definition in
|
||||
|
||||
Reference in New Issue
Block a user