/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/clang/include/clang/Basic/MacroBuilder.h
Line | Count | Source |
1 | | //===--- MacroBuilder.h - CPP Macro building utility ------------*- C++ -*-===// |
2 | | // |
3 | | // The LLVM Compiler Infrastructure |
4 | | // |
5 | | // This file is distributed under the University of Illinois Open Source |
6 | | // License. See LICENSE.TXT for details. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | /// |
10 | | /// \file |
11 | | /// \brief Defines the clang::MacroBuilder utility class. |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | |
15 | | #ifndef LLVM_CLANG_BASIC_MACROBUILDER_H |
16 | | #define LLVM_CLANG_BASIC_MACROBUILDER_H |
17 | | |
18 | | #include "clang/Basic/LLVM.h" |
19 | | #include "llvm/ADT/Twine.h" |
20 | | #include "llvm/Support/raw_ostream.h" |
21 | | |
22 | | namespace clang { |
23 | | |
24 | | class MacroBuilder { |
25 | | raw_ostream &Out; |
26 | | public: |
27 | 31.5k | MacroBuilder(raw_ostream &Output) : Out(Output) {} |
28 | | |
29 | | /// Append a \#define line for macro of the form "\#define Name Value\n". |
30 | 11.7M | void defineMacro(const Twine &Name, const Twine &Value = "1") { |
31 | 11.7M | Out << "#define " << Name << ' ' << Value << '\n'; |
32 | 11.7M | } |
33 | | |
34 | | /// Append a \#undef line for Name. Name should be of the form XXX |
35 | | /// and we emit "\#undef XXX". |
36 | 43 | void undefineMacro(const Twine &Name) { |
37 | 43 | Out << "#undef " << Name << '\n'; |
38 | 43 | } |
39 | | |
40 | | /// Directly append Str and a newline to the underlying buffer. |
41 | 93.7k | void append(const Twine &Str) { |
42 | 93.7k | Out << Str << '\n'; |
43 | 93.7k | } |
44 | | }; |
45 | | |
46 | | } // end namespace clang |
47 | | |
48 | | #endif |