void cp_scan_for_anonymous_namespaces (const struct symbol *const symbol, struct objfile *const objfile) { if (SYMBOL_DEMANGLED_NAME (symbol) != NULL) { const char *name = SYMBOL_DEMANGLED_NAME (symbol); unsigned int previous_component; unsigned int next_component; /* Start with a quick-and-dirty check for mention of "(anonymous namespace)". */ if (!cp_is_anonymous (name)) return; previous_component = 0; next_component = cp_find_first_component (name + previous_component); while (name[next_component] == ':') { if (((next_component - previous_component) == CP_ANONYMOUS_NAMESPACE_LEN) && strncmp (name + previous_component, CP_ANONYMOUS_NAMESPACE_STR, CP_ANONYMOUS_NAMESPACE_LEN) == 0) { int dest_len = (previous_component == 0 ? 0 : previous_component - 2); int src_len = next_component; char *dest = alloca (dest_len + 1); char *src = alloca (src_len + 1); memcpy (dest, name, dest_len); memcpy (src, name, src_len); dest[dest_len] = '\0'; src[src_len] = '\0'; /* We've found a component of the name that's an anonymous namespace. So add symbols in it to the namespace given by the previous component if there is one, or to the global namespace if there isn't. */ cp_add_using_directive (dest, src, NULL, NULL, NULL, &objfile->objfile_obstack); } /* The "+ 2" is for the "::". */ previous_component = next_component + 2; next_component = (previous_component + cp_find_first_component (name + previous_component)); } } }
void cp_scan_for_anonymous_namespaces (const struct symbol *symbol) { if (!processing_has_namespace_info && SYMBOL_CPLUS_DEMANGLED_NAME (symbol) != NULL) { const char *name = SYMBOL_CPLUS_DEMANGLED_NAME (symbol); unsigned int previous_component; unsigned int next_component; const char *len; /* Start with a quick-and-dirty check for mention of "(anonymous namespace)". */ if (!cp_is_anonymous (name)) return; previous_component = 0; next_component = cp_find_first_component (name + previous_component); while (name[next_component] == ':') { if ((next_component - previous_component) == ANONYMOUS_NAMESPACE_LEN && strncmp (name + previous_component, "(anonymous namespace)", ANONYMOUS_NAMESPACE_LEN) == 0) { /* We've found a component of the name that's an anonymous namespace. So add symbols in it to the namespace given by the previous component if there is one, or to the global namespace if there isn't. */ cp_add_using_directive (name, previous_component == 0 ? 0 : previous_component - 2, next_component); } /* The "+ 2" is for the "::". */ previous_component = next_component + 2; next_component = (previous_component + cp_find_first_component (name + previous_component)); } } }