[PATCH] D46176: Add SourceManagerForFile helper which sets up SourceManager and dependencies for a single file with code snippet

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 7 01:42:15 PDT 2018


sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.


================
Comment at: include/clang/Basic/SourceManager.h:1819
+/// SourceManager and necessary depdencies (e.g. VFS, FileManager) for a single
+/// file.
+class SourceManagerForFile {
----------------
nit: single in-memory file


================
Comment at: include/clang/Basic/SourceManager.h:1824
+  /// The main file in the SourceManager will be \p FileName with \p Content.
+  static std::unique_ptr<SourceManagerForFile> create(StringRef FileName,
+                                                      StringRef Content);
----------------
why is this not just a constructor? it looks like it can't fail?


================
Comment at: include/clang/Basic/SourceManager.h:1827
+
+  SourceManager &getSourceManager() { return SourceMgr; }
+
----------------
this could also just be `get()` or `operator*`


================
Comment at: lib/Format/TokenAnalyzer.h:71
 private:
+  std::unique_ptr<SourceManagerForFile> VirtualSM;
+
----------------
add a comment that this is only present if constructed from a string?


Repository:
  rC Clang

https://reviews.llvm.org/D46176





More information about the cfe-commits mailing list