[PATCH] D127660: [clang][lex] NFCI: Use DirectoryEntryRef in Preprocessor::MainFileDir

2023-05-30 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
jansvoboda11 marked an inline comment as done.
Closed by commit rGe19f352beee7: [clang][lex] NFCI: Use DirectoryEntryRef in 
Preprocessor::MainFileDir (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D127660?vs=436422=526781#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127660

Files:
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Lex/PPDirectives.cpp


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -956,7 +956,7 @@
 // map file.
 if (!FileEnt) {
   if (FID == SourceMgr.getMainFileID() && MainFileDir) {
-Includers.push_back(std::make_pair(nullptr, MainFileDir));
+Includers.push_back(std::make_pair(nullptr, *MainFileDir));
 BuildSystemModule = getCurrentModule()->IsSystem;
   } else if ((FileEnt =
 SourceMgr.getFileEntryForID(SourceMgr.getMainFileID(
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -511,7 +511,7 @@
 
   // Inform the preprocessor that includes from within the input buffer should
   // be resolved relative to the build directory of the module map file.
-  CI.getPreprocessor().setMainFileDir(M->Directory);
+  CI.getPreprocessor().setMainFileDir(*M->Directory);
 
   // If the module was inferred from a different module map (via an expanded
   // umbrella module definition), track that fact.
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -625,7 +625,7 @@
   /// The directory that the main file should be considered to occupy,
   /// if it does not correspond to a real file (as happens when building a
   /// module).
-  const DirectoryEntry *MainFileDir = nullptr;
+  OptionalDirectoryEntryRef MainFileDir;
 
   /// The number of bytes that we will initially skip when entering the
   /// main file, along with a flag that indicates whether skipping this number
@@ -2012,9 +2012,7 @@
 
   /// Set the directory in which the main file should be considered
   /// to have been found, if it is not a real file.
-  void setMainFileDir(const DirectoryEntry *Dir) {
-MainFileDir = Dir;
-  }
+  void setMainFileDir(DirectoryEntryRef Dir) { MainFileDir = Dir; }
 
   /// Instruct the preprocessor to skip part of the main source file.
   ///


Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -956,7 +956,7 @@
 // map file.
 if (!FileEnt) {
   if (FID == SourceMgr.getMainFileID() && MainFileDir) {
-Includers.push_back(std::make_pair(nullptr, MainFileDir));
+Includers.push_back(std::make_pair(nullptr, *MainFileDir));
 BuildSystemModule = getCurrentModule()->IsSystem;
   } else if ((FileEnt =
 SourceMgr.getFileEntryForID(SourceMgr.getMainFileID(
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -511,7 +511,7 @@
 
   // Inform the preprocessor that includes from within the input buffer should
   // be resolved relative to the build directory of the module map file.
-  CI.getPreprocessor().setMainFileDir(M->Directory);
+  CI.getPreprocessor().setMainFileDir(*M->Directory);
 
   // If the module was inferred from a different module map (via an expanded
   // umbrella module definition), track that fact.
Index: clang/include/clang/Lex/Preprocessor.h
===
--- clang/include/clang/Lex/Preprocessor.h
+++ clang/include/clang/Lex/Preprocessor.h
@@ -625,7 +625,7 @@
   /// The directory that the main file should be considered to occupy,
   /// if it does not correspond to a real file (as happens when building a
   /// module).
-  const DirectoryEntry *MainFileDir = nullptr;
+  OptionalDirectoryEntryRef MainFileDir;
 
   /// The number of bytes that we will initially skip when entering the
   /// main file, along with a flag that indicates whether skipping this number
@@ -2012,9 +2012,7 @@
 
   /// Set the directory in which the main file should be considered
   /// to have been found, if it is not a real file.
-  void setMainFileDir(const DirectoryEntry *Dir) {
-MainFileDir = Dir;
-  }
+  void setMainFileDir(DirectoryEntryRef Dir) { 

[PATCH] D127660: [clang][lex] NFCI: Use DirectoryEntryRef in Preprocessor::MainFileDir

2023-05-25 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 marked an inline comment as done.
jansvoboda11 added inline comments.
Herald added a subscriber: ributzka.



Comment at: clang/lib/Frontend/FrontendAction.cpp:507
   // be resolved relative to the build directory of the module map file.
-  CI.getPreprocessor().setMainFileDir(M->Directory);
+  CI.getPreprocessor().setMainFileDir(*M->Directory);
 

bnbarham wrote:
> Same as in previous review, is this guaranteed to be set? Might be worth a 
> comment on the field itself if so (in https://reviews.llvm.org/D127654)
It is. Couple lines above we call `HeaderSearch::lookupModule()`, which parses 
the defining module map and sets the `Directory`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127660

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127660: [clang][lex] NFCI: Use DirectoryEntryRef in Preprocessor::MainFileDir

2022-06-13 Thread Ben Barham via Phabricator via cfe-commits
bnbarham accepted this revision.
bnbarham added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Frontend/FrontendAction.cpp:507
   // be resolved relative to the build directory of the module map file.
-  CI.getPreprocessor().setMainFileDir(M->Directory);
+  CI.getPreprocessor().setMainFileDir(*M->Directory);
 

Same as in previous review, is this guaranteed to be set? Might be worth a 
comment on the field itself if so (in https://reviews.llvm.org/D127654)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127660

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits