<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014-03-03 0:04 GMT+01:00 Gautier DI FOLCO <span dir="ltr"><<a href="mailto:gautier.difolco@gmail.com" target="_blank">gautier.difolco@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi doug.gregor,<br>
<br>
lookupModuleName segfaulted in ModuleManager on "-" FileName when the FileManager was empty.<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D2920" target="_blank">http://llvm-reviews.chandlerc.com/D2920</a><br>
<br>
Files:<br>
lib/Serialization/ModuleManager.cpp<br>
unittests/CMakeLists.txt<br>
unittests/Makefile<br>
unittests/Serialization/CMakeLists.txt<br>
unittests/Serialization/ModuleManagerTest.cpp<br>
<br>
Index: lib/Serialization/ModuleManager.cpp<br>
===================================================================<br>
--- lib/Serialization/ModuleManager.cpp<br>
+++ lib/Serialization/ModuleManager.cpp<br>
@@ -383,7 +383,7 @@<br>
const FileEntry *&File) {<br>
File = FileMgr.getFile(FileName, /*openFile=*/false, /*cacheFailure=*/false);<br>
<br>
- if (!File && FileName != "-") {<br>
+ if (!File) {<br>
return false;<br>
}<br>
<br>
Index: unittests/CMakeLists.txt<br>
===================================================================<br>
--- unittests/CMakeLists.txt<br>
+++ unittests/CMakeLists.txt<br>
@@ -12,6 +12,7 @@<br>
add_subdirectory(Basic)<br>
add_subdirectory(Lex)<br>
add_subdirectory(Driver)<br>
+add_subdirectory(Serialization)<br>
if(CLANG_ENABLE_STATIC_ANALYZER)<br>
add_subdirectory(Frontend)<br>
endif()<br>
Index: unittests/Makefile<br>
===================================================================<br>
--- unittests/Makefile<br>
+++ unittests/Makefile<br>
@@ -14,7 +14,7 @@<br>
<br>
IS_UNITTEST_LEVEL := 1<br>
CLANG_LEVEL := ..<br>
-PARALLEL_DIRS = Basic Lex Driver libclang<br>
+PARALLEL_DIRS = Basic Lex Driver libclang Serialization<br>
<br>
include $(CLANG_LEVEL)/../..//Makefile.config<br>
<br>
Index: unittests/Serialization/CMakeLists.txt<br>
===================================================================<br>
--- unittests/Serialization/CMakeLists.txt<br>
+++ unittests/Serialization/CMakeLists.txt<br>
@@ -0,0 +1,7 @@<br>
+add_clang_unittest(clangSerializationTests<br>
+ ModuleManagerTest.cpp<br>
+ )<br>
+<br>
+target_link_libraries(clangSerializationTests<br>
+ clangSerialization<br>
+ )<br>
Index: unittests/Serialization/ModuleManagerTest.cpp<br>
===================================================================<br>
--- unittests/Serialization/ModuleManagerTest.cpp<br>
+++ unittests/Serialization/ModuleManagerTest.cpp<br>
@@ -0,0 +1,39 @@<br>
+//=== unittests/Serialization/ModuleManagerTest.cpp - ModuleManager tests ===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "clang/Basic/FileSystemOptions.h"<br>
+#include "clang/Basic/FileManager.h"<br>
+#include "clang/Serialization/ModuleManager.h"<br>
+#include "gtest/gtest.h"<br>
+<br>
+using namespace clang;<br>
+<br>
+namespace {<br>
+<br>
+// Test a lookup of a unknown file when there is no Modules<br>
+TEST(ModuleManager, LookupModuleUnknownFilenameDontFailAtStartup) {<br>
+ FileSystemOptions f;<br>
+ FileManager m(f);<br>
+ serialization::ModuleManager ModuleMgr(m);<br>
+ const FileEntry *File = 0;<br>
+ ASSERT_FALSE(ModuleMgr.lookupModuleFile("UnknownModuleFile", 1, 1, File));<br>
+ ASSERT_TRUE(File == NULL);<br>
+}<br>
+<br>
+// Test a lookup of dash file when there is no Modules<br>
+TEST(ModuleManager, LookupModuleDashFilenameDontFailAtStartup) {<br>
+ FileSystemOptions f;<br>
+ FileManager m(f);<br>
+ serialization::ModuleManager ModuleMgr(m);<br>
+ const FileEntry *File = 0;<br>
+ ASSERT_FALSE(ModuleMgr.lookupModuleFile("-", 1, 1, File));<br>
+ ASSERT_TRUE(File == NULL);<br>
+}<br>
+<br>
+} // anonymous namespace<br>
</blockquote></div><br></div><div class="gmail_extra">Gentle ping.<br></div></div>