[clang-tools-extra] [clang-tidy] Add new check: `readability-use-concise-preprocessor-directives` (PR #146830)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 5 09:34:13 PDT 2025


================
@@ -0,0 +1,40 @@
+//===--- UseConcisePreprocessorDirectivesCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_USECONCISEPREPROCESSORDIRECTIVESCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_USECONCISEPREPROCESSORDIRECTIVESCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::readability {
+
+/// Shortens `#if` preprocessor conditions:
+///
+/// #if  defined(MEOW) -> #ifdef  MEOW
+/// #if !defined(MEOW) -> #ifndef MEOW
+///
+/// And, since C23 and C++23, shortens `#elif` conditions too:
+///
+/// #elif  defined(MEOW) -> #elifdef  MEOW
+/// #elif !defined(MEOW) -> #elifndef MEOW
----------------
vbvictor wrote:

This part should be the same as in ReleaseNotes

https://github.com/llvm/llvm-project/pull/146830


More information about the cfe-commits mailing list