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 | 151976694a8e63bb6ff5e280d77371a9490b9413 (patch) | |
tree | c6cba7c16dcc09bedff10266bba0c3f186ccae1f /clang/lib/Sema/SemaLookup.cpp | |
parent | 54dc7fdefb05ce04e7864335e231c4f597967b6d (diff) | |
download | bcm5719-llvm-151976694a8e63bb6ff5e280d77371a9490b9413.tar.gz bcm5719-llvm-151976694a8e63bb6ff5e280d77371a9490b9413.zip |
<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.
llvm-svn: 178711
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 2b3ca3f0ef7..f26b8ed7f7a 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/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; + } + } } } |