Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
45 lines (37 loc) · 1.24 KB

File metadata and controls

45 lines (37 loc) · 1.24 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "hermes/AST/Context.h"
#include "hermes/IR/CFG.h"
#include "hermes/IR/IR.h"
#include "hermes/IR/IRBuilder.h"
#include "hermes/IR/Instrs.h"
#include "hermes/Utils/Dumper.h"
#include "gtest/gtest.h"
using namespace hermes;
namespace {
/// When a basic block contains a jump to another, they should be in
/// each others' predecessor and successor lists.
TEST(IRBasicBlockTest, BasicBlockConnectionTest) {
auto Ctx = std::make_shared<Context>();
Module M(Ctx);
IRBuilder Builder(&M);
auto F = Builder.createFunction(
"main", Function::DefinitionKind::ES5Function, true);
auto BB1 = Builder.createBasicBlock(F);
auto BB2 = Builder.createBasicBlock(F);
Builder.setInsertionBlock(BB1);
Builder.createBranchInst(BB2);
// BB1 is a predecessor of BB2
EXPECT_TRUE(pred_contains(BB2, BB1));
// BB2 is not a predecessor of itself
EXPECT_FALSE(pred_contains(BB2, BB2));
// BB2 is a successor of BB1
EXPECT_TRUE(succ_contains(BB1, BB2));
// BB1 is not a successor of itself
EXPECT_FALSE(succ_contains(BB1, BB1));
}
} // end anonymous namespace
Morty Proxy This is a proxified and sanitized view of the page, visit original site.