On 11/6/20 3:23 PM, Jeff Law wrote:
04-cpp-lexer.diff
diff --git c/libcpp/include/cpplib.h w/libcpp/include/cpplib.h
index 8e398863cf6..81be6457951 100644
--- c/libcpp/include/cpplib.h
+++ w/libcpp/include/cpplib.h
@@ -888,9 +915,9 @@ struct GTY(()) cpp_hashnode {
unsigned int directive_index : 7; /* If is_directive,
then index into directive table.
Otherwise, a NODE_OPERATOR. */
- unsigned char rid_code; /* Rid code - for front ends. */
+ unsigned int rid_code : 8; /* Rid code - for front ends. */
+ unsigned int flags : 9; /* CPP flags. */
ENUM_BITFIELD(node_type) type : 2; /* CPP node type. */
- unsigned int flags : 8; /* CPP flags. */
/* 6 bits spare (plus another 32 on 64-bit hosts). */
Someone already mentioned it, but the # of spare bits needs updating.
yeah, andit was me manually editing a patch wot flubbed it.
+ /* Enter directives mode for the peeking. */
+ pfile->state.in_deferred_pragma = true;
+ pfile->state.pragma_allow_expansion = true;
+ pfile->state.save_comments = 0;
+ pfile->directive_line = result->src_loc;
It looks like you slam in known values when you drop out of directive
mode rather than restoring the original values. That may be OK, I'm not
all that familiar with this code to know if that's corerct or not.
Looks like comments would be useful, and maybe asserts. You only get to
call the peeking when you were in a known (non-directives) state. I
wanted the peeking to be as cheap as possible, so saving and restoring
did not seem needed.
+
+ if (__builtin_expect (node == n_modules[spec_nodes::M__IMPORT][0], false))
+ /* __import */
+ header_count = backup + 2 + 16;
+ else if (__builtin_expect (node == n_modules[spec_nodes::M_IMPORT][0],
false))
+ /* import */
+ header_count = backup + 2 + (CPP_OPTION (pfile, preprocessed) ? 16 : 0);
+ else if (__builtin_expect (node == n_modules[spec_nodes::M_MODULE][0],
false))
+ ; /* module */
+ else
+ goto not_module;
Are the __builtin_expects really useful here? If not I'd prefer to
avoid them and just let the predictors do their job. Similarly
elsewhere in this patch.
I'll investigate.
+ not_module:
+ /* Drop out of directive mode. */
+ pfile->state.save_comments
+ = !CPP_OPTION (pfile, discard_comments);
+ pfile->state.in_deferred_pragma = false;
+ pfile->state.angled_headers = false;
This doesn't seem to match the code to go into directives mode all that
well. You don't reset pragma_allow_expansion or directive_line.
Hm, yeah. I think neither of those fields have any bearing in
non-directives mode, and always get set when entering it? Again,
comment at the very least.
nathan
--
Nathan Sidwell