[all-commits] [llvm/llvm-project] e53b9f: Print source location in the error message when pa...

Shivanshu Goyal via All-commits all-commits at lists.llvm.org
Wed Dec 16 12:18:56 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: e53b9f733a7cb0a5da372b73ab6b7711c0300d65
      https://github.com/llvm/llvm-project/commit/e53b9f733a7cb0a5da372b73ab6b7711c0300d65
  Author: Shivanshu Goyal <shigoyal at microsoft.com>
  Date:   2020-12-16 (Wed, 16 Dec 2020)

  Changed paths:
    M clang/lib/Parse/ParseExpr.cpp
    A clang/test/Parser/sizeof-missing-parens.c

  Log Message:
  -----------
  Print source location in the error message when parens are missing around sizeof typename and the expression is inside macro expansion

Given the following code:

```
void Foo(int);

void Baz()
{
	Bar(sizeof int);
}
```

The error message which is printed today is this:
```
error: expected parentheses around type name in sizeof expression
```

There is no source location printed whatsoever, so fixing a compile break like this becomes extremely hard in a large codebase.

My change improves the error message. But it doesn't output a FixItHint because I wasn't able to figure out how to get the locations for left and right parens. So any tips would be appreciated.

```
<source>:7:6: error: expected parentheses around type name in sizeof expression
        Bar(sizeof int);
            ^
```

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D91129




More information about the All-commits mailing list