r206977 - Initial implementation of -modules-earch-all option, for searching for symbols in non-imported modules.
John Thompson
john.thompson.jtsoftware at gmail.com
Wed Apr 23 10:13:58 PDT 2014
>
> >
> ==============================================================================
> > --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
> > +++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Apr 23 07:57:01 2014
> > @@ -23,6 +23,9 @@
> > #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"
> > #include "clang/Sema/Overload.h"
> > @@ -32,6 +35,8 @@
> > #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"
> > @@ -3924,6 +3929,7 @@ TypoCorrection Sema::CorrectTypo(const D
> > Sema::LookupNameKind LookupKind,
> > Scope *S, CXXScopeSpec *SS,
> > CorrectionCandidateCallback &CCC,
> > + CorrectTypoKind Mode,
> > DeclContext *MemberContext,
> > bool EnteringContext,
> > const ObjCObjectPointerType *OPT,
> > @@ -3978,10 +3984,36 @@ TypoCorrection Sema::CorrectTypo(const D
> > if (getLangOpts().AltiVec && Typo->isStr("vector"))
> > return TypoCorrection();
> >
> > - NamespaceSpecifierSet Namespaces(Context, CurContext, SS);
> > -
> > 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))
> {
>
> This introduces a cyclic dependency from clangSema to clangSerialization,
> breaking the shared cmake build.
>
> - Ben
>
> > + TypoCorrection TC(TypoName.getName(), (NestedNameSpecifier *)0,
> 0);
> > + TC.setCorrectionRange(SS, TypoName);
> > + TC.setRequiresImport(true);
> > + }
> > + }
> > + }
> > +
>
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
Sorry about that. I'm going to refactor it with a callback.
-John
--
John Thompson
John.Thompson.JTSoftware at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140423/401802f3/attachment.html>
More information about the cfe-commits
mailing list