This revision was automatically updated to reflect the committed changes. Closed by commit rG9be33de4f397: [clang-tidy]`pro-bounds-array-to-pointer-decay` ignore predefined expression (authored by HerrCai0907).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158244/new/ https://reviews.llvm.org/D158244 Files: clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-array-to-pointer-decay.cpp Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-array-to-pointer-decay.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-array-to-pointer-decay.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-array-to-pointer-decay.cpp @@ -43,6 +43,9 @@ const char *g2() { return ("clang"); // OK, ParenExpr hides the literal-pointer decay } +const char *g3() { + return __func__; // OK, don't diagnose PredefinedExpr +} void f2(void *const *); void bug25362() { Index: clang-tools-extra/docs/ReleaseNotes.rst =================================================================== --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -186,6 +186,10 @@ <clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to ignore delegate constructors. +- Improved :doc `cppcoreguidelines-pro-bounds-array-to-pointer-decay + <clang-tidy/checks/cppcoreguidelines/pro-bounds-array-to-pointer-decay>` check + to ignore predefined expression (e.g., ``__func__``, ...). + - Improved :doc:`cppcoreguidelines-pro-type-member-init <clang-tidy/checks/cppcoreguidelines/pro-type-member-init>` check to ignore dependent delegate constructors. Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp +++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp @@ -10,6 +10,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/ParentMapContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" using namespace clang::ast_matchers; @@ -56,6 +57,7 @@ TK_AsIs, implicitCastExpr( unless(hasParent(arraySubscriptExpr())), + unless(hasSourceExpression(predefinedExpr())), unless(hasParentIgnoringImpCasts(explicitCastExpr())), unless(isInsideOfRangeBeginEndStmt()), unless(hasSourceExpression(ignoringParens(stringLiteral()))),
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-array-to-pointer-decay.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-array-to-pointer-decay.cpp +++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-bounds-array-to-pointer-decay.cpp @@ -43,6 +43,9 @@ const char *g2() { return ("clang"); // OK, ParenExpr hides the literal-pointer decay } +const char *g3() { + return __func__; // OK, don't diagnose PredefinedExpr +} void f2(void *const *); void bug25362() { Index: clang-tools-extra/docs/ReleaseNotes.rst =================================================================== --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -186,6 +186,10 @@ <clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to ignore delegate constructors. +- Improved :doc `cppcoreguidelines-pro-bounds-array-to-pointer-decay + <clang-tidy/checks/cppcoreguidelines/pro-bounds-array-to-pointer-decay>` check + to ignore predefined expression (e.g., ``__func__``, ...). + - Improved :doc:`cppcoreguidelines-pro-type-member-init <clang-tidy/checks/cppcoreguidelines/pro-type-member-init>` check to ignore dependent delegate constructors. Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp +++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp @@ -10,6 +10,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/ParentMapContext.h" #include "clang/ASTMatchers/ASTMatchFinder.h" +#include "clang/ASTMatchers/ASTMatchers.h" using namespace clang::ast_matchers; @@ -56,6 +57,7 @@ TK_AsIs, implicitCastExpr( unless(hasParent(arraySubscriptExpr())), + unless(hasSourceExpression(predefinedExpr())), unless(hasParentIgnoringImpCasts(explicitCastExpr())), unless(isInsideOfRangeBeginEndStmt()), unless(hasSourceExpression(ignoringParens(stringLiteral()))),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits