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: unassignedclangb...@nondot.org
          Reporter: scott.ba...@gd-ms.com
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@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@fozzie ~/source/
$ git add temp.h

sbauer@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@fozzie ~/source/
$ clang-format -style=file temp.h -i

sbauer@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@fozzie ~/source/
$ git add temp.h

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

sbauer@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@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to