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
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SourceRange SourceInfo::getRange() const {
}

const Expr *SourceInfo::asExpr() const {
if (const auto *S = dyn_cast<const Stmt *>(Source))
if (const auto *S = dyn_cast_if_present<const Stmt *>(Source))
return dyn_cast<Expr>(S);
return nullptr;
}
Expand Down
8 changes: 6 additions & 2 deletions clang/lib/AST/ByteCode/Source.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ class SourceInfo final {
SourceLocation getLoc() const;
SourceRange getRange() const;

const Stmt *asStmt() const { return dyn_cast<const Stmt *>(Source); }
const Decl *asDecl() const { return dyn_cast<const Decl *>(Source); }
const Stmt *asStmt() const {
return dyn_cast_if_present<const Stmt *>(Source);
}
const Decl *asDecl() const {
return dyn_cast_if_present<const Decl *>(Source);
}
const Expr *asExpr() const;

operator bool() const { return !Source.isNull(); }
Expand Down
5 changes: 5 additions & 0 deletions clang/test/SemaCXX/lambda-expressions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify=expected,not-cxx03,expected-cxx14 -fblocks %s
// RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify=expected,not-cxx03 -ast-dump -fblocks %s | FileCheck %s

// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only -verify=expected,not-cxx03,cxx03-cxx11,cxx11,expected-cxx14 -fblocks %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -std=c++03 -Wno-unused-value -fsyntax-only -verify=expected,cxx03,cxx03-cxx11,expected-cxx14 -fblocks %s -Ddecltype=__decltype -Dstatic_assert=_Static_assert -Wno-c++11-extensions -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify=expected,not-cxx03,expected-cxx14 -fblocks %s -fexperimental-new-constant-interpreter
// RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify=expected,not-cxx03 -ast-dump -fblocks %s -fexperimental-new-constant-interpreter| FileCheck %s

namespace std { class type_info; };

namespace ExplicitCapture {
Expand Down
Loading