summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-071-1/+1
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* [C++11] Updating getUsingDirectives to use iterator_range instead of a ↵Aaron Ballman2014-03-071-8/+5
| | | | | | std::pair. llvm-svn: 203239
* [C++11] Replacing iterators redecls_begin() and redecls_end() with ↵Aaron Ballman2014-03-061-3/+2
| | | | | | iterator_range redecls(). Updating all of the usages of the iterators with range-based for loops, which allows the begin/end forms to be removed entirely. llvm-svn: 203179
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-7/+7
| | | | llvm-svn: 202639
* [C++11] Replace llvm::next and llvm::prior with std::next and std::prev.Benjamin Kramer2014-03-021-1/+1
| | | | llvm-svn: 202635
* Don't suggest non-static methods as corrections when they obviouslyKaelyn Uhrain2014-02-281-5/+27
| | | | | | | won't work (i.e. when not doing a member lookup and not in a method from the same class or a descendant class). llvm-svn: 202520
* PR18685: Ignore class template specializations as potentialKaelyn Uhrain2014-02-091-0/+7
| | | | | | | nested-name-specifiers for typos unless the typo already has a nested-name-specifier that is a template specialization. llvm-svn: 201056
* Don't consider records with a NULL identifier as a name for typo correction.Kaelyn Uhrain2014-02-051-1/+1
| | | | | | | | | Because in C++, "anonymous" doesn't mean "nameless" for records. In other words, RecordDecl::isAnonymousStructOrUnion only returns true if the record lacks a name *and* is not used as the type in an object's declaration. llvm-svn: 200868
* Add implicit declarations of allocation functions when looking them up forRichard Smith2014-02-041-21/+19
| | | | | | | | redeclaration, not just when looking them up for a use -- we need the implicit declaration to appropriately check various properties of them (notably, whether they're deleted). llvm-svn: 200729
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-1/+1
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Don't forget about a builtin if we're about to redeclare it and we couldn'tRichard Smith2014-01-221-8/+0
| | | | | | | | | | | | | create an implicit declaration of it (because some type it depends on is unavailable). This had the effect of causing us to not implicitly give it the right attributes. It turns out that glibc's __sigsetjmp is declared before sigjmp_buf is declared, and this resulted in us not implicitly giving it __attribute__((returns_twice)), which in turn resulted in miscompiles in any C code calling glibc's sigsetjmp. (See also the vaguely-related sourceware.org/PR4662.) llvm-svn: 199850
* Introduce and use Decl::getAsFunction() to simplify templated function checksAlp Toker2014-01-221-23/+7
| | | | | | | | | | | | | | Lift the getFunctionDecl() utility out of the parser into a general Decl::getAsFunction() and use it to simplify other parts of the implementation. Reduce isFunctionOrFunctionTemplate() to a simple type check that works the same was as the other is* functions and move unwrapping of shadowed decls to callers so it doesn't get run twice. Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer. There's no need to query when we already know the body can't be skipped. llvm-svn: 199794
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-8/+9
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* Rename language option MicrosoftMode to MSVCCompatAlp Toker2014-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | There's been long-standing confusion over the role of these two options. This commit makes the necessary changes to differentiate them clearly, following up from r198936. MicrosoftExt (aka. fms-extensions): Enable largely unobjectionable Microsoft language extensions to ease portability. This mode, also supported by gcc, is used for building software like FreeBSD and Linux kernel extensions that share code with Windows drivers. MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode): Turn on a special mode supporting 'heinous' extensions for drop-in compatibility with the Microsoft Visual C++ product. Standards-compilant C and C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt. Note that full -fms-compatibility mode is currently enabled by default on the Windows target, which may need tuning to serve as a reasonable default. See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined type_info out of InitializePredefinedMacros' No change in behaviour. llvm-svn: 199209
* Use the appropriate SourceLocation for the template backtrace when doingNick Lewycky2014-01-111-1/+1
| | | | | | template argument deduction. llvm-svn: 198995
* Eliminate the last trivial NDEBUG uses in clang headersAlp Toker2013-12-071-1/+2
| | | | | | assert(sanity()) reads so much better than preprocessor conditional blocks. llvm-svn: 196657
* Sema: Make helper function static.Benjamin Kramer2013-11-011-1/+1
| | | | llvm-svn: 193857
* PR17731: When determining whether a tag and a non-tag were declared in the sameRichard Smith2013-10-301-2/+17
| | | | | | | scope, be careful about function-scope declarations (which are not declared in their semantic context). llvm-svn: 193671
* Allow CorrectTypo to replace CXXScopeSpecifiers that refer to classes.Kaelyn Uhrain2013-10-191-1/+13
| | | | | | | | | | | Now that CorrectTypo knows how to correctly search classes for typo correction candidates, there is no good reason to only replace an existing CXXScopeSpecifier if it refers to a namespace. While the actual enablement was a matter of changing a single comparison, the fallout from enabling the functionality required a lot more code changes (including my two previous commits). llvm-svn: 193020
* Be smarter about deciding to add a leading '::' to aKaelyn Uhrain2013-10-191-22/+49
| | | | | | NestedNameSpecifier that replaces an existing specifier. llvm-svn: 193019
* Merge NamespaceSpecifierSet's AddNamespace and AddRecord as they areKaelyn Uhrain2013-10-191-75/+9
| | | | | | essentially the same. llvm-svn: 193018
* PR17592: Ensure we diagnose shadowing a template parameter with a local externRichard Smith2013-10-161-2/+4
| | | | | | declaration. llvm-svn: 192846
* Fixed code style of my change.Serge Pavlov2013-10-151-1/+1
| | | | llvm-svn: 192708
* Do not use typo correction that is unaccessible.Serge Pavlov2013-10-141-2/+9
| | | | | | | | This patch fixes PR17019. When doing typo correction, Sema::CorrectTypo uses correction already seen for the same typo. This causes problems if that correction is from another scope and cannot be accessed in the current. llvm-svn: 192594
* Convert anachronistic use of 'void *' to 'DeclContext *' in Scope that was a ↵Ted Kremenek2013-10-081-15/+12
| | | | | | holdover from the long-dead Action interface. llvm-svn: 192203
* Add support for WG21 N3599 (literal operator template for strings) as a GNURichard Smith2013-10-071-13/+32
| | | | | | | | | extension. The GCC folks have decided to support this even though the standard committee have not yet approved this feature. Patch by Hristo Venev! llvm-svn: 192128
* Silencing an MSVC warning; SmallSet::count returns a bool instead of a size_t.Aaron Ballman2013-10-051-1/+1
| | | | llvm-svn: 192043
* Speed up CorrectTypo by avoiding lookups on unreasonable candidates.Kaelyn Uhrain2013-10-021-37/+47
| | | | llvm-svn: 191846
* Fix typo correction usage of SemaAccess.cpp.Eli Friedman2013-10-011-1/+1
| | | | | | | | | | When we check access for lookup results, make sure we propagate the result's access to the access control APIs; this can be different from the natural access of the declaration depending on the path used by the lookup. PR17394. llvm-svn: 191726
* Cache the location of failed typo corrections so that typo correctionKaelyn Uhrain2013-09-271-25/+26
| | | | | | isn't repeatedly attempted for the same identifier at the same location. llvm-svn: 191543
* Teach typo correction to look inside of classes like it does namespaces.Kaelyn Uhrain2013-09-261-5/+102
| | | | | | | | | | | | | | | Unlike with namespaces, searching inside of classes requires also checking the access to correction candidates (i.e. don't suggest a correction to a private class member for a correction occurring outside that class and its methods or friends). Included is a small (one line) fix for a bug, that was uncovered while cleaning up the unit tests, where the decls from a TypoCorrection candidate were preserved in new TypoCorrection candidates that are derived (copied) from the old TypoCorrection--notably when creating a new candidate by changing the NestedNameSpecifier associated with the base idenitifer. llvm-svn: 191449
* Switch the semantic DeclContext for a block-scope declaration of a function orRichard Smith2013-09-201-2/+42
| | | | | | | | | | | | | | variable from being the function to being the enclosing namespace scope (in C++) or the TU (in C). This allows us to fix a selection of related issues where we would build incorrect redeclaration chains for such declarations, and fail to notice type mismatches. Such declarations are put into a new IdentifierNamespace, IDNS_LocalExtern, which is only found when searching scopes, and not found when searching DeclContexts. Such a declaration is only made visible in its DeclContext if there are no non-LocalExtern declarations. llvm-svn: 191064
* PR13657 (and duplicates):Richard Smith2013-09-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a comma occurs in a default argument or default initializer within a class, disambiguate whether it is part of the initializer or whether it ends the initializer. The way this works (which I will be proposing for standardization) is to treat the comma as ending the default argument or default initializer if the following token sequence matches the syntactic constraints of a parameter-declaration-clause or init-declarator-list (respectively). This is both consistent with the disambiguation rules elsewhere (where entities are treated as declarations if they can be), and should have no regressions over our old behavior. I think it might also disambiguate all cases correctly, but I don't have a proof of that. There is an annoyance here: because we're performing a tentative parse in a situation where we may not have seen declarations of all relevant entities (if the comma is part of the initializer, lookup may find entites declared later in the class), we need to turn off typo-correction and diagnostics during the tentative parse, and in the rare case that we decide the comma is part of the initializer, we need to revert all token annotations we performed while disambiguating. Any diagnostics that occur outside of the immediate context of the tentative parse (for instance, if we trigger the implicit instantiation of a class template) are *not* suppressed, mirroring the usual rules for a SFINAE context. llvm-svn: 190639
* C++ modules: if a class is defined in multiple modules (for instance, becauseRichard Smith2013-09-091-1/+1
| | | | | | | | | | | | it is an implicit instantiation of a class template specialization), pick the first-loaded definition to be the canonical definition, and merge all other definitions into it. This is still rather incomplete -- we need to extend every form of declaration that can appear within a CXXRecordDecl to be redeclarable if it came from an AST file (this includes fields, enumerators, ...). llvm-svn: 190315
* Removed useless default branch of switch statement.Serge Pavlov2013-08-291-3/+0
| | | | | | The problem was caught by sanitizer build. llvm-svn: 189575
* Change return type of Sema::DiagnoseAmbiguousLookup from bool to void.Serge Pavlov2013-08-291-13/+8
| | | | | | The function always returned true value, which was never used. llvm-svn: 189571
* Delete CC_Default and use the target default CC everywhereReid Kleckner2013-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Makes functions with implicit calling convention compatible with function types with a matching explicit calling convention. This fixes things like calls to qsort(), which has an explicit __cdecl attribute on the comparator in Windows headers. Clang will now infer the calling convention from the declarator. There are two cases when the CC must be adjusted during redeclaration: 1. When defining a non-inline static method. 2. When redeclaring a function with an implicit or mismatched convention. Fixes PR13457, and allows clang to compile CommandLine.cpp for the Microsoft C++ ABI. Excellent test cases provided by Alexander Zinenko! Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1231 llvm-svn: 189412
* Use pop_back_val() instead of both back() and pop_back().Robert Wilhelm2013-08-231-9/+6
| | | | | | No functionality change intended. llvm-svn: 189112
* During typo correction, check for an exact match in an unimported module. If weRichard Smith2013-08-201-8/+116
| | | | | | find one, then report the error as a missing import instead of as a typo. llvm-svn: 188821
* Fix a use-after-free found in libclang when doing code completion. TheChandler Carruth2013-08-181-3/+9
| | | | | | | | | | | | loop processing the candidates can cause new declerations to be added to the context, invalidating lookup_result. To avoid that, make a copy of the list of declarations to iterate over. I don't have a way to check in a test case for this as it involves a giant pile of source code and a generated PCH file used to accelerate code completion, all of this running under ASan. llvm-svn: 188623
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-171-0/+38
| | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. llvm-svn: 188602
* Fix implementation of C11 6.2.7/4 and C++11 [dcl.array]p3:Richard Smith2013-08-131-3/+21
| | | | | | | | | | | | | When a local extern declaration redeclares some other entity, the type of that entity is merged with the prior type if the prior declaration is visible (in C) or is declared in the same scope (in C++). - Make LookupRedeclarationWithLinkage actually work in C++, use it in the right set of cases, and make it track whether it found a shadowed declaration. - Track whether we found a declaration in the same scope (for C++) including across serialization and template instantiation. llvm-svn: 188307
* Add hooks for typo correction to ExternalSemaSource, courtesy of Luke Zarko.Kaelyn Uhrain2013-08-121-0/+8
| | | | llvm-svn: 188196
* Omit llvm:: before ArrayRef, as we have using llvm::ArrayRef in ↵Robert Wilhelm2013-08-091-9/+7
| | | | | | include/clang/Basic/LLVM.h. llvm-svn: 188089
* Implement [class.friend]p11's special name lookup rules for friend declarationsRichard Smith2013-08-091-0/+11
| | | | | | | | of local classes. We were previously handling this by performing qualified lookup within a function declaration(!!); replace it with the proper scope lookup. llvm-svn: 188050
* When we perform dependent name lookup during template instantiation, it's notRichard Smith2013-07-251-31/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sufficient to only consider names visible at the point of instantiation, because that may not include names that were visible when the template was defined. More generally, if the instantiation backtrace goes through a module M, then every declaration visible within M should be available to the instantiation. Any of those declarations might be part of the interface that M intended to export to a template that it instantiates. The fix here has two parts: 1) If we find a non-visible declaration during name lookup during template instantiation, check whether the declaration was visible from the defining module of all entities on the active template instantiation stack. The defining module is not the owning module in all cases: we look at the module in which a template was defined, not the module in which it was first instantiated. 2) Perform pending instantiations at the end of a module, not at the end of the translation unit. This is general goodness, since it significantly cuts down the amount of redundant work that is performed in every TU importing a module, and also implicitly adds the module containing the point of instantiation to the set of modules checked for declarations in a lookup within a template instantiation. There's a known issue here with template instantiations performed while building a module, if additional imports are added later on. I'll fix that in a subsequent commit. llvm-svn: 187167
* Reinstate r186040, with additional fixes and more test coverage (reverted inRichard Smith2013-07-171-2/+10
| | | | | | | | | | | | | r186331). Original commit log: If we friend a declaration twice, that should not make it visible to name lookup in the surrounding context. Slightly rework how we handle friend declarations to inherit the visibility of the prior declaration, rather than setting a friend declaration to be visible whenever there was a prior declaration. llvm-svn: 186546
* Re-revert r86040, which was un-reverted in r186199.Chandler Carruth2013-07-151-9/+2
| | | | | | | | | | | | | | | This breaks the build of basic patterns with repeated friend declarations. See the added test case in SemaCXX/friend.cpp or the test case reported to the original commit log. Original commit log: If we friend a declaration twice, that should not make it visible to name lookup in the surrounding context. Slightly rework how we handle friend declarations to inherit the visibility of the prior declaration, rather than setting a friend declaration to be visible whenever there was a prior declaration. llvm-svn: 186331
* Add 'static' and 'const' qualifiers to some arrays of strings.Craig Topper2013-07-151-3/+3
| | | | llvm-svn: 186314
* Use llvm::array_lengthof to replace sizeof(array)/sizeof(array[0]).Craig Topper2013-07-151-3/+3
| | | | llvm-svn: 186300
OpenPOWER on IntegriCloud