[Clang] Fix a Wbitfield-enum-conversion warning in DirectoryLookup.h
authorShivam Gupta <shivam98.tkg@gmail.com>
Mon, 23 Jan 2023 18:18:37 +0000 (23:48 +0530)
committerShivam Gupta <shivam98.tkg@gmail.com>
Mon, 23 Jan 2023 18:18:48 +0000 (23:48 +0530)
commit94b9187a7d37e4269af35f8f7ec8e0f78fd6a06e
tree7d6db559539f4631314bd5179d0b76ef8402aa70
parenta15b0e86cbfd4fa68aaa68c13d6bd34d8f839c9a
[Clang] Fix a Wbitfield-enum-conversion warning in DirectoryLookup.h

When compiling clang/Lex/DirectoryLookup.h with option -Wbitfield-enum-conversion, we get the following warning:

DirectoryLookup.h:77:17: warning:
      bit-field 'DirCharacteristic' is not wide enough to store all enumerators of
      'CharacteristicKind' [-Wbitfield-enum-conversion]
      : u(Map), DirCharacteristic(DT), LookupType(LT_HeaderMap),

DirCharacteristic is a bitfield with 2 bits (4 values)
  /// DirCharacteristic - The type of directory this is: this is an instance of
  /// SrcMgr::CharacteristicKind.
  unsigned DirCharacteristic : 2;

Whereas SrcMgr::CharacterKind is an enum with 5 values:
enum CharacteristicKind {
  C_User,
  C_System,
  C_ExternCSystem,
  C_User_ModuleMap,
  C_System_ModuleMap
};

Solution is to increase DirCharacteristic bitfield from 2 to 3.
Patch by Dimitri van Heesch

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D142304
clang/include/clang/Lex/DirectoryLookup.h