diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-06-05 22:29:36 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-06-05 22:29:36 +0000 |
commit | 3092d728cd80b2cd234a694120dc05edcb305d4d (patch) | |
tree | a137d97881dae1121ec71f21c63974e701f01f42 /clang/lib/Sema/SemaLookup.cpp | |
parent | effb794346dacae2be07ab8793f529648cfe0bdf (diff) | |
download | bcm5719-llvm-3092d728cd80b2cd234a694120dc05edcb305d4d.tar.gz bcm5719-llvm-3092d728cd80b2cd234a694120dc05edcb305d4d.zip |
Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls
replaced by visible decls.
Make sure that all paths through checkCorrectionVisibility set the
RequiresImport flag appropriately, so we don't end up using a stale value.
Patch by Jorge Gorbe!
Differential Revision: https://reviews.llvm.org/D30963
llvm-svn: 304745
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 1d32e579681..1fb25f4e0e7 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -3747,20 +3747,19 @@ static void LookupPotentialTypoResult(Sema &SemaRef, 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<NamedDecl*, 4> NewDecls(TC.begin(), DI); bool AnyVisibleDecls = !NewDecls.empty(); |