ソースを参照

template functions should not be simplified (#498)

Maggie Nolan 5 年 前
コミット
73b556cfc1
No account linked to committer's email address
共有2 個のファイルを変更した9 個の追加3 個の削除を含む
  1. 5
    3
      internal/graph/graph.go
  2. 4
    0
      internal/graph/graph_test.go

+ 5
- 3
internal/graph/graph.go ファイルの表示

28
 )
28
 )
29
 
29
 
30
 var (
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(`^(?:(?:\(anonymous namespace\)::)(\w+$))|(?:(?:\(anonymous namespace\)::)?(?:[_a-zA-Z]\w*\::|)*(_*[A-Z]\w*::~?[_a-zA-Z]\w*))`)
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*)`)
34
+	cppAnonymousPrefixRegExp = regexp.MustCompile(`^\(anonymous namespace\)::`)
34
 )
35
 )
35
 
36
 
36
 // Graph summarizes a performance profile into a format that is
37
 // Graph summarizes a performance profile into a format that is
429
 
430
 
430
 // ShortenFunctionName returns a shortened version of a function's name.
431
 // ShortenFunctionName returns a shortened version of a function's name.
431
 func ShortenFunctionName(f string) string {
432
 func ShortenFunctionName(f string) string {
433
+	f = cppAnonymousPrefixRegExp.ReplaceAllString(f, "")
432
 	for _, re := range []*regexp.Regexp{goRegExp, javaRegExp, cppRegExp} {
434
 	for _, re := range []*regexp.Regexp{goRegExp, javaRegExp, cppRegExp} {
433
 		if matches := re.FindStringSubmatch(f); len(matches) >= 2 {
435
 		if matches := re.FindStringSubmatch(f); len(matches) >= 2 {
434
 			return strings.Join(matches[1:], "")
436
 			return strings.Join(matches[1:], "")

+ 4
- 0
internal/graph/graph_test.go ファイルの表示

475
 			"foo_bar::Foo::bar",
475
 			"foo_bar::Foo::bar",
476
 			"Foo::bar",
476
 			"Foo::bar",
477
 		},
477
 		},
478
+		{
479
+			"Foo::bar::baz<float, long, int>::operator()",
480
+			"Foo::bar::baz<float, long, int>::operator()",
481
+		},
478
 		{
482
 		{
479
 			"foo",
483
 			"foo",
480
 			"foo",
484
 			"foo",