Tweak the way appendModuleInlineAsm works, so you aren't obliged
authorDuncan Sands <baldrick@free.fr>
Tue, 26 Jan 2010 11:58:04 +0000 (11:58 +0000)
committerDuncan Sands <baldrick@free.fr>
Tue, 26 Jan 2010 11:58:04 +0000 (11:58 +0000)
to append a newline when using setModuleInlineAsm in case later
someone calls appendModuleInlineAsm - make newline handling fully
automatic.  In case anyone is wondering there is only one user of
appendModuleInlineAsm: the dragonegg plugin.

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

include/llvm/Module.h

index 3c8055d09fd799c0ad5a7176849a934773394bcf..8dfb5089eadea0d42405716923110c42c30df161 100644 (file)
@@ -211,11 +211,13 @@ public:
   /// Set the module-scope inline assembly blocks.
   void setModuleInlineAsm(StringRef Asm) { GlobalScopeAsm = Asm; }
 
-  /// Append to the module-scope inline assembly blocks, automatically
-  /// appending a newline to the end.
+  /// Append to the module-scope inline assembly blocks, automatically inserting
+  /// a separating newline if necessary.
   void appendModuleInlineAsm(StringRef Asm) {
+    if (!GlobalScopeAsm.empty() &&
+        GlobalScopeAsm[GlobalScopeAsm.size()-1] != '\n')
+      GlobalScopeAsm += '\n';
     GlobalScopeAsm += Asm;
-    GlobalScopeAsm += '\n';
   }
 
 /// @}