This patch extends TypeQuery matching to support anonymous namespaces. A new flag is added to control the behavior. In the "strict" mode, the query must match the type exactly -- all anonymous namespaces included. The dynamic type resolver in the itanium abi (the motivating use case for this) uses this flag, as it queries using the name from the demangles, which includes anonymous namespaces. This ensures we don't confuse a type with a same-named type in an anonymous namespace. However, this does *not* ensure we don't confuse two types in anonymous namespacs (in different CUs). To resolve this, we would need to use a completely different lookup algorithm, which probably also requires a DWARF extension. In the "lax" mode (the default), the anonymous namespaces in the query are optional, and this allows one search for the type using the usual language rules (`::A` matches `::(anonymous namespace)::A`). This patch also changes the type context computation algorithm in DWARFDIE, so that it includes anonymous namespace information. This causes a slight change in behavior: the algorithm previously stopped computing the context after encountering an anonymous namespace, which caused the outer namespaces to be ignored. This meant that a type like `NS::(anonymous namespace)::A` would be (incorrectly) recognized as `::A`). This can cause code depending on the old behavior to misbehave. The fix is to specify all the enclosing namespaces in the query, or use a non-exact match.
26 lines
380 B
C++
26 lines
380 B
C++
#ifndef A_H
|
|
#define A_H
|
|
|
|
#include <cstdio>
|
|
#include <memory>
|
|
|
|
class A {
|
|
public:
|
|
A(int value) : m_a_value(value) {}
|
|
A(int value, A *client_A) : m_a_value(value), m_client_A(client_A) {}
|
|
|
|
virtual ~A() {}
|
|
|
|
virtual void doSomething(A &anotherA);
|
|
|
|
int Value() { return m_a_value; }
|
|
|
|
private:
|
|
int m_a_value;
|
|
std::auto_ptr<A> m_client_A;
|
|
};
|
|
|
|
A *make_anonymous_B();
|
|
|
|
#endif
|