diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-04-03 23:06:26 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-04-03 23:06:26 +0000 |
commit | 96df3562752e13237df051469271f8999ad60fe6 (patch) | |
tree | 06ccb2f94fe625a5d5822b2618f01d806c0f25cb /lib | |
parent | 5b8d0af4234252b38229a5bae1d615ac9769f73f (diff) |
<rdar://problem/13560075> Teach name lookup for builtin names to find hidden declarations.
Normal name lookup ignores any hidden declarations. When name lookup
for builtin declarations fails, we just synthesize a new
declaration at the point of use. With modules, this could lead to
multiple declarations of the same builtin, if one came from a (hidden)
submodule that was later made visible. Teach name lookup to always
find builtin names, so we don't create these redundant declarations in
the first place.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178711 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 2b3ca3f0ef..f26b8ed7f7 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -287,10 +287,10 @@ void LookupResult::configure() { IDNS = getIDNS(LookupKind, SemaRef.getLangOpts().CPlusPlus, isForRedeclaration()); - // If we're looking for one of the allocation or deallocation - // operators, make sure that the implicitly-declared new and delete - // operators can be found. if (!isForRedeclaration()) { + // If we're looking for one of the allocation or deallocation + // operators, make sure that the implicitly-declared new and delete + // operators can be found. switch (NameInfo.getName().getCXXOverloadedOperator()) { case OO_New: case OO_Delete: @@ -302,6 +302,15 @@ void LookupResult::configure() { default: break; } + + // Compiler builtins are always visible, regardless of where they end + // up being declared. + if (IdentifierInfo *Id = NameInfo.getName().getAsIdentifierInfo()) { + if (unsigned BuiltinID = Id->getBuiltinID()) { + if (!SemaRef.Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID)) + AllowHidden = true; + } + } } } |