[PATCH] Fix uninitialized value in AttributedTypeLoc.
Logan Chien
tzuhsiang.chien at gmail.com
Sat Mar 8 23:29:41 PST 2014
Hi aaron.ballman,
The uninitialized value for enum operand in AttributedTypeLoc
might be used during the serialization or deserialization of the
precompiled headers. This commit fix this issue by adding expression
variant for enum operand. Besides, several assertions are added to
prevent future unexpected situation.
http://llvm-reviews.chandlerc.com/D3020
Files:
lib/Sema/SemaType.cpp
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -3444,10 +3444,17 @@
}
TL.setAttrNameLoc(attrs->getLoc());
- if (TL.hasAttrExprOperand() && attrs->isArgExpr(0))
+ if (TL.hasAttrExprOperand()) {
+ assert(attrs->isArgExpr(0) && "mismatched attribute operand kind");
TL.setAttrExprOperand(attrs->getArgAsExpr(0));
- else if (TL.hasAttrEnumOperand() && attrs->isArgIdent(0))
- TL.setAttrEnumOperandLoc(attrs->getArgAsIdent(0)->Loc);
+ } else if (TL.hasAttrEnumOperand()) {
+ assert((attrs->isArgIdent(0) || attrs->isArgExpr(0)) &&
+ "unexpected attribute operand kind");
+ if (attrs->isArgIdent(0))
+ TL.setAttrEnumOperandLoc(attrs->getArgAsIdent(0)->Loc);
+ else
+ TL.setAttrEnumOperandLoc(attrs->getArgAsExpr(0)->getExprLoc());
+ }
// FIXME: preserve this information to here.
if (TL.hasAttrOperand())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3020.1.patch
Type: text/x-patch
Size: 965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140308/27ac4cd2/attachment.bin>
More information about the cfe-commits
mailing list