[PATCH] D30963: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls replaced by visible decls.
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 5 15:30:11 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304745: Fix crash when an 'import a module' TypoCorrection has its CorrectionDecls (authored by rsmith).
Changed prior to commit:
https://reviews.llvm.org/D30963?vs=101437&id=101466#toc
Repository:
rL LLVM
https://reviews.llvm.org/D30963
Files:
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.h
cfe/trunk/test/Modules/Inputs/crash-typo-correction-visibility/module.modulemap
cfe/trunk/test/Modules/crash-typo-correction-visibility.cpp
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'}}
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/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/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<NamedDecl*, 4> NewDecls(TC.begin(), DI);
bool AnyVisibleDecls = !NewDecls.empty();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30963.101466.patch
Type: text/x-patch
Size: 2552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170605/d98fa5cb/attachment.bin>
More information about the cfe-commits
mailing list