Skip to content

fix: Drop the anonymous namespace from the benchmark URI - #56

Open
chfast wants to merge 1 commit into
CodSpeedHQ:mainfrom
chfast:fix/anonymous-namespace
Open

fix: Drop the anonymous namespace from the benchmark URI#56
chfast wants to merge 1 commit into
CodSpeedHQ:mainfrom
chfast:fix/anonymous-namespace

Conversation

@chfast

@chfast chfast commented Aug 14, 2026

Copy link
Copy Markdown

Related to #40.

extract_lambda_namespace() rejects a namespace containing (anonymous namespace), which is how clang spells it, but GCC spells it {anonymous} and that spelling passes the check unnoticed. The benchmarks registered inside an anonymous namespace therefore end up reported as file.cpp::{anonymous}::bench[…] with GCC, and as file.cpp::bench[…] plus an [ERROR] Anonymous namespace not supported line per benchmark with clang.

Since an anonymous namespace is not part of any identifier a benchmark can be referred to by, this strips the segment instead of bailing out, handling both spellings. The rest of the namespace path is preserved, so {anonymous}::outer:: becomes outer::, and nothing is reported for a construct that is merely unnameable rather than unsupported.

The namespace was extracted from __PRETTY_FUNCTION__ and rejected only when
spelled '(anonymous namespace)', as clang does, so with GCC, which spells it
'{anonymous}', it ended up in the URI: file.cpp::{anonymous}::bench[…]. Strip the
segment instead of bailing out, for both spellings, so the rest of the namespace
path is kept and no error is reported for a construct that is merely unnameable.
@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR normalizes benchmark namespace extraction across GCC and Clang by removing compiler-specific anonymous-namespace segments instead of rejecting them.

  • Adds a helper that removes both GCC and Clang anonymous-namespace spellings.
  • Applies normalization after compiler-specific namespace extraction.
  • Removes the obsolete error output and <iostream> dependency.

Confidence Score: 5/5

The PR appears safe to merge with no actionable correctness or security issues identified.

The normalization removes only compiler-generated strings that cannot be valid C++ namespace identifiers, while retaining the source-file and named-namespace portions used to identify benchmarks.

Important Files Changed

Filename Overview
core/src/uri.cpp Anonymous namespace markers are consistently removed while preserving source-file and named-namespace components of benchmark URIs.

Reviews (1): Last reviewed commit: "fix: Drop the anonymous namespace from t..." | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant