Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-format] pragmas are considered hashes in IndentPPDirectives #97891

Closed
zeule opened this issue Jul 6, 2024 · 3 comments
Closed

[clang-format] pragmas are considered hashes in IndentPPDirectives #97891

zeule opened this issue Jul 6, 2024 · 3 comments
Labels
clang-format invalid Resolved as invalid, i.e. not a bug

Comments

@zeule
Copy link

zeule commented Jul 6, 2024

When IndentPPDirectives is set to AfterHash, placing #pragma once at the beginning of the include file make all #include directives indented.

@owenca owenca added the incomplete Issue not complete (e.g. missing a reproducer, build arguments, etc.) label Jul 6, 2024
@owenca
Copy link
Contributor

owenca commented Jul 6, 2024

Please provide the version and config of clang-format and the code snippet you used.

@zeule
Copy link
Author

zeule commented Jul 6, 2024

Oops, sorry: llvm 18.1.8

.clang-format:

---
BasedOnStyle: LLVM
Language: Cpp
TabWidth: 4
UseTab: AlignWithSpaces
IndentWidth: 4

IndentPPDirectives: AfterHash

In a fragment:

#pragma once
#ifndef HEADER_ID_H
#define HEADER_ID_H // (1)

clang-format inserts indent in (1) after the hash sign

@owenca owenca added invalid Resolved as invalid, i.e. not a bug and removed incomplete Issue not complete (e.g. missing a reproducer, build arguments, etc.) labels Jul 7, 2024
@owenca
Copy link
Contributor

owenca commented Jul 7, 2024

In a fragment:

#pragma once
#ifndef HEADER_ID_H
#define HEADER_ID_H // (1)

clang-format inserts indent in (1) after the hash sign

Doesn't the pragma make the header guard redundant and vice versa? Anyway, clang-format checks for header guards only at the beginning of the input as it's supposed to.

@owenca owenca closed this as completed Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-format invalid Resolved as invalid, i.e. not a bug
Projects
None yet
Development

No branches or pull requests

2 participants