clang
15.0.0git
include
clang
Basic
MacroBuilder.h
Go to the documentation of this file.
1
//===--- MacroBuilder.h - CPP Macro building utility ------------*- 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
/// Defines the clang::MacroBuilder utility class.
11
///
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_BASIC_MACROBUILDER_H
15
#define LLVM_CLANG_BASIC_MACROBUILDER_H
16
17
#include "
clang/Basic/LLVM.h
"
18
#include "llvm/ADT/Twine.h"
19
#include "llvm/Support/raw_ostream.h"
20
21
namespace
clang
{
22
23
class
MacroBuilder
{
24
raw_ostream &Out;
25
public
:
26
MacroBuilder
(raw_ostream &Output) : Out(Output) {}
27
28
/// Append a \#define line for macro of the form "\#define Name Value\n".
29
void
defineMacro
(
const
Twine &Name,
const
Twine &
Value
=
"1"
) {
30
Out <<
"#define "
<< Name <<
' '
<<
Value
<<
'\n'
;
31
}
32
33
/// Append a \#undef line for Name. Name should be of the form XXX
34
/// and we emit "\#undef XXX".
35
void
undefineMacro
(
const
Twine &Name) {
36
Out <<
"#undef "
<< Name <<
'\n'
;
37
}
38
39
/// Directly append Str and a newline to the underlying buffer.
40
void
append
(
const
Twine &Str) {
41
Out << Str <<
'\n'
;
42
}
43
};
44
45
}
// end namespace clang
46
47
#endif
clang::MacroBuilder::defineMacro
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".
Definition:
MacroBuilder.h:29
clang::MacroBuilder::undefineMacro
void undefineMacro(const Twine &Name)
Append a #undef line for Name.
Definition:
MacroBuilder.h:35
clang::MacroBuilder::MacroBuilder
MacroBuilder(raw_ostream &Output)
Definition:
MacroBuilder.h:26
clang::MacroBuilder::append
void append(const Twine &Str)
Directly append Str and a newline to the underlying buffer.
Definition:
MacroBuilder.h:40
Value
Value
Definition:
UninitializedValues.cpp:102
LLVM.h
clang
Definition:
CalledOnceCheck.h:17
clang::MacroBuilder
Definition:
MacroBuilder.h:23
Generated on Sun Jun 26 2022 13:27:40 for clang by
1.8.17