This enables easy consumption of arbitrary data added
to this annotation in addition to the annotation category,
which was already exposed.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thank you for the additions! This should have test coverage in clang/unitttests/libclang/LibclangTest.cpp and a release note.
clang/tools/libclang/CIndex.cpp | ||
---|---|---|
2752 | We could use a template type and enable_if (for some type safety), then it shares the implementation. |
- Deduplicated code by using templates (looks a bit ridiculous though)
- Release notes entry added
- Unit test added
I think precommit CI may have found a relevant failure:
******************** TEST 'Clang :: Index/IBOutletCollection.m' FAILED ******************** Script: -- : 'RUN: at line 8'; c:\ws\w5\llvm-project\premerge-checks\build\bin\c-index-test.exe -cursor-at=C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m:4:24 C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m | c:\ws\w5\llvm-project\premerge-checks\build\bin\filecheck.exe -check-prefix=CHECK-CURSOR C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m : 'RUN: at line 11'; c:\ws\w5\llvm-project\premerge-checks\build\bin\c-index-test.exe -test-annotate-tokens=C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m:4:1:5:1 C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m | c:\ws\w5\llvm-project\premerge-checks\build\bin\filecheck.exe -check-prefix=CHECK-TOK C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m -- Exit Code: 1 Command Output (stdout): -- $ ":" "RUN: at line 8" $ "c:\ws\w5\llvm-project\premerge-checks\build\bin\c-index-test.exe" "-cursor-at=C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m:4:24" "C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m" $ "c:\ws\w5\llvm-project\premerge-checks\build\bin\filecheck.exe" "-check-prefix=CHECK-CURSOR" "C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m" # command stderr: C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m:9:18: error: CHECK-CURSOR: expected string not found in input // CHECK-CURSOR: ObjCClassRef=Test:3:12 ^ <stdin>:1:1: note: scanning from here 4:3 attribute(iboutletcollection)= [IBOutletCollection=ObjCInterface] Extent=[4:3 - 4:27] ^ <stdin>:1:54: note: possible intended match here 4:3 attribute(iboutletcollection)= [IBOutletCollection=ObjCInterface] Extent=[4:3 - 4:27] ^ Input file: <stdin> Check file: C:\ws\w5\llvm-project\premerge-checks\clang\test\Index\IBOutletCollection.m -dump-input=help explains the following input dump. Input was: <<<<<< 1: 4:3 attribute(iboutletcollection)= [IBOutletCollection=ObjCInterface] Extent=[4:3 - 4:27] check:9'0 X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found check:9'1 ? possible intended match >>>>>> error: command failed with exit status: 1 -- ********************
clang/unittests/libclang/LibclangTest.cpp | ||
---|---|---|
1176 | Spurious comment? | |
1178 | We don't seem to be testing this? |
I fixed the failing IBOutletCollection.m test - there was code to do special handling for the respective attribute type, which my patch accidentally skipped previously. I reordered the generic attribute handling to come after the special cases in VisitChildren.
I cleaned up my unit test. After trying a bit to fix it for testing annotate_type as well, I found out that for some unknown reason it is not exposed like usual attributes (maybe because it's a type attribute?).
Therefore, I decided to drop it from the test altogether.
Nice!
I cleaned up my unit test. After trying a bit to fix it for testing annotate_type as well, I found out that for some unknown reason it is not exposed like usual attributes (maybe because it's a type attribute?).
Therefore, I decided to drop it from the test altogether.
I think we should drop the annotate_type functionality from the patch entirely rather than add it without any test coverage knowing it doesn't seem to work as expected.
Whoops, forgot to run clang-format on the last diff. Also took the opportunity to just get rid of the template mess now that we're only dealing with AnnotateAttr anyway.
LGTM! Do you need me to commit this on your behalf? If so, what name and email address would you like me to use for patch attribution?
(Whoops, somehow never got a mail for that reply)
Yes, please. You can attribute the commit to "fridtjof <fridtjof@das-labor.org>"
clang/tools/libclang/CIndex.cpp | ||
---|---|---|
3656 | There is a leak here https://lab.llvm.org/buildbot/#/builders/5/builds/35725 |
Not sure why the similar code above does not leak, so I will revert and leave to author to investigate
clang/tools/libclang/CIndex.cpp | ||
---|---|---|
3656 | Please ignore the location of this comment. |
We could use a template type and enable_if (for some type safety), then it shares the implementation.