<div dir="ltr">The source which I am compiling looking at does include a macro, which I suspect might be part of the problem.<div><br></div><div>This is the file we are compiling.
PLATFORM_WINDOWS
is a #define.<br>#if PLATFORM_WINDOWS</div><div>//...</div><div>#endif</div><div>// Other code.</div><div><br></div><div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 7, 2019 at 9:25 AM fdart <<a href="mailto:jfdart17@gmail.com">jfdart17@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<br><div><br></div><div>In my libtooling project I have a class implementing the PPCallbacks interface to get that information. When the "If" function is triggered, I am passed a condition range. I expect that would be whatever followed "#if " on that line.</div><div><br></div><div>To extract the raw source text information as a string, I followed the advice of the below thread and have the below implementation. The string "source" I retrieve contains the entire source of the file, after the "#if " statement. Why is that? How can I get only the information for the text on the line following the "#if "? I'm using Clang 8.0.0.</div><div><br></div><div><a href="http://clang-developers.42468.n3.nabble.com/source-code-string-from-SourceRange-td4032732.html" target="_blank">http://clang-developers.42468.n3.nabble.com/source-code-string-from-SourceRange-td4032732.html</a> </div><div><br></div><div> void PreprocessorInfoListener::If(SourceLocation sourceLoc, SourceRange conditionRange, PPCallbacks::ConditionValueKind conditionValue)<br></div>{<div> LangOptions langOptions;</div> llvm::StringRef source = Lexer::getSourceText(CharSourceRange::getTokenRange(conditionRange), m_sourceManager, langOptions);<div>}<br><div><br></div><div>Thanks,</div><div>Justin</div></div></div>
</blockquote></div>