0

I have a huge c++ project and I find myself rgrep-ing for patterns that I know are in string literals. Is there a way to get clang or xtags or cscope or whatever to build a file with a mapping of each string literal in the project to the file and line where it was found?

fakedrake
  • 6,528
  • 8
  • 41
  • 64
  • 2
    In general, a good habit could be to give a *name* to your (string) literals and refer to them in the code. Doing so, you could group literal definitions in any way you would like. – Paolo M Nov 30 '15 at 12:02
  • It's not actually my code, it's a legacy project that I have to debug from time to time based on the messages it emits to stderr. – fakedrake Nov 30 '15 at 12:37
  • 1
    If this is the case... I'm with you, brother ;) – Paolo M Nov 30 '15 at 13:22

1 Answers1

0

I don't know of a way to make cscope or friends to do this. You could almost certainly write a custom Starscope extractor that would do this, if you don't mind writing a dozen or so lines of Ruby (starscope: https://github.com/eapache/starscope, adding an extractor: https://github.com/eapache/starscope/blob/master/doc/LANGUAGE_SUPPORT.md#how-to-add-another-language)

Alternatively it may just be enough to use something like ag instead, which is grep-like but generally a lot faster: https://github.com/ggreer/the_silver_searcher

Evan
  • 6,369
  • 1
  • 29
  • 30