summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Roll-back r250822.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-201-1/+1
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* No functionality change, just fix whitespace, a typo and remove an unnecessaryNick Lewycky2015-10-181-3/+3
| | | | | | | emacs mode marker. (Changes left behind from another patch that ended up not working out.) llvm-svn: 250666
* Fix Clang-tidy modernize-use-nullptr warnings in source directories; other ↵Hans Wennborg2015-10-061-5/+7
| | | | | | | | | | minor cleanups Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13406 llvm-svn: 249484
* Don't try to get a CXXRecordDecl from a non-class TemplateSpecializationType.Kaelyn Takata2015-10-011-0/+2
| | | | | | | | With -fms-extensions it is possible to have a non-class record that is a template specialization cause an assertion failure via the call to Type::getAsCXXRecordDecl. Fixes PR 24246. llvm-svn: 249090
* [modules] When picking one of two template declarations as a lookup result,Richard Smith2015-09-111-1/+16
| | | | | | | | it's not sufficient to prefer the declaration with more default arguments, or the one that's visible; they might both be visible, but one of them might have a visible default argument where the other has a hidden default argument. llvm-svn: 247486
* Fix access control for lookups using the Microsoft __super extension.John McCall2015-09-091-2/+15
| | | | | | rdar://22464808 llvm-svn: 247207
* [modules] If local submodule visibility is disabled, don't bother checkingRichard Smith2015-08-241-15/+20
| | | | | | whether the owning module of a hidden declaration is visible -- it can't be. llvm-svn: 245822
* Improve the performance of resolving a lookup result. We usually don't need toRichard Smith2015-08-221-4/+37
| | | | | | | pick the most recent declaration, and we can often tell which declaration is more recent without walking the redeclaration chain. Do so when possible. llvm-svn: 245794
* Add support for System z vector language extensionsUlrich Weigand2015-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The z13 vector facility has an associated language extension, closely modeled on AltiVec/VSX. The main differences are: - vector long, vector float and vector pixel are not supported - vector long long and vector double are supported (like VSX) - comparison operators return a vector rather than a scalar integer - shift operators behave like the OpenCL shift operators - vector bool is only supported as argument to certain operators; some operators allow mixing a bool with a non-bool vector This patch adds clang support for the extension. It is closely modelled on the AltiVec support. Similarly to the -faltivec option, there's a new -fzvector option to enable the extensions (as well as an -mzvector alias for compatibility with GCC). There's also a separate LangOpt. The extension as implemented here is intended to be compatible with the -mzvector extension recently implemented by GCC. Based on a patch by Richard Sandiford. Differential Revision: http://reviews.llvm.org/D11001 llvm-svn: 243642
* [modules] When performing redeclaration lookup for a using declaration, preferRichard Smith2015-07-291-26/+58
| | | | | | | | | | UsingShadowDecls over other declarations of the same entity in the lookup results. This ensures that we build correct redeclaration chains for the UsingShadowDecls (otherwise we could see assertions and other misbehavior in modules builds, when merging combines multiple redeclaration chains for the same entity from the same module into one chain). llvm-svn: 243592
* [AST] Turn the callbacks of lookupInBases and forallBases into a function_refBenjamin Kramer2015-07-251-7/+10
| | | | | | | | | This lets us pass functors (and lambdas) without void * tricks. On the downside we can't pass CXXRecordDecl's Find* members (which are now type safe) to lookupInBases directly, but a lambda trampoline is a small price to pay. No functionality change intended. llvm-svn: 243217
* [modules] In C++, stop serializing and deserializing a list of declarations inRichard Smith2015-07-211-7/+19
| | | | | | | | | 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. llvm-svn: 242855
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-3/+3
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-3/+3
| | | | | | | | | | | | 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. llvm-svn: 240270
* [modules] If we merge a template, also track that its parameters are merged soRichard Smith2015-06-171-4/+12
| | | | | | that we know when its default arguments should be visible. llvm-svn: 239936
* [modules] Improve diagnostic for a template-id that's invalid because a defaultRichard Smith2015-06-171-17/+50
| | | | | | argument is not visible. llvm-svn: 239934
* [modules] Better support for redefinitions of an entity from the same module.Richard Smith2015-06-151-17/+46
| | | | | | | Support this across module save/reload and extend the 'missing import' diagnostics with a list of providing modules. llvm-svn: 239750
* [modules] Apply name visibility rules to names found by ADL.Richard Smith2015-06-121-0/+3
| | | | llvm-svn: 239578
* [modules] Track all default template arguments for a given parameter acrossRichard Smith2015-06-101-0/+26
| | | | | | | modules, and allow use of a default template argument if any of the parameters providing it is visible. llvm-svn: 239485
* [modules] Fix some visibility issues with default template arguments.Richard Smith2015-06-091-3/+15
| | | | | | | | | | | | | | | | | | | 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. llvm-svn: 239371
* Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial typesBenjamin Kramer2015-05-291-1/+1
| | | | | | | | | | | | | | | | | | | | If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. llvm-svn: 238601
* [modules] Support merging a parsed default function/template argument with ↵Richard Smith2015-05-201-1/+6
| | | | | | an imported but hidden one. llvm-svn: 237814
* [modules] Add local submodule visibility support for declarations.Richard Smith2015-05-151-20/+95
| | | | | | | | | | | | With this change, enabling -fmodules-local-submodule-visibility results in name visibility rules being applied to submodules of the current module in addition to imported modules (that is, names no longer "leak" between submodules of the same top-level module). This also makes it much safer to textually include a non-modular library into a module: each submodule that textually includes that library will get its own "copy" of that library, and so the library becomes visible no matter which including submodule you import. llvm-svn: 237473
* Refactor: when exposing a definition in some module, provide listeners with theRichard Smith2015-05-151-1/+3
| | | | | | module rather than requiring them to work it out themselves. llvm-svn: 237416
* [modules] Suport for merging a parsed enum definition into an existing ↵Richard Smith2015-05-071-0/+7
| | | | | | imported but not visible definition. llvm-svn: 236690
* Use concrete type instead of auto in for-loop. No functionality change.Richard Trieu2015-04-151-1/+1
| | | | llvm-svn: 234976
* Change range-based for-loops to be -Wrange-loop-analysis clean.Richard Trieu2015-04-151-1/+1
| | | | | | No functionality change. llvm-svn: 234964
* [modules] Allow a function to be redefined if the old definition is not visible.Richard Smith2015-03-271-2/+1
| | | | llvm-svn: 233407
* [modules] Handle defining a class template on top of an existing ↵Richard Smith2015-03-271-2/+18
| | | | | | imported-but-not-visible definition. llvm-svn: 233341
* [modules] Remove redundant import of lexical decls when building a lookup tableRichard Smith2015-03-231-6/+34
| | | | | | | | | | | | | | | for a DeclContext, and fix propagation of exception specifications along redeclaration chains. This reverts r232905, r232907, and r232907, which reverted r232793, r232853, and r232853. One additional change is present here to resolve issues with LLDB: distinguish between whether lexical decls missing from the lookup table are local or are provided by the external AST source, and still look in the external source if that's where they came from. llvm-svn: 232928
* Reverting r232793 until some new LLDB failures are discussedVince Harron2015-03-221-34/+6
| | | | llvm-svn: 232905
* [modules] Remove some redundant work when building a lookup table for a ↵Richard Smith2015-03-201-6/+34
| | | | | | | | | | | | | | | | | | | | | | | | DeclContext. When we need to build the lookup table for a DeclContext, we used to pull in all lexical declarations for the context; instead, just build a lookup table for the local lexical declarations. We previously didn't guarantee that the imported declarations would be in the returned map, but in some cases we'd happen to put them all in there regardless. Now we're even lazier about this. This unnecessary work was papering over some other bugs: - LookupVisibleDecls would use the DC for name lookups in the TU in C, and this was not guaranteed to find all imported names (generally, the DC for the TU in C is not a reliable place to perform lookups). We now use an identifier-based lookup mechanism for this. - We didn't actually load in the list of eagerly-deserialized declarations when importing a module (so external definitions in a module wouldn't be emitted by users of those modules unless they happened to be deserialized by the user of the module). llvm-svn: 232793
* Sema: Replace the SetVector/DenseMap/std::sort combination with a simple ↵Benjamin Kramer2015-03-131-21/+1
| | | | | | | | | | | | std::map This guarantees the order and doesn't increase malloc counts a lot as there are typically very few elements int the map. Provide a little iterator adapter to keep the same interface as we had with the flat sorted list. No functional change intended. llvm-svn: 232173
* [modules] Rework merging of redeclaration chains on module import.Richard Smith2015-03-051-1/+3
| | | | | | | | | | | | | | | | | | | | | | We used to save out and eagerly load a (potentially huge) table of merged formerly-canonical declarations when we loaded each module. This was extremely inefficient in the presence of large amounts of merging, and didn't actually save any merging lookup work, because we still needed to perform name lookup to check that our merged declaration lists were complete. This also resulted in a loss of laziness -- even if we only needed an early declaration of an entity, we would eagerly pull in all declarations that had been merged into it regardless. We now store the relevant fragments of the table within the declarations themselves. In detail: * The first declaration of each entity within a module stores a list of first declarations from imported modules that are merged into it. * Loading that declaration pre-loads those other entities, so that they appear earlier within the redeclaration chain. * The name lookup tables list the most recent local lookup result, if there is one, or all directly-imported lookup results if not. llvm-svn: 231424
* Cleanup: remove artificial division between lookup results and const lookupRichard Smith2015-02-211-2/+2
| | | | | | | results. No-one was ever modifying a lookup result, and it would not be reasonable to do so. llvm-svn: 230123
* PR21857: weaken an incorrect assertion.Richard Smith2015-02-111-2/+12
| | | | llvm-svn: 228785
* [modules] When determining whether a name from a module replaces a name weRichard Smith2015-02-101-0/+5
| | | | | | | | | already have, check whether the name from the module is actually newer than the existing declaration. If it isn't, we might (say) replace a visible declaration with an injected friend, and thus make it invisible (or lose a default argument or an array bound). llvm-svn: 228661
* Update APIs that return a pair of iterators to return an iterator_range instead.Benjamin Kramer2015-02-061-12/+8
| | | | | | Convert uses of those APIs into ranged for loops. NFC. llvm-svn: 228404
* Use the real CXXScopeSpec when setting the correction SourceRange.Kaelyn Takata2015-01-281-1/+1
| | | | | | | | | Otherwise, in the most important case and the only case where SS and TempSS are different (which is when the CXXScopeSpec should be dropped, and TempSS is NULL) the wrong SourceRange will be used in the fixit for the typo correction. Fixes the remaining issue in PR20626. llvm-svn: 227278
* Fix a case where delayed typo correction should have resolved anKaelyn Takata2015-01-161-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ambiguity but wasn't. In the new test case, "click" wasn't being corrected properly because Sema::ClassifyName would call CorrectTypo for "click" then later Sema::DiagnoseEmptyLookup would call CorrectTypoDelayed for the same use of "click" (the former by the parser needing to determine what the identifier is so it knows how to parse the statement, i.e. is it the beginning of a declaration or an expression). CorrectTypo would record that typo correction for "click" failed and CorrectTypoDelayed would see that and not even try to correct the typo, even though in this case CorrectTypo failed due to an ambiguity (both "Click" and "clock" having an edit distance of one from "click") that could be resolved with more information. The fix is two-fold: 1) Have CorrectTypo not record failed corrections if the reason for the failure was two or more corrections with the same edit distance, and 2) Make the CorrectionCandidateCallback used by Parser::ParseCastExpression reject FunctionDecl candidates when the next token after the identifier is a ".", "=", or "->" since functions cannot be assigned to and do not have members that can be referenced. The reason for two correction spots is that from r222549 until r224375 landed, the first correction attempt would fail completely but the second would suggest "clock" while having the note point to the declaration of "Click". llvm-svn: 226334
* Add a new flag, -fspell-checking-limit=<number> to control how many times ↵Nick Lewycky2014-12-161-69/+16
| | | | | | | | we'll do spell checking. Note that spell checking will change the produced AST, so we don't automatically change this value when someone sets -ferror-limit=. With this, merge test typo-correction-pt2.cpp into typo-correction.cpp. Remove Sema::UnqualifiedTyposCorrected, a cache of corrected typos. It would only cache typo corrections that didn't provide ValidateCandidate of which there were few left, and it had a bug when we had the same identifier spelled wrong twice. See the last two tests in typo-correction.cpp for cases this fires. llvm-svn: 224375
* Perform correct lookup when '__super' is used in class with dependent base.Nikola Smiljanic2014-12-011-0/+25
| | | | llvm-svn: 223090
* Correctly set the SourceRange a TypoCorrection will replace.Kaelyn Takata2014-11-201-3/+5
| | | | | | Also clean up TypoCorrection::setCorrectionRange while we're at it. llvm-svn: 222460
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-10/+10
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* Wrap to 80 columns, no behavior change.Nico Weber2014-11-191-1/+2
| | | | llvm-svn: 222315
* Make LookupResult be copyable to avoid decomposing an existing one andKaelyn Takata2014-11-111-6/+6
| | | | | | initializing a new one every time a copy is needed. llvm-svn: 221724
* Add a callback for recovering using a typo correction.Kaelyn Takata2014-10-271-5/+9
| | | | | | | Also keep track of the stack of Exprs visited during the tree transform so the callback can be passed the parent of the TypoExpr. llvm-svn: 220697
* Add simple way for a CorrectionCandidateCallback to reject exactKaelyn Takata2014-10-271-47/+50
| | | | | | | | | | | | | | | matches of the typo. Also be more proactive about checking a correction's visibility so that a correction requiring a module import can be distinguished from the original typo even if it looks identical. Otherwise the correction will be excluded and the diagnostic about needing the module import won't be emitted. Note that no change was made to checkCorrectionVisibility other than moving where it is at in SemaLookup.cpp. llvm-svn: 220696
* Start adding the infrastructure for handling TypoExprs.Kaelyn Takata2014-10-271-104/+213
| | | | | | | | | | | | | | | | Part of the infrastructure is a map from a TypoExpr to the Sema-specific state needed to correct it, along with helpers to ease dealing with the state. The the typo count is propagated up the stack of ExpressionEvaluationContextRecords when one is popped off of to avoid accidentally dropping TypoExprs on the floor. For example, the attempted correction of g() in test/CXX/class/class.mem/p5-0x.cpp happens with an ExpressionEvaluationContextRecord that is popped off the stack prior to ActOnFinishFullExpr being called and the tree transform for TypoExprs being run. llvm-svn: 220695
OpenPOWER on IntegriCloud