Skip to content

Source rewrite misidentifies non-block-closing } as such  #16

Description

@trungtruong1

Reproducible: foo.c

int main(){
  if(1)
    2;
  else
    const *foo = "{}";

}

Rewrite passes:

/usr/local/bin/clang -fcommon -g -O2 -E -o fault1.c foo.c
/usr/local/bin/clang -Xclang -load -Xclang /root/project/MSV/src/.libs/libprofiler.so.0\
  -Xclang -plugin -Xclang err-profiler-gen -Xclang -plugin-arg-err-profiler-gen\
 -Xclang gen.c -Xclang -plugin-arg-err-profiler-gen -Xclang gen.log -fcommon -g -O2 -c -o foo.o foo.c
/usr/local/bin/clang -Xclang -load -Xclang /root/project/MSV/src/.libs/libprofiler.so.0\
  -Xclang -plugin -Xclang err-profiler-rewrite  -Xclang -plugin-arg-err-profiler-rewrite\
  -Xclang gen.c -Xclang -plugin-arg-err-profiler-rewrite -Xclang rewrite.c -fcommon -g -O2 -c -o xargs.o fault1.c

Output: rewrite.c

#include "_prophet_profile.h"
# 1 "fool.c"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 341 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "fool.c" 2
int main(){
 __prof_init();
 __prof_track(0);
 if(1)
  {__prof_track(1);
  2;}
 else
  {__prof_track(2);
  const *foo = }"{}";

}

Expected output:

  {__prof_track(2);
  const *foo = "{}";}

I think it has something to do with the function below, you can start investigating from here:

virtual bool VisitIfStmt(IfStmt *IF) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions