Skip to content
Closed

When #126173

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: 3 additions & 1 deletion .github/workflows/clang-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
push:
branches:
- 'release/**'
- 'main'
paths:
- 'clang/**'
- '.github/workflows/clang-tests.yml'
Expand All @@ -16,6 +17,7 @@ on:
pull_request:
branches:
- 'release/**'
- 'main'
paths:
- 'clang/**'
- '.github/workflows/clang-tests.yml'
Expand All @@ -30,7 +32,7 @@ concurrency:

jobs:
check_clang:
if: github.repository_owner == 'llvm'
if: github.event_name == 'pull_request' && github.base_ref == 'main'
name: Test clang,lldb,libclc
uses: ./.github/workflows/llvm-project-tests.yml
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ pythonenv*
/clang/utils/analyzer/projects/*/RefScanBuildResults
# automodapi puts generated documentation files here.
/lldb/docs/python_api/
llvm-project.code-workspace
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3768,7 +3768,7 @@ class TagDecl : public TypeDecl,

bool isStruct() const { return getTagKind() == TagTypeKind::Struct; }
bool isInterface() const { return getTagKind() == TagTypeKind::Interface; }
bool isClass() const { return getTagKind() == TagTypeKind::Class; }
bool isClass() const { return getTagKind() == TagTypeKind::Class || getTagKind() == TagTypeKind::Coroutine; }
bool isUnion() const { return getTagKind() == TagTypeKind::Union; }
bool isEnum() const { return getTagKind() == TagTypeKind::Enum; }

Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2472,6 +2472,7 @@ DEF_TRAVERSE_STMT(MSDependentExistsStmt, {
DEF_TRAVERSE_STMT(ReturnStmt, {})
DEF_TRAVERSE_STMT(SwitchStmt, {})
DEF_TRAVERSE_STMT(WhileStmt, {})
DEF_TRAVERSE_STMT(WhenStmt, {})

DEF_TRAVERSE_STMT(ConstantExpr, {})

Expand Down
55 changes: 55 additions & 0 deletions clang/include/clang/AST/Stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -2409,6 +2409,61 @@ class IfStmt final
}
};

/// WhenStmt - This represents a '_When' stmt.
class WhenStmt : public Stmt, private llvm::TrailingObjects<WhenStmt, Stmt *> {
SourceLocation WhenLoc;
Expr *Condition;
bool IsAccept;
IdentifierInfo *VarName;
Stmt *Body;

/*
* WhenStmt is followed by several trailing objects, some of which optional.
* Note that it would be more convenient to put the optional trailing objects
* at the end but this would change the order in children().
* The trailing objects are in order:
*
* * A "Stmt *" for the condition.
* Always present. This is in fact an "Expr *".
*
* * A "Stmt *" for the body.
* Always present.
*/
enum {
NumMandatoryStmtPtr = 2
};

public:
// WhenStmt(SourceLocation Loc, Expr *Cond, bool Accept, IdentifierInfo *Var, Stmt *BodyStmt)
WhenStmt(SourceLocation Loc, Expr *Cond, Stmt *BodyStmt)
: Stmt(Stmt::WhenStmtClass), WhenLoc(Loc), Condition(Cond),
Body(BodyStmt) {}
// IsAccept(Accept), VarName(Var), Body(BodyStmt) {}

explicit WhenStmt(EmptyShell Empty)
: Stmt(Stmt::WhenStmtClass) {}

// static WhenStmt* Create(const ASTContext &Ctx, SourceLocation Loc, Expr *Cond, bool Accept, IdentifierInfo *Var, Stmt *BodyStmt);
static WhenStmt* Create(const ASTContext &Ctx, SourceLocation Loc, Expr *Cond, Stmt *BodyStmt);
static WhenStmt* CreateEmpty(const ASTContext &Ctx);

SourceLocation getBeginLoc() const { return WhenLoc; }
SourceLocation getEndLoc() const { return Body ? Body->getEndLoc() : WhenLoc; }
child_range children() { return child_range(&Body, &Body + 1); }
static bool classof(const Stmt *S) { return S->getStmtClass() == WhenStmtClass; }

bool isAccept() const { return IsAccept; }
IdentifierInfo *getVarName() const { return VarName; }
Expr *getCondition() const { return Condition; }
void setCondition(Expr *Cond) { Condition = Cond; }
Stmt *getBody() const { return Body; }
void setBody(Stmt *B) { Body = B; }

SourceLocation getWhenLoc() const { return WhenLoc; }
SourceLocation setWhenLoc(SourceLocation Loc) { return WhenLoc = Loc; }

};

/// SwitchStmt - This represents a 'switch' stmt.
class SwitchStmt final : public Stmt,
private llvm::TrailingObjects<SwitchStmt, Stmt *> {
Expand Down
8 changes: 7 additions & 1 deletion clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -6859,6 +6859,9 @@ enum class ElaboratedTypeKeyword {
/// \c typename T::type.
Typename,

/// The "Coroutine" keyword also introduces elaborated-type specifier
Coroutine,

/// No keyword precedes the qualified type name.
None
};
Expand All @@ -6878,7 +6881,10 @@ enum class TagTypeKind {
Class,

/// The "enum" keyword.
Enum
Enum,

/// The "_Coroutine" keyword.
Coroutine
};

/// A helper class for Type nodes having an ElaboratedTypeKeyword.
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/Specifiers.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace clang {
TST_enum,
TST_union,
TST_struct,
TST_coroutine,
TST_class, // C++ class type
TST_interface, // C++ (Microsoft-specific) __interface type
TST_typename, // Typedef, C++ class-name or enum name, etc.
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/StmtNodes.td
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ def CaseStmt : StmtNode<SwitchCase>;
def DefaultStmt : StmtNode<SwitchCase>;
def CapturedStmt : StmtNode<Stmt>;

// uC++ Statements
def WhenStmt : StmtNode<Stmt>;

// Statements that might produce a value (for example, as the last non-null
// statement in a GNU statement-expression).
def ValueStmt : StmtNode<Stmt, 1>;
Expand Down
Loading