Verilog uses the backtick instead of the hash. In this revision
backticks are lexed manually and then get labeled as hashes so the logic
for handling C preprocessor stuff don't have to change. Hashes get
labeled as identifiers for Verilog-specific stuff like delays.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This revision depends on D124748, but somehow it doesn't show up when I open the parent revision dialog.
You add significant number of keywords here but I don't see any of them being tested? can you add a unit tests to cover what you are adding
clang/lib/Format/FormatTokenLexer.cpp | ||
---|---|---|
1117 | You mean like this? static const llvm::Regex VerilogToken(R"re(^('|``?|\\(\\)re" "(\r?\n|\r)|[^[:space:]])*)"); | |
1141–1144 | The function is only supposed to be used for Verilog, so && is correct. If you mean why this part is different from D121758, I changed the name from readRawTokenLanguageSpecific to readRawTokenVerilogSpecific as suggested by a reviewer. Then I moved the check for language out of that function like what tryParseJSRegexLiteral does. |
The two parents of this revision change the same file, so the build bot says patch does not apply. Does that mean I have to submit the parent patches with less context?
Maybe just wait until one of the parents has landed. We can make a review without the bot. :)
Or put the parents in relation.
I think this is still open?
clang/lib/Format/FormatTokenLexer.cpp | ||
---|---|---|
1117 | I'd put it in one line, but basically yeah. | |
1141–1144 | I think I missed the parens. | |
1143 | As demonstrated by me, the parens can go under in a quick read. |
- use raw string for regex
- use default style in test
- remove parentheses
- use seek now that skipOver no longer exists
clang/lib/Format/UnwrappedLineParser.cpp | ||
---|---|---|
1889 | Previously the if checked whether the line is comment and an identifier. For Verilog it's comment, a backtick, and an identifier. I found it easier to break if the line doesn't match the pattern. |
clang/lib/Format/FormatTokenLexer.cpp | ||
---|---|---|
1121 | Add braces. Maybe check all other added ifs too. You can check with clang-format with InsertBraces and RemoveBracesLLVM. | |
clang/lib/Format/UnwrappedLineParser.cpp | ||
1891 | ||
1893 | I find just scopes a bit confusing. Maybe put the check if we want to break into a lambda and call that? |
clang/lib/Format/FormatToken.h | ||
---|---|---|
1173 | Now that I added kw_ to verilogHashHash, four columns can't fit. |
It seems a comment before is missing. Should be fixed in a separate patch.