Index: cfe/trunk/lib/Sema/SemaLookup.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaLookup.cpp +++ cfe/trunk/lib/Sema/SemaLookup.cpp @@ -3747,20 +3747,19 @@ bool FindHidden); /// \brief Check whether the declarations found for a typo correction are -/// visible, and if none of them are, convert the correction to an 'import -/// a module' correction. +/// visible. Set the correction's RequiresImport flag to true if none of the +/// declarations are visible, false otherwise. static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC) { - if (TC.begin() == TC.end()) - return; - TypoCorrection::decl_iterator DI = TC.begin(), DE = TC.end(); for (/**/; DI != DE; ++DI) if (!LookupResult::isVisible(SemaRef, *DI)) break; - // Nothing to do if all decls are visible. - if (DI == DE) + // No filtering needed if all decls are visible. + if (DI == DE) { + TC.setRequiresImport(false); return; + } llvm::SmallVector NewDecls(TC.begin(), DI); bool AnyVisibleDecls = !NewDecls.empty(); Index: cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h =================================================================== --- cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h +++ cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h @@ -0,0 +1 @@ +struct member; Index: cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap =================================================================== --- cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap +++ cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap @@ -0,0 +1,3 @@ +module "module" { + header "module.h" +} Index: cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp =================================================================== --- cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp +++ cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-name=module -o %T/module.pcm -emit-module %S/Inputs/crash-typo-correction-visibility/module.modulemap +// RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fmodule-file=%T/module.pcm %s -verify + +struct S { + int member; // expected-note {{declared here}} +}; + +int f(...); + +int b = sizeof(f(member)); // expected-error {{undeclared identifier 'member'}}