Skip to content

Commit f2e3d1c

Browse files
Merge branch 'master' into master-post-microsoft
2 parents b6146c3 + 9494e6a commit f2e3d1c

File tree

11 files changed

+150
-145
lines changed

11 files changed

+150
-145
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

clang/docs/checkedc/3C/CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ here. You must grant the same license on your contribution as the
4242
existing codebase. We do not have a formal contributor license
4343
agreement (CLA) process at this time, but we may set one up and
4444
require you to complete it before we accept your contribution. Also be
45-
aware that we need to keep 5C working, so you may have to wait for us
46-
to address 5C-specific problems arising from your 3C pull request
47-
and/or we may ask you to make specific changes to your pull request to
48-
accommodate 5C's code.
45+
aware that we need to keep 5C ([our proprietary extension of
46+
3C](README.md#what-3c-users-should-know-about-the-development-process))
47+
working, so you may have to wait for us to address 5C-specific
48+
problems arising from your 3C pull request and/or we may ask you to
49+
make specific changes to your pull request to accommodate 5C's code.
4950

5051
## Testing
5152

clang/include/clang/3C/AVarBoundsInfo.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ class AVarBoundsInfo {
362362
class ContextSensitiveBoundsKeyVisitor
363363
: public RecursiveASTVisitor<ContextSensitiveBoundsKeyVisitor> {
364364
public:
365-
explicit ContextSensitiveBoundsKeyVisitor(ASTContext *C, ProgramInfo &I,
366-
ConstraintResolver *CResolver);
365+
explicit ContextSensitiveBoundsKeyVisitor(ASTContext *C, ProgramInfo &I);
367366

368367
virtual ~ContextSensitiveBoundsKeyVisitor();
369368

@@ -372,7 +371,6 @@ class ContextSensitiveBoundsKeyVisitor
372371
private:
373372
ASTContext *Context;
374373
ProgramInfo &Info;
375-
ConstraintResolver *CR;
376374
};
377375

378376
#endif // LLVM_CLANG_3C_AVARBOUNDSINFO_H

clang/include/clang/3C/RewriteUtils.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,13 @@ class GlobalVariableGroups {
193193
// detected array variables.
194194
class ArrayBoundsRewriter {
195195
public:
196-
ArrayBoundsRewriter(ASTContext *C, ProgramInfo &I) : Context(C), Info(I) {}
196+
ArrayBoundsRewriter(ProgramInfo &I) : Info(I) {}
197197
// Get the string representation of the bounds for the given variable.
198198
std::string getBoundsString(PVConstraint *PV, Decl *D, bool Isitype = false);
199199
// Check if the constraint variable has newly created bounds string.
200200
bool hasNewBoundsString(PVConstraint *PV, Decl *D, bool Isitype = false);
201201

202202
private:
203-
ASTContext *Context;
204203
ProgramInfo &Info;
205204
};
206205

clang/include/clang/AST/PreorderAST.h

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,32 @@
2323

2424
namespace clang {
2525
using Result = Lexicographic::Result;
26+
class OperatorNode;
2627

2728
class Node {
2829
public:
29-
enum class NodeKind { BinaryNode, LeafExprNode };
30+
enum class NodeKind { OperatorNode, LeafExprNode };
3031

3132
NodeKind Kind;
32-
Node *Parent;
33+
OperatorNode *Parent;
3334

34-
Node(NodeKind Kind, Node *Parent) :
35+
Node(NodeKind Kind, OperatorNode *Parent) :
3536
Kind(Kind), Parent(Parent) {}
3637
};
3738

38-
class BinaryNode : public Node {
39+
class OperatorNode : public Node {
3940
public:
4041
BinaryOperator::Opcode Opc;
42+
// Note: An OperatorNode has a list of children because the preorder AST is
43+
// an n-ary tree.
4144
llvm::SmallVector<Node *, 2> Children;
4245

43-
BinaryNode(BinaryOperator::Opcode Opc, Node *Parent) :
44-
Node(NodeKind::BinaryNode, Parent),
46+
OperatorNode(BinaryOperator::Opcode Opc, OperatorNode *Parent) :
47+
Node(NodeKind::OperatorNode, Parent),
4548
Opc(Opc) {}
4649

4750
static bool classof(const Node *N) {
48-
return N->Kind == NodeKind::BinaryNode;
51+
return N->Kind == NodeKind::OperatorNode;
4952
}
5053

5154
// Is the operator commutative and associative?
@@ -58,7 +61,7 @@ namespace clang {
5861
public:
5962
Expr *E;
6063

61-
LeafExprNode(Expr *E, Node *Parent) :
64+
LeafExprNode(Expr *E, OperatorNode *Parent) :
6265
Node(NodeKind::LeafExprNode, Parent),
6366
E(E) {}
6467

@@ -81,27 +84,32 @@ namespace clang {
8184
// Create a PreorderAST for the expression E.
8285
// @param[in] E is the sub expression to be added to a new node.
8386
// @param[in] Parent is the parent of the new node.
84-
void Create(Expr *E, Node *Parent = nullptr);
87+
void Create(Expr *E, OperatorNode *Parent = nullptr);
8588

8689
// Add a new node to the AST.
8790
// @param[in] Node is the current node to be added.
8891
// @param[in] Parent is the parent of the node to be added.
89-
void AddNode(Node *N, Node *Parent);
92+
void AddNode(Node *N, OperatorNode *Parent);
9093

91-
// Move the children (if any) of node N to its parent and then remove N.
92-
// @param[in] N is the current node.
93-
// @param[in] P is the parent of the node to be removed. P should be a
94-
// BinaryNode.
95-
void RemoveNode(Node *N, Node *P);
94+
// Coalesce the OperatorNode O with its parent. This involves moving the
95+
// children (if any) of node O to its parent and then removing O.
96+
// @param[in] O is the current node. O should be a OperatorNode.
97+
void CoalesceNode(OperatorNode *O);
9698

97-
// Recursively coalesce binary nodes having the same commutative and
99+
// Determines if a OperatorNode could be coalesced into its parent.
100+
// @param[in] O is the current node. O should be a OperatorNode.
101+
// @return Return true if O can be coalesced into its parent, false
102+
// otherwise.
103+
bool CanCoalesceNode(OperatorNode *O);
104+
105+
// Recursively coalesce OperatoreNodes having the same commutative and
98106
// associative operator.
99107
// @param[in] N is current node of the AST. Initial value is Root.
100108
// @param[in] Changed indicates whether a node was coalesced. We need this
101109
// to control when to stop recursive coalescing.
102110
void Coalesce(Node *N, bool &Changed);
103111

104-
// Sort the children expressions in a binary node of the AST.
112+
// Sort the children expressions in a OperatorNode of the AST.
105113
// @param[in] N is current node of the AST. Initial value is Root.
106114
void Sort(Node *N);
107115

clang/lib/3C/AVarBoundsInfo.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,6 @@ bool AvarBoundsInference::inferBounds(BoundsKey K, AVarGraph &BKGraph,
898898
std::set<BoundsKey> PotentialB;
899899
PotentialB.clear();
900900
for (auto TK : PotBDs[K]) {
901-
ProgramVar *TKVar = BI->getProgramVar(TK);
902901
getReachableBoundKeys(Kvar->getScope(), TK, PotentialB, BKGraph,
903902
true);
904903
}
@@ -1333,8 +1332,8 @@ bool AVarBoundsInfo::areSameProgramVar(BoundsKey B1, BoundsKey B2) {
13331332
}
13341333

13351334
ContextSensitiveBoundsKeyVisitor::ContextSensitiveBoundsKeyVisitor(
1336-
ASTContext *C, ProgramInfo &I, ConstraintResolver *CResolver)
1337-
: Context(C), Info(I), CR(CResolver) {
1335+
ASTContext *C, ProgramInfo &I)
1336+
: Context(C), Info(I) {
13381337
Info.getABoundsInfo().resetContextSensitiveBoundsKey();
13391338
}
13401339

clang/lib/3C/ArrayBoundsInferenceConsumer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,6 @@ bool LocalVarABVisitor::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
613613

614614
bool LocalVarABVisitor::VisitDeclStmt(DeclStmt *S) {
615615
// Build rules based on initializers.
616-
auto &ABoundsInfo = Info.getABoundsInfo();
617616
for (const auto &D : S->decls())
618617
if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
619618
Expr *InitE = VD->getInit();

clang/lib/3C/ConstraintBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ void ConstraintBuilderConsumer::HandleTranslationUnit(ASTContext &C) {
546546
TypeVarVisitor TV = TypeVarVisitor(&C, Info);
547547
ConstraintResolver CSResolver(Info, &C);
548548
ContextSensitiveBoundsKeyVisitor CSBV =
549-
ContextSensitiveBoundsKeyVisitor(&C, Info, &CSResolver);
549+
ContextSensitiveBoundsKeyVisitor(&C, Info);
550550
ConstraintGenVisitor GV = ConstraintGenVisitor(&C, Info, TV);
551551
TranslationUnitDecl *TUD = C.getTranslationUnitDecl();
552552
// Generate constraints.

clang/lib/3C/DeclRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ using namespace clang;
3030
void DeclRewriter::rewriteDecls(ASTContext &Context, ProgramInfo &Info,
3131
Rewriter &R) {
3232
// Compute the bounds information for all the array variables.
33-
ArrayBoundsRewriter ABRewriter(&Context, Info);
33+
ArrayBoundsRewriter ABRewriter(Info);
3434

3535
// Collect function and record declarations that need to be rewritten in a set
3636
// as well as their rewriten types in a map.

0 commit comments

Comments
 (0)