Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/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
246
    : Stmt(ObjCForCollectionStmtClass) {
24
246
  SubExprs[ELEM] = Elem;
25
246
  SubExprs[COLLECTION] = Collect;
26
246
  SubExprs[BODY] = Body;
27
246
  ForLoc = FCL;
28
246
  RParenLoc = RPL;
29
246
}
30
31
ObjCAtTryStmt::ObjCAtTryStmt(SourceLocation atTryLoc, Stmt *atTryStmt,
32
                             Stmt **CatchStmts, unsigned NumCatchStmts,
33
                             Stmt *atFinallyStmt)
34
    : Stmt(ObjCAtTryStmtClass), AtTryLoc(atTryLoc),
35
293
      NumCatchStmts(NumCatchStmts), HasFinally(atFinallyStmt != nullptr) {
36
293
  Stmt **Stmts = getStmts();
37
293
  Stmts[0] = atTryStmt;
38
620
  for (unsigned I = 0; I != NumCatchStmts; 
++I327
)
39
327
    Stmts[I + 1] = CatchStmts[I];
40
293
41
293
  if (HasFinally)
42
71
    Stmts[NumCatchStmts + 1] = atFinallyStmt;
43
293
}
44
45
ObjCAtTryStmt *ObjCAtTryStmt::Create(const ASTContext &Context,
46
                                     SourceLocation atTryLoc, Stmt *atTryStmt,
47
                                     Stmt **CatchStmts, unsigned NumCatchStmts,
48
293
                                     Stmt *atFinallyStmt) {
49
293
  unsigned Size =
50
293
      sizeof(ObjCAtTryStmt) +
51
293
      (1 + NumCatchStmts + (atFinallyStmt != nullptr)) * sizeof(Stmt *);
52
293
  void *Mem = Context.Allocate(Size, alignof(ObjCAtTryStmt));
53
293
  return new (Mem) ObjCAtTryStmt(atTryLoc, atTryStmt, CatchStmts, NumCatchStmts,
54
293
                                 atFinallyStmt);
55
293
}
56
57
ObjCAtTryStmt *ObjCAtTryStmt::CreateEmpty(const ASTContext &Context,
58
                                          unsigned NumCatchStmts,
59
2
                                          bool HasFinally) {
60
2
  unsigned Size =
61
2
      sizeof(ObjCAtTryStmt) + (1 + NumCatchStmts + HasFinally) * sizeof(Stmt *);
62
2
  void *Mem = Context.Allocate(Size, alignof(ObjCAtTryStmt));
63
2
  return new (Mem) ObjCAtTryStmt(EmptyShell(), NumCatchStmts, HasFinally);
64
2
}
65
66
32
SourceLocation ObjCAtTryStmt::getEndLoc() const {
67
32
  if (HasFinally)
68
21
    return getFinallyStmt()->getEndLoc();
69
11
  if (NumCatchStmts)
70
11
    return getCatchStmt(NumCatchStmts - 1)->getEndLoc();
71
0
  return getTryBody()->getEndLoc();
72
0
}