[PATCH] D36670: misc-misplaced-widening-cast: fix assertion
This revision was automatically updated to reflect the committed changes. Closed by commit rL311984: [clang-tidy] Fix 'misc-misplaced-widening-cast' assertion error. (authored by danielmarjamaki). Changed prior to commit: https://reviews.llvm.org/D36670?vs=110940=113026#toc Repository: rL LLVM https://reviews.llvm.org/D36670 Files: clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp Index: clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp === --- clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp @@ -56,3 +56,9 @@ return (long)a * 1000; } } + +// Shall not generate an assert. https://bugs.llvm.org/show_bug.cgi?id=33660 +template class A { + enum Type {}; + static char *m_fn1() { char p = (Type)( - m_fn1()); } +}; Index: clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp @@ -192,6 +192,10 @@ if (Calc->getLocStart().isMacroID()) return; + if (Cast->isTypeDependent() || Cast->isValueDependent() || + Calc->isTypeDependent() || Calc->isValueDependent()) +return; + ASTContext = *Result.Context; QualType CastType = Cast->getType(); Index: clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp === --- clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp +++ clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp @@ -56,3 +56,9 @@ return (long)a * 1000; } } + +// Shall not generate an assert. https://bugs.llvm.org/show_bug.cgi?id=33660 +template class A { + enum Type {}; + static char *m_fn1() { char p = (Type)( - m_fn1()); } +}; Index: clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/misc/MisplacedWideningCastCheck.cpp @@ -192,6 +192,10 @@ if (Calc->getLocStart().isMacroID()) return; + if (Cast->isTypeDependent() || Cast->isValueDependent() || + Calc->isTypeDependent() || Calc->isValueDependent()) +return; + ASTContext = *Result.Context; QualType CastType = Cast->getType(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36670: misc-misplaced-widening-cast: fix assertion
alexfh accepted this revision. alexfh added a comment. LG. Thank you for the fix! Comment at: test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp:63 + enum Type {}; + static char *m_fn1() { char p = (Type)( - m_fn1()); } +}; xazax.hun wrote: > Isn't this testcase a bit overcomplicated to demonstrate the issue? It's what creduce spat out a few hours after I had run it on a pretty large preprocessed source. I wouldn't spend more time simplifying the case ;) Repository: rL LLVM https://reviews.llvm.org/D36670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36670: misc-misplaced-widening-cast: fix assertion
xazax.hun added inline comments. Comment at: test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp:63 + enum Type {}; + static char *m_fn1() { char p = (Type)( - m_fn1()); } +}; Isn't this testcase a bit overcomplicated to demonstrate the issue? Repository: rL LLVM https://reviews.llvm.org/D36670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36670: misc-misplaced-widening-cast: fix assertion
xazax.hun accepted this revision. xazax.hun added a comment. This revision is now accepted and ready to land. LGTM! Repository: rL LLVM https://reviews.llvm.org/D36670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36670: misc-misplaced-widening-cast: fix assertion
danielmarjamaki added a comment. LGTM. I let others approve this. Repository: rL LLVM https://reviews.llvm.org/D36670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36670: misc-misplaced-widening-cast: fix assertion
AndersRonnholm created this revision. AndersRonnholm added a project: clang-tools-extra. Fixes assert reported in https://bugs.llvm.org/show_bug.cgi?id=33660 Repository: rL LLVM https://reviews.llvm.org/D36670 Files: clang-tidy/misc/MisplacedWideningCastCheck.cpp test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp Index: test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp === --- test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp +++ test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp @@ -56,3 +56,9 @@ return (long)a * 1000; } } + +// Shall not generate an assert. https://bugs.llvm.org/show_bug.cgi?id=33660 +template class A { + enum Type {}; + static char *m_fn1() { char p = (Type)( - m_fn1()); } +}; Index: clang-tidy/misc/MisplacedWideningCastCheck.cpp === --- clang-tidy/misc/MisplacedWideningCastCheck.cpp +++ clang-tidy/misc/MisplacedWideningCastCheck.cpp @@ -192,6 +192,10 @@ if (Calc->getLocStart().isMacroID()) return; + if (Cast->isTypeDependent() || Cast->isValueDependent() || + Calc->isTypeDependent() || Calc->isValueDependent()) +return; + ASTContext = *Result.Context; QualType CastType = Cast->getType(); Index: test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp === --- test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp +++ test/clang-tidy/misc-misplaced-widening-cast-explicit-only.cpp @@ -56,3 +56,9 @@ return (long)a * 1000; } } + +// Shall not generate an assert. https://bugs.llvm.org/show_bug.cgi?id=33660 +template class A { + enum Type {}; + static char *m_fn1() { char p = (Type)( - m_fn1()); } +}; Index: clang-tidy/misc/MisplacedWideningCastCheck.cpp === --- clang-tidy/misc/MisplacedWideningCastCheck.cpp +++ clang-tidy/misc/MisplacedWideningCastCheck.cpp @@ -192,6 +192,10 @@ if (Calc->getLocStart().isMacroID()) return; + if (Cast->isTypeDependent() || Cast->isValueDependent() || + Calc->isTypeDependent() || Calc->isValueDependent()) +return; + ASTContext = *Result.Context; QualType CastType = Cast->getType(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits