<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 23, 2014 at 12:04 PM, John Thompson <span dir="ltr"><<a href="mailto:John.Thompson.JTSoftware@gmail.com" target="_blank">John.Thompson.JTSoftware@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jtsoftware<br>
Date: Wed Apr 23 14:04:32 2014<br>
New Revision: 207011<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=207011&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=207011&view=rev</a><br>
Log:<br>
Quick fix for layering that broke shared library build.<br></blockquote><div><br></div><div>Thanks! Putting this into ModuleLoader seems reasonable for now.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Modified:<br>
    cfe/trunk/include/clang/Frontend/ASTUnit.h<br>
    cfe/trunk/include/clang/Frontend/CompilerInstance.h<br>
    cfe/trunk/include/clang/Lex/ModuleLoader.h<br>
    cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
    cfe/trunk/lib/Sema/SemaLookup.cpp<br>
    cfe/trunk/unittests/Basic/SourceManagerTest.cpp<br>
    cfe/trunk/unittests/Lex/LexerTest.cpp<br>
    cfe/trunk/unittests/Lex/PPCallbacksTest.cpp<br>
    cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=207011&r1=207010&r2=207011&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=207011&r1=207010&r2=207011&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)<br>
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Wed Apr 23 14:04:32 2014<br>
@@ -874,8 +874,10 @@ public:<br>
   void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility,<br>
                          SourceLocation ImportLoc, bool Complain) override {}<br>
<br>
-  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)<br>
+  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override<br>
     { return 0; }<br>
+  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override<br>
+    { return 0; };<br>
 };<br>
<br>
 } // namespace clang<br>
<br>
Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=207011&r1=207010&r2=207011&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=207011&r1=207010&r2=207011&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)<br>
+++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Wed Apr 23 14:04:32 2014<br>
@@ -700,7 +700,9 @@ public:<br>
     return ModuleLoader::HadFatalFailure;<br>
   }<br>
<br>
-  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc);<br>
+  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override;<br>
+<br>
+  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override;<br>
 };<br>
<br>
 } // end namespace clang<br>
<br>
Modified: cfe/trunk/include/clang/Lex/ModuleLoader.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleLoader.h?rev=207011&r1=207010&r2=207011&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleLoader.h?rev=207011&r1=207010&r2=207011&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Lex/ModuleLoader.h (original)<br>
+++ cfe/trunk/include/clang/Lex/ModuleLoader.h Wed Apr 23 14:04:32 2014<br>
@@ -113,7 +113,14 @@ public:<br>
   /// \param TriggerLoc The location for what triggered the load.<br>
   /// \returns Returns null if load failed.<br>
   virtual GlobalModuleIndex *loadGlobalModuleIndex(<br>
-                                            SourceLocation TriggerLoc) = 0;<br>
+                                                SourceLocation TriggerLoc) = 0;<br>
+<br>
+  /// Check global module index for missing imports.<br>
+  /// \param Name The symbol name to look for.<br>
+  /// \param TriggerLoc The location for what triggered the load.<br>
+  /// \returns Returns true if any modules with that symbol found.<br>
+  virtual bool lookupMissingImports(StringRef Name,<br>
+                                    SourceLocation TriggerLoc) = 0;<br>
<br>
   bool HadFatalFailure;<br>
 };<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=207011&r1=207010&r2=207011&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=207011&r1=207010&r2=207011&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Apr 23 14:04:32 2014<br>
@@ -1466,3 +1466,29 @@ GlobalModuleIndex *CompilerInstance::loa<br>
   }<br>
   return GlobalIndex;<br>
 }<br>
+<br>
+// Check global module index for missing imports.<br>
+bool<br>
+CompilerInstance::lookupMissingImports(StringRef Name,<br>
+                                       SourceLocation TriggerLoc) {<br>
+  // Look for the symbol in non-imported modules, but only if an error<br>
+  // actually occurred.<br>
+  if (!buildingModule()) {<br>
+    // Load global module index, or retrieve a previously loaded one.<br>
+    GlobalModuleIndex *GlobalIndex = loadGlobalModuleIndex(<br>
+      TriggerLoc);<br>
+<br>
+    // Only if we have a global index.<br>
+    if (GlobalIndex) {<br>
+      GlobalModuleIndex::HitSet FoundModules;<br>
+<br>
+      // Find the modules that reference the identifier.<br>
+      // Note that this only finds top-level modules.<br>
+      // We'll let diagnoseTypo find the actual declaration module.<br>
+      if (GlobalIndex->lookupIdentifier(Name, FoundModules))<br>
+        return true;<br>
+    }<br>
+  }<br>
+<br>
+  return false;<br>
+}<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=207011&r1=207010&r2=207011&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=207011&r1=207010&r2=207011&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Apr 23 14:04:32 2014<br>
@@ -23,8 +23,6 @@<br>
 #include "clang/AST/ExprCXX.h"<br>
 #include "clang/Basic/Builtins.h"<br>
 #include "clang/Basic/LangOptions.h"<br>
