From b9c0f9ed3ea314bf763c15e189ffb2fb4a7b6d21 Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Tue, 14 Jun 2016 00:01:36 +0200 Subject: [PATCH] data: Fixed macro expand location was wrong when used within expansion of different file --- .../data/parser/cxx/PreprocessorCallbacks.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib_parser/data/parser/cxx/PreprocessorCallbacks.cpp b/src/lib_parser/data/parser/cxx/PreprocessorCallbacks.cpp index 0c0ae41d..b5fdaf1d 100644 --- a/src/lib_parser/data/parser/cxx/PreprocessorCallbacks.cpp +++ b/src/lib_parser/data/parser/cxx/PreprocessorCallbacks.cpp @@ -142,13 +142,15 @@ void PreprocessorCallbacks::onMacroUsage(const clang::Token& macroNameToken) ParseLocation PreprocessorCallbacks::getParseLocation(const clang::Token& macroNameTok) const { - clang::SourceLocation location = macroNameTok.getLocation(); + const clang::SourceLocation& location = m_sourceManager.getSpellingLoc(macroNameTok.getLocation()); + const clang::SourceLocation& endLocation = m_sourceManager.getSpellingLoc(macroNameTok.getEndLoc()); + return ParseLocation( - m_sourceManager.getFilename(m_sourceManager.getFileLoc(location)), + m_sourceManager.getFilename(location), m_sourceManager.getSpellingLineNumber(location), m_sourceManager.getSpellingColumnNumber(location), - m_sourceManager.getSpellingLineNumber(macroNameTok.getEndLoc()), - m_sourceManager.getSpellingColumnNumber(macroNameTok.getEndLoc()) - 1 + m_sourceManager.getSpellingLineNumber(endLocation), + m_sourceManager.getSpellingColumnNumber(endLocation) - 1 ); }