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
4 changes: 4 additions & 0 deletions clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ bool tryToFindPtrOrigin(
break;
}
}
if (auto *TempExpr = dyn_cast<CXXUnresolvedConstructExpr>(E)) {
if (isSafePtrType(TempExpr->getTypeAsWritten()))
return callback(TempExpr, true);
}
if (auto *POE = dyn_cast<PseudoObjectExpr>(E)) {
if (auto *RF = POE->getResultExpr()) {
E = RF;
Expand Down
15 changes: 8 additions & 7 deletions clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,14 @@ static bool isPtrOfType(const clang::QualType T, Predicate Pred) {
type = elaboratedT->desugar();
continue;
}
auto *SpecialT = type->getAs<TemplateSpecializationType>();
if (!SpecialT)
return false;
auto *Decl = SpecialT->getTemplateName().getAsTemplateDecl();
if (!Decl)
return false;
return Pred(Decl->getNameAsString());
if (auto *SpecialT = type->getAs<TemplateSpecializationType>()) {
auto *Decl = SpecialT->getTemplateName().getAsTemplateDecl();
return Decl && Pred(Decl->getNameAsString());
} else if (auto *DTS = type->getAs<DeducedTemplateSpecializationType>()) {
auto *Decl = DTS->getTemplateName().getAsTemplateDecl();
return Decl && Pred(Decl->getNameAsString());
} else
break;
}
return false;
}
Expand Down
35 changes: 35 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/call-args.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,41 @@ namespace call_with_ptr_on_ref {
}
}

namespace call_with_explicit_construct_from_auto {

struct Impl {
void ref() const;
void deref() const;

static Ref<Impl> create();
};

template <typename T>
struct ArgObj {
T* t;
};

struct Object {
Object();
Object(Ref<Impl>&&);

Impl* impl() const { return m_impl.get(); }

static Object create(ArgObj<char>&) { return Impl::create(); }
static void bar(Impl&);

private:
RefPtr<Impl> m_impl;
};

template<typename CharacterType> void foo()
{
auto result = Object::create(ArgObj<CharacterType> { });
Object::bar(Ref { *result.impl() });
}

}

namespace call_with_explicit_temporary_obj {
void foo() {
Ref { *provide() }->method();
Expand Down
Loading