This patch places a guard around to prevent nullptr deference during atomic update lowering
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thank you for the patch. I am wondering if it's better to completely remove the if statements. Please see the inline comments. Thanks again!
flang/lib/Lower/OpenMP.cpp | ||
---|---|---|
1129–1130 | If you expect updateSymbol to be always set, could we do something like this? We can catch errors earlier this way. Also, if statements that are always taken should be assert instead. auto varDesignator = std::get_if<Fortran::common::Indirection<Fortran::parser::Designator>>( &assignmentStmtVariable.u); assert(varDesignator && "varDesignator must have a value."); const auto *name = getDesignatorNameIfDataRef(varDesignator->value()); assert(name && name->symbol && "No symbol attached to atomic update variable."); const Fortran::semantics::Symbol *updateSymbol = name->symbol; |
flang/lib/Lower/OpenMP.cpp | ||
---|---|---|
1129–1130 | That is a nice suggestion. |
Thank you for updating the patch. Please see the inline comment.
flang/lib/Lower/OpenMP.cpp | ||
---|---|---|
1156–1164 | If you are moving this block of code, you might as well do: const Fortran::semantics::Symbol *updateSymbol = name->symbol; converter.bindSymbol(*updateSymbol, val); or drop the intermediate variable altogether: converter.bindSymbol(*(name->symbol), val); I would avoid an unused value like = nullptr in the straight-line code. Some compilers might even issue a warning like "set but unused" or something. |
Is it better to move this assert outside in line 1164?