clang 23.0.0git
QualifierAlignmentFixer.h
Go to the documentation of this file.
1//===--- QualifierAlignmentFixer.h -------------------------------*- C++-*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file declares QualifierAlignmentFixer, a TokenAnalyzer that
11/// enforces either east or west const depending on the style.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_LIB_FORMAT_QUALIFIERALIGNMENTFIXER_H
16#define LLVM_CLANG_LIB_FORMAT_QUALIFIERALIGNMENTFIXER_H
17
18#include "TokenAnalyzer.h"
19
20namespace clang {
21namespace format {
22
24 const Environment &)>
26
27void addQualifierAlignmentFixerPasses(const FormatStyle &Style,
29
31 const std::vector<std::string> &Order, std::vector<std::string> &LeftOrder,
32 std::vector<std::string> &RightOrder,
33 std::vector<tok::TokenKind> &Qualifiers);
34
35// Is the Token a simple or qualifier type
36bool isQualifierOrType(const FormatToken *Tok, const LangOptions &LangOpts);
38 const std::vector<tok::TokenKind> &Qualifiers,
39 const LangOptions &LangOpts);
40
42 std::string Qualifier;
43 bool RightAlign;
44 SmallVector<tok::TokenKind, 8> QualifierTokens;
45 std::vector<tok::TokenKind> ConfiguredQualifierTokens;
46
47public:
49 const Environment &Env, const FormatStyle &Style,
50 const std::string &Qualifier,
51 const std::vector<tok::TokenKind> &ConfiguredQualifierTokens,
52 bool RightAlign);
53
54 std::pair<tooling::Replacements, unsigned>
55 analyze(TokenAnnotator &Annotator,
57 FormatTokenLexer &Tokens) override;
58
59 static tok::TokenKind getTokenFromQualifier(const std::string &Qualifier);
60
62 FormatTokenLexer &Tokens,
64
65 const FormatToken *analyzeRight(const SourceManager &SourceMgr,
66 const AdditionalKeywords &Keywords,
68 const FormatToken *Tok,
69 const std::string &Qualifier,
70 tok::TokenKind QualifierType);
71
72 const FormatToken *analyzeLeft(const SourceManager &SourceMgr,
73 const AdditionalKeywords &Keywords,
75 const FormatToken *Tok,
76 const std::string &Qualifier,
77 tok::TokenKind QualifierType);
78};
79
80} // end namespace format
81} // end namespace clang
82
83#endif
Token Tok
The Token.
This file declares an abstract TokenAnalyzer, and associated helper classes.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
The collection of all-type qualifiers we support.
Definition TypeBase.h:331
This class handles loading and caching of source files into memory.
LeftRightQualifierAlignmentFixer(const Environment &Env, const FormatStyle &Style, const std::string &Qualifier, const std::vector< tok::TokenKind > &ConfiguredQualifierTokens, bool RightAlign)
const FormatToken * analyzeLeft(const SourceManager &SourceMgr, const AdditionalKeywords &Keywords, tooling::Replacements &Fixes, const FormatToken *Tok, const std::string &Qualifier, tok::TokenKind QualifierType)
const FormatToken * analyzeRight(const SourceManager &SourceMgr, const AdditionalKeywords &Keywords, tooling::Replacements &Fixes, const FormatToken *Tok, const std::string &Qualifier, tok::TokenKind QualifierType)
std::pair< tooling::Replacements, unsigned > analyze(TokenAnnotator &Annotator, SmallVectorImpl< AnnotatedLine * > &AnnotatedLines, FormatTokenLexer &Tokens) override
void fixQualifierAlignment(SmallVectorImpl< AnnotatedLine * > &AnnotatedLines, FormatTokenLexer &Tokens, tooling::Replacements &Fixes)
static tok::TokenKind getTokenFromQualifier(const std::string &Qualifier)
const Environment & Env
TokenAnalyzer(const Environment &Env, const FormatStyle &Style)
Determines extra information about the tokens comprising an UnwrappedLine.
Maintains a set of replacements that are conflict-free.
void addQualifierAlignmentFixerPasses(const FormatStyle &Style, SmallVectorImpl< AnalyzerPass > &Passes)
bool isConfiguredQualifierOrType(const FormatToken *Tok, const std::vector< tok::TokenKind > &Qualifiers, const LangOptions &LangOpts)
std::function< std::pair< tooling::Replacements, unsigned >(const Environment &)> AnalyzerPass
bool isQualifierOrType(const FormatToken *Tok, const LangOptions &LangOpts)
void prepareLeftRightOrderingForQualifierAlignmentFixer(const std::vector< std::string > &Order, std::vector< std::string > &LeftOrder, std::vector< std::string > &RightOrder, std::vector< tok::TokenKind > &Qualifiers)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition TokenKinds.h:25
The JSON file list parser is used to communicate input to InstallAPI.
int const char * function
Definition c++config.h:31
Encapsulates keywords that are context sensitive or for languages not properly supported by Clang's l...
A wrapper around a Token storing information about the whitespace characters preceding it.