[PATCH] Don't eagerly evaluate the TypeSourceInfo when mangling names.
David Blaikie
dblaikie at gmail.com
Tue Jun 24 17:53:41 PDT 2014
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.
On Jun 24, 2014 4:46 PM, "Zachary Turner" <zturner at google.com> wrote:
> Hi rnk, majnemer,
>
> Don't eagerly evaluate the TypeSourceInfo while mangling.
>
> A VarDecl may not have TypeSourceInfo, for example if source is
> generated in-memory by another application. This patch changes
> the mangler to use a default instance if the TypeSourceInfo
> doesn't exist.
>
> http://reviews.llvm.org/D4281
>
> Files:
> lib/AST/MicrosoftMangle.cpp
>
> Index: lib/AST/MicrosoftMangle.cpp
> ===================================================================
> --- lib/AST/MicrosoftMangle.cpp
> +++ lib/AST/MicrosoftMangle.cpp
> @@ -418,11 +418,13 @@
> // ::= <type> <pointee-cvr-qualifiers> # pointers,
> references
> // Pointers and references are odd. The type of 'int * const foo;' gets
> // mangled as 'QAHA' instead of 'PAHB', for example.
> - TypeLoc TL = VD->getTypeSourceInfo()->getTypeLoc();
> + SourceRange SR;
> + if (TypeSourceInfo *TI = VD->getTypeSourceInfo())
> + SR = TI->getTypeLoc().getSourceRange();
> QualType Ty = VD->getType();
> if (Ty->isPointerType() || Ty->isReferenceType() ||
> Ty->isMemberPointerType()) {
> - mangleType(Ty, TL.getSourceRange(), QMM_Drop);
> + mangleType(Ty, SR, QMM_Drop);
> manglePointerExtQualifiers(
> Ty.getDesugaredType(getASTContext()).getLocalQualifiers(),
> nullptr);
> if (const MemberPointerType *MPT = Ty->getAs<MemberPointerType>()) {
> @@ -440,7 +442,7 @@
> else
> mangleQualifiers(Ty.getQualifiers(), false);
> } else {
> - mangleType(Ty, TL.getSourceRange(), QMM_Drop);
> + mangleType(Ty, SR, QMM_Drop);
> mangleQualifiers(Ty.getLocalQualifiers(), false);
> }
> }
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140624/308f7516/attachment.html>
More information about the cfe-commits
mailing list