[PATCH] Don't eagerly evaluate the TypeSourceInfo when mangling names.
Zachary Turner
zturner at google.com
Tue Jun 24 15:41:34 PDT 2014
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);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4281.10812.patch
Type: text/x-patch
Size: 1212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140624/6f027aa6/attachment.bin>
More information about the cfe-commits
mailing list