[PATCH 0/8] Initial implementation of delayed typo correction.

Kaelyn Takata rikka at google.com
Tue Jun 17 14:14:31 PDT 2014


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.


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 last TypoCorrection returned.
  Add simple way for a CorrectionCandidateCallback to reject exact    
    matches of the typo.
  Add another keyword-selection flag to CorrectionCandidateCallback.
  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                    |  20 +
 include/clang/AST/RecursiveASTVisitor.h     |   1 +
 include/clang/Basic/StmtNodes.td            |   1 +
 include/clang/Parse/Parser.h                |   5 +-
 include/clang/Sema/Sema.h                   |  53 ++-
 include/clang/Sema/SemaInternal.h           | 156 +++++++-
 include/clang/Sema/TypoCorrection.h         |  46 ++-
 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                     |  10 +-
 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                       |  42 +-
 lib/Sema/SemaExprCXX.cpp                    |  85 ++++
 lib/Sema/SemaExprMember.cpp                 | 164 +++++++-
 lib/Sema/SemaExprObjC.cpp                   |  18 +-
 lib/Sema/SemaInit.cpp                       |   4 +-
 lib/Sema/SemaLambda.cpp                     |   4 +-
 lib/Sema/SemaLookup.cpp                     | 584 +++++++++++++---------------
 lib/Sema/SemaOpenMP.cpp                     |   7 +-
 lib/Sema/SemaOverload.cpp                   |  23 +-
 lib/Sema/SemaTemplate.cpp                   |  17 +-
 lib/Sema/SemaTemplateVariadic.cpp           |   8 +-
 lib/Sema/TreeTransform.h                    |   8 +
 lib/Serialization/ASTReaderStmt.cpp         |   6 +
 lib/Serialization/ASTWriterStmt.cpp         |   6 +
 lib/StaticAnalyzer/Core/ExprEngine.cpp      |   1 +
 test/SemaCXX/arrow-operator.cpp             |   5 +-
 test/SemaCXX/typo-correction-pt2.cpp        |   2 +-
 test/SemaCXX/typo-correction.cpp            |  10 +-
 tools/libclang/CXCursor.cpp                 |   1 +
 42 files changed, 953 insertions(+), 487 deletions(-)

-- 
2.0.0.526.g5318336


More information about the cfe-commits mailing list