<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Aug 3, 2018 at 12:20 AM Reka Kovacs via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rkovacs<br>
Date: Thu Aug  2 15:19:57 2018<br>
New Revision: 338775<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=338775&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=338775&view=rev</a><br>
Log:<br>
[analyzer] Add a safety check to InnerPointerChecker.<br>
<br>
Do not crash if the CXXRecordDecl of an object is not available.<br>
<br>
Modified:<br>
    cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp<br>
<br>
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp?rev=338775&r1=338774&r2=338775&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp?rev=338775&r1=338774&r2=338775&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp (original)<br>
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp Thu Aug  2 15:19:57 2018<br>
@@ -129,8 +129,11 @@ bool InnerPointerChecker::isCalledOnStri<br>
     return false;<br>
<br>
   QualType ObjTy = ObjRegion->getValueType();<br>
-  if (ObjTy.isNull() ||<br>
-      ObjTy->getAsCXXRecordDecl()->getName() != "basic_string")<br>
+  if (ObjTy.isNull())<br>
+    return false;<br>
+<br>
+  CXXRecordDecl *Decl = ObjTy->getAsCXXRecordDecl();<br>
+  if (!Decl || Decl->getName() != "basic_string")<br>
     return false;<br>
<br>
   return true;<br></blockquote><div><br></div><div>Thanks for the fix! An improvement suggestion:</div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">return Decl && Decl->getName() == "basic_string";</span><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>