[PATCH v4 0/8] Initial implementation of delayed typo correction.
Kaelyn Takata
rikka at google.com
Tue Aug 26 11:03:49 PDT 2014
+dblaikie
On Thu, Jul 31, 2014 at 1:20 PM, Kaelyn Takata <rikka at google.com> wrote:
>
> This patch set adds a new node to the AST called a TypoExpr. It is used as
> a
> placeholder to delay typo correction until a full expression is being
> finalized
> (via Sema::ActOnFinishFullExpr), at which point a TreeTransform is run to
> replace each TypoExpr by performing typo correction. This allows, for
> example,
> to delay typo correction on a call to a class method until after the
> arguments
> have been parsed, instead of trying to do the typo correction while
> looking up
> the member before the parser has even reached the opening parenthesis. The
> patches have been broken up such that clang builds and the tests pass after
> each patch in the sequence has been applied. The first patch is included in
> here despite being a simple, mechanical moving around of code (instead of
> committing it directly) because it is unnecessary/useless outside of the
> rest
> of the patch set.
>
> v2:
> * Unmunge a couple of patches that accidentally got merged together
> (primarily #5 had incorrectly gotten squashed into #4).
> * Pass unique_ptrs by value instead of by reference.
> v3:
> * Have the TypoCorrectionConsumer remember all TypoCorrections it has
> returned instead of just the last one, and add the ability to
> restart/replay
> returning those TypoCorrections.
> * Rework TransformTypos to try all combinations of typo corrections when
> multiple TypoExpr nodes are present within the same Expr.
> * Add a helper method to TypoExpr to free the unique_ptr members once the
> TypoExpr has been processed e.g by TransformTypos.
> * A few other small changes in response to review feedback of patches 2
> and 5.
> v4:
> * Rebase against ToT and resolve all merge conflicts and related changes.
> * Remove layering violation in the AST library by having Sema keep track
> of
> the Sema-specific state associated with each TypoExpr.
> * Make the typo count tracking in an ExpressionEvaluationContext to be
> more
> accurate by taking advantage of the TypoExpr state being tracked by
> Sema.
> * Keep track of the callees that were OverloadExprs which are
> subsequently
> resolved by TreeTransform<T>::RebuildCallExpr, and use that
> information when
> emitting typo correction diagnostics to select the right decl for the
> diagnostic note.
> * Remove the overload resolution code for members that are the callee in
> a
> CallExpr from the MemberExprTypoRecovery callback now that it is no
> longer
> needed to emit notes on the correct decl of an overloaded method.
> * Make the TypoCorrections passed to the various callbacks be const
> references
> and have the TypoCorrectionConsumer return the current and new
> TypoCorrection by const reference so that they remain immutable and
> replays
> of the typo correction stream are always identical, now that modifying
> the
> TypoCorrection in the recovery callback is no longer necessary to emit
> correct diagnostic notes.
> * Remove the expression stack tracking in the TypoExpr tree transform
> now that
> the parent Expr no longer needs to be passed to the recovery callback.
> * Submit the previous patch 7, "Add another keyword-selection flag to
> CorrectionCandidateCallback", separately with its own test (r214109).
> * A few other small changes in response to review feedback of patches 6
> and 9.
>
> Note that dealing with TypoExprs that weren't handled by a call to
> ActOnFinishFullExpr is still missing. It will be coming in a subsequent
> patch
> since I don't have a good reproduction for having LookupMemberExpr create a
> TypoExpr that isn't subsequently dealt with by ActOnFinishFullExpr, while
> such
> cases are common when having DiagnoseEmptyLookup call CorrectTypoDelayed on
> behalf of ActOnFinishFullExpr.
>
> (I skipped re-mailing patch 1, "Move TypoCorrectionConsumer into a header",
> since it hasn't changed since the first versions of this patchset.)
>
> Kaelyn Takata (8):
> Move TypoCorrectionConsumer into a header.
> Add the initial TypoExpr AST node for delayed typo correction.
> Pass around CorrectionCandidateCallbacks as unique_ptrs so
> TypoCorrectionConsumer can keep the callback around as long as
> needed.
> Have TypoCorrectionConsumer remember the TypoCorrections it returned.
> Start adding the infrastructure for handling TypoExprs.
> Add simple way for a CorrectionCandidateCallback to reject exact
> matches of the typo.
> Add a callback for recovering using a typo correction.
> Wire up LookupMemberExpr to use the new TypoExpr.
>
> include/clang/AST/DataRecursiveASTVisitor.h | 1 +
> include/clang/AST/Expr.h | 18 +
> include/clang/AST/RecursiveASTVisitor.h | 1 +
> include/clang/Basic/StmtNodes.td | 1 +
> include/clang/Parse/Parser.h | 5 +-
> include/clang/Sema/Sema.h | 75 +++-
> include/clang/Sema/SemaInternal.h | 181 ++++++++-
> include/clang/Sema/TypoCorrection.h | 38 +-
> lib/AST/Expr.cpp | 1 +
> lib/AST/ExprClassification.cpp | 3 +-
> lib/AST/ExprConstant.cpp | 1 +
> lib/AST/ItaniumMangle.cpp | 1 +
> lib/AST/StmtPrinter.cpp | 5 +
> lib/AST/StmtProfile.cpp | 4 +
> lib/Parse/ParseExpr.cpp | 8 +-
> lib/Parse/ParseStmt.cpp | 6 +-
> lib/Parse/ParseTentative.cpp | 8 +-
> lib/Parse/Parser.cpp | 8 +-
> lib/Sema/SemaCXXScopeSpec.cpp | 9 +-
> lib/Sema/SemaDecl.cpp | 57 ++-
> lib/Sema/SemaDeclCXX.cpp | 27 +-
> lib/Sema/SemaDeclObjC.cpp | 21 +-
> lib/Sema/SemaExceptionSpec.cpp | 1 +
> lib/Sema/SemaExpr.cpp | 44 ++-
> lib/Sema/SemaExprCXX.cpp | 149 +++++++
> lib/Sema/SemaExprMember.cpp | 131 ++++++-
> lib/Sema/SemaExprObjC.cpp | 18 +-
> lib/Sema/SemaInit.cpp | 4 +-
> lib/Sema/SemaLambda.cpp | 4 +-
> lib/Sema/SemaLookup.cpp | 587
> +++++++++++++---------------
> lib/Sema/SemaOpenMP.cpp | 7 +-
> lib/Sema/SemaOverload.cpp | 23 +-
> lib/Sema/SemaTemplate.cpp | 17 +-
> lib/Sema/SemaTemplateVariadic.cpp | 8 +-
> lib/Sema/TreeTransform.h | 6 +
> lib/Serialization/ASTReaderStmt.cpp | 4 +
> lib/Serialization/ASTWriterStmt.cpp | 6 +
> lib/StaticAnalyzer/Core/ExprEngine.cpp | 1 +
> test/SemaCXX/arrow-operator.cpp | 5 +-
> test/SemaCXX/typo-correction-delayed.cpp | 32 ++
> test/SemaCXX/typo-correction-pt2.cpp | 2 +-
> test/SemaCXX/typo-correction.cpp | 10 +-
> tools/libclang/CXCursor.cpp | 1 +
> 43 files changed, 1057 insertions(+), 482 deletions(-)
> create mode 100644 test/SemaCXX/typo-correction-delayed.cpp
>
> --
> 2.0.0.526.g5318336
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140826/ef3cd7b4/attachment.html>
More information about the cfe-commits
mailing list