diff options
author | Nico Weber <nicolasweber@gmx.de> | 2013-01-17 17:17:19 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2013-01-17 17:17:19 +0000 |
commit | 80a82761bde1fee351c6a7381f439ba8b6213198 (patch) | |
tree | 457d41cce6555bd8d4ed146c229430f906579823 /clang/lib/Analysis/PrintfFormatString.cpp | |
parent | 149d952e861f7730a580a1b842a589a81d1494c9 (diff) | |
download | llvm-80a82761bde1fee351c6a7381f439ba8b6213198.zip llvm-80a82761bde1fee351c6a7381f439ba8b6213198.tar.gz llvm-80a82761bde1fee351c6a7381f439ba8b6213198.tar.bz2 |
Formatter: Get bit tests in ifs right.
It's generally not possible to know if 'a' '*' 'b' is a multiplication
expression or a variable declaration with a purely lexer-based approach. The
formatter currently uses a heuristic that classifies this token sequence as a
multiplication in rhs contexts (after '=' or 'return') and as a declaration
else.
Because of this, it gets bit tests in ifs, such as "if (a & b)" wrong. However,
declarations in ifs always have to be followed by '=', so this patch changes
the formatter to classify '&' as an operator if it's at the start of an if
statement.
Before:
if (a& b)
if (int* b = f())
Now:
if (a & b)
if (int* b = f())
llvm-svn: 172731
Diffstat (limited to 'clang/lib/Analysis/PrintfFormatString.cpp')
0 files changed, 0 insertions, 0 deletions