Commit Graph
1 Commits
Author SHA1 Message Date
Colby MchenryandClaude Opus 5.5 81fd007850 fix(cpp): a call through a namespace links no class's method by its name (#2730)
A C++ call written through a namespace, `x::m()`, reached matchMethodCall's
name strategies when no declaration of `x::m` was found by qualified name.
They can only return a method of some class, which a namespace never holds:
the capitalized-receiver class (`internal` → a class `Internal`), the one
method of the name in the project, or the best receiver-word guess. So
protocolbuffers/protobuf's `absl::StripPrefix(name, …)` linked to its Rust
generator's `MultiCasePrefixStripper::StripPrefix` and `absl::Status(…)` to
`upb::Status`'s constructor. fmtlib/fmt's `fmt::ptr(p)` linked to a test
scanner's `ptr()` method, and `fmt::day(…)` to a test's `date::day`, ahead of
the step that reads the namespaces a macro opens and finds fmt's own `ptr`
function and `day` alias in `FMT_BEGIN_NAMESPACE`.

Those strategies now return nothing when the qualifier is a namespace
(isCppNamespaceQualifier): a lowercase name that no C or C++ type or alias
node has, and that the calling file declares as neither a template parameter
nor an alias (cppNamesBroughtIn, now split into type names and namespace
names, since a namespace the file opens confirms it is one). rocksdb's
`hash_table::Insert(…)` through `typedef HashTable<…> hash_table;` keeps its
edge. So does the constructor of a class the call names in that namespace
(isCppConstructorThrough): protobuf's `internal::SourceWrapper<absl::Cord>(&data)`
constructs `struct SourceWrapper<absl::Cord>`, a specialization the index
holds without its name, whose template is only declared. A method of
another template's specialization is no constructor: fmt's
`fmt::scan<int>(…)` is fmt's `scan` function, not `scanner<num>::scan`.
The check runs only where one of those strategies would return.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 05:56:24 +00:00