diff options
author | Nico Weber <nicolasweber@gmx.de> | 2016-09-13 18:55:26 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2016-09-13 18:55:26 +0000 |
commit | 88f5ed9430a99667261c24c6082aa4c0ccc4df83 (patch) | |
tree | 91df1209dd801e326f3b1758f61e459ab262a8e6 /clang/lib/Parse/ParseDecl.cpp | |
parent | 39ccd24126fcb99e95f15e49278a88adece2319a (diff) | |
download | bcm5719-llvm-88f5ed9430a99667261c24c6082aa4c0ccc4df83.tar.gz bcm5719-llvm-88f5ed9430a99667261c24c6082aa4c0ccc4df83.zip |
[clang-cl] Diagnose duplicate uuids.
This mostly behaves cl.exe's behavior, even though clang-cl is stricter in some
corner cases and more lenient in others (see the included test).
To make the uuid declared previously here diagnostic work correctly, tweak
stripTypeAttributesOffDeclSpec() to keep attributes in the right order.
https://reviews.llvm.org/D24469
llvm-svn: 281367
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 86f7abafeb5..71cbc451e1c 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -1439,6 +1439,8 @@ void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs, ParsedAttributes &PA = DS.getAttributes(); AttributeList *AL = PA.getList(); AttributeList *Prev = nullptr; + AttributeList *TypeAttrHead = nullptr; + AttributeList *TypeAttrTail = nullptr; while (AL) { AttributeList *Next = AL->getNext(); @@ -1446,8 +1448,12 @@ void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs, AL->isDeclspecAttribute()) || AL->isMicrosoftAttribute()) { // Stitch the attribute into the tag's attribute list. - AL->setNext(nullptr); - Attrs.add(AL); + if (TypeAttrTail) + TypeAttrTail->setNext(AL); + else + TypeAttrHead = AL; + TypeAttrTail = AL; + TypeAttrTail->setNext(nullptr); // Remove the attribute from the variable's attribute list. if (Prev) { @@ -1465,6 +1471,12 @@ void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs, AL = Next; } + + // Find end of type attributes Attrs and add NewTypeAttributes in the same + // order they were in originally. (Remember, in AttributeList things earlier + // in source order are later in the list, since new attributes are added to + // the front of the list.) + Attrs.addAllAtEnd(TypeAttrHead); } /// ParseDeclaration - Parse a full 'declaration', which consists of |