kbobyrev planned changes to this revision.
kbobyrev added a comment.

As discussed offline with @ilya-biryukov, the better approach would be to 
prefix match first symbols of each distinct identifier piece instead of prefix 
matching (just looking at the first letter of the identifier) the whole 
identifier.

Example:

- Query: `"u"`
- Symbols: `"unique_ptr"`, `"user"`, `"super_user"`

Current implementation would match `"unique_ptr"` and `"user"` only.
Proposed implementation would match all three symbols, because the second piece 
of `"super_user"` starts with `u`.

This might be useful for codebases where e.g. each identifier starts with some 
project prefix (`ProjectInstruction`, `ProjectGraph`, etc). For C++, it's 
better to use namespaces instead of this naming which is not really great, but 
I am aware of the C++ projects which actually opt for such naming convention. 
However, in pure C this relatively common practice, e.g. a typical piece of 
code for GNOME might be

        GtkOrientation        orientation;
        GtkWrapAllocationMode mode;
  
        GtkWrapBoxSpreading   horizontal_spreading;
        GtkWrapBoxSpreading   vertical_spreading;
  
        guint16               vertical_spacing;
        guint16               horizontal_spacing;
  
        guint16               minimum_line_children;
        guint16               natural_line_children;
  
        GList                *children;
  };

Also, this is better for macros, which can not be put into namespaces anyway 
and there's `BENCHMARK_UNREACHABLE` and so on.

I'll update the patch with the proposed solution.


https://reviews.llvm.org/D50517



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to