Skip to content

Commit 12a6d58

Browse files
committed
Apply suggestions from vbvictor.
1 parent ccf539e commit 12a6d58

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

clang-tools-extra/clang-tidy/portability/AvoidPragmaOnceCheck.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,15 @@ class PragmaOnceCallbacks : public PPCallbacks {
2222
void PragmaDirective(SourceLocation Loc,
2323
PragmaIntroducerKind Introducer) override {
2424
auto Str = llvm::StringRef(SM.getCharacterData(Loc));
25-
if (!Str.consume_front("#")) {
25+
if (!Str.consume_front("#"))
2626
return;
27-
}
2827
Str = Str.trim();
29-
if (!Str.consume_front("pragma")) {
28+
if (!Str.consume_front("pragma"))
3029
return;
31-
}
3230
Str = Str.trim();
33-
if (Str.starts_with("once")) {
31+
if (Str.starts_with("once"))
3432
Check->diag(Loc,
3533
"avoid 'pragma once' directive; use include guards instead");
36-
}
3734
}
3835

3936
private:

clang-tools-extra/docs/clang-tidy/checks/portability/avoid-pragma-once.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include guards (``#ifndef``/``#define``/``#endif``) for improved portability.
88

99
``#pragma once`` is a non-standard extension, despite being widely supported
1010
by modern compilers. Relying on it can lead to portability issues in
11-
environments.
11+
some environments.
1212

1313
Some older or specialized C/C++ compilers, particularly in embedded systems,
1414
may not fully support ``#pragma once``.

0 commit comments

Comments
 (0)