diff options
| author | Logan Chien <tzuhsiang.chien@gmail.com> | 2014-03-09 16:21:03 +0000 |
|---|---|---|
| committer | Logan Chien <tzuhsiang.chien@gmail.com> | 2014-03-09 16:21:03 +0000 |
| commit | 8153b368b601b72f9e3ebd356ed56213c7ada433 (patch) | |
| tree | 5337c1fade7dacec08862fdafbcba34e7de4e4c4 | |
| parent | 24555e15efde6fdf3d7ad729c3d196564ff5bda2 (diff) | |
| download | bcm5719-llvm-8153b368b601b72f9e3ebd356ed56213c7ada433.tar.gz bcm5719-llvm-8153b368b601b72f9e3ebd356ed56213c7ada433.zip | |
Fix uninitialized value in AttributedTypeLoc.
Clang might crash while reading the precompiled headers if
we don't initialize the AttrEnumOperandLoc properly.
This commit fixes the combination of string attribute
operand and enum operand. Besides, this commit also adds
several assertions to avoid unexpected operand kind.
llvm-svn: 203416
| -rw-r--r-- | clang/lib/Sema/SemaType.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 7ba824b909b..1f6543875bb 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -3444,10 +3444,17 @@ static void fillAttributedTypeLoc(AttributedTypeLoc TL, } 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()) |

