[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:204 + return true; +} + LegalizeAdulthood wrote: > LegalizeAdulthood wrote: > > aaron.ballman wrote: > > > LegalizeAdulthood wrote: > >

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-14 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked an inline comment as done. LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:204 + return true; +} + LegalizeAdulthood wrote: > aaron.ballman wrote: > >

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-14 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked an inline comment as done. LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:210-214 +std::ostream <<(std::ostream , + const clang::tidy::test::Param ) { + return

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-14 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked an inline comment as done. LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:210-214 +std::ostream <<(std::ostream , + const clang::tidy::test::Param ) { + return

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments. Comment at: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:210-214 +std::ostream <<(std::ostream , + const clang::tidy::test::Param ) { + return Str << "Matched: " << std::boolalpha << Value.Matched <<

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-14 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:210-214 +std::ostream <<(std::ostream , + const clang::tidy::test::Param ) { + return Str << "Matched: " << std::boolalpha <<

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-14 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:210-214 +std::ostream <<(std::ostream , + const clang::tidy::test::Param ) { + return Str << "Matched: " << std::boolalpha <<

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments. Comment at: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:210-214 +std::ostream <<(std::ostream , + const clang::tidy::test::Param ) { + return Str << "Matched: " << std::boolalpha << Value.Matched <<

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-13 Thread Richard via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG512273833136: [clang-tidy] Support expressions of literals in modernize-macro-to-enum (authored by LegalizeAdulthood). Repository: rG LLVM Github

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-13 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 429353. LegalizeAdulthood added a comment. Update documentation from review comments CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124500/new/ https://reviews.llvm.org/D124500 Files:

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-09 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:99 + + if (!Current->isLiteral() || isStringLiteral(Current->getKind()) || + !isIntegralConstant(*Current)) { aaron.ballman

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-09 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/docs/clang-tidy/checks/modernize-macro-to-enum.rst:21-22 + `,`, `-`, `+`, `*`, `/`, `%`, `&`, `|`, `^`, `<`, `>`, `<=`, `>=`, + `==`, `!=`, `||`, `&&`, `<<`, `>>` or `<=>`, and the ternary operator +

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision. aaron.ballman added a comment. This revision is now accepted and ready to land. In D124500#3499683 , @LegalizeAdulthood wrote: > OK, so thinking about this review a little more, I propose this: > > - Take the check

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-08 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked 2 inline comments as done. LegalizeAdulthood added a comment. OK, so thinking about this review a little more, I propose this: - Take the check as is, but document that the initializing expressions may result in an invalid enum, particularly for C which restricts the

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-08 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked an inline comment as done. LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:99 + + if (!Current->isLiteral() || isStringLiteral(Current->getKind()) || +

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:99 + + if (!Current->isLiteral() || isStringLiteral(Current->getKind()) || + !isIntegralConstant(*Current)) { aaron.ballman wrote:

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-02 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:99 + + if (!Current->isLiteral() || isStringLiteral(Current->getKind()) || + !isIntegralConstant(*Current)) {

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:99 + + if (!Current->isLiteral() || isStringLiteral(Current->getKind()) || + !isIntegralConstant(*Current)) { LegalizeAdulthood

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-02 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:99 + + if (!Current->isLiteral() || isStringLiteral(Current->getKind()) || + !isIntegralConstant(*Current)) { aaron.ballman

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D124500#3485924 , @LegalizeAdulthood wrote: > In D124500#3485462 , @aaron.ballman > wrote: > >> I largely agree, but I've found cases where we'll convert correct code to >>

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-02 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:99 + + if (!Current->isLiteral() || isStringLiteral(Current->getKind()) || + !isIntegralConstant(*Current)) { aaron.ballman

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-02 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment. In D124500#3485462 , @aaron.ballman wrote: > In D124500#3483328 , > @LegalizeAdulthood wrote: > >> In D124500#3483224 , >>

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. In D124500#3483328 , @LegalizeAdulthood wrote: > In D124500#3483224 , @aaron.ballman > wrote: > >> To clarify my previous comments, I'm fine punting on the edge cases until >>

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-30 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment. FYI, once nice addition of the parsing of macro bodies is that it paves the way for a modernize-macro-to-function check that converts function-like macros that compute values to template functions. Once this change has landed, I'll be putting up a review for

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-30 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 426263. LegalizeAdulthood added a comment. Recognize comma operator expressions CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124500/new/ https://reviews.llvm.org/D124500 Files: clang-tools-extra/clang-tidy/modernize/CMakeLists.txt

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-30 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:204 + return true; +} + LegalizeAdulthood wrote: > aaron.ballman wrote: > > LegalizeAdulthood wrote: > > > aaron.ballman wrote: > >

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-29 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 426160. LegalizeAdulthood marked an inline comment as done. LegalizeAdulthood added a comment. Update from review comments CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124500/new/ https://reviews.llvm.org/D124500 Files:

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-29 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked 7 inline comments as done. LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.h:18-20 +// Parses an array of tokens and returns true if they conform to the rules of +// C++ for

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-29 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked 3 inline comments as done. LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:66 +{false, "1.23"}, +{false, "0x1p3"}, +{false, R"("string")"}, LegalizeAdulthood

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-29 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment. In D124500#3483224 , @aaron.ballman wrote: > To clarify my previous comments, I'm fine punting on the edge cases until > user reports come in, so don't let them block this review if you feel > strongly about not

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-29 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked 3 inline comments as done. LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:99 + + if (!Current->isLiteral() || isStringLiteral(Current->getKind()) || +

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment. To clarify my previous comments, I'm fine punting on the edge cases until user reports come in, so don't let them block this review if you feel strongly about not supporting them. But when user reports start coming in, at some point I might start asking to

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:99 + + if (!Current->isLiteral() || isStringLiteral(Current->getKind()) || + !isIntegralConstant(*Current)) { LegalizeAdulthood

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-29 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood marked 2 inline comments as done. LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:32-33 + // not a decimal floating-point literal + return std::none_of( + Begin, End,

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:25 + + // not a hexadecimal floating-point literal + if (Token.getLength() > 2 && Begin[0] == '0' && std::toupper(Begin[1]) == 'X')

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-28 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 425700. LegalizeAdulthood added a comment. Update documentation CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124500/new/ https://reviews.llvm.org/D124500 Files: clang-tools-extra/clang-tidy/modernize/CMakeLists.txt

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-27 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 425679. LegalizeAdulthood added a comment. Add file block comment CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124500/new/ https://reviews.llvm.org/D124500 Files: clang-tools-extra/clang-tidy/modernize/CMakeLists.txt

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-27 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/unittests/clang-tidy/ModernizeModuleTest.cpp:1 +#include "ClangTidyTest.h" +#include "modernize/IntegralLiteralExpressionMatcher.h" Needs a file header CHANGES SINCE LAST ACTION

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-27 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 425425. LegalizeAdulthood added a comment. Inline Variable CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124500/new/ https://reviews.llvm.org/D124500 Files: clang-tools-extra/clang-tidy/modernize/CMakeLists.txt

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-27 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 425423. LegalizeAdulthood added a comment. - Add banner block comment for new files - Extract Functions to eliminate duplication CHANGES SINCE LAST ACTION https://reviews.llvm.org/D124500/new/ https://reviews.llvm.org/D124500 Files:

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-26 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments. Comment at: clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp:1 +#include "IntegralLiteralExpressionMatcher.h" + ditto Comment at:

[PATCH] D124500: [clang-tidy] Support expressions of literals in modernize-macro-to-enum

2022-04-26 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood created this revision. LegalizeAdulthood added a reviewer: aaron.ballman. Herald added subscribers: carlosgalvezp, xazax.hun, mgorny. Herald added a project: All. LegalizeAdulthood requested review of this revision. Herald added a project: clang-tools-extra. Herald added a