================ @@ -0,0 +1,111 @@ +//===--- UseConcisePreprocessorDirectivesCheck.cpp - clang-tidy -----------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include "UseConcisePreprocessorDirectivesCheck.h" +#include "clang/Basic/TokenKinds.h" +#include "clang/Lex/Lexer.h" +#include "clang/Lex/PPCallbacks.h" +#include "clang/Lex/Preprocessor.h" + +#include <array> + +namespace clang::tidy::readability { + +namespace { + +class IfPreprocessorCallbacks final : public PPCallbacks { +public: + IfPreprocessorCallbacks(ClangTidyCheck &Check, const Preprocessor &PP) + : Check(Check), PP(PP) {} + + void If(SourceLocation Loc, SourceRange ConditionRange, + ConditionValueKind) override { + impl(Loc, ConditionRange, {"ifdef", "ifndef"}); + } + + void Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind, + SourceLocation) override { + if (PP.getLangOpts().C23 || PP.getLangOpts().CPlusPlus23) { + impl(Loc, ConditionRange, {"elifdef", "elifndef"}); + } ---------------- vbvictor wrote:
```suggestion if (PP.getLangOpts().C23 || PP.getLangOpts().CPlusPlus23) impl(Loc, ConditionRange, {"elifdef", "elifndef"}); ``` Probable enabling https://clang.llvm.org/docs/ClangFormatStyleOptions.html#removebracesllvm option will catch it https://github.com/llvm/llvm-project/pull/146830 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits