-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][NFC] Fix static code analysis concerns #2531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Found via a static-analysis tool: 1. Pointer 'NewDeclAttr' returned from call to function 'getAttr<clang::SYCLIntelMaxWorkGroupSizeAttr>' at line 3218 may be NULL and will be dereferenced at line 3220. 2. Pointer 'NewDeclAttr' returned from call to function 'getAttr<clang::ReqdWorkGroupSizeAttr>' at line 3218 may be NULL and will be dereferenced at line 3220. 3. Pointer 'OldDeclAttr' returned from call to function 'getAttr<clang::ReqdWorkGroupSizeAttr>' at line 3219 may be NULL and will be dereferenced at line 3220. 4. Pointer 'OldDeclAttr' returned from call to function 'getAttr<clang::SYCLIntelMaxWorkGroupSizeAttr>' at line 3219 may be NULL and will be dereferenced at line 3220. This patch fixes null pointer dereference issues in SemaDecl.cpp file by changing return type of pointers from AttributeType to const auto. Signed-off-by: Soumi Manna <soumi.manna@intel.com>
This won't change the return type other than adding 'const', it won't change the fact that getAttr can return a nullptr. This doesn't solve hte problem you're trying to solve. |
Signed-off-by: Soumi Manna <soumi.manna@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm.... bonus points would be given for making this a variadic template, so that this would work:
checkDimensionsAndSetDiagnostics<ReqdWorkGroupSizeAttr, SYCLIntelMaxWorkGroupSizeAttr>(*this, New, Old);
That said, its more code at the moment to do so over just leaving 2 otherwise identical calls, so next time someone adds to this list perhaps we'll make them do it then :)
@@ -3302,12 +3306,8 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, | |||
} | |||
} | |||
|
|||
if (New->hasAttr<ReqdWorkGroupSizeAttr>() && | |||
Old->hasAttr<ReqdWorkGroupSizeAttr>()) | |||
checkDimensionsAndSetDiagnostics<ReqdWorkGroupSizeAttr>(*this, New, Old); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this is what @erichkeane suggested earlier, but I am not sure I like this. Would we do this for every attribute we want to merge? Seems like a lot of wasted calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it ends up being basically the same runtime-cost here after optimization. It seems like an easy function to inline, and hasAttr and getAttr have identical runtime cost.
My fear here is that this ends up being REALLY error-prone as time goes on, we're going to be adding these for a handful of attributes and it becomes easy to copy/paste error the THREE uses of the attribute type.
Okay, I can live with this. :-) |
Thank you everyone for the reviews. |
…_wrapper * upstream/sycl: (1533 commits) [SYCL] XFAIL sub_group shuffle tests on GPU [SYCL] Add support for L0 loader validation layer (intel#2520) [NFC][LIT] Temporary disable function pointers as they hang on L0 (intel#2544) [SYCL] use release version of OpenCL ICD loader [SYCL] Improve testing of host-task (intel#2540) Revert 1291215 [SYCL] Fix warning caused by [[nodiscard]] attribute (intel#2545) [SYCL] Workaround windows build failure [SYCL] Remove kernel_signature_start from int header (intel#2537) [SYCL] Fix ABI tests in post-commit (intel#2539) [SYCL][DOC] Update C-CXX-StandardLibrary doc to align with latest status (intel#2529) [SYCL][NFC] Fix static code analysis concerns (intel#2531) [SYCL][NFC] Improve testing for accessor_property_list (intel#2532) [SYCL] Avoid overuse of CPU on wait read-write lock loop (intel#2525) [SYCL] Implement no-decomposition for kernel types that don't need it. (intel#2477) [SYCL] Add group algorithm constraints (intel#2462) [BuildBot] Uplift Windows GPU RT from 8673 to 8778 (intel#2533) [SYCL][LIT][NFC] Extend ABI test suite (intel#2522) [SYCL][DebugInfo] Reinstate source locations for some kernel instructions (intel#2527) [SYCL][NFC] Replace the deprecated VectorType::getNumElements() (intel#2524) ...
Fix calls to ze destructors in level-zero adapter v2
Fix calls to ze destructors in level-zero adapter v2
Found via a static-analysis tool:
This patch fixes null pointer dereference issues in SemaDecl.cpp file
by adding early return if (!NewDeclAttr || !OldDeclAttr)
Signed-off-by: Soumi Manna soumi.manna@intel.com