Commit d5c75af8 authored by Daniel Cheng's avatar Daniel Cheng

Fix value_cleanup to handle cases where arg_expr is a macro.

Apparently true and false are macros!

BUG=581865
R=danakj@chromium.org

Review URL: https://codereview.chromium.org/2036413003 .

Cr-Commit-Position: refs/heads/master@{#397800}
parent 28307938
...@@ -32,8 +32,11 @@ void ListValueRewriter::AppendCallback::run( ...@@ -32,8 +32,11 @@ void ListValueRewriter::AppendCallback::run(
auto* newExpr = result.Nodes.getNodeAs<clang::CXXNewExpr>("newExpr"); auto* newExpr = result.Nodes.getNodeAs<clang::CXXNewExpr>("newExpr");
auto* argExpr = result.Nodes.getNodeAs<clang::Expr>("argExpr"); auto* argExpr = result.Nodes.getNodeAs<clang::Expr>("argExpr");
// Note that for the end loc, we use the expansion loc: the argument might be
// a macro like true and false.
clang::CharSourceRange pre_arg_range = clang::CharSourceRange::getCharRange( clang::CharSourceRange pre_arg_range = clang::CharSourceRange::getCharRange(
newExpr->getLocStart(), argExpr->getLocStart()); newExpr->getLocStart(),
result.SourceManager->getExpansionLoc(argExpr->getLocStart()));
replacements_->emplace(*result.SourceManager, pre_arg_range, ""); replacements_->emplace(*result.SourceManager, pre_arg_range, "");
clang::CharSourceRange post_arg_range = clang::CharSourceRange post_arg_range =
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
#include "base/values.h" #include "base/values.h"
#define true true
void F() { void F() {
base::ListValue list; base::ListValue list;
list.AppendBoolean(1 == 0); list.AppendBoolean(1 == 0);
list.AppendBoolean(true);
list.AppendInteger(static_cast<unsigned char>(1.0)); list.AppendInteger(static_cast<unsigned char>(1.0));
list.AppendDouble(double{3}); list.AppendDouble(double{3});
list.AppendString("abc"); list.AppendString("abc");
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
#include "base/values.h" #include "base/values.h"
#define true true
void F() { void F() {
base::ListValue list; base::ListValue list;
list.Append(new base::FundamentalValue(1 == 0)); list.Append(new base::FundamentalValue(1 == 0));
list.Append(new base::FundamentalValue(true));
list.Append(new base::FundamentalValue(static_cast<unsigned char>(1.0))); list.Append(new base::FundamentalValue(static_cast<unsigned char>(1.0)));
list.Append(new base::FundamentalValue(double{3})); list.Append(new base::FundamentalValue(double{3}));
list.Append(new base::StringValue("abc")); list.Append(new base::StringValue("abc"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment