[clang] 053bdb7 - [clang] Bump AS_GNU to 1
Richard Sandiford via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 13 02:16:04 PDT 2023
Author: Richard Sandiford
Date: 2023-04-13T10:14:50+01:00
New Revision: 053bdb77b0ce4506d15ed381b6db0dddafe52c3e
URL: https://github.com/llvm/llvm-project/commit/053bdb77b0ce4506d15ed381b6db0dddafe52c3e
DIFF: https://github.com/llvm/llvm-project/commit/053bdb77b0ce4506d15ed381b6db0dddafe52c3e.diff
LOG: [clang] Bump AS_GNU to 1
Following a suggestion from Erich in https://reviews.llvm.org/D148101,
this patch bumps AS_GNU to 1 so that syntax 0 is invalid. It also
asserts that the syntax is in range.
Differential Revision: https://reviews.llvm.org/D148148
Added:
Modified:
clang/include/clang/Basic/AttributeCommonInfo.h
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h b/clang/include/clang/Basic/AttributeCommonInfo.h
index a68f8d97e91a..a92dc0dad515 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -25,7 +25,7 @@ class AttributeCommonInfo {
/// The style used to specify an attribute.
enum Syntax {
/// __attribute__((...))
- AS_GNU,
+ AS_GNU = 1,
/// [[...]]
AS_CXX11,
@@ -122,37 +122,32 @@ class AttributeCommonInfo {
AttributeCommonInfo(const IdentifierInfo *AttrName,
const IdentifierInfo *ScopeName, SourceRange AttrRange,
- SourceLocation ScopeLoc, Form FormUsed)
+ SourceLocation ScopeLoc, Kind AttrKind, Form FormUsed)
: AttrName(AttrName), ScopeName(ScopeName), AttrRange(AttrRange),
- ScopeLoc(ScopeLoc),
- AttrKind(getParsedKind(AttrName, ScopeName, FormUsed.getSyntax())),
+ ScopeLoc(ScopeLoc), AttrKind(AttrKind),
SyntaxUsed(FormUsed.getSyntax()),
SpellingIndex(FormUsed.getSpellingIndex()),
- IsAlignas(FormUsed.isAlignas()) {}
+ IsAlignas(FormUsed.isAlignas()) {
+ assert(SyntaxUsed >= AS_GNU && SyntaxUsed <= AS_Implicit &&
+ "Invalid syntax!");
+ }
AttributeCommonInfo(const IdentifierInfo *AttrName,
const IdentifierInfo *ScopeName, SourceRange AttrRange,
- SourceLocation ScopeLoc, Kind AttrKind, Form FormUsed)
- : AttrName(AttrName), ScopeName(ScopeName), AttrRange(AttrRange),
- ScopeLoc(ScopeLoc), AttrKind(AttrKind),
- SyntaxUsed(FormUsed.getSyntax()),
- SpellingIndex(FormUsed.getSpellingIndex()),
- IsAlignas(FormUsed.isAlignas()) {}
+ SourceLocation ScopeLoc, Form FormUsed)
+ : AttributeCommonInfo(
+ AttrName, ScopeName, AttrRange, ScopeLoc,
+ getParsedKind(AttrName, ScopeName, FormUsed.getSyntax()),
+ FormUsed) {}
AttributeCommonInfo(const IdentifierInfo *AttrName, SourceRange AttrRange,
Form FormUsed)
- : AttrName(AttrName), ScopeName(nullptr), AttrRange(AttrRange),
- ScopeLoc(),
- AttrKind(getParsedKind(AttrName, ScopeName, FormUsed.getSyntax())),
- SyntaxUsed(FormUsed.getSyntax()),
- SpellingIndex(FormUsed.getSpellingIndex()),
- IsAlignas(FormUsed.isAlignas()) {}
+ : AttributeCommonInfo(AttrName, nullptr, AttrRange, SourceLocation(),
+ FormUsed) {}
AttributeCommonInfo(SourceRange AttrRange, Kind K, Form FormUsed)
- : AttrName(nullptr), ScopeName(nullptr), AttrRange(AttrRange), ScopeLoc(),
- AttrKind(K), SyntaxUsed(FormUsed.getSyntax()),
- SpellingIndex(FormUsed.getSpellingIndex()),
- IsAlignas(FormUsed.isAlignas()) {}
+ : AttributeCommonInfo(nullptr, nullptr, AttrRange, SourceLocation(), K,
+ FormUsed) {}
AttributeCommonInfo(AttributeCommonInfo &&) = default;
AttributeCommonInfo(const AttributeCommonInfo &) = default;
More information about the cfe-commits
mailing list