Found by Coverity static analysis tool.
Details
Diff Detail
Event Timeline
clang/lib/Serialization/ASTReader.cpp | ||
---|---|---|
5890–5892 ↗ | (On Diff #507221) | It is odd that these values aren't preserved by the AST writer. I wonder if that is intentional. It took me a while, but I eventually found that these data members are assigned via an inclusion of clang/Driver/Options.inc somewhere. Rather than assigning values here, I think we would be better off adding member initializers in the class definition. But I think we do need to look into why the AST writer isn't preserving the values. |
clang/include/clang/Basic/TargetOptions.h | ||
---|---|---|
48 | Looks good; this is consistent with the default initialization performed for llvm::TargetOptions::EABIVersion. | |
91 | I see that COV_4 is the default as specified in clang/include/clang/Driver/Options.td, but I wonder if we want to duplicate that value here. I'm a bit more inclined to default to COV_None so that we're not trying to maintain the same default in multiple places. I don't know that it matters though. Perhaps it would make sense to add a "default" option value as is done for EABI? I'm not sure. |
clang/include/clang/Basic/TargetOptions.h | ||
---|---|---|
91 | I think none makes the most sense to me. This is set via a CC1 option, and the driver doesn't unconditionally set it (https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/Clang.cpp#L1073), so I think none is safer than assuming CodeObjectVersion is meaningful when it's not set by -cc1. WDYT? |
clang/include/clang/Basic/TargetOptions.h | ||
---|---|---|
91 | I agree, and that's why I made the change to none. @tahonermann |
Thank you, @aaron.ballman and @tahonermann for your comments!
This was committed to https://github.com/llvm/llvm-project.git with hash 6f2a865d2f6bc426a61939a0a1acfcb25d5c1a18
Looks good; this is consistent with the default initialization performed for llvm::TargetOptions::EABIVersion.