]> granicus.if.org Git - clang/commitdiff
[ms-inline asm] Change the -fenable-experimental-ms-inline-asm option from a
authorChad Rosier <mcrosier@apple.com>
Fri, 24 Aug 2012 21:42:51 +0000 (21:42 +0000)
committerChad Rosier <mcrosier@apple.com>
Fri, 24 Aug 2012 21:42:51 +0000 (21:42 +0000)
CodeGen option to a LangOpt option.  In turn, hoist the guard into the parser
so that we avoid the new (and fairly unstable) Sema/AST/CodeGen logic.  This
should restore the behavior of clang to that prior to r158325.
<rdar://problem/12163681>

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

include/clang/Basic/DiagnosticParseKinds.td
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/LangOptions.def
include/clang/Frontend/CodeGenOptions.h
lib/CodeGen/CGStmt.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Parse/ParseStmt.cpp
lib/Sema/SemaStmtAsm.cpp
test/Parser/ms-inline-asm.c

index b1c16fa8529f1e501725dcc5083550a07558bacf..a9c0a1752c462094c6d9bba3d6abc7cf5bb24e02 100644 (file)
@@ -18,6 +18,9 @@ def w_asm_qualifier_ignored : Warning<"ignored %0 qualifier on asm">,
 def warn_file_asm_volatile : Warning<
   "meaningless 'volatile' on asm outside function">, CatInlineAsm;
 
