https://bugs.llvm.org/show_bug.cgi?id=46446
Bug ID: 46446
Summary: Attribute plugin example in trunk does not seem to
recognize attribute arguments
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: jonathan.protze...@gmail.com
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
neeil...@live.com, richard-l...@metafoo.co.uk
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
https://en.cppreference.com/w/cpp/language/attributes 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
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs