nvetrini wrote: > > Hi, are there other suggestions? After reflecting a bit on the approach > > proposed by @ojhunt I think that it won't fit my usecase all that well, > > since I'd like to have accurate locations from clang in all cases. I can > > understand memory concerns, though they do not seem too excessive to me. I > > can run some benchmarks, though I'm not quite sure how. > > I guess this is restricted to just parenlist but it still doesn't seem > necessary - can you explain your reasoning as to why finding the location at > diagnostic time is not feasible/sufficent? > > There should fundamentally not be any difference in the final source location > that you end up with
Because there are cases where you lose track of exact location, as you correctly pointed out [here](https://github.com/llvm/llvm-project/pull/199411#issuecomment-4543531463). Specifically in [findNextToken()](https://clang.llvm.org/doxygen/Lexer_8cpp_source.html#l01375) it will give up if the location is not at the end of a macro expansion, so there is indeed a difference between tracking exact location and trying to reconstruct it afterwards. The use of the `-Wcomma` diagnostic in the test was just an easy way to show the problem, but potentially more intricate testcases can be derived that would work with one approach and fail to reconstruct the exact location with the other proposed method. For my usecase (static analyzer that uses the clang API as the parsing backend) source fidelity does matter a lot, but if it is deemed excessive for clang I can keep this downsteam. https://github.com/llvm/llvm-project/pull/199411 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
