summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-1/+1
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* Fix typos found by http://github.com/lyda/misspell-checkBenjamin Kramer2012-06-021-1/+1
| | | | llvm-svn: 157886
* Don't allow multiple correction candidates that have the same identifierKaelyn Uhrain2012-06-011-25/+53
| | | | | | | | but different nested name specifiers to quietly clobber each other so only one remains if they do not refer to the same NamedDecl. Fixes PR12951. llvm-svn: 157823
* In TypoCorrectionConsumer, BestResults to CorrectionResults to lessenKaelyn Uhrain2012-05-311-14/+19
| | | | | | | | | | the confusion among all of the uses of Best* in relation to the set of possible typo correction results. Also add a method to return the set of typo corrections that have the single best edit distance--it returns the second half of the first pair in TypoEditDistanceMap (with getBestEditDistance already returning the first half). llvm-svn: 157781
* Implement simplify_type traits for redecl_iterator.David Blaikie2012-05-011-1/+1
| | | | | | Based on Chandler Carruth's feedback on r155869. llvm-svn: 155929
* Remove ref/value inconsistency in redecl_iterator.David Blaikie2012-05-011-1/+1
| | | | | | | | | | | | | Similar to r155808 - this mistake has been made in a few iterators. Based on Chandler Carruth's feedback to r155808 I added an implicit conversion to Decl* to ease adoption/usage. Useful for the pointer comparison, but not the dyn_cast (due to template argument deduction causing the conversion not to be used) - there for future convenience, though. This idiom (op T* for iterators) seems to be fairly idiomatic within the LLVM codebase & I'll likely add it as I fix up the other iterators here. llvm-svn: 155869
* Fix bug where a class's (deleted) copy constructor would be implicitly given aRichard Smith2012-04-201-31/+14
| | | | | | | | non-const reference parameter type if the class had any subobjects with deleted copy constructors. This causes a rejects-valid if the class's copy constructor is explicitly defaulted (as happens for some implementations of std::pair etc). llvm-svn: 155218
* Directly store TypoResultsMaps in the TypoEditDistanceMap, getting rid of ↵Benjamin Kramer2012-04-141-27/+15
| | | | | | manual deletion. llvm-svn: 154736
* Delete the TypoResultsMap when erasing the pointer to it.Benjamin Kramer2012-04-131-7/+6
| | | | | | | This manual deleting is error-prone, but we can't just put an OwningPtr in a std::map :( llvm-svn: 154707
* Remove more redundant lookups. Add a new "all_lookups_iterator" which providesNick Lewycky2012-04-031-15/+6
| | | | | | | | a view over the contents of a DeclContext without exposing the implementation details of the StoredDeclsMap. Use this in LookupVisibleDecls to find the visible declarations. Fixes PR12339! llvm-svn: 153970
* Don't treat synthesized ivars as being in the base class for the purpose ofNick Lewycky2012-04-031-5/+5
| | | | | | looking up visible decls. llvm-svn: 153967
* Replace the workaround from r153445 with a proper fix.Kaelyn Uhrain2012-04-031-1/+1
| | | | | | | | | | | | | Infinite recursion was happening when DiagnoseInvalidRedeclaration called ActOnFunctionDeclarator to check if a typo correction works when the correction was just to the nested-name-specifier because the wrong DeclContext was being passed in. Unlike a number of functions surrounding typo correction, the DeclContext passed in for a function is the context of the function name after applying any nested name specifiers, not the lexical DeclContext where the function+nested-name-specifier appears. llvm-svn: 153962
* PR10217: Provide diagnostics explaining why an implicitly-deleted specialRichard Smith2012-03-301-7/+13
| | | | | | member function is deleted. llvm-svn: 153773
* When diagnosing an invalid out-of-line redeclaration, don't permitDouglas Gregor2012-03-261-4/+11
| | | | | | | typo correction to introduce a nested-name-specifier; we aren't prepared to handle it here. Fixes PR12297 / <rdar://problem/11075219>. llvm-svn: 153445
* Support for definitions of member enumerations of class templates outside theRichard Smith2012-03-231-2/+1
| | | | | | | class template's definition, and for explicit specializations of such enum members. llvm-svn: 153304
* It never makes sense to do a lookup into a LinkageSpecDecl, so assert that weNick Lewycky2012-03-131-5/+6
| | | | | | | | | don't, and clean up the places that do it. The change to ASTWriter is surprising, but the deleted code is a no-op as of r152608. llvm-svn: 152609
* Fix PR10447: lazily building name lookup tables for DeclContexts was broken.Richard Smith2012-03-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | The deferred lookup table building step couldn't accurately tell which Decls should be included in the lookup table, and consequently built different tables in some cases. Fix this by removing lazy building of DeclContext name lookup tables. In practice, the laziness was frequently not worthwhile in C++, because we performed lookup into most DeclContexts. In C, it had a bit more value, since there is no qualified lookup. In the place of lazy lookup table building, we simply don't build lookup tables for function DeclContexts at all. Such name lookup tables are not useful, since they don't capture the scoping information required to correctly perform name lookup in a function scope. The resulting performance delta is within the noise on my testing, but appears to be a very slight win for C++ and a very slight loss for C. The C performance can probably be recovered (if it is a measurable problem) by avoiding building the lookup table for the translation unit. llvm-svn: 152608
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-33/+33
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Improve our semantic error recovery.Argyrios Kyrtzidis2012-03-091-4/+0
| | | | | | | | | | | | | | | | | When an error made a record member invalid, the record would stay as "isBeingDefined" and not "completeDefinition". Even easily recoverable errors ended up propagating records in such "beingDefined" state, for example: struct A { ~A() const; // expected-error {{'const' qualifier is not allowed on a destructor}} }; struct B : A {}; // A & B would stay as "not complete definition" and "being defined". This weird state was impending lookups in the records and hitting assertion in the ASTWriter. Part of rdar://11007039 llvm-svn: 152432
* Support for raw and template forms of numeric user-defined literals,Richard Smith2012-03-091-0/+99
| | | | | | and lots of tidying up. llvm-svn: 152392
* Sema: Don't emit a gajillion calls to sanity() -- an empty function -- in NDEBUGDaniel Dunbar2012-03-081-1/+3
| | | | | | builds. Sheesh. llvm-svn: 152279
* ArrayRef'ize various functions in the AST/Parser/Sema.Ahmed Charles2012-02-251-10/+13
| | | | llvm-svn: 151447
* Fix a regression from r151117: ADL requires that we attempt to complete anyRichard Smith2012-02-251-0/+8
| | | | | | | | associated classes, since it can find friend functions declared within them, but overload resolution does not otherwise require argument types to be complete. llvm-svn: 151434
* Replace some DenseSets with SmallPtrSets. Apart from the "small" ↵Benjamin Kramer2012-02-231-4/+3
| | | | | | optimization, the current implementation is also a denser. llvm-svn: 151257
* Initial refactoring of 'ShouldDeleteSpecialMember', in preparation for providingRichard Smith2012-02-181-1/+1
| | | | | | | | | decent diagnostics. Finish the work of combining all the 'ShouldDelete' functions into one. In unifying the code, fix a minor bug where an anonymous union with a deleted default constructor as a member of a union wasn't being considered as making the outer union's default constructor deleted. llvm-svn: 150862
* Silence a valgrind warning, and remove an unused var.Kaelyn Uhrain2012-02-151-3/+2
| | | | llvm-svn: 150629
* Improve typo correction involving nested name specifiers.Kaelyn Uhrain2012-02-151-18/+112
| | | | | | | | | | | | Snooping in other namespaces when the identifier being corrected is already qualified (i.e. a valid CXXScopeSpec is passed to CorrectTypo) and ranking synthesized namespace qualifiers relative to the existing qualifier is now performed. Support for disambiguating the string representation of synthesized namespace qualifers has also been added (the change to test/Parser/cxx-using-directive.cpp is an example of an ambiguous relative qualifier). llvm-svn: 150622
* Use several weighted factors to determine typo candidate viablity.Kaelyn Uhrain2012-02-141-42/+35
| | | | | | | | | | | Replace the simple Levenshtein edit distance for typo correction candidates--and the hacky way adding namespace qualifiers would affect the edit distance--with a synthetic "edit distance" comprised of several factors and their relative weights. This also allows the typo correction callback object to convey more information about the viability of a correction candidate than simply viable or not viable. llvm-svn: 150495
* Remove the unused TypoCorrectionConsumer::MaxEditDistance.Kaelyn Uhrain2012-02-071-37/+13
| | | | | | | | | | | | MaxEditDistance was effectively unused as it being initialized to the max unsigned valued but never updated. Removing it avoids conversion headaches once the "edit distance" of a typo correction is a weighted composite of several values instead of roughly the number of characters changed; comparing the weighted composite value to the number of characters in a typo would require some form of normalization to make it comparable to the old, character-based notion of edit distance. llvm-svn: 149953
* Basic: import OwningPtr<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | llvm-svn: 149798
* Introduce the lambda scope before determining explicit captures, whichDouglas Gregor2012-02-011-0/+1
| | | | | | | | | | | | | cleans up and improves a few things: - We get rid of the ugly dance of computing all of the captures in data structures that clone those of CapturingScopeInfo, centralizing the logic for accessing/updating these data structures - We re-use the existing capture logic for 'this', which actually works now. Cleaned up some diagnostic wording in minor ways as well. llvm-svn: 149516
* Make the callback object to Sema::CorrectTypo mandatory.Kaelyn Uhrain2012-01-311-10/+9
| | | | llvm-svn: 149451
* In CorrectTypo, use the cached correction as a starting point instead.Kaelyn Uhrain2012-01-231-30/+44
| | | | | | | | | | | | | | | | | Previously, for unqualified lookups, a positive cache hit is used as the only non-keyword correction and a negative cache hit immediately returns an empty TypoCorrection. With the new callback objects, this behavior causes false negatives by not accounting for the fact that callback objects alter the set of potential/allowed corrections. The new behavior is to seed the set of corrections with the cached correction (for positive hits) to estabilishing a baseline edit distance. Negative cache hits are only stored or used when either no callback object is provided or when it returns true for a call to ValidateCandidate with an empty TypoCorrection (i.e. when ValidateCandidate does not seem to be doing any checking of the TypoCorrection, such as when an instance of the base callback class is used solely to specify the set of keywords to be accepted). llvm-svn: 148720
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-1/+0
| | | | llvm-svn: 148577
* Remove the now-unused CorrectTypoContext enum.Kaelyn Uhrain2012-01-191-72/+1
| | | | llvm-svn: 148441
* De-virtualize getPreviousDecl() and getMostRecentDecl() when we knowDouglas Gregor2012-01-141-1/+1
| | | | | | | | | | | | we have a redeclarable type, and only use the new virtual versions (getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have that type information. This keeps us from penalizing users with strict type information (and is the moral equivalent of a "final" method). Plus, settle on the names getPreviousDecl() and getMostRecentDecl() throughout. llvm-svn: 148187
* Make sure to consider non-DeclContext scopes properly when findingDouglas Gregor2012-01-131-10/+30
| | | | | | | multiple name lookup results in C/Objective-C. Fixes a regression a caused in r147533, found by Enea Zaffanella! llvm-svn: 148154
* Fix the caching in CorrectTypo so that other non-keyword identifiersKaelyn Uhrain2012-01-111-1/+2
| | | | | | | | | | | | | | are still added if the cached correction fails validation. Also fix a copy-and-paste error in a comment from my previous commit. Finally, add an example of the benefit the typo correction callback adds to TryNamespaceTypoCorrection--which happens to also tickle the above caching problem, as the only way a non-namespace Decl would be added to the possible corrections is if it was cached as the correction for a previous instance of the same typo where the typo was corrected to a non-namespace via a different code path. llvm-svn: 147968
* Add initial callback object support to Sema::CorrectTypo.Kaelyn Uhrain2012-01-111-69/+113
| | | | | | | | | Also includes two examples of the callback: a wrapper/replacement for the CorrectTypoContext enum, and a conversion of the two calls to CorrectTypo in SemaDeclCXX.cpp (one of which provides verifiable improvement to the typo correction, as demonstrated in the added test). llvm-svn: 147962
* Switch NamespaceDecl from its own hand-rolled redeclaration chain overDouglas Gregor2012-01-071-2/+4
| | | | | | | | | | | | to Redeclarable<NamespaceDecl>, so that we benefit from the improveed redeclaration deserialization and merging logic provided by Redeclarable<T>. Otherwise, no functionality change. As a drive-by fix, collapse the "inline" bit into the low bit of the original namespace/anonymous namespace, saving 8 bytes per NamespaceDecl on x86_64. llvm-svn: 147729
* During name lookup, use redecl_iterator to walk over the redeclarationDouglas Gregor2012-01-061-23/+6
| | | | | | | | | | | | | chain to determine whether any declaration of the given entity is visible, eliminating the redundant (and less efficient) getPreviousDeclaration() implementation. This tweak uncovered an omission in the handling of RedeclarableTemplateDecl, where we weren't making sure to search for additional redeclarations of a template in other module files. Things would be cleaner if RedeclarableTemplateDecl actually used Redeclarable. llvm-svn: 147687
* When we're performing name lookup for a tag, we still allow ourselvesDouglas Gregor2012-01-051-2/+2
| | | | | | | | | | | | | | | | | | 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. llvm-svn: 147588
* Implement declaration merging for typedefs loaded from disjointDouglas Gregor2012-01-041-21/+20
| | | | | | | | | | | modules, so long as the typedefs refer to the same underlying type. This ensures that the typedefs end up in the same redeclaration chain. To test this, fix name lookup for C/Objective-C to properly deal with multiple declarations with the same name in the same scope. llvm-svn: 147533
* Minor tweak to name lookup for C/Objective-C: after the first name, still ↵Douglas Gregor2012-01-031-1/+1
| | | | | | consider whether this is a redeclaration lookup when determining whether to look for the visible declaration llvm-svn: 147499
* Test "merging" of typedef types across distinct modules. At present,Douglas Gregor2012-01-031-21/+22
| | | | | | | | | | | | the AST reader doesn't actually perform a merge, because name lookup knows how to merge identical typedefs together. As part of this, teach C/Objective-C name lookup to return multiple results in all cases, rather than first digging through the attributes to see if the value is overloadable. This way, we'll catch ambiguous lookups in C/Objective-C. llvm-svn: 147498
* Eliminate ObjCForwardProtocolDecl, which is redundant now thatDouglas Gregor2012-01-011-12/+0
| | | | | | ObjCProtocolDecl modules forward declarations properly. llvm-svn: 147415
* Wire up redeclaration chains for Objective-C protocols, so that bothDouglas Gregor2012-01-011-2/+3
| | | | | | | forward declarations and definitions of an Objective-C protocol are represented within a single chain of ObjCProtocolDecls. llvm-svn: 147412
* Introduce the core infrastructure needed to model redeclaration chainsDouglas Gregor2012-01-011-0/+2
| | | | | | | | | | | | | | | for Objective-C protocols, including: - Using the first declaration as the canonical declaration - Using the definition as the primary DeclContext - Making sure that all declarations have a pointer to the definition data, and that we know which declaration is the definition - Serialization support for redeclaration chains and for adding definitions to already-serialized declarations. However, note that we're not taking advantage of much of this code yet, because we're still re-using ObjCProtocolDecls. llvm-svn: 147410
* Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDeclDouglas Gregor2011-12-271-6/+0
| | | | | | | covers both declarations (@class) and definitions (@interface) of an Objective-C class. llvm-svn: 147299
* When performing name lookup for a redeclaration, ignore moduleDouglas Gregor2011-12-201-1/+1
| | | | | | | | | | | | | | | | | | | | | visibility restrictions. This ensures that all declarations of the same entity end up in the same redeclaration chain, even if some of those declarations aren't visible. While this may seem unfortunate to some---why can't two C modules have different functions named 'f'?---it's an acknowedgment that a module does not introduce a new "namespace" of names. As part of this, stop merging the 'module-private' bit from previous declarations to later declarations, because we want each declaration in a module to stand on its own because this can effect, for example, submodule visibility. Note that this notion of names that are invisible to normal name lookup but are available for redeclaration lookups is how we should implement friend declarations and extern declarations within local function scopes. I'm not tackling that problem now. llvm-svn: 146980
OpenPOWER on IntegriCloud