clang-tools  7.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
28 public:
29  RawStringLiteralCheck(StringRef Name, ClangTidyContext *Context);
30 
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
llvm::StringRef Name
This check replaces string literals with escaped characters to raw string literals.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
std::bitset< 1<< CHAR_BIT > CharsBitSet
std::map< std::string, std::string > OptionMap
RawStringLiteralCheck(StringRef Name, ClangTidyContext *Context)
void storeOptions(ClangTidyOptions::OptionMap &Options) override
Should store all options supported by this check with their current values or default values for opti...
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.