Skip to content

Commit f689f14

Browse files
authored
Fix compiler warnings in astmatcher & uniontool (#70)
1 parent 5192a6a commit f689f14

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

commonAST/ASTMatcher.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ bool isInCurFile(ASTContext *Context, const Stmt* S, string& filename){
8484

8585
vector<string>::iterator fileItr = find(includeList.begin(), includeList.end(), filename);
8686
bool ret = fileItr != includeList.end();
87-
if(debugPrint && S->getStmtClassName() == "CXXConstructExpr"){
87+
if(debugPrint && S->getStmtClassName() == std::string("CXXConstructExpr")){
8888
cerr << "context is is current file: " << ret << endl;
8989

9090
}
@@ -232,7 +232,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
232232
bool DeclHelper(Decl *D){
233233

234234
const Stmt* parent = getStmtParent(D, Context);
235-
const Stmt* parentsParent = getStmtParent(parent, Context);
235+
//const Stmt* parentsParent = getStmtParent(parent, Context);
236236

237237
//if it is part of the (init; condition; increment) of a for loop, we don't care about it
238238
if(isFlowControl(D, Context)){
@@ -446,7 +446,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
446446
*/
447447
void StmtHelper(Stmt *x){
448448
//variable used for <cond> </cond>
449-
bool condition = false;
449+
//bool condition = false;
450450
bool isElse = false;
451451
if(x != NULL){
452452
string output = "";
@@ -463,7 +463,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
463463

464464
const Stmt* parent = getStmtParent(x, Context);
465465
//PROBLEM
466-
if(x->getStmtClassName() != "ForStmt" && isFlowControl(x, Context)){
466+
if(x->getStmtClassName() != std::string("ForStmt") && isFlowControl(x, Context)){
467467
//return;
468468
}
469469

@@ -587,7 +587,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
587587
}else if(node == "DoStmt"){
588588
output += "<do";
589589
}else if(node == "IfStmt"){
590-
if(parent->getStmtClassName() != "IfStmt"){
590+
if(parent->getStmtClassName() != std::string("IfStmt")){
591591
stringstream ssminus;
592592
ssminus << (intLevel-1);
593593
output += "<ifBlock," + ssminus.str() + ">\n";
@@ -635,7 +635,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
635635

636636
}else if(node == "CXXConstructExpr"){
637637
CXXConstructExpr* ce = (CXXConstructExpr*) x;
638-
Decl* CD = ce->getConstructor();
638+
//Decl* CD = ce->getConstructor();
639639

640640
string filename;
641641
//if(isInCurFile(Context, CD, filename)){
@@ -711,7 +711,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
711711
}
712712

713713
}else if(node == "DeclRefExpr"){
714-
if(parent != NULL && parent->getStmtClassName() == "ImplicitCastExpr"){
714+
if(parent != NULL && parent->getStmtClassName() == std::string("ImplicitCastExpr")){
715715
DeclRefExpr* dr = (DeclRefExpr*) x;
716716
ValueDecl* d = (ValueDecl*) dr->getDecl();
717717
//cout << d->getQualType().getAsString() << endl;
@@ -937,8 +937,8 @@ It can be a grandparent, great grand parent etc
937937

938938
const Stmt* parent = getStmtParent(S, Context);
939939

940-
if(S->getStmtClassName() == "IfStmt" and parent != NULL
941-
and parent->getStmtClassName() != "IfStmt"){
940+
if(S->getStmtClassName() == std::string("IfStmt") and parent != NULL
941+
and parent->getStmtClassName() != std::string("IfStmt")){
942942
level += 1;
943943
}
944944

commonAST/unionTool.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ bool isInCurFile(ASTContext *Context, const Stmt* S, string& filename){
8484

8585
vector<string>::iterator fileItr = find(includeList.begin(), includeList.end(), filename);
8686
bool ret = fileItr != includeList.end();
87-
if(debugPrint && S->getStmtClassName() == "CXXConstructExpr"){
87+
if(debugPrint && S->getStmtClassName() == std::string("CXXConstructExpr")){
8888
cerr << "context is is current file: " << ret << endl;
8989

9090
}
@@ -232,7 +232,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
232232
bool DeclHelper(Decl *D){
233233

234234
const Stmt* parent = getStmtParent(D, Context);
235-
const Stmt* parentsParent = getStmtParent(parent, Context);
235+
//const Stmt* parentsParent = getStmtParent(parent, Context);
236236

237237
//if it is part of the (init; condition; increment) of a for loop, we don't care about it
238238
if(isFlowControl(D, Context)){
@@ -443,7 +443,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
443443
*/
444444
void StmtHelper(Stmt *x){
445445
//variable used for <cond> </cond>
446-
bool condition = false;
446+
//bool condition = false;
447447
bool isElse = false;
448448
if(x != NULL){
449449
string output = "";
@@ -460,7 +460,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
460460

461461
const Stmt* parent = getStmtParent(x, Context);
462462
//PROBLEM
463-
if(x->getStmtClassName() != "ForStmt" && isFlowControl(x, Context)){
463+
if(x->getStmtClassName() != std::string("ForStmt") && isFlowControl(x, Context)){
464464
return;
465465
}
466466

@@ -533,7 +533,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
533533
}
534534
535535
536-
if(parent != NULL && strcmp(parent->getStmtClassName(), "IfStmt") == 0){
536+
if(parent != NULL && strcmp(parent->getStmtClassName(), std::string("IfStmt")) == 0){
537537
if(debugPrint){
538538
cerr << "possibly an if statement" << endl;
539539
}
@@ -579,7 +579,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
579579
}else if(node == "DoStmt"){
580580
output += "<do";
581581
}else if(node == "IfStmt"){
582-
if(parent->getStmtClassName() != "IfStmt"){
582+
if(parent->getStmtClassName() != std::string("IfStmt")){
583583
intLevel += 1;
584584
stringstream ssif;
585585
ssif << intLevel;
@@ -621,7 +621,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
621621
}
622622

623623
}else if(node == "CallExpr"){
624-
CallExpr* expr = (CallExpr*) x;
624+
//CallExpr* expr = (CallExpr*) x;
625625
output += "<Call";
626626
//output += "<calling func: ";
627627
//output += expr->getDirectCallee()->getNameInfo().getAsString();
@@ -641,7 +641,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
641641

642642
string filename;
643643
if(isInCurFile(Context, CD, filename)){
644-
CXXMethodDecl* MD = ce->getConstructor();
644+
//CXXMethodDecl* MD = ce->getConstructor();
645645
output += "<Call ";
646646
/*
647647
output += MD->getNameInfo().getAsString();
@@ -698,7 +698,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
698698

699699
string filename;
700700
if(isInCurFile(Context, CD, filename)){
701-
CXXMethodDecl* MD = ce->getConstructor();
701+
//CXXMethodDecl* MD = ce->getConstructor();
702702

703703
output += "<Call ";
704704
/*
@@ -718,7 +718,7 @@ class ASTMatcherVisitor : public RecursiveASTVisitor<ASTMatcherVisitor> {
718718
}
719719

720720
}else if(node == "DeclRefExpr"){
721-
if(parent != NULL && parent->getStmtClassName() == "ImplicitCastExpr"){
721+
if(parent != NULL && parent->getStmtClassName() == std::string("ImplicitCastExpr")){
722722
DeclRefExpr* dr = (DeclRefExpr*) x;
723723
ValueDecl* d = (ValueDecl*) dr->getDecl();
724724
if(d != NULL){
@@ -939,15 +939,15 @@ It can be a grandparent, great grand parent etc
939939

940940
const Stmt* parent = getStmtParent(S, Context);
941941
const Stmt* gp = getStmtParent(parent, Context);
942-
//if(gp != NULL && parent != NULL && parent->getStmtClassName() == "IfStmt" && S->getStmtClassName() == "CompoundStmt"){ cout << gp->getStmtClassName() << endl;}
942+
//if(gp != NULL && parent != NULL && parent->getStmtClassName() == std::string("IfStmt") && S->getStmtClassName() == std::string("CompoundStmt")){ cout << gp->getStmtClassName() << endl;}
943943

944944

945-
if(parent != NULL && S->getStmtClassName() == "IfStmt" && parent->getStmtClassName() == "IfStmt"){
945+
if(parent != NULL && S->getStmtClassName() == std::string("IfStmt") && parent->getStmtClassName() == std::string("IfStmt")){
946946
level += 1;
947-
}else if(S->getStmtClassName() == "CompoundStmt" && gp != NULL && gp->getStmtClassName() == "IfStmt"
948-
&& parent != NULL && parent->getStmtClassName() == "IfStmt"){
949-
level = level;
950-
}else if(parent != NULL && parent->getStmtClassName() == "IfStmt"){
947+
}else if(S->getStmtClassName() == std::string("CompoundStmt") && gp != NULL && gp->getStmtClassName() == std::string("IfStmt")
948+
&& parent != NULL && parent->getStmtClassName() == std::string("IfStmt")){
949+
//level = level;
950+
}else if(parent != NULL && parent->getStmtClassName() == std::string("IfStmt")){
951951
level += 2;
952952
}
953953
//FIX HERE - issues!

0 commit comments

Comments
 (0)