r249833 - Amending r249721 to properly handle pathological attribute-related names like __ and ____.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 06:53:24 PDT 2015


Author: aaronballman
Date: Fri Oct  9 08:53:24 2015
New Revision: 249833

URL: http://llvm.org/viewvc/llvm-project?rev=249833&view=rev
Log:
Amending r249721 to properly handle pathological attribute-related names like __ and ____.

Patch by Adrian Zgorzalek!

Modified:
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/Sema/attr-ownership.c

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=249833&r1=249832&r2=249833&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Oct  9 08:53:24 2015
@@ -1311,8 +1311,8 @@ void Sema::AddAssumeAlignedAttr(SourceRa
 /// Normalize the attribute, __foo__ becomes foo.
 /// Returns true if normalization was applied.
 static bool normalizeName(StringRef &AttrName) {
-  if (AttrName.startswith("__") && AttrName.endswith("__")) {
-    assert(AttrName.size() > 4 && "Name too short");
+  if (AttrName.size() > 4 && AttrName.startswith("__") &&
+      AttrName.endswith("__")) {
     AttrName = AttrName.drop_front(2).drop_back(2);
     return true;
   }

Modified: cfe/trunk/test/Sema/attr-ownership.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-ownership.c?rev=249833&r1=249832&r2=249833&view=diff
==============================================================================
--- cfe/trunk/test/Sema/attr-ownership.c (original)
+++ cfe/trunk/test/Sema/attr-ownership.c Fri Oct  9 08:53:24 2015
@@ -19,6 +19,7 @@ void f13(int *i, int *j) __attribute__((
 void f14(int i, int j, int *k) __attribute__((ownership_holds(foo, 3))) __attribute__((ownership_takes(foo, 3)));  // expected-error {{'ownership_holds' and 'ownership_takes' attributes are not compatible}}
 
 void f15(int, int)
-  __attribute__((ownership_returns(foo, 1)))  // expected-note {{declared with index 1 here}}
-  __attribute__((ownership_returns(foo, 2))); // expected-error {{'ownership_returns' attribute index does not match; here it is 2}}
-void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index
+  __attribute__((ownership_returns(foo, 1)))  // expected-note {{declared with index 1 here}}
+  __attribute__((ownership_returns(foo, 2))); // expected-error {{'ownership_returns' attribute index does not match; here it is 2}}
+void f16(int *i, int *j) __attribute__((ownership_holds(foo, 1))) __attribute__((ownership_holds(foo, 1))); // OK, same index
+void f17(void*) __attribute__((ownership_takes(__, 1)));




More information about the cfe-commits mailing list