[llvm-bugs] [Bug 47255] New: clang-format needs to run twice

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 20 07:04:21 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47255

            Bug ID: 47255
           Summary: clang-format needs to run twice
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Scott.Bauer at gd-ms.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Created attachment 23867
  --> https://bugs.llvm.org/attachment.cgi?id=23867&action=edit
The .clang-format configuration we are using

The file temp.h needs to be run through clang-format twice in order for it to
be fully formatted.

temp.h
const int64_t MAX_COLLECTION = 1; //parasoft-suppress MISRA2008 "ignore global
namespace"
const uint32_t NUM_BIT_FUNCTIONS = 10;

sbauer at fozzie ~/source/
$ git add temp.h

sbauer at fozzie ~/source/
$ cat temp.h
const int64_t MAX_COLLECTION = 1; //parasoft-suppress MISRA2008 "ignore global
namespace"
const uint32_t NUM_BIT_FUNCTIONS = 10;

sbauer at fozzie ~/source/
$ clang-format -style=file temp.h -i

sbauer at fozzie ~/source/
$ git diff
diff --git a/temp.h b/temp.h
index 65afc77f..b6962bcf 100644
--- a/temp.h
+++ b/temp.h
@@ -1,2 +1,2 @@
-const int64_t MAX_COLLECTION = 1; //parasoft-suppress MISRA2008 "ignore global
namespace"
+const int64_t  MAX_COLLECTION = 1;    // parasoft-suppress MISRA2008 "ignore
global namespace"
const uint32_t NUM_BIT_FUNCTIONS = 10;

sbauer at fozzie ~/source/
$ git add temp.h

sbauer at fozzie ~/source/
$ clang-format -style=file temp.h -i

sbauer at fozzie ~/source/
$ git diff
diff --git a/temp.h b/temp.h
index b6962bcf..ea1585f2 100644
--- a/temp.h
+++ b/temp.h
@@ -1,2 +1,2 @@
-const int64_t  MAX_COLLECTION = 1;    // parasoft-suppress MISRA2008 "ignore
global namespace"
+const int64_t  MAX_COLLECTION    = 1;    // parasoft-suppress MISRA2008
"ignore global namespace"
const uint32_t NUM_BIT_FUNCTIONS = 10;

sbauer at fozzie ~/source/
$ git status
On branch feature/los_882
Your branch is behind 'origin/feature/los_882' by 1 commit, and can be
fast-forwarded.
  (use "git pull" to update your local branch)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   temp.h

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   temp.h

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200820/4ed3b014/attachment.html>


More information about the llvm-bugs mailing list