================
@@ -1275,43 +1275,24 @@ class SourceManager : public 
RefCountedBase<SourceManager> {
   /// start of the buffer of the location.
   FileIDAndOffset getDecomposedLoc(SourceLocation Loc) const {
     FileID FID = getFileID(Loc);
-    auto *Entry = getSLocEntryOrNull(FID);
-    if (!Entry)
-      return std::make_pair(FileID(), 0);
-    return std::make_pair(FID, Loc.getOffset() - Entry->getOffset());
+    const SrcMgr::SLocEntry &Entry = getSLocEntry(FID);
+    return std::make_pair(FID, Loc.getOffset() - Entry.getOffset());
   }
 
   /// Decompose the specified location into a raw FileID + Offset pair.
   ///
   /// If the location is an expansion record, walk through it until we find
   /// the final location expanded.
   FileIDAndOffset getDecomposedExpansionLoc(SourceLocation Loc) const {
-    FileID FID = getFileID(Loc);
-    auto *E = getSLocEntryOrNull(FID);
-    if (!E)
-      return std::make_pair(FileID(), 0);
-
-    unsigned Offset = Loc.getOffset()-E->getOffset();
-    if (Loc.isFileID())
-      return std::make_pair(FID, Offset);
-
-    return getDecomposedExpansionLocSlowCase(E);
+    return getDecomposedLoc(getExpansionLoc(Loc));
----------------
SergejSalnikov wrote:

If you look into implementation of  getDecomposedExpansionLocSlowCase it does
`Loc = E->getExpansion().getExpansionLocStart()` in a while loop, that's 
exactly the same as what `getExpansionLoc` does.

I've actually added the assertion about `old result == new result` and run all 
tests. and they all pass.

https://github.com/llvm/llvm-project/pull/166236
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to