zbrid updated this revision to Diff 265081.
zbrid added a comment.

Add test; Update command for existing test

Also rename file to match warning flag


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79743/new/

https://reviews.llvm.org/D79743

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/test/Parser/slh-asm-goto-no-warn.cpp
  clang/test/Parser/slh-asm-goto.cpp


Index: clang/test/Parser/slh-asm-goto.cpp
===================================================================
--- /dev/null
+++ clang/test/Parser/slh-asm-goto.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -mspeculative-load-hardening -fsyntax-only -verify %s
+
+void f() {
+  __asm goto("movl %ecx, %edx"); // expected-warning {{Speculative load 
hardening does not protect functions with asm goto}}
+}
Index: clang/test/Parser/slh-asm-goto-no-warn.cpp
===================================================================
--- /dev/null
+++ clang/test/Parser/slh-asm-goto-no-warn.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -Wno-slh-asm-goto -mspeculative-load-hardening 
-fsyntax-only -verify %s
+
+void f() {
+  __asm goto("movl %ecx, %edx"); // expected-no-diagnostics
+}
Index: clang/lib/Parse/ParseStmtAsm.cpp
===================================================================
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -729,6 +729,9 @@
   if (parseGNUAsmQualifierListOpt(GAQ))
     return StmtError();
 
+  if (GAQ.isGoto() && getLangOpts().SpeculativeLoadHardening)
+    Diag(Loc, diag::warn_slh_does_not_support_asm_goto);
+
   BalancedDelimiterTracker T(*this, tok::l_paren);
   T.consumeOpen();
 
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -243,6 +243,9 @@
   def warn_stack_clash_protection_inline_asm : Warning<
     "Unable to protect inline asm that clobbers stack pointer against stack 
clash">,
     InGroup<DiagGroup<"stack-protector">>;
+
+  def warn_slh_does_not_support_asm_goto : Warning<
+    "Speculative load hardening does not protect functions with asm goto">, 
InGroup<DiagGroup<"slh-asm-goto">>;
 }
 
 // Sema && Serialization


Index: clang/test/Parser/slh-asm-goto.cpp
===================================================================
--- /dev/null
+++ clang/test/Parser/slh-asm-goto.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -mspeculative-load-hardening -fsyntax-only -verify %s
+
+void f() {
+  __asm goto("movl %ecx, %edx"); // expected-warning {{Speculative load hardening does not protect functions with asm goto}}
+}
Index: clang/test/Parser/slh-asm-goto-no-warn.cpp
===================================================================
--- /dev/null
+++ clang/test/Parser/slh-asm-goto-no-warn.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -Wno-slh-asm-goto -mspeculative-load-hardening -fsyntax-only -verify %s
+
+void f() {
+  __asm goto("movl %ecx, %edx"); // expected-no-diagnostics
+}
Index: clang/lib/Parse/ParseStmtAsm.cpp
===================================================================
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -729,6 +729,9 @@
   if (parseGNUAsmQualifierListOpt(GAQ))
     return StmtError();
 
+  if (GAQ.isGoto() && getLangOpts().SpeculativeLoadHardening)
+    Diag(Loc, diag::warn_slh_does_not_support_asm_goto);
+
   BalancedDelimiterTracker T(*this, tok::l_paren);
   T.consumeOpen();
 
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===================================================================
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -243,6 +243,9 @@
   def warn_stack_clash_protection_inline_asm : Warning<
     "Unable to protect inline asm that clobbers stack pointer against stack clash">,
     InGroup<DiagGroup<"stack-protector">>;
+
+  def warn_slh_does_not_support_asm_goto : Warning<
+    "Speculative load hardening does not protect functions with asm goto">, InGroup<DiagGroup<"slh-asm-goto">>;
 }
 
 // Sema && Serialization
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to