to see hidden declarations because every tag lookup is effectively a
redeclaration lookup. For example, image that
struct foo;
is declared in a submodule that is known but hasn't been imported. If
someone later writes
struct foo *foo_p;
then "struct foo" is either a reference or a redeclaration. To keep
the redeclaration chains sound, we treat it like a redeclaration for
name-lookup purposes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147588
91177308-0d34-0410-b5e6-
96231b3b80d8
return Redecl;
}
+ /// \brief Determine whether this lookup is permitted to see hidden
+ /// declarations, such as those in modules that have not yet been imported.
+ bool isHiddenDeclarationVisible() const {
+ return Redecl || LookupKind == Sema::LookupTagName;
+ }
+
/// Sets whether tag declarations should be hidden by non-tag
/// declarations during resolution. The default is true.
void setHideTags(bool Hide) {
if (!D->isInIdentifierNamespace(IDNS))
return 0;
- if (Redecl == Sema::ForRedeclaration || isVisible(D))
+ if (isHiddenDeclarationVisible() || isVisible(D))
return D;
return getAcceptableDeclSlow(D);
// If this declaration is module-private and it came from an AST
// file, we can't see it.
- NamedDecl *D = R.isForRedeclaration()? *I : getVisibleDecl(*I);
+ NamedDecl *D = R.isHiddenDeclarationVisible()? *I : getVisibleDecl(*I);
if (!D)
continue;
if (!LastDC->isFileContext() && !S->isDeclScope(*LastI))
break;
- D = R.isForRedeclaration()? *LastI : getVisibleDecl(*LastI);
+ D = R.isHiddenDeclarationVisible()? *LastI : getVisibleDecl(*LastI);
if (D)
R.addDecl(D);
}
struct explicit_struct { int member; };
#define ONE 1
+
+typedef struct my_struct_type *my_struct_ref;
// RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify
+// RUN: %clang_cc1 -fmodules -fmodule-cache-path %t -Wno-typedef-redefinition -I %S/Inputs %s -verify
// RUN: %clang_cc1 -x objective-c++ -fmodules -fmodule-cache-path %t -I %S/Inputs %s -verify
@class C2;
@class C3;
@class C3;
@import redecl_merge_left;
-
+typedef struct my_struct_type *my_struct_ref;
@protocol P4;
@class C3;
@class C3;