From: law Date: Wed, 3 Oct 2018 17:23:15 +0000 (+0000) Subject: * gimple-fold.c (get_range_strlen): Only set *nonstr when X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=55f0ab6e6332adc35f6808c96f9010cfcd247004;p=thirdparty%2Fgcc.git * gimple-fold.c (get_range_strlen): Only set *nonstr when an unterminated string is discovered. Bubble up range even for unterminated strings. (gimple_fold_builtin_strlen): Do not fold if get_range_strlen indicates the string was not terminated via NONSTR. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264816 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6acb077b3575..aa10aa07269f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,12 @@ -2018-10-3 Aldy Hernandez +2018-10-02 Jeff Law + + * gimple-fold.c (get_range_strlen): Only set *nonstr when + an unterminated string is discovered. Bubble up range + even for unterminated strings. + (gimple_fold_builtin_strlen): Do not fold if get_range_strlen + indicates the string was not terminated via NONSTR. + +2018-10-03 Aldy Hernandez * tree-vrp.c (extract_range_from_unary_expr): Special case all pointer conversions. diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index fa1fc60876c0..fe6bc08bdd98 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -1344,8 +1344,13 @@ get_range_strlen (tree arg, tree length[2], bitmap *visited, int type, /* If we potentially had a non-terminated string, then bubble that information up to the caller. */ - if (!val) - *nonstr = data.decl; + if (!val && data.decl) + { + *nonstr = data.decl; + *minlen = data.len; + *maxlen = data.len; + return type == 0 ? false : true; + } } if (!val && fuzzy) @@ -3596,6 +3601,7 @@ gimple_fold_builtin_strlen (gimple_stmt_iterator *gsi) tree nonstr; tree lenrange[2]; if (!get_range_strlen (arg, lenrange, 1, true, &nonstr) + && !nonstr && lenrange[0] && TREE_CODE (lenrange[0]) == INTEGER_CST && lenrange[1] && TREE_CODE (lenrange[1]) == INTEGER_CST) {