1 //===--- MacroBuilder.h - CPP Macro building utility ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the MacroBuilder utility class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CLANG_BASIC_MACROBUILDER_H
15 #define LLVM_CLANG_BASIC_MACROBUILDER_H
17 #include "llvm/ADT/Twine.h"
18 #include "llvm/Support/raw_ostream.h"
25 MacroBuilder(raw_ostream &Output) : Out(Output) {}
27 /// Append a #define line for macro of the form "#define Name Value\n".
28 void defineMacro(const Twine &Name, const Twine &Value = "1") {
29 Out << "#define " << Name << ' ' << Value << '\n';
32 /// Append a #undef line for Name. Name should be of the form XXX
33 /// and we emit "#undef XXX".
34 void undefineMacro(const Twine &Name) {
35 Out << "#undef " << Name << '\n';
38 /// Directly append Str and a newline to the underlying buffer.
39 void append(const Twine &Str) {
44 } // end namespace clang