Skip to content

Commit 05d7088

Browse files
committed
Improved the reading of line numbers by expanding locations.
Signed-off-by: Dimitar Dobrev <[email protected]>
1 parent b3a5b88 commit 05d7088

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/CppParser/Parser.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2407,10 +2407,8 @@ void Parser::GetLineNumbersFromLocation(const clang::SourceLocation& StartLoc,
24072407
const clang::SourceLocation& EndLoc, int* LineNumberStart, int* LineNumberEnd)
24082408
{
24092409
auto& SM = C->getSourceManager();
2410-
auto DecomposedLocStart = SM.getDecomposedLoc(StartLoc);
2411-
*LineNumberStart = SM.getLineNumber(DecomposedLocStart.first, DecomposedLocStart.second);
2412-
auto DecomposedLocEnd = SM.getDecomposedLoc(EndLoc);
2413-
*LineNumberEnd = SM.getLineNumber(DecomposedLocEnd.first, DecomposedLocEnd.second);
2410+
*LineNumberStart = StartLoc.isInvalid() ? -1 : SM.getExpansionLineNumber(StartLoc);
2411+
*LineNumberEnd = EndLoc.isInvalid() ? -1 : SM.getExpansionLineNumber(EndLoc);
24142412
}
24152413

24162414
bool Parser::IsValidDeclaration(const clang::SourceLocation& Loc)
@@ -2771,7 +2769,7 @@ void Parser::HandleDeclaration(clang::Decl* D, Declaration* Decl)
27712769
Decl->OriginalPtr = (void*) D;
27722770
Decl->USR = GetDeclUSR(D);
27732771
Decl->Location = SourceLocation(D->getLocation().getRawEncoding());
2774-
GetLineNumbersFromLocation(D->getLocation(), D->getLocEnd(),
2772+
GetLineNumbersFromLocation(D->getLocStart(), D->getLocEnd(),
27752773
&Decl->LineNumberStart, &Decl->LineNumberEnd);
27762774

27772775
if (Decl->PreprocessedEntities.empty() && !D->isImplicit())

0 commit comments

Comments
 (0)