[PATCH] D79834: Speed up preamble building by replacing the slow translateFile call by a new, faster isMainFile check

Jan Korous via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 13 20:43:40 PDT 2020


jkorous added a comment.

Could you please add a test for this method to `clang/unittests/Basic/SourceManagerTest.cpp`?



================
Comment at: clang/include/clang/Basic/SourceManager.h:816
 
+  /// Returns true when the given FileEntry corresponds to the main file.
+  bool isMainFile(FileEntryRef SourceFile);
----------------
Please mention the assertion this method makes about the state of the instance it's called on.


================
Comment at: clang/lib/Basic/SourceManager.cpp:397
+    return false;
+  return FE->getUID() == SourceFile.getUID();
+}
----------------
I don't really understand all the details here but shouldn't we use this comparison?
```
bool operator==(const FileEntryRef &LHS, const FileEntryRef &RHS)
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79834/new/

https://reviews.llvm.org/D79834





More information about the cfe-commits mailing list