testsuite, threads: fix LD_LIBRARY_PATH in 'tls-sepdebug.exp'
[binutils-gdb.git] / gdb / gdb-code-style.el
blobc6e34c2c378ee931dff8794bfd38bdb5ffbfc73d
1 ;;; gdb-code-style.el --- code style checker for GDB contributors
3 ;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
5 ;; Author: Yao Qi <yao@codesourcery.com>
6 ;; Created: 17 April 2012
7 ;; Version: 1.0
8 ;; Keywords: GDB
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; These hooks defined in this file provide some code style checks in
26 ;; Emacs. You can load it in your ~/.emacs,
27 ;; (load-file "~/$(GDB_SOURCE)/gdb/gdb-code-style.el")
30 ;;; Code:
32 ;; Don't use these functions. Their alternatives are better. This list
33 ;; of functions is from ARI rules.
34 (defun gdb-fun-name-hook ()
35 (font-lock-add-keywords
36 nil
37 '(("\\<\\(\\(xasprintf\\|abort\\|vasprintf\\|strerror\\|strdup\\|asprintf\\|sprintf\\)[ ]*\(\\)" 1 font-lock-warning-face t))))
38 (add-hook 'c-mode-common-hook 'gdb-fun-name-hook)
40 ;; Don't include these files directly.
41 (defun gdb-include-hook ()
42 (font-lock-add-keywords
43 nil
44 '(("\\<include[ ]*\\(<\\(sys/stat\\|stat\\|dirent\\|wait\\|sys/wait\\|assert\\)\\.h>\\)" 1 font-lock-warning-face t))))
46 (add-hook 'c-mode-common-hook 'gdb-include-hook)
48 ;; Check marker up. If the marker up is missing, like,
49 ;; warning ("abc");
50 ;; The '(' and '"' will be highlight.
51 (defun gdb-markup-hook ()
52 (font-lock-add-keywords
53 nil
54 '(("\\<\\(warning\\|error\\)[ ]*\\(\([^_]\\)" 2 font-lock-warning-face t))))
56 (add-hook 'c-mode-common-hook 'gdb-markup-hook)
58 (defun gdb-comment-hook ()
59 ;; A space should follow "/*", otherwise report a warning.
60 ;; If the comment is like:
61 ;; /*F. */
62 ;; The 'F' will be highlight.
63 (font-lock-add-keywords
64 nil
65 '(("/\\*\\([^ ]\\).*\\*/" 1 font-lock-warning-face t)))
66 ;; Two spaces are needed between "." and "*/". Report warning if there
67 ;; is no space (".*/") or only one space (". */").
68 ;; If the comment is like:
69 ;; /* ABC. */ or /* ABC.*/
70 ;; the '.' is highlight.
71 (font-lock-add-keywords
72 nil
73 '(("\\<[[:ascii:]]*\\(\\.[ ]?\\)\\*/" 1 font-lock-warning-face t)))
75 (add-hook 'c-mode-common-hook 'gdb-comment-hook)
77 ;; Set c-set-offset 'innamespace as a safe value to be used in .dir-locals.el.
78 (setq safe-local-variable-values
79 (cons safe-local-variable-values
80 '((eval c-set-offset 'innamespace 0)
81 (c-offsets-alist (innamespace . 0)))))
82 ;;; gdb-code-style.el ends here