Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ class TrivialFunctionAnalysisVisitor
return true;
}

bool VisitOffsetOfExpr(const OffsetOfExpr *OE) {
// offsetof(T, D) is considered trivial.
return true;
}

bool VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE) {
if (!checkArguments(MCE))
return false;
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/uncounted-obj-arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ T&& forward(T& arg);
template<typename T>
T&& move( T&& t );

#define offsetof(t, d) __builtin_offsetof(t, d)

} // namespace std

bool isMainThread();
Expand Down Expand Up @@ -373,6 +375,7 @@ class RefCounted {
double y;
};
void trivial68() { point pt = { 1.0 }; }
unsigned trivial69() { return offsetof(RefCounted, children); }

static RefCounted& singleton() {
static RefCounted s_RefCounted;
Expand Down Expand Up @@ -560,6 +563,7 @@ class UnrelatedClass {
getFieldTrivial().trivial66()->trivial6(); // no-warning
getFieldTrivial().trivial67()->trivial6(); // no-warning
getFieldTrivial().trivial68(); // no-warning
getFieldTrivial().trivial69(); // no-warning

RefCounted::singleton().trivial18(); // no-warning
RefCounted::singleton().someFunction(); // no-warning
Expand Down