summaryrefslogtreecommitdiffstats
path: root/include/clang/Sema/Lookup.h
Commit message (Collapse)AuthorAgeFilesLines
* Fix implementation of [temp.local]p4.Richard Smith2019-02-151-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | When a template-name is looked up, we need to give injected-class-name declarations of class templates special treatment, as they denote a template rather than a type. Previously we achieved this by applying a filter to the lookup results after completing name lookup, but that is incorrect in various ways, not least of which is that it lost all information about access and how members were named, and the filtering caused us to generally lose all ambiguity errors between templates and non-templates. We now preserve the lookup results exactly, and the few places that need to map from a declaration found by name lookup into a declaration of a template do so explicitly. Deduplication of repeated lookup results of the same injected-class-name declaration is done by name lookup instead of after the fact. This reinstates r354091, which was previously reverted in r354097 because it exposed bugs in lldb and compiler-rt. Those bugs were fixed in r354173 and r354174 respectively. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354176 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Fix implementation of [temp.local]p4."Francis Visoiu Mistrih2019-02-151-17/+2
| | | | | | | | | This reverts commit 40bd10b770813bd1471d46f514545437516aa4ba. This seems to now emit an error when building the sanitizer tests: http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354097 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix implementation of [temp.local]p4.Richard Smith2019-02-151-2/+17
| | | | | | | | | | | | | | | | | | | | When a template-name is looked up, we need to give injected-class-name declarations of class templates special treatment, as they denote a template rather than a type. Previously we achieved this by applying a filter to the lookup results after completing name lookup, but that is incorrect in various ways, not least of which is that it lost all information about access and how members were named, and the filtering caused us to generally lose all ambiguity errors between templates and non-templates. We now preserve the lookup results exactly, and the few places that need to map from a declaration found by name lookup into a declaration of a template do so explicitly. Deduplication of repeated lookup results of the same injected-class-name declaration is done by name lookup instead of after the fact. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354091 91177308-0d34-0410-b5e6-96231b3b80d8
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove trailing space in rC343150Fangrui Song2018-09-261-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343152 91177308-0d34-0410-b5e6-96231b3b80d8
* Init LookupResult::AmbiguityKindVitaly Buka2018-09-261-1/+3
| | | | | | | | We don't expect useful value there unless it's "ambiguous". However we use read it for copying and moving, so we need either init the field add login to avoid reading invalid values. Such reads trigger ubsan errors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343150 91177308-0d34-0410-b5e6-96231b3b80d8
* Annotate LookupResult::clear() as LLVM_ATTRIBUTE_REINITIALIZES to silence ↵Fangrui Song2018-09-251-1/+1
| | | | | | | | | | | | | | bugprone-use-after-move after rC342925 Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52446 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342950 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove trailing spaceFangrui Song2018-07-301-5/+5
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-48/+48
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@331834 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-02-211-63/+49
| | | | | | other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325659 91177308-0d34-0410-b5e6-96231b3b80d8
* [Sema] Add visited contexts to CodeCompleteContextHaojian Wu2018-01-171-0/+6
| | | | | | | | | | | | | | | | | | | Summary: This would allow code completion clients to know which context is visited during Sema code completion. Also some changes: * add `EnteredContext` callback in VisibleDeclConsumer. * add a simple unittest for sema code completion (only for visited contexts at the moment). Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: mgorny, bkramer, cfe-commits Differential Revision: https://reviews.llvm.org/D42071 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322661 91177308-0d34-0410-b5e6-96231b3b80d8
* [Modules TS] Module ownership semantics for redeclarations.Richard Smith2017-10-101-3/+22
| | | | | | | | | | | | | | | | | | When declaring an entity in the "purview" of a module, it's never a redeclaration of an entity in the purview of a default module or in no module ("in the global module"). Don't consider those other declarations as possible redeclaration targets if they're not visible, and reject any cases where we pick a prior visible declaration that violates this rule. This reinstates r315251 and r315256, reverted in r315309 and r315308 respectively, tweaked to avoid triggering a linkage calculation when declaring implicit special members (this exposed our pre-existing issue with typedef names for linkage changing the linkage of types whose linkage has already been computed and cached in more cases). A testcase for that regression has been added in r315366. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315379 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "[Modules TS] Module ownership semantics for redeclarations."Eric Liu2017-10-101-22/+3
| | | | | | This reverts commit r315251. See the original commit thread for reason. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315309 91177308-0d34-0410-b5e6-96231b3b80d8
* [Modules TS] Module ownership semantics for redeclarations.Richard Smith2017-10-091-3/+22
| | | | | | | | | | | When declaring an entity in the "purview" of a module, it's never a redeclaration of an entity in the purview of a default module or in no module ("in the global module"). Don't consider those other declarations as possible redeclaration targets if they're not visible, and reject any cases where we pick a prior visible declaration that violates this rule. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@315251 91177308-0d34-0410-b5e6-96231b3b80d8
* Change enumerator default linkage type for CBruno Cardoso Lopes2017-07-011-1/+1
| | | | | | | | | | | | | | | Redeclaration lookup should never find hidden enumerators in C, because they do not have linkage (C11 6.2.2/6) The linkage of an enumerator should be VisibleNoLinkage, and isHiddenDeclarationVisible should be checking hasExternalFormalLinkage. This is was reviewed as part of D31778, but splitted into a different commit for clarity. rdar://problem/31909368 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306917 91177308-0d34-0410-b5e6-96231b3b80d8
* Ambiguity might be also uninitialized. Use llvm::Optional.Vassil Vassilev2017-06-301-2/+5
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306809 91177308-0d34-0410-b5e6-96231b3b80d8
* Initialize variable and silence potentially uninitialized warning.Vassil Vassilev2017-06-291-2/+1
| | | | | | | Patch by Liza Sakellari! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@306692 91177308-0d34-0410-b5e6-96231b3b80d8
* Spelling mistakes in comments. NFCI. (PR27635)Simon Pilgrim2017-03-301-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299083 91177308-0d34-0410-b5e6-96231b3b80d8
* Change ADL to produce lookup results in a deterministic order. This fixes someRichard Smith2016-03-241-17/+11
| | | | | | | | rare issues with nondeterministic diagnostic order, and some very common issues with nondeterministic module builds. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264323 91177308-0d34-0410-b5e6-96231b3b80d8
* Make LookupResult movable again.Benjamin Kramer2016-03-181-0/+38
| | | | | | | | | We lost copy semantics in r263730, because it only worked for a few very specific cases. Move semantics don't have this issue. Sadly the implementation is a bit messy but I don't know how to clean it up without losing support for msvc 2013 :/ git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263785 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix implicit copy ctor and copy assignment operator warnings when ↵David Blaikie2016-03-171-0/+5
| | | | | | | | | | | | | -Wdeprecated passed. Fix implicit copy ctor and copy assignment operator warnings when -Wdeprecated passed. Patch by Don Hinton! Differential Revision: http://reviews.llvm.org/D18123 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263730 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve AST dumping:Richard Smith2016-01-121-0/+1
| | | | | | | | | 1) When dumping a declaration that declares a name for a type, also dump the named type. 2) Add a #pragma clang __debug dump X, that dumps the lookup results for X in the current context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257529 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] When a declaration has non-trivial visibility, check whether it'sRichard Smith2015-11-131-2/+1
| | | | | | | | actually hidden before we check its linkage. This avoids computing the linkage "too early" for an anonymous struct with a typedef name for linkage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253012 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Simplify and generalize the existing rule for finding hiddenRichard Smith2015-11-121-25/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | declarations in redeclaration lookup. A declaration is now visible to lookup if: * It is visible (not in a module, or in an imported module), or * We're doing redeclaration lookup and it's externally-visible, or * We're doing typo correction and looking for unimported decls. We now support multiple modules having different internal-linkage or no-linkage definitions of the same name for all entities, not just for functions, variables, and some typedefs. As previously, if multiple such entities are visible, any attempt to use them will result in an ambiguity error. This patch fixes the linkage calculation for a number of entities where we previously didn't need to get it right (using-declarations, namespace aliases, and so on). It also classifies enumerators as always having no linkage, which is a slight deviation from the C++ standard's definition, but not an observable change outside modules (this change is being discussed on the -core reflector currently). This also removes the prior special case for tag lookup, which made some cases of this work, but also led to bizarre, bogus "must use 'struct' to refer to type 'Foo' in this scope" diagnostics in C++. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252960 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Make sure we make hidden UsingShadowDecls visible to redeclarationRichard Smith2015-09-151-1/+1
| | | | | | | lookup for the UsingShadowDecls themselves. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247714 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] A using-declaration doesn't introduce a new entity, just a new nameRichard Smith2015-09-151-0/+5
| | | | | | | | for an existing entity, and as such a using-declaration doesn't need to conflict with a hidden entity (nor vice versa). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247654 91177308-0d34-0410-b5e6-96231b3b80d8
* Wdeprecated: Make Filter safely move constructible.David Blaikie2015-08-131-0/+5
| | | | | | | | makeFilter returns Filters by value which seems to be only safe when the copy doesn't occur and RVO kicks in. Make the object safely movable to support this more reliably. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244983 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] In C++, stop serializing and deserializing a list of declarations inRichard Smith2015-07-211-5/+18
| | | | | | | | | | the identifier table. This is redundant, since the TU-scope lookups are also serialized as part of the TU DeclContext, and wasteful in a number of ways. We still emit the decls for PCH / preamble builds, since for those we want identical results, not merely semantically equivalent ones. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242855 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240353 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240270 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Track all default template arguments for a given parameter acrossRichard Smith2015-06-101-6/+2
| | | | | | | | modules, and allow use of a default template argument if any of the parameters providing it is visible. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239485 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Fix some visibility issues with default template arguments.Richard Smith2015-06-091-2/+6
| | | | | | | | | | | | | | | | | | | | There are still problems here, but this is a better starting point. The main part of the change is: when doing a lookup that would accept visible or hidden declarations, prefer to produce the latest visible declaration if there are any visible declarations, rather than always producing the latest declaration. Thus, when we inherit default arguments (and other properties) from a previous declaration, we inherit them from the previous visible declaration; if the previous declaration is hidden, we already suppress inheritance of default arguments. There are a couple of other changes here that fix latent bugs exposed by this change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239371 91177308-0d34-0410-b5e6-96231b3b80d8
* [modules] Handle defining a class template on top of an existing ↵Richard Smith2015-03-271-3/+0
| | | | | | imported-but-not-visible definition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233341 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove decltype in an attempt to fix the MSVC build.Benjamin Kramer2015-02-011-4/+4
| | | | | | C++ is hard, attempt #1 of n. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227768 91177308-0d34-0410-b5e6-96231b3b80d8
* Reimplement iterator wrappers on top of llvm::iterator_adaptor_base.Benjamin Kramer2015-02-011-12/+8
| | | | | | Eliminates a ton of boilerplate proxying the iterator methods. NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227764 91177308-0d34-0410-b5e6-96231b3b80d8
* Make LookupResult be copyable to avoid decomposing an existing one andKaelyn Takata2014-11-111-9/+9
| | | | | | initializing a new one every time a copy is needed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221724 91177308-0d34-0410-b5e6-96231b3b80d8
* Suppress defined-but-unused warningsJingyue Wu2014-10-031-0/+1
| | | | | | | by adding a fake use git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219029 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't load ill-formed AmbiguityKind in Sema::Lookup.Alexey Samsonov2014-08-281-1/+7
| | | | | | | This bug was reported by UBSan. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216695 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'Craig Topper2014-05-061-13/+13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208063 91177308-0d34-0410-b5e6-96231b3b80d8
* Eliminate the last trivial NDEBUG uses in clang headersAlp Toker2013-12-071-8/+2
| | | | | | assert(sanity()) reads so much better than preprocessor conditional blocks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196657 91177308-0d34-0410-b5e6-96231b3b80d8
* Make ADLResult::iterator a proper iterator.Benjamin Kramer2013-11-041-2/+3
| | | | | | PR17796. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193986 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch the semantic DeclContext for a block-scope declaration of a function orRichard Smith2013-09-201-0/+7
| | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191064 91177308-0d34-0410-b5e6-96231b3b80d8
* During typo correction, check for an exact match in an unimported module. If weRichard Smith2013-08-201-0/+5
| | | | | | | find one, then report the error as a missing import instead of as a typo. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188821 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix indentation.Richard Smith2013-08-171-25/+25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188603 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix implementation of C11 6.2.7/4 and C++11 [dcl.array]p3:Richard Smith2013-08-131-4/+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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188307 91177308-0d34-0410-b5e6-96231b3b80d8
* When we perform dependent name lookup during template instantiation, it's notRichard Smith2013-07-251-12/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187167 91177308-0d34-0410-b5e6-96231b3b80d8
* Unresolved lookups can have using declarations that refer toDouglas Gregor2013-01-301-1/+1
| | | | | | | unresolved using declarations. Fixes PR14768 / <rdar://problem/13030296>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173883 91177308-0d34-0410-b5e6-96231b3b80d8
* Provide Decl::getOwningModule(), which determines the (sub)module inDouglas Gregor2013-01-121-4/+17
| | | | | | | | | | | | | | | which a particular declaration resides. Use this information to customize the "definition of 'blah' must be imported from another module" diagnostic with the module the user actually has to import. Additionally, recover by importing that module, so we don't complain about other names in that module. Still TODO: coming up with decent Fix-Its for these cases, and expand this recovery approach for other name lookup failures. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172290 91177308-0d34-0410-b5e6-96231b3b80d8
* Sort #include lines for all files under include/...Chandler Carruth2012-12-041-1/+1
| | | | | | | This is a simpler sort, entirely automatic with the help of llvm/utils/sort_includes.py -- no manual edits here. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169238 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8