summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprMember.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-18/+18
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [Sema][ObjC] Do not DiagnoseUseOfDecl in LookupMemberExprSteven Wu2018-05-241-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Remove the call to DiagnoseUseOfDecl in LookupMemberExpr because: 1. LookupMemberExpr eagerly lookup both getter and setter, reguardless if they are used or not. It causes wrong diagnostics if you are only using getter. 2. LookupMemberExpr only diagnoses getter, but not setter. 3. ObjCPropertyOpBuilder already DiagnoseUseOfDecl when building getter and setter. Doing it again in LookupMemberExpr causes duplicated diagnostics. rdar://problem/38479756 Reviewers: erik.pilkington, arphaman, doug.gregor Reviewed By: arphaman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D47280 llvm-svn: 333148
* Improve diagnostics and error recovery for template name lookup.Richard Smith2018-05-111-16/+19
| | | | | | | | | | | | | For 'x::template y', consistently give a "no member named 'y' in 'x'" diagnostic if there is no such member, and give a 'template keyword not followed by a template' name error if there is such a member but it's not a template. In the latter case, add a note pointing at the non-template. Don't suggest inserting a 'template' keyword in 'X::Y<' if X is dependent if the lookup of X::Y was actually not a dependent lookup and found only non-templates. llvm-svn: 332076
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-2/+2
| | | | | | | | | | | | | | | | | | | 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 llvm-svn: 331834
* Parse A::template B as an identifier rather than as a template-id with noRichard Smith2018-04-271-7/+7
| | | | | | | | | | template arguments. This fixes some cases where we'd incorrectly accept "A::template B" when B is a kind of template that requires template arguments (in particular, a variable template or a concept). llvm-svn: 331013
* Factor out common code for diagnosing missing template arguments.Richard Smith2018-04-261-7/+3
| | | | | | In passing, add 'concept' to the list of template kinds in diagnostics. llvm-svn: 330890
* [OPENMP] Code cleanup and code improvements.Alexey Bataev2018-04-181-1/+1
| | | | llvm-svn: 330270
* [Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with ↵Eric Fiselier2018-04-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | multiple bases. Summary: Currently clang doesn't do qualified lookup when building indirect field decl references. This causes ambiguity when the field is in a base class to which there are multiple valid paths even though a qualified name is used. For example: ``` class B { protected: int i; union { int j; }; }; class X : public B { }; class Y : public B { }; class Z : public X, public Y { int a() { return X::i; } // works int b() { return X::j; } // fails }; ``` Reviewers: rsmith, aaron.ballman, rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45411 llvm-svn: 329521
* Revert "[Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with ↵Eric Fiselier2018-04-081-1/+1
| | | | | | | | multiple bases." This reverts commit r329519. There are some unaddressed test failures. llvm-svn: 329520
* [Sema] Fix PR35832 - Ambiguity accessing anonymous struct/union with ↵Eric Fiselier2018-04-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | multiple bases. Summary: Currently clang doesn't do qualified lookup when building indirect field decl references. This causes ambiguity when the field is in a base class to which there are multiple valid paths even though a qualified name is used. For example: ``` class B { protected: int i; union { int j; }; }; class X : public B { }; class Y : public B { }; class Z : public X, public Y { int a() { return X::i; } // works int b() { return X::j; } // fails }; ``` Reviewers: rsmith, aaron.ballman, rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45411 llvm-svn: 329519
* [Sema] Remove dead code in BuildAnonymousStructUnionMemberReference. NFCIEric Fiselier2018-04-081-54/+20
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch cleans up a bunch of dead or unused code in BuildAnonymousStructUnionMemberReference. The dead code was a branch that built a new CXXThisExpr when we weren't given a base object expression or base variable. However, BuildAnonymousFoo has only two callers. One of which always builds a base object expression first, the second only calls when the IndirectFieldDecl is not a C++ class member. Even within C this branch seems entirely unused. I tried diligently to write a test which hit it with no success. This patch removes the branch and replaces it with an assertion that we were given either a base object expression or a base variable. Reviewers: rsmith, aaron.ballman, majnemer, rjmccall Reviewed By: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45410 llvm-svn: 329518
* [Sema] Avoid crash for category implementation without interfaceShoaib Meenai2018-03-271-0/+3
| | | | | | | | | | | When we have a category implementation without a corresponding interface (which is an error by itself), semantic checks for property accesses will attempt to access a null interface declaration and then segfault. Error out in such cases instead. Differential Revision: https://reviews.llvm.org/D44916 llvm-svn: 328654
* Avoid including ScopeInfo.h from Sema.hReid Kleckner2018-03-071-2/+3
| | | | | | | | | | | | | | | | | Summary: This provides no measurable build speedup, but it reinstates an optimization from r112038 that was lost in r179618. It requires moving CapturedScopeInfo::Capture out to clang::sema, which might be too general since we have plenty of other Capture records in BlockDecl and other AST nodes. Reviewers: rjmccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44221 llvm-svn: 326957
* Fif for an issue when Clang permits assignment to vector/extvector elements ↵Andrew V. Tischenko2018-02-091-0/+4
| | | | | | in a const method. llvm-svn: 324721
* [NFC] Modernize enum 'UnqualifiedId::IdKind' into a scoped enum ↵Faisal Vali2017-12-301-1/+1
| | | | | | UnqualifiedIdKind. llvm-svn: 321574
* Silence a bunch of implicit fallthrough warningsAdrian Prantl2017-12-191-1/+1
| | | | llvm-svn: 321115
* Fix -Wunused-private-field to fire regardless of which implicit special ↵Richard Smith2017-11-011-1/+3
| | | | | | members have been implicitly declared. llvm-svn: 317076
* [OpenCL] Restrict swizzle length check to OpenCL modeBruno Cardoso Lopes2017-10-171-1/+3
| | | | | | | | | | | Changes behavior introduced in r298369 to only error out on vector component invalid length access on OpenCL mode. Differential Revision: https://reviews.llvm.org/D38868 rdar://problem/33568748 llvm-svn: 316016
* [Modules TS] Module ownership semantics for redeclarations.Richard Smith2017-10-101-2/+1
| | | | | | | | | | | | | | | | | 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. llvm-svn: 315379
* Revert "[Modules TS] Module ownership semantics for redeclarations."Eric Liu2017-10-101-1/+2
| | | | | | This reverts commit r315251. See the original commit thread for reason. llvm-svn: 315309
* [Modules TS] Module ownership semantics for redeclarations.Richard Smith2017-10-091-2/+1
| | | | | | | | | | 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. llvm-svn: 315251
* Fix the second half of PR34266: Don't implicitly capture '*this' if the ↵Faisal Vali2017-09-171-47/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | members are found in a class unrelated to the enclosing class. https://bugs.llvm.org/show_bug.cgi?id=34266 For e.g. struct A { void f(int); static void f(char); }; struct B { auto foo() { return [&] (auto a) { A::f(a); // this should not cause a capture of '*this' }; } }; The patch does the following: 1) It moves the check to attempt an implicit capture of '*this' by reference into the more logical location of when the call is actually built within ActOnCallExpr (as opposed to when the unresolved-member-lookup node is created). - Reminder: A capture of '*this' by value has to always be an explicit capture. 2) It additionally checks whether the naming class of the UnresolvedMemberExpr ('A' in the example above) is related to the enclosing class ('B' above). P.S. If you have access to ISO-C++'s CWG reflector, see this thread for some potentially related discussion: http://lists.isocpp.org/core/2017/08/2851.php llvm-svn: 313487
* revert r311839 (ongoing cwg discussion)Faisal Vali2017-08-291-1/+1
| | | | | | apologies. llvm-svn: 311975
* revert changes from r311851.Faisal Vali2017-08-271-7/+7
| | | | | | | | The right answers here (and how clang needs to be tweaked) require further analysis (ongoing cwg thread). sorry. llvm-svn: 311855
* Don't see through 'using member-declarations' when determining the relation ↵Faisal Vali2017-08-271-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | of any potential implicit object expression to the parent class of the member function containing the function call. Prior to this patch clang would not error here: template <class T> struct B; template <class T> struct A { void foo(); void foo2(); void test1() { B<T>::foo(); // OK, foo is declared in A<int> - matches type of 'this'. B<T>::foo2(); // This should be an error! // foo2 is found in B<int>, 'base unrelated' to 'this'. } }; template <class T> struct B : A<T> { using A<T>::foo2; }; llvm-svn: 311851
* Pass the correct object argument when a member call to an 'unrelated' class ↵Faisal Vali2017-08-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | is made. Prior to this patch, clang would do the wrong thing here (see inline comments for pre-patch behavior): struct A { void bar(int) { } static void bar(double) { } void g(int*); static void g(char *); }; struct B { void f() { A::bar(3); // selects (double) ??!! A::g((int*)0); // Instead of no object argument, states conversion error?!! } }; The fix is as follows: When we detect that what appears to be an implicit member function call (A::bar) is actually a call to a member of a class (A) unrelated to the type (B) that contains the member function (B::f) from which the call is being made, don't treat it (A::bar) as an Implicit Member Call Expression. P.S. I wonder if there is an existing bug report related to this? (Surprisingly, a cursory search did not find one). llvm-svn: 311839
* [OPENMP] Fix DSA processing for member declaration.Alexey Bataev2017-07-201-2/+4
| | | | | | | | If the member declaration is captured in the OMPCapturedExprDecl, we may loose data-sharing attribute info for this declaration. Patch fixes this bug. llvm-svn: 308629
* [OPENMP] Skip BuildMemberExpr() in BuildFieldReferenceExpr(), NFC, by Kai NodaAlexey Bataev2017-07-111-5/+4
| | | | | | | | | In the OpenMP mode, we don't need to call BuildMemberExpr() only to discard its return value. BuildDeclRefExpr() is called instead. Differential revision: https://reviews.llvm.org/D35201 llvm-svn: 307697
* [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped EnumFaisal Vali2017-04-011-7/+7
| | | | | | | | - also replace direct equality checks against the ConstantEvaluated enumerator with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17. - update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed. llvm-svn: 299316
* [Objective-C] Fix "repeated use of weak" warning with -fobjc-weakBrian Kelley2017-03-291-6/+4
| | | | | | | | | | | | | | Summary: -Warc-repeated-use-of-weak should produce the same warnings with -fobjc-weak as it does with -objc-arc. Also check for ObjCWeak along with ObjCAutoRefCount when recording the use of an evaluated weak variable. Add a -fobjc-weak run to the existing arc-repeated-weak test case and adapt it slightly to work in both modes. Reviewers: rsmith, doug.gregor, jordan_rose, rjmccall Reviewed By: rjmccall Subscribers: arphaman, rjmccall, cfe-commits Differential Revision: https://reviews.llvm.org/D31005 llvm-svn: 299011
* [OpenCL] Added diagnostic for checking length of vectorEgor Churaev2017-03-211-0/+21
| | | | | | | | | | | | Reviewers: Anastasia, cfe-commits Reviewed By: Anastasia Subscribers: bader, yaxunl Differential Revision: https://reviews.llvm.org/D30937 llvm-svn: 298369
* [coroutines] Build and pass coroutine_handle to await_suspendGor Nishanov2017-03-091-1/+1
| | | | | | | | | | | | | | | | Summary: This patch adds passing a coroutine_handle object to await_suspend calls. It builds the coroutine_handle using coroutine_handle<PromiseType>::from_address(__builtin_coro_frame()). (a revision of https://reviews.llvm.org/D26316 that for some reason refuses to apply via arc patch) Reviewers: GorNishanov Subscribers: mehdi_amini, cfe-commits, EricWF Differential Revision: https://reviews.llvm.org/D30769 llvm-svn: 297356
* PR23135: Don't instantiate constexpr functions referenced in unevaluated ↵Richard Smith2017-01-071-0/+1
| | | | | | | | | | | | | | | | | | | | | operands where possible. This implements something like the current direction of DR1581: we use a narrow syntactic check to determine the set of places where a constant expression could be evaluated, and only instantiate a constexpr function or variable if it's referenced in one of those contexts, or is odr-used. It's not yet clear whether this is the right set of syntactic locations; we currently consider all contexts within templates that would result in odr-uses after instantiation, and contexts within list-initialization (narrowing conversions take another victim...), as requiring instantiation. We could in principle restrict the former cases more (only const integral / reference variable initializers, and contexts in which a constant expression is required, perhaps). However, this is sufficient to allow us to accept libstdc++ code, which relies on GCC's behavior (which appears to be somewhat similar to this approach). llvm-svn: 291318
* DR616, and part of P0135R1: member access (or pointer-to-member access) on aRichard Smith2016-12-031-0/+9
| | | | | | | temporary produces an xvalue, not a prvalue. Support this by materializing the temporary prior to performing the member access. llvm-svn: 288563
* Mass-rename the handful of error_* diagnostics to err_*.Richard Smith2016-12-021-3/+3
| | | | llvm-svn: 288545
* Sema: correct typo correction for ivars in @implementationSaleem Abdulrasool2016-11-171-3/+10
| | | | | | | | | | | | The previous typo correction handling assumed that ivars are only declared in the interface declaration rather than as a private ivar in the implementation. Adjust the handling to permit both interfaces. Assert earlier that the interface has been acquired to ensure that we can identify when both possible casts have failed. Addresses PR31040! llvm-svn: 287238
* P0217R3: Perform semantic checks and initialization for the bindings in aRichard Smith2016-08-111-30/+23
| | | | | | | decomposition declaration for arrays, aggregate-like structs, tuple-like types, and (as an extension) for complex and vector types. llvm-svn: 278435
* Add .rgba syntax extension to ext_vector_type typesPirama Arumuga Nainar2016-07-221-1/+29
| | | | | | | | | | | | | | | | | | Summary: This patch enables .rgba accessors to ext_vector_type types and adds tests for syntax validation and code generation. 'a' and 'b' can appear either in the point access mode or the numeric access mode (for indices 10 and 11). To disambiguate between the two usages, the accessor type is explicitly passed to relevant methods. Reviewers: rsmith Subscribers: Anastasia, bader, srhines, cfe-commits Differential Revision: http://reviews.llvm.org/D20602 llvm-svn: 276455
* Implement p0292r2 (constexpr if), a likely C++1z feature.Richard Smith2016-06-231-0/+1
| | | | llvm-svn: 273602
* [OPENMP 4.5] Codegen for dacross loop synchronization constructs.Alexey Bataev2016-05-251-0/+1
| | | | | | | OpenMP 4.5 adds support for doacross loop synchronization. Patch implements codegen for this construct. llvm-svn: 270690
* [OPENMP 4.5] Codegen for data members in 'reduction' clause.Alexey Bataev2016-03-021-1/+1
| | | | | | | | OpenMP 4.5 allows to privatize non-static data members of current class in non-static member functions. Patch supports codegen for non-static data members in 'reduction' clauses. llvm-svn: 262460
* Twek fix for PR24473 (r261506) - Preserve the template arguments as writtenFaisal Vali2016-02-251-1/+4
| | | | | | | | | | | | (within the DeclRefExpr Node) when creating AST nodes that reference specializations of static data member templates. While we pass the template args through for all non-instance members, they should only be relevant (i.e. non-null) for variable template ids (assertion added for that assumption) Also preserve the FoundDecl that refers to the canonical Decl (the primary VarTemplateDecl for a variable template specialization) that we are referencing in our DeclRefExpr. Not sure why this was not being done for non-variable template-ids. No functionality change - so no tests added. Thanks to Richard Smith for drawing my attention to this! llvm-svn: 261823
* Fix PR24473 : Teach clang to remember to substitute into member variable ↵Faisal Vali2016-02-221-2/+48
| | | | | | | | templates referred to within dependent qualified ids. In passing also fix a semi-related bug that allows access to variable templates through member access notation. llvm-svn: 261506
* [OPENMP 4.5] Ccapture/codegen of private non-static data members.Alexey Bataev2016-02-081-3/+13
| | | | | | | OpenMP 4.5 introduces privatization of non-static data members of current class in non-static member functions. To correctly handle such kind of privatization a new (pseudo)declaration VarDecl-based node is added. It allows to reuse an existing code for capturing variables in Lambdas/Block/Captured blocks of code for correct privatization and codegen. llvm-svn: 260077
* Class Property: class property and instance property can have the same name.Manman Ren2016-01-281-3/+7
| | | | | | | | | | | | | | | | | | | Add "enum ObjCPropertyQueryKind" to a few APIs that used to only take the name of the property: ObjCPropertyDecl::findPropertyDecl, ObjCContainerDecl::FindPropertyDeclaration, ObjCInterfaceDecl::FindPropertyVisibleInPrimaryClass, ObjCImplDecl::FindPropertyImplDecl, and Sema::ActOnPropertyImplDecl. ObjCPropertyQueryKind currently has 3 values: OBJC_PR_query_unknown, OBJC_PR_query_instance, OBJC_PR_query_class This extra parameter specifies that we are looking for an instance property with the given name, or a class property with the given name, or any property with the given name (if both exist, the instance property will be returned). rdar://23891898 llvm-svn: 259070
* Look through using decls when classifying implicit member accessReid Kleckner2015-10-201-4/+4
| | | | | | | | | | | | | | | | | | | | | Clang will now accept this valid C++11 code: struct A { int field; }; struct B : A { using A::field; enum { TheSize = sizeof(field) }; }; Previously we would classify the 'field' reference as something other than a field, and then forget to apply the C++11 rule to allow non-static data member references in unevaluated contexts. This usually arises in class templates that want to reference fields of a dependent base in an unevaluated context outside of an instance method. Such contexts do not allow references to 'this', so the only way to access the field is with a using decl and an implicit member reference. llvm-svn: 250839
* Revert "Diagnose UnresolvedLookupExprs that resolve to instance members in ↵Reid Kleckner2015-10-201-11/+14
| | | | | | | | | | | | | | | | | static methods" This reverts commit r250592. It has issues around unevaluated contexts, like this: template <class T> struct A { T i; }; template <class T> struct B : A<T> { using A<T>::i; typedef decltype(i) U; }; template struct B<int>; llvm-svn: 250774
* Diagnose UnresolvedLookupExprs that resolve to instance members in static ↵Reid Kleckner2015-10-171-14/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | methods During the initial template parse for this code, 'member' is unresolved and we don't know anything about it: struct A { int member }; template <typename T> struct B : public T { using T::member; static void f() { (void)member; // Could be static or non-static. } }; template class B<A>; The pattern declaration contains an UnresolvedLookupExpr rather than an UnresolvedMemberExpr because `f` is static, and `member` should never be a field. However, if the code is invalid, it may become a field, in which case we should diagnose it. Reviewers: rjmccall, rsmith Differential Revision: http://reviews.llvm.org/D6700 llvm-svn: 250592
* Remove the only use of LookupResult's implicit copy ctorDavid Blaikie2015-09-281-0/+11
| | | | | | | | | | | | | | | | | | | | | LookupResult should not be copyable, it's not readily copyable and can only be copied when it's in specific states (in a query state, without any results, basically). Instead, just extract the /query/ state and pass that across the copy boundary, then build a new LookupResult on the other side. I wonder if a better API (one in which the query state is separate from the result state - essentialyl making QueryState a first class part of the Lookup API - pass a QueryState, get a LookupResult, rather than mutating the LookupResult in place (LookupResult could contain a QueryState if it's particularly helpful to be able to observe the query parameters while also examining the result)) might be a good idea here. Future patches will probably make LookupResult actually non-copyable (transition the CXXBasePaths to unique_ptr, for example) and hopefully we'll enable -Wdeprecated in LLVM soon to avoid issues like this. llvm-svn: 248761
* Add a new frontend warning for referencing members from the handler of a ↵Aaron Ballman2015-09-011-8/+35
| | | | | | | | constructor or destructor function-try-block, which is UB in C++. This corresponds to the CERT secure coding rule ERR53-CPP. llvm-svn: 246548
OpenPOWER on IntegriCloud