llvm/clang/lib/Format/FormatToken.h

//===--- FormatToken.h - Format C++ code ------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file contains the declaration of the FormatToken, a wrapper
/// around Token with additional information related to formatting.
///
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H
#define LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H

#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/OperatorPrecedence.h"
#include "clang/Format/Format.h"
#include "clang/Lex/Lexer.h"
#include <unordered_set>

namespace clang {
namespace format {

#define LIST_TOKEN_TYPES

/// Determines the semantic type of a syntactic token, e.g. whether "<" is a
/// template opener or binary operator.
enum TokenType : uint8_t {};

/// Determines the name of a token type.
const char *getTokenTypeName(TokenType Type);

// Represents what type of block a set of braces open.
enum BraceBlockKind {};

// The packing kind of a function's parameters.
enum ParameterPackingKind {};

enum FormatDecision {};

/// Roles a token can take in a configured macro expansion.
enum MacroRole {};

struct FormatToken;

/// Contains information on the token's role in a macro expansion.
///
/// Given the following definitions:
/// A(X) = [ X ]
/// B(X) = < X >
/// C(X) = X
///
/// Consider the macro call:
/// A({B(C(C(x)))}) -> [{<x>}]
///
/// In this case, the tokens of the unexpanded macro call will have the
/// following relevant entries in their macro context (note that formatting
/// the unexpanded macro call happens *after* formatting the expanded macro
/// call):
///                   A( { B( C( C(x) ) ) } )
/// Role:             NN U NN NN NNUN N N U N  (N=None, U=UnexpandedArg)
///
///                   [  { <       x    > } ]
/// Role:             H  E H       E    H E H  (H=Hidden, E=ExpandedArg)
/// ExpandedFrom[0]:  A  A A       A    A A A
/// ExpandedFrom[1]:       B       B    B
/// ExpandedFrom[2]:               C
/// ExpandedFrom[3]:               C
/// StartOfExpansion: 1  0 1       2    0 0 0
/// EndOfExpansion:   0  0 0       2    1 0 1
struct MacroExpansion {};

class TokenRole;
class AnnotatedLine;

/// A wrapper around a \c Token storing information about the
/// whitespace characters preceding it.
struct FormatToken {};

class ContinuationIndenter;
struct LineState;

class TokenRole {};

class CommaSeparatedList : public TokenRole {};

/// Encapsulates keywords that are context sensitive or for languages not
/// properly supported by Clang's lexer.
struct AdditionalKeywords {};

inline bool isLineComment(const FormatToken &FormatTok) {}

// Checks if \p FormatTok is a line comment that continues the line comment
// \p Previous. The original column of \p MinColumnToken is used to determine
// whether \p FormatTok is indented enough to the right to continue \p Previous.
inline bool continuesLineComment(const FormatToken &FormatTok,
                                 const FormatToken *Previous,
                                 const FormatToken *MinColumnToken) {}

// Returns \c true if \c Current starts a new parameter.
bool startsNextParameter(const FormatToken &Current, const FormatStyle &Style);

} // namespace format
} // namespace clang

#endif