r207011 - Quick fix for layering that broke shared library build.

Richard Smith richard at metafoo.co.uk
Wed Apr 23 13:28:55 PDT 2014


On Wed, Apr 23, 2014 at 12:04 PM, John Thompson <
John.Thompson.JTSoftware at gmail.com> wrote:

> Author: jtsoftware
> Date: Wed Apr 23 14:04:32 2014
> New Revision: 207011
>
> URL: http://llvm.org/viewvc/llvm-project?rev=207011&view=rev
> Log:
> Quick fix for layering that broke shared library build.
>

Thanks! Putting this into ModuleLoader seems reasonable for now.


> Modified:
>     cfe/trunk/include/clang/Frontend/ASTUnit.h
>     cfe/trunk/include/clang/Frontend/CompilerInstance.h
>     cfe/trunk/include/clang/Lex/ModuleLoader.h
>     cfe/trunk/lib/Frontend/CompilerInstance.cpp
>     cfe/trunk/lib/Sema/SemaLookup.cpp
>     cfe/trunk/unittests/Basic/SourceManagerTest.cpp
>     cfe/trunk/unittests/Lex/LexerTest.cpp
>     cfe/trunk/unittests/Lex/PPCallbacksTest.cpp
>     cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
>
> Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=207011&r1=207010&r2=207011&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
> +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Wed Apr 23 14:04:32 2014
> @@ -874,8 +874,10 @@ public:
>    void makeModuleVisible(Module *Mod, Module::NameVisibilityKind
> Visibility,
>                           SourceLocation ImportLoc, bool Complain)
> override {}
>
> -  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)
> +  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)
> override
>      { return 0; }
> +  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc)
> override
> +    { return 0; };
>  };
>
>  } // namespace clang
>
> Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=207011&r1=207010&r2=207011&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
> +++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Wed Apr 23
> 14:04:32 2014
> @@ -700,7 +700,9 @@ public:
>      return ModuleLoader::HadFatalFailure;
>    }
>
> -  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc);
> +  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)
> override;
> +
> +  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc)
> override;
>  };
>
>  } // end namespace clang
>
> Modified: cfe/trunk/include/clang/Lex/ModuleLoader.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleLoader.h?rev=207011&r1=207010&r2=207011&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Lex/ModuleLoader.h (original)
> +++ cfe/trunk/include/clang/Lex/ModuleLoader.h Wed Apr 23 14:04:32 2014
> @@ -113,7 +113,14 @@ public:
>    /// \param TriggerLoc The location for what triggered the load.
>    /// \returns Returns null if load failed.
>    virtual GlobalModuleIndex *loadGlobalModuleIndex(
> -                                            SourceLocation TriggerLoc) =
> 0;
> +                                                SourceLocation
> TriggerLoc) = 0;
> +
> +  /// Check global module index for missing imports.
> +  /// \param Name The symbol name to look for.
> +  /// \param TriggerLoc The location for what triggered the load.
> +  /// \returns Returns true if any modules with that symbol found.
> +  virtual bool lookupMissingImports(StringRef Name,
> +                                    SourceLocation TriggerLoc) = 0;
>
>    bool HadFatalFailure;
>  };
>
> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=207011&r1=207010&r2=207011&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Apr 23 14:04:32 2014
> @@ -1466,3 +1466,29 @@ GlobalModuleIndex *CompilerInstance::loa
>    }
>    return GlobalIndex;
>  }
> +
> +// Check global module index for missing imports.
> +bool
> +CompilerInstance::lookupMissingImports(StringRef Name,
> +                                       SourceLocation TriggerLoc) {
> +  // Look for the symbol in non-imported modules, but only if an error
> +  // actually occurred.
> +  if (!buildingModule()) {
> +    // Load global module index, or retrieve a previously loaded one.
> +    GlobalModuleIndex *GlobalIndex = loadGlobalModuleIndex(
> +      TriggerLoc);
> +
> +    // Only if we have a global index.
> +    if (GlobalIndex) {
> +      GlobalModuleIndex::HitSet FoundModules;
> +
> +      // Find the modules that reference the identifier.
> +      // Note that this only finds top-level modules.
> +      // We'll let diagnoseTypo find the actual declaration module.
> +      if (GlobalIndex->lookupIdentifier(Name, FoundModules))
> +        return true;
> +    }
> +  }
> +
> +  return false;
> +}
>
> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=207011&r1=207010&r2=207011&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Apr 23 14:04:32 2014
> @@ -23,8 +23,6 @@
>  #include "clang/AST/ExprCXX.h"
>  #include "clang/Basic/Builtins.h"
>  #include "clang/Basic/LangOptions.h"
> -#include "clang/Lex/HeaderSearch.h"
> -#include "clang/Lex/ModuleLoader.h"
>  #include "clang/Lex/Preprocessor.h"
>  #include "clang/Sema/DeclSpec.h"
>  #include "clang/Sema/ExternalSemaSource.h"
> @@ -35,8 +33,6 @@
>  #include "clang/Sema/SemaInternal.h"
>  #include "clang/Sema/TemplateDeduction.h"
>  #include "clang/Sema/TypoCorrection.h"
> -#include "clang/Serialization/GlobalModuleIndex.h"
> -#include "clang/Serialization/Module.h"
>  #include "llvm/ADT/STLExtras.h"
>  #include "llvm/ADT/SetVector.h"
>  #include "llvm/ADT/SmallPtrSet.h"
> @@ -3986,29 +3982,13 @@ TypoCorrection Sema::CorrectTypo(const D
>
>    TypoCorrectionConsumer Consumer(*this, Typo);
>
> -  // Get the module loader (usually compiler instance).
> -  ModuleLoader &Loader = PP.getModuleLoader();
> -
> -  // Look for the symbol in non-imported modules, but only if an error
> -  // actually occurred.
> -  if ((Mode == CTK_ErrorRecovery) && !Loader.buildingModule() &&
> -      getLangOpts().Modules && getLangOpts().ModulesSearchAll) {
> -    // Load global module index, or retrieve a previously loaded one.
> -    GlobalModuleIndex *GlobalIndex = Loader.loadGlobalModuleIndex(
> -      TypoName.getLocStart());
> -
> -    // Only if we have a global index.
> -    if (GlobalIndex) {
> -      GlobalModuleIndex::HitSet FoundModules;
> -
> -      // Find the modules that reference the identifier.
> -      // Note that this only finds top-level modules.
> -      // We'll let diagnoseTypo find the actual declaration module.
> -      if (GlobalIndex->lookupIdentifier(Typo->getName(), FoundModules)) {
> -        TypoCorrection TC(TypoName.getName(), (NestedNameSpecifier *)0,
> 0);
> -        TC.setCorrectionRange(SS, TypoName);
> -        TC.setRequiresImport(true);
> -      }
> +  if ((Mode == CTK_ErrorRecovery) &&  getLangOpts().Modules &&
> +      getLangOpts().ModulesSearchAll) {
> +    if (PP.getModuleLoader().lookupMissingImports(Typo->getName(),
> +                                               TypoName.getLocStart())) {
> +      TypoCorrection TC(TypoName.getName(), (NestedNameSpecifier *)0, 0);
> +      TC.setCorrectionRange(SS, TypoName);
> +      TC.setRequiresImport(true);
>

This TC variable is unused; remove it?

     }
>    }
>
>
> Modified: cfe/trunk/unittests/Basic/SourceManagerTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/SourceManagerTest.cpp?rev=207011&r1=207010&r2=207011&view=diff
>
> ==============================================================================
> --- cfe/trunk/unittests/Basic/SourceManagerTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/SourceManagerTest.cpp Wed Apr 23 14:04:32
> 2014
> @@ -52,20 +52,22 @@ protected:
>  };
>
>  class VoidModuleLoader : public ModuleLoader {
> -  virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,
> -                                      ModuleIdPath Path,
> -                                      Module::NameVisibilityKind
> Visibility,
> -                                      bool IsInclusionDirective) {
> +  ModuleLoadResult loadModule(SourceLocation ImportLoc,
> +                              ModuleIdPath Path,
> +                              Module::NameVisibilityKind Visibility,
> +                              bool IsInclusionDirective) override {
>      return ModuleLoadResult();
>    }
>
> -  virtual void makeModuleVisible(Module *Mod,
> -                                 Module::NameVisibilityKind Visibility,
> -                                 SourceLocation ImportLoc,
> -                                 bool Complain) { }
> +  void makeModuleVisible(Module *Mod,
> +                         Module::NameVisibilityKind Visibility,
> +                         SourceLocation ImportLoc,
> +                         bool Complain) override { }
>
> -  virtual GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation
> TriggerLoc)
> +  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)
> override
>      { return 0; }
> +  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc)
> override
> +    { return 0; };
>  };
>
>  TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
>
> Modified: cfe/trunk/unittests/Lex/LexerTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=207011&r1=207010&r2=207011&view=diff
>
> ==============================================================================
> --- cfe/trunk/unittests/Lex/LexerTest.cpp (original)
> +++ cfe/trunk/unittests/Lex/LexerTest.cpp Wed Apr 23 14:04:32 2014
> @@ -29,20 +29,22 @@ using namespace clang;
>  namespace {
>
>  class VoidModuleLoader : public ModuleLoader {
> -  virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,
> -                                      ModuleIdPath Path,
> -                                      Module::NameVisibilityKind
> Visibility,
> -                                      bool IsInclusionDirective) {
> +  ModuleLoadResult loadModule(SourceLocation ImportLoc,
> +                              ModuleIdPath Path,
> +                              Module::NameVisibilityKind Visibility,
> +                              bool IsInclusionDirective) override {
>      return ModuleLoadResult();
>    }
>
> -  virtual void makeModuleVisible(Module *Mod,
> -                                 Module::NameVisibilityKind Visibility,
> -                                 SourceLocation ImportLoc,
> -                                 bool Complain) { }
> +  void makeModuleVisible(Module *Mod,
> +                         Module::NameVisibilityKind Visibility,
> +                         SourceLocation ImportLoc,
> +                         bool Complain) override { }
>
> -  virtual GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation
> TriggerLoc)
> +  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)
> override
>      { return 0; }
> +  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc)
> override
> +    { return 0; };
>  };
>
>  // The test fixture.
>
> Modified: cfe/trunk/unittests/Lex/PPCallbacksTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPCallbacksTest.cpp?rev=207011&r1=207010&r2=207011&view=diff
>
> ==============================================================================
> --- cfe/trunk/unittests/Lex/PPCallbacksTest.cpp (original)
> +++ cfe/trunk/unittests/Lex/PPCallbacksTest.cpp Wed Apr 23 14:04:32 2014
> @@ -34,20 +34,22 @@ namespace {
>
>  // Stub out module loading.
>  class VoidModuleLoader : public ModuleLoader {
> -  virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,
> -                                      ModuleIdPath Path,
> -                                      Module::NameVisibilityKind
> Visibility,
> -                                      bool IsInclusionDirective) {
> +  ModuleLoadResult loadModule(SourceLocation ImportLoc,
> +                              ModuleIdPath Path,
> +                              Module::NameVisibilityKind Visibility,
> +                              bool IsInclusionDirective) override {
>      return ModuleLoadResult();
>    }
>
> -  virtual void makeModuleVisible(Module *Mod,
> -                                 Module::NameVisibilityKind Visibility,
> -                                 SourceLocation ImportLoc,
> -                                 bool Complain) { }
> +  void makeModuleVisible(Module *Mod,
> +                         Module::NameVisibilityKind Visibility,
> +                         SourceLocation ImportLoc,
> +                         bool Complain) override { }
>
> -  virtual GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation
> TriggerLoc)
> +  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)
> override
>      { return 0; }
> +  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc)
> override
> +    { return 0; };
>  };
>
>  // Stub to collect data from InclusionDirective callbacks.
>
> Modified: cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp?rev=207011&r1=207010&r2=207011&view=diff
>
> ==============================================================================
> --- cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp (original)
> +++ cfe/trunk/unittests/Lex/PPConditionalDirectiveRecordTest.cpp Wed Apr
> 23 14:04:32 2014
> @@ -53,20 +53,22 @@ protected:
>  };
>
>  class VoidModuleLoader : public ModuleLoader {
> -  virtual ModuleLoadResult loadModule(SourceLocation ImportLoc,
> -                                      ModuleIdPath Path,
> -                                      Module::NameVisibilityKind
> Visibility,
> -                                      bool IsInclusionDirective) {
> +  ModuleLoadResult loadModule(SourceLocation ImportLoc,
> +                              ModuleIdPath Path,
> +                              Module::NameVisibilityKind Visibility,
> +                              bool IsInclusionDirective) override {
>      return ModuleLoadResult();
>    }
>
> -  virtual void makeModuleVisible(Module *Mod,
> -                                 Module::NameVisibilityKind Visibility,
> -                                 SourceLocation ImportLoc,
> -                                 bool Complain) { }
> +  void makeModuleVisible(Module *Mod,
> +                         Module::NameVisibilityKind Visibility,
> +                         SourceLocation ImportLoc,
> +                         bool Complain) override { }
>
> -  virtual GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation
> TriggerLoc)
> +  GlobalModuleIndex *loadGlobalModuleIndex(SourceLocation TriggerLoc)
> override
>      { return 0; }
> +  bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc)
> override
> +    { return 0; };
>  };
>
>  TEST_F(PPConditionalDirectiveRecordTest, PPRecAPI) {
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140423/5e9d840e/attachment.html>


More information about the cfe-commits mailing list