Commit Graph

4 Commits

Author SHA1 Message Date
Alex Lorenz c38ba6697f Typo correct the condition of 'do-while' before exiting its scope
rdar://35172419

llvm-svn: 316966
2017-10-30 22:55:11 +00:00
Volodymyr Sapsai 4c33079dc3 [Sema] Correct typos in LHS, RHS before building a binop expression.
Specifically, typo correction should be done before dispatching between
different kinds of binary operations like pseudo-object assignment,
overloaded binary operation, etc.

Without this change we hit an assertion

    Assertion failed: (!LHSExpr->hasPlaceholderType(BuiltinType::PseudoObject)), function CheckAssignmentOperands

when in Objective-C we reference a property without `self` and there are
2 equally good typo correction candidates: ivar and a class name. In
this case LHS expression in `BuildBinOp` is

    CXXDependentScopeMemberExpr
    `-TypoExpr

and instead of handling Obj-C property assignment as pseudo-object
assignment, we call `CreateBuiltinBinOp` which corrects typo to

    ObjCPropertyRefExpr '<pseudo-object type>'

but cannot handle pseudo-objects and asserts about it (indirectly,
through `CheckAssignmentOperands`).

rdar://problem/33102722

Reviewers: rsmith, ahatanak, majnemer

Reviewed By: ahatanak

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D37322

llvm-svn: 313323
2017-09-15 00:08:37 +00:00
Alex Lorenz 776b417634 [Sema][ObjC++] Typo correction should handle ivars and properties
After r260016 and r260017 disabled typo correction for ivars and properties
clang didn't report errors about unresolved identifier in the base of ivar and
property ref expressions. This meant that clang invoked CodeGen on invalid AST
which then caused a crash.

This commit re-enables typo correction for ivars and properites, and fixes the
PR25113 & PR26486 (that were originally fixed in r260017 and r260016) in a
different manner by transforming the Objective-C ivar reference expression with
'IsFreeIvar' preserved.

rdar://30310772

llvm-svn: 294008
2017-02-03 14:22:33 +00:00
Manman Ren 1c40052646 [ObjCXX] Warn undeclared identifiers.
Instantiation dependence were not being handled correctly for OpqaueValueExpr
AST nodes. As a result, if an undeclared identifier was used in a CXXNewExpr
that is assigned to a ObjC property, there would be no error during parsing, and
there would be a crash during code gen. This patch makes sure that an error
will be issued during parsing in this case.

Before the fix, if CXXNewExpr has a typo, its InstantiationDependent will be
set to true, but if it is wrapped in a OpaqueValueExpr, the OpaqueValueExpr will
not be instantiation dependent, causing the TypoExpr not be to resolved. The fix
propagates InstantiationDependent to OpaqueValueExpr from its SourceExpr. It
also propagates the other instantiation bits.

rdar://24975562

Differential Revision: http://reviews.llvm.org/D18461

llvm-svn: 264444
2016-03-25 18:43:46 +00:00