[PATCH] D55439: [MC] Do not consider .ifdef/.ifndef as a use

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 7 09:04:54 PST 2018


scott.linder created this revision.
scott.linder added reviewers: grosbach, echristo, dblaikie.
Herald added a subscriber: llvm-commits.

GAS seems to allow this, and I can't think of a reason why these directives should be considered uses.


Repository:
  rL LLVM

https://reviews.llvm.org/D55439

Files:
  lib/MC/MCParser/AsmParser.cpp
  test/MC/AsmParser/ifdef.s
  test/MC/AsmParser/ifndef.s


Index: test/MC/AsmParser/ifndef.s
===================================================================
--- test/MC/AsmParser/ifndef.s
+++ test/MC/AsmParser/ifndef.s
@@ -27,3 +27,13 @@
 .else
 	.byte 0
 .endif
+
+# .ifndef directive does not count as a use, so ensure redefinition is permitted
+.set var, 1
+.ifndef var
+	.set var, 2
+.else
+	.set var, 3
+.endif
+# CHECK: .byte 3
+.byte var
Index: test/MC/AsmParser/ifdef.s
===================================================================
--- test/MC/AsmParser/ifdef.s
+++ test/MC/AsmParser/ifdef.s
@@ -27,3 +27,13 @@
 .else
 	.byte 1
 .endif
+
+# .ifdef directive does not count as a use, so ensure redefinition is permitted
+.set var, 1
+.ifdef var
+	.set var, 2
+.else
+	.set var, 3
+.endif
+# CHECK: .byte 2
+.byte var
Index: lib/MC/MCParser/AsmParser.cpp
===================================================================
--- lib/MC/MCParser/AsmParser.cpp
+++ lib/MC/MCParser/AsmParser.cpp
@@ -5028,9 +5028,9 @@
     MCSymbol *Sym = getContext().lookupSymbol(Name);
 
     if (expect_defined)
-      TheCondState.CondMet = (Sym && !Sym->isUndefined());
+      TheCondState.CondMet = (Sym && !Sym->isUndefined(false));
     else
-      TheCondState.CondMet = (!Sym || Sym->isUndefined());
+      TheCondState.CondMet = (!Sym || Sym->isUndefined(false));
     TheCondState.Ignore = !TheCondState.CondMet;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55439.177230.patch
Type: text/x-patch
Size: 1368 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181207/b57de97e/attachment.bin>


More information about the llvm-commits mailing list