[cfe-commits] r93982 - in /cfe/trunk: include/clang/Basic/MacroBuilder.h include/clang/Basic/TargetInfo.h lib/Basic/Targets.cpp lib/Frontend/InitPreprocessor.cpp

Chandler Carruth chandlerc at gmail.com
Tue Jan 19 22:13:02 PST 2010


Author: chandlerc
Date: Wed Jan 20 00:13:02 2010
New Revision: 93982

URL: http://llvm.org/viewvc/llvm-project?rev=93982&view=rev
Log:
Move the MacroBuilder utilitiy to its own header. Update references.

Comments and/or improvements to the documentation are welcome.

Added:
    cfe/trunk/include/clang/Basic/MacroBuilder.h
Modified:
    cfe/trunk/include/clang/Basic/TargetInfo.h
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Added: cfe/trunk/include/clang/Basic/MacroBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/MacroBuilder.h?rev=93982&view=auto

==============================================================================
--- cfe/trunk/include/clang/Basic/MacroBuilder.h (added)
+++ cfe/trunk/include/clang/Basic/MacroBuilder.h Wed Jan 20 00:13:02 2010
@@ -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

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=93982&r1=93981&r2=93982&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Wed Jan 20 00:13:02 2010
@@ -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 @@
 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 {

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=93982&r1=93981&r2=93982&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Jan 20 00:13:02 2010
@@ -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"

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=93982&r1=93981&r2=93982&view=diff

==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Jan 20 00:13:02 2010
@@ -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"





More information about the cfe-commits mailing list