[PATCH] D50740: [SourceManager] isPointWithin: avoid using isBeforeInTranslationUnit, compare buffer offsets directly for lexical correctness

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 16 04:34:51 PDT 2018


ioeric added inline comments.


================
Comment at: lib/Basic/SourceManager.cpp:2035
+         "Passed invalid source location!");
+  assert(Start.isFileID() && End.isFileID() && Loc.isFileID() &&
+         "Passed non-file source location!");
----------------
Why do we disallow locations from macro expansions?


================
Comment at: lib/Basic/SourceManager.cpp:2049
+    return false;
+  std::pair<FileID, unsigned> EndLoc = getDecomposedLoc(End);
+  // The point must be in the same file as the end location.
----------------
nit: the pattern seems repetitive. Maybe pull out a helper/lambda like: `isBeforeInSameFile(L1, L2)`?



Repository:
  rC Clang

https://reviews.llvm.org/D50740





More information about the cfe-commits mailing list