[PATCH] D36670: misc-misplaced-widening-cast: fix assertion
Anders Rönnholm via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 14 04:25:12 PDT 2017
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> class A {
+ enum Type {};
+ static char *m_fn1() { char p = (Type)(&p - 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 &Context = *Result.Context;
QualType CastType = Cast->getType();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36670.110940.patch
Type: text/x-patch
Size: 1035 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170814/5dd2c0f9/attachment.bin>
More information about the cfe-commits
mailing list