Dwarf_Attribute producer_attr;
if (dwarf_attr_integrate(cu, DW_AT_producer, &producer_attr))
{
- // GNU C x.x.x YYYYMMDD ...
+ // GNU C[++] x.x.x YYYYMMDD ...
const char* producer = dwarf_formstring(&producer_attr);
const char* gnuc = strstr(producer, "GNU C");
if (gnuc)
{
- string version;
-
- // skip to the version number
- gnuc += 6;
+ // skip over GNU C[++]
+ gnuc += 4; // skip to C
const char *space = strchr(gnuc, ' ');
- if (!space)
- version.assign(gnuc);
- else
- version.assign(gnuc, space-gnuc);
-
- if (strverscmp(version.c_str(), "4.4.0") < 0)
- consider_decl_line = true;
+ if (space && *(space+1) != '\0')
+ {
+ string version;
+ const char* vers = space+1;
+ space = strchr(vers, ' ');
+ if (!space)
+ version.assign(vers);
+ else
+ version.assign(vers, space-vers);
+
+ if (strverscmp(version.c_str(), "4.4.0") < 0)
+ consider_decl_line = true;
+ }
}
}