[PATCH] D32828: [Modules] Fix conservative assertion for import diagnostics
Bruno Cardoso Lopes via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 16:53:38 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303705: [Modules] Fix overly conservative assertion for import diagnostic (authored by bruno).
Changed prior to commit:
https://reviews.llvm.org/D32828?vs=100016&id=100023#toc
Repository:
rL LLVM
https://reviews.llvm.org/D32828
Files:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/Modules/Inputs/diagnose-missing-import/a.h
cfe/trunk/test/Modules/Inputs/diagnose-missing-import/module.modulemap
cfe/trunk/test/Modules/diagnose-missing-import.m
Index: cfe/trunk/test/Modules/diagnose-missing-import.m
===================================================================
--- cfe/trunk/test/Modules/diagnose-missing-import.m
+++ cfe/trunk/test/Modules/diagnose-missing-import.m
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/diagnose-missing-import \
+// RUN: -Werror=implicit-function-declaration -fsyntax-only \
+// RUN: -fimplicit-module-maps -verify %s
+ at import NCI;
+
+void foo() {
+ XYZLogEvent(xyzRiskyCloseOpenParam, xyzRiskyCloseOpenParam); // expected-error {{implicit declaration of function 'XYZLogEvent'}} expected-error {{declaration of 'XYZLogEvent' must be imported}} expected-error {{declaration of 'xyzRiskyCloseOpenParam' must be imported from module 'NCI.A'}} expected-error {{declaration of 'xyzRiskyCloseOpenParam' must be imported from module 'NCI.A'}}
+}
+
+// expected-note at Inputs/diagnose-missing-import/a.h:5 {{previous declaration is here}}
+// expected-note at Inputs/diagnose-missing-import/a.h:5 {{previous declaration is here}}
+// expected-note at Inputs/diagnose-missing-import/a.h:6 {{previous declaration is here}}
+
Index: cfe/trunk/test/Modules/Inputs/diagnose-missing-import/module.modulemap
===================================================================
--- cfe/trunk/test/Modules/Inputs/diagnose-missing-import/module.modulemap
+++ cfe/trunk/test/Modules/Inputs/diagnose-missing-import/module.modulemap
@@ -0,0 +1,3 @@
+module NCI {
+ explicit module A { header "a.h" }
+}
Index: cfe/trunk/test/Modules/Inputs/diagnose-missing-import/a.h
===================================================================
--- cfe/trunk/test/Modules/Inputs/diagnose-missing-import/a.h
+++ cfe/trunk/test/Modules/Inputs/diagnose-missing-import/a.h
@@ -0,0 +1,8 @@
+#ifndef A_h
+#define A_h
+
+ at class NSString;
+static NSString * const xyzRiskyCloseOpenParam = @"riskyCloseParam";
+static inline void XYZLogEvent(NSString* eventName, NSString* params);
+
+#endif
Index: cfe/trunk/lib/Sema/SemaDecl.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp
+++ cfe/trunk/lib/Sema/SemaDecl.cpp
@@ -16097,7 +16097,8 @@
void Sema::createImplicitModuleImportForErrorRecovery(SourceLocation Loc,
Module *Mod) {
// Bail if we're not allowed to implicitly import a module here.
- if (isSFINAEContext() || !getLangOpts().ModulesErrorRecovery)
+ if (isSFINAEContext() || !getLangOpts().ModulesErrorRecovery ||
+ VisibleModules.isVisible(Mod))
return;
// Create the implicit import declaration.
Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -4933,8 +4933,6 @@
void Sema::diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl,
MissingImportKind MIK, bool Recover) {
- assert(!isVisible(Decl) && "missing import for non-hidden decl?");
-
// Suggest importing a module providing the definition of this entity, if
// possible.
NamedDecl *Def = getDefinitionToImport(Decl);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32828.100023.patch
Type: text/x-patch
Size: 3211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170523/b9107ee0/attachment.bin>
More information about the cfe-commits
mailing list