<p dir="ltr">It'd be good to include an explanation (in a comment and/or the commit message) as to why this is necessary and untested in-tree so when someone comes back to this they don't remove it for being unnecessary.</p>

<div class="gmail_quote">On Jun 24, 2014 4:46 PM, "Zachary Turner" <<a href="mailto:zturner@google.com">zturner@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi rnk, majnemer,<br>
<br>
Don't eagerly evaluate the TypeSourceInfo while mangling.<br>
<br>
A VarDecl may not have TypeSourceInfo, for example if source is<br>
generated in-memory by another application.  This patch changes<br>
the mangler to use a default instance if the TypeSourceInfo<br>
doesn't exist.<br>
<br>
<a href="http://reviews.llvm.org/D4281" target="_blank">http://reviews.llvm.org/D4281</a><br>
<br>
Files:<br>
  lib/AST/MicrosoftMangle.cpp<br>
<br>
Index: lib/AST/MicrosoftMangle.cpp<br>
===================================================================<br>
--- lib/AST/MicrosoftMangle.cpp<br>
+++ lib/AST/MicrosoftMangle.cpp<br>
@@ -418,11 +418,13 @@<br>
   //                 ::= <type> <pointee-cvr-qualifiers> # pointers, references<br>
   // Pointers and references are odd. The type of 'int * const foo;' gets<br>
   // mangled as 'QAHA' instead of 'PAHB', for example.<br>
-  TypeLoc TL = VD->getTypeSourceInfo()->getTypeLoc();<br>
+  SourceRange SR;<br>
+  if (TypeSourceInfo *TI = VD->getTypeSourceInfo())<br>
+    SR = TI->getTypeLoc().getSourceRange();<br>
   QualType Ty = VD->getType();<br>
   if (Ty->isPointerType() || Ty->isReferenceType() ||<br>
       Ty->isMemberPointerType()) {<br>
-    mangleType(Ty, TL.getSourceRange(), QMM_Drop);<br>
+    mangleType(Ty, SR, QMM_Drop);<br>
     manglePointerExtQualifiers(<br>
         Ty.getDesugaredType(getASTContext()).getLocalQualifiers(), nullptr);<br>
     if (const MemberPointerType *MPT = Ty->getAs<MemberPointerType>()) {<br>
@@ -440,7 +442,7 @@<br>
     else<br>
       mangleQualifiers(Ty.getQualifiers(), false);<br>
   } else {<br>
-    mangleType(Ty, TL.getSourceRange(), QMM_Drop);<br>
+    mangleType(Ty, SR, QMM_Drop);<br>
     mangleQualifiers(Ty.getLocalQualifiers(), false);<br>
   }<br>
 }<br>
<br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div>