diff options
author | Erich Keane <erich.keane@intel.com> | 2018-07-03 20:30:34 +0000 |
---|---|---|
committer | Erich Keane <erich.keane@intel.com> | 2018-07-03 20:30:34 +0000 |
commit | 0aab72368709c1da440c0367a572b8a53ae1c51b (patch) | |
tree | e7736b5697019fff40337bee9b50970fc5aeaec2 /clang/lib/Parse/ParseObjc.cpp | |
parent | 93357f52c6a8394554c98919d88328d089fb60a1 (diff) | |
download | bcm5719-llvm-0aab72368709c1da440c0367a572b8a53ae1c51b.tar.gz bcm5719-llvm-0aab72368709c1da440c0367a572b8a53ae1c51b.zip |
Fix allocation of Nullability attribute.
Existing code always allocates for on the declarator's attribute pool,
but sometimes adds it to the declspec. This patch ensures that the
correct pool is used.
Discovered while testing: https://reviews.llvm.org/D48788
llvm-svn: 336225
Diffstat (limited to 'clang/lib/Parse/ParseObjc.cpp')
-rw-r--r-- | clang/lib/Parse/ParseObjc.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp index ff33d5fb96b..81b930a2284 100644 --- a/clang/lib/Parse/ParseObjc.cpp +++ b/clang/lib/Parse/ParseObjc.cpp @@ -381,25 +381,23 @@ static void addContextSensitiveTypeNullability(Parser &P, SourceLocation nullabilityLoc, bool &addedToDeclSpec) { // Create the attribute. - auto getNullabilityAttr = [&]() -> AttributeList * { - return D.getAttributePool().create( - P.getNullabilityKeyword(nullability), - SourceRange(nullabilityLoc), - nullptr, SourceLocation(), - nullptr, 0, - AttributeList::AS_ContextSensitiveKeyword); + auto getNullabilityAttr = [&](AttributePool &Pool) -> AttributeList * { + return Pool.create(P.getNullabilityKeyword(nullability), + SourceRange(nullabilityLoc), nullptr, SourceLocation(), + nullptr, 0, AttributeList::AS_ContextSensitiveKeyword); }; if (D.getNumTypeObjects() > 0) { // Add the attribute to the declarator chunk nearest the declarator. - auto nullabilityAttr = getNullabilityAttr(); + auto nullabilityAttr = getNullabilityAttr(D.getAttributePool()); DeclaratorChunk &chunk = D.getTypeObject(0); nullabilityAttr->setNext(chunk.getAttrListRef()); chunk.getAttrListRef() = nullabilityAttr; } else if (!addedToDeclSpec) { // Otherwise, just put it on the declaration specifiers (if one // isn't there already). - D.getMutableDeclSpec().addAttributes(getNullabilityAttr()); + D.getMutableDeclSpec().addAttributes( + getNullabilityAttr(D.getDeclSpec().getAttributePool())); addedToDeclSpec = true; } } |