-#include "clang/Lex/HeaderSearch.h"<br>
-#include "clang/Lex/ModuleLoader.h"<br>
 #include "clang/Lex/Preprocessor.h"<br>
 #include "clang/Sema/DeclSpec.h"<br>
 #include "clang/Sema/ExternalSemaSource.h"<br>
@@ -35,8 +33,6 @@<br>
 #include "clang/Sema/SemaInternal.h"<br>
 #include "clang/Sema/TemplateDeduction.h"<br>
 #include "clang/Sema/TypoCorrection.h"<br>
-#include "clang/Serialization/GlobalModuleIndex.h"<br>
-#include "clang/Serialization/Module.h"<br>
 #include "llvm/ADT/STLExtras.h"<br>
 #include "llvm/ADT/SetVector.h"<br>
 #include "llvm/ADT/SmallPtrSet.h"<br>
@@ -3986,29 +3982,13 @@ TypoCorrection Sema::CorrectTypo(const D<br>
<br>
   TypoCorrectionConsumer Consumer(*this, Typo);<br>
<br>
-  // Get the module loader (usually compiler instance).<br>
-  ModuleLoader &Loader = PP.getModuleLoader();<br>
-<br>
-  // Look for the symbol in non-imported modules, but only if an error<br>
-  // actually occurred.<br>
-  if ((Mode == CTK_ErrorRecovery) && !Loader.buildingModule() &&<br>
-      getLangOpts().Modules && getLangOpts().ModulesSearchAll) {<br>
-    // Load global module index, or retrieve a previously loaded one.<br>
-    GlobalModuleIndex *GlobalIndex = Loader.loadGlobalModuleIndex(<br>
-      TypoName.getLocStart());<br>
-<br>
-    // Only if we have a global index.<br>
-    if (GlobalIndex) {<br>
-      GlobalModuleIndex::HitSet FoundModules;<br>
-<br>
-      // Find the modules that reference the identifier.<br>
-      // Note that this only finds top-level modules.<br>
-      // We'll let diagnoseTypo find the actual declaration module.<br>
-      if (GlobalIndex->lookupIdentifier(Typo->getName(), FoundModules)) {<br>
-        TypoCorrection TC(TypoName.getName(), (NestedNameSpecifier *)0, 0);<br>
-        TC.setCorrectionRange(SS, TypoName);<br>
-        TC.setRequiresImport(true);<br>
-      }<br>
+  if ((Mode == CTK_ErrorRecovery) &&  getLangOpts().Modules &&<br>
+      getLangOpts().ModulesSearchAll) {<br>
+    if (PP.getModuleLoader().lookupMissingImports(Typo->getName(),<br>
+                                               TypoName.getLocStart())) {<br>
+      TypoCorrection TC(TypoName.getName(), (NestedNameSpecifier *)0, 0);<br>
+      TC.setCorrectionRange(SS, TypoName);<br>
+      TC.setRequiresImport(true);<br></blockquote><div><br></div><div>This TC variable is unused; remove it?</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

     }<br>
   }<br>
<br>
<br>
Modified: cfe/trunk/unittests/Basic/SourceManagerTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/SourceManagerTest.cpp?rev=207011&r1=207010&r2=207011&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/SourceManagerTest.cpp?rev=207011&r1=207010&r2=207011&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/unittests/Basic/SourceManagerTest.cpp (original)<br>
+++ cfe/trunk/unittests/Basic/SourceManagerTest.cpp Wed Apr 23 14:04:32 2014<br>
@@ -52,20 +52,22 @@ protected:<br>
 };<br>
<br>
 class VoidModuleLoader : public ModuleLoader {<br>
-  virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,<br>
-                                      ModuleIdPath Path,<br>
-                                      Module::NameVisibilityKind Visibility,<br>
-                                      bool IsInclusionDirective) {<br>
+  ModuleLoadResult loadModule(SourceLocation ImportLoc,<br>
+                              ModuleIdPath Path,<br>
+                              Module::NameVisibilityKind Visibility,<br>
+                              bool IsInclusionDirective) override {<br>
     return ModuleLoadResult();<br>
   }<br>
<br>
-  virtual void makeModuleVisible(Module *Mod,<br>
-                                 Module::NameVisibilityKind Visibility,<br>
-                                 SourceLocation ImportLoc,<br>
-                                 bool Complain) { }<br>
+  void makeModuleVisible(Module *Mod,<br>
+                         Module::NameVisibilityKind Visibility,<br>
+                         SourceLocation ImportLoc,<br>
+                         bool Complain) override { }<br>
<br>
-  virtual GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)<br>
+  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override<br>
     { return 0; }<br>
+  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override<br>
+    { return 0; };<br>
 };<br>
<br>
 TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {<br>
<br>
Modified: cfe/trunk/unittests/Lex/LexerTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=207011&r1=207010&r2=207011&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=207011&r1=207010&r2=207011&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/unittests/Lex/LexerTest.cpp (original)<br>
+++ cfe/trunk/unittests/Lex/LexerTest.cpp Wed Apr 23 14:04:32 2014<br>
@@ -29,20 +29,22 @@ using namespace clang;<br>
 namespace {<br>
<br>
 class VoidModuleLoader : public ModuleLoader {<br>
-  virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,<br>
-                                      ModuleIdPath Path,<br>
-                                      Module::NameVisibilityKind Visibility,<br>
-                                      bool IsInclusionDirective) {<br>
+  ModuleLoadResult loadModule(SourceLocation ImportLoc,<br>
+                              ModuleIdPath Path,<br>
+                              Module::NameVisibilityKind Visibility,<br>
+                              bool IsInclusionDirective) override {<br>
     return ModuleLoadResult();<br>
   }<br>
<br>
-  virtual void makeModuleVisible(Module *Mod,<br>
-                                 Module::NameVisibilityKind Visibility,<br>
-                                 SourceLocation ImportLoc,<br>
-                                 bool Complain) { }<br>
+  void makeModuleVisible(Module *Mod,<br>
+                         Module::NameVisibilityKind Visibility,<br>
+                         SourceLocation ImportLoc,<br>
+                         bool Complain) override { }<br>
<br>
-  virtual GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)<br>
+  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override<br>
     { return 0; }<br>
+  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override<br>
+    { return 0; };<br>
 };<br>
<br>
 // The test fixture.<br>
<br>
Modified: cfe/trunk/unittests/Lex/PPCallbacksTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPCallbacksTest.cpp?rev=207011&r1=207010&r2=207011&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPCallbacksTest.cpp?rev=207011&r1=207010&r2=207011&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/unittests/Lex/PPCallbacksTest.cpp (original)<br>
+++ cfe/trunk/unittests/Lex/PPCallbacksTest.cpp Wed Apr 23 14:04:32 2014<br>
@@ -34,20 +34,22 @@ namespace {<br>
<br>
 // Stub out module loading.<br>
 class VoidModuleLoader : public ModuleLoader {<br>
-  virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,<br>
-                                      ModuleIdPath Path,<br>
-                                      Module::NameVisibilityKind Visibility,<br>
-                                      bool IsInclusionDirective) {<br>
+  ModuleLoadResult loadModule(SourceLocation ImportLoc,<br>
+                              ModuleIdPath Path,<br>
+                              Module::NameVisibilityKind Visibility,<br>
+                              bool IsInclusionDirective) override {<br>
     return ModuleLoadResult();<br>
   }<br>
<br>
-  virtual void makeModuleVisible(Module *Mod,<br>
-                                 Module::NameVisibilityKind Visibility,<br>
-                                 SourceLocation ImportLoc,<br>
-                                 bool Complain) { }<br>
+  void makeModuleVisible(Module *Mod,<br>
+                         Module::NameVisibilityKind Visibility,<br>
+                         SourceLocation ImportLoc,<br>
+                         bool Complain) override { }<br>
<br>
-  virtual GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)<br>
+  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override<br>
     { return 0; }<br>
+  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override<br>
+    { return 0; };<br>
 };<br>
<br>
 // Stub to collect data from InclusionDirective callbacks.<br>
<br>
Modified: cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp?rev=207011&r1=207010&r2=207011&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp?rev=207011&r1=207010&r2=207011&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp (original)<br>
+++ cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp Wed Apr 23 14:04:32 2014<br>
@@ -53,20 +53,22 @@ protected:<br>
 };<br>
<br>
 class VoidModuleLoader : public ModuleLoader {<br>
-  virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,<br>
-                                      ModuleIdPath Path,<br>
-                                      Module::NameVisibilityKind Visibility,<br>
-                                      bool IsInclusionDirective) {<br>
+  ModuleLoadResult loadModule(SourceLocation ImportLoc,<br>
+                              ModuleIdPath Path,<br>
+                              Module::NameVisibilityKind Visibility,<br>
+                              bool IsInclusionDirective) override {<br>
     return ModuleLoadResult();<br>
   }<br>
<br>
-  virtual void makeModuleVisible(Module *Mod,<br>
-                                 Module::NameVisibilityKind Visibility,<br>
-                                 SourceLocation ImportLoc,<br>
-                                 bool Complain) { }<br>
+  void makeModuleVisible(Module *Mod,<br>
+                         Module::NameVisibilityKind Visibility,<br>
+                         SourceLocation ImportLoc,<br>
+                         bool Complain) override { }<br>
<br>
-  virtual GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)<br>
+  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc) override<br>
     { return 0; }<br>
+  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc) override<br>
+    { return 0; };<br>
 };<br>
<br>
 TEST_F(PPConditionalDirectiveRecordTest, PPRecAPI) {<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>