gollvm: fix bug in godumpspec macro parser

Be more restrictive about function-style macros -- they need to be
weeded out from the get-go (as opposed to indirectly as a result of
uses in other macros).

Updates golang/go#26405.

Change-Id: Ic8548df72d71d26ffa6b65886a08b21730026e65
Reviewed-on: https://go-review.googlesource.com/124375
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/libgo/godumpspec/mparser/macro-parser.cpp b/libgo/godumpspec/mparser/macro-parser.cpp
index cbe2ce0..f91e5c6 100644
--- a/libgo/godumpspec/mparser/macro-parser.cpp
+++ b/libgo/godumpspec/mparser/macro-parser.cpp
@@ -37,6 +37,11 @@
   d.name = mac.substr(0, spos);
   d.body = mac.substr(spos+1);
 
+  // Don't try to process functions.
+  auto ppos = d.name.find('(');
+  if (ppos != std::string::npos)
+    return 0;
+
   // A collision here typically indicates that we have
   // a clash between a macro and an enum literal.
   auto it = macros_.find(d);
diff --git a/unittests/GoDumpSpec/ParserTests.cpp b/unittests/GoDumpSpec/ParserTests.cpp
index 3216d21..30b3204 100644
--- a/unittests/GoDumpSpec/ParserTests.cpp
+++ b/unittests/GoDumpSpec/ParserTests.cpp
@@ -101,6 +101,7 @@
 TEST(GoDumpSpecParserTests, FunctionMacros) {
 
   const char *input = R"RAW_RESULT(
+    #define ISFUNC() 99
     #define FOO(x,y) x+y
     #define BLIX (7.8e-2*9.01e-8+.00001)<<4u
     #define GLIX() FOO(3,4)