@@ -330,7 +330,7 @@ void CGDebugInfo::setLocation(SourceLocation Loc) {
330330 if (Loc.isInvalid ())
331331 return ;
332332
333- CurLoc = CGM.getContext ().getSourceManager ().getExpansionLoc (Loc);
333+ CurLoc = CGM.getContext ().getSourceManager ().getFileLoc (Loc);
334334
335335 // If we've changed files in the middle of a lexical scope go ahead
336336 // and create a new lexical scope with file node if it's different
@@ -557,7 +557,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
557557 FileName = TheCU->getFile ()->getFilename ();
558558 CSInfo = TheCU->getFile ()->getChecksum ();
559559 } else {
560- PresumedLoc PLoc = SM.getPresumedLoc (Loc);
560+ PresumedLoc PLoc = SM.getPresumedLoc (SM. getFileLoc ( Loc) );
561561 FileName = PLoc.getFilename ();
562562
563563 if (FileName.empty ()) {
@@ -584,7 +584,8 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
584584 if (CSKind)
585585 CSInfo.emplace (*CSKind, Checksum);
586586 }
587- return createFile (FileName, CSInfo, getSource (SM, SM.getFileID (Loc)));
587+ return createFile (FileName, CSInfo,
588+ getSource (SM, SM.getFileID (SM.getFileLoc (Loc))));
588589}
589590
590591llvm::DIFile *CGDebugInfo::createFile (
@@ -639,7 +640,7 @@ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
639640 if (Loc.isInvalid ())
640641 return 0 ;
641642 SourceManager &SM = CGM.getContext ().getSourceManager ();
642- return SM.getPresumedLoc (Loc).getLine ();
643+ return SM.getPresumedLoc (SM. getFileLoc ( Loc) ).getLine ();
643644}
644645
645646unsigned CGDebugInfo::getColumnNumber (SourceLocation Loc, bool Force) {
@@ -651,7 +652,8 @@ unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
651652 if (Loc.isInvalid () && CurLoc.isInvalid ())
652653 return 0 ;
653654 SourceManager &SM = CGM.getContext ().getSourceManager ();
654- PresumedLoc PLoc = SM.getPresumedLoc (Loc.isValid () ? Loc : CurLoc);
655+ PresumedLoc PLoc =
656+ SM.getPresumedLoc (Loc.isValid () ? SM.getFileLoc (Loc) : CurLoc);
655657 return PLoc.isValid () ? PLoc.getColumn () : 0 ;
656658}
657659
@@ -4975,7 +4977,7 @@ void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc) {
49754977 // Update our current location
49764978 setLocation (Loc);
49774979
4978- if (CurLoc.isInvalid () || CurLoc. isMacroID () || LexicalBlockStack.empty ())
4980+ if (CurLoc.isInvalid () || LexicalBlockStack.empty ())
49794981 return ;
49804982
49814983 llvm::MDNode *Scope = LexicalBlockStack.back ();
@@ -6246,7 +6248,8 @@ void CGDebugInfo::EmitGlobalAlias(const llvm::GlobalValue *GV,
62466248void CGDebugInfo::AddStringLiteralDebugInfo (llvm::GlobalVariable *GV,
62476249 const StringLiteral *S) {
62486250 SourceLocation Loc = S->getStrTokenLoc (0 );
6249- PresumedLoc PLoc = CGM.getContext ().getSourceManager ().getPresumedLoc (Loc);
6251+ SourceManager &SM = CGM.getContext ().getSourceManager ();
6252+ PresumedLoc PLoc = SM.getPresumedLoc (SM.getFileLoc (Loc));
62506253 if (!PLoc.isValid ())
62516254 return ;
62526255
0 commit comments