llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.15k stars 12.03k forks source link

[clang-format] Support extern "C" namespace statement #54810

Open ikspress opened 2 years ago

ikspress commented 2 years ago

In the extern "C" namespace statement, clang-format treats it as a normal scope instead of namespace.

e.g.

# .clang-format
BasedOnStyle: LLVM
NamespaceIndentation: None
// test.hh
extern "C" namespace foo {
  class bar;
  void foo(bar * response) noexcept;
}

Obviously this is wrong.

A simple workaround is as follows

#define EXTERN_NAMESPACE(name, lang) extern #lang namespace name
EXTERN_NAMESPACE(foo, C)
llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-format

EugeneZelenko commented 2 months ago

@ikspress: Could you please elaborate?

ikspress commented 2 months ago

@ikspress: Could you please elaborate?

Okay, I will report it in a new issue with more information.

EugeneZelenko commented 2 months ago

@ikspress: You could just modify this ticket if underlying problem is same.