Re: [PATCH] D155580: [trivial-auto-var-init] Do not emit initialization code for empty class

2023-07-18 Thread Serge Guelton via cfe-commits
On Tue, Jul 18, 2023 at 10:15:09PM +0900, JF Bastien wrote:
> 
> 
> On Tue, Jul 18, 2023 at 8:41 PM serge via Phabricator <[1]
> revi...@reviews.llvm.org> wrote:
> 
> serge-sans-paille created this revision.
> serge-sans-paille added reviewers: nickdesaulniers, jfb, aaron.ballman.
> Herald added a subscriber: kristof.beyls.
> Herald added a project: All.
> serge-sans-paille requested review of this revision.
> Herald added a project: clang.
> Herald added a subscriber: cfe-commits.
> 
> Empty class still use one byte, but there is no way to read that byte
> programmatically in a legitimate way. Yet trivial auto var init always
> generate a store for it and there is no programmatic way to prevent the
> generation of that extra store.
> 
> 
> 
> This is the same as padding, and is initialized on purpose. If it’s truly
> unused then the optimizer will eliminate it… unless it can’t prove whether the
> store is dead. 
> 
> Does this show up in any meaningless performance case? If so, can we optimize
> it away?

It shows up in the top 10 hottest places in firefox where
-ftrivial-auto-var-init injects code that cannot be removed. It cannot be
removed because there's an opaque method call in the object that prevents the
store from being removed, something along those lines: 
https://godbolt.org/z/o5asYGq8G

For my particular case I can work around this, but as the behavior was different
in GCC, I think it's at elast worth having this discussion :-)

I understand your point wrt. padding and empty classes, harden by default. Can
you think of any legitimate use of the actual value used to `anchor` the empty
class?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D120333: [NFC][Lexer] Make access to LangOpts more consistent

2022-02-23 Thread Serge Guelton via cfe-commits
Sure!
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D99409: [clang] Speedup line offset mapping computation

2021-04-07 Thread Serge Guelton via cfe-commits
On Wed, Apr 07, 2021 at 12:48:01PM +, Simon Pilgrim via Phabricator wrote:
> RKSimon added a comment.
> 
> @serge-sans-paille Please can you look at the clang-ppc buildbot breakages: 
> http://lab.llvm.org:8011/#/builders/52/builds/6108

I'm on it.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D78192: Support compiler extensions as a normal component

2020-04-24 Thread Serge Guelton via cfe-commits
On Fri, Apr 24, 2020 at 10:15:15AM +0100, Russell Gallop wrote:
> Hi Serge,
> 
> It looks like this is failing to build on Windows bots (e.g. [1]http://
> lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/
> builds/32003). Error below.
> 
> Please could you take a look?

e307eeba0137700e75893089cf0de03383d851ca should do the trick (finger crossed)

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D78192: Support compiler extensions as a normal component

2020-04-24 Thread Serge Guelton via cfe-commits
On Fri, Apr 24, 2020 at 10:15:15AM +0100, Russell Gallop wrote:
> Hi Serge,
> 
> It looks like this is failing to build on Windows bots (e.g. [1]http://
> lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/
> builds/32003). Error below.
> 
> Please could you take a look?

Sure, thanks for reaching me!

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Serge Guelton via cfe-commits
On Wed, Feb 26, 2020 at 08:08:49PM +, Leonard Chan via Phabricator wrote:
> leonardchan added a comment.
> 
> Unsure if my reply was sent over email so copying it here.
> 
> Yup, adding `// REQUIRES: platform-linker` to both `*-extra.c` files seems to 
> fix it. Thanks. Will you be sending out the fix?

Feel free to commit these changes/push them on phabricator if they work for 
you, unless you explicitly
want me to do it?

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Serge Guelton via cfe-commits
Does adding

// REQUIRES: platform-linker

to Driver/riscv32-toolchain-extra.c fixes your issue?


On Wed, Feb 26, 2020 at 06:25:39PM +, Leonard Chan via Phabricator wrote:
> leonardchan added a comment.
> 
> Hi again, I think e058667a2e017d3225a9bb067dbac7f2159576f7 
>  
> might've broken our toolchain again:
> 
>   FAIL: Clang :: Driver/riscv32-toolchain-extra.c (5723 of 17018)
>    TEST 'Clang :: Driver/riscv32-toolchain-extra.c' 
> FAILED 
>   Script:
>   --
>   : 'RUN: at line 14';   mkdir -p 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin
>   : 'RUN: at line 15';   [ ! -s 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>  ] || rm 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>   : 'RUN: at line 16';   [ ! -s 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>  ] || rm 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>   : 'RUN: at line 17';   [ ! -s 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>  ] || rm 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>   : 'RUN: at line 18';   ln -s 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/clang 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>   : 'RUN: at line 19';   ln -s 
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
>  
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>   : 'RUN: at line 20';   ln -s 
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf
>  
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>   : 'RUN: at line 21';   
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>  /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c 
> -### -no-canonical-prefixes 
> --gcc-toolchain=/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/invalid
>  -target riscv32-unknown-elf --rtlib=platform 2>&1 | 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/FileCheck 
> -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC 
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
>   --
>   Exit Code: 1
>   
>   Command Output (stderr):
>   --
>   
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c:27:34:
>  error: C-RV32-BAREMETAL-ILP32-NOGCC: expected string not found in input
>   // C-RV32-BAREMETAL-ILP32-NOGCC: 
> "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
>^
>   :5:1070: note: scanning from here
>
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang"
>  "-cc1" "-triple" "riscv32-unknown-unknown-elf" "-emit-obj" "-mrelax-all" 
> "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier" 
> "-discard-value-names" "-main-file-name" "riscv32-toolchain-extra.c" 
> "-mrelocation-model" "static" "-mthread-model" "posix" "-mframe-pointer=all" 
> "-fmath-errno" "-fno-rounding-math" "-masm-verbose" "-mconstructor-aliases" 
> "-nostdsysteminc" "-target-feature" "+m" "-target-feature" "+a" 
> "-target-feature" "+c" "-target-feature" "+relax" "-target-feature" 
> "-save-restore" "-target-abi" "ilp32" "-dwarf-column-info" 
> "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" 
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/lib/clang/11.0.0"
>  "-internal-isystem" 
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
>  "-fdebug-compilation-dir" 
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver"
>  "-ferror-limit" "19" "-fmessage-length" "0" "-fno-signed-char" 
> "-fgnuc-version=4.2.1" 

Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Serge Guelton via cfe-commits
On Wed, Feb 26, 2020 at 06:25:39PM +, Leonard Chan via Phabricator wrote:
> leonardchan added a comment.
> 
> Hi again, I think e058667a2e017d3225a9bb067dbac7f2159576f7 
>  
> might've broken our toolchain again:

s***t. Can you share you cmake configure flags?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D68720: Support -fstack-clash-protection for x86

2020-02-08 Thread Serge Guelton via cfe-commits
On Sat, Feb 08, 2020 at 01:26:03PM +, Simon Pilgrim via Phabricator wrote:
> RKSimon added a comment.
> 
> @serge-sans-paille Please can you fix the issues with EXPENSIVE_CHECKS 
> builds: 
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-debian/builds/2604

yeah, spotted that... and reverted

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D68720: Support -fstack-clash-protection for x86

2020-02-07 Thread Serge Guelton via cfe-commits
On Fri, Feb 07, 2020 at 07:12:39PM +, Nico Weber via Phabricator wrote:
> thakis added a comment.
> 
> This breaks check-clang on mac and win: 
> http://45.33.8.238/mac/7485/step_7.txt http://45.33.8.238/win/7753/step_7.txt
> 
> Please revert and then investigate asynchronously, unless the fix is obvious.
> 
> 
> 
> 
> Comment at: clang/test/CodeGen/stack-clash-protection.c:2
> +// check interaction between -fstack-clash-protection and dynamic allocation 
> schemes
> +// RUN: %clang -target x86_64 -O0 -o %t.out %s -fstack-clash-protection && 
> %t.out
> +
> 
> Tests should compile binaries and then run them if at all possible. This is 
> impossible in cross-build scenarios and in general we try hard to have unit 
> tests, not integration tests. Check that this produces the IR you expect, and 
> have an llvm-level test that the IR produces the assembly you expect, and if 
> you must, an lld level test that checks that the generated elf file looks 
> like you think.

ok, thanks for the hint! Indeed I overlooked the cross compilation situation.
Thanks for the hint and for reverting!
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 24ab9b5 - Generalize the pass registration mechanism used by Polly to any third-party tool

2020-01-08 Thread Serge Guelton via cfe-commits
On Tue, Jan 07, 2020 at 04:57:29PM -0800, Eric Christopher wrote:
> >  ; CHECK-EP-VECTORIZER-START-NEXT: Running pass: NoOpFunctionPass
> > +; CHECK-EXT: Running pass: {{.*}}::Bye on foo
> >
> > Why is this running on every test of the pass manager? It should be an
> example
> > run in the examples directory and not on by default? Same for every 
> other
> PM
> > test. This seems like a bug?
> 
> It's not. When the examples are active and if the appropriate cmake flag 
> is
> set
> (which is not the case by default), the pass is linked in statically, and
> is run
> in the default pipeline. The CHECK-EXT prefix is disabled otherwise. 
> That's
> one
> of the configuration I did test :-)
> 
> 
> 
> I really don't think this is ideal. The examples directory shouldn't affect
> tests being run or not or in what way. Can we back this part out and talk 
> about
> it a bit more? I don't think we should need to do this to test the
> functionality.

I can just error if LLVM_BYE_LINK_INTO_TOOLS=ON, and remove that part. It means
less testing, but somehow Polly is already some kind of test case. Would
that be okay with you?

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 24ab9b5 - Generalize the pass registration mechanism used by Polly to any third-party tool

2020-01-07 Thread Serge Guelton via cfe-commits
On Mon, Jan 06, 2020 at 03:45:15PM -0800, Eric Christopher wrote:
> Hi Serge,

Hi Eric,

> I have a few questions here about this:
> 
> In general this appears to be a lot more complex than the existing plugin
> solutions and requires quite a lot of custom cmake rules that are difficult to
> maintain. Why do we want this in general for the project? I understand the
> desire to make polly less of a special case, but I don't think that the 
> overall
> complexity is worth the added ability to register polly plugins. Perhaps
> disabling the polly plugin registration scheme is a better option?

Indeed, the cmake machinery is now more generic (making Polly an application of
it, instead of an exception), at the expense of being more complex.

Why would we want that? When trying to write a custom pass, the usual process,
is to write a plugin that works correctly with opt, and that step is relatively
easy. To achieve a decent clang integration, it gets more difficult, and if one
still take the external plugin approach, one ends up with very long and non
standard command line like -Xclang -load -Xclang MyPlugin.so etc. So one need
another step to integrate the plugin into the static build, which means forking
llvm-project, rebasing every now and then etc.

The proposed infrastructure makes this process smoother and non intrusive to the
llvm-project codebase: all development can be done in a separate git repo,
integration is controlled through cmake flags, and integration to
clang/opt/bugpoint is built-in.

> That being said, perhaps it is worth it? But I think we need to call out why 
> we
> want it. I would also have expected something to llvm-dev for a change of this
> magnitude. I didn't see anyone from the pass manager hierarchy on the reviews
> and the final reviewer wasn't someone who contributes to these areas 
> typically.

I've (obviously) mentioned this development on llvm-dev, see

http://lists.llvm.org/pipermail/llvm-dev/2019-September/135326.html

Is there anything I should have done? Probably reaching llvm-dev before
commiting. Reaching the right reviewers has always been a challenge to me, I had
hoped that the mail to llvm-dev would trigger some subscription :-)

> In addition, what's with the OSX failure? It's currently turned off and was
> breaking the bots, but does it mean that you don't expect this machinery to
> work on OSX? That seems like a severely limiting factor for the project.

I've setup github actions to test many configurations before merging [0], but 
missed one of
them. I'm currently working on fixing that part.

> +One first needs to create an independent project and add it to either 
> ``tools/
> ``
> +or, using the MonoRepo layout, at the root of the repo alongside other
> projects.
> 
> This appears to be from an earlier incarnation of the patch? There's only one
> layout now.

Correct! I'll fix that.

> 
>  ; CHECK-EP-VECTORIZER-START-NEXT: Running pass: NoOpFunctionPass
> +; CHECK-EXT: Running pass: {{.*}}::Bye on foo
> 
> Why is this running on every test of the pass manager? It should be an example
> run in the examples directory and not on by default? Same for every other PM
> test. This seems like a bug?

It's not. When the examples are active and if the appropriate cmake flag is set
(which is not the case by default), the pass is linked in statically, and is run
in the default pipeline. The CHECK-EXT prefix is disabled otherwise. That's one
of the configuration I did test :-)

> Thanks!

Thanks for giving me the opportunity to clarify some obscure points, hope it
helps !


[0] 
https://github.com/serge-sans-paille/llvm-project/commit/37c9b5080acd3d7543347de109e44c402626d504/checks?check_suite_id=346849887

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r372281 - Initialize all fields in ABIArgInfo.

