<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Attribute plugin example in trunk does not seem to recognize attribute arguments"
   href="https://bugs.llvm.org/show_bug.cgi?id=46446">46446</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Attribute plugin example in trunk does not seem to recognize attribute arguments
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jonathan.protzenko@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm re-posting this from the discord #clang channel, since I haven't any
answers there.

I'm playing with the Attribute plugin in clang/examples, and I modified one
thing: replace OptArgs = 1 (one optional argument) in the constructor with
`NumArgs = 1` (exactly one argument required)... I ran `bin/clang++
-fplugin=lib/Attribute.dylib -std=c++17 /tmp/test.hpp` with the following
contents for test.hpp:

```
[[ example("foo") ]]
void f() {
}
```

and I get:

```
jonathan@absinthe:~/Code/llvm-project/build (master) $ bin/clang++
-fplugin=lib/Attribute.dylib -std=c++17 /tmp/test.hpp 
/tmp/test.hpp:1:4: error: 'example' attribute takes one argument
[[ example("foo") ]]
   ^
1 error generated.
```

which confuses me quite a bit since the attribute *does* seem to have an
argument!

---

First possible cause: the comment in Attr.h is wrong and NumArgs has a
different behavior.

```
  /// The number of required arguments of this attribute.
  unsigned NumArgs : 4;
```

Second possible cause: the syntax I'm using for passing an argument to an
attribute is incorrect, but I thought according to
<a href="https://en.cppreference.com/w/cpp/language/attributes">https://en.cppreference.com/w/cpp/language/attributes</a> that I was correct.

Third possible cause: a genuine issue in ParsedAttr.

---

The reason I'm filing a bug is that I tried something different, leaving the
code in Attribute.cpp as-is, and adding `assert(false)` right after the test ` 
   if (Attr.getNumArgs() > 0) {`, in the hope of at least asserting that this
codepath is reached (same test.hpp). But, alas, nothing happened, which leads
me to think that at the very least something is wrong with the example plugin.

Thanks,

Jonathan</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>