[PATCH] D143560: clang-format.el: fix warnings
Augustin Fabre via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 8 01:27:48 PST 2023
augfab created this revision.
augfab added reviewers: sammccall, phst, djasper.
augfab added a project: clang-format.
Herald added a project: All.
augfab requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Emacs trunk complained about:
Warning (comp): clang-format.el:87:15: Warning: Case 'replacement will match ‘quote’. If that’s intended, write (replacement quote) instead. Otherwise, don’t quote ‘replacement’.
Warning (comp): clang-format.el:98:15: Warning: Case 'cursor will match ‘quote’. If that’s intended, write (cursor quote) instead. Otherwise, don’t quote ‘cursor’.
Fixed the syntax by applying the suggestion.
Checked that the code works like before the change by stepping through the execution of the function.
Ran tests with Emacs 26.3 and Emacs trunk with:
$ emacs -Q -batch -l clang/tools/clang-format/clang-format.el -l clang/tools/clang-format/clang-format-test.el -f ert-run-tests-batch-and-exit
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143560
Files:
clang/tools/clang-format/clang-format.el
Index: clang/tools/clang-format/clang-format.el
===================================================================
--- clang/tools/clang-format/clang-format.el
+++ clang/tools/clang-format/clang-format.el
@@ -82,29 +82,29 @@
(let* ((children (xml-node-children node))
(text (car children)))
(cl-case (xml-node-name node)
- ('replacement
+ ((replacement quote)
(let* ((offset (xml-get-attribute-or-nil node 'offset))
(length (xml-get-attribute-or-nil node 'length)))
(when (or (null offset) (null length))
(error "<replacement> node does not have offset and length attributes"))
(when (cdr children)
(error "More than one child node in <replacement> node"))
(setq offset (string-to-number offset))
(setq length (string-to-number length))
(push (list offset length text) replacements)))
- ('cursor
+ ((cursor quote)
(setq cursor (string-to-number text)))))))
;; Sort by decreasing offset, length.
(setq replacements (sort (delq nil replacements)
(lambda (a b)
(or (> (car a) (car b))
(and (= (car a) (car b))
(> (cadr a) (cadr b)))))))
(list replacements cursor (string= incomplete-format "true"))))
(defun clang-format--replace (offset length &optional text)
"Replace the region defined by OFFSET and LENGTH with TEXT.
OFFSET and LENGTH are measured in bytes, not characters. OFFSET
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143560.495756.patch
Type: text/x-patch
Size: 1692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230208/fdef5e10/attachment.bin>
More information about the cfe-commits
mailing list