Skip to content

[NFC][TableGen] Refactor preprocessor directive handling #102967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2024

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Aug 12, 2024

  • Make PreprocessorDirs array constexpr, move its definition outside the anonymous namespace, and make it static.
  • Change Word field to a StringRef.
  • Simplify prepIsDirective to use StringRef comparison and early continue per LLVM coding standards.
  • Use C++17 structured bindings to iterate over the array.

@jurahul jurahul marked this pull request as ready for review August 12, 2024 21:48
Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make PreprocessDirs array constexpr

The subject isn't accurate as this patch has other refactoring.

};
} // end anonymous namespace

static constexpr PreprocessorDir PreprocessorDirs[] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just constexpr. This has internal linkage even without static

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jurahul
Copy link
Contributor Author

jurahul commented Aug 12, 2024

The subject isn't accurate as this patch has other refactoring.

How about: Refactor preprocessor directive handling in TableGen ?

- Make `PreprocessorDirs` array constexpr, move its definition outside the
  anonymous namespace, and make it static.
- Change `Word` field to a StringRef.
- Simplify `prepIsDirective` to use StringRef comparison and early `continue`
  per LLVM coding standards.
- Use C++17 structured bindings to iterate over the array.
@jurahul jurahul force-pushed the constexpr_PreprocessorDirs branch from 55536b6 to 00f731f Compare August 12, 2024 23:56
@jurahul jurahul changed the title [NFC][TableGen] Make PreprocessDirs array constexpr [NFC][TableGen] Refactor preprocessor directive handling Aug 12, 2024
@jurahul
Copy link
Contributor Author

jurahul commented Aug 13, 2024

Thanks @s-barannikov. Can one of you please merge the PR?

@s-barannikov s-barannikov merged commit b8fc97f into llvm:main Aug 13, 2024
9 checks passed
@jurahul
Copy link
Contributor Author

jurahul commented Aug 13, 2024

Thanks!

@jurahul jurahul deleted the constexpr_PreprocessorDirs branch August 13, 2024 04:10
jurahul added a commit to jurahul/llvm-project that referenced this pull request Aug 13, 2024
- Fixes an issue in llvm#102967,
  which inddvertently changed the type of `NextChar` from int to char,
  causing ppc64le build failures.
s-barannikov pushed a commit that referenced this pull request Aug 13, 2024
Fixes an issue in #102967, 
which inddvertently changed the type of `NextChar` from int to char,
causing ppc64le build failures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants