diff --git a/lisp/llvm-lib/llvm-act-on-file/act-on-c-file.el b/lisp/llvm-lib/llvm-act-on-file/act-on-c-file.el index 6d482e7..3cf108b 100644 --- a/lisp/llvm-lib/llvm-act-on-file/act-on-c-file.el +++ b/lisp/llvm-lib/llvm-act-on-file/act-on-c-file.el @@ -27,6 +27,7 @@ (require 'llvm-shared) (require 'action-map-lib) (require 'anaphora) +(require 'make-tmp-output-file) (defvar ll/c-file-action-map '((debug :key ?d :major-mode llvm-mode :buffer-string "debug" :description "[d]ebug pass" :compiler-action assemble) @@ -151,7 +152,7 @@ (defun ll/act-on-c-file (file) (let* ((action (aml/read-action-map ll/c-file-action-map)) - (output (make-temp-file (concat (file-name-sans-extension file) "-") nil ".ll"))) + (output (ll/make-tmp-file file ".ll"))) (if (eq action 'diff) (ll/diff-c-on-two-compilations file action) (let ((comm (ll/build-clang-command (lls/un-trampify file) action output))) diff --git a/lisp/llvm-lib/llvm-act-on-file/act-on-ll-file.el b/lisp/llvm-lib/llvm-act-on-file/act-on-ll-file.el index 8cb2acf..87ba1d2 100644 --- a/lisp/llvm-lib/llvm-act-on-file/act-on-ll-file.el +++ b/lisp/llvm-lib/llvm-act-on-file/act-on-ll-file.el @@ -25,6 +25,7 @@ ;;; Code: (require 'llvm-shared) (require 'action-map-lib) +(require 'make-tmp-output-file) (defvar ll/ll-file-action-map '((assembly :key ?a :major-mode asm-mode :buffer-string "assembly" :description "[a]ssembly") @@ -45,9 +46,12 @@ ;; I just recently noticed that the default directory is changing, but ;; I don't know what changed. Should investigate later. (default-directory (file-name-directory file)) - (output (make-temp-file - (concat (file-name-sans-extension file) "-") - nil ".mir"))) + (output (ll/make-tmp-file + file + (cond + ((eq action 'assembly) + ".S") + (t ".mir"))))) (aprog1 (compilation-start (ll/build-llc-command file action output pass) diff --git a/lisp/llvm-lib/llvm-act-on-file/make-tmp-output-file.el b/lisp/llvm-lib/llvm-act-on-file/make-tmp-output-file.el new file mode 100644 index 0000000..15ccc21 --- /dev/null +++ b/lisp/llvm-lib/llvm-act-on-file/make-tmp-output-file.el @@ -0,0 +1,38 @@ +;;; make-tmp-output-file.el --- -*- lexical-binding: t -*- + +;; Copyright (C) 2024 Benson Chu + +;; Author: Benson Chu +;; Created: [2024-10-25 19:36] + +;; This file is not part of GNU Emacs + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;;; Code: + +(defun ll/make-tmp-file (file ext) + (let (fname temporary-file-directory) + (if (string-match-p (rx "/.tmp") file) + (setq fname (file-name-sans-extension file) + temporary-file-directory (file-name-directory file)) + (setq fname (file-name-nondirectory (file-name-sans-extension file)) + temporary-file-directory (expand-file-name ".tmp" default-directory))) + (make-temp-file (concat fname "-") + nil ext))) + +(provide 'make-tmp-output-file) +;;; make-tmp-output-file.el ends here