llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[clang-format] Google-Style on sorting Includes moves them into comment & breaks code

Open iAroc opened this issue 1 year ago • 0 comments

if you have a few includes commented out with a multiline comment (e.g. /* */) and then use clang-format on based google style to sort, it will move needed includes into the comment.

my includes pre sort:

#include <Log.h>
#include <Misc.h>
#include <TryCatch.h>
#include <robin_hood.h>

/* #include "DBO_Articles/DBO_Articles.h"
#include "DBO_Customers/DBO_Customers.h"
#include "DBO_PackagingOrders/DBO_PackagingOrders.h"
#include "DBO_PickingListRegistrations/DBO_PickingListRegistrations.h" */
#include "MySQL/MySQL.h"
#include "SQLJob.h"
#include "Time/Time.h"
#include "Worker/Worker.h"

#include <chrono>
#include <thread>

and after clang format sort:

#include <Misc.h>
#include <TryCatch.h>
#include <robin_hood.h>

/* #include "DBO_Articles/DBO_Articles.h"
#include <chrono>
#include <thread>

#include "DBO_Customers/DBO_Customers.h"
#include "DBO_PackagingOrders/DBO_PackagingOrders.h"
#include "DBO_PickingListRegistrations/DBO_PickingListRegistrations.h" */
#include "MySQL/MySQL.h"
#include "SQLJob.h"
#include "Time/Time.h"
#include "Worker/Worker.h"

as seen in the example, it moved the chrono and thread includes into the comment, which should not happen, since it breaks code

here is my clang format

BasedOnStyle: Google
SpaceBeforeRangeBasedForLoopColon: false
ReferenceAlignment: Left
PointerAlignment: Left
AlignConsecutiveDeclarations: true
IndentWidth: 4
ColumnLimit: 0
BreakBeforeBraces: Attach
AllowShortFunctionsOnASingleLine: false
AllowShortLambdasOnASingleLine: false
DerivePointerAlignment: false
NamespaceIndentation: All
QualifierAlignment: Right

BraceWrapping:
  AfterControlStatement: true
  SplitEmptyFunction: false

iAroc avatar Jul 03 '24 08:07 iAroc