<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div class="BodyFragment"><font size="2"><span style="font-size:10pt;">
<div class="PlainText">You are right, my bad, I thought this if covers all the cases, but <foo> part could be empty.<br>
<br>
Here is the fix:<br>
<br>
</div>
</span></font></div>
<div class="BodyFragment"><font size="2"><span style="font-size:10pt;">
<div class="PlainText"><br>
<br>
Adrian<br>
> On Oct 8, 2015, at 1:52 PM, Aaron Ballman <aaron@aaronballman.com> wrote:<br>
> <br>
> On Thu, Oct 8, 2015 at 4:49 PM, Richard Smith <richard@metafoo.co.uk> wrote:<br>
>> On Thu, Oct 8, 2015 at 1:21 PM, Aaron Ballman <aaron@aaronballman.com><br>
>> wrote:<br>
>>> <br>
>>> On Thu, Oct 8, 2015 at 4:16 PM, Richard Smith <richard@metafoo.co.uk><br>
>>> wrote:<br>
>>>> On Thu, Oct 8, 2015 at 12:24 PM, Aaron Ballman via cfe-commits<br>
>>>> <cfe-commits@lists.llvm.org> wrote:<br>
>>>>> <br>
>>>>> Author: aaronballman<br>
>>>>> Date: Thu Oct 8 14:24:08 2015<br>
>>>>> New Revision: 249721<br>
>>>>> <br>
>>>>> URL: <a href="https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd">
https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project?rev%3D249721%26view%3Drev&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=8862f3210cdb7661e90a0d8588334d3e1cf64e92851d05bbcd2b159daf05c7dd</a><br>
>>>>> Log:<br>
>>>>> When mapping no_sanitize_* attributes to no_sanitize attributes, handle<br>
>>>>> GNU-style formatting that involves prefix and suffix underscores.<br>
>>>>> Cleans up<br>
>>>>> other usages of similar functionality.<br>
>>>>> <br>
>>>>> Patch by Adrian Zgorzalek!<br>
>>>>> <br>
>>>>> Modified:<br>
>>>>> cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
>>>>> cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp<br>
>>>>> cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp<br>
>>>>> cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp<br>
>>>>> <br>
>>>>> Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
>>>>> URL:<br>
>>>>> <br>
>>>>> <a href="https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f">
https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=7dae8eb5cffae4493f0a6c26033810564fd7b688297fc93106a3b980f76cdd9f</a><br>
>>>>> <br>
>>>>> <br>
>>>>> ==============================================================================<br>
>>>>> --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)<br>
>>>>> +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Oct 8 14:24:08 2015<br>
>>>>> @@ -1308,6 +1308,17 @@ void Sema::AddAssumeAlignedAttr(SourceRa<br>
>>>>> AssumeAlignedAttr(AttrRange, Context, E, OE,<br>
>>>>> SpellingListIndex));<br>
>>>>> }<br>
>>>>> <br>
>>>>> +/// Normalize the attribute, __foo__ becomes foo.<br>
>>>>> +/// Returns true if normalization was applied.<br>
>>>>> +static bool normalizeName(StringRef &AttrName) {<br>
>>>>> + if (AttrName.startswith("__") && AttrName.endswith("__")) {<br>
>>>>> + assert(AttrName.size() > 4 && "Name too short");<br>
>>>> <br>
>>>> <br>
>>>> This assert will fire on the strings __, ___, and ____, which are valid<br>
>>>> in<br>
>>>> some of the below cases.<br>
>>> <br>
>>> That assert won't fire on anything but ____ because it's &&, not ||.<br>
>> <br>
>> <br>
>> I disagree. __ starts with __ and ends with __. The right thing to do here<br>
>> is remove the assert and put back the AttrName.size() > 4 check that the<br>
>> callers used to have.<br>
> <br>
> Hah, you are correct. I hadn't considered that point. I agree with you. :-)<br>
> <br>
> ~Aaron<br>
> <br>
>> <br>
>>> I<br>
>>> don't think these names were intended to be valid in their uses.<br>
>>> However, you are correct that this will trigger assertions instead of<br>
>>> diagnostics. Adrian, can you investigate?<br>
>>> <br>
>>>> <br>
>>>>> <br>
>>>>> + AttrName = AttrName.drop_front(2).drop_back(2);<br>
>>>>> + return true;<br>
>>>>> + }<br>
>>>>> + return false;<br>
>>>>> +}<br>
>>>>> +<br>
>>>>> static void handleOwnershipAttr(Sema &S, Decl *D, const AttributeList<br>
>>>>> &AL) {<br>
>>>>> // This attribute must be applied to a function declaration. The<br>
>>>>> first<br>
>>>>> // argument to the attribute must be an identifier, the name of the<br>
>>>>> resource,<br>
>>>>> @@ -1349,11 +1360,8 @@ static void handleOwnershipAttr(Sema &S,<br>
>>>>> <br>
>>>>> IdentifierInfo *Module = AL.getArgAsIdent(0)->Ident;<br>
>>>>> <br>
>>>>> - // Normalize the argument, __foo__ becomes foo.<br>
>>>>> StringRef ModuleName = Module->getName();<br>
>>>>> - if (ModuleName.startswith("__") && ModuleName.endswith("__") &&<br>
>>>>> - ModuleName.size() > 4) {<br>
>>>>> - ModuleName = ModuleName.drop_front(2).drop_back(2);<br>
>>>>> + if (normalizeName(ModuleName)) {<br>
>>>>> Module = &S.PP.getIdentifierTable().get(ModuleName);<br>
>>>>> }<br>
>>>>> <br>
>>>>> @@ -2648,9 +2656,7 @@ static void handleFormatAttr(Sema &S, De<br>
>>>>> IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;<br>
>>>>> StringRef Format = II->getName();<br>
>>>>> <br>
>>>>> - // Normalize the argument, __foo__ becomes foo.<br>
>>>>> - if (Format.startswith("__") && Format.endswith("__")) {<br>
>>>>> - Format = Format.substr(2, Format.size() - 4);<br>
>>>>> + if (normalizeName(Format)) {<br>
>>>>> // If we've modified the string name, we need a new identifier for<br>
>>>>> it.<br>
>>>>> II = &S.Context.Idents.get(Format);<br>
>>>>> }<br>
>>>>> @@ -3131,9 +3137,7 @@ static void handleModeAttr(Sema &S, Decl<br>
>>>>> IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;<br>
>>>>> StringRef Str = Name->getName();<br>
>>>>> <br>
>>>>> - // Normalize the attribute name, __foo__ becomes foo.<br>
>>>>> - if (Str.startswith("__") && Str.endswith("__"))<br>
>>>>> - Str = Str.substr(2, Str.size() - 4);<br>
>>>>> + normalizeName(Str);<br>
>>>>> <br>
>>>>> unsigned DestWidth = 0;<br>
>>>>> bool IntegerMode = true;<br>
>>>>> @@ -4533,8 +4537,10 @@ static void handleNoSanitizeAttr(Sema &S<br>
>>>>> <br>
>>>>> static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,<br>
>>>>> const AttributeList &Attr) {<br>
>>>>> + StringRef AttrName = Attr.getName()->getName();<br>
>>>>> + normalizeName(AttrName);<br>
>>>>> std::string SanitizerName =<br>
>>>>> - llvm::StringSwitch<std::string>(Attr.getName()->getName())<br>
>>>>> + llvm::StringSwitch<std::string>(AttrName)<br>
>>>>> .Case("no_address_safety_analysis", "address")<br>
>>>>> .Case("no_sanitize_address", "address")<br>
>>>>> .Case("no_sanitize_thread", "thread")<br>
>>>> <br>
>>>> <br>
>>>> Is there any way we could use the spelling list index in this case<br>
>>>> rather<br>
>>>> than repeating the attribute names and __-stripping here?<br>
>>> <br>
>>> The spelling list index isn't exposed in a meaningful way (and I think<br>
>>> that would be an abuse of it; I want to someday remove that<br>
>>> implementation detail to something far more private).<br>
>>> <br>
>>> I was hoping there would be a way to use the semantic spelling, but<br>
>>> the issue is that this particular attribute doesn't have semantic<br>
>>> spellings. The NoSanitizeSpecificAttr would have one, but it has no<br>
>>> AST node to hang those off of. Since we explicitly document that we do<br>
>>> not want any additional names added to this list (see Attr.td line<br>
>>> 1500), I think this is a reasonable solution as-is.<br>
>>> <br>
>>> ~Aaron<br>
>>> <br>
>>>> <br>
>>>>> Modified: cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp<br>
>>>>> URL:<br>
>>>>> <br>
>>>>> <a href="https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=46b5171e8784900ffa959a20f8824d63377f6d80d0c92c69d5a271edb5d83930">
https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=46b5171e8784900ffa959a20f8824d63377f6d80d0c92c69d5a271edb5d83930</a><br>
>>>>> <br>
>>>>> <br>
>>>>> ==============================================================================<br>
>>>>> --- cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp (original)<br>
>>>>> +++ cfe/trunk/test/SemaCXX/attr-no-sanitize-address.cpp Thu Oct 8<br>
>>>>> 14:24:08 2015<br>
>>>>> @@ -5,12 +5,14 @@<br>
>>>>> #if !__has_attribute(no_sanitize_address)<br>
>>>>> #error "Should support no_sanitize_address"<br>
>>>>> #endif<br>
>>>>> -<br>
>>>>> -void noanal_fun() NO_SANITIZE_ADDRESS;<br>
>>>>> -<br>
>>>>> -void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \<br>
>>>>> - // expected-error {{'no_sanitize_address' attribute takes no<br>
>>>>> arguments}}<br>
>>>>> -<br>
>>>>> +<br>
>>>>> +void noanal_fun() NO_SANITIZE_ADDRESS;<br>
>>>>> +<br>
>>>>> +void noanal_fun_alt() __attribute__((__no_sanitize_address__));<br>
>>>>> +<br>
>>>>> +void noanal_fun_args() __attribute__((no_sanitize_address(1))); // \<br>
>>>>> + // expected-error {{'no_sanitize_address' attribute takes no<br>
>>>>> arguments}}<br>
>>>>> +<br>
>>>>> int noanal_testfn(int y) NO_SANITIZE_ADDRESS;<br>
>>>>> <br>
>>>>> int noanal_testfn(int y) {<br>
>>>>> <br>
>>>>> Modified: cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp<br>
>>>>> URL:<br>
>>>>> <br>
>>>>> <a href="https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=676ca5d3b6bef5b3c04a9d6861c547a35afb54f85454fc23551da843ce369b1c">
https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=676ca5d3b6bef5b3c04a9d6861c547a35afb54f85454fc23551da843ce369b1c</a><br>
>>>>> <br>
>>>>> <br>
>>>>> ==============================================================================<br>
>>>>> --- cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp (original)<br>
>>>>> +++ cfe/trunk/test/SemaCXX/attr-no-sanitize-memory.cpp Thu Oct 8<br>
>>>>> 14:24:08<br>
>>>>> 2015<br>
>>>>> @@ -5,12 +5,14 @@<br>
>>>>> #if !__has_attribute(no_sanitize_memory)<br>
>>>>> #error "Should support no_sanitize_memory"<br>
>>>>> #endif<br>
>>>>> -<br>
>>>>> -void noanal_fun() NO_SANITIZE_MEMORY;<br>
>>>>> -<br>
>>>>> -void noanal_fun_args() __attribute__((no_sanitize_memory(1))); // \<br>
>>>>> - // expected-error {{'no_sanitize_memory' attribute takes no<br>
>>>>> arguments}}<br>
>>>>> -<br>
>>>>> +<br>
>>>>> +void noanal_fun() NO_SANITIZE_MEMORY;<br>
>>>>> +<br>
>>>>> +void noanal_fun_alt() __attribute__((__no_sanitize_memory__));<br>
>>>>> +<br>
>>>>> +void noanal_fun_args() __attribute__((no_sanitize_memory(1))); // \<br>
>>>>> + // expected-error {{'no_sanitize_memory' attribute takes no<br>
>>>>> arguments}}<br>
>>>>> +<br>
>>>>> int noanal_testfn(int y) NO_SANITIZE_MEMORY;<br>
>>>>> <br>
>>>>> int noanal_testfn(int y) {<br>
>>>>> <br>
>>>>> Modified: cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp<br>
>>>>> URL:<br>
>>>>> <br>
>>>>> <a href="https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=30f400a0be1c699374d1f30504fa1f190158506f984bbeac66fe6998be9fd7b7">
https://urldefense.proofpoint.com/v1/url?u=http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp?rev%3D249721%26r1%3D249720%26r2%3D249721%26view%3Ddiff&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=30f400a0be1c699374d1f30504fa1f190158506f984bbeac66fe6998be9fd7b7</a><br>
>>>>> <br>
>>>>> <br>
>>>>> ==============================================================================<br>
>>>>> --- cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp (original)<br>
>>>>> +++ cfe/trunk/test/SemaCXX/attr-no-sanitize-thread.cpp Thu Oct 8<br>
>>>>> 14:24:08<br>
>>>>> 2015<br>
>>>>> @@ -5,12 +5,14 @@<br>
>>>>> #if !__has_attribute(no_sanitize_thread)<br>
>>>>> #error "Should support no_sanitize_thread"<br>
>>>>> #endif<br>
>>>>> -<br>
>>>>> -void noanal_fun() NO_SANITIZE_THREAD;<br>
>>>>> -<br>
>>>>> -void noanal_fun_args() __attribute__((no_sanitize_thread(1))); // \<br>
>>>>> - // expected-error {{'no_sanitize_thread' attribute takes no<br>
>>>>> arguments}}<br>
>>>>> -<br>
>>>>> +<br>
>>>>> +void noanal_fun() NO_SANITIZE_THREAD;<br>
>>>>> +<br>
>>>>> +void noanal_fun_alt() __attribute__((__no_sanitize_thread__));<br>
>>>>> +<br>
>>>>> +void noanal_fun_args() __attribute__((no_sanitize_thread(1))); // \<br>
>>>>> + // expected-error {{'no_sanitize_thread' attribute takes no<br>
>>>>> arguments}}<br>
>>>>> +<br>
>>>>> int noanal_testfn(int y) NO_SANITIZE_THREAD;<br>
>>>>> <br>
>>>>> int noanal_testfn(int y) {<br>
>>>>> <br>
>>>>> <br>
>>>>> _______________________________________________<br>
>>>>> cfe-commits mailing list<br>
>>>>> cfe-commits@lists.llvm.org<br>
>>>>> <a href="https://urldefense.proofpoint.com/v1/url?u=http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=76daddf3012e1755f9df59be7e195c26e1d2179d81b412635ff70771ec3f1ed5">
https://urldefense.proofpoint.com/v1/url?u=http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits&k=ZVNjlDMF0FElm4dQtryO4A%3D%3D%0A&r=ZpIyPFH5RmN0EBF%2B6Om2Hg%3D%3D%0A&m=kMsJztGqfQof%2FUicfGEXM78GJV6jd7CTOxlypvgU10A%3D%0A&s=76daddf3012e1755f9df59be7e195c26e1d2179d81b412635ff70771ec3f1ed5</a><br>
>>>> <br>
>>>> <br>
>> <br>
>> <br>
<br>
</div>
</span></font></div>
</body>
</html>