diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
commit | b35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch) | |
tree | cdff4a5d1a715d4ad622fd8f190128b54bebe440 /include/clang/Sema/TypoCorrection.h | |
parent | 3748d41833787fcbf59cc5624e8d2b042a8991bc (diff) | |
parent | 741e05796da92b46d4f7bcbee00702ff37df6489 (diff) |
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Sema/TypoCorrection.h')
-rw-r--r-- | include/clang/Sema/TypoCorrection.h | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/include/clang/Sema/TypoCorrection.h b/include/clang/Sema/TypoCorrection.h index d8fe827998..b49a96c0b9 100644 --- a/include/clang/Sema/TypoCorrection.h +++ b/include/clang/Sema/TypoCorrection.h @@ -1,9 +1,8 @@ //===- TypoCorrection.h - Class for typo correction results -----*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // @@ -313,6 +312,13 @@ public: : InvalidDistance; } + /// Clone this CorrectionCandidateCallback. CorrectionCandidateCallbacks are + /// initially stack-allocated. However in case where delayed typo-correction + /// is done we need to move the callback to storage with a longer lifetime. + /// Every class deriving from CorrectionCandidateCallback must implement + /// this method. + virtual std::unique_ptr<CorrectionCandidateCallback> clone() = 0; + void setTypoName(IdentifierInfo *II) { Typo = II; } void setTypoNNS(NestedNameSpecifier *NNS) { TypoNNS = NNS; } @@ -343,14 +349,28 @@ protected: NestedNameSpecifier *TypoNNS; }; +class DefaultFilterCCC final : public CorrectionCandidateCallback { +public: + explicit DefaultFilterCCC(IdentifierInfo *Typo = nullptr, + NestedNameSpecifier *TypoNNS = nullptr) + : CorrectionCandidateCallback(Typo, TypoNNS) {} + + std::unique_ptr<CorrectionCandidateCallback> clone() override { + return llvm::make_unique<DefaultFilterCCC>(*this); + } +}; + /// Simple template class for restricting typo correction candidates /// to ones having a single Decl* of the given type. template <class C> -class DeclFilterCCC : public CorrectionCandidateCallback { +class DeclFilterCCC final : public CorrectionCandidateCallback { public: bool ValidateCandidate(const TypoCorrection &candidate) override { return candidate.getCorrectionDeclAs<C>(); } + std::unique_ptr<CorrectionCandidateCallback> clone() override { + return llvm::make_unique<DeclFilterCCC>(*this); + } }; // Callback class to limit the allowed keywords and to only accept typo @@ -363,6 +383,9 @@ public: MemberExpr *ME = nullptr); bool ValidateCandidate(const TypoCorrection &candidate) override; + std::unique_ptr<CorrectionCandidateCallback> clone() override { + return llvm::make_unique<FunctionCallFilterCCC>(*this); + } private: unsigned NumArgs; @@ -372,7 +395,7 @@ private: }; // Callback class that effectively disabled typo correction -class NoTypoCorrectionCCC : public CorrectionCandidateCallback { +class NoTypoCorrectionCCC final : public CorrectionCandidateCallback { public: NoTypoCorrectionCCC() { WantTypeSpecifiers = false; @@ -385,6 +408,9 @@ public: bool ValidateCandidate(const TypoCorrection &candidate) override { return false; } + std::unique_ptr<CorrectionCandidateCallback> clone() override { + return llvm::make_unique<NoTypoCorrectionCCC>(*this); + } }; } // namespace clang |