xref: /llvm-project/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.h (revision 4718da506091a37ca4863d979bc541e359b79b10)
1c526e026SHyrum Wright //===--- TimeSubtractionCheck.h - clang-tidy --------------------*- C++ -*-===//
2c526e026SHyrum Wright //
3c526e026SHyrum Wright // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4c526e026SHyrum Wright // See https://llvm.org/LICENSE.txt for license information.
5c526e026SHyrum Wright // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6c526e026SHyrum Wright //
7c526e026SHyrum Wright //===----------------------------------------------------------------------===//
8c526e026SHyrum Wright 
9c526e026SHyrum Wright #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_TIMESUBTRACTIONCHECK_H
10c526e026SHyrum Wright #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_TIMESUBTRACTIONCHECK_H
11c526e026SHyrum Wright 
12860aefd0SNathan James #include "../ClangTidyCheck.h"
13c526e026SHyrum Wright 
14*4718da50SCarlos Galvez namespace clang::tidy::abseil {
15c526e026SHyrum Wright 
16c526e026SHyrum Wright /// Finds and fixes `absl::Time` subtraction expressions to do subtraction
17c526e026SHyrum Wright /// in the time domain instead of the numeric domain.
18c526e026SHyrum Wright ///
19c526e026SHyrum Wright /// For the user-facing documentation see:
206e566bc5SRichard /// http://clang.llvm.org/extra/clang-tidy/checks/abseil/time-subtraction.html
21c526e026SHyrum Wright class TimeSubtractionCheck : public ClangTidyCheck {
22c526e026SHyrum Wright public:
TimeSubtractionCheck(StringRef Name,ClangTidyContext * Context)23c526e026SHyrum Wright   TimeSubtractionCheck(StringRef Name, ClangTidyContext *Context)
24c526e026SHyrum Wright       : ClangTidyCheck(Name, Context) {}
25c526e026SHyrum Wright   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
26c526e026SHyrum Wright   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
27c526e026SHyrum Wright 
28c526e026SHyrum Wright private:
29c526e026SHyrum Wright   void emitDiagnostic(const Expr* Node, llvm::StringRef Replacement);
30c526e026SHyrum Wright };
31c526e026SHyrum Wright 
32*4718da50SCarlos Galvez } // namespace clang::tidy::abseil
33c526e026SHyrum Wright 
34c526e026SHyrum Wright #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_TIMESUBTRACTIONCHECK_H
35