Commit ecfbc749 authored by Teng Qin's avatar Teng Qin Committed by GitHub

Merge pull request #1929 from iovisor/yhs_dev

fix a rewriter bug for array subscript
parents 02843254 eb7b586d
...@@ -509,7 +509,7 @@ bool ProbeVisitor::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { ...@@ -509,7 +509,7 @@ bool ProbeVisitor::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
SourceLocation lbracket_start, lbracket_end; SourceLocation lbracket_start, lbracket_end;
SourceRange lbracket_range; SourceRange lbracket_range;
pre = "({ typeof(" + E->getType().getAsString() + ") _val; __builtin_memset(&_val, 0, sizeof(_val));"; pre = "({ typeof(" + E->getType().getAsString() + ") _val; __builtin_memset(&_val, 0, sizeof(_val));";
pre += " bpf_probe_read(&_val, sizeof(_val), (u64)("; pre += " bpf_probe_read(&_val, sizeof(_val), (u64)((";
if (isMemberDereference(base)) { if (isMemberDereference(base)) {
pre += "&"; pre += "&";
// If the base of the array subscript is a member dereference, we'll rewrite // If the base of the array subscript is a member dereference, we'll rewrite
...@@ -530,7 +530,7 @@ bool ProbeVisitor::VisitArraySubscriptExpr(ArraySubscriptExpr *E) { ...@@ -530,7 +530,7 @@ bool ProbeVisitor::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
lbracket_range = expansionRange(SourceRange(lbracket_start, lbracket_end)); lbracket_range = expansionRange(SourceRange(lbracket_start, lbracket_end));
rewriter_.ReplaceText(lbracket_range, lbracket); rewriter_.ReplaceText(lbracket_range, lbracket);
rbracket = ")); _val; })"; rbracket = "))); _val; })";
rewriter_.ReplaceText(expansionLoc(E->getRBracketLoc()), 1, rbracket); rewriter_.ReplaceText(expansionLoc(E->getRBracketLoc()), 1, rbracket);
return true; return true;
......
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