Skip to content

Commit b178cec

Browse files
committed
[clang][NFC] Annotate most of clang/Basic headers with preferred_type
This patch doesn't touch `CodeGenOptions.h`, `DiagnosticOptions.h`, `LangOptions.h`, `IdentifierTable.h`.
1 parent 6f1d3b9 commit b178cec

File tree

8 files changed

+75
-3
lines changed

8 files changed

+75
-3
lines changed

clang/include/clang/Basic/AttributeCommonInfo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,16 @@ class AttributeCommonInfo {
7474
SourceRange AttrRange;
7575
const SourceLocation ScopeLoc;
7676
// Corresponds to the Kind enum.
77+
LLVM_PREFERRED_TYPE(Kind)
7778
unsigned AttrKind : 16;
7879
/// Corresponds to the Syntax enum.
80+
LLVM_PREFERRED_TYPE(Syntax)
7981
unsigned SyntaxUsed : 4;
82+
LLVM_PREFERRED_TYPE(bool)
8083
unsigned SpellingIndex : 4;
84+
LLVM_PREFERRED_TYPE(bool)
8185
unsigned IsAlignas : 1;
86+
LLVM_PREFERRED_TYPE(bool)
8287
unsigned IsRegularKeywordAttribute : 1;
8388

8489
protected:
@@ -123,9 +128,12 @@ class AttributeCommonInfo {
123128
: SyntaxUsed(SyntaxUsed), SpellingIndex(SpellingNotCalculated),
124129
IsAlignas(0), IsRegularKeywordAttribute(0) {}
125130

131+
LLVM_PREFERRED_TYPE(Syntax)
126132
unsigned SyntaxUsed : 4;
127133
unsigned SpellingIndex : 4;
134+
LLVM_PREFERRED_TYPE(bool)
128135
unsigned IsAlignas : 1;
136+
LLVM_PREFERRED_TYPE(bool)
129137
unsigned IsRegularKeywordAttribute : 1;
130138
};
131139

clang/include/clang/Basic/Diagnostic.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,18 +314,23 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
314314
// "Global" configuration state that can actually vary between modules.
315315

316316
// Ignore all warnings: -w
317+
LLVM_PREFERRED_TYPE(bool)
317318
unsigned IgnoreAllWarnings : 1;
318319

319320
// Enable all warnings.
321+
LLVM_PREFERRED_TYPE(bool)
320322
unsigned EnableAllWarnings : 1;
321323

322324
// Treat warnings like errors.
325+
LLVM_PREFERRED_TYPE(bool)
323326
unsigned WarningsAsErrors : 1;
324327

325328
// Treat errors like fatal errors.
329+
LLVM_PREFERRED_TYPE(bool)
326330
unsigned ErrorsAsFatal : 1;
327331

328332
// Suppress warnings in system headers.
333+
LLVM_PREFERRED_TYPE(bool)
329334
unsigned SuppressSystemWarnings : 1;
330335

331336
// Map extensions to warnings or errors?
@@ -1822,12 +1827,17 @@ class ForwardingDiagnosticConsumer : public DiagnosticConsumer {
18221827
struct TemplateDiffTypes {
18231828
intptr_t FromType;
18241829
intptr_t ToType;
1830+
LLVM_PREFERRED_TYPE(bool)
18251831
unsigned PrintTree : 1;
1832+
LLVM_PREFERRED_TYPE(bool)
18261833
unsigned PrintFromType : 1;
1834+
LLVM_PREFERRED_TYPE(bool)
18271835
unsigned ElideType : 1;
1836+
LLVM_PREFERRED_TYPE(bool)
18281837
unsigned ShowColors : 1;
18291838

18301839
// The printer sets this variable to true if the template diff was used.
1840+
LLVM_PREFERRED_TYPE(bool)
18311841
unsigned TemplateDiffUsed : 1;
18321842
};
18331843

clang/include/clang/Basic/DiagnosticIDs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,17 @@ namespace clang {
100100
}
101101

102102
class DiagnosticMapping {
103+
LLVM_PREFERRED_TYPE(diag::Severity)
103104
unsigned Severity : 3;
105+
LLVM_PREFERRED_TYPE(bool)
104106
unsigned IsUser : 1;
107+
LLVM_PREFERRED_TYPE(bool)
105108
unsigned IsPragma : 1;
109+
LLVM_PREFERRED_TYPE(bool)
106110
unsigned HasNoWarningAsError : 1;
111+
LLVM_PREFERRED_TYPE(bool)
107112
unsigned HasNoErrorAsFatal : 1;
113+
LLVM_PREFERRED_TYPE(bool)
108114
unsigned WasUpgradedFromWarning : 1;
109115

110116
public:

clang/include/clang/Basic/Module.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,69 +298,85 @@ class alignas(8) Module {
298298
/// Whether this module has declared itself unimportable, either because
299299
/// it's missing a requirement from \p Requirements or because it's been
300300
/// shadowed by another module.
301+
LLVM_PREFERRED_TYPE(bool)
301302
unsigned IsUnimportable : 1;
302303

303304
/// Whether we tried and failed to load a module file for this module.
305+
LLVM_PREFERRED_TYPE(bool)
304306
unsigned HasIncompatibleModuleFile : 1;
305307

306308
/// Whether this module is available in the current translation unit.
307309
///
308310
/// If the module is missing headers or does not meet all requirements then
309311
/// this bit will be 0.
312+
LLVM_PREFERRED_TYPE(bool)
310313
unsigned IsAvailable : 1;
311314

312315
/// Whether this module was loaded from a module file.
316+
LLVM_PREFERRED_TYPE(bool)
313317
unsigned IsFromModuleFile : 1;
314318

315319
/// Whether this is a framework module.
320+
LLVM_PREFERRED_TYPE(bool)
316321
unsigned IsFramework : 1;
317322

318323
/// Whether this is an explicit submodule.
324+
LLVM_PREFERRED_TYPE(bool)
319325
unsigned IsExplicit : 1;
320326

321327
/// Whether this is a "system" module (which assumes that all
322328
/// headers in it are system headers).
329+
LLVM_PREFERRED_TYPE(bool)
323330
unsigned IsSystem : 1;
324331

325332
/// Whether this is an 'extern "C"' module (which implicitly puts all
326333
/// headers in it within an 'extern "C"' block, and allows the module to be
327334
/// imported within such a block).
335+
LLVM_PREFERRED_TYPE(bool)
328336
unsigned IsExternC : 1;
329337

330338
/// Whether this is an inferred submodule (module * { ... }).
339+
LLVM_PREFERRED_TYPE(bool)
331340
unsigned IsInferred : 1;
332341

333342
/// Whether we should infer submodules for this module based on
334343
/// the headers.
335344
///
336345
/// Submodules can only be inferred for modules with an umbrella header.
346+
LLVM_PREFERRED_TYPE(bool)
337347
unsigned InferSubmodules : 1;
338348

339349
/// Whether, when inferring submodules, the inferred submodules
340350
/// should be explicit.
351+
LLVM_PREFERRED_TYPE(bool)
341352
unsigned InferExplicitSubmodules : 1;
342353

343354
/// Whether, when inferring submodules, the inferr submodules should
344355
/// export all modules they import (e.g., the equivalent of "export *").
356+
LLVM_PREFERRED_TYPE(bool)
345357
unsigned InferExportWildcard : 1;
346358

347359
/// Whether the set of configuration macros is exhaustive.
348360
///
349361
/// When the set of configuration macros is exhaustive, meaning
350362
/// that no identifier not in this list should affect how the module is
351363
/// built.
364+
LLVM_PREFERRED_TYPE(bool)
352365
unsigned ConfigMacrosExhaustive : 1;
353366

354367
/// Whether files in this module can only include non-modular headers
355368
/// and headers from used modules.
369+
LLVM_PREFERRED_TYPE(bool)
356370
unsigned NoUndeclaredIncludes : 1;
357371

358372
/// Whether this module came from a "private" module map, found next
359373
/// to a regular (public) module map.
374+
LLVM_PREFERRED_TYPE(bool)
360375
unsigned ModuleMapIsPrivate : 1;
361376

362377
/// Whether this C++20 named modules doesn't need an initializer.
363378
/// This is only meaningful for C++20 modules.
379+
LLVM_PREFERRED_TYPE(bool)
364380
unsigned NamedModuleHasInit : 1;
365381

366382
/// Describes the visibility of the various names within a

clang/include/clang/Basic/ParsedAttrInfo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class TargetInfo;
3333

3434
struct ParsedAttrInfo {
3535
/// Corresponds to the Kind enum.
36+
LLVM_PREFERRED_TYPE(AttributeCommonInfo::Kind)
3637
unsigned AttrKind : 16;
3738
/// The number of required arguments of this attribute.
3839
unsigned NumArgs : 4;
@@ -41,18 +42,25 @@ struct ParsedAttrInfo {
4142
/// The number of non-fake arguments specified in the attribute definition.
4243
unsigned NumArgMembers : 4;
4344
/// True if the parsing does not match the semantic content.
45+
LLVM_PREFERRED_TYPE(bool)
4446
unsigned HasCustomParsing : 1;
4547
// True if this attribute accepts expression parameter pack expansions.
48+
LLVM_PREFERRED_TYPE(bool)
4649
unsigned AcceptsExprPack : 1;
4750
/// True if this attribute is only available for certain targets.
51+
LLVM_PREFERRED_TYPE(bool)
4852
unsigned IsTargetSpecific : 1;
4953
/// True if this attribute applies to types.
54+
LLVM_PREFERRED_TYPE(bool)
5055
unsigned IsType : 1;
5156
/// True if this attribute applies to statements.
57+
LLVM_PREFERRED_TYPE(bool)
5258
unsigned IsStmt : 1;
5359
/// True if this attribute has any spellings that are known to gcc.
60+
LLVM_PREFERRED_TYPE(bool)
5461
unsigned IsKnownToGCC : 1;
5562
/// True if this attribute is supported by #pragma clang attribute.
63+
LLVM_PREFERRED_TYPE(bool)
5664
unsigned IsSupportedByPragmaAttribute : 1;
5765
/// The syntaxes supported by this attribute and how they're spelled.
5866
struct Spelling {

clang/include/clang/Basic/SourceManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,21 @@ class alignas(8) ContentCache {
167167
///
168168
/// When true, the original entry may be a virtual file that does not
169169
/// exist.
170+
LLVM_PREFERRED_TYPE(bool)
170171
unsigned BufferOverridden : 1;
171172

172173
/// True if this content cache was initially created for a source file
173174
/// considered to be volatile (likely to change between stat and open).
175+
LLVM_PREFERRED_TYPE(bool)
174176
unsigned IsFileVolatile : 1;
175177

176178
/// True if this file may be transient, that is, if it might not
177179
/// exist at some later point in time when this content entry is used,
178180
/// after serialization and deserialization.
181+
LLVM_PREFERRED_TYPE(bool)
179182
unsigned IsTransient : 1;
180183

184+
LLVM_PREFERRED_TYPE(bool)
181185
mutable unsigned IsBufferInvalid : 1;
182186

183187
ContentCache()
@@ -305,6 +309,7 @@ class FileInfo {
305309
unsigned NumCreatedFIDs : 31;
306310

307311
/// Whether this FileInfo has any \#line directives.
312+
LLVM_PREFERRED_TYPE(bool)
308313
unsigned HasLineDirectives : 1;
309314

310315
/// The content cache and the characteristic of the file.
@@ -476,6 +481,7 @@ static_assert(sizeof(FileInfo) <= sizeof(ExpansionInfo),
476481
class SLocEntry {
477482
static constexpr int OffsetBits = 8 * sizeof(SourceLocation::UIntTy) - 1;
478483
SourceLocation::UIntTy Offset : OffsetBits;
484+
LLVM_PREFERRED_TYPE(bool)
479485
SourceLocation::UIntTy IsExpansion : 1;
480486
union {
481487
FileInfo File;

clang/include/clang/Basic/Specifiers.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,13 @@ namespace clang {
103103
/// were written in a particular type specifier sequence.
104104
struct WrittenBuiltinSpecs {
105105
static_assert(TST_error < 1 << 7, "Type bitfield not wide enough for TST");
106-
/*DeclSpec::TST*/ unsigned Type : 7;
107-
/*DeclSpec::TSS*/ unsigned Sign : 2;
108-
/*TypeSpecifierWidth*/ unsigned Width : 2;
106+
LLVM_PREFERRED_TYPE(TypeSpecifierType)
107+
unsigned Type : 7;
108+
LLVM_PREFERRED_TYPE(TypeSpecifierSign)
109+
unsigned Sign : 2;
110+
LLVM_PREFERRED_TYPE(TypeSpecifierWidth)
111+
unsigned Width : 2;
112+
LLVM_PREFERRED_TYPE(bool)
109113
unsigned ModeAttr : 1;
110114
};
111115

clang/include/clang/Basic/TargetInfo.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,15 @@ struct TransferrableTargetInfo {
156156
///
157157
/// Otherwise, when this flag is not set, the normal built-in boolean type is
158158
/// used.
159+
LLVM_PREFERRED_TYPE(bool)
159160
unsigned UseSignedCharForObjCBool : 1;
160161

161162
/// Control whether the alignment of bit-field types is respected when laying
162163
/// out structures. If true, then the alignment of the bit-field type will be
163164
/// used to (a) impact the alignment of the containing structure, and (b)
164165
/// ensure that the individual bit-field will not straddle an alignment
165166
/// boundary.
167+
LLVM_PREFERRED_TYPE(bool)
166168
unsigned UseBitFieldTypeAlignment : 1;
167169

168170
/// Whether zero length bitfields (e.g., int : 0;) force alignment of
@@ -171,13 +173,16 @@ struct TransferrableTargetInfo {
171173
/// If the alignment of the zero length bitfield is greater than the member
172174
/// that follows it, `bar', `bar' will be aligned as the type of the
173175
/// zero-length bitfield.
176+
LLVM_PREFERRED_TYPE(bool)
174177
unsigned UseZeroLengthBitfieldAlignment : 1;
175178

176179
/// Whether zero length bitfield alignment is respected if they are the
177180
/// leading members.
181+
LLVM_PREFERRED_TYPE(bool)
178182
unsigned UseLeadingZeroLengthBitfield : 1;
179183

180184
/// Whether explicit bit field alignment attributes are honored.
185+
LLVM_PREFERRED_TYPE(bool)
181186
unsigned UseExplicitBitFieldAlignment : 1;
182187

183188
/// If non-zero, specifies a fixed alignment value for bitfields that follow
@@ -239,20 +244,29 @@ class TargetInfo : public TransferrableTargetInfo,
239244
mutable StringRef PlatformName;
240245
mutable VersionTuple PlatformMinVersion;
241246

247+
LLVM_PREFERRED_TYPE(bool)
242248
unsigned HasAlignMac68kSupport : 1;
249+
LLVM_PREFERRED_TYPE(FloatModeKind)
243250
unsigned RealTypeUsesObjCFPRetMask : llvm::BitWidth<FloatModeKind>;
251+
LLVM_PREFERRED_TYPE(bool)
244252
unsigned ComplexLongDoubleUsesFP2Ret : 1;
245253

254+
LLVM_PREFERRED_TYPE(bool)
246255
unsigned HasBuiltinMSVaList : 1;
247256

257+
LLVM_PREFERRED_TYPE(bool)
248258
unsigned IsRenderScriptTarget : 1;
249259

260+
LLVM_PREFERRED_TYPE(bool)
250261
unsigned HasAArch64SVETypes : 1;
251262

263+
LLVM_PREFERRED_TYPE(bool)
252264
unsigned HasRISCVVTypes : 1;
253265

266+
LLVM_PREFERRED_TYPE(bool)
254267
unsigned AllowAMDGPUUnsafeFPAtomics : 1;
255268

269+
LLVM_PREFERRED_TYPE(bool)
256270
unsigned ARMCDECoprocMask : 8;
257271

258272
unsigned MaxOpenCLWorkGroupSize;

0 commit comments

Comments
 (0)