bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.68k stars 744 forks source link

Expanded macro spelling locations point to macro expansion location #1536

Open icemachined opened 2 months ago

icemachined commented 2 months ago

The problem is that clang_getSpellingLocation function return the same value for all nodes expanded from macro. I'd expect that it should be inside macro declaration.

For example, see attached clang-macrolocations.zip example project, file main.cpp call macro in main function which declarations contained in inner_head.h file. When i use command clang++ -Xclang -ast-dump main.cpp it provide me astdump.txt in which i see that it referenced to ./inner_head.h

    `-DoStmt 0x25d6b0f2b18 <./inner_head.h:19:38, col:78>
      |-CompoundStmt 0x25d6b0f2ac8 <col:41, col:68>
      | `-IfStmt 0x25d6b0f2aa8 <col:42, col:67>

using clang_getSpellingLocation on the same nodes in ClangASTVisitorExample it referenced to macro expansion location.

How can i get the same location as in ast dump using javacpp=persets for clang?

clang version i used is 14.0.4

saudet commented 2 months ago

Do you have a working example in C/C++?

icemachined commented 2 months ago

Do you have a working example in C/C++?

no, i don't. only java code using clang javacpp persets see clang-macrolocations.zip