[cfe-commits] r147588 - in /cfe/trunk: include/clang/Sema/Lookup.h lib/Sema/SemaLookup.cpp test/Modules/Inputs/redecl-merge-top-explicit.h test/Modules/redecl-merge.m
Douglas Gregor
dgregor at apple.com
Wed Jan 4 17:11:48 PST 2012
Author: dgregor
Date: Wed Jan 4 19:11:47 2012
New Revision: 147588
URL: http://llvm.org/viewvc/llvm-project?rev=147588&view=rev
Log:
When we're performing name lookup for a tag, we still allow ourselves
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.
Modified:
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h
cfe/trunk/test/Modules/redecl-merge.m
Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=147588&r1=147587&r2=147588&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Wed Jan 4 19:11:47 2012
@@ -214,6 +214,12 @@
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) {
@@ -286,7 +292,7 @@
if (!D->isInIdentifierNamespace(IDNS))
return 0;
- if (Redecl == Sema::ForRedeclaration || isVisible(D))
+ if (isHiddenDeclarationVisible() || isVisible(D))
return D;
return getAcceptableDeclSlow(D);
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=147588&r1=147587&r2=147588&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Wed Jan 4 19:11:47 2012
@@ -1171,7 +1171,7 @@
// 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;
@@ -1194,7 +1194,7 @@
if (!LastDC->isFileContext() && !S->isDeclScope(*LastI))
break;
- D = R.isForRedeclaration()? *LastI : getVisibleDecl(*LastI);
+ D = R.isHiddenDeclarationVisible()? *LastI : getVisibleDecl(*LastI);
if (D)
R.addDecl(D);
}
Modified: cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h?rev=147588&r1=147587&r2=147588&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h (original)
+++ cfe/trunk/test/Modules/Inputs/redecl-merge-top-explicit.h Wed Jan 4 19:11:47 2012
@@ -5,3 +5,5 @@
struct explicit_struct { int member; };
#define ONE 1
+
+typedef struct my_struct_type *my_struct_ref;
Modified: cfe/trunk/test/Modules/redecl-merge.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/redecl-merge.m?rev=147588&r1=147587&r2=147588&view=diff
==============================================================================
--- cfe/trunk/test/Modules/redecl-merge.m (original)
+++ cfe/trunk/test/Modules/redecl-merge.m Wed Jan 4 19:11:47 2012
@@ -1,11 +1,11 @@
// 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;
More information about the cfe-commits
mailing list