forked from OSchip/llvm-project
Soften the macro rewrite error to a warning (and change the text).
llvm-svn: 45209
This commit is contained in:
parent
6a128ae962
commit
7e718bb3fd
|
@ -646,12 +646,10 @@ Stmt *RewriteTest::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
|
||||||
IV->getLocation());
|
IV->getLocation());
|
||||||
if (Rewrite.ReplaceStmt(IV, Replacement)) {
|
if (Rewrite.ReplaceStmt(IV, Replacement)) {
|
||||||
// replacement failed.
|
// replacement failed.
|
||||||
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
|
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Warning,
|
||||||
"rewriter could not replace sub-expression due to macros");
|
"rewriting sub-expression within a macro (may not be correct)");
|
||||||
SourceRange Range = IV->getSourceRange();
|
SourceRange Range = IV->getSourceRange();
|
||||||
Diags.Report(Context->getFullLoc(IV->getLocation()), DiagID, 0, 0, &Range, 1);
|
Diags.Report(Context->getFullLoc(IV->getLocation()), DiagID, 0, 0, &Range, 1);
|
||||||
delete IV;
|
|
||||||
return Replacement;
|
|
||||||
}
|
}
|
||||||
delete IV;
|
delete IV;
|
||||||
return Replacement;
|
return Replacement;
|
||||||
|
@ -670,12 +668,10 @@ Stmt *RewriteTest::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
|
||||||
ParenExpr *PE = new ParenExpr(SourceLocation(), SourceLocation(), castExpr);
|
ParenExpr *PE = new ParenExpr(SourceLocation(), SourceLocation(), castExpr);
|
||||||
if (Rewrite.ReplaceStmt(IV->getBase(), PE)) {
|
if (Rewrite.ReplaceStmt(IV->getBase(), PE)) {
|
||||||
// replacement failed.
|
// replacement failed.
|
||||||
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
|
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Warning,
|
||||||
"rewriter could not replace sub-expression due to macros");
|
"rewriting sub-expression within a macro (may not be correct)");
|
||||||
SourceRange Range = IV->getBase()->getSourceRange();
|
SourceRange Range = IV->getBase()->getSourceRange();
|
||||||
Diags.Report(Context->getFullLoc(IV->getBase()->getLocStart()), DiagID, 0, 0, &Range, 1);
|
Diags.Report(Context->getFullLoc(IV->getBase()->getLocStart()), DiagID, 0, 0, &Range, 1);
|
||||||
delete IV->getBase();
|
|
||||||
return PE;
|
|
||||||
}
|
}
|
||||||
delete IV->getBase();
|
delete IV->getBase();
|
||||||
return PE;
|
return PE;
|
||||||
|
@ -935,12 +931,10 @@ Stmt *RewriteTest::RewriteAtEncode(ObjCEncodeExpr *Exp) {
|
||||||
SourceLocation(), SourceLocation());
|
SourceLocation(), SourceLocation());
|
||||||
if (Rewrite.ReplaceStmt(Exp, Replacement)) {
|
if (Rewrite.ReplaceStmt(Exp, Replacement)) {
|
||||||
// replacement failed.
|
// replacement failed.
|
||||||
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
|
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Warning,
|
||||||
"rewriter could not replace sub-expression due to macros");
|
"rewriting sub-expression within a macro (may not be correct)");
|
||||||
SourceRange Range = Exp->getSourceRange();
|
SourceRange Range = Exp->getSourceRange();
|
||||||
Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1);
|
Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1);
|
||||||
delete Replacement;
|
|
||||||
return Exp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace this subexpr in the parent.
|
// Replace this subexpr in the parent.
|
||||||
|
@ -961,12 +955,10 @@ Stmt *RewriteTest::RewriteAtSelector(ObjCSelectorExpr *Exp) {
|
||||||
&SelExprs[0], SelExprs.size());
|
&SelExprs[0], SelExprs.size());
|
||||||
if (Rewrite.ReplaceStmt(Exp, SelExp)) {
|
if (Rewrite.ReplaceStmt(Exp, SelExp)) {
|
||||||
// replacement failed.
|
// replacement failed.
|
||||||
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
|
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Warning,
|
||||||
"rewriter could not replace sub-expression due to macros");
|
"rewriting sub-expression within a macro (may not be correct)");
|
||||||
SourceRange Range = Exp->getSourceRange();
|
SourceRange Range = Exp->getSourceRange();
|
||||||
Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1);
|
Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1);
|
||||||
delete SelExp;
|
|
||||||
return Exp;
|
|
||||||
}
|
}
|
||||||
delete Exp;
|
delete Exp;
|
||||||
return SelExp;
|
return SelExp;
|
||||||
|
@ -1295,12 +1287,10 @@ Stmt *RewriteTest::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
|
||||||
CastExpr *cast = new CastExpr(Exp->getType(), call, SourceLocation());
|
CastExpr *cast = new CastExpr(Exp->getType(), call, SourceLocation());
|
||||||
if (Rewrite.ReplaceStmt(Exp, cast)) {
|
if (Rewrite.ReplaceStmt(Exp, cast)) {
|
||||||
// replacement failed.
|
// replacement failed.
|
||||||
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
|
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Warning,
|
||||||
"rewriter could not replace sub-expression due to macros");
|
"rewriting sub-expression within a macro (may not be correct)");
|
||||||
SourceRange Range = Exp->getSourceRange();
|
SourceRange Range = Exp->getSourceRange();
|
||||||
Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1);
|
Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1);
|
||||||
delete cast;
|
|
||||||
return Exp;
|
|
||||||
}
|
}
|
||||||
delete Exp;
|
delete Exp;
|
||||||
return cast;
|
return cast;
|
||||||
|
@ -1668,12 +1658,10 @@ Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) {
|
||||||
// Now do the actual rewrite.
|
// Now do the actual rewrite.
|
||||||
if (Rewrite.ReplaceStmt(Exp, PE)) {
|
if (Rewrite.ReplaceStmt(Exp, PE)) {
|
||||||
// replacement failed.
|
// replacement failed.
|
||||||
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
|
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Warning,
|
||||||
"rewriter could not replace sub-expression due to macros");
|
"rewriting sub-expression within a macro (may not be correct)");
|
||||||
SourceRange Range = Exp->getSourceRange();
|
SourceRange Range = Exp->getSourceRange();
|
||||||
Diags.Report(Context->getFullLoc(Exp->getLocStart()), DiagID, 0, 0, &Range, 1);
|
Diags.Report(Context->getFullLoc(Exp->getLocStart()), DiagID, 0, 0, &Range, 1);
|
||||||
delete PE;
|
|
||||||
return Exp;
|
|
||||||
}
|
}
|
||||||
delete Exp;
|
delete Exp;
|
||||||
return PE;
|
return PE;
|
||||||
|
@ -1681,12 +1669,10 @@ Stmt *RewriteTest::RewriteMessageExpr(ObjCMessageExpr *Exp) {
|
||||||
// Now do the actual rewrite.
|
// Now do the actual rewrite.
|
||||||
if (Rewrite.ReplaceStmt(Exp, CE)) {
|
if (Rewrite.ReplaceStmt(Exp, CE)) {
|
||||||
// replacement failed.
|
// replacement failed.
|
||||||
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
|
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Warning,
|
||||||
"rewriter could not replace sub-expression due to macros");
|
"rewriting sub-expression within a macro (may not be correct)");
|
||||||
SourceRange Range = Exp->getSourceRange();
|
SourceRange Range = Exp->getSourceRange();
|
||||||
Diags.Report(Context->getFullLoc(Exp->getLocStart()), DiagID, 0, 0, &Range, 1);
|
Diags.Report(Context->getFullLoc(Exp->getLocStart()), DiagID, 0, 0, &Range, 1);
|
||||||
delete CE;
|
|
||||||
return Exp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete Exp;
|
delete Exp;
|
||||||
|
@ -1710,12 +1696,10 @@ Stmt *RewriteTest::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
|
||||||
ProtoExprs.size());
|
ProtoExprs.size());
|
||||||
if (Rewrite.ReplaceStmt(Exp, ProtoExp)) {
|
if (Rewrite.ReplaceStmt(Exp, ProtoExp)) {
|
||||||
// replacement failed.
|
// replacement failed.
|
||||||
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Error,
|
unsigned DiagID = Diags.getCustomDiagID(Diagnostic::Warning,
|
||||||
"rewriter could not replace sub-expression due to macros");
|
"rewriting sub-expression within a macro (may not be correct)");
|
||||||
SourceRange Range = Exp->getSourceRange();
|
SourceRange Range = Exp->getSourceRange();
|
||||||
Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1);
|
Diags.Report(Context->getFullLoc(Exp->getAtLoc()), DiagID, 0, 0, &Range, 1);
|
||||||
delete ProtoExp;
|
|
||||||
return Exp;
|
|
||||||
}
|
}
|
||||||
delete Exp;
|
delete Exp;
|
||||||
return ProtoExp;
|
return ProtoExp;
|
||||||
|
|
Loading…
Reference in New Issue