<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
I was able to solve my problem by making sure to get the expansion location before calling getPreviousToken.  <br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Feb 17, 2020, at 5:42 PM, Lewis, Cannada <<a href="mailto:canlewi@sandia.gov" class="">canlewi@sandia.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
I am trying to use the getPreviousToken function from <span id="blob-path" class="css-truncate-target"><span class="js-path-segment"><a data-pjax="true" href="https://github.com/llvm/llvm-project/tree/master/clang-tools-extra" class="">clang-tools-extra</a></span><span class="separator">/</span><span class="js-path-segment"><a data-pjax="true" href="https://github.com/llvm/llvm-project/tree/master/clang-tools-extra/clang-tidy" class="">clang-tidy</a></span><span class="separator">/</span><span class="js-path-segment"><a data-pjax="true" href="https://github.com/llvm/llvm-project/tree/master/clang-tools-extra/clang-tidy/utils" class="">utils</a></span><span class="separator">/</span><strong class="final-path">LexerUtils.cpp,
</strong><span class="final-path">but am having issues when the SourceLocation comes from a macro.  Let’s say I have the following functions:</span></span>
<div class=""><span class="css-truncate-target"><span class="final-path"><br class="">
</span></span></div>
<div class=""><span class="css-truncate-target"><span class="final-path">
<div class="">#include <Kokkos_Core.hpp></div>
<div class="">#include <string></div>
<div class=""><br class="">
</div>
<div class="">// The macros are  defined such that KOKKOS_FUNCTION is empty and KOKKOS_INLINE_FUNCITON = “inline” </div>
<div class=""><br class="">
</div>
<div class="">KOKKOS_FUNCTION</div>
<div class="">void useString(std::string const& s, int i){ }</div>
<div class=""><br class="">
</div>
<div class="">KOKKOS_INLINE_FUNCTION</div>
<div class="">void useString2(std::string const& s, int i){ }</div>
<div class=""><br class="">
</div>
<div class="">If I take the FunctionDecl for useString and use getBeginLoc, I will get a location that corresponds to the token void right before useString, I then use getPreviousToken to find the KOKKOS_FUNCTION macro and all is well.  </div>
<div class=""><br class="">
</div>
<div class="">But if I call getBeginLoc on useString2 my location starts off in the macro (I’m not really sure exactly what that means, my guess is that it starts on the inline keyword) and if I use that location for getPreviousToken, I don’t get the ‘}' from
 the line with useString, instead I get some location from other headers included in Kokkos_Core.hpp.  I don’t think that this is the intended behavior, but I don’t have a minimal working example at the moment. I did track it down to  where getPreviousToken
 calls getWithOffset(-1) on the source location and it is that new location which is the unexpected location. </div>
<div class=""><br class="">
</div>
<div class="">Any help would be appreciated. </div>
<div class=""><br class="">
</div>
<div class="">-Cannada Lewis</div>
</span></span></div>
</div>
</div>
</blockquote>
</div>
<br class="">
</body>
</html>