@@ -318,7 +318,7 @@ void CGDebugInfo::setLocation(SourceLocation Loc) {
318318 if (Loc.isInvalid ())
319319 return ;
320320
321- CurLoc = CGM.getContext ().getSourceManager ().getExpansionLoc (Loc);
321+ CurLoc = CGM.getContext ().getSourceManager ().getFileLoc (Loc);
322322
323323 // If we've changed files in the middle of a lexical scope go ahead
324324 // and create a new lexical scope with file node if it's different
@@ -545,7 +545,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
545545 FileName = TheCU->getFile ()->getFilename ();
546546 CSInfo = TheCU->getFile ()->getChecksum ();
547547 } else {
548- PresumedLoc PLoc = SM.getPresumedLoc (Loc);
548+ PresumedLoc PLoc = SM.getPresumedLoc (SM. getFileLoc ( Loc) );
549549 FileName = PLoc.getFilename ();
550550
551551 if (FileName.empty ()) {
@@ -572,7 +572,8 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
572572 if (CSKind)
573573 CSInfo.emplace (*CSKind, Checksum);
574574 }
575- return createFile (FileName, CSInfo, getSource (SM, SM.getFileID (Loc)));
575+ return createFile (FileName, CSInfo,
576+ getSource (SM, SM.getFileID (SM.getExpansionLoc (Loc))));
576577}
577578
578579llvm::DIFile *CGDebugInfo::createFile (
@@ -627,7 +628,7 @@ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
627628 if (Loc.isInvalid ())
628629 return 0 ;
629630 SourceManager &SM = CGM.getContext ().getSourceManager ();
630- return SM.getPresumedLoc (Loc).getLine ();
631+ return SM.getPresumedLoc (SM. getFileLoc ( Loc) ).getLine ();
631632}
632633
633634unsigned CGDebugInfo::getColumnNumber (SourceLocation Loc, bool Force) {
@@ -639,7 +640,7 @@ unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
639640 if (Loc.isInvalid () && CurLoc.isInvalid ())
640641 return 0 ;
641642 SourceManager &SM = CGM.getContext ().getSourceManager ();
642- PresumedLoc PLoc = SM.getPresumedLoc (Loc.isValid () ? Loc : CurLoc);
643+ PresumedLoc PLoc = SM.getPresumedLoc (Loc.isValid () ? SM. getFileLoc ( Loc) : CurLoc);
643644 return PLoc.isValid () ? PLoc.getColumn () : 0 ;
644645}
645646
@@ -4973,7 +4974,7 @@ void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc) {
49734974 // Update our current location
49744975 setLocation (Loc);
49754976
4976- if (CurLoc.isInvalid () || CurLoc. isMacroID () || LexicalBlockStack.empty ())
4977+ if (CurLoc.isInvalid () || LexicalBlockStack.empty ())
49774978 return ;
49784979
49794980 llvm::MDNode *Scope = LexicalBlockStack.back ();
@@ -6244,7 +6245,8 @@ void CGDebugInfo::EmitGlobalAlias(const llvm::GlobalValue *GV,
62446245void CGDebugInfo::AddStringLiteralDebugInfo (llvm::GlobalVariable *GV,
62456246 const StringLiteral *S) {
62466247 SourceLocation Loc = S->getStrTokenLoc (0 );
6247- PresumedLoc PLoc = CGM.getContext ().getSourceManager ().getPresumedLoc (Loc);
6248+ SourceManager &SM = CGM.getContext ().getSourceManager ();
6249+ PresumedLoc PLoc = SM.getPresumedLoc (SM.getFileLoc (Loc));
62486250 if (!PLoc.isValid ())
62496251 return ;
62506252
0 commit comments