2019-09-18 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Sep 18 17:54:40 2019
New Revision: 372281

URL: http://llvm.org/viewvc/llvm-project?rev=372281=rev
Log:
Initialize all fields in ABIArgInfo.

Due to usage of an uninitialized fields, we end up with
a Conditional jump or move depends on uninitialised value

Fixes https://bugs.llvm.org/show_bug.cgi?id=40547

Commited on behalf of Martin Liska 

Modified:
cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h

Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=372281=372280=372281=diff
==
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original)
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Wed Sep 18 17:54:40 2019
@@ -109,14 +109,12 @@ private:
 UnpaddedCoerceAndExpandType = T;
   }
 
-  ABIArgInfo(Kind K)
-  : TheKind(K), PaddingInReg(false), InReg(false) {
-  }
-
 public:
-  ABIArgInfo()
+  ABIArgInfo(Kind K = Direct)
   : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0),
-TheKind(Direct), PaddingInReg(false), InReg(false) {}
+TheKind(K), PaddingInReg(false), InAllocaSRet(false),
+IndirectByVal(false), IndirectRealign(false), SRetAfterThis(false),
+InReg(false), CanBeFlattened(false), SignExt(false) {}
 
   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
   llvm::Type *Padding = nullptr,


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366194 - [clang-scan-view] Force utf-8 when handling report (python2 only)

2019-07-16 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Jul 16 01:56:47 2019
New Revision: 366194

URL: http://llvm.org/viewvc/llvm-project?rev=366194=rev
Log:
[clang-scan-view] Force utf-8 when handling report (python2 only)

Original patch by random human 

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

Modified:
cfe/trunk/tools/scan-view/share/ScanView.py

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=366194=366193=366194=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Tue Jul 16 01:56:47 2019
@@ -764,11 +764,11 @@ File Bug
 variables['report'] = m.group(2)
 
 try:
-f = open(path,'r')
+f = open(path,'rb')
 except IOError:
 return self.send_404()
 fs = os.fstat(f.fileno())
-data = f.read()
+data = f.read().decode('utf-8')
 for a,b in kReportReplacements:
 data = a.sub(b % variables, data)
 return self.send_string(data, ctype, mtime=fs.st_mtime)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r363975 - [clang-tidy] Fail gracefully upon empty database fields

2019-06-21 Thread Serge Guelton via cfe-commits
On Fri, Jun 21, 2019 at 08:16:42AM +, douglas.y...@sony.com wrote:
> Hi Serge,
> 
> The test you added here is failing on the PS4 Windows build bot, can you take 
> a look?

Sure, thanks for fwding it!

> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/26513/steps/test/logs/stdio

The error message seems to be OS-dependant, I do have a ttrivial patch, do you 
have means to reproduce the issue?

-- serge

> FAIL: Clang Tools :: clang-tidy/empty-database.cpp (14917 of 50455)
>  TEST 'Clang Tools :: clang-tidy/empty-database.cpp' 
> FAILED 
> Script:
> --
> : 'RUN: at line 1';   not clang-tidy -p 
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy/Inputs/empty-database
>  
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\empty-database.cpp
>  2>&1 | FileCheck 
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\empty-database.cpp
> --
> Exit Code: 1
> 
> Command Output (stdout):
> --
> $ ":" "RUN: at line 1"
> $ "not" "clang-tidy" "-p" 
> "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy/Inputs/empty-database"
>  
> "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\empty-database.cpp"
> note: command had no output on stdout or stderr
> error: command failed with exit status: 1
> $ "FileCheck" 
> "C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\empty-database.cpp"
> # command stderr:
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\empty-database.cpp:3:11:
>  error: CHECK: expected string not found in input
> 
> // CHECK: LLVM ERROR: Cannot chdir into ""!
> 
>   ^
> 
> :1:1: note: scanning from here
> 
> Skipping 
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\empty-database.cpp.
>  Compile command not found.
> 
> ^
> 
> :1:150: note: possible intended match here
> 
> Skipping 
> C:\ps4-buildslave2\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.src\tools\clang\tools\extra\test\clang-tidy\empty-database.cpp.
>  Compile command not found.
> 
>                   
>^
> 
> 
> error: command failed with exit status: 1
> 
> Douglas Yung
> 
> -Original Message-
> From: cfe-commits  On Behalf Of Serge 
> Guelton via cfe-commits
> Sent: Thursday, June 20, 2019 13:26
> To: cfe-commits@lists.llvm.org
> Subject: [clang-tools-extra] r363975 - [clang-tidy] Fail gracefully upon 
> empty database fields
> 
> Author: serge_sans_paille
> Date: Thu Jun 20 13:25:59 2019
> New Revision: 363975
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=363975=rev
> Log:
> [clang-tidy] Fail gracefully upon empty database fields
> 
> Fix bz#42281
> 
> Differential Revision: https://reviews.llvm.org/D63613
> 
> Added:
> clang-tools-extra/trunk/test/clang-tidy/empty-database/
> clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
> 
> clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json
> 
> Added: clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp?rev=363975=auto
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp (added)
> +++ clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp Thu Jun 20 
> 13:25:59 2019
> @@ -0,0 +1,3 @@
> +// RUN: not clang-tidy -p %S/empty-database %s 2>&1 | FileCheck %s
> +
> +// CHECK: LLVM ERROR: Cannot chdir into ""!
> 
> Added: 
> clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json?rev=363975=auto
> ==
> --- 
> clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json 
> (added)
> +++ 
> clang-tools-extra/tr

[clang-tools-extra] r363975 - [clang-tidy] Fail gracefully upon empty database fields

2019-06-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Thu Jun 20 13:25:59 2019
New Revision: 363975

URL: http://llvm.org/viewvc/llvm-project?rev=363975=rev
Log:
[clang-tidy] Fail gracefully upon empty database fields

Fix bz#42281

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

Added:
clang-tools-extra/trunk/test/clang-tidy/empty-database/
clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json

Added: clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp?rev=363975=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/empty-database.cpp Thu Jun 20 
13:25:59 2019
@@ -0,0 +1,3 @@
+// RUN: not clang-tidy -p %S/empty-database %s 2>&1 | FileCheck %s
+
+// CHECK: LLVM ERROR: Cannot chdir into ""!

Added: 
clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json?rev=363975=auto
==
--- 
clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json 
(added)
+++ 
clang-tools-extra/trunk/test/clang-tidy/empty-database/compile_commands.json 
Thu Jun 20 13:25:59 2019
@@ -0,0 +1,4 @@
+[{
+"directory":"",
+"file":"/tmp/","arguments":[]
+}]


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r363975 - [clang-tidy] Fail gracefully upon empty database fields

2019-06-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Thu Jun 20 13:25:59 2019
New Revision: 363975

URL: http://llvm.org/viewvc/llvm-project?rev=363975=rev
Log:
[clang-tidy] Fail gracefully upon empty database fields

Fix bz#42281

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

Modified:
cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp?rev=363975=363974=363975=diff
==
--- cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp Thu Jun 20 
13:25:59 2019
@@ -150,7 +150,8 @@ struct TransferableCommand {
 // spelling of each argument; re-rendering is lossy for aliased flags.
 // E.g. in CL mode, /W4 maps to -Wall.
 auto OptTable = clang::driver::createDriverOptTable();
-Cmd.CommandLine.emplace_back(OldArgs.front());
+if (!OldArgs.empty())
+  Cmd.CommandLine.emplace_back(OldArgs.front());
 for (unsigned Pos = 1; Pos < OldArgs.size();) {
   using namespace driver::options;
 
@@ -243,7 +244,8 @@ private:
 }
 
 // Otherwise just check the clang executable file name.
-return llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
+return !CmdLine.empty() &&
+   llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl");
   }
 
   // Map the language from the --std flag to that of the -x flag.

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=363975=363974=363975=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Jun 20 13:25:59 2019
@@ -481,7 +481,7 @@ int ClangTool::run(ToolAction *Action) {
   if (OverlayFileSystem->setCurrentWorkingDirectory(
   CompileCommand.Directory))
 llvm::report_fatal_error("Cannot chdir into \"" +
- Twine(CompileCommand.Directory) + "\n!");
+ Twine(CompileCommand.Directory) + "\"!");
 
   // Now fill the in-memory VFS with the relative file mappings so it will
   // have the correct relative paths. We never remove mappings but that


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362584 - Reduce memory consumption of coverage dumps

2019-06-05 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Jun  4 23:35:10 2019
New Revision: 362584

URL: http://llvm.org/viewvc/llvm-project?rev=362584=rev
Log:
Reduce memory consumption of coverage dumps

Avoiding an intermediate join operation removes the need for an
intermediate buffer that may be quite large, as showcased by

https://bugs.llvm.org/show_bug.cgi?id=41965

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

Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=362584=362583=362584=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Tue Jun  4 23:35:10 2019
@@ -1388,10 +1388,19 @@ void CoverageMappingModuleGen::emit() {
   std::string FilenamesAndCoverageMappings;
   llvm::raw_string_ostream OS(FilenamesAndCoverageMappings);
   CoverageFilenamesSectionWriter(FilenameRefs).write(OS);
-  std::string RawCoverageMappings =
-  llvm::join(CoverageMappings.begin(), CoverageMappings.end(), "");
-  OS << RawCoverageMappings;
-  size_t CoverageMappingSize = RawCoverageMappings.size();
+
+  // Stream the content of CoverageMappings to OS while keeping
+  // memory consumption under control.
+  size_t CoverageMappingSize = 0;
+  for (auto  : CoverageMappings) {
+CoverageMappingSize += S.size();
+OS << S;
+S.clear();
+S.shrink_to_fit();
+  }
+  CoverageMappings.clear();
+  CoverageMappings.shrink_to_fit();
+
   size_t FilenamesSize = OS.str().size() - CoverageMappingSize;
   // Append extra zeroes if necessary to ensure that the size of the filenames
   // and coverage mappings is a multiple of 8.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360885 - Fix isInSystemMacro in presence of macro and pasted token

2019-05-16 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Thu May 16 05:40:00 2019
New Revision: 360885

URL: http://llvm.org/viewvc/llvm-project?rev=360885=rev
Log:
Fix isInSystemMacro in presence of macro and pasted token

When a warning is raised from the expansion of a system macro that
involves pasted token, there was still situations were they were not
skipped, as showcased by this issue:
https://bugzilla.redhat.com/show_bug.cgi?id=1472437

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

Modified:
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/test/Misc/no-warn-in-system-macro.c

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=360885=360884=360885=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Thu May 16 05:40:00 2019
@@ -1466,8 +1466,13 @@ public:
 
 // This happens when the macro is the result of a paste, in that case
 // its spelling is the scratch memory, so we take the parent context.
-if (isWrittenInScratchSpace(getSpellingLoc(loc)))
-  return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));
+// There can be several level of token pasting.
+if (isWrittenInScratchSpace(getSpellingLoc(loc))) {
+  do {
+loc = getImmediateMacroCallerLoc(loc);
+  } while (isWrittenInScratchSpace(getSpellingLoc(loc)));
+  return isInSystemMacro(loc);
+}
 
 return isInSystemHeader(getSpellingLoc(loc));
   }

Modified: cfe/trunk/test/Misc/no-warn-in-system-macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/no-warn-in-system-macro.c?rev=360885=360884=360885=diff
==
--- cfe/trunk/test/Misc/no-warn-in-system-macro.c (original)
+++ cfe/trunk/test/Misc/no-warn-in-system-macro.c Thu May 16 05:40:00 2019
@@ -3,11 +3,16 @@
 
 #include 
 
+#define MACRO(x) x
+
 int main(void)
 {
double foo = 1.0;
 
if (isnan(foo))
return 1;
-   return 0;
+
+MACRO(isnan(foo));
+
+return 0;
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354549 - Revert r354546

2019-02-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Feb 20 22:59:21 2019
New Revision: 354549

URL: http://llvm.org/viewvc/llvm-project?rev=354549=rev
Log:
Revert r354546

This triggers an ICE on gcc 7, see 
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/17598/steps/build%20stage%201/logs/stdio

Modified:
cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h

Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=354549=354548=354549=diff
==
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original)
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Wed Feb 20 22:59:21 2019
@@ -111,13 +111,14 @@ private:
   }
 
   ABIArgInfo(Kind K)
-  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), TheKind(K),
-PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false),
-IndirectRealign(false), SRetAfterThis(false), InReg(false),
-CanBeFlattened(false), SignExt(false), SuppressSRet(false) {}
+  : TheKind(K), PaddingInReg(false), InReg(false), SuppressSRet(false) {
+  }
 
-public : ABIArgInfo()
-: ABIArgInfo(Direct) {}
+public:
+  ABIArgInfo()
+  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0),
+TheKind(Direct), PaddingInReg(false), InReg(false),
+SuppressSRet(false) {}
 
   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
   llvm::Type *Padding = nullptr,


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354548 - Fix typo in r354546