+def warn_unsupported_msasm : Warning<
+  "MS-style inline assembly is not supported">, InGroup<Microsoft>;
+
 let CategoryName = "Parse Issue" in {
 
 def ext_empty_translation_unit : Extension<
index aaa022e4b3dd3a7bd8a8c8bddbc7508d49c9b6c0..867f75c79243dd5efd347c11510790046e1cb050 100644 (file)
@@ -5073,9 +5073,6 @@ let CategoryName = "Inline Assembly Issue" in {
     "invalid use of a cast in a inline asm context requiring an l-value: "
     "accepted due to -fheinous-gnu-extensions, but clang may remove support "
     "for this in the future">;
-
-  def warn_unsupported_msasm : ExtWarn<
-    "MS-style inline assembly is not supported">, InGroup<Microsoft>;
 }
 
 let CategoryName = "Semantic Issue" in {
index 3c70028ee3faffc7ceb381a3e3e51cd976e03352..acc1cf4df1d801990e28075b18c3c53642356e6e 100644 (file)
@@ -162,6 +162,9 @@ VALUE_LANGOPT(MSCVersion, 32, 0,
 
 LANGOPT(ApplePragmaPack, 1, 0, "Apple gcc-compatible #pragma pack handling")
 
+BENIGN_LANGOPT(EmitMicrosoftInlineAsm , 1, 0, 
+               "Enable emission of MS-style inline assembly.")
+
 #undef LANGOPT
 #undef VALUE_LANGOPT
 #undef BENIGN_LANGOPT
index 8610b8a89b39e254981fde42152c7f35c1e482c6..3b0d59957721fd11f5572cb38507e698514a56ec 100644 (file)
@@ -72,8 +72,6 @@ public:
   unsigned EmitGcovArcs      : 1; ///< Emit coverage data files, aka. GCDA.
   unsigned EmitGcovNotes     : 1; ///< Emit coverage "notes" files, aka GCNO.
   unsigned EmitOpenCLArgMetadata : 1; ///< Emit OpenCL kernel arg metadata.
-  unsigned EmitMicrosoftInlineAsm : 1; ///< Enable emission of MS-style inline
-                                       ///< assembly.
   unsigned ForbidGuardVariables : 1; ///< Issue errors if C++ guard variables
                                      ///< are required.
   unsigned FunctionSections  : 1; ///< Set when -ffunction-sections is enabled.
@@ -206,7 +204,6 @@ public:
     EmitGcovArcs = 0;
     EmitGcovNotes = 0;
     EmitOpenCLArgMetadata = 0;
-    EmitMicrosoftInlineAsm = 0;
     ForbidGuardVariables = 0;
     FunctionSections = 0;
     HiddenWeakTemplateVTables = 0;
index 5004b4925e3fef478d90b3e9502f50a65daaf00c..e52063da74b619e7526390bd5e0d6f55cd70d7e1 100644 (file)
@@ -1668,10 +1668,6 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
 }
 
 void CodeGenFunction::EmitMSAsmStmt(const MSAsmStmt &S) {
-  // MS-style inline assembly is not fully supported, so sema emits a warning.
-  if (!CGM.getCodeGenOpts().EmitMicrosoftInlineAsm)
-    return;
-
   std::vector<llvm::Value*> Args;
   std::vector<llvm::Type *> ArgTypes;
   std::string Constraints;
index 95f9c388283fba6049aa1cb70bdf05f9998dfa2e..4f166b0e919bdb0f0a3b8d9681c961ef98f0f9ae 100644 (file)
@@ -1263,7 +1263,6 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
   Opts.EmitGcovArcs = Args.hasArg(OPT_femit_coverage_data);
   Opts.EmitGcovNotes = Args.hasArg(OPT_femit_coverage_notes);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
-  Opts.EmitMicrosoftInlineAsm = Args.hasArg(OPT_fenable_experimental_ms_inline_asm);
   Opts.CoverageFile = Args.getLastArgValue(OPT_coverage_file);
   Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
   Opts.LinkBitcodeFile = Args.getLastArgValue(OPT_mlink_bitcode_file);
@@ -2113,6 +2112,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
   Opts.FastMath = Args.hasArg(OPT_ffast_math);
   Opts.FiniteMathOnly = Args.hasArg(OPT_ffinite_math_only);
 
+  Opts.EmitMicrosoftInlineAsm = Args.hasArg(OPT_fenable_experimental_ms_inline_asm);
+
   unsigned SSP = Args.getLastArgIntValue(OPT_stack_protector, 0, Diags);
   switch (SSP) {
   default:
index 72536fa6821c91164e4753ccf5c570211b4185e3..37f5bc51ca69e177aaea6f73ffd947bbbaae8285 100644 (file)
@@ -1596,6 +1596,9 @@ StmtResult Parser::ParseReturnStatement() {
 ///         ms-asm-line '\n' ms-asm-instruction-block
 ///
 StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
+  // MS-style inline assembly is not fully supported, so emit a warning.
+  Diag(AsmLoc, diag::warn_unsupported_msasm);
+
   SourceManager &SrcMgr = PP.getSourceManager();
   SourceLocation EndLoc = AsmLoc;
   SmallVector<Token, 4> AsmToks;
@@ -1688,6 +1691,21 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
     return StmtError();
   }
 
+  // If MS-style inline assembly is disabled, then build an empty asm.
+  if (!getLangOpts().EmitMicrosoftInlineAsm) {
+    Token t;
+    t.setKind(tok::string_literal);
+    t.setLiteralData("\"/*FIXME: not done*/\"");
+    t.clearFlag(Token::NeedsCleaning);
+    t.setLength(21);
+    ExprResult AsmString(Actions.ActOnStringLiteral(&t, 1));
+    ExprVector Constraints;
+    ExprVector Exprs;
+    ExprVector Clobbers;
+    return Actions.ActOnAsmStmt(AsmLoc, true, true, 0, 0, 0, Constraints, Exprs,
+                                AsmString.take(), Clobbers, EndLoc);
+  }
+
   // FIXME: We should be passing source locations for better diagnostics.
   return Actions.ActOnMSAsmStmt(AsmLoc, LBraceLoc,
                                 llvm::makeArrayRef(AsmToks), EndLoc);
index 6f34af2f40d222427eabe3eeecd7b653fb78f61e..dcbc21b287c96332bb09144e4116b2c1f84e50e6 100644 (file)
@@ -465,8 +465,6 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc,
                                 SourceLocation LBraceLoc,
                                 ArrayRef<Token> AsmToks,
                                 SourceLocation EndLoc) {
-  // MS-style inline assembly is not fully supported, so emit a warning.
-  Diag(AsmLoc, diag::warn_unsupported_msasm);
   SmallVector<StringRef,4> Clobbers;
   std::set<std::string> ClobberRegs;
   SmallVector<IdentifierInfo*, 4> Inputs;
index 5326ce4d241798daa5340582449f0e2d6030a1fc..0e8b317e56b055b4be69095326a17103758dd070 100644 (file)
@@ -6,7 +6,7 @@
 void t1(void) { M } // expected-warning {{MS-style inline assembly is not supported}}
 void t2(void) { __asm int 0x2c } // expected-warning {{MS-style inline assembly is not supported}}
 void t3(void) { __asm M2 0x2c } // expected-warning {{MS-style inline assembly is not supported}}
-void* t4(void) { __asm mov eax, fs:[0x10] } // expected-warning {{MS-style inline assembly is not supported}}
+void t4(void) { __asm mov eax, fs:[0x10] } // expected-warning {{MS-style inline assembly is not supported}}
 void t5() {
   __asm { // expected-warning {{MS-style inline assembly is not supported}}
     int 0x2c ; } asm comments are fun! }{
@@ -20,7 +20,7 @@ int t6() {
   __asm int 4 // expected-warning {{MS-style inline assembly is not supported}}
   return 10;
 }
-int t7() {
+void t7() {
   __asm { // expected-warning {{MS-style inline assembly is not supported}}
     push ebx
     mov ebx, 0x07
@@ -34,5 +34,5 @@ void t9() {
   __asm nop __asm nop ; __asm nop // expected-warning {{MS-style inline assembly is not supported}}
 }
 int t_fail() { // expected-note {{to match this}}
-  __asm
-  __asm { // expected-error 3 {{expected}} expected-note {{to match this}}
+  __asm // expected-warning {{MS-style inline assembly is not supported}}
+  __asm { // expected-warning {{MS-style inline assembly is not supported}} expected-error 3 {{expected}} expected-note {{to match this}}