This patch makes it possible for lambdas, implicit copy/move ctors and structured bindings to
handle non-POD multidimensional arrays.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/lib/Analysis/CFG.cpp | ||
---|---|---|
1724 | Would a regular dyn_cast work? I would not expect getSubExpr to return nullptr. This applies to some other places as well. | |
3432–3436 | Instead of duplicating both the code and adding this comment, I wonder if a well named small utility function can make this code equally clear and reduce duplication. | |
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | ||
569 | Do you need a dyn_cast here? ``AILE alreadt has the right type. |
clang/lib/Analysis/CFG.cpp | ||
---|---|---|
3432–3436 | I've been thinking about the same thing. I would also place the getArrayInitLoopExprSize() helper function into ASTContext as it also has a similar helper called getConstantArrayElementCount(). | |
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | ||
569 | It handles if the user passes a nullptr to the function. Also because AILE is an ArrayInitLoopExpr *, in the loop I also have This might not be the best solution but this helper will be reworked anyway due to a mistake I've made below. | |
575 |
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | ||
---|---|---|
569 | I think if you just declare E to be const ArrayInitLoopExpr*, you might not need the cast at all. while should already guard against nullptr from the user. |
Some nits inline but overall looks good to me.
clang/lib/AST/ASTContext.cpp | ||
---|---|---|
6917 | Did you see examples where the SubExpr of an ArrayInitLoopExpr returned a nullptr? If not, I'd go with dyn_cast for now. | |
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | ||
544–545 | Shouldn't this also use extractElementInitializerFromNestedAILE? | |
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp | ||
544–545 | extractElementInitializerFromNestedAILE? | |
1169–1170 | extractElementInitializerFromNestedAILE? |
- Rebased
- Moved extractElementInitializerFromNestedAILE() to ExprEngine
- Addressed comments
clang/lib/AST/ASTContext.cpp | ||
---|---|---|
6917 | getSubExpr() uses a regular cast, so it cannot return nullptr. |
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h | ||
---|---|---|
983 ↗ | (On Diff #452932) | The definition is in the header, because this method is used in CFG.cpp, but that source file is not linked against any of the ExprEngine source files and I don't want to change the linking of libraries. @xazax.hun do you have any suggestions, where to put a function that is referenced in both the Analysis and the Static Analyzer library? I want to avoid creating the same helper twice. |
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h | ||
---|---|---|
983 ↗ | (On Diff #452932) | Are you sure? CFG.cpp is linked into clangAnalysis and clangAnalysis is linked a dependency of the static analyzer core. I'd expect putting this in CFG.cpp should work perfectly well. Just be sure to not put the implementation in an anonymous namespace. |
Overall looks good to me. I think extractElementInitializerFromNestedAILE should live somewhere in the clangAnalysis component due to how layering is done, but otherwise it looks wonderful, thanks!
Moved extractElementInitializerFromNestedAILE to CFG.cpp.
@xazax.hun is this how you meant it?
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | ||
---|---|---|
236–237 | Would moving this declaration to CFG.h work? |
Did you see examples where the SubExpr of an ArrayInitLoopExpr returned a nullptr? If not, I'd go with dyn_cast for now.