2019-02-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Feb 20 22:12:41 2019
New Revision: 354548

URL: http://llvm.org/viewvc/llvm-project?rev=354548=rev
Log:
Fix typo in r354546

Modified:
cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h

Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=354548=354547=354548=diff
==
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original)
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Wed Feb 20 22:12:41 2019
@@ -115,11 +115,9 @@ private:
 PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false),
 IndirectRealign(false), SRetAfterThis(false), InReg(false),
 CanBeFlattened(false), SignExt(false), SuppressSRet(false) {}
-}
 
 public : ABIArgInfo()
-: ABIArgInfo(Direct) {
-}
+: ABIArgInfo(Direct) {}
 
   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
   llvm::Type *Padding = nullptr,


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354546 - [NFC] Always initialize all members in ABIArgInfo

2019-02-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Feb 20 20:55:50 2019
New Revision: 354546

URL: http://llvm.org/viewvc/llvm-project?rev=354546=rev
Log:
[NFC] Always initialize all members in ABIArgInfo

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

Modified:
cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h

Modified: cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h?rev=354546=354545=354546=diff
==
--- cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h (original)
+++ cfe/trunk/include/clang/CodeGen/CGFunctionInfo.h Wed Feb 20 20:55:50 2019
@@ -111,14 +111,15 @@ private:
   }
 
   ABIArgInfo(Kind K)
-  : TheKind(K), PaddingInReg(false), InReg(false), SuppressSRet(false) {
-  }
+  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), TheKind(K),
+PaddingInReg(false), InAllocaSRet(false), IndirectByVal(false),
+IndirectRealign(false), SRetAfterThis(false), InReg(false),
+CanBeFlattened(false), SignExt(false), SuppressSRet(false) {}
+}
 
-public:
-  ABIArgInfo()
-  : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0),
-TheKind(Direct), PaddingInReg(false), InReg(false),
-SuppressSRet(false) {}
+public : ABIArgInfo()
+: ABIArgInfo(Direct) {
+}
 
   static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0,
   llvm::Type *Padding = nullptr,


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r353707 - [tools] Fix python DeprecationWarning: invalid escape sequence

2019-02-11 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Mon Feb 11 07:03:17 2019
New Revision: 353707

URL: http://llvm.org/viewvc/llvm-project?rev=353707=rev
Log:
[tools] Fix python DeprecationWarning: invalid escape sequence

