Bläddra i källkod

fix how template function names are simplified (#499)

Maggie Nolan 5 år sedan
förälder
incheckning
27840fff0d
2 ändrade filer med 14 tillägg och 5 borttagningar
  1. 12
    3
      internal/graph/graph.go
  2. 2
    2
      internal/graph/graph_test.go

+ 12
- 3
internal/graph/graph.go Visa fil

@@ -28,9 +28,18 @@ import (
28 28
 )
29 29
 
30 30
 var (
31
-	javaRegExp               = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:<init>|[a-z][\w\$]*(?:\$\d+)?))(?:(?:\()|$)`)
32
-	goRegExp                 = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
33
-	cppRegExp                = regexp.MustCompile(`^(?:[_a-zA-Z]\w*::)+(_*[A-Z]\w*::~?[_a-zA-Z]\w*)`)
31
+	// Removes package name and method arugments for Java method names.
32
+	// See tests for examples.
33
+	javaRegExp = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:<init>|[a-z][\w\$]*(?:\$\d+)?))(?:(?:\()|$)`)
34
+	// Removes package name and method arugments for Go function names.
35
+	// See tests for examples.
36
+	goRegExp = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`)
37
+	// Strips C++ namespace prefix from a C++ function / method name.
38
+	// NOTE: Make sure to keep the template parameters in the name. Normally,
39
+	// template parameters are stripped from the C++ names but when
40
+	// -symbolize=demangle=templates flag is used, they will not be.
41
+	// See tests for examples.
42
+	cppRegExp                = regexp.MustCompile(`^(?:[_a-zA-Z]\w*::)+(_*[A-Z]\w*::~?[_a-zA-Z]\w*(?:<.*>)?)`)
34 43
 	cppAnonymousPrefixRegExp = regexp.MustCompile(`^\(anonymous namespace\)::`)
35 44
 )
36 45
 

+ 2
- 2
internal/graph/graph_test.go Visa fil

@@ -476,8 +476,8 @@ func TestShortenFunctionName(t *testing.T) {
476 476
 			"Foo::bar",
477 477
 		},
478 478
 		{
479
-			"Foo::bar::baz<float, long, int>::operator()",
480
-			"Foo::bar::baz<float, long, int>::operator()",
479
+			"cpp::namespace::Class::method<float, long, int>()",
480
+			"Class::method<float, long, int>",
481 481
 		},
482 482
 		{
483 483
 			"foo",