llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.09k stars 12k forks source link

clang-format messes up returning negative numbers #15575

Closed llvmbot closed 11 years ago

llvmbot commented 11 years ago
Bugzilla Link 15203
Resolution INVALID
Resolved on Feb 08, 2013 01:12
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @nico

Extended Description

clang-format (LLVM version 3.3svn) converts return -1; to return - 1;

It should know about negative numbers. It doesn't seem to mess up asdf = asdf * -2; however (it doesn't insert a space there).

llvmbot commented 11 years ago

The script is here http://src.chromium.org/viewvc/chrome/trunk/src/tools/clang/scripts/update.sh?revision=174285&view=markup and it looks like the version is hardcoded and Nico just manually updates it from time to time. I guess I'll just wait for the next update. Thanks for the help.

llvmbot commented 11 years ago

Last Changed Rev: 170390 Last Changed Date: 2012-12-17 16:31:01 -0800 (Mon, 17 Dec 2012)

That might explain it, this would mean it is an almost two months old version. I am not actually sure on how clang-format makes it into the chromium repository. Adding Nico, who might have some insides into this.

llvmbot commented 11 years ago

Sorry if I'm doing something stupid. I checked out the code using Chromium's checkout script and built it today.

odor[~] local/src2/src/third_party/llvm-build/Release+Asserts/bin/clang-format -version LLVM (http://llvm.org/): LLVM version 3.3svn Optimized build with assertions. Built Feb 7 2013 (14:00:39). Default target: x86_64-unknown-linux-gnu Host CPU: corei7

odor[~] cat test.cc

int foo() { return -1; }

odor[~] local/src2/src/third_party/llvm-build/Release+Asserts/bin/clang-format < test.cc

int foo() { return - 1; }

odor[~] cd local/src2/src/third_party/llvm

odor[~/local/src2/src/third_party/llvm] svn info Path: . URL: https://llvm.org/svn/llvm-project/llvm/trunk Repository Root: https://llvm.org/svn/llvm-project Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 Revision: 170392 Node Kind: directory Schedule: normal Last Changed Author: echristo Last Changed Rev: 170390 Last Changed Date: 2012-12-17 16:31:01 -0800 (Mon, 17 Dec 2012)

odor[~/local/src2/src/third_party/llvm] svn status ? projects/compiler-rt

llvmbot commented 11 years ago

No, it doesn't. There is even a test for it:

unittests/Format/FormatTests.cpp (l. 1503)

Could you please verify that this really happens for you and if so, paste a reduced version of the code where it happens?