Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanded macro spelling locations point to macro expansion location #1536

Open
icemachined opened this issue Aug 28, 2024 · 2 comments
Open

Comments

@icemachined
Copy link

icemachined commented Aug 28, 2024

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
Copy link
Member

saudet commented Aug 28, 2024

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

@icemachined
Copy link
Author

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants