flang icon indicating copy to clipboard operation
flang copied to clipboard

Unify and fix hashset/hashmap implementations

Open bryanpkc opened this issue 4 years ago • 0 comments

Classic Flang contains two implementations of hashset and hashmap that are almost identical:

  • https://github.com/flang-compiler/flang/blob/master/tools/flang1/flang1exe/hash.c
  • https://github.com/flang-compiler/flang/blob/master/lib/ADT/hash.c

The first one is used by flang1, and the second is used by flang2. It seems that plan was to reuse the code between flang1 and flang2, but that effort was abandoned half-way through. It would be nice to unify these implementations.

Both of these implementations suffer require type casts on arguments to their APIs. Specifically, hash_key_t and hash_data_t are typedef-ed to const void *, and throughout the code base these casts often have to add or drop the const qualifier, resulting in -Wcast-qual warnings, which turn into compile-time errors when -Werror is enabled. #1073 avoided these warnings with diagnostic pragmas, but ideally the APIs could be rewritten to avoid dropping the const qualifier, or at least to reduce the number of places where pragmas are needed.

bryanpkc avatar Jul 13 '21 17:07 bryanpkc