clang
20.0.0git
lib
Format
Macros.h
Go to the documentation of this file.
1
//===--- Macros.h - Format C++ code -----------------------------*- 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 contains the main building blocks of macro support in
11
/// clang-format.
12
///
13
/// In order to not violate the requirement that clang-format can format files
14
/// in isolation, clang-format's macro support uses expansions users provide
15
/// as part of clang-format's style configuration.
16
///
17
/// Macro definitions are of the form "MACRO(p1, p2)=p1 + p2", but only support
18
/// one level of expansion (\see MacroExpander for a full description of what
19
/// is supported).
20
///
21
/// As part of parsing, clang-format uses the MacroExpander to expand the
22
/// spelled token streams into expanded token streams when it encounters a
23
/// macro call. The UnwrappedLineParser continues to parse UnwrappedLines
24
/// from the expanded token stream.
25
/// After the expanded unwrapped lines are parsed, the MacroCallReconstructor
26
/// matches the spelled token stream into unwrapped lines that best resemble the
27
/// structure of the expanded unwrapped lines. These reconstructed unwrapped
28
/// lines are aliasing the tokens in the expanded token stream, so that token
29
/// annotations will be reused when formatting the spelled macro calls.
30
///
31
/// When formatting, clang-format annotates and formats the expanded unwrapped
32
/// lines first, determining the token types. Next, it formats the spelled
33
/// unwrapped lines, keeping the token types fixed, while allowing other
34
/// formatting decisions to change.
35
///
36
//===----------------------------------------------------------------------===//
37
38
#ifndef CLANG_LIB_FORMAT_MACROS_H
39
#define CLANG_LIB_FORMAT_MACROS_H
40
41
#include <list>
42
43
#include "
FormatToken.h
"