@@ -357,7 +357,7 @@ void CGDebugInfo::setLocation(SourceLocation Loc) {
357357 if (Loc.isInvalid ())
358358 return ;
359359
360- CurLoc = CGM.getContext ().getSourceManager ().getExpansionLoc (Loc);
360+ CurLoc = CGM.getContext ().getSourceManager ().getFileLoc (Loc);
361361
362362 // If we've changed files in the middle of a lexical scope go ahead
363363 // and create a new lexical scope with file node if it's different
@@ -584,7 +584,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
584584 FileName = TheCU->getFile ()->getFilename ();
585585 CSInfo = TheCU->getFile ()->getChecksum ();
586586 } else {
587- PresumedLoc PLoc = SM.getPresumedLoc (Loc);
587+ PresumedLoc PLoc = SM.getPresumedLoc (SM. getFileLoc ( Loc) );
588588 FileName = PLoc.getFilename ();
589589
590590 if (FileName.empty ()) {
@@ -611,7 +611,8 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
611611 if (CSKind)
612612 CSInfo.emplace (*CSKind, Checksum);
613613 }
614- return createFile (FileName, CSInfo, getSource (SM, SM.getFileID (Loc)));
614+ return createFile (FileName, CSInfo,
615+ getSource (SM, SM.getFileID (SM.getFileLoc (Loc))));
615616}
616617
617618llvm::DIFile *CGDebugInfo::createFile (
@@ -666,7 +667,7 @@ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {
666667 if (Loc.isInvalid ())
667668 return 0 ;
668669 SourceManager &SM = CGM.getContext ().getSourceManager ();
669- return SM.getPresumedLoc (Loc).getLine ();
670+ return SM.getPresumedLoc (SM. getFileLoc ( Loc) ).getLine ();
670671}
671672
672673unsigned CGDebugInfo::getColumnNumber (SourceLocation Loc, bool Force) {
@@ -678,7 +679,8 @@ unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) {
678679 if (Loc.isInvalid () && CurLoc.isInvalid ())
679680 return 0 ;
680681 SourceManager &SM = CGM.getContext ().getSourceManager ();
681- PresumedLoc PLoc = SM.getPresumedLoc (Loc.isValid () ? Loc : CurLoc);
682+ PresumedLoc PLoc =
683+ SM.getPresumedLoc (Loc.isValid () ? SM.getFileLoc (Loc) : CurLoc);
682684 return PLoc.isValid () ? PLoc.getColumn () : 0 ;
683685}
684686
@@ -5002,7 +5004,7 @@ void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc) {
50025004 // Update our current location
50035005 setLocation (Loc);
50045006
5005- if (CurLoc.isInvalid () || CurLoc. isMacroID () || LexicalBlockStack.empty ())
5007+ if (CurLoc.isInvalid () || LexicalBlockStack.empty ())
50065008 return ;
50075009
50085010 llvm::MDNode *Scope = LexicalBlockStack.back ();
@@ -6278,7 +6280,8 @@ void CGDebugInfo::EmitGlobalAlias(const llvm::GlobalValue *GV,
62786280void CGDebugInfo::AddStringLiteralDebugInfo (llvm::GlobalVariable *GV,
62796281 const StringLiteral *S) {
62806282 SourceLocation Loc = S->getStrTokenLoc (0 );
6281- PresumedLoc PLoc = CGM.getContext ().getSourceManager ().getPresumedLoc (Loc);
6283+ SourceManager &SM = CGM.getContext ().getSourceManager ();
6284+ PresumedLoc PLoc = SM.getPresumedLoc (SM.getFileLoc (Loc));
62826285 if (!PLoc.isValid ())
62836286 return ;
62846287
0 commit comments