The python documentation says "it’s highly recommended that you use raw strings 
for all but the simplest expressions." 
(https://docs.python.org/3/library/re.html)

So do that with the attached patch generated by

sed -i -e "s/re.search('/re.search(r'/g" $(git grep -l 're.search(')

The warning can be seen in e.g. python3.7:

$ python3.7 -Wd
>>> import re; re.search('\s', '')
:1: DeprecationWarning: invalid escape sequence \s

Commited on behalf of Marco Falke.
Differential Revision: https://reviews.llvm.org/D57528

Modified:
cfe/trunk/tools/clang-format/clang-format-diff.py
cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
cfe/trunk/tools/scan-build/bin/set-xcode-analyzer

Modified: cfe/trunk/tools/clang-format/clang-format-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py?rev=353707=353706=353707=diff
==
--- cfe/trunk/tools/clang-format/clang-format-diff.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-diff.py Mon Feb 11 07:03:17 2019
@@ -66,7 +66,7 @@ def main():
   filename = None
   lines_by_file = {}
   for line in sys.stdin:
-match = re.search('^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
+match = re.search(r'^\+\+\+\ (.*?/){%s}(\S*)' % args.p, line)
 if match:
   filename = match.group(2)
 if filename == None:
@@ -79,7 +79,7 @@ def main():
   if not re.match('^%s$' % args.iregex, filename, re.IGNORECASE):
 continue
 
-match = re.search('^@@.*\+(\d+)(,(\d+))?', line)
+match = re.search(r'^@@.*\+(\d+)(,(\d+))?', line)
 if match:
   start_line = int(match.group(1))
   line_count = 1

Modified: cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py?rev=353707=353706=353707=diff
==
--- cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/analyze.py Mon Feb 11 07:03:17 
2019
@@ -97,7 +97,7 @@ def need_analyzer(args):
 when compiler wrappers are used. That's the moment when build setup
 check the compiler and capture the location for the build process. """
 
-return len(args) and not re.search('configure|autogen', args[0])
+return len(args) and not re.search(r'configure|autogen', args[0])
 
 
 def prefix_with(constant, pieces):

Modified: cfe/trunk/tools/scan-build/bin/set-xcode-analyzer
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/bin/set-xcode-analyzer?rev=353707=353706=353707=diff
==
--- cfe/trunk/tools/scan-build/bin/set-xcode-analyzer (original)
+++ cfe/trunk/tools/scan-build/bin/set-xcode-analyzer Mon Feb 11 07:03:17 2019
@@ -42,7 +42,7 @@ def ModifySpec(path, isBuiltinAnalyzer,
 if line.find("Static Analyzer") >= 0:
   foundAnalyzer = True
   else:
-m = re.search('^(\s*ExecPath\s*=\s*")', line)
+m = re.search(r'^(\s*ExecPath\s*=\s*")', line)
 if m:
   line = "".join([m.group(0), pathToChecker, '";\n'])
   # Do not modify further ExecPath's later in the xcspec.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r352838 - Fix isInSystemMacro to handle pasted macros

2019-02-01 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Thu Jan 31 22:11:44 2019
New Revision: 352838

URL: http://llvm.org/viewvc/llvm-project?rev=352838=rev
Log:
Fix isInSystemMacro to handle pasted macros

Token pasted by the preprocessor (through ##) have a Spelling pointing to 
scratch buffer.
As a result they are not recognized at system macro, even though the pasting 
happened in
a system macro. Fix that by looking into the parent macro if the original 
lookup finds a
scratch buffer.

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

This effectively fixes https://bugs.llvm.org/show_bug.cgi?id=35268,

Added:
cfe/trunk/test/Misc/no-warn-in-system-macro.c
cfe/trunk/test/Misc/no-warn-in-system-macro.c.inc
cfe/trunk/test/Misc/warn-in-system-macro-def.c
cfe/trunk/test/Misc/warn-in-system-macro-def.c.inc
Modified:
cfe/trunk/include/clang/Basic/SourceManager.h

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=352838=352837=352838=diff
==
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Thu Jan 31 22:11:44 2019
@@ -1440,6 +1440,12 @@ public:
 return Filename.equals("");
   }
 
+  /// Returns whether \p Loc is located in a  file.
+  bool isWrittenInScratchSpace(SourceLocation Loc) const {
+StringRef Filename(getPresumedLoc(Loc).getFilename());
+return Filename.equals("");
+  }
+
   /// Returns if a SourceLocation is in a system header.
   bool isInSystemHeader(SourceLocation Loc) const {
 return isSystem(getFileCharacteristic(Loc));
@@ -1452,7 +1458,17 @@ public:
 
   /// Returns whether \p Loc is expanded from a macro in a system header.
   bool isInSystemMacro(SourceLocation loc) const {
-return loc.isMacroID() && isInSystemHeader(getSpellingLoc(loc));
+if(!loc.isMacroID())
+  return false;
+
+// This happens when the macro is the result of a paste, in that case
+// its spelling is the scratch memory, so we take the parent context.
+if (isWrittenInScratchSpace(getSpellingLoc(loc))) {
+  return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));
+}
+else {
+  return isInSystemHeader(getSpellingLoc(loc));
+}
   }
 
   /// The size of the SLocEntry that \p FID represents.

Added: cfe/trunk/test/Misc/no-warn-in-system-macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/no-warn-in-system-macro.c?rev=352838=auto
==
--- cfe/trunk/test/Misc/no-warn-in-system-macro.c (added)
+++ cfe/trunk/test/Misc/no-warn-in-system-macro.c Thu Jan 31 22:11:44 2019
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s  2>&1 | 
FileCheck -allow-empty %s
+// CHECK-NOT: warning:
+
+#include 
+
+int main(void)
+{
+   double foo = 1.0;
+
+   if (isnan(foo))
+   return 1;
+   return 0;
+}

Added: cfe/trunk/test/Misc/no-warn-in-system-macro.c.inc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/no-warn-in-system-macro.c.inc?rev=352838=auto
==
--- cfe/trunk/test/Misc/no-warn-in-system-macro.c.inc (added)
+++ cfe/trunk/test/Misc/no-warn-in-system-macro.c.inc Thu Jan 31 22:11:44 2019
@@ -0,0 +1,9 @@
+extern int __isnanf(float f);
+extern int __isnan(double f);
+extern int __isnanl(long double f);
+#define isnan(x) \
+   (sizeof (x) == sizeof (float)\
+   ? __isnanf (x)\
+   : sizeof (x) == sizeof (double)   \
+   ? __isnan (x) : __isnanl (x))
+

Added: cfe/trunk/test/Misc/warn-in-system-macro-def.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warn-in-system-macro-def.c?rev=352838=auto
==
--- cfe/trunk/test/Misc/warn-in-system-macro-def.c (added)
+++ cfe/trunk/test/Misc/warn-in-system-macro-def.c Thu Jan 31 22:11:44 2019
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s  2>&1 | 
FileCheck -allow-empty %s
+// CHECK: warning:
+// CHECK: expanded from macro 'ISNAN'
+// CHECK: expanded from macro 'isnan'
+
+#include 
+
+#define isnan(x) \
+   (sizeof (x) == sizeof (float)\
+   ? __isnanf (x)\
+   : sizeof (x) == sizeof (double)   \
+   ? __isnan (x) : __isnanl (x))
+
+int main(void)
+{
+   double foo = 1.0;
+
+   if (ISNAN(foo))
+   return 1;
+   return 0;
+}

Added: cfe/trunk/test/Misc/warn-in-system-macro-def.c.inc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warn-in-system-macro-def.c.inc?rev=352838=auto
==
--- 

r352039 - Fix python3 compability issue in clang binding

2019-01-24 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Thu Jan 24 02:34:44 2019
New Revision: 352039

URL: http://llvm.org/viewvc/llvm-project?rev=352039=rev
Log:
Fix python3 compability issue in clang binding

The file contents could be of str type. Should use byte length instead
of str length, otherwise utf-8 encoded files may not get properly parsed
for completion.

Source issue: https://github.com/ncm2/ncm2-pyclang#2

Commited on behalf of `roxma'

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=352039=352038=352039=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Jan 24 02:34:44 2019
@@ -2814,9 +2814,9 @@ class TranslationUnit(ClangObject):
 for i, (name, contents) in enumerate(unsaved_files):
 if hasattr(contents, "read"):
 contents = contents.read()
-
+contents = b(contents)
 unsaved_array[i].name = b(fspath(name))
-unsaved_array[i].contents = b(contents)
+unsaved_array[i].contents = contents
 unsaved_array[i].length = len(contents)
 
 ptr = conf.lib.clang_parseTranslationUnit(index,
@@ -2993,17 +2993,13 @@ class TranslationUnit(ClangObject):
 unsaved_files_array = 0
 if len(unsaved_files):
 unsaved_files_array = (_CXUnsavedFile * len(unsaved_files))()
-for i,(name,value) in enumerate(unsaved_files):
-if not isinstance(value, str):
-# FIXME: It would be great to support an efficient version
-# of this, one day.
-value = value.read()
-print(value)
-if not isinstance(value, str):
-raise TypeError('Unexpected unsaved file contents.')
-unsaved_files_array[i].name = fspath(name)
-unsaved_files_array[i].contents = value
-unsaved_files_array[i].length = len(value)
+for i,(name,contents) in enumerate(unsaved_files):
+if hasattr(contents, "read"):
+contents = contents.read()
+contents = b(contents)
+unsaved_files_array[i].name = b(fspath(name))
+unsaved_files_array[i].contents = contents
+unsaved_files_array[i].length = len(contents)
 ptr = conf.lib.clang_reparseTranslationUnit(self, len(unsaved_files),
 unsaved_files_array, options)
 
@@ -3057,17 +3053,13 @@ class TranslationUnit(ClangObject):
 unsaved_files_array = 0
 if len(unsaved_files):
 unsaved_files_array = (_CXUnsavedFile * len(unsaved_files))()
-for i,(name,value) in enumerate(unsaved_files):
-if not isinstance(value, str):
-# FIXME: It would be great to support an efficient version
-# of this, one day.
-value = value.read()
-print(value)
-if not isinstance(value, str):
-raise TypeError('Unexpected unsaved file contents.')
+for i,(name,contents) in enumerate(unsaved_files):
+if hasattr(contents, "read"):
+contents = contents.read()
+contents = b(contents)
 unsaved_files_array[i].name = b(fspath(name))
-unsaved_files_array[i].contents = b(value)
-unsaved_files_array[i].length = len(value)
+unsaved_files_array[i].contents = contents
+unsaved_files_array[i].length = len(contents)
 ptr = conf.lib.clang_codeCompleteAt(self, fspath(path), line, column,
 unsaved_files_array, len(unsaved_files), options)
 if ptr:


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351706 - Tentative fix for r351701 and gcc 6.2 build on ubuntu

2019-01-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Sun Jan 20 15:43:37 2019
New Revision: 351706

URL: http://llvm.org/viewvc/llvm-project?rev=351706=rev
Log:
Tentative fix for r351701 and gcc 6.2 build on ubuntu

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=351706=351705=351706=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Sun Jan 20 15:43:37 2019
@@ -11731,19 +11731,19 @@ class SequenceChecker : public Evaluated
   };
 
   struct Usage {
-Expr *Use = nullptr;
+Expr *Use;
 SequenceTree::Seq Seq;
 
-Usage() = default;
+Usage() : Use(nullptr), Seq() {}
   };
 
   struct UsageInfo {
 Usage Uses[UK_Count];
 
 /// Have we issued a diagnostic for this variable already?
-bool Diagnosed = false;
+bool Diagnosed;
 
-UsageInfo() = default;
+UsageInfo() : Uses(), Diagnosed(false) {}
   };
   using UsageInfoMap = llvm::SmallDenseMap;
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351701 - Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>

2019-01-20 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Sun Jan 20 13:19:56 2019
New Revision: 351701

URL: http://llvm.org/viewvc/llvm-project?rev=351701=rev
Log:
Replace llvm::isPodLike<...>  by llvm::is_trivially_copyable<...>

As noted in https://bugs.llvm.org/show_bug.cgi?id=36651, the specialization for
isPodLike> did not match the expectation of
std::is_trivially_copyable which makes the memcpy optimization invalid.

This patch renames the llvm::isPodLike trait into llvm::is_trivially_copyable.
Unfortunately std::is_trivially_copyable is not portable across compiler / STL
versions. So a portable version is provided too.

Note that the following specialization were invalid:

std::pair
llvm::Optional

Tests have been added to assert that former specialization are respected by the
standard usage of llvm::is_trivially_copyable, and that when a decent version
of std::is_trivially_copyable is available, llvm::is_trivially_copyable is
compared to std::is_trivially_copyable.

As of this patch, llvm::Optional is no longer considered trivially copyable,
even if T is. This is to be fixed in a later patch, as it has impact on a
long-running bug (see r347004)

Note that GCC warns about this UB, but this got silented by 
https://reviews.llvm.org/D50296.

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


Modified:
cfe/trunk/include/clang/AST/BaseSubobject.h
cfe/trunk/include/clang/AST/CharUnits.h
cfe/trunk/include/clang/AST/DeclAccessPair.h
cfe/trunk/include/clang/AST/DeclarationName.h
cfe/trunk/include/clang/AST/ExprObjC.h
cfe/trunk/include/clang/AST/GlobalDecl.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Analysis/ProgramPoint.h
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/include/clang/Basic/SourceLocation.h
cfe/trunk/include/clang/Lex/Token.h
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/include/clang/Sema/Ownership.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/test/Analysis/llvm-conventions.cpp
cfe/trunk/tools/libclang/Indexing.cpp

Modified: cfe/trunk/include/clang/AST/BaseSubobject.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/BaseSubobject.h?rev=351701=351700=351701=diff
==
--- cfe/trunk/include/clang/AST/BaseSubobject.h (original)
+++ cfe/trunk/include/clang/AST/BaseSubobject.h Sun Jan 20 13:19:56 2019
@@ -80,11 +80,6 @@ template<> struct DenseMapInfo struct isPodLike {
-  static const bool value = true;
-};
-
 } // namespace llvm
 
 #endif // LLVM_CLANG_AST_BASESUBOBJECT_H

Modified: cfe/trunk/include/clang/AST/CharUnits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CharUnits.h?rev=351701=351700=351701=diff
==
--- cfe/trunk/include/clang/AST/CharUnits.h (original)
+++ cfe/trunk/include/clang/AST/CharUnits.h Sun Jan 20 13:19:56 2019
@@ -237,10 +237,6 @@ template<> struct DenseMapInfo struct isPodLike {
-  static const bool value = true;
-};
-
 } // end namespace llvm
 
 #endif // LLVM_CLANG_AST_CHARUNITS_H

Modified: cfe/trunk/include/clang/AST/DeclAccessPair.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclAccessPair.h?rev=351701=351700=351701=diff
==
--- cfe/trunk/include/clang/AST/DeclAccessPair.h (original)
+++ cfe/trunk/include/clang/AST/DeclAccessPair.h Sun Jan 20 13:19:56 2019
@@ -60,12 +60,4 @@ public:
 };
 }
 
-// Take a moment to tell SmallVector that DeclAccessPair is POD.
-namespace llvm {
-template struct isPodLike;
-template<> struct isPodLike {
-   static const bool value = true;
-};
-}
-
 #endif

Modified: cfe/trunk/include/clang/AST/DeclarationName.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclarationName.h?rev=351701=351700=351701=diff
==
--- cfe/trunk/include/clang/AST/DeclarationName.h (original)
+++ cfe/trunk/include/clang/AST/DeclarationName.h Sun Jan 20 13:19:56 2019
@@ -861,9 +861,6 @@ struct DenseMapInfo
-struct isPodLike { static const bool value = true; };
-
 } // namespace llvm
 
 #endif // LLVM_CLANG_AST_DECLARATIONNAME_H

Modified: cfe/trunk/include/clang/AST/ExprObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprObjC.h?rev=351701=351700=351701=diff
==
--- cfe/trunk/include/clang/AST/ExprObjC.h (original)
+++ cfe/trunk/include/clang/AST/ExprObjC.h Sun Jan 20 13:19:56 2019
@@ -255,12 +255,6 @@ struct ObjCDictionaryElement {
 
 } // namespace clang
 
-namespace llvm {
-
-template <> struct isPodLike : 

r350955 - [Bug 39548][Clang] PGO bootstrap fails with python3: errors in perf-helper.py

2019-01-11 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Fri Jan 11 11:04:48 2019
New Revision: 350955

URL: http://llvm.org/viewvc/llvm-project?rev=350955=rev
Log:
[Bug 39548][Clang] PGO bootstrap fails with python3: errors in perf-helper.py

Current clang fail to bootstrap in PGO mode when only python3 is available,
because perf-helper.py is not compatible with python3.

Commited on behalf of  Romain Geissler.

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

Modified:
cfe/trunk/utils/perf-training/perf-helper.py

Modified: cfe/trunk/utils/perf-training/perf-helper.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/perf-helper.py?rev=350955=350954=350955=diff
==
--- cfe/trunk/utils/perf-training/perf-helper.py (original)
+++ cfe/trunk/utils/perf-training/perf-helper.py Fri Jan 11 11:04:48 2019
@@ -114,7 +114,7 @@ def get_cc1_command_for_args(cmd, env):
   # Find the cc1 command used by the compiler. To do this we execute the
   # compiler with '-###' to figure out what it wants to do.
   cmd = cmd + ['-###']
-  cc_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, 
env=env).strip()
+  cc_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env, 
universal_newlines=True).strip()
   cc_commands = []
   for ln in cc_output.split('\n'):
   # Filter out known garbage.
@@ -340,7 +340,7 @@ def genOrderFile(args):
   # If the user gave us a binary, get all the symbols in the binary by
   # snarfing 'nm' output.
   if opts.binary_path is not None:
- output = subprocess.check_output(['nm', '-P', opts.binary_path])
+ output = subprocess.check_output(['nm', '-P', opts.binary_path], 
universal_newlines=True)
  lines = output.split("\n")
  all_symbols = [ln.split(' ',1)[0]
 for ln in lines


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350467 - [python] Make the collections import future-proof

2019-01-05 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Sat Jan  5 04:07:36 2019
New Revision: 350467

URL: http://llvm.org/viewvc/llvm-project?rev=350467=rev
Log:
[python] Make the collections import future-proof

On Python 3.7 the old code raises a warning:

DeprecationWarning: Using or importing the ABCs from 'collections' 
instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
class ArgumentsIterator(collections.Sequence):

On Python 3.8 it wouldn't work anymore.

Commited on behalf of Jakub Stasiak.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=350467=350466=350467=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Sat Jan  5 04:07:36 2019
@@ -64,7 +64,6 @@ from __future__ import absolute_import,
 # o implement additional SourceLocation, SourceRange, and File methods.
 
 from ctypes import *
-import collections
 
 import clang.enumerations
 
@@ -123,6 +122,14 @@ elif sys.version_info[0] == 2:
 def b(x):
 return x
 
+# Importing ABC-s directly from collections is deprecated since Python 3.7,
+# will stop working in Python 3.8.
+# See: https://docs.python.org/dev/whatsnew/3.7.html#id3
+if sys.version_info[:2] >= (3, 7):
+from collections import abc as collections_abc
+else:
+import collections as collections_abc
+
 # We only support PathLike objects on Python version with os.fspath present
 # to be consistent with the Python standard library. On older Python versions
 # we only support strings and we have dummy fspath to just pass them through.
@@ -2181,7 +2188,7 @@ class Type(Structure):
 The returned object is iterable and indexable. Each item in the
 container is a Type instance.
 """
-class ArgumentsIterator(collections.Sequence):
+class ArgumentsIterator(collections_abc.Sequence):
 def __init__(self, parent):
 self.parent = parent
 self.length = None


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350319 - Portable Python script across Python version

2019-01-03 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Thu Jan  3 06:27:05 2019
New Revision: 350319

URL: http://llvm.org/viewvc/llvm-project?rev=350319=rev
Log:
Portable Python script across Python version

Get rid of Python version specific shebang.

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

Modified:
cfe/trunk/utils/check_cfc/check_cfc.py
cfe/trunk/utils/check_cfc/obj_diff.py
cfe/trunk/utils/check_cfc/test_check_cfc.py

Modified: cfe/trunk/utils/check_cfc/check_cfc.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/check_cfc/check_cfc.py?rev=350319=350318=350319=diff
==
--- cfe/trunk/utils/check_cfc/check_cfc.py (original)
+++ cfe/trunk/utils/check_cfc/check_cfc.py Thu Jan  3 06:27:05 2019
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
 
 """Check CFC - Check Compile Flow Consistency
 

Modified: cfe/trunk/utils/check_cfc/obj_diff.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/check_cfc/obj_diff.py?rev=350319=350318=350319=diff
==
--- cfe/trunk/utils/check_cfc/obj_diff.py (original)
+++ cfe/trunk/utils/check_cfc/obj_diff.py Thu Jan  3 06:27:05 2019
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
 
 from __future__ import absolute_import, division, print_function
 

Modified: cfe/trunk/utils/check_cfc/test_check_cfc.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/check_cfc/test_check_cfc.py?rev=350319=350318=350319=diff
==
--- cfe/trunk/utils/check_cfc/test_check_cfc.py (original)
+++ cfe/trunk/utils/check_cfc/test_check_cfc.py Thu Jan  3 06:27:05 2019
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python
 
 """Test internal functions within check_cfc.py."""
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350318 - Portable Python script across Python version

2019-01-03 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Thu Jan  3 06:26:56 2019
New Revision: 350318

URL: http://llvm.org/viewvc/llvm-project?rev=350318=rev
Log:
Portable Python script across Python version

StringIO is obsoleted in Python3, replaced by io.BytesIO or io.StringIO 
depending on the use.

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

Modified:
cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
cfe/trunk/tools/clang-format/clang-format-diff.py
cfe/trunk/tools/scan-view/share/ScanView.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py?rev=350318=350317=350318=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py Thu Jan  3 
06:26:56 2019
@@ -6,6 +6,7 @@ if 'CLANG_LIBRARY_PATH' in os.environ:
 from contextlib import contextmanager
 import gc
 import os
+import sys
 import tempfile
 import unittest
 
@@ -93,10 +94,10 @@ int SOME_DEFINE;
 self.assertEqual(spellings[-1], 'y')
 
 def test_unsaved_files_2(self):
-try:
-from StringIO import StringIO
-except:
+if sys.version_info.major >= 3:
 from io import StringIO
+else:
+from io import BytesIO as StringIO
 tu = TranslationUnit.from_source('fake.c', unsaved_files = [
 ('fake.c', StringIO('int x;'))])
 spellings = [c.spelling for c in tu.cursor.get_children()]

Modified: cfe/trunk/tools/clang-format/clang-format-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py?rev=350318=350317=350318=diff
==
--- cfe/trunk/tools/clang-format/clang-format-diff.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-diff.py Thu Jan  3 06:26:56 2019
@@ -28,10 +28,11 @@ import difflib
 import re
 import subprocess
 import sys
-try:
-  from StringIO import StringIO
-except ImportError:
-   from io import StringIO
+
+if sys.version_info.major >= 3:
+from io import StringIO
+else:
+from io import BytesIO as StringIO
 
 
 def main():

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=350318=350317=350318=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Thu Jan  3 06:26:56 2019
@@ -13,7 +13,12 @@ except ImportError:
 from urllib.parse import urlparse, unquote
 
 import posixpath
-import StringIO
+
+if sys.version_info.major >= 3:
+from io import StringIO, BytesIO
+else:
+from io import BytesIO, BytesIO as StringIO
+
 import re
 import shutil
 import threading
@@ -117,7 +122,7 @@ class ReporterThread(threading.Thread):
 except Reporter.ReportFailure as e:
 self.status = e.value
 except Exception as e:
-s = StringIO.StringIO()
+s = StringIO()
 import traceback
 print('Unhandled Exception', file=s)
 traceback.print_exc(file=s)
@@ -275,7 +280,7 @@ class ScanViewRequestHandler(SimpleHTTPR
 
 def handle_exception(self, exc):
 import traceback
-s = StringIO.StringIO()
+s = StringIO()
 print("INTERNAL ERROR\n", file=s)
 traceback.print_exc(file=s)
 f = self.send_string(s.getvalue(), 'text/plain')
@@ -739,15 +744,16 @@ File Bug
 return f
 
 def send_string(self, s, ctype='text/html', headers=True, mtime=None):
+encoded_s = s.encode()
 if headers:
 self.send_response(200)
 self.send_header("Content-type", ctype)
-self.send_header("Content-Length", str(len(s)))
+self.send_header("Content-Length", str(len(encoded_s)))
 if mtime is None:
 mtime = self.dynamic_mtime
 self.send_header("Last-Modified", self.date_time_string(mtime))
 self.end_headers()
-return StringIO.StringIO(s)
+return BytesIO(encoded_s)
 
 def send_patched_file(self, path, ctype):
 # Allow a very limited set of variables. This is pretty gross.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349627 - Portable Python script across Python version

2018-12-19 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Dec 19 05:46:13 2018
New Revision: 349627

URL: http://llvm.org/viewvc/llvm-project?rev=349627=rev
Log:
Portable Python script across Python version

urllib2 as been renamed into urllib and the library layout has changed.
Workaround that in a consistent manner.

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

Modified:
cfe/trunk/docs/tools/dump_ast_matchers.py
cfe/trunk/docs/tools/dump_format_style.py
cfe/trunk/tools/scan-view/bin/scan-view
cfe/trunk/tools/scan-view/share/ScanView.py

Modified: cfe/trunk/docs/tools/dump_ast_matchers.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_ast_matchers.py?rev=349627=349626=349627=diff
==
--- cfe/trunk/docs/tools/dump_ast_matchers.py (original)
+++ cfe/trunk/docs/tools/dump_ast_matchers.py Wed Dec 19 05:46:13 2018
@@ -5,7 +5,10 @@
 
 import collections
 import re
-import urllib2
+try:
+from urllib.request import urlopen
+except ImportError:
+from urllib2 import urlopen
 
 MATCHERS_FILE = '../../include/clang/ASTMatchers/ASTMatchers.h'
 
@@ -42,7 +45,7 @@ def esc(text):
 if url not in doxygen_probes:
   try:
 print('Probing %s...' % url)
-urllib2.urlopen(url)
+urlopen(url)
 doxygen_probes[url] = True
   except:
 doxygen_probes[url] = False

Modified: cfe/trunk/docs/tools/dump_format_style.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_format_style.py?rev=349627=349626=349627=diff
==
--- cfe/trunk/docs/tools/dump_format_style.py (original)
+++ cfe/trunk/docs/tools/dump_format_style.py Wed Dec 19 05:46:13 2018
@@ -6,7 +6,6 @@
 import collections
 import os
 import re
-import urllib2
 
 CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..')
 FORMAT_STYLE_FILE = os.path.join(CLANG_DIR, 'include/clang/Format/Format.h')

Modified: cfe/trunk/tools/scan-view/bin/scan-view
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/bin/scan-view?rev=349627=349626=349627=diff
==
--- cfe/trunk/tools/scan-view/bin/scan-view (original)
+++ cfe/trunk/tools/scan-view/bin/scan-view Wed Dec 19 05:46:13 2018
@@ -11,7 +11,10 @@ import os
 import posixpath
 import threading
 import time
-import urllib
+try:
+from urllib.request import urlopen
+except ImportError:
+from urllib2 import urlopen
 import webbrowser
 
 # How long to wait for server to start.
@@ -29,7 +32,7 @@ kMaxPortsToTry = 100
 
 def url_is_up(url):
 try:
-o = urllib.urlopen(url)
+o = urlopen(url)
 except IOError:
 return False
 o.close()
@@ -37,7 +40,6 @@ def url_is_up(url):
 
 
 def start_browser(port, options):
-import urllib
 import webbrowser
 
 url = 'http://%s:%d' % (options.host, port)

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=349627=349626=349627=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Wed Dec 19 05:46:13 2018
@@ -6,7 +6,12 @@ except ImportError:
 from SimpleHTTPServer import SimpleHTTPRequestHandler
 import os
 import sys
-import urllib, urlparse
+try:
+from urlparse import urlparse
+from urllib import unquote
+except ImportError:
+from urllib.parse import urlparse, unquote
+
 import posixpath
 import StringIO
 import re
@@ -198,8 +203,8 @@ def parse_query(qs, fields=None):
 value = ''
 else:
 name, value = chunk.split('=', 1)
-name = urllib.unquote(name.replace('+', ' '))
-value = urllib.unquote(value.replace('+', ' '))
+name = unquote(name.replace('+', ' '))
+value = unquote(value.replace('+', ' '))
 item = fields.get(name)
 if item is None:
 fields[name] = [value]
@@ -654,9 +659,9 @@ File Bug
 fields = {}
 self.fields = fields
 
-o = urlparse.urlparse(self.path)
+o = urlparse(self.path)
 self.fields = parse_query(o.query, fields)
-path = posixpath.normpath(urllib.unquote(o.path))
+path = posixpath.normpath(unquote(o.path))
 
 # Split the components and strip the root prefix.
 components = path.split('/')[1:]


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349504 - Portable Python script across Python version

2018-12-18 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Dec 18 08:07:37 2018
New Revision: 349504

URL: http://llvm.org/viewvc/llvm-project?rev=349504=rev
Log:
Portable Python script across Python version

Make scripts more future-proof by importing most __future__ stuff.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/docs/conf.py
cfe/trunk/tools/clang-format/clang-format-diff.py
cfe/trunk/tools/clang-format/clang-format-sublime.py
cfe/trunk/tools/clang-format/clang-format.py
cfe/trunk/tools/clang-format/git-clang-format
cfe/trunk/tools/clang-rename/clang-rename.py
cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
cfe/trunk/utils/ABITest/ABITestGen.py
cfe/trunk/utils/ABITest/Enumeration.py
cfe/trunk/utils/CIndex/completion_logger_server.py
cfe/trunk/utils/TestUtils/deep-stack.py
cfe/trunk/utils/analyzer/SATestAdd.py
cfe/trunk/utils/analyzer/SATestUpdateDiffs.py
cfe/trunk/utils/analyzer/SumTimerInfo.py
cfe/trunk/utils/check_cfc/check_cfc.py
cfe/trunk/utils/check_cfc/obj_diff.py
cfe/trunk/utils/check_cfc/setup.py
cfe/trunk/utils/clangdiag.py
cfe/trunk/utils/hmaptool/hmaptool
cfe/trunk/utils/modfuzz.py
cfe/trunk/utils/perf-training/perf-helper.py
cfe/trunk/utils/token-delta.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=349504=349503=349504=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Tue Dec 18 08:07:37 2018
@@ -44,7 +44,7 @@ The major indexing objects are:
 Most object information is exposed using properties, when the underlying API
 call is efficient.
 """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 # TODO
 # 

Modified: cfe/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/conf.py?rev=349504=349503=349504=diff
==
--- cfe/trunk/docs/conf.py (original)
+++ cfe/trunk/docs/conf.py Tue Dec 18 08:07:37 2018
@@ -11,7 +11,7 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import sys, os
 from datetime import date
 

Modified: cfe/trunk/tools/clang-format/clang-format-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py?rev=349504=349503=349504=diff
==
--- cfe/trunk/tools/clang-format/clang-format-diff.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-diff.py Tue Dec 18 08:07:37 2018
@@ -21,7 +21,7 @@ Example usage for git/svn users:
   svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
 
 """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import argparse
 import difflib

Modified: cfe/trunk/tools/clang-format/clang-format-sublime.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-sublime.py?rev=349504=349503=349504=diff
==
--- cfe/trunk/tools/clang-format/clang-format-sublime.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-sublime.py Tue Dec 18 08:07:37 
2018
@@ -12,7 +12,7 @@
 # It operates on the current, potentially unsaved buffer and does not create
 # or save any files. To revert a formatting, just undo.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import sublime
 import sublime_plugin
 import subprocess

Modified: cfe/trunk/tools/clang-format/clang-format.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=349504=349503=349504=diff
==
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Tue Dec 18 08:07:37 2018
@@ -25,7 +25,7 @@
 #
 # It operates on the current, potentially unsaved buffer and does not create
 # or save any files. To revert a formatting, just undo.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import difflib
 import json

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=349504=349503=349504=diff
==
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ 

r349503 - Portable Python script across Python version

2018-12-18 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Dec 18 08:07:06 2018
New Revision: 349503

URL: http://llvm.org/viewvc/llvm-project?rev=349503=rev
Log:
Portable Python script across Python version

commands.getoutput has been move to subprocess module in Python3

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

Modified:
cfe/trunk/tools/scan-view/share/startfile.py
cfe/trunk/utils/clangdiag.py

Modified: cfe/trunk/tools/scan-view/share/startfile.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/startfile.py?rev=349503=349502=349503=diff
==
--- cfe/trunk/tools/scan-view/share/startfile.py (original)
+++ cfe/trunk/tools/scan-view/share/startfile.py Tue Dec 18 08:07:06 2018
@@ -110,7 +110,10 @@ elif sys.platform == 'darwin':
 # Platform support for Unix
 else:
 
-import commands
+try:
+from commands import getoutput
+except ImportError:
+from subprocess import getoutput
 
 # @WARNING: use the private API of the webbrowser module
 from webbrowser import _iscommand
@@ -125,7 +128,7 @@ else:
 def detect_kde_version(self):
 kde_version = None
 try:
-info = commands.getoutput('kde-config --version')
+info = getoutput('kde-config --version')
 
 for line in info.splitlines():
 if line.startswith('KDE'):
@@ -158,7 +161,7 @@ else:
 desktop_environment = 'gnome'
 else:
 try:
-info = commands.getoutput('xprop -root _DT_SAVE_MODE')
+info = getoutput('xprop -root _DT_SAVE_MODE')
 if ' = "xfce4"' in info:
 desktop_environment = 'xfce'
 except (OSError, RuntimeError):

Modified: cfe/trunk/utils/clangdiag.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clangdiag.py?rev=349503=349502=349503=diff
==
--- cfe/trunk/utils/clangdiag.py (original)
+++ cfe/trunk/utils/clangdiag.py Tue Dec 18 08:07:06 2018
@@ -12,7 +12,6 @@
 from __future__ import print_function
 import lldb
 import argparse
-import commands
 import shlex
 import os
 import re


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349501 - Portable Python script across Python version

2018-12-18 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Dec 18 08:04:21 2018
New Revision: 349501

URL: http://llvm.org/viewvc/llvm-project?rev=349501=rev
Log:
Portable Python script across Python version

In Python3, dict.items, dict.keys, dict.values, zip, map and filter no longer 
return lists, they create generator instead.

The portability patch consists in forcing an extra `list` call if the result is 
actually used as a list.
`map` are replaced by list comprehension and `filter` by filtered list 
comprehension.

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

Modified:
cfe/trunk/bindings/python/examples/cindex/cindex-dump.py
cfe/trunk/tools/scan-view/share/Reporter.py
cfe/trunk/tools/scan-view/share/ScanView.py
cfe/trunk/utils/ABITest/ABITestGen.py
cfe/trunk/utils/ABITest/TypeGen.py
cfe/trunk/utils/analyzer/CmpRuns.py
cfe/trunk/utils/analyzer/SATestBuild.py
cfe/trunk/utils/check_cfc/check_cfc.py
cfe/trunk/utils/check_cfc/obj_diff.py
cfe/trunk/utils/perf-training/perf-helper.py
cfe/trunk/www/builtins.py

Modified: cfe/trunk/bindings/python/examples/cindex/cindex-dump.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/examples/cindex/cindex-dump.py?rev=349501=349500=349501=diff
==
--- cfe/trunk/bindings/python/examples/cindex/cindex-dump.py (original)
+++ cfe/trunk/bindings/python/examples/cindex/cindex-dump.py Tue Dec 18 
08:04:21 2018
@@ -79,7 +79,7 @@ def main():
 if not tu:
 parser.error("unable to load input")
 
-pprint(('diags', map(get_diag_info, tu.diagnostics)))
+pprint(('diags', [get_diag_info(d) for d in  tu.diagnostics]))
 pprint(('nodes', get_info(tu.cursor)))
 
 if __name__ == '__main__':

Modified: cfe/trunk/tools/scan-view/share/Reporter.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/Reporter.py?rev=349501=349500=349501=diff
==
--- cfe/trunk/tools/scan-view/share/Reporter.py (original)
+++ cfe/trunk/tools/scan-view/share/Reporter.py Tue Dec 18 08:04:21 2018
@@ -80,7 +80,7 @@ class EmailReporter(object):
 return 'Email'
 
 def getParameters(self):
-return map(lambda x:TextParameter(x),['To', 'From', 'SMTP Server', 
'SMTP Port'])
+return [TextParameter(x) for x in ['To', 'From', 'SMTP Server', 'SMTP 
Port']]
 
 # Lifted from python email module examples.
 def attachFile(self, outer, path):
@@ -148,7 +148,7 @@ class BugzillaReporter(object):
 return 'Bugzilla'
 
 def getParameters(self):
-return map(lambda x:TextParameter(x),['URL','Product'])
+return [TextParameter(x) for x in ['URL','Product']]
 
 def fileReport(self, report, parameters):
 raise NotImplementedError
@@ -211,7 +211,7 @@ class RadarReporter(object):
 
 script = 
os.path.join(os.path.dirname(__file__),'../share/scan-view/FileRadar.scpt')
 args = ['osascript', script, component, componentVersion, 
classification, personID, report.title,
-report.description, diagnosis, config] + map(os.path.abspath, 
report.files)
+report.description, diagnosis, config] + [os.path.abspath(f) 
for f in report.files]
 #print >>sys.stderr, args
 try:
   p = subprocess.Popen(args, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=349501=349500=349501=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Tue Dec 18 08:04:21 2018
@@ -192,7 +192,7 @@ class ScanViewServer(HTTPServer):
 def parse_query(qs, fields=None):
 if fields is None:
 fields = {}
-for chunk in filter(None, qs.split('&')):
+for chunk in (_f for _f in qs.split('&') if _f):
 if '=' not in chunk:
 name = chunk
 value = ''

Modified: cfe/trunk/utils/ABITest/ABITestGen.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/ABITestGen.py?rev=349501=349500=349501=diff
==
--- cfe/trunk/utils/ABITest/ABITestGen.py (original)
+++ cfe/trunk/utils/ABITest/ABITestGen.py Tue Dec 18 08:04:21 2018
@@ -148,7 +148,7 @@ class TypePrinter(object):
 retvalTests = None
 else:
 retvalTests = self.getTestValuesArray(FT.returnType)
-tests = map(self.getTestValuesArray, FT.argTypes)
+tests = [self.getTestValuesArray(ty) for ty in FT.argTypes]
 print('void test_%s(void) {'%(fnName,), file=self.outputTests)
 
 if retvalTests is not None:
@@ -231,10 +231,10 @@ class TypePrinter(object):
  

r349455 - Portable Python script across Python version

2018-12-18 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Dec 18 00:38:50 2018
New Revision: 349455

URL: http://llvm.org/viewvc/llvm-project?rev=349455=rev
Log:
Portable Python script across Python version

In Python2, division between integer yields an integer, while it yields a float 
in Python3.
Use a combination of from __future__ import division and // operator to get a 
portable behavior.

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

Modified:
cfe/trunk/utils/ABITest/TypeGen.py
cfe/trunk/utils/analyzer/CmpRuns.py

Modified: cfe/trunk/utils/ABITest/TypeGen.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/TypeGen.py?rev=349455=349454=349455=diff
==
--- cfe/trunk/utils/ABITest/TypeGen.py (original)
+++ cfe/trunk/utils/ABITest/TypeGen.py Tue Dec 18 00:38:50 2018
@@ -1,5 +1,5 @@
 """Flexible enumeration of C types."""
-from __future__ import print_function
+from __future__ import division, print_function
 
 from Enumeration import *
 
@@ -235,7 +235,7 @@ def fact(n):
 
 # Compute the number of combinations (n choose k)
 def num_combinations(n, k): 
-return fact(n) / (fact(k) * fact(n - k))
+return fact(n) // (fact(k) * fact(n - k))
 
 # Enumerate the combinations choosing k elements from the list of values
 def combinations(values, k):

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=349455=349454=349455=diff
==
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Tue Dec 18 00:38:50 2018
@@ -25,7 +25,7 @@ Usage:
 diff = compareResults(resultsA, resultsB)
 
 """
-from __future__ import print_function
+from __future__ import division, print_function
 
 from collections import defaultdict
 
@@ -308,7 +308,7 @@ def deriveStats(results):
 "mean": sum(values) / len(values),
 "90th %tile": computePercentile(values, 0.9),
 "95th %tile": computePercentile(values, 0.95),
-"median": sorted(values)[len(values) / 2],
+"median": sorted(values)[len(values) // 2],
 "total": sum(values)
 }
 return combined_stats


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349454 - Portable Python script across Python version

2018-12-18 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Dec 18 00:36:33 2018
New Revision: 349454

URL: http://llvm.org/viewvc/llvm-project?rev=349454=rev
Log:
Portable Python script across Python version

Using from __future__ import print_function it is possible to have a compatible 
behavior of `print(...)` across Python version.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/docs/conf.py
cfe/trunk/docs/tools/dump_ast_matchers.py
cfe/trunk/tools/clang-format/clang-format-diff.py
cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
cfe/trunk/tools/scan-view/bin/scan-view
cfe/trunk/tools/scan-view/share/ScanView.py
cfe/trunk/utils/ABITest/ABITestGen.py
cfe/trunk/utils/ABITest/Enumeration.py
cfe/trunk/utils/ABITest/TypeGen.py
cfe/trunk/utils/CIndex/completion_logger_server.py
cfe/trunk/utils/TestUtils/deep-stack.py
cfe/trunk/utils/analyzer/CmpRuns.py
cfe/trunk/utils/analyzer/SATestAdd.py
cfe/trunk/utils/analyzer/SATestBuild.py
cfe/trunk/utils/analyzer/SATestUpdateDiffs.py
cfe/trunk/utils/analyzer/SumTimerInfo.py
cfe/trunk/utils/check_cfc/setup.py
cfe/trunk/utils/clangdiag.py
cfe/trunk/utils/modfuzz.py
cfe/trunk/utils/token-delta.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=349454=349453=349454=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Tue Dec 18 00:36:33 2018
@@ -44,6 +44,7 @@ The major indexing objects are:
 Most object information is exposed using properties, when the underlying API
 call is efficient.
 """
+from __future__ import print_function
 
 # TODO
 # 

Modified: cfe/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/conf.py?rev=349454=349453=349454=diff
==
--- cfe/trunk/docs/conf.py (original)
+++ cfe/trunk/docs/conf.py Tue Dec 18 00:36:33 2018
@@ -11,6 +11,7 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
+from __future__ import print_function
 import sys, os
 from datetime import date
 
@@ -233,14 +234,14 @@ for name in os.listdir(command_guide_pat
 header = f.readline().rstrip('\n')
 
 if len(header) != len(title):
-print >>sys.stderr, (
+print((
 "error: invalid header in %r (does not match title)" % (
-file_subpath,))
+file_subpath,)), file=sys.stderr)
 if ' - ' not in title:
-print >>sys.stderr, (
+print((
 ("error: invalid title in %r "
  "(expected ' - ')") % (
-file_subpath,))
+file_subpath,)), file=sys.stderr)
 
 # Split the name out of the title.
 name,description = title.split(' - ', 1)

Modified: cfe/trunk/docs/tools/dump_ast_matchers.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_ast_matchers.py?rev=349454=349453=349454=diff
==
--- cfe/trunk/docs/tools/dump_ast_matchers.py (original)
+++ cfe/trunk/docs/tools/dump_ast_matchers.py Tue Dec 18 00:36:33 2018
@@ -41,7 +41,7 @@ def esc(text):
 url = 'https://clang.llvm.org/doxygen/classclang_1_1%s.html' % name
 if url not in doxygen_probes:
   try:
-print 'Probing %s...' % url
+print('Probing %s...' % url)
 urllib2.urlopen(url)
 doxygen_probes[url] = True
   except:
@@ -307,14 +307,14 @@ def act_on_decl(declaration, comment, al
   if not result_types:
 if not comment:
   # Only overloads don't have their own doxygen comments; ignore those.
-  print 'Ignoring "%s"' % name
+  print('Ignoring "%s"' % name)
 else:
-  print 'Cannot determine result type for "%s"' % name
+  print('Cannot determine result type for "%s"' % name)
   else:
 for result_type in result_types:
   add_matcher(result_type, name, args, comment)
 else:
-  print '*** Unparsable: "' + declaration + '" ***'
+  print('*** Unparsable: "' + declaration + '" ***')
 
 def sort_table(matcher_type, matcher_map):
   """Returns the sorted html table for the given row map."""

Modified: cfe/trunk/tools/clang-format/clang-format-diff.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py?rev=349454=349453=349454=diff
==
--- cfe/trunk/tools/clang-format/clang-format-diff.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-diff.py Tue Dec 18 00:36:33 2018
@@ -21,6 +21,7 @@ Example 

r349449 - Portable Python script across Python version

2018-12-18 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Dec 18 00:25:25 2018
New Revision: 349449

URL: http://llvm.org/viewvc/llvm-project?rev=349449=rev
Log:
Portable Python script across Python version

ConfigParser module has been renamed as configparser in Python3

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

Modified:
cfe/trunk/tools/scan-view/share/ScanView.py
cfe/trunk/utils/check_cfc/check_cfc.py

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=349449=349448=349449=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Tue Dec 18 00:25:25 2018
@@ -16,7 +16,10 @@ import socket
 import itertools
 
 import Reporter
-import ConfigParser
+try:
+import configparser
+except ImportError:
+import ConfigParser as configparser
 
 ###
 # Various patterns matched or replaced by server.
@@ -126,7 +129,7 @@ class ScanViewServer(HTTPServer):
 self.load_config()
 
 def load_config(self):
-self.config = ConfigParser.RawConfigParser()
+self.config = configparser.RawConfigParser()
 
 # Add defaults
 self.config.add_section('ScanView')

Modified: cfe/trunk/utils/check_cfc/check_cfc.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/check_cfc/check_cfc.py?rev=349449=349448=349449=diff
==
--- cfe/trunk/utils/check_cfc/check_cfc.py (original)
+++ cfe/trunk/utils/check_cfc/check_cfc.py Tue Dec 18 00:25:25 2018
@@ -56,7 +56,10 @@ import shutil
 import subprocess
 import sys
 import tempfile
-import ConfigParser
+try:
+import configparser
+except ImportError:
+import ConfigParser as configparser
 import io
 
 import obj_diff
@@ -318,7 +321,7 @@ if __name__ == '__main__':
 for c in checks:
 default_config += "{} = false\n".format(c)
 
-config = ConfigParser.RawConfigParser()
+config = configparser.RawConfigParser()
 config.readfp(io.BytesIO(default_config))
 scriptdir = get_main_dir()
 config_path = os.path.join(scriptdir, 'check_cfc.cfg')


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349448 - Portable Python script across Python version

2018-12-18 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Dec 18 00:24:06 2018
New Revision: 349448

URL: http://llvm.org/viewvc/llvm-project?rev=349448=rev
Log:
Portable Python script across Python version

Replace `xrange(...)` by either `range(...)` or `list(range(...))` depending on 
the context.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/utils/ABITest/Enumeration.py
cfe/trunk/utils/ABITest/TypeGen.py
cfe/trunk/utils/modfuzz.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=349448=349447=349448=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Tue Dec 18 00:24:06 2018
@@ -109,8 +109,6 @@ if sys.version_info[0] == 3:
 return x
 return x.encode('utf8')
 
-xrange = range
-
 elif sys.version_info[0] == 2:
 # Python 2 strings are utf8 byte strings, no translation is needed for
 # C-interop.
@@ -556,7 +554,7 @@ class TokenGroup(object):
 
 token_group = TokenGroup(tu, tokens_memory, tokens_count)
 
-for i in xrange(0, count):
+for i in range(0, count):
 token = Token()
 token.int_data = tokens_array[i].int_data
 token.ptr_data = tokens_array[i].ptr_data
@@ -3190,7 +3188,7 @@ class CompileCommand(object):
 Invariant : the first argument is the compiler executable
 """
 length = conf.lib.clang_CompileCommand_getNumArgs(self.cmd)
-for i in xrange(length):
+for i in range(length):
 yield conf.lib.clang_CompileCommand_getArg(self.cmd, i)
 
 class CompileCommands(object):

Modified: cfe/trunk/utils/ABITest/Enumeration.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/Enumeration.py?rev=349448=349447=349448=diff
==
--- cfe/trunk/utils/ABITest/Enumeration.py (original)
+++ cfe/trunk/utils/ABITest/Enumeration.py Tue Dec 18 00:24:06 2018
@@ -199,7 +199,7 @@ def getNthPairVariableBounds(N, bounds):
 raise ValueError("Invalid input (out of bounds)")
 
 level = 0
-active = range(len(bounds))
+active = list(range(len(bounds)))
 active.sort(key=lambda i: bounds[i])
 prevLevel = 0
 for i,index in enumerate(active):

Modified: cfe/trunk/utils/ABITest/TypeGen.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/TypeGen.py?rev=349448=349447=349448=diff
==
--- cfe/trunk/utils/ABITest/TypeGen.py (original)
+++ cfe/trunk/utils/ABITest/TypeGen.py Tue Dec 18 00:24:06 2018
@@ -242,7 +242,7 @@ def combinations(values, k):
 # combinations, selections of a sequence
 if k==0: yield []
 else:
-for i in xrange(len(values)-k+1):
+for i in range(len(values)-k+1):
 for cc in combinations(values[i+1:],k-1):
 yield [values[i]]+cc
 

Modified: cfe/trunk/utils/modfuzz.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/modfuzz.py?rev=349448=349447=349448=diff
==
--- cfe/trunk/utils/modfuzz.py (original)
+++ cfe/trunk/utils/modfuzz.py Tue Dec 18 00:24:06 2018
@@ -106,7 +106,7 @@ def generate():
   try:
 while True:
   assert m, 'got a failure with no steps; broken clang binary?'
-  i = random.choice(range(len(m)))
+  i = random.choice(list(range(len(m
   x = m[0:i] + m[i+1:]
   m2 = CodeModel()
   for d in x:


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349447 - Portable Python script across Python version

2018-12-18 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue Dec 18 00:22:47 2018
New Revision: 349447

URL: http://llvm.org/viewvc/llvm-project?rev=349447=rev
Log:
Portable Python script across Python version

dict no longer have the `has_key` method in Python3. Instead, one can
use the `in` keyword which already works in Python2.

Modified:
cfe/trunk/docs/tools/dump_format_style.py
cfe/trunk/tools/scan-view/share/startfile.py

Modified: cfe/trunk/docs/tools/dump_format_style.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_format_style.py?rev=349447=349446=349447=diff
==
--- cfe/trunk/docs/tools/dump_format_style.py (original)
+++ cfe/trunk/docs/tools/dump_format_style.py Tue Dec 18 00:22:47 2018
@@ -180,9 +180,9 @@ def read_options(header):
'std::vector',
'std::vector',
'std::vector']:
-  if enums.has_key(option.type):
+  if option.type in enums:
 option.enum = enums[option.type]
-  elif nested_structs.has_key(option.type):
+  elif option.type in nested_structs:
 option.nested_struct = nested_structs[option.type]
   else:
 raise Exception('Unknown type: %s' % option.type)

Modified: cfe/trunk/tools/scan-view/share/startfile.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/startfile.py?rev=349447=349446=349447=diff
==
--- cfe/trunk/tools/scan-view/share/startfile.py (original)
+++ cfe/trunk/tools/scan-view/share/startfile.py Tue Dec 18 00:22:47 2018
@@ -189,7 +189,7 @@ else:
 return _controllers[controller_name].open
 
 except KeyError:
-if _controllers.has_key('xdg-open'):
+if 'xdg-open' in _controllers:
 return _controllers['xdg-open'].open
 else:
 return webbrowser.open


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349010 - Portable Python script across Python version

2018-12-12 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Dec 12 23:45:55 2018
New Revision: 349010

URL: http://llvm.org/viewvc/llvm-project?rev=349010=rev
Log:
Portable Python script across Python version

SocketServer has been renamed socketserver in Python3.

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

Modified:
cfe/trunk/tools/scan-view/bin/scan-view

Modified: cfe/trunk/tools/scan-view/bin/scan-view
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/bin/scan-view?rev=349010=349009=349010=diff
==
--- cfe/trunk/tools/scan-view/bin/scan-view (original)
+++ cfe/trunk/tools/scan-view/bin/scan-view Wed Dec 12 23:45:55 2018
@@ -80,9 +80,12 @@ def run(port, options, root):
 
 
 def port_is_open(port):
-import SocketServer
 try:
-t = SocketServer.TCPServer((kDefaultHost, port), None)
+import socketserver
+except ImportError:
+import SocketServer as socketserver
+try:
+t = socketserver.TCPServer((kDefaultHost, port), None)
 except:
 return False
 t.server_close()


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349009 - Portable Python script across Python version

2018-12-12 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Dec 12 23:44:19 2018
New Revision: 349009

URL: http://llvm.org/viewvc/llvm-project?rev=349009=rev
Log:
Portable Python script across Python version

Queue module as been renamed into queue in Python3

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

Modified:
cfe/trunk/utils/analyzer/SATestBuild.py

Modified: cfe/trunk/utils/analyzer/SATestBuild.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestBuild.py?rev=349009=349008=349009=diff
==
--- cfe/trunk/utils/analyzer/SATestBuild.py (original)
+++ cfe/trunk/utils/analyzer/SATestBuild.py Wed Dec 12 23:44:19 2018
@@ -58,7 +58,10 @@ import shutil
 import sys
 import threading
 import time
-import Queue
+try:
+import queue
+except ImportError:
+import Queue as queue
 
 ###
 # Helper functions.
@@ -742,7 +745,7 @@ def multiThreadedTestAll(Args, ProjectsT
 
 :return: whether tests have passed.
 """
-TasksQueue = Queue.Queue()
+TasksQueue = queue.Queue()
 
 for ProjArgs in ProjectsToTest:
 TasksQueue.put(ProjArgs)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r349008 - Portable Python script across Python version

2018-12-12 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed Dec 12 23:42:30 2018
New Revision: 349008

URL: http://llvm.org/viewvc/llvm-project?rev=349008=rev
Log:
Portable Python script across Python version

Use higher-level and more compatible threading module to start a new thread.

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

Modified:
cfe/trunk/tools/scan-view/bin/scan-view

Modified: cfe/trunk/tools/scan-view/bin/scan-view
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/bin/scan-view?rev=349008=349007=349008=diff
==
--- cfe/trunk/tools/scan-view/bin/scan-view (original)
+++ cfe/trunk/tools/scan-view/bin/scan-view Wed Dec 12 23:42:30 2018
@@ -7,7 +7,7 @@ import sys
 import imp
 import os
 import posixpath
-import thread
+import threading
 import time
 import urllib
 import webbrowser
@@ -135,7 +135,7 @@ def main():
 # Kick off thread to wait for server and start web browser, if
 # requested.
 if args.startBrowser:
-t = thread.start_new_thread(start_browser, (port, args))
+threading.Thread(target=start_browser, args=(port, args)).start()
 
 run(port, args, args.root)
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348184 - Portable Python script across Python version

2018-12-03 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Mon Dec  3 12:26:51 2018
New Revision: 348184

URL: http://llvm.org/viewvc/llvm-project?rev=348184=rev
Log:
Portable Python script across Python version

Workaround naming and hierarchy changes in BaseHTTPServer and SimpleHTTPServer 
module.

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

Modified:
cfe/trunk/tools/scan-view/share/ScanView.py

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=348184=348183=348184=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Mon Dec  3 12:26:51 2018
@@ -1,5 +1,8 @@
-import BaseHTTPServer
-import SimpleHTTPServer
+try:
+from http.server import HTTPServer, SimpleHTTPRequestHandler
+except ImportError:
+from BaseHTTPServer import HTTPServer
+from SimpleHTTPServer import SimpleHTTPRequestHandler
 import os
 import sys
 import urllib, urlparse
@@ -112,9 +115,9 @@ class ReporterThread(threading.Thread):
 print >>s,''
 self.status = s.getvalue()
 
-class ScanViewServer(BaseHTTPServer.HTTPServer):
+class ScanViewServer(HTTPServer):
 def __init__(self, address, handler, root, reporters, options):
-BaseHTTPServer.HTTPServer.__init__(self, address, handler)
+HTTPServer.__init__(self, address, handler)
 self.root = root
 self.reporters = reporters
 self.options = options
@@ -170,7 +173,7 @@ class ScanViewServer(BaseHTTPServer.HTTP
 if self.options.autoReload:
 import ScanView
 self.RequestHandlerClass = reload(ScanView).ScanViewRequestHandler
-BaseHTTPServer.HTTPServer.finish_request(self, request, client_address)
+HTTPServer.finish_request(self, request, client_address)
 
 def handle_error(self, request, client_address):
 # Ignore socket errors
@@ -179,7 +182,7 @@ class ScanViewServer(BaseHTTPServer.HTTP
 if self.options.debug > 1:
 print >>sys.stderr, "%s: SERVER: ignored socket error." % 
(sys.argv[0],)
 return
-BaseHTTPServer.HTTPServer.handle_error(self, request, client_address)
+HTTPServer.handle_error(self, request, client_address)
 
 # Borrowed from Quixote, with simplifications.
 def parse_query(qs, fields=None):
@@ -200,19 +203,19 @@ def parse_query(qs, fields=None):
 item.append(value)
 return fields
 
-class ScanViewRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+class ScanViewRequestHandler(SimpleHTTPRequestHandler):
 server_version = "ScanViewServer/" + __version__
 dynamic_mtime = time.time()
 
 def do_HEAD(self):
 try:
-SimpleHTTPServer.SimpleHTTPRequestHandler.do_HEAD(self)
+SimpleHTTPRequestHandler.do_HEAD(self)
 except Exception as e:
 self.handle_exception(e)
 
 def do_GET(self):
 try:
-SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+SimpleHTTPRequestHandler.do_GET(self)
 except Exception as e:
 self.handle_exception(e)
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348182 - Portable Python script across Python version

2018-12-03 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Mon Dec  3 12:12:34 2018
New Revision: 348182

URL: http://llvm.org/viewvc/llvm-project?rev=348182=rev
Log:
Portable Python script across Python version

Python2 supports both backticks and `repr` to access the __repr__ slot. Python3 
only supports `repr`.

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

Modified:
cfe/trunk/tools/scan-view/share/ScanView.py

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=348182=348181=348182=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Mon Dec  3 12:12:34 2018
@@ -544,7 +544,7 @@ Line: %s
 """%(r.getName(),display,r.getName(),options))
 reporterSelections = '\n'.join(reporterSelections)
 reporterOptionsDivs = '\n'.join(reporterOptions)
-reportersArray = '[%s]'%(','.join([`r.getName()` for r in 
self.server.reporters]))
+reportersArray = '[%s]'%(','.join([repr(r.getName()) for r in 
self.server.reporters]))
 
 if c.files:
 fieldSize = min(5, len(c.files))


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348129 - Portable Python script across Python version

2018-12-03 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Mon Dec  3 04:41:35 2018
New Revision: 348129

URL: http://llvm.org/viewvc/llvm-project?rev=348129=rev
Log:
Portable Python script across Python version

Python3 does not support type destructuring in function parameters.

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

Modified:
cfe/trunk/utils/ABITest/Enumeration.py
cfe/trunk/utils/ABITest/TypeGen.py

Modified: cfe/trunk/utils/ABITest/Enumeration.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/Enumeration.py?rev=348129=348128=348129=diff
==
--- cfe/trunk/utils/ABITest/Enumeration.py (original)
+++ cfe/trunk/utils/ABITest/Enumeration.py Mon Dec  3 04:41:35 2018
@@ -46,7 +46,8 @@ aleph0 = Aleph0()
 def base(line):
 return line*(line+1)//2
 
-def pairToN((x,y)):
+def pairToN(pair):
+x,y = pair
 line,index = x+y,y
 return base(line)+index
 

Modified: cfe/trunk/utils/ABITest/TypeGen.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/TypeGen.py?rev=348129=348128=348129=diff
==
--- cfe/trunk/utils/ABITest/TypeGen.py (original)
+++ cfe/trunk/utils/ABITest/TypeGen.py Mon Dec  3 04:41:35 2018
@@ -99,7 +99,8 @@ class RecordType(Type):
 ' '.join(map(getField, self.fields)))
 
 def getTypedefDef(self, name, printer):
-def getField((i, t)):
+def getField(it):
+i, t = it
 if t.isBitField():
 if t.isPaddingBitField():
 return '%s : 0;'%(printer.getTypeName(t),)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r348127 - Portable Python script across version

2018-12-03 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Mon Dec  3 04:12:48 2018
New Revision: 348127

URL: http://llvm.org/viewvc/llvm-project?rev=348127=rev
Log:
Portable Python script across version

Have all classes derive from object: that's implicitly the default in Python3,
it needs to be done explicilty in Python2.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/docs/tools/dump_format_style.py
cfe/trunk/tools/scan-view/share/Reporter.py
cfe/trunk/tools/scan-view/share/ScanView.py
cfe/trunk/utils/ABITest/ABITestGen.py
cfe/trunk/utils/ABITest/TypeGen.py
cfe/trunk/utils/analyzer/CmpRuns.py
cfe/trunk/utils/modfuzz.py
cfe/trunk/utils/token-delta.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=348127=348126=348127=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Dec  3 04:12:48 2018
@@ -400,7 +400,7 @@ class Diagnostic(object):
 
 @property
 def ranges(self):
-class RangeIterator:
+class RangeIterator(object):
 def __init__(self, diag):
 self.diag = diag
 
@@ -416,7 +416,7 @@ class Diagnostic(object):
 
 @property
 def fixits(self):
-class FixItIterator:
+class FixItIterator(object):
 def __init__(self, diag):
 self.diag = diag
 
@@ -436,7 +436,7 @@ class Diagnostic(object):
 
 @property
 def children(self):
-class ChildDiagnosticsIterator:
+class ChildDiagnosticsIterator(object):
 def __init__(self, diag):
 self.diag_set = conf.lib.clang_getChildDiagnostics(diag)
 
@@ -2475,8 +2475,8 @@ SpellingCache = {
 # 20: CompletionChunk.Kind("VerticalSpace")
 }
 
-class CompletionChunk:
-class Kind:
+class CompletionChunk(object):
+class Kind(object):
 def __init__(self, name):
 self.name = name
 
@@ -2563,7 +2563,7 @@ completionChunkKindMap = {
 20: CompletionChunk.Kind("VerticalSpace")}
 
 class CompletionString(ClangObject):
-class Availability:
+class Availability(object):
 def __init__(self, name):
 self.name = name
 
@@ -2656,7 +2656,7 @@ class CodeCompletionResults(ClangObject)
 
 @property
 def diagnostics(self):
-class DiagnosticsItr:
+class DiagnosticsItr(object):
 def __init__(self, ccr):
 self.ccr= ccr
 
@@ -2958,7 +2958,7 @@ class TranslationUnit(ClangObject):
 """
 Return an iterable (and indexable) object containing the diagnostics.
 """
-class DiagIterator:
+class DiagIterator(object):
 def __init__(self, tu):
 self.tu = tu
 
@@ -4090,7 +4090,7 @@ def register_functions(lib, ignore_error
 for f in functionList:
 register(f)
 
-class Config:
+class Config(object):
 library_path = None
 library_file = None
 compatibility_check = True

Modified: cfe/trunk/docs/tools/dump_format_style.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_format_style.py?rev=348127=348126=348127=diff
==
--- cfe/trunk/docs/tools/dump_format_style.py (original)
+++ cfe/trunk/docs/tools/dump_format_style.py Mon Dec  3 04:12:48 2018
@@ -32,7 +32,7 @@ def indent(text, columns, indent_first_l
 return s
   return indent + s
 
-class Option:
+class Option(object):
   def __init__(self, name, type, comment):
 self.name = name
 self.type = type
@@ -50,7 +50,7 @@ class Option:
   2)
 return s
 
-class NestedStruct:
+class NestedStruct(object):
   def __init__(self, name, comment):
 self.name = name
 self.comment = comment.strip()
@@ -59,7 +59,7 @@ class NestedStruct:
   def __str__(self):
 return '\n'.join(map(str, self.values))
 
-class NestedField:
+class NestedField(object):
   def __init__(self, name, comment):
 self.name = name
 self.comment = comment.strip()
@@ -69,7 +69,7 @@ class NestedField:
 self.name,
 doxygen2rst(indent(self.comment, 2, indent_first_line=False)))
 
-class Enum:
+class Enum(object):
   def __init__(self, name, comment):
 self.name = name
 self.comment = comment.strip()
@@ -78,7 +78,7 @@ class Enum:
   def __str__(self):
 return '\n'.join(map(str, self.values))
 
-class EnumValue:
+class EnumValue(object):
   def __init__(self, name, comment):
 self.name = name
 self.comment = comment
@@ -101,7 +101,7 @@ def clean_comment_line(line):
   return line[4:] + '\n'
 
 def read_options(header):
-  class State:
+  class State(object):
 BeforeStruct, Finished, InStruct, InNestedStruct, InNestedFieldComent, \
 InFieldComment, InEnum, 

r348126 - Portable Python script across Python version

2018-12-03 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Mon Dec  3 04:11:21 2018
New Revision: 348126

URL: http://llvm.org/viewvc/llvm-project?rev=348126=rev
Log:
Portable Python script across Python version

Python2 supports the two following equivalent construct

raise ExceptionType, exception_value
and
raise ExceptionType(exception_value)

Only the later is supported by Python3.

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

Modified:
cfe/trunk/tools/scan-view/share/ScanView.py
cfe/trunk/utils/ABITest/ABITestGen.py
cfe/trunk/utils/ABITest/Enumeration.py
cfe/trunk/utils/ABITest/TypeGen.py
cfe/trunk/utils/analyzer/SATestBuild.py
cfe/trunk/utils/token-delta.py

Modified: cfe/trunk/tools/scan-view/share/ScanView.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-view/share/ScanView.py?rev=348126=348125=348126=diff
==
--- cfe/trunk/tools/scan-view/share/ScanView.py (original)
+++ cfe/trunk/tools/scan-view/share/ScanView.py Mon Dec  3 04:11:21 2018
@@ -102,9 +102,9 @@ class ReporterThread(threading.Thread):
 time.sleep(3)
 if self.server.options.debug:
 print >>sys.stderr, "%s: SERVER: submission 
complete."%(sys.argv[0],)
-except Reporter.ReportFailure,e:
+except Reporter.ReportFailure as e:
 self.status = e.value
-except Exception,e:
+except Exception as e:
 s = StringIO.StringIO()
 import traceback
 print >>s,'Unhandled Exception'
@@ -163,7 +163,7 @@ class ScanViewServer(BaseHTTPServer.HTTP
 print >>sys.stderr, "%s: SERVER: waiting..." % (sys.argv[0],)
 try:
 self.handle_request()
-except OSError,e:
+except OSError as e:
 print 'OSError',e.errno
 
 def finish_request(self, request, client_address):
@@ -207,13 +207,13 @@ class ScanViewRequestHandler(SimpleHTTPS
 def do_HEAD(self):
 try:
 SimpleHTTPServer.SimpleHTTPRequestHandler.do_HEAD(self)
-except Exception,e:
+except Exception as e:
 self.handle_exception(e)
 
 def do_GET(self):
 try:
 SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
-except Exception,e:
+except Exception as e:
 self.handle_exception(e)
 
 def do_POST(self):
@@ -230,7 +230,7 @@ class ScanViewRequestHandler(SimpleHTTPS
 if f:
 self.copyfile(f, self.wfile)
 f.close()
-except Exception,e:
+except Exception as e:
 self.handle_exception(e)
 
 def log_message(self, format, *args):
@@ -428,7 +428,7 @@ Submit
 data = self.load_crashes()
 # Don't allow empty reports.
 if not data:
-raise ValueError, 'No crashes detected!'
+raise ValueError('No crashes detected!')
 c = Context()
 c.title = 'clang static analyzer failures'
 
@@ -472,7 +472,7 @@ STDERR Summary
 # Check that this is a valid report.
 path = posixpath.join(self.server.root, 'report-%s.html' % report)
 if not posixpath.exists(path):
-raise ValueError, 'Invalid report ID'
+raise ValueError('Invalid report ID')
 keys = self.load_report(report)
 c = Context()
 c.title = keys.get('DESC','clang error (unrecognized')
@@ -501,7 +501,7 @@ Line: %s
 # report is None is used for crashes
 try:
 c = self.get_report_context(report)
-except ValueError, e:
+except ValueError as e:
 return self.send_error(400, e.message)
 
 title = c.title

Modified: cfe/trunk/utils/ABITest/ABITestGen.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/ABITestGen.py?rev=348126=348125=348126=diff
==
--- cfe/trunk/utils/ABITest/ABITestGen.py (original)
+++ cfe/trunk/utils/ABITest/ABITestGen.py Mon Dec  3 04:11:21 2018
@@ -250,7 +250,7 @@ class TypePrinter:
 elements[i] = v
 yield '{ %s }'%(', '.join(elements))
 else:
-raise NotImplementedError,'Cannot make tests values of type: 
"%s"'%(t,)
+raise NotImplementedError('Cannot make tests values of type: 
"%s"'%(t,))
 
 def printSizeOfType(self, prefix, name, t, output=None, indent=2):
 print >>output, '%*sprintf("%s: sizeof(%s) = %%ld\\n", 
(long)sizeof(%s));'%(indent, '', prefix, name, name) 
@@ -310,7 +310,7 @@ class TypePrinter:
 else:
 self.printValueOfType(prefix, '%s[%d]'%(name,i), 
t.elementType, output=output,indent=indent)
 else:
-raise 

r302654 - Use clang++-3.5 compatible initializer_list constructor

2017-05-10 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Wed May 10 08:22:11 2017
New Revision: 302654

URL: http://llvm.org/viewvc/llvm-project?rev=302654=rev
Log:
Use clang++-3.5 compatible initializer_list constructor

Otherwise, a warning is issued.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h?rev=302654=302653=302654=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h Wed May 10 08:22:11 
2017
@@ -20,7 +20,7 @@ static inline Selector getKeywordSelecto
   IdentifierInfos *... IIs) {
   static_assert(sizeof...(IdentifierInfos),
 "keyword selectors must have at least one argument");
-  SmallVector II{{(IIs)...}};
+  SmallVector II({(IIs)...});
 
   return Ctx.Selectors.getSelector(II.size(), [0]);
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302588 - Fix CGObjCGNU::init bug introduced by r302572

2017-05-09 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue May  9 16:19:44 2017
New Revision: 302588

URL: http://llvm.org/viewvc/llvm-project?rev=302588=rev
Log:
Fix CGObjCGNU::init bug introduced by r302572

Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=302588=302587=302588=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Tue May  9 16:19:44 2017
@@ -63,8 +63,13 @@ public:
 CGM = Mod;
 FunctionName = name;
 Function = nullptr;
-std::vector ArgTys{{Types...}};
-FTy = llvm::FunctionType::get(RetTy, ArgTys, false);
+if(sizeof...(Tys)) {
+  SmallVector ArgTys({Types...});
+  FTy = llvm::FunctionType::get(RetTy, ArgTys, false);
+}
+else {
+  FTy = llvm::FunctionType::get(RetTy, None, false);
+}
   }
 
   llvm::FunctionType *getType() { return FTy; }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302572 - Suppress all uses of LLVM_END_WITH_NULL. NFC.

2017-05-09 Thread Serge Guelton via cfe-commits
Author: serge_sans_paille
Date: Tue May  9 14:31:30 2017
New Revision: 302572

URL: http://llvm.org/viewvc/llvm-project?rev=302572=rev
Log:
Suppress all uses of LLVM_END_WITH_NULL. NFC.

Use variadic templates instead of relying on  + sentinel.

This enforces better type checking and makes code more readable.

Differential revision: https://reviews.llvm.org/D32550

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/CodeGen/CGCleanup.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NoReturnFunctionChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/SelectorExtras.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=302572=302571=302572=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue May  9 14:31:30 2017
@@ -961,9 +961,8 @@ llvm::Type *CodeGenModule::getBlockDescr
   //   const char *signature;   // the block signature
   //   const char *layout;  // reserved
   // };
-  BlockDescriptorType =
-llvm::StructType::create("struct.__block_descriptor",
- UnsignedLongTy, UnsignedLongTy, nullptr);
+  BlockDescriptorType = llvm::StructType::create(
+  "struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
 
   // Now form a pointer to that.
   unsigned AddrSpace = 0;
@@ -987,9 +986,8 @@ llvm::Type *CodeGenModule::getGenericBlo
   //   struct __block_descriptor *__descriptor;
   // };
   GenericBlockLiteralType =
-llvm::StructType::create("struct.__block_literal_generic",
- VoidPtrTy, IntTy, IntTy, VoidPtrTy,
- BlockDescPtrTy, nullptr);
+  llvm::StructType::create("struct.__block_literal_generic", VoidPtrTy,
+   IntTy, IntTy, VoidPtrTy, BlockDescPtrTy);
 
   return GenericBlockLiteralType;
 }

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=302572=302571=302572=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May  9 14:31:30 2017
@@ -4571,7 +4571,7 @@ Value *CodeGenFunction::EmitARMBuiltinEx
 Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_stlex
? Intrinsic::arm_stlexd
: Intrinsic::arm_strexd);
-llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 Value *Val = EmitScalarExpr(E->getArg(0));
@@ -5401,7 +5401,7 @@ Value *CodeGenFunction::EmitAArch64Built
 Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_stlex
? Intrinsic::aarch64_stlxp
: Intrinsic::aarch64_stxp);
-llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty, nullptr);
+llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty);
 
 Address Tmp = CreateMemTemp(E->getArg(0)->getType());
 EmitAnyExprToMem(E->getArg(0), Tmp, Qualifiers(), /*init*/ true);
@@ -7373,8 +7373,8 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 // unsigned int __cpu_type;
 // unsigned int __cpu_subtype;
 // unsigned int __cpu_features[1];
-llvm::Type *STy = llvm::StructType::get(
-Int32Ty, Int32Ty, Int32Ty, llvm::ArrayType::get(Int32Ty, 1), nullptr);
+llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, Int32Ty,
+llvm::ArrayType::get(Int32Ty, 1));
 
 // Grab the global __cpu_model.
 llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=302572=302571=302572=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Tue May  9 14:31:30 2017
@@ -265,7 +265,7 @@ llvm::Function *CGNVCUDARuntime::makeMod