Variable: cc-imenu-c++-generic-expression
cc-imenu-c++-generic-expression is a variable defined in
cc-menus.el.gz.
Value
((nil
"^\\_<.*[^[:alnum:]_:<>~]\\(\\([[:alnum:]_:<>~]*::\\)?operator\\_>[ ]*\\(()\\|[^(]*\\)\\)[ ]*([^)]*)[ ]*[^ ;]"
1)
(nil
"^\\([[:alpha:]_][[:alnum:]_:<>~]*\\)[ ]*([ ]*\\([^ (*][^)]*\\)?)[ ]*[^ ;(]"
1)
(nil
"^\\_<[^()\n]*[^[:alnum:]_:<>~]\\([[:alpha:]_][[:alnum:]_:<>~]*\\)\\([ \n]\\|\\\\\n\\)*(\\([ \n]\\|\\\\\n\\)*\\([^ \n(*][^()]*\\(([^()]*)[^()]*\\)*\\)?)\\([ \n]\\|\\\\\n\\)*[^ \n;(]"
1)
("Class"
"^\\(template[ ]*<[^>]+>[ ]*\\)?\\(class\\|struct\\)[ ]+\\([[:alnum:]_]+\\(<[^>]+>\\)?\\)\\([ \n]\\|\\\\\n\\)*[:{]"
3))
Documentation
Imenu generic expression for C++ mode. See imenu-generic-expression.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-menus.el.gz
;; *Warning for cc-mode developers*
;;
;; `cc-imenu-objc-generic-expression' elements depend on
;; `cc-imenu-c++-generic-expression'. So if you change this
;; expression, you need to change following variables,
;; `cc-imenu-objc-generic-expression-*-index',
;; too. `cc-imenu-objc-function' uses these *-index variables, in
;; order to know where the each regexp *group \\(foobar\\)* elements
;; are started.
;;
;; *-index variables are initialized during `cc-imenu-objc-generic-expression'
;; being initialized.
;;
(defvar cc-imenu-c++-generic-expression
`(
;; Try to match ::operator definitions first. Otherwise `X::operator new ()'
;; will be incorrectly recognized as function `new ()' because the regexps
;; work by backtracking from the end of the definition.
(nil
,(concat
"^\\_<.*"
"[^" c-alnum "_:<>~]" ; match any non-identifier char
; (note: this can be `\n')
"\\("
"\\([" c-alnum "_:<>~]*::\\)?" ; match an operator
"operator\\_>[ \t]*"
"\\(()\\|[^(]*\\)" ; special case for `()' operator
"\\)"
"[ \t]*([^)]*)[ \t]*[^ \t;]" ; followed by ws, arg list,
; require something other than
; a `;' after the (...) to
; avoid prototypes. Can't
; catch cases with () inside
; the parentheses surrounding
; the parameters. e.g.:
; `int foo(int a=bar()) {...}'
) 1)
;; Special case to match a line like `main() {}'
;; e.g. no return type, not even on the previous line.
(nil
,(concat
"^"
"\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
"[ \t]*(" ; see above, BUT
"[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start
"[ \t]*[^ \t;(]" ; with an asterisk or parentheses
) 1)
;; General function name regexp
(nil
,(concat
"^\\_<" ; line MUST start with symbol char
;; \n added to prevent overflow in regexp matcher.
;; https://lists.gnu.org/r/emacs-pretest-bug/2007-02/msg00021.html
"[^()\n]*" ; no parentheses before
"[^" c-alnum "_:<>~]" ; match any non-identifier char
"\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
"\\([ \t\n]\\|\\\\\n\\)*(" ; see above, BUT the arg list
"\\([ \t\n]\\|\\\\\n\\)*" ; must not start
"\\([^ \t\n(*]" ; with an asterisk or parentheses
"[^()]*\\(([^()]*)[^()]*\\)*" ; Maybe function pointer arguments
"\\)?)"
"\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]"
) 1)
;; Special case for definitions using phony prototype macros like:
;; `int main _PROTO( (int argc,char *argv[]) )'.
;; This case is only included if cc-imenu-c-prototype-macro-regexp is set.
;; Only supported in c-code, so no `:<>~' chars in function name!
,@(if cc-imenu-c-prototype-macro-regexp
`((nil
,(concat
"^\\_<.*" ; line MUST start with symbol char
"[^" c-alnum "_]" ; match any non-identifier char
"\\([" c-alpha "_][" c-alnum "_]*\\)" ; match function name
"[ \t]*" ; whitespace before macro name
cc-imenu-c-prototype-macro-regexp
"[ \t]*(" ; ws followed by first paren.
"[ \t]*([^)]*)[ \t]*)[ \t]*[^ \t;]" ; see above
) 1)))
;; Class definitions
("Class"
,(concat
"^" ; beginning of line is required
"\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a `template <...>'
"\\(class\\|struct\\)[ \t]+"
"\\(" ; the string we want to get
"[" c-alnum "_]+" ; class name
"\\(<[^>]+>\\)?" ; possibly explicitly specialized
"\\)"
"\\([ \t\n]\\|\\\\\n\\)*[:{]"
) 3))
"Imenu generic expression for C++ mode. See `imenu-generic-expression'.")