Page MenuHomePhabricator

Fix assertion on C++ attributes in fillAttributedTypeLoc (this fixes http://llvm.org/PR17424)
ClosedPublic

Authored by alexfrol on Apr 27 2015, 3:22 AM.

Details

Summary

fillAttributedTypeLoc() function is only called with AttributeLists of either DeclarationChunk (which is used for each type in a declarator being parsed) or DeclSpec (which captures information about declaration specifiers).
As C++11 attributes actually appertain to declarators, they are moved straight to the declarator’s attr list in distributeFunctionTypeAttrFromDeclSpec() function.
'Put them wherever you like' semantics is not supported for C++11 attributes (but is allowed for GNU attributes, for example).
So when we meet an attribute while parsing the declaration, we cannot be sure if it appertains to either DeclarationChunk or DeclSpec.

This investigation correlates with the history of changes of SemaType.cpp:
• Asserts in fillAttributedTypeLoc() were added on 3 Mar 2011 in r126986 (http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20110228/039638.html);
• Distributing C++11 attrs to the declarator was added on 14 Jan 2013 in r172504 (http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130114/071830.html).

Considering all written above I changed asserts in fillAttributedTypeLoc() to nullptr checks.

This fixes PR17424 and related assertion on

[[gnu::fastcall]] void __stdcall foo();

Diff Detail

Repository
rL LLVM

Event Timeline

alexfrol updated this revision to Diff 24376.Apr 27 2015, 3:22 AM
alexfrol retitled this revision from to Fix assertion on C++ attributes in fillAttributedTypeLoc (this fixes http://llvm.org/PR17424).
alexfrol updated this object.
alexfrol edited the test plan for this revision. (Show Details)
alexfrol added reviewers: rsmith, aaron.ballman.
alexfrol set the repository for this revision to rL LLVM.
alexfrol added a subscriber: Unknown Object (MLST).

This is a kind reminder just in case this got forgotten.

alexfrol updated this revision to Diff 26290.EditedMay 21 2015, 5:14 PM

Thank you for the review!
I changed fillAttributedTypeLoc() to search through C++11 attributes in the declarator attribute list if a desired attribute not found in DeclaratorChunk.
I also added a new testcase.

rsmith accepted this revision.May 28 2015, 3:58 PM
rsmith edited edge metadata.

LGTM, thanks!

This revision is now accepted and ready to land.May 28 2015, 3:58 PM
This revision was automatically updated to reflect the committed changes.