clang-tools 8.0.0

RawStringLiteralCheck.h
Go to the documentation of this file.
1 //===--- RawStringLiteralCheck.h - clang-tidy--------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RAW_STRING_LITERAL_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RAW_STRING_LITERAL_H
12
13 #include "../ClangTidy.h"
14 #include <bitset>
15
16 namespace clang {
17 namespace tidy {
18 namespace modernize {
19
20 using CharsBitSet = std::bitset<1 << CHAR_BIT>;
21
22 /// This check replaces string literals with escaped characters to
23 /// raw string literals.
24 ///
25 /// For the user-facing documentation see:
26 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize-raw-string-literal.html
27 class RawStringLiteralCheck : public ClangTidyCheck {
28 public:
29 RawStringLiteralCheck(StringRef Name, ClangTidyContext *Context);
30
31 void storeOptions(ClangTidyOptions::OptionMap &Options) override;
32 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
33 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
34
35 private:
36 void replaceWithRawStringLiteral(
37 const ast_matchers::MatchFinder::MatchResult &Result,
38 const StringLiteral *Literal, StringRef Replacement);
39
40 std::string DelimiterStem;
41 CharsBitSet DisallowedChars;
42 const bool ReplaceShorterLiterals;
43 };
44
45 } // namespace modernize
46 } // namespace tidy
47 } // namespace clang
48
49 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RAW_STRING_LITERAL_H
clang::tidy::modernize::RawStringLiteralCheck
This check replaces string literals with escaped characters to raw string literals.
Definition: RawStringLiteralCheck.h:27
clang::tidy::modernize::RawStringLiteralCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: RawStringLiteralCheck.cpp:130
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
clang::tidy::modernize::CharsBitSet
std::bitset< 1<< CHAR_BIT > CharsBitSet
Definition: RawStringLiteralCheck.h:20
clang::tidy::ClangTidyCheck::Options
OptionsView Options
Definition: ClangTidy.h:183
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition: ClangTidyOptions.h:98
clang::tidy::modernize::RawStringLiteralCheck::RawStringLiteralCheck
RawStringLiteralCheck(StringRef Name, ClangTidyContext *Context)
Definition: RawStringLiteralCheck.cpp:88
Result
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
Definition: ClangdServer.cpp:60
clang::tidy::modernize::RawStringLiteralCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Options) override
Should store all options supported by this check with their current values or default values for opti...
Definition: RawStringLiteralCheck.cpp:115
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:100
clang::tidy::modernize::RawStringLiteralCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: RawStringLiteralCheck.cpp:121