- Need trimming before parsing major or minor version numbers. This's required due to the different line ending on Windows.
- In addition, the integer conversion may fail due to invalid char. Return that parsing function return true when the parsing fails.
Details
- Reviewers
yaxunl tra - Commits
- rG2a29ce303451: [hip] Fix HIP version parsing.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Driver/ToolChains/AMDGPU.cpp | ||
---|---|---|
91–93 | A comment describing expected input format would be helpful here. | |
91–93 | A comment that it returns true on failure to parse would be helpful. | |
98–106 | Part.trim().split() (or, maybe, rtrim()if you only care about EOL) would save you trimming in each individual case. |
clang/lib/Driver/ToolChains/AMDGPU.cpp | ||
---|---|---|
98–106 | sure, as that file is auto-gen so far, we could simplify the unnecessary parsing so far. The EOL is the only issue so far. |
LGTM overall.
clang/lib/Driver/ToolChains/AMDGPU.cpp | ||
---|---|---|
92 | It still does not desribe what we expect to see in that file. HIP_VERSION_MAJOR=1 HIP_VERSION_MINOR=2 HIP_VERSION_PATCH=3 | |
100 | Perhaps we could use StringSwitch here: int &Value = llvm::StringSwitch<int&>(Splits.first) .Case("HIP_VERSION_MAJOR", Major) .Case("HIP_VERSION_MINOR", Minor) .Case("HIP_VERSION_PATCH", VersionPatch) if (Splits.second.getAsInteger(0, Value)) return true; |
It still does not desribe what we expect to see in that file.
E.g.: