fix rdar://6804322 by wiring up -fdollars-in-identifiers
with assembler-with-cpp mode.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69520 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Preprocessor/assembler-with-cpp.c b/test/Preprocessor/assembler-with-cpp.c
index 7a2830b..e27cf2d 100644
--- a/test/Preprocessor/assembler-with-cpp.c
+++ b/test/Preprocessor/assembler-with-cpp.c
@@ -1,4 +1,4 @@
-// RUN: clang-cc -x assembler-with-cpp -E %s > %t &&
+// RUN: clang-cc -x assembler-with-cpp -fdollars-in-identifiers=0 -E %s > %t &&
 
 #ifndef __ASSEMBLER__
 #error "__ASSEMBLER__ not defined"
@@ -42,6 +42,15 @@
 
 5: M5()
 
+// rdar://6804322
+// RUN: grep -F "6: blarg $foo" %t &&
+#define FOO(name)  name ## $foo
+6: FOO(blarg)
+
+// RUN: clang-cc -x assembler-with-cpp -fdollars-in-identifiers=1 -E %s > %t &&
+// RUN: grep -F "7: blarg$foo" %t &&
+#define FOO(name)  name ## $foo
+7: FOO(blarg)
 
 
 // RUN: true
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 316e242..07c1518 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -618,22 +618,22 @@
 // value).
 static llvm::cl::opt<bool>
 Exceptions("fexceptions",
-           llvm::cl::desc("Enable support for exception handling."));
+           llvm::cl::desc("Enable support for exception handling"));
 
 static llvm::cl::opt<bool>
 GNURuntime("fgnu-runtime",
             llvm::cl::desc("Generate output compatible with the standard GNU "
-                           "Objective-C runtime."));
+                           "Objective-C runtime"));
 
 static llvm::cl::opt<bool>
 NeXTRuntime("fnext-runtime",
             llvm::cl::desc("Generate output compatible with the NeXT "
-                           "runtime."));
+                           "runtime"));
 
 
 
 static llvm::cl::opt<bool>
-Trigraphs("trigraphs", llvm::cl::desc("Process trigraph sequences."));
+Trigraphs("trigraphs", llvm::cl::desc("Process trigraph sequences"));
 
 static llvm::cl::list<std::string>
 TargetFeatures("mattr", llvm::cl::CommaSeparated,
@@ -643,6 +643,9 @@
 TemplateDepth("ftemplate-depth", llvm::cl::init(99),
               llvm::cl::desc("Maximum depth of recursive template "
                              "instantiation"));
+static llvm::cl::opt<bool>
+DollarsInIdents("fdollars-in-identifiers",
+                llvm::cl::desc("Allow '$' in identifiers"));
 
 
 static llvm::cl::opt<bool>
@@ -679,8 +682,6 @@
 static llvm::cl::opt<bool>
 StaticDefine("static-define", llvm::cl::desc("Should __STATIC__ be defined"));
 
-// FIXME: add:
-//   -fdollars-in-identifiers
 static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
                                        TargetInfo *Target) {
   // Allow the target to set the default the langauge options as it sees fit.
@@ -785,7 +786,10 @@
   
   // Never accept '$' in identifiers when preprocessing assembler.
   if (LK != langkind_asm_cpp)
-    Options.DollarIdents = 1;  // FIXME: Really a target property.
+    Options.DollarIdents = true;  // FIXME: target property?
+  else
+    Options.DollarIdents = DollarsInIdents;
+  
   if (PascalStrings.getPosition())
     Options.PascalStrings = PascalStrings;
   Options.Microsoft = MSExtensions;