Is there a way that Clang can check if the warning is turned off and skip the expensive checking?<div>And did you mean the list in <meta http-equiv="content-type" content="text/html; charset=utf-8">[basic.lval]p15?  <meta http-equiv="content-type" content="text/html; charset=utf-8">[basic.lval]p10 doesn't have a list.<br>
<br><div class="gmail_quote">On Wed, Apr 27, 2011 at 4:32 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Apr 27, 2011, at 4:18 PM, Richard Trieu wrote:<br>
> Added a new check so that casting between tag types doesn't give the warning.  Casting to/from chars and voids won't throw the warning either.  Anything else needed?<br>
<br>
</div><div class="im">+// Returns false if the reinterpret_cast has undefined behavior.<br>
+// SrcType = A, DestType = B<br>
+// *reinterpret_cast<B*>(&A)<br>
</div>+// reinterpret_cast<&B>(A)<br>
<div class="im">+bool Sema::CompatibleReinterpretCast(QualType SrcType,<br>
<br>
</div>You have punctuation backwards in the comment.  Also, this is a predicate<br>
and should be named like one, e.g. "isCompatibleReinterpretCast".<br>
<br>
If the intent of this warning is to warn about violations of the aliasing rules<br>
in [basic.lval]p10, you really need to white-list all those cases.  That's going<br>
to be kindof expensive to check on every reinterpret_cast for a warning<br>
that's disabled by default.<br>
<br>
+  if (S.getLangOptions().CPlusPlus && isa<CXXReinterpretCastExpr>(Op)) {<br>
+    QualType OpOrigType = Op->IgnoreParenCasts()->getType();<br>
+    if (OpOrigType->isPointerType() && OpTy->isPointerType()) {<br>
<br>
Unconditionally checking for CXXReinterpretCastExpr is very likely<br>
faster than checking for the language option.<br>
<br>
Also, you should use getAs<PointerType>() instead of<br>
isPointerType() / getPointeeType().<br>
<font color="#888888"><br>
John.<br>
</font></blockquote></div><br></div>