       (byte-to-position (1+ byte)))))
 
 ;;;###autoload
-(defun clang-format-region (start end &optional style)
+(defun clang-format-region (start end &optional style assume-file-name)
   "Use clang-format to format the code between START and END according to STYLE.
-If called interactively uses the region or the current statement if there
-is no active region.  If no style is given uses `clang-format-style'."
+If called interactively uses the region or the current statement if there is no
+no active region. If no STYLE is given uses `clang-format-style'. Use
+ASSUME-FILE-NAME to locate a style config file, if no ASSUME-FILE-NAME is given
+uses the function `buffer-file-name'."
   (interactive
    (if (use-region-p)
        (list (region-beginning) (region-end))


  (unless style
    (setq style clang-format-style))

  (let ((file-start (clang-format--bufferpos-to-filepos start 'approximate
                                                        'utf-8-unix))

        ;; always use ‘utf-8-unix’ and ignore the buffer coding system.
        (default-process-coding-system '(utf-8-unix . utf-8-unix)))
    (unwind-protect
        (let ((status (apply #'call-process-region
                             nil nil clang-format-executable
                             nil `(,temp-buffer ,temp-file) nil
                             `("-output-replacements-xml"
                               ;; Gaurd against a nil assume-file-name.
                               ;; If the clang-format option -assume-filename
                               ;; is given a blank string it will crash as per
                               ;; the following bug report
                               ;; https://bugs.llvm.org/show_bug.cgi?id=34667
                               ,@(and assume-file-name
                                      (list "-assume-filename" assume-file-name))
                               "-style" ,style
                               "-offset" ,(number-to-string file-start)
                               "-length" ,(number-to-string (- file-end file-start))
                               "-cursor" ,(number-to-string cursor))))
              (stderr (with-temp-buffer
                        (unless (zerop (cadr (insert-file-contents temp-file)))
                          (insert ": "))
