[clang] 58679ea - [clang][NFC] Annotate `clang/Lex` headers with `preferred_type`

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 6 01:34:18 PST 2023


Author: Vlad Serebrennikov
Date: 2023-11-06T12:34:10+03:00
New Revision: 58679ea576f9e48e20e43dcd99fd75c98fb7e6ba

URL: https://github.com/llvm/llvm-project/commit/58679ea576f9e48e20e43dcd99fd75c98fb7e6ba
DIFF: https://github.com/llvm/llvm-project/commit/58679ea576f9e48e20e43dcd99fd75c98fb7e6ba.diff

LOG: [clang][NFC] Annotate `clang/Lex` headers with `preferred_type`

This helps debuggers display unsigned bit-fields correctly.

Added: 
    

Modified: 
    clang/include/clang/Lex/DirectoryLookup.h
    clang/include/clang/Lex/HeaderSearch.h
    clang/include/clang/Lex/HeaderSearchOptions.h
    clang/include/clang/Lex/MacroInfo.h
    clang/include/clang/Lex/ModuleMap.h
    clang/include/clang/Lex/PreprocessingRecord.h
    clang/include/clang/Lex/VariadicMacroSupport.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Lex/DirectoryLookup.h b/clang/include/clang/Lex/DirectoryLookup.h
index d668a830db38fd1..81680d3b271e081 100644
--- a/clang/include/clang/Lex/DirectoryLookup.h
+++ b/clang/include/clang/Lex/DirectoryLookup.h
@@ -50,17 +50,21 @@ class DirectoryLookup {
 
   /// DirCharacteristic - The type of directory this is: this is an instance of
   /// SrcMgr::CharacteristicKind.
+  LLVM_PREFERRED_TYPE(SrcMgr::CharacteristicKind)
   unsigned DirCharacteristic : 3;
 
   /// LookupType - This indicates whether this DirectoryLookup object is a
   /// normal directory, a framework, or a headermap.
+  LLVM_PREFERRED_TYPE(LookupType_t)
   unsigned LookupType : 2;
 
   /// Whether this is a header map used when building a framework.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsIndexHeaderMap : 1;
 
   /// Whether we've performed an exhaustive search for module maps
   /// within the subdirectories of this directory.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned SearchedAllModuleMaps : 1;
 
 public:

diff  --git a/clang/include/clang/Lex/HeaderSearch.h b/clang/include/clang/Lex/HeaderSearch.h
index a212eea7cfd0cb9..a100598c80155fa 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -59,29 +59,36 @@ struct HeaderFileInfo {
   // TODO: Whether the file was imported is not a property of the file itself.
   // It's a preprocessor state, move it there.
   /// True if this is a \#import'd file.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned isImport : 1;
 
   /// True if this is a \#pragma once file.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned isPragmaOnce : 1;
 
   /// Keep track of whether this is a system header, and if so,
   /// whether it is C++ clean or not.  This can be set by the include paths or
   /// by \#pragma gcc system_header.  This is an instance of
   /// SrcMgr::CharacteristicKind.
+  LLVM_PREFERRED_TYPE(SrcMgr::CharacteristicKind)
   unsigned DirInfo : 3;
 
   /// Whether this header file info was supplied by an external source,
   /// and has not changed since.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned External : 1;
 
   /// Whether this header is part of a module.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned isModuleHeader : 1;
 
   /// Whether this header is part of the module that we are building.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned isCompilingModuleHeader : 1;
 
   /// Whether this structure is considered to already have been
   /// "resolved", meaning that it was loaded from the external source.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned Resolved : 1;
 
   /// Whether this is a header inside a framework that is currently
@@ -91,9 +98,11 @@ struct HeaderFileInfo {
   /// into the appropriate framework subdirectories, and therefore are
   /// provided via a header map. This bit indicates when this is one of
   /// those framework headers.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IndexHeaderMapHeader : 1;
 
   /// Whether this file has been looked up as a header.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsValid : 1;
 
   /// The ID number of the controlling macro.

diff  --git a/clang/include/clang/Lex/HeaderSearchOptions.h b/clang/include/clang/Lex/HeaderSearchOptions.h
index 7f162efe4f0d4b3..114af14dec7f5a8 100644
--- a/clang/include/clang/Lex/HeaderSearchOptions.h
+++ b/clang/include/clang/Lex/HeaderSearchOptions.h
@@ -70,11 +70,13 @@ class HeaderSearchOptions {
   struct Entry {
     std::string Path;
     frontend::IncludeDirGroup Group;
+    LLVM_PREFERRED_TYPE(bool)
     unsigned IsFramework : 1;
 
     /// IgnoreSysRoot - This is false if an absolute path should be treated
     /// relative to the sysroot, or true if it should always be the absolute
     /// path.
+    LLVM_PREFERRED_TYPE(bool)
     unsigned IgnoreSysRoot : 1;
 
     Entry(StringRef path, frontend::IncludeDirGroup group, bool isFramework,
@@ -128,10 +130,12 @@ class HeaderSearchOptions {
   /// module cache.
   ///
   /// Note: Only used for testing!
+  LLVM_PREFERRED_TYPE(bool)
   unsigned DisableModuleHash : 1;
 
   /// Implicit module maps.  This option is enabld by default when
   /// modules is enabled.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ImplicitModuleMaps : 1;
 
   /// Set the 'home directory' of a module map file to the current
@@ -141,16 +145,19 @@ class HeaderSearchOptions {
   //
   /// The home directory is where we look for files named in the module map
   /// file.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ModuleMapFileHomeIsCwd : 1;
 
   /// Set the base path of a built module file to be the current working
   /// directory. This is useful for sharing module files across machines
   /// that build with 
diff erent paths without having to rewrite all
   /// modulemap files to have working directory relative paths.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ModuleFileHomeIsCwd : 1;
 
   /// Also search for prebuilt implicit modules in the prebuilt module cache
   /// path.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned EnablePrebuiltImplicitModules : 1;
 
   /// The interval (in seconds) between pruning operations.
@@ -185,48 +192,62 @@ class HeaderSearchOptions {
   std::vector<std::string> VFSOverlayFiles;
 
   /// Include the compiler builtin includes.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned UseBuiltinIncludes : 1;
 
   /// Include the system standard include search directories.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned UseStandardSystemIncludes : 1;
 
   /// Include the system standard C++ library include search directories.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned UseStandardCXXIncludes : 1;
 
   /// Use libc++ instead of the default libstdc++.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned UseLibcxx : 1;
 
   /// Whether header search information should be output as for -v.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned Verbose : 1;
 
   /// If true, skip verifying input files used by modules if the
   /// module was already verified during this build session (see
   /// \c BuildSessionTimestamp).
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ModulesValidateOncePerBuildSession : 1;
 
   /// Whether to validate system input files when a module is loaded.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ModulesValidateSystemHeaders : 1;
 
   // Whether the content of input files should be hashed and used to
   // validate consistency.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ValidateASTInputFilesContent : 1;
 
   // Whether the input files from C++20 Modules should be checked.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ForceCheckCXX20ModulesInputFiles : 1;
 
   /// Whether the module includes debug information (-gmodules).
+  LLVM_PREFERRED_TYPE(bool)
   unsigned UseDebugInfo : 1;
 
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ModulesValidateDiagnosticOptions : 1;
 
   /// Whether to entirely skip writing diagnostic options.
   /// Primarily used to speed up deserialization during dependency scanning.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ModulesSkipDiagnosticOptions : 1;
 
   /// Whether to entirely skip writing header search paths.
   /// Primarily used to speed up deserialization during dependency scanning.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ModulesSkipHeaderSearchPaths : 1;
 
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ModulesHashContent : 1;
 
   /// Whether we should include all things that could impact the module in the
@@ -234,6 +255,7 @@ class HeaderSearchOptions {
   ///
   /// This includes things like the full header search path, and enabled
   /// diagnostics.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned ModulesStrictContextHash : 1;
 
   HeaderSearchOptions(StringRef _Sysroot = "/")

diff  --git a/clang/include/clang/Lex/MacroInfo.h b/clang/include/clang/Lex/MacroInfo.h
index 00c1c3866bbd9ca..1237fc62eb6cf39 100644
--- a/clang/include/clang/Lex/MacroInfo.h
+++ b/clang/include/clang/Lex/MacroInfo.h
@@ -325,15 +325,18 @@ class MacroDirective {
   SourceLocation Loc;
 
   /// MacroDirective kind.
+  LLVM_PREFERRED_TYPE(Kind)
   unsigned MDKind : 2;
 
   /// True if the macro directive was loaded from a PCH file.
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsFromPCH : 1;
 
   // Used by VisibilityMacroDirective ----------------------------------------//
 
   /// Whether the macro has public visibility (when described in a
   /// module).
+  LLVM_PREFERRED_TYPE(bool)
   unsigned IsPublic : 1;
 
   MacroDirective(Kind K, SourceLocation Loc)

diff  --git a/clang/include/clang/Lex/ModuleMap.h b/clang/include/clang/Lex/ModuleMap.h
index 69ec8f34a324255..d5824713970ea7b 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -232,16 +232,20 @@ class ModuleMap {
   /// The set of attributes that can be attached to a module.
   struct Attributes {
     /// Whether this is a system module.
+    LLVM_PREFERRED_TYPE(bool)
     unsigned IsSystem : 1;
 
     /// Whether this is an extern "C" module.
+    LLVM_PREFERRED_TYPE(bool)
     unsigned IsExternC : 1;
 
     /// Whether this is an exhaustive set of configuration macros.
+    LLVM_PREFERRED_TYPE(bool)
     unsigned IsExhaustive : 1;
 
     /// Whether files in this module can only include non-modular headers
     /// and headers from used modules.
+    LLVM_PREFERRED_TYPE(bool)
     unsigned NoUndeclaredIncludes : 1;
 
     Attributes()
@@ -252,6 +256,7 @@ class ModuleMap {
   /// A directory for which framework modules can be inferred.
   struct InferredDirectory {
     /// Whether to infer modules from this directory.
+    LLVM_PREFERRED_TYPE(bool)
     unsigned InferModules : 1;
 
     /// The attributes to use for inferred modules.

diff  --git a/clang/include/clang/Lex/PreprocessingRecord.h b/clang/include/clang/Lex/PreprocessingRecord.h
index 00f1bfd7394b2a1..5ddf024186f8655 100644
--- a/clang/include/clang/Lex/PreprocessingRecord.h
+++ b/clang/include/clang/Lex/PreprocessingRecord.h
@@ -228,15 +228,18 @@ class Token;
 
     /// Whether the file name was in quotation marks; otherwise, it was
     /// in angle brackets.
+    LLVM_PREFERRED_TYPE(bool)
     unsigned InQuotes : 1;
 
     /// The kind of inclusion directive we have.
     ///
     /// This is a value of type InclusionKind.
+    LLVM_PREFERRED_TYPE(InclusionKind)
     unsigned Kind : 2;
 
     /// Whether the inclusion directive was automatically turned into
     /// a module import.
+    LLVM_PREFERRED_TYPE(bool)
     unsigned ImportedModule : 1;
 
     /// The file that was included.

diff  --git a/clang/include/clang/Lex/VariadicMacroSupport.h b/clang/include/clang/Lex/VariadicMacroSupport.h
index 119f02201fc6144..cf86a00c6d66370 100644
--- a/clang/include/clang/Lex/VariadicMacroSupport.h
+++ b/clang/include/clang/Lex/VariadicMacroSupport.h
@@ -129,11 +129,16 @@ namespace clang {
     // the function-like macro's new replacement list.
     int NumOfTokensPriorToVAOpt = -1;
 
+    LLVM_PREFERRED_TYPE(bool)
     unsigned LeadingSpaceForStringifiedToken : 1;
 
+    LLVM_PREFERRED_TYPE(bool)
     unsigned StringifyBefore : 1;
+    LLVM_PREFERRED_TYPE(bool)
     unsigned CharifyBefore : 1;
+    LLVM_PREFERRED_TYPE(bool)
     unsigned BeginsWithPlaceholder : 1;
+    LLVM_PREFERRED_TYPE(bool)
     unsigned EndsWithPlaceholder : 1;
 
     bool hasStringifyBefore() const {


        


More information about the cfe-commits mailing list