--===============4948634871667098473== Content-Type: multipart/alternative; boundary=bcaec5196aab98e5c2051c21676c --bcaec5196aab98e5c2051c21676c Content-Type: text/plain; charset=UTF-8 On Thu, Jul 30, 2015 at 5:58 PM, Argyrios Kyrtzidis wrote: > Author: akirtzidis > Date: Thu Jul 30 19:58:32 2015 > New Revision: 243718 > > URL: http://llvm.org/viewvc/llvm-project?rev=243718&view=rev > Log: > [modules] Fix issue where building a module from a relative path when > -working-directory option is set, results in error. > > The error was "module '' was built in directory '' but now > resides in directory '' > rdar://21330027 > > Added: > cfe/trunk/test/Modules/Inputs/working-dir-test/ > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/ > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Headers/ > > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Headers/Test.h > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Modules/ > > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Modules/module.modulemap > cfe/trunk/test/Modules/working-dir-flag.m > Modified: > cfe/trunk/include/clang/Basic/FileManager.h > cfe/trunk/lib/Basic/FileManager.cpp > cfe/trunk/lib/Serialization/ASTWriter.cpp > > Modified: cfe/trunk/include/clang/Basic/FileManager.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=243718&r1=243717&r2=243718&view=diff > > ============================================================================== > --- cfe/trunk/include/clang/Basic/FileManager.h (original) > +++ cfe/trunk/include/clang/Basic/FileManager.h Thu Jul 30 19:58:32 2015 > @@ -254,7 +254,13 @@ public: > /// \brief If path is not absolute and FileSystemOptions set the working > /// directory, the path is modified to be relative to the given > /// working directory. > - void FixupRelativePath(SmallVectorImpl &path) const; > + /// \returns true if \c path changed. > + bool FixupRelativePath(SmallVectorImpl &path) const; > + > + /// Makes \c Path absolute taking into account FileSystemOptions and the > + /// working directory option. > + /// \returns true if \c Path changed to absolute. > + bool makeAbsolutePath(SmallVectorImpl &Path) const; > > /// \brief Produce an array mapping from the unique IDs assigned to each > /// file to the corresponding FileEntry pointer. > > Modified: cfe/trunk/lib/Basic/FileManager.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=243718&r1=243717&r2=243718&view=diff > > ============================================================================== > --- cfe/trunk/lib/Basic/FileManager.cpp (original) > +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Jul 30 19:58:32 2015 > @@ -389,16 +389,28 @@ FileManager::getVirtualFile(StringRef Fi > return UFE; > } > > -void FileManager::FixupRelativePath(SmallVectorImpl &path) const { > +bool FileManager::FixupRelativePath(SmallVectorImpl &path) const { > StringRef pathRef(path.data(), path.size()); > > if (FileSystemOpts.WorkingDir.empty() > || llvm::sys::path::is_absolute(pathRef)) > - return; > + return false; > > SmallString<128> NewPath(FileSystemOpts.WorkingDir); > llvm::sys::path::append(NewPath, pathRef); > path = NewPath; > + return true; > +} > + > +bool FileManager::makeAbsolutePath(SmallVectorImpl &Path) const { > + bool Changed = FixupRelativePath(Path); > + > + if (!llvm::sys::path::is_absolute(StringRef(Path.data(), Path.size()))) > { > + llvm::sys::fs::make_absolute(Path); > + Changed = true; > + } > + > + return Changed; > } > > llvm::ErrorOr> > > Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=243718&r1=243717&r2=243718&view=diff > > ============================================================================== > --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original) > +++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Jul 30 19:58:32 2015 > @@ -1074,14 +1074,7 @@ void ASTWriter::WriteBlockInfoBlock() { > /// \return \c true if the path was changed. > static bool cleanPathForOutput(FileManager &FileMgr, > SmallVectorImpl &Path) { > - bool Changed = false; > - > - if (!llvm::sys::path::is_absolute(StringRef(Path.data(), Path.size()))) > { > - llvm::sys::fs::make_absolute(Path); > - Changed = true; > - } > - > - return Changed | FileMgr.removeDotPaths(Path); > + return FileMgr.makeAbsolutePath(Path) | FileMgr.removeDotPaths(Path); > These two operations are unsequenced, and I suspect the order in which they're performed matters... > } > > /// \brief Adjusts the given filename to only write out the portion of the > @@ -1429,7 +1422,7 @@ void ASTWriter::WriteControlBlock(Prepro > > SmallString<128> OutputPath(OutputFile); > > - llvm::sys::fs::make_absolute(OutputPath); > + SM.getFileManager().makeAbsolutePath(OutputPath); > StringRef origDir = llvm::sys::path::parent_path(OutputPath); > > RecordData Record; > > Added: > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Headers/Test.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Headers/Test.h?rev=243718&view=auto > > ============================================================================== > --- > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Headers/Test.h > (added) > +++ > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Headers/Test.h > Thu Jul 30 19:58:32 2015 > @@ -0,0 +1 @@ > +void test_me_call(void); > > Added: > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Modules/module.modulemap > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Modules/module.modulemap?rev=243718&view=auto > > ============================================================================== > --- > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Modules/module.modulemap > (added) > +++ > cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Modules/module.modulemap > Thu Jul 30 19:58:32 2015 > @@ -0,0 +1,6 @@ > +framework module Test { > + umbrella header "Test.h" > + > + export * > + module * { export * } > +} > > Added: cfe/trunk/test/Modules/working-dir-flag.m > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/working-dir-flag.m?rev=243718&view=auto > > ============================================================================== > --- cfe/trunk/test/Modules/working-dir-flag.m (added) > +++ cfe/trunk/test/Modules/working-dir-flag.m Thu Jul 30 19:58:32 2015 > @@ -0,0 +1,9 @@ > +// RUN: rm -rf %t.mcp > +// RUN: %clang_cc1 -fmodules-cache-path=%t.mcp -fmodules > -fimplicit-module-maps -F . -working-directory=%S/Inputs/working-dir-test > %s -verify > +// expected-no-diagnostics > + > +@import Test; > + > +void foo() { > + test_me_call(); > +} > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > --bcaec5196aab98e5c2051c21676c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: Quoted-printable
On T= hu, Jul 30, 2015 at 5:58 PM, Argyrios Kyrtzidis <akyrtzi@gmail.com>= wrote:
Author: akirtzidis
Date: Thu Jul 30 19:58:32 2015
New Revision: 243718

URL: http://llvm.org/viewv= c/llvm-project?rev=3D243718&view=3Drev
Log:
[modules] Fix issue where building a module from a relative path when -work= ing-directory option is set, results in error.

The error was "module '<name>' was built in directory &#= 39;<path>' but now resides in directory '<path>'
rdar://21330027

Added:
=C2=A0 =C2=A0 cfe/trunk/test/Modules/Inputs/working-dir-test/
=C2=A0 =C2=A0 cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework= /
=C2=A0 =C2=A0 cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework= /Headers/
=C2=A0 =C2=A0 cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework= /Headers/Test.h
=C2=A0 =C2=A0 cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework= /Modules/
=C2=A0 =C2=A0 cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework= /Modules/module.modulemap
=C2=A0 =C2=A0 cfe/trunk/test/Modules/working-dir-flag.m
Modified:
=C2=A0 =C2=A0 cfe/trunk/include/clang/Basic/FileManager.h
=C2=A0 =C2=A0 cfe/trunk/lib/Basic/FileManager.cpp
=C2=A0 =C2=A0 cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/= llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=3D243718&r= 1=3D243717&r2=3D243718&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Thu Jul 30 19:58:32 2015
@@ -254,7 +254,13 @@ public:
=C2=A0 =C2=A0/// \brief If path is not absolute and FileSystemOptions set t= he working
=C2=A0 =C2=A0/// directory, the path is modified to be relative to the give= n
=C2=A0 =C2=A0/// working directory.
-=C2=A0 void FixupRelativePath(SmallVectorImpl<char> &path) const= ;
+=C2=A0 /// \returns true if \c path changed.
+=C2=A0 bool FixupRelativePath(SmallVectorImpl<char> &path) const= ;
+
+=C2=A0 /// Makes \c Path absolute taking into account FileSystemOptions an= d the
+=C2=A0 /// working directory option.
+=C2=A0 /// \returns true if \c Path changed to absolute.
+=C2=A0 bool makeAbsolutePath(SmallVectorImpl<char> &Path) const;=

=C2=A0 =C2=A0/// \brief Produce an array mapping from the unique IDs assign= ed to each
=C2=A0 =C2=A0/// file to the corresponding FileEntry pointer.

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-pro= ject/cfe/trunk/lib/Basic/FileManager.cpp?rev=3D243718&r1=3D243717&r= 2=3D243718&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Thu Jul 30 19:58:32 2015
@@ -389,16 +389,28 @@ FileManager::getVirtualFile(StringRef Fi
=C2=A0 =C2=A0return UFE;
=C2=A0}

-void FileManager::FixupRelativePath(SmallVectorImpl<char> &path)= const {
+bool FileManager::FixupRelativePath(SmallVectorImpl<char> &path)= const {
=C2=A0 =C2=A0StringRef pathRef(path.data(), path.size());

=C2=A0 =C2=A0if (FileSystemOpts.WorkingDir.empty()
=C2=A0 =C2=A0 =C2=A0 =C2=A0|| llvm::sys::path::is_absolute(pathRef))
-=C2=A0 =C2=A0 return;
+=C2=A0 =C2=A0 return false;

=C2=A0 =C2=A0SmallString<128> NewPath(FileSystemOpts.WorkingDir);
=C2=A0 =C2=A0llvm::sys::path::append(NewPath, pathRef);
=C2=A0 =C2=A0path =3D NewPath;
+=C2=A0 return true;
+}
+
+bool FileManager::makeAbsolutePath(SmallVectorImpl<char> &Path) = const {
+=C2=A0 bool Changed =3D FixupRelativePath(Path);
+
+=C2=A0 if (!llvm::sys::path::is_absolute(StringRef(Path.data(), Path.size(= )))) {
+=C2=A0 =C2=A0 llvm::sys::fs::make_absolute(Path);
+=C2=A0 =C2=A0 Changed =3D true;
+=C2=A0 }
+
+=C2=A0 return Changed;
=C2=A0}

=C2=A0llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/ll= vm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=3D243718&r1=3D= 243717&r2=3D243718&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Thu Jul 30 19:58:32 2015
@@ -1074,14 +1074,7 @@ void ASTWriter::WriteBlockInfoBlock() {
=C2=A0/// \return \c true if the path was changed.
=C2=A0static bool cleanPathForOutput(FileManager &FileMgr,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SmallVectorImpl<char> &Pat= h) {
-=C2=A0 bool Changed =3D false;
-
-=C2=A0 if (!llvm::sys::path::is_absolute(StringRef(Path.data(), Path.size(= )))) {
-=C2=A0 =C2=A0 llvm::sys::fs::make_absolute(Path);
-=C2=A0 =C2=A0 Changed =3D true;
-=C2=A0 }
-
-=C2=A0 return Changed | FileMgr.removeDotPaths(Path);
+=C2=A0 return FileMgr.makeAbsolutePath(Path) | FileMgr.removeDotPaths(Path= );

These two operations are unsequenced= , and I suspect the order in which they're performed matters...
=C2=A0
=C2=A0}

=C2=A0/// \brief Adjusts the given filename to only write out the portion o= f the
@@ -1429,7 +1422,7 @@ void ASTWriter::WriteControlBlock(Prepro

=C2=A0 =C2=A0 =C2=A0SmallString<128> OutputPath(OutputFile);

-=C2=A0 =C2=A0 llvm::sys::fs::make_absolute(OutputPath);
+=C2=A0 =C2=A0 SM.getFileManager().makeAbsolutePath(OutputPath);
=C2=A0 =C2=A0 =C2=A0StringRef origDir =3D llvm::sys::path::parent_path(Outp= utPath);

=C2=A0 =C2=A0 =C2=A0RecordData Record;

Added: cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Header= s/Test.h
URL: http://llvm.= org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/working-dir-test/Test= .framework/Headers/Test.h?rev=3D243718&view=3Dauto
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Headers/T= est.h (added)
+++ cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Headers/T= est.h Thu Jul 30 19:58:32 2015
@@ -0,0 +1 @@
+void test_me_call(void);

Added: cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Module= s/module.modulemap
URL: http= ://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/working-dir-t= est/Test.framework/Modules/module.modulemap?rev=3D243718&view=3Dauto
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Modules/m= odule.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/working-dir-test/Test.framework/Modules/m= odule.modulemap Thu Jul 30 19:58:32 2015
@@ -0,0 +1,6 @@
+framework module Test {
+=C2=A0 umbrella header "Test.h"
+
+=C2=A0 export *
+=C2=A0 module * { export * }
+}

Added: cfe/trunk/test/Modules/working-dir-flag.m
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/tes= t/Modules/working-dir-flag.m?rev=3D243718&view=3Dauto
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D
--- cfe/trunk/test/Modules/working-dir-flag.m (added)
+++ cfe/trunk/test/Modules/working-dir-flag.m Thu Jul 30 19:58:32 2015
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t.mcp
+// RUN: %clang_cc1 -fmodules-cache-path=3D%t.mcp -fmodules -fimplicit-modu= le-maps -F . -working-directory=3D%S/Inputs/working-dir-test %s -verify
+// expected-no-diagnostics
+
+@import Test;
+
+void foo() {
+=C2=A0 test_me_call();
+}


_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-c= ommits

--bcaec5196aab98e5c2051c21676c-- --===============4948634871667098473== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits --===============4948634871667098473==--