aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaLookup.cpp
AgeCommit message (Collapse)Author
2010-05-20Reinstate r104117, Chandler Carruth's change that "[provides] a namingDouglas Gregor
class for UnresolvedLookupExprs, even when occuring on template names" along with a fix for an Objective-C++ crasher it introduced. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104277 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-20Remove accidental commitDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104207 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-20Various small fixes for construction/destruction of Objective-C++Douglas Gregor
instance variables: - Use isRecordType() rather than isa<RecordType>(), so that we see through typedefs in ivar types. - Mark the destructor as referenced - Perform C++ access control on the destructor git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104206 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-19Revert r104117, "Provide a naming class for UnresolvedLookupExprs, even whenDaniel Dunbar
occuring on..." which breaks some Objective-C code. Working on getting a test case... git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104150 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-19Provide a naming class for UnresolvedLookupExprs, even when occuring onChandler Carruth
template names. We were completely missing naming classes for many unqualified lookups, but this didn't trigger code paths that need it. This removes part of an optimization that re-uses the template name lookup done by the parser to determine if explicit template arguments actually form a template-id. Unfortunately the technique for avoiding the duplicate lookup lost needed data such as the class context in which the lookup succeeded. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104117 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18Give a slight edge to the context-sensitive keyword 'super' overDouglas Gregor
non-function-local declarations with names similar to what the user typed. For example, this allows us to correct 'supper' to 'super' in an Objective-C message send, even though the C function 'isupper' has the same edit distance. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104023 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18Tweak typo-correction logic a bit regarding "super", so that weDouglas Gregor
consider "super" as a candidate whenever we're parsing an expression within an Objective-C method in an interface that has a superclass. At some point, we'd like to give "super" a little edge over non-local names; that will come later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104022 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-14Make sure to search semantic scopes and appropriate template-parameterDouglas Gregor
scopes during unqualified name lookup that has fallen out to namespace scope. Fixes PR7133. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103766 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-01It turns out that basically every caller to RequireCompleteDeclContextJohn McCall
already knows what context it's looking in. Just pass that context in instead of (questionably) recalculating it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102818 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30Fix ADL for types declared in transparent decls, from Alp Toker!Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102695 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-25When name lookup finds a single declaration that was imported via aDouglas Gregor
using declaration, look at its underlying declaration to determine the lookup result kind (e.g., overloaded, unresolved). Fixes at least one issue in Boost.Bimap. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102317 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-25When performing name lookup for an operator name, be sure to lookDouglas Gregor
through using declarations. Fixes ~18 tests in Boost.Fusion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102311 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24Recommit r102215, this time being more careful to only set the "principalJohn McCall
declaration" (i.e. the only which will actually be looked up) to have the non-member-operator bit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102231 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-24Revert r102215. This causes clang crash while compiling a test case from gdb ↵Devang Patel
testsuite. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102224 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23Transition the last acceptable-result filter kind in LookupResult over to useJohn McCall
a simple IDNS mask by introducing a namespace for non-member operators. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102215 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23Recommit my change to how C++ does elaborated type lookups, now withJohn McCall
two bugfixes which fix selfhost and (hopefully) the nightly tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102198 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23Revert "C++ doesn't really use "namespaces" for different kinds of names the ↵Daniel Dunbar
same", which seems to break most C++ nightly test apps. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102174 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-23C++ doesn't really use "namespaces" for different kinds of names the sameJohn McCall
way that C does. Among other differences, elaborated type specifiers are defined to skip "non-types", which, as you might imagine, does not include typedefs. Rework our use of IDNS masks to capture the semantics of different kinds of declarations better, and remove most current lookup filters. Removing the last remaining filter is more complicated and will happen in a separate patch. Fixes PR 6885 as well some spectrum of unfiled bugs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102164 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-22Kill off IDNS_ObjCImplementation and IDNS_ObjCCategoryName; theyDouglas Gregor
aren't and never were used. There's a gap in the bit pattern for IDNS now, but I'm sure *someone* will fill it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102143 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19When searching for code-completion and typo-correction candidates,Douglas Gregor
look from an Objective-C class or category to its implementation, to pick up synthesized ivars. Fixes a problem reported by David Chisnall. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101792 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15Feed proper source-location information into Sema::LookupSingleResult,Douglas Gregor
in case it ends up doing something that might trigger diagnostics (template instantiation, ambiguity reporting, access reporting). Noticed while working on PR6831. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101412 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14Teach typo correction about various language keywords. We can'tDouglas Gregor
generally recover from typos in keywords (since we would effectively have to mangle the token stream). However, there are still benefits to typo-correcting with keywords: - We don't make stupid suggestions when the user typed something that is similar to a keyword. - We can suggest the keyword in a diagnostic (did you mean "static_cast"?), even if we can't recover and therefore don't have a fix-it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101274 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14Return the corrected DeclarationName from Sema::CorrectTypo ratherDouglas Gregor
than just a bool indicating that correction occurred. No actual functionality change (it's still always used like a bool), but this refactoring will be used to support typo correction to keywords. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101259 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08Make CXXScopeSpec invalid when incomplete, and propagate that into anyJeffrey Yasskin
Declarator that depends on it. This fixes several redundant errors and bad recoveries. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100779 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30the big refactoring bits of PR3782.Rafael Espindola
This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99920 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24When performing name lookup for the allocation or deallocationDouglas Gregor
operators, make sure that the implicitly-declared global new and delete operators are always available. Fixes PR5904. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99382 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-18When elevating access along an inheritance path, initialize the computedJohn McCall
access to the (elevated) access of the accessed declaration, if applicable, rather than plunking that access onto the end after we've calculated the inheritance access. Also, being a friend of a derived class gives you public access to its members (subject to later modification by further inheritance); it does not simply ignore a single location of restricted inheritance. Also, when computing the best unprivileged path to a subobject, preserve the information that the worst path might be AS_none (forbidden) rather than a minimum of AS_private. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98899 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-15During C++ name lookup, use DeclContext::Equals() rather thanDouglas Gregor
comparing DeclContext pointers, to avoid having to remember to call getPrimaryContext() everywhere. This is the last part PR6594. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98546 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-15Implement C++ [temp.local]p8, which specifies that a templateDouglas Gregor
parameter hides a namespace-scope declararion with the same name in an out-of-line definition of a template. The lookup requires a strange interleaving of lexical and semantic scopes (go C++), which I have not yet handled in the typo correction/code completion path. Fixes PR6594. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98544 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21Eliminate the default arguments to ASTContext::getFunctionType(),Douglas Gregor
fixing up a few callers that thought they were propagating NoReturn information but were in fact saying something about exception specifications. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96766 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19Implement C++ name lookup for instance variables of Objective-C classesDouglas Gregor
from an instance method. Previously, we were following the Objective-C name lookup rules for ivars, which are of course completely different from and incompatible with the Objective-C++ rules. For the record, the Objective-C++ rules are the sane ones. This is another part of <rdar://problem/7660386>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96677 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-12In C++, allow builtins to be referred to via qualified name lookup, e.g.,Douglas Gregor
::__builtin_va_copy Fixes one of the Firefox issues in PR5511. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95966 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-10Improve access control diagnostics. Perform access control on member-pointerJohn McCall
conversions. Fix an access-control bug where privileges were not considered at intermediate points along the inheritance path. Prepare for friends. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95775 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08Thread a source location into the template-argument deduction routines. ThereJohn McCall
may be some other places that could take advantage of this new information, but I haven't really looked yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95600 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05Teach C++ name lookup that it's okay to look in a scope without aDouglas Gregor
context. This happens fairly rarely (which is why we got away with this bug). Fixes PR6184, where we skipped over the template parameter scope while tentatively parsing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95376 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04Fix a crash with ill-formed code within a method in an ill-formedDouglas Gregor
category implementation, which showed up during (attempted) typo correction. Fixes <rdar://problem/7605289>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95334 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04Extract a common structure for holding information about the definitionJohn McCall
of a C++ record. Exposed a lot of problems where various routines were silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order) when presented with a non-definition. Also cuts down on memory usage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95330 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02Add a stop gap to Sema::CorrectTypo() to correct only up to 20 typos.Ted Kremenek
This is to address a serious performance problem observed when running 'clang -fsyntax-only' on really broken source files. In one case, repeatedly calling CorrectTypo() caused one source file to be rejected after 2 minutes instead of 1 second. This patch causes typo correction to take neglible time on that file while still providing correction results for the first 20 cases. I felt this was a reasonable number for moderately broken source files. I don't claim this is the best solution. Comments welcome. It is necessary for us to address this issue because it is a serious performance problem. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95049 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31Return early, reduce indentation, and simplify line breaks. No functionalityChandler Carruth
change. PS: I'm under the impression formatting-only patches don't need pre-commit review, but feel free to yell at me if I should post these first! =D git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94956 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Handle redeclarations found by ADL deterministically and reasonably.John McCall
This solution relies on an O(n) scan of redeclarations, which means it might scale poorly in crazy cases with tons of redeclarations brought in by a ton of distinct associated namespaces. I believe that avoiding this is not worth the common-case cost. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94530 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Allow ADL to find functions imported by using decls. Leave wordy commentJohn McCall
about interaction between ADL and default arguments. Shrug shoulders, commit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94524 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Preserve access bits through overload resolution much better. SomeJohn McCall
general refactoring in operator resolution. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94498 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23Implement elementary access control.John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94268 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20First pass at collecting access-specifier information along inheritance paths.John McCall
Triggers lots of assertions about missing access information; fix them. Will actually consume this information soon. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94038 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20Give UnresolvedSet the ability to store access specifiers for each declaration.John McCall
Change LookupResult to use UnresolvedSet. Also extract UnresolvedSet into its own header and make it templated over an inline capacity. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93959 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15Make LookupResult::resolveKind() robust against NotFoundInCurrentInstantiation.John McCall
Fixes PR 6049. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93557 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15When performing qualified name lookup into the current instantiation,Douglas Gregor
do not look into base classes if there are any dependent base classes. Instead, note in the lookup result that we couldn't look into any dependent bases. Use that new result kind to detect when this case occurs, so that we can fall back to treating the type/value/etc. as a member of an unknown specialization. Fixes an issue where we were resolving lookup at template definition time and then missing an ambiguity at template instantiation time. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93497 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14Switch the remaining code completions over to LookupVisibleDecls,Douglas Gregor
after adding the ability to determine whether our lookup is a base-class lookup. Eliminate CollectMemberLookupResults, since it is no longer used (yay). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93428 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14Move code completion for qualified name lookup (foo::) toDouglas Gregor
LookupVisibleDecls. Also, a function does not hide another function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93421 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14Look through using declarations when determining whether one decl hides anotherDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93378 91177308-0d34-0410-b5e6-96231b3b80d8