]> granicus.if.org Git - clang/commitdiff
Move the MacroBuilder utilitiy to its own header. Update references.
authorChandler Carruth <chandlerc@gmail.com>
Wed, 20 Jan 2010 06:13:02 +0000 (06:13 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 20 Jan 2010 06:13:02 +0000 (06:13 +0000)
Comments and/or improvements to the documentation are welcome.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93982 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/MacroBuilder.h [new file with mode: 0644]
include/clang/Basic/TargetInfo.h
lib/Basic/Targets.cpp
lib/Frontend/InitPreprocessor.cpp

diff --git a/include/clang/Basic/MacroBuilder.h b/include/clang/Basic/MacroBuilder.h
new file mode 100644 (file)
index 0000000..e46f424
--- /dev/null
@@ -0,0 +1,46 @@
+//===--- MacroBuilder.h - CPP Macro building utilitiy -----------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//  This file defines the MacroBuilder utility class.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_BASIC_MACROBUILDER_H
+#define LLVM_CLANG_BASIC_MACROBUILDER_H
+
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+
+class MacroBuilder {
+  llvm::raw_ostream &Out;
+public:
+  MacroBuilder(llvm::raw_ostream &Output) : Out(Output) {}
+
+  /// Append a #define line for macro of the form "#define Name Value\n".
+  void defineMacro(const llvm::Twine &Name, const llvm::Twine &Value = "1") {
+    Out << "#define " << Name << ' ' << Value << '\n';
+  }
+
+  /// Append a #undef line for Name.  Name should be of the form XXX
+  /// and we emit "#undef XXX".
+  void undefineMacro(const llvm::Twine &Name) {
+    Out << "#undef " << Name << '\n';
+  }
+
+  /// Directly append Str and a newline to the underlying buffer.
+  void append(const llvm::Twine &Str) {
+    Out << Str << '\n';
+  }
+};
+
+}  // end namespace clang
+
+#endif
index 45c3b9732b9657c6a5fe1caf528a8f0239f34f65..97e0495bfbe20d7d400b87e6d781623ad632911a 100644 (file)
@@ -17,8 +17,6 @@
 // FIXME: Daniel isn't smart enough to use a prototype for this.
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/ADT/Twine.h"
-#include "llvm/Support/raw_ostream.h"
 #include "llvm/System/DataTypes.h"
 #include <cassert>
 #include <vector>
@@ -32,34 +30,13 @@ class StringRef;
 namespace clang {
 class Diagnostic;
 class LangOptions;
+class MacroBuilder;
 class SourceLocation;
 class SourceManager;
 class TargetOptions;
 
 namespace Builtin { struct Info; }
 
-class MacroBuilder {
-  llvm::raw_ostream &Out;
-public:
-  MacroBuilder(llvm::raw_ostream &Output) : Out(Output) {}
-
-  /// Append a #define line for macro of the form "#define Name Value\n".
-  void defineMacro(const llvm::Twine &Name, const llvm::Twine &Value = "1") {
-    Out << "#define " << Name << ' ' << Value << '\n';
-  }
-
-  /// Append a #undef line for Name.  Name should be of the form XXX
-  /// and we emit "#undef XXX".
-  void undefineMacro(const llvm::Twine &Name) {
-    Out << "#undef " << Name << '\n';
-  }
-
-  /// Directly append Str and a newline to the underlying buffer.
-  void append(const llvm::Twine &Str) {
-    Out << Str << '\n';
-  }
-};
-
 /// TargetInfo - This class exposes information about the current target.
 ///
 class TargetInfo {
index a015ec31106b652c93aad0c88af1707f4a477764..ea076ae0bbfc0d0f6e961fd7b431b6edcb775c2f 100644 (file)
@@ -16,6 +16,7 @@
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/APFloat.h"
index f2eb4e642be807add9f068b904b77d67f75c28c9..32363eed20aadbad1c661efb94b2bffe26958351 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Frontend/Utils.h"
+#include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Frontend/FrontendOptions.h"