Coverage Report

Created: 2022-07-16 07:03

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/StmtObjC.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- StmtObjC.cpp - Classes for representing ObjC statements ---------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file implements the subclesses of Stmt class declared in StmtObjC.h
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "clang/AST/StmtObjC.h"
14
15
#include "clang/AST/Expr.h"
16
#include "clang/AST/ASTContext.h"
17
18
using namespace clang;
19
20
ObjCForCollectionStmt::ObjCForCollectionStmt(Stmt *Elem, Expr *Collect,
21
                                             Stmt *Body, SourceLocation FCL,
22
                                             SourceLocation RPL)
23
279
    : Stmt(ObjCForCollectionStmtClass) {
24
279
  SubExprs[ELEM] = Elem;
25
279
  SubExprs[COLLECTION] = Collect;
26
279
  SubExprs[BODY] = Body;
27
279
  ForLoc = FCL;
28
279
  RParenLoc = RPL;
29
279
}
30
31
ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt,
32
                             Stmt **CatchStmts, unsigned NumCatchStmts,
33
                             Stmt *atFinallyStmt)
34
    : Stmt(ObjCAtTryStmtClass), AtTryLoc(atTryLoc),
35
315
      NumCatchStmts(NumCatchStmts), HasFinally(atFinallyStmt != nullptr) {
36
315
  Stmt **Stmts = getStmts();
37
315
  Stmts[0] = atTryStmt;
38
660
  for (unsigned I = 0; I != NumCatchStmts; 
++I345
)
39
345
    Stmts[I + 1] = CatchStmts[I];
40
41
315
  if (HasFinally)
42
72
    Stmts[NumCatchStmts + 1] = atFinallyStmt;
43
315
}
44
45
ObjCAtTryStmt *ObjCAtTryStmt::Create(const ASTContext &Context,
46
                                     SourceLocation atTryLoc, Stmt *atTryStmt,
47
                                     Stmt **CatchStmts, unsigned NumCatchStmts,
48
315
                                     Stmt *atFinallyStmt) {
49
315
  size_t Size =
50
315
      totalSizeToAlloc<Stmt *>(1 + NumCatchStmts + (atFinallyStmt != nullptr));
51
315
  void *Mem = Context.Allocate(Size, alignof(ObjCAtTryStmt));
52
315
  return new (Mem) ObjCAtTryStmt(atTryLoc, atTryStmt, CatchStmts, NumCatchStmts,
53
315
                                 atFinallyStmt);
54
315
}
55
56
ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(const ASTContext &Context,
57
                                          unsigned NumCatchStmts,
58
3
                                          bool HasFinally) {
59
3
  size_t Size = totalSizeToAlloc<Stmt *>(1 + NumCatchStmts + HasFinally);
60
3
  void *Mem = Context.Allocate(Size, alignof(ObjCAtTryStmt));
61
3
  return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally);
62
3
}
63
64
33
SourceLocation ObjCAtTryStmt::getEndLoc() const {
65
33
  if (HasFinally)
66
22
    return getFinallyStmt()->getEndLoc();
67
11
  if (NumCatchStmts)
68
11
    return getCatchStmt(NumCatchStmts - 1)->getEndLoc();
69
0
  return getTryBody()->getEndLoc();
70
11
}