ubsan: score: left shift of negative value
[deliverable/binutils-gdb.git] / gdb / make-target-delegates
index 10853e3e203cb17785187f147fcb6116fe1125c3..4388f948908fdef0696a55fbc3203e4bd62186ed 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# Copyright (C) 2013-2018 Free Software Foundation, Inc.
+# Copyright (C) 2013-2020 Free Software Foundation, Inc.
 #
 # This file is part of GDB.
 #
@@ -43,11 +43,9 @@ $POINTER_PART = qr,\s*(\*)?\s*,;
 $CP_SYMBOL = qr,[a-zA-Z_][a-zA-Z0-9_<>:]*,;
 # Match the return type when it is "ordinary".
 $SIMPLE_RETURN_PART = qr,((struct|class|enum|union)\s+)?${CP_SYMBOL}+,;
-# Match the return type when it is a VEC.
-$VEC_RETURN_PART = qr,VEC\s*\([^\)]+\),;
 
 # Match a return type.
-$RETURN_PART = qr,((const|volatile)\s+)?(${SIMPLE_RETURN_PART}|${VEC_RETURN_PART})${POINTER_PART},;
+$RETURN_PART = qr,((const|volatile)\s+)?(${SIMPLE_RETURN_PART})${POINTER_PART},;
 
 # Match "virtual".
 $VIRTUAL_PART = qr,virtual\s,;
@@ -102,7 +100,6 @@ sub scan_target_h() {
 
        # Strip // comments.
        $_ =~ s,//.*$,,;
-       $_ = trim ($_);
 
        $all_the_text .= $_;
     }
@@ -110,6 +107,21 @@ sub scan_target_h() {
     # Now strip out the C comments.
     $all_the_text =~ s,/\*(.*?)\*/,,g;
 
+    # Replace sequences of tabs and/or whitespace with a single
+    # whitespace character.  We need the whitespace because the method
+    # may have been split between multiple lines, like e.g.:
+    #
+    #  virtual std::vector<long_type_name>
+    #    my_long_method_name ()
+    #    TARGET_DEFAULT_IGNORE ();
+    #
+    # If we didn't preserve the whitespace, then we'd end up with:
+    #
+    #  virtual std::vector<long_type_name>my_long_method_name ()TARGET_DEFAULT_IGNORE ()
+    #
+    # ... which wouldn't later be parsed correctly.
+    $all_the_text =~ s/[\t\s]+/ /g;
+
     return split (/;/, $all_the_text);
 }
 
@@ -211,7 +223,7 @@ sub write_delegator($$@) {
     if ($return_type ne 'void') {
        print "return ";
     }
-    print "this->beneath->" . $name . " (";
+    print "this->beneath ()->" . $name . " (";
     print join (', ', @names);
     print ");\n";
     print "}\n\n";
@@ -295,19 +307,19 @@ sub write_debugmethod($$$@) {
        print "  $return_type result;\n";
     }
 
-    print "  fprintf_unfiltered (gdb_stdlog, \"-> %s->$name (...)\\n\", this->beneath->shortname ());\n";
+    print "  fprintf_unfiltered (gdb_stdlog, \"-> %s->$name (...)\\n\", this->beneath ()->shortname ());\n";
 
     # Delegate to the beneath target.
     print "  ";
     if ($return_type ne 'void') {
        print "result = ";
     }
-    print "this->beneath->" . $name . " (";
+    print "this->beneath ()->" . $name . " (";
     print join (', ', @names);
     print ");\n";
 
     # Now print the arguments.
-    print "  fprintf_unfiltered (gdb_stdlog, \"<- %s->$name (\", this->beneath->shortname ());\n";
+    print "  fprintf_unfiltered (gdb_stdlog, \"<- %s->$name (\", this->beneath ()->shortname ());\n";
     for my $i (0 .. $#argtypes) {
        if ($i > 0) {
            print "  fputs_unfiltered (\", \", gdb_stdlog);\n"
@@ -348,6 +360,10 @@ print "\n";
 @argtypes_array = ();
 
 foreach $current_line (@lines) {
+    # See comments in scan_target_h.  Here we strip away the leading
+    # and trailing whitespace.
+    $current_line = trim ($current_line);
+
     next unless $current_line =~ m/$METHOD/;
 
     my $name = $+{name};
@@ -372,11 +388,9 @@ sub print_class($) {
 
     print "struct " . $name . " : public target_ops\n";
     print "{\n";
-    print "  $name ();\n";
+    print "  const target_info &info () const override;\n";
     print "\n";
-    print "  const char *shortname () override;\n";
-    print "  const char *longname () override;\n";
-    print "  const char *doc () override;\n";
+    print "  strata stratum () const override;\n";
     print "\n";
 
     for $name (@delegators) {
This page took 0.025619 seconds and 4 git commands to generate.