@@ -2407,10 +2407,8 @@ void Parser::GetLineNumbersFromLocation(const clang::SourceLocation& StartLoc,
2407
2407
const clang::SourceLocation& EndLoc, int * LineNumberStart, int * LineNumberEnd)
2408
2408
{
2409
2409
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);
2414
2412
}
2415
2413
2416
2414
bool Parser::IsValidDeclaration (const clang::SourceLocation& Loc)
@@ -2771,7 +2769,7 @@ void Parser::HandleDeclaration(clang::Decl* D, Declaration* Decl)
2771
2769
Decl->OriginalPtr = (void *) D;
2772
2770
Decl->USR = GetDeclUSR (D);
2773
2771
Decl->Location = SourceLocation (D->getLocation ().getRawEncoding ());
2774
- GetLineNumbersFromLocation (D->getLocation (), D->getLocEnd (),
2772
+ GetLineNumbersFromLocation (D->getLocStart (), D->getLocEnd (),
2775
2773
&Decl->LineNumberStart , &Decl->LineNumberEnd );
2776
2774
2777
2775
if (Decl->PreprocessedEntities .empty () && !D->isImplicit ())
0 commit comments