[all-commits] [llvm/llvm-project] 779a2a: [clang-tidy] Crash fix for bugprone-misplaced-poin...
Balogh, Ádám via All-commits
all-commits at lists.llvm.org
Wed Sep 16 04:28:09 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 779a2a2edcea89ad5f5bf99eeac90516542159d9
https://github.com/llvm/llvm-project/commit/779a2a2edcea89ad5f5bf99eeac90516542159d9
Author: Adam Balogh <adam.balogh at ericsson.com>
Date: 2020-09-16 (Wed, 16 Sep 2020)
Changed paths:
M clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
M clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
Log Message:
-----------
[clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc
Placement new operators on non-object types cause crash in
`bugprone-misplaced-pointer-arithmetic-in-alloc`. This patch fixes this
issue.
Differential Revision: https://reviews.llvm.org/D87683
Commit: dbd45b2db8e0c396fa20d4c72734c4f31f54af96
https://github.com/llvm/llvm-project/commit/dbd45b2db8e0c396fa20d4c72734c4f31f54af96
Author: Adam Balogh <adam.balogh at ericsson.com>
Date: 2020-09-16 (Wed, 16 Sep 2020)
Changed paths:
M clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
M clang/include/clang/ASTMatchers/ASTMatchers.h
M clang/include/clang/ASTMatchers/ASTMatchersInternal.h
M clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
Log Message:
-----------
[ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl`
//AST Matcher// `hasBody` is a polymorphic matcher that behaves
differently for loop statements and function declarations. The main
difference is the for functions declarations it does not only call
`FunctionDecl::getBody()` but first checks whether the declaration in
question is that specific declaration which has the body by calling
`FunctionDecl::doesThisDeclarationHaveABody()`. This is achieved by
specialization of the template `GetBodyMatcher`. Unfortunately template
specializations do not catch the descendants of the class for which the
template is specialized. Therefore it does not work correcly for the
descendants of `FunctionDecl`, such as `CXXMethodDecl`,
`CXXConstructorDecl`, `CXXDestructorDecl` etc. This patch fixes this
issue by using a template metaprogram.
The patch also introduces a new matcher `hasAnyBody` which matches
declarations which have a body present in the AST but not necessarily
belonging to that particular declaration.
Differential Revision: https://reviews.llvm.org/D87527
Compare: https://github.com/llvm/llvm-project/compare/7029e5d4ca20...dbd45b2db8e0
More information about the All-commits
mailing list