lang/cc: more type safety when reading compile options #1168

It was possible that +cc-default-compiler-options and/or
irony--compile-options could contain a nil, causing stringp type errors.
This commit is contained in:
Henrik Lissner 2019-02-13 20:06:51 -05:00
parent 02a3f815a3
commit 60df01714e
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -144,11 +144,15 @@ compilation dbs."
(require 'irony-cdb) (require 'irony-cdb)
(unless (irony-cdb-autosetup-compile-options) (unless (irony-cdb-autosetup-compile-options)
(irony-cdb--update-compile-options (irony-cdb--update-compile-options
(append (delq nil (cdr-safe (assq major-mode +cc-default-compiler-options))) (delq nil
(list (locate-dominating-file (or buffer-file-name default-directory) (append (cdr-safe (assq major-mode +cc-default-compiler-options))
"include")) (cl-loop with path = (or buffer-file-name default-directory)
for dir in '("include" "includes")
if (projectile-locate-dominating-file path dir)
collect it)
(cl-loop for path in +cc-default-include-paths (cl-loop for path in +cc-default-include-paths
nconc (list "-I" path))) if (stringp path)
nconc (list "-I" path))))
(doom-project-root))) (doom-project-root)))
;; Make ffap aware of include paths ;; Make ffap aware of include paths
(when irony--working-directory (when irony--working-directory
@ -156,7 +160,8 @@ compilation dbs."
(make-local-variable 'ffap-c-path) (make-local-variable 'ffap-c-path)
(make-local-variable 'ffap-c++-path) (make-local-variable 'ffap-c++-path)
(cl-loop for opt in irony--compile-options (cl-loop for opt in irony--compile-options
if (string-match "^-I\\(.+\\)" opt) if (and (stringp opt)
(string-match "^-I\\(.+\\)" opt))
do (add-to-list (pcase major-mode do (add-to-list (pcase major-mode
(`c-mode 'ffap-c-path) (`c-mode 'ffap-c-path)
(`c++-mode 'ffap-c++-path)) (`c++-mode 'ffap-c++-path))