Browse Source

Improved the reading of line numbers by expanding locations.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/604/head
Dimitar Dobrev 10 years ago
parent
commit
05d7088cd0
  1. 8
      src/CppParser/Parser.cpp

8
src/CppParser/Parser.cpp

@ -2407,10 +2407,8 @@ void Parser::GetLineNumbersFromLocation(const clang::SourceLocation& StartLoc,
const clang::SourceLocation& EndLoc, int* LineNumberStart, int* LineNumberEnd) const clang::SourceLocation& EndLoc, int* LineNumberStart, int* LineNumberEnd)
{ {
auto& SM = C->getSourceManager(); auto& SM = C->getSourceManager();
auto DecomposedLocStart = SM.getDecomposedLoc(StartLoc); *LineNumberStart = StartLoc.isInvalid() ? -1 : SM.getExpansionLineNumber(StartLoc);
*LineNumberStart = SM.getLineNumber(DecomposedLocStart.first, DecomposedLocStart.second); *LineNumberEnd = EndLoc.isInvalid() ? -1 : SM.getExpansionLineNumber(EndLoc);
auto DecomposedLocEnd = SM.getDecomposedLoc(EndLoc);
*LineNumberEnd = SM.getLineNumber(DecomposedLocEnd.first, DecomposedLocEnd.second);
} }
bool Parser::IsValidDeclaration(const clang::SourceLocation& Loc) bool Parser::IsValidDeclaration(const clang::SourceLocation& Loc)
@ -2771,7 +2769,7 @@ void Parser::HandleDeclaration(clang::Decl* D, Declaration* Decl)
Decl->OriginalPtr = (void*) D; Decl->OriginalPtr = (void*) D;
Decl->USR = GetDeclUSR(D); Decl->USR = GetDeclUSR(D);
Decl->Location = SourceLocation(D->getLocation().getRawEncoding()); Decl->Location = SourceLocation(D->getLocation().getRawEncoding());
GetLineNumbersFromLocation(D->getLocation(), D->getLocEnd(), GetLineNumbersFromLocation(D->getLocStart(), D->getLocEnd(),
&Decl->LineNumberStart, &Decl->LineNumberEnd); &Decl->LineNumberStart, &Decl->LineNumberEnd);
if (Decl->PreprocessedEntities.empty() && !D->isImplicit()) if (Decl->PreprocessedEntities.empty() && !D->isImplicit())

Loading…
Cancel
Save