r207011 - Quick fix for layering that broke shared library build.
Benjamin Kramer
benny.kra at gmail.com
Wed Apr 23 13:24:02 PDT 2014
On 23.04.2014, at 21:33, Thompson, John <John_Thompson at playstation.sony.com> wrote:
>
>
> -----Original Message-----
> From: Thompson, John
> Sent: Wednesday, April 23, 2014 12:33 PM
> To: 'Benjamin Kramer'; 'Richard Smith'
> Subject: FW: r207011 - Quick fix for layering that broke shared library build.
>
> Hi Benjamin and Richard,
>
> Benjamin, I'm hoping this fixes the broken shared library build. BTW, how do you do a shared library build on Windows?
It's fixed, thanks! I'm afraid that there is no way to build LLVM as a DLL currently, dynamic linking on windows is too different :(
- Ben
>
> Richard, I know this doesn't completely fix the layering problem, as it still needs PP to get the module loader, which I use as a place for the callback. Is this good enough, or should I do a real callback? And by "callback" do you actually mean saving a function pointer, or do you mean just a small class defined in the Sema class that I can derive from and set up in CompilerInstance and store in the Sema object? I first did the latter, but then replaced it with using ModuleLoader as the host for the callback.
>
> Thanks.
>
> -John
>
> -----Original Message-----
> From: cfe-commits-bounces at cs.uiuc.edu [mailto:cfe-commits-bounces at cs.uiuc.edu] On Behalf Of John Thompson
> Sent: Wednesday, April 23, 2014 12:05 PM
> To: cfe-commits at cs.uiuc.edu
> Subject: r207011 - Quick fix for layering that broke shared library build.
>
> 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.
>
> 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);
> }
> }
>
>
> 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
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list