facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.83k stars 2k forks source link

Topl parse error if there isn't a newline at end of property.topl #1710

Open JukMR opened 1 year ago

JukMR commented 1 year ago

Please make sure your issue is not addressed in the FAQ.

Please include the following information:

When trying to run a property in topl the following command fails if there is no newline at the end of file.

Running infer --topl-only --topl-properties property.topl -- clang -c file.c

where file.c is:

int foo(int number){
    return number;
}

int main(){
    foo(1);
}

and property.topl is:

property notOneAsArg
  prefix "Main"
  start -> start: *
  start -> error: foo(Arg1, Ret) when Arg1 == 1

When there is a newline at the end of property.topl topl detect the property as expected:

➜  issue infer --topl-only --topl-properties property.topl -- clang -c file.c
Capturing in make/cc mode...
Found 1 source file to analyze in $HOME/issue/infer-out
1/1 [################################################################################] 100% 38.55ms

file.c:5: error: Topl Error
  property notOneAsArg fails.
  3. }
  4. 
  5. int main(){
     ^
  6.     foo(1);
  7. }

Found 1 issue
  Issue Type(ISSUED_TYPE_ID): #
      Topl Error(TOPL_ERROR): 1

When there is no newline at the end of property.topl the following error occurs

➜  issue infer --topl-only --topl-properties property.topl -- clang -c file.c
Usage Error: $HOME/property.topl:4:48: topl parse error

I don't know if this an expected behavior but couldn't find its explanation anywhere on the topl docs.

CC: @dgutson