1 //===--- MacroBuilder.h - CPP Macro building utility ------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 /// Defines the clang::MacroBuilder utility class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_BASIC_MACROBUILDER_H
15 #define LLVM_CLANG_BASIC_MACROBUILDER_H
17 #include "clang/Basic/LLVM.h"
18 #include "llvm/ADT/Twine.h"
19 #include "llvm/Support/raw_ostream.h"
26 MacroBuilder(raw_ostream &Output) : Out(Output) {}
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';
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';
39 /// Directly append Str and a newline to the underlying buffer.
40 void append(const Twine &Str) {
45 } // end namespace clang