]> granicus.if.org Git - clang/log
clang
5 years ago[clang] DirectoryWatcher
Jan Korous [Tue, 9 Jul 2019 22:44:48 +0000 (22:44 +0000)]
[clang] DirectoryWatcher

Asynchronously monitors specified directory for changes and passes notifications to provided callback.

Dependency for index-while-building.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365574 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoXFAIL clang/test/Headers/max_align.c on i686
Andus Yu [Tue, 9 Jul 2019 21:06:34 +0000 (21:06 +0000)]
XFAIL clang/test/Headers/max_align.c on i686

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365558 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoUse the Itanium C++ ABI for the pipe_builtin.cl test
Reid Kleckner [Tue, 9 Jul 2019 21:02:06 +0000 (21:02 +0000)]
Use the Itanium C++ ABI for the pipe_builtin.cl test

Certain OpenCL constructs cannot yet be mangled in the MS C++ ABI.
Add a FIXME for it if anyone cares to implement it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365557 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoDe-templatize non-dependent VS macro logic, NFC
Reid Kleckner [Tue, 9 Jul 2019 20:57:28 +0000 (20:57 +0000)]
De-templatize non-dependent VS macro logic, NFC

These macro definitions don't depend on the template parameter, so they
don't need to be part of the template. Move them to a .cpp file.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365556 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CXX] Exercise all paths through these tests.
Paul Robinson [Tue, 9 Jul 2019 20:49:07 +0000 (20:49 +0000)]
[CXX] Exercise all paths through these tests.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365555 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agohwasan: Improve precision of checks using short granule tags.
Peter Collingbourne [Tue, 9 Jul 2019 20:22:36 +0000 (20:22 +0000)]
hwasan: Improve precision of checks using short granule tags.

A short granule is a granule of size between 1 and `TG-1` bytes. The size
of a short granule is stored at the location in shadow memory where the
granule's tag is normally stored, while the granule's actual tag is stored
in the last byte of the granule. This means that in order to verify that a
pointer tag matches a memory tag, HWASAN must check for two possibilities:

* the pointer tag is equal to the memory tag in shadow memory, or
* the shadow memory tag is actually a short granule size, the value being loaded
  is in bounds of the granule and the pointer tag is equal to the last byte of
  the granule.

Pointer tags between 1 to `TG-1` are possible and are as likely as any other
tag. This means that these tags in memory have two interpretations: the full
tag interpretation (where the pointer tag is between 1 and `TG-1` and the
last byte of the granule is ordinary data) and the short tag interpretation
(where the pointer tag is stored in the granule).

When HWASAN detects an error near a memory tag between 1 and `TG-1`, it
will show both the memory tag and the last byte of the granule. Currently,
it is up to the user to disambiguate the two possibilities.

Because this functionality obsoletes the right aligned heap feature of
the HWASAN memory allocator (and because we can no longer easily test
it), the feature is removed.

Also update the documentation to cover both short granule tags and
outlined checks.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365551 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenMP] Simplify getFloatTypeSemantics
Fangrui Song [Tue, 9 Jul 2019 19:36:22 +0000 (19:36 +0000)]
[OpenMP] Simplify getFloatTypeSemantics

When the float point representations are the same on the host and on the target device,
(`&Target->getLongDoubleFormat() == &AuxTarget->getLongDoubleFormat()`),
we can just use `AuxTarget->getLongDoubleFormat()`.

Reviewed By: ABataev

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365545 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AMDGPU] gfx908 clang target
Stanislav Mekhanoshin [Tue, 9 Jul 2019 18:19:00 +0000 (18:19 +0000)]
[AMDGPU] gfx908 clang target

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365528 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ObjC] Add a warning for implicit conversions of a constant non-boolean value to...
Erik Pilkington [Tue, 9 Jul 2019 17:29:40 +0000 (17:29 +0000)]
[ObjC] Add a warning for implicit conversions of a constant non-boolean value to BOOL

rdar://51954400

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365518 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert Revert Devirtualize destructor of final class.
Hiroshi Yamauchi [Tue, 9 Jul 2019 15:57:29 +0000 (15:57 +0000)]
Revert Revert Devirtualize destructor of final class.

Revert r364359 and recommit r364100.

r364100 was reverted as r364359 due to an internal test failure, but it was a
false alarm.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365509 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL][Sema] Improve address space support for blocks
Marco Antognini [Tue, 9 Jul 2019 15:04:27 +0000 (15:04 +0000)]
[OpenCL][Sema] Improve address space support for blocks

Summary:
This patch ensures that the following code is compiled identically with
-cl-std=CL2.0 and -fblocks -cl-std=c++.

    kernel void test(void) {
      void (^const block_A)(void) = ^{
        return;
      };
    }

A new test is not added because cl20-device-side-enqueue.cl will cover
this once blocks are further improved for C++ for OpenCL.

The changes to Sema::PerformImplicitConversion are based on
the parts of Sema::CheckAssignmentConstraints on block pointer
conversions.

Reviewers: rjmccall, Anastasia

Subscribers: yaxunl, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365500 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OpenCL][Sema] Fix builtin rewriting
Marco Antognini [Tue, 9 Jul 2019 15:04:23 +0000 (15:04 +0000)]
[OpenCL][Sema] Fix builtin rewriting

This patch ensures built-in functions are rewritten using the proper
parent declaration.

Existing tests are modified to run in C++ mode to ensure the
functionality works also with C++ for OpenCL while not increasing the
testing runtime.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365499 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoIgnore trailing NullStmts in StmtExprs for GCC compatibility.
Aaron Ballman [Tue, 9 Jul 2019 15:02:07 +0000 (15:02 +0000)]
Ignore trailing NullStmts in StmtExprs for GCC compatibility.

Ignore trailing NullStmts in compound expressions when determining the result type and value. This is to match the GCC behavior which ignores semicolons at the end of compound expressions.

Patch by Dominic Ferreira.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365498 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[libclang] Fix hang in release / assertion in debug when evaluating value-dependent...
Emilio Cobos Alvarez [Tue, 9 Jul 2019 14:27:01 +0000 (14:27 +0000)]
[libclang] Fix hang in release / assertion in debug when evaluating value-dependent types.

Expression evaluator doesn't work in value-dependent types, so ensure that the
precondition it asserts holds.

This fixes https://bugs.llvm.org/show_bug.cgi?id=42532

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365490 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Fix the float point semantics handling on the device.
Alexey Bataev [Tue, 9 Jul 2019 14:09:53 +0000 (14:09 +0000)]
[OPENMP]Fix the float point semantics handling on the device.

The device should use the same float point representation as the host.
Previous patch fixed the handling of the sizes of the float point types,
but did not fixed the fp semantics. This patch makes target device to
use the host fp semantics. this is required for the correct data
transfer between host and device and correct codegen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365485 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ItaniumMangle] Refactor long double/__float128 mangling and fix the mangled code
Fangrui Song [Tue, 9 Jul 2019 13:32:26 +0000 (13:32 +0000)]
[ItaniumMangle] Refactor long double/__float128 mangling and fix the mangled code

In gcc PowerPC, long double has 3 mangling schemes:

-mlong-double-64: `e`
-mlong-double-128 -mabi=ibmlongdouble: `g`
-mlong-double-128 -mabi=ieeelongdouble: `u9__ieee128` (gcc <= 8.1: `U10__float128`)

The current useFloat128ManglingForLongDouble() bisection is not suitable
when we support -mlong-double-128 in clang (D64277). Replace
useFloat128ManglingForLongDouble() with getLongDoubleMangling() and
getFloat128Mangling() to allow 3 mangling schemes.

I also deleted the `getTriple().isOSBinFormatELF()` check (the Darwin
support has gone: https://reviews.llvm.org/D50988).

For x86, change the mangled code of __float128 from `U10__float128` to `g`. `U10__float128` was wrongly copied from PowerPC.
The test will be added to `test/CodeGen/x86-long-double.cpp` in D64277.

Reviewed By: erichkeane

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365480 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Syntax] Move roles into a separate enum
Ilya Biryukov [Tue, 9 Jul 2019 13:31:43 +0000 (13:31 +0000)]
[Syntax] Move roles into a separate enum

To align with reviewer's suggestions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365479 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] [X86] Fix scan-build complaining
Pengfei Wang [Tue, 9 Jul 2019 12:41:12 +0000 (12:41 +0000)]
[NFC] [X86] Fix scan-build complaining

Summary:
Remove unused variable. This fixes bug:
https://bugs.llvm.org/show_bug.cgi?id=42526

Signed-off-by: pengfei <pengfei.wang@intel.com>
Reviewers: RKSimon, xiangzhangllvm, craig.topper

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365473 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReland r365355: [Syntax] Introduce syntax trees
Ilya Biryukov [Tue, 9 Jul 2019 11:32:13 +0000 (11:32 +0000)]
Reland r365355: [Syntax] Introduce syntax trees

With a fix to a PS4 buildbot crash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365466 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert rL365355 : [Syntax] Introduce syntax trees
Simon Pilgrim [Tue, 9 Jul 2019 11:26:35 +0000 (11:26 +0000)]
Revert rL365355 : [Syntax] Introduce syntax trees

Summary:
A tooling-focused alternative to the AST. This commit focuses on the
memory-management strategy and the structure of the AST.

More to follow later:
  - Operations to mutate the syntax trees and corresponding textual
    replacements.
  - Mapping between clang AST nodes and syntax tree nodes.
  - More node types corresponding to the language constructs.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: llvm-commits, mgorny, cfe-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D61637
........
Fixes buildbots which were crashing on SyntaxTests.exe

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365465 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTImporter] Added visibility context check for EnumDecl.
Balazs Keri [Tue, 9 Jul 2019 11:08:18 +0000 (11:08 +0000)]
[ASTImporter] Added visibility context check for EnumDecl.

Summary:
ASTImporter makes now difference between enums with same name in different translation
units if these are not visible outside.
("Scoped enums" are not handled yet.)

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365464 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRetire VS2015 Support
Simon Pilgrim [Tue, 9 Jul 2019 10:12:37 +0000 (10:12 +0000)]
Retire VS2015 Support

As proposed here: https://lists.llvm.org/pipermail/llvm-dev/2019-June/133147.html

This patch raises the minimum supported version to build LLVM/Clang to Visual Studio 2017.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365454 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemove trailing whitespaces in the Language Extensions doc
Sylvestre Ledru [Tue, 9 Jul 2019 08:50:17 +0000 (08:50 +0000)]
Remove trailing whitespaces in the Language Extensions doc

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365446 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd AlignConsecutiveMacros to the clang release notes
Sylvestre Ledru [Tue, 9 Jul 2019 08:45:55 +0000 (08:45 +0000)]
Add AlignConsecutiveMacros to the clang release notes

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365445 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[BPF] Preserve debuginfo array/union/struct type/access index
Yonghong Song [Tue, 9 Jul 2019 04:21:50 +0000 (04:21 +0000)]
[BPF] Preserve debuginfo array/union/struct type/access index

For background of BPF CO-RE project, please refer to
  http://vger.kernel.org/bpfconf2019.html
In summary, BPF CO-RE intends to compile bpf programs
adjustable on struct/union layout change so the same
program can run on multiple kernels with adjustment
before loading based on native kernel structures.

In order to do this, we need keep track of GEP(getelementptr)
instruction base and result debuginfo types, so we
can adjust on the host based on kernel BTF info.
Capturing such information as an IR optimization is hard
as various optimization may have tweaked GEP and also
union is replaced by structure it is impossible to track
fieldindex for union member accesses.

Three intrinsic functions, preserve_{array,union,struct}_access_index,
are introducted.
  addr = preserve_array_access_index(base, index, dimension)
  addr = preserve_union_access_index(base, di_index)
  addr = preserve_struct_access_index(base, gep_index, di_index)
here,
  base: the base pointer for the array/union/struct access.
  index: the last access index for array, the same for IR/DebugInfo layout.
  dimension: the array dimension.
  gep_index: the access index based on IR layout.
  di_index: the access index based on user/debuginfo types.

If using these intrinsics blindly, i.e., transforming all GEPs
to these intrinsics and later on reducing them to GEPs, we have
seen up to 7% more instructions generated. To avoid such an overhead,
a clang builtin is proposed:
  base = __builtin_preserve_access_index(base)
such that user wraps to-be-relocated GEPs in this builtin
and preserve_*_access_index intrinsics only apply to
those GEPs. Such a buyin will prevent performance degradation
if people do not use CO-RE, even for programs which use
bpf_probe_read().

For example, for the following example,
  $ cat test.c
  struct sk_buff {
     int i;
     int b1:1;
     int b2:2;
     union {
       struct {
         int o1;
         int o2;
       } o;
       struct {
         char flags;
         char dev_id;
       } dev;
       int netid;
     } u[10];
  };

  static int (*bpf_probe_read)(void *dst, int size, const void *unsafe_ptr)
      = (void *) 4;

  #define _(x) (__builtin_preserve_access_index(x))

  int bpf_prog(struct sk_buff *ctx) {
    char dev_id;
    bpf_probe_read(&dev_id, sizeof(char), _(&ctx->u[5].dev.dev_id));
    return dev_id;
  }
  $ clang -target bpf -O2 -g -emit-llvm -S -mllvm -print-before-all \
    test.c >& log

The generated IR looks like below:
  ...
  define dso_local i32 @bpf_prog(%struct.sk_buff*) #0 !dbg !15 {
    %2 = alloca %struct.sk_buff*, align 8
    %3 = alloca i8, align 1
    store %struct.sk_buff* %0, %struct.sk_buff** %2, align 8, !tbaa !45
    call void @llvm.dbg.declare(metadata %struct.sk_buff** %2, metadata !43, metadata !DIExpression()), !dbg !49
    call void @llvm.lifetime.start.p0i8(i64 1, i8* %3) #4, !dbg !50
    call void @llvm.dbg.declare(metadata i8* %3, metadata !44, metadata !DIExpression()), !dbg !51
    %4 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** @bpf_probe_read, align 8, !dbg !52, !tbaa !45
    %5 = load %struct.sk_buff*, %struct.sk_buff** %2, align 8, !dbg !53, !tbaa !45
    %6 = call [10 x %union.anon]* @llvm.preserve.struct.access.index.p0a10s_union.anons.p0s_struct.sk_buffs(
         %struct.sk_buff* %5, i32 2, i32 3), !dbg !53, !llvm.preserve.access.index !19
    %7 = call %union.anon* @llvm.preserve.array.access.index.p0s_union.anons.p0a10s_union.anons(
         [10 x %union.anon]* %6, i32 1, i32 5), !dbg !53
    %8 = call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(
         %union.anon* %7, i32 1), !dbg !53, !llvm.preserve.access.index !26
    %9 = bitcast %union.anon* %8 to %struct.anon.0*, !dbg !53
    %10 = call i8* @llvm.preserve.struct.access.index.p0i8.p0s_struct.anon.0s(
         %struct.anon.0* %9, i32 1, i32 1), !dbg !53, !llvm.preserve.access.index !34
    %11 = call i32 %4(i8* %3, i32 1, i8* %10), !dbg !52
    %12 = load i8, i8* %3, align 1, !dbg !54, !tbaa !55
    %13 = sext i8 %12 to i32, !dbg !54
    call void @llvm.lifetime.end.p0i8(i64 1, i8* %3) #4, !dbg !56
    ret i32 %13, !dbg !57
  }

  !19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "sk_buff", file: !3, line: 1, size: 704, elements: !20)
  !26 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !19, file: !3, line: 5, size: 64, elements: !27)
  !34 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !26, file: !3, line: 10, size: 16, elements: !35)

Note that @llvm.preserve.{struct,union}.access.index calls have metadata llvm.preserve.access.index
attached to instructions to provide struct/union debuginfo type information.

For &ctx->u[5].dev.dev_id,
  . The "%6 = ..." represents struct member "u" with index 2 for IR layout and index 3 for DI layout.
  . The "%7 = ..." represents array subscript "5".
  . The "%8 = ..." represents union member "dev" with index 1 for DI layout.
  . The "%10 = ..." represents struct member "dev_id" with index 1 for both IR and DI layout.

Basically, traversing the use-def chain recursively for the 3rd argument of bpf_probe_read() and
examining all preserve_*_access_index calls, the debuginfo struct/union/array access index
can be achieved.

The intrinsics also contain enough information to regenerate codes for IR layout.
For array and structure intrinsics, the proper GEP can be constructed.
For union intrinsics, replacing all uses of "addr" with "base" should be enough.

Signed-off-by: Yonghong Song <yhs@fb.com>
Differential Revision: https://reviews.llvm.org/D61809

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365438 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[BPF] Preserve debuginfo array/union/struct type/access index"
Yonghong Song [Tue, 9 Jul 2019 04:15:12 +0000 (04:15 +0000)]
Revert "[BPF] Preserve debuginfo array/union/struct type/access index"

This reverts commit r365435.

Forgot adding the Differential Revision link. Will add to the
commit message and resubmit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365436 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[BPF] Preserve debuginfo array/union/struct type/access index
Yonghong Song [Tue, 9 Jul 2019 04:04:21 +0000 (04:04 +0000)]
[BPF] Preserve debuginfo array/union/struct type/access index

For background of BPF CO-RE project, please refer to
  http://vger.kernel.org/bpfconf2019.html
In summary, BPF CO-RE intends to compile bpf programs
adjustable on struct/union layout change so the same
program can run on multiple kernels with adjustment
before loading based on native kernel structures.

In order to do this, we need keep track of GEP(getelementptr)
instruction base and result debuginfo types, so we
can adjust on the host based on kernel BTF info.
Capturing such information as an IR optimization is hard
as various optimization may have tweaked GEP and also
union is replaced by structure it is impossible to track
fieldindex for union member accesses.

Three intrinsic functions, preserve_{array,union,struct}_access_index,
are introducted.
  addr = preserve_array_access_index(base, index, dimension)
  addr = preserve_union_access_index(base, di_index)
  addr = preserve_struct_access_index(base, gep_index, di_index)
here,
  base: the base pointer for the array/union/struct access.
  index: the last access index for array, the same for IR/DebugInfo layout.
  dimension: the array dimension.
  gep_index: the access index based on IR layout.
  di_index: the access index based on user/debuginfo types.

If using these intrinsics blindly, i.e., transforming all GEPs
to these intrinsics and later on reducing them to GEPs, we have
seen up to 7% more instructions generated. To avoid such an overhead,
a clang builtin is proposed:
  base = __builtin_preserve_access_index(base)
such that user wraps to-be-relocated GEPs in this builtin
and preserve_*_access_index intrinsics only apply to
those GEPs. Such a buyin will prevent performance degradation
if people do not use CO-RE, even for programs which use
bpf_probe_read().

For example, for the following example,
  $ cat test.c
  struct sk_buff {
     int i;
     int b1:1;
     int b2:2;
     union {
       struct {
         int o1;
         int o2;
       } o;
       struct {
         char flags;
         char dev_id;
       } dev;
       int netid;
     } u[10];
  };

  static int (*bpf_probe_read)(void *dst, int size, const void *unsafe_ptr)
      = (void *) 4;

  #define _(x) (__builtin_preserve_access_index(x))

  int bpf_prog(struct sk_buff *ctx) {
    char dev_id;
    bpf_probe_read(&dev_id, sizeof(char), _(&ctx->u[5].dev.dev_id));
    return dev_id;
  }
  $ clang -target bpf -O2 -g -emit-llvm -S -mllvm -print-before-all \
    test.c >& log

The generated IR looks like below:
  ...
  define dso_local i32 @bpf_prog(%struct.sk_buff*) #0 !dbg !15 {
    %2 = alloca %struct.sk_buff*, align 8
    %3 = alloca i8, align 1
    store %struct.sk_buff* %0, %struct.sk_buff** %2, align 8, !tbaa !45
    call void @llvm.dbg.declare(metadata %struct.sk_buff** %2, metadata !43, metadata !DIExpression()), !dbg !49
    call void @llvm.lifetime.start.p0i8(i64 1, i8* %3) #4, !dbg !50
    call void @llvm.dbg.declare(metadata i8* %3, metadata !44, metadata !DIExpression()), !dbg !51
    %4 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** @bpf_probe_read, align 8, !dbg !52, !tbaa !45
    %5 = load %struct.sk_buff*, %struct.sk_buff** %2, align 8, !dbg !53, !tbaa !45
    %6 = call [10 x %union.anon]* @llvm.preserve.struct.access.index.p0a10s_union.anons.p0s_struct.sk_buffs(
         %struct.sk_buff* %5, i32 2, i32 3), !dbg !53, !llvm.preserve.access.index !19
    %7 = call %union.anon* @llvm.preserve.array.access.index.p0s_union.anons.p0a10s_union.anons(
         [10 x %union.anon]* %6, i32 1, i32 5), !dbg !53
    %8 = call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(
         %union.anon* %7, i32 1), !dbg !53, !llvm.preserve.access.index !26
    %9 = bitcast %union.anon* %8 to %struct.anon.0*, !dbg !53
    %10 = call i8* @llvm.preserve.struct.access.index.p0i8.p0s_struct.anon.0s(
         %struct.anon.0* %9, i32 1, i32 1), !dbg !53, !llvm.preserve.access.index !34
    %11 = call i32 %4(i8* %3, i32 1, i8* %10), !dbg !52
    %12 = load i8, i8* %3, align 1, !dbg !54, !tbaa !55
    %13 = sext i8 %12 to i32, !dbg !54
    call void @llvm.lifetime.end.p0i8(i64 1, i8* %3) #4, !dbg !56
    ret i32 %13, !dbg !57
  }

  !19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "sk_buff", file: !3, line: 1, size: 704, elements: !20)
  !26 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !19, file: !3, line: 5, size: 64, elements: !27)
  !34 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !26, file: !3, line: 10, size: 16, elements: !35)

Note that @llvm.preserve.{struct,union}.access.index calls have metadata llvm.preserve.access.index
attached to instructions to provide struct/union debuginfo type information.

For &ctx->u[5].dev.dev_id,
  . The "%6 = ..." represents struct member "u" with index 2 for IR layout and index 3 for DI layout.
  . The "%7 = ..." represents array subscript "5".
  . The "%8 = ..." represents union member "dev" with index 1 for DI layout.
  . The "%10 = ..." represents struct member "dev_id" with index 1 for both IR and DI layout.

Basically, traversing the use-def chain recursively for the 3rd argument of bpf_probe_read() and
examining all preserve_*_access_index calls, the debuginfo struct/union/array access index
can be achieved.

The intrinsics also contain enough information to regenerate codes for IR layout.
For array and structure intrinsics, the proper GEP can be constructed.
For union intrinsics, replacing all uses of "addr" with "base" should be enough.

Signed-off-by: Yonghong Song <yhs@fb.com>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365435 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoUse `ln -n` to prevent forming a symlink cycle, instead of rm'ing the source
Nico Weber [Tue, 9 Jul 2019 00:36:18 +0000 (00:36 +0000)]
Use `ln -n` to prevent forming a symlink cycle, instead of rm'ing the source

This is a better fix for the problem fixed in r334972.

Also remove the rm'ing of the symlink destination that was there to
clean up the bots -- it's over a year later, bots should be happy now.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365414 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoLet unaliased Args track which Alias they were created from, and use that in Arg...
Nico Weber [Tue, 9 Jul 2019 00:34:08 +0000 (00:34 +0000)]
Let unaliased Args track which Alias they were created from, and use that in Arg::getAsString() for diagnostics

With this, `clang-cl /source-charset:utf-16 test.cc` now prints `invalid
value 'utf-16' in '/source-charset:utf-16'` instead of `invalid value
'utf-16' in '-finput-charset=utf-16'` before, and several other clang-cl
flags produce much less confusing output as well.

Fixes PR29106.

Since an arg and its alias can have different arg types (joined vs not)
and different values (because of AliasArgs<>), I chose to give the Alias
its own Arg object. For convenience, I just store the alias directly in
the unaliased arg – there aren't many arg objects at runtime, so that
seems ok.

Finally, I changed Arg::getAsString() to use the alias's representation
if it's present – that function was already documented as being the
suitable function for diagnostics, and most callers already used it for
diagnostics.

Implementation-wise, Arg::accept() previously used to parse things as
the unaliased option. The core of that switch is now extracted into a
new function acceptInternal() which parses as the _aliased_ option, and
the previously-intermingled unaliasing is now done as an explicit step
afterwards.

(This also changes one place in lld that didn't use getAsString() for
diagnostics, so that that one place now also prints the flag as the user
wrote it, not as it looks after it went through unaliasing.)

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365413 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[X86][PPC] Support -mlong-double-64
Fangrui Song [Tue, 9 Jul 2019 00:27:43 +0000 (00:27 +0000)]
[X86][PPC] Support -mlong-double-64

-mlong-double-64 is supported on some ports of gcc (i386, x86_64, and ppc{32,64}).
On many other targets, there will be an error:

    error: unrecognized command line option '-mlong-double-64'

This patch makes the driver option -mlong-double-64 available for x86
and ppc. The CC1 option -mlong-double-64 is available on all targets for
users to test on unsupported targets.

LongDoubleSize is added as a VALUE_LANGOPT so that the option can be
shared with -mlong-double-128 when we support it in clang.

Also, make powerpc*-linux-musl default to use 64-bit long double. It is
currently the only supported ABI on musl and is also how people
configure powerpc*-linux-musl-gcc.

Reviewed By: rnk

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365412 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoclang-cl: Port cl.exe's C4659 to clang-cl
Nico Weber [Tue, 9 Jul 2019 00:02:23 +0000 (00:02 +0000)]
clang-cl: Port cl.exe's C4659 to clang-cl

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365411 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: Implement a topology-only mode.
Artem Dergachev [Mon, 8 Jul 2019 23:54:14 +0000 (23:54 +0000)]
[analyzer] exploded-graph-rewriter: Implement a topology-only mode.

In this mode the rewriter will only rewrite program points
and omit program states. Useful for understanding
the rough topology of the graph.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365410 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: Implement a single-path mode.
Artem Dergachev [Mon, 8 Jul 2019 23:54:11 +0000 (23:54 +0000)]
[analyzer] exploded-graph-rewriter: Implement a single-path mode.

Instead of rewriting the whole graph, rewrite the leftmost path in the
graph. Useful for trimmed graphs that are still too large to display due
to multiple equivalent reports mixed into them.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365409 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ObjC] Add a -Wtautological-compare warning for BOOL
Erik Pilkington [Mon, 8 Jul 2019 23:42:52 +0000 (23:42 +0000)]
[ObjC] Add a -Wtautological-compare warning for BOOL

On macOS, BOOL is a typedef for signed char, but it should never hold a value
that isn't 1 or 0. Any code that expects a different value in their BOOL should
be fixed.

rdar://51954400

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365408 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[cxx2a] P0624R2 fix: only lambdas with no lambda-capture are default-constructible...
David Blaikie [Mon, 8 Jul 2019 23:24:41 +0000 (23:24 +0000)]
[cxx2a] P0624R2 fix: only lambdas with no lambda-capture are default-constructible and assignable.

This is a fix for rG864949 which only disabled default construction and
assignment for lambdas with capture-defaults, where the C++2a draft
disables them for lambdas with any lambda-capture at all.

Patch by Logan Smith!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365406 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Frontend] Explicitly include Bitstream/BitCodes.h and BitstreamWriter.h
Francis Visoiu Mistrih [Mon, 8 Jul 2019 23:02:50 +0000 (23:02 +0000)]
[Frontend] Explicitly include Bitstream/BitCodes.h and BitstreamWriter.h

This fixes a modules issue:

error: declaration of 'bitc' must be imported from module
'Clang_Serialization.ASTBitCodes' before it is required
Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365405 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix line endings. NFC
Paul Robinson [Mon, 8 Jul 2019 22:35:30 +0000 (22:35 +0000)]
Fix line endings. NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365402 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sanitizers] Don't use clang_rt.sancov_{begin,end} on Solaris
Rainer Orth [Mon, 8 Jul 2019 22:04:25 +0000 (22:04 +0000)]
[Sanitizers] Don't use clang_rt.sancov_{begin,end} on Solaris

As explained in https://reviews.llvm.org/D63601, there's no point using clang_rt.sancov_{begin,end}
on Solaris any longer.

This companion patch to the above removes their use from the driver.

Tested on amd64-pc-solaris2.11

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365396 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd parentheses to silence warnings.
Bill Wendling [Mon, 8 Jul 2019 22:01:07 +0000 (22:01 +0000)]
Add parentheses to silence warnings.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365395 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert [Sema] Resolve placeholder types before type deduction to silence spurious...
Reid Kleckner [Mon, 8 Jul 2019 21:59:07 +0000 (21:59 +0000)]
Revert [Sema] Resolve placeholder types before type deduction to silence spurious `-Warc-repeated-use-of-weak` warnings

This reverts r365382 (git commit 8b1becf2e31d9170ee356a19c7b6ea991d3a520f)

Appears to regress this semi-reduced fragment of valid code from windows
SDK headers:

  #define InterlockedIncrement64 _InterlockedIncrement64
  extern "C" __int64 InterlockedIncrement64(__int64 volatile *Addend);
  #pragma intrinsic(_InterlockedIncrement64)
  unsigned __int64 InterlockedIncrement(unsigned __int64 volatile *Addend) {
    return (unsigned __int64)(InterlockedIncrement64)((volatile __int64 *)Addend);
  }

Found on a buildbot here, but no mail was sent due to it already being
red:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/48067

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365393 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Sema] Resolve placeholder types before type deduction to silence
Akira Hatanaka [Mon, 8 Jul 2019 20:04:39 +0000 (20:04 +0000)]
[Sema] Resolve placeholder types before type deduction to silence
spurious `-Warc-repeated-use-of-weak` warnings

The spurious -Warc-repeated-use-of-weak warnings are issued when an
initializer expression uses a weak ObjC pointer.

My first attempt to silence the warnings (r350917) caused clang to
reject code that is legal in C++17. The patch is based on the feedback I
received from Richard when the patch was reverted.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268945.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268943.html

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365382 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd missing declarations of explicit member specializations.
Richard Smith [Mon, 8 Jul 2019 19:45:46 +0000 (19:45 +0000)]
Add missing declarations of explicit member specializations.

This should fix the build under -Wundefined-func-template and certain
versions of GCC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365377 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Improve error message for device unsupported types.
Alexey Bataev [Mon, 8 Jul 2019 19:21:54 +0000 (19:21 +0000)]
[OPENMP]Improve error message for device unsupported types.

Provide more data to the user in the error message about unsupported
type for device compilation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365374 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoReplace temporary variable matches in test since r363952 causes an
Amy Huang [Mon, 8 Jul 2019 17:35:28 +0000 (17:35 +0000)]
Replace temporary variable matches in test since r363952 causes an
extra temporary variable to be created.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365357 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Syntax] Introduce syntax trees
Ilya Biryukov [Mon, 8 Jul 2019 17:25:02 +0000 (17:25 +0000)]
[Syntax] Introduce syntax trees

Summary:
A tooling-focused alternative to the AST. This commit focuses on the
memory-management strategy and the structure of the AST.

More to follow later:
  - Operations to mutate the syntax trees and corresponding textual
    replacements.
  - Mapping between clang AST nodes and syntax tree nodes.
  - More node types corresponding to the language constructs.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: llvm-commits, mgorny, cfe-commits

Tags: #clang, #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365355 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd nofree attribute to CodeGenOpenCL/convergent.cl test
Brian Homerding [Mon, 8 Jul 2019 16:24:10 +0000 (16:24 +0000)]
Add nofree attribute to CodeGenOpenCL/convergent.cl test

The revision at https://reviews.llvm.org/rL365336 added inference of the nofree
attribute.  This revision updates the test to reflect this.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365341 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[OPENMP]Add -Wunintialized to the erroneous tests for future fix PR42392,
Alexey Bataev [Mon, 8 Jul 2019 15:45:24 +0000 (15:45 +0000)]
[OPENMP]Add -Wunintialized to the erroneous tests for future fix PR42392,
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365334 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clangd] A code tweak to expand a macro
Ilya Biryukov [Mon, 8 Jul 2019 15:25:16 +0000 (15:25 +0000)]
[clangd] A code tweak to expand a macro

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365331 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[RISCV][NFC] Make use of Triple::isRISCV
Alex Bradbury [Mon, 8 Jul 2019 15:07:12 +0000 (15:07 +0000)]
[RISCV][NFC] Make use of Triple::isRISCV

Use new helper introduced in rL365327.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365329 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[ASTImporter] Fix import of lambda in function param
Gabor Marton [Mon, 8 Jul 2019 12:49:13 +0000 (12:49 +0000)]
[ASTImporter] Fix import of lambda in function param

Summary:
The current import implementation fails to import the definition of a
lambda class if the lambda class is defined in a function param.
E.g., the lambda class below will be imported without any methods:
```
  template <typename F>
  void f(F L = [](){}) {}
```

Reviewers: a_sidorin, a.sidorin, shafik

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365315 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Add analyzer option to limit the number of imported TUs
Endre Fulop [Mon, 8 Jul 2019 12:37:10 +0000 (12:37 +0000)]
[analyzer] Add analyzer option to limit the number of imported TUs

Summary:
During CTU analysis of complex projects, the loaded AST-contents of
imported TUs can grow bigger than available system memory. This option
introduces a threshold on the number of TUs to be imported for a single
TU in order to prevent such cases.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365314 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[RISCV] Specify registers used for exception handling
Alex Bradbury [Mon, 8 Jul 2019 09:38:06 +0000 (09:38 +0000)]
[RISCV] Specify registers used for exception handling

Implements the handling of __builtin_eh_return_regno().

Differential Revision: https://reviews.llvm.org/D63417
Patch by Edward Jones.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365305 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AArch64] Fix scalar vuqadd intrinsics operands
Diogo N. Sampaio [Mon, 8 Jul 2019 08:47:47 +0000 (08:47 +0000)]
[AArch64] Fix scalar vuqadd intrinsics operands

Summary:
Change the vuqadd scalar instrinsics to have the second argument as unsigned values, not signed,
accordingly to https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics

So now the compiler correctly warns that a undefined negative float conversion is being done.

Reviewers: LukeCheeseman, john.brawn

Reviewed By: john.brawn

Subscribers: john.brawn, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365300 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[AArch64] Fix vsqadd scalar intrinsics operands
Diogo N. Sampaio [Mon, 8 Jul 2019 08:35:05 +0000 (08:35 +0000)]
[AArch64] Fix vsqadd scalar intrinsics operands

Summary:
Change the vsqadd scalar instrinsics to have the second argument as signed values, not unsigned,
accordingly to https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics

The existing unsigned argument can cause faulty code as negative float to unsigned conversion is
undefined, which llvm/clang optimizes away.

Reviewers: LukeCheeseman, john.brawn

Reviewed By: john.brawn

Subscribers: john.brawn, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365298 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoTreat the range of representable values of floating-point types as [-inf, +inf] not...
Richard Smith [Sat, 6 Jul 2019 21:05:52 +0000 (21:05 +0000)]
Treat the range of representable values of floating-point types as [-inf, +inf] not as [-max, +max].

Summary:
Prior to r329065, we used [-max, max] as the range of representable
values because LLVM's `fptrunc` did not guarantee defined behavior when
truncating from a larger floating-point type to a smaller one. Now that
has been fixed, we can make clang follow normal IEEE 754 semantics in this
regard and take the larger range [-inf, +inf] as the range of representable
values.

In practice, this affects two parts of the frontend:
 * the constant evaluator no longer treats floating-point evaluations
   that result in +-inf as being undefined (because they no longer leave
   the range of representable values of the type)
 * UBSan no longer treats conversions to floating-point type that are
   outside the [-max, +max] range as being undefined

In passing, also remove the float-divide-by-zero sanitizer from
-fsanitize=undefined, on the basis that while it's undefined per C++
rules (and we disallow it in constant expressions for that reason), it
is defined by Clang / LLVM / IEEE 754.

Reviewers: rnk, BillyONeal

Subscribers: cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365272 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Rewrite] Try to fix buildbot link fail left by r365263
Joel E. Denny [Sat, 6 Jul 2019 16:28:32 +0000 (16:28 +0000)]
[Rewrite] Try to fix buildbot link fail left by r365263

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10272

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365264 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Rewrite] Try to fix buildbot link fail caused by r365258
Joel E. Denny [Sat, 6 Jul 2019 13:44:57 +0000 (13:44 +0000)]
[Rewrite] Try to fix buildbot link fail caused by r365258

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10270

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365263 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Rewrite] Extend to further accept CharSourceRange
Joel E. Denny [Sat, 6 Jul 2019 02:55:06 +0000 (02:55 +0000)]
[Rewrite] Extend to further accept CharSourceRange

Some Rewrite functions are already overloaded to accept
CharSourceRange, and this extends others in the same manner.  I'm
calling these in code that's not ready to upstream, but I figure they
might be useful to others in the meantime.

Reviewed By: jdoerfert

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365258 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoImprove MSVC visualization of annot_template_id tokens
Mike Spertus [Fri, 5 Jul 2019 21:41:30 +0000 (21:41 +0000)]
Improve MSVC visualization of annot_template_id tokens

Now shows the actual annotated template. E.g.,
{annot_template_id (A<int, double>)}

Also a few miscellaneous fixes to visualizers of other types

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365248 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoBitstream reader: Fix undefined behavior seen after rL364464
Bjorn Pettersson [Fri, 5 Jul 2019 20:22:40 +0000 (20:22 +0000)]
Bitstream reader: Fix undefined behavior seen after rL364464

Summary:
After rL364464 the following tests started to fail when
running the clang-doc tests with an ubsan instrumented
build of clang-doc:
    Clang Tools :: clang-doc/single-file-public.cpp
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitEnumInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitMethodInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitRecordInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/SerializeTest.emitInfoWithCommentBitcode

We need to check that the read value is in range for being
casted to the llvm::bitc::FixedAbbrevIDs enum, before the
cast in ClangDocBitcodeReader::skipUntilRecordOrBlock.

SerializedDiagnosticReader::skipUntilRecordOrBlock was updated
in the same way.

Reviewers: jfb

Reviewed By: jfb

Subscribers: Bigcheese, vsapsai, bruno, ilya-biryukov, dexonsmith, kadircet, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365239 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoAdd a comment explaining why a function exists
Nico Weber [Fri, 5 Jul 2019 15:12:31 +0000 (15:12 +0000)]
Add a comment explaining why a function exists

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365212 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoNFC: Add an explicit return for safety and consistency
Hamza Sood [Fri, 5 Jul 2019 14:36:08 +0000 (14:36 +0000)]
NFC: Add an explicit return for safety and consistency

This case implicitly falls-through, which is fine now as it's at the end of the
function, but it seems like an accident waiting to happen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365210 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRemoved the test case added in D63538 due to windows buildbot failures
Kristof Umann [Fri, 5 Jul 2019 14:22:10 +0000 (14:22 +0000)]
Removed the test case added in D63538 due to windows buildbot failures

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365209 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Add a debug analyzer config to place an event for each tracked condition
Kristof Umann [Fri, 5 Jul 2019 14:00:08 +0000 (14:00 +0000)]
[analyzer] Add a debug analyzer config to place an event for each tracked condition

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365208 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] Track terminator conditions on which a tracked expression depends
Kristof Umann [Fri, 5 Jul 2019 13:29:54 +0000 (13:29 +0000)]
[analyzer] Track terminator conditions on which a tracked expression depends

This patch is a major part of my GSoC project, aimed to improve the bug
reports of the analyzer.

TL;DR: Help the analyzer understand that some conditions are important,
and should be explained better. If an CFGBlock is a control dependency
of a block where an expression value is tracked, explain the condition
expression better by tracking it.

if (A) // let's explain why we believe A to be true
  10 / x; // division by zero

This is an experimental feature, and can be enabled by the
off-by-default analyzer configuration "track-conditions".

In detail:

This idea was inspired by the program slicing algorithm. Essentially,
two things are used to produce a program slice (a subset of the program
relevant to a (statement, variable) pair): data and control
dependencies. The bug path (the linear path in the ExplodedGraph that leads
from the beginning of the analysis to the error node) enables to
analyzer to argue about data dependencies with relative ease.

Control dependencies are a different slice of the cake entirely.

Just because we reached a branch during symbolic execution, it
doesn't mean that that particular branch has any effect on whether the
bug would've occured. This means that we can't simply rely on the bug
path to gather control dependencies.

In previous patches, LLVM's IDFCalculator, which works on a control flow
graph rather than the ExplodedGraph was generalized to solve this issue.
We use this information to heuristically guess that the value of a tracked
expression depends greatly on it's control dependencies, and start
tracking them as well.

After plenty of evaluations this was seen as great idea, but still
lacking refinements (we should have different descriptions about a
conditions value), hence it's off-by-default.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365207 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][IDF] Add a control dependency calculator + a new debug checker
Kristof Umann [Fri, 5 Jul 2019 12:17:44 +0000 (12:17 +0000)]
[analyzer][IDF] Add a control dependency calculator + a new debug checker

I intend to improve the analyzer's bug reports by tracking condition
expressions.

01 bool b = messyComputation();
02 int i = 0;
03 if (b) // control dependency of the bug site, let's explain why we assume val
04        // to be true
05   10 / i; // warn: division by zero

I'll detail this heuristic in the followup patch, strictly related to this one
however:

* Create the new ControlDependencyCalculator class that uses llvm::IDFCalculator
  to (lazily) calculate control dependencies for Clang's CFG.
* A new debug checker debug.DumpControlDependencies is added for lit tests
* Add unittests

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365197 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Test commit access
Endre Fulop [Fri, 5 Jul 2019 12:00:52 +0000 (12:00 +0000)]
[NFC] Test commit access

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365189 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMake joined instances of JoinedOrSeparate flags point to the unaliased args, like...
Nico Weber [Fri, 5 Jul 2019 11:45:24 +0000 (11:45 +0000)]
Make joined instances of JoinedOrSeparate flags point to the unaliased args, like all other arg types do

This fixes an 8-year-old regression. r105763 made it so that aliases
always refer to the unaliased option – but it missed the "joined" branch
of JoinedOrSeparate flags. (r162231 then made the Args classes
non-virtual, and r169344 moved them from clang to llvm.)

Back then, there was no JoinedOrSeparate flag that was an alias, so it
wasn't observable. Now /U in CLCompatOptions is a JoinedOrSeparate alias
in clang, and warn_slash_u_filename incorrectly used the aliased arg id
(using the unaliased one isn't really a regression since that warning
checks if the undefined macro contains slash or backslash and only then
emits the warning – and no valid use will pass "-Ufoo/bar" or similar).

Also, lld has many JoinedOrSeparate aliases, and due to this bug it had
to explicitly call `getUnaliasedOption()` in a bunch of places, even
though that shouldn't be necessary by design. After this fix in Option,
these calls really don't have an effect any more, so remove them.

No intended behavior change.

(I accidentally fixed this bug while working on PR29106 but then
wondered why the warn_slash_u_filename broke. When I figured it out, I
thought it would make sense to land this in a separate commit.)

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365186 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix a buildbot failure due to the AST's lifetime ending before the test
Kristof Umann [Fri, 5 Jul 2019 11:14:57 +0000 (11:14 +0000)]
Fix a buildbot failure due to the AST's lifetime ending before the test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365181 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][Dominators][NFC] Add unit tests
Kristof Umann [Fri, 5 Jul 2019 10:16:36 +0000 (10:16 +0000)]
[analyzer][Dominators][NFC] Add unit tests

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365179 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CFG] Add a new function to get the proper condition of a CFGBlock
Kristof Umann [Fri, 5 Jul 2019 09:52:00 +0000 (09:52 +0000)]
[CFG] Add a new function to get the proper condition of a CFGBlock

getTerminatorCondition() returned a condition that may be outside of the
block, while the new function returns the proper one:

if (A && B && C) {}

Return C instead of A && B && C.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365177 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoSilence gcc warning "control reaches end of non-void function" [NFCI]
Mikael Holmen [Fri, 5 Jul 2019 06:12:24 +0000 (06:12 +0000)]
Silence gcc warning "control reaches end of non-void function" [NFCI]

Without this fix gcc (7.4) complains with

 /data/repo/master/clang/lib/CodeGen/CGObjCMac.cpp: In member function 'std::__cxx11::string {anonymous}::CGObjCCommonMac::GetSectionName(llvm::StringRef, llvm::StringRef)':
 /data/repo/master/clang/lib/CodeGen/CGObjCMac.cpp:4944:1: error: control reaches end of non-void function [-Werror=return-type]
  }
  ^

All values in the ObjectFormatType enum are currently handled in the switch
but gcc complains anyway.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365174 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[NFC] Make some ObjectFormatType switches covering
Hubert Tong [Thu, 4 Jul 2019 21:40:28 +0000 (21:40 +0000)]
[NFC] Make some ObjectFormatType switches covering

Summary:
This patch removes the `default` case from some switches on
`llvm::Triple::ObjectFormatType`, and cases for the missing enumerators
are then added.

For `UnknownObjectFormat`, the action (`llvm_unreachable`) for the
`default` case is kept.

For the other unhandled cases, `report_fatal_error` is used instead.

Reviewers: sfertile, jasonliu, daltenty

Reviewed By: sfertile

Subscribers: wuzish, aheejin, jsji, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365160 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[modules] Add PP callbacks for entering and leaving a submodule.
Vassil Vassilev [Thu, 4 Jul 2019 19:06:52 +0000 (19:06 +0000)]
[modules] Add PP callbacks for entering and leaving a submodule.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365153 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[CTU] Add support for virtual functions
Gabor Marton [Thu, 4 Jul 2019 11:39:00 +0000 (11:39 +0000)]
[CTU] Add support for virtual functions

Reviewers: Szelethus, xazax.hun

Subscribers: rnkovacs, dkrupp, gamesh411, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365133 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix -Wdocumentation warning.
Simon Pilgrim [Thu, 4 Jul 2019 10:28:31 +0000 (10:28 +0000)]
Fix -Wdocumentation warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365126 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[PowerPC] Support constraint code "ww"
Fangrui Song [Thu, 4 Jul 2019 04:44:42 +0000 (04:44 +0000)]
[PowerPC] Support constraint code "ww"

Summary:
"ww" and "ws" are both constraint codes for VSX vector registers that
hold scalar double data. "ww" is preferred for float while "ws" is
preferred for double.

Reviewed By: jsji

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365106 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] ReturnValueChecker: Model the guaranteed boolean return value of function...
Csaba Dabis [Thu, 4 Jul 2019 00:50:50 +0000 (00:50 +0000)]
[analyzer] ReturnValueChecker: Model the guaranteed boolean return value of function calls

Summary: It models the known LLVM methods paired with their class.

Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus

Reviewed By: NoQ

Subscribers: dschuff, aheejin, mgorny, szepet, rnkovacs, a.sidorin,
             mikhail.ramalho, donat.nagy, dkrupp, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365103 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agocmake: Add CLANG_LINK_CLANG_DYLIB option
Tom Stellard [Wed, 3 Jul 2019 22:45:55 +0000 (22:45 +0000)]
cmake: Add CLANG_LINK_CLANG_DYLIB option

Summary:
Setting CLANG_LINK_CLANG_DYLIB=ON causes clang tools to link against
libclang_shared.so instead of the individual component libraries.

Reviewers: mgorny, beanz, smeenai, phosek, sylvestre.ledru

Subscribers: arphaman, cfe-commits, llvm-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365092 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Bitcode] Move Bitstream to a separate library
Francis Visoiu Mistrih [Wed, 3 Jul 2019 22:40:07 +0000 (22:40 +0000)]
[Bitcode] Move Bitstream to a separate library

This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/.

This is needed to avoid a circular dependency when using the bitstream
code for parsing optimization remarks.

Since Bitcode uses Core for the IR part:

libLLVMRemarks -> Bitcode -> Core

and Core uses libLLVMRemarks to generate remarks (see
IR/RemarkStreamer.cpp):

Core -> libLLVMRemarks

we need to separate the Bitstream and Bitcode part.

For clang-doc, it seems that it doesn't need the whole bitcode layer, so
I updated the CMake to only use the bitstream part.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365091 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: Implement a black-and-white color scheme.
Artem Dergachev [Wed, 3 Jul 2019 20:48:23 +0000 (20:48 +0000)]
[analyzer] exploded-graph-rewriter: Implement a black-and-white color scheme.

For accessibility!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365085 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-scan-deps] use `-Wno-error` when scanning for dependencies
Alex Lorenz [Wed, 3 Jul 2019 18:01:32 +0000 (18:01 +0000)]
[clang-scan-deps] use `-Wno-error` when scanning for dependencies

Warnings can be promoted to errors.
But that shouldn't prevent us from getting the dependencies!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365065 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoRevert "[analyzer][CFG] Return the correct terminator condition"
Kristof Umann [Wed, 3 Jul 2019 13:03:33 +0000 (13:03 +0000)]
Revert "[analyzer][CFG] Return the correct terminator condition"

This reverts commit 7a57118a6fcfa3770f984453543bbdfd0b233e84.

Causes a bunch of crashes, I need to time to evaluate this.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365037 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][CFG] Return the correct terminator condition
Kristof Umann [Wed, 3 Jul 2019 12:53:19 +0000 (12:53 +0000)]
[analyzer][CFG] Return the correct terminator condition

For the following terminator statement:

if (A && B && C && D)
The built CFG is the following:

[B5 (ENTRY)]
  Succs (1): B4

[B1]
  1: 10
  2: j
  3: [B1.2] (ImplicitCastExpr, LValueToRValue, int)
  4: [B1.1] / [B1.3]
  5: int x = 10 / j;
  Preds (1): B2
  Succs (1): B0

[B2]
  1: C
  2: [B2.1] (ImplicitCastExpr, LValueToRValue, _Bool)
  T: if [B4.4] && [B3.2] && [B2.2]
  Preds (1): B3
  Succs (2): B1 B0

[B3]
  1: B
  2: [B3.1] (ImplicitCastExpr, LValueToRValue, _Bool)
  T: [B4.4] && [B3.2] && ...
  Preds (1): B4
  Succs (2): B2 B0

[B4]
  1: 0
  2: int j = 0;
  3: A
  4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
  T: [B4.4] && ...
  Preds (1): B5
  Succs (2): B3 B0

[B0 (EXIT)]
  Preds (4): B1 B2 B3 B4

However, even though the path of execution in B2 only depends on C's value,
CFGBlock::getCondition() would return the entire condition (A && B && C). For
B3, it would return A && B. I changed this the actual condition.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365036 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix -Wcast-qual const warning. NFCI.
Simon Pilgrim [Wed, 3 Jul 2019 12:20:28 +0000 (12:20 +0000)]
Fix -Wcast-qual const warning. NFCI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365031 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoMake a buildbot using a buggy gcc happy
Kristof Umann [Wed, 3 Jul 2019 12:06:10 +0000 (12:06 +0000)]
Make a buildbot using a buggy gcc happy

When specializing a template in a namespace, it has to be in a namespace
block, else gcc will get confused. Hopefully this fixes the issue.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365030 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoSpecialize an anchor() function in the correct namespace
Kristof Umann [Wed, 3 Jul 2019 11:54:47 +0000 (11:54 +0000)]
Specialize an anchor() function in the correct namespace

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365029 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer][Dominator] Add post dominators to CFG + a new debug checker
Kristof Umann [Wed, 3 Jul 2019 11:39:12 +0000 (11:39 +0000)]
[analyzer][Dominator] Add post dominators to CFG + a new debug checker

Transform clang::DominatorTree to be able to also calculate post dominators.

* Tidy up the documentation
* Make it clang::DominatorTree template class (similarly to how
  llvm::DominatorTreeBase works), rename it to clang::CFGDominatorTreeImpl
* Clang's dominator tree is now called clang::CFGDomTree
* Clang's brand new post dominator tree is called clang::CFGPostDomTree
* Add a lot of asserts to the dump() function
* Create a new checker to test the functionality

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365028 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[Dominators] PR42041: Skip nullpointer successors
Kristof Umann [Wed, 3 Jul 2019 11:14:42 +0000 (11:14 +0000)]
[Dominators] PR42041: Skip nullpointer successors

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

In Clang's CFG, we use nullpointers to represent unreachable nodes, for
example, in the included testfile, block B0 is unreachable from block
B1, resulting in a nullpointer dereference somewhere in
llvm::DominatorTreeBase<clang::CFGBlock, false>::recalculate.

This patch fixes this issue by specializing
llvm::DomTreeBuilder::SemiNCAInfo::ChildrenGetter::Get for
clang::CFG to not contain nullpointer successors.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365026 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix MSVC "signed/unsigned mismatch" warning. NFCI.
Simon Pilgrim [Wed, 3 Jul 2019 10:26:28 +0000 (10:26 +0000)]
Fix MSVC "signed/unsigned mismatch" warning. NFCI.

Fixes PR42426.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365019 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang-tidy] Fix the YAML created for checks like modernize-pass-by-value
Ivan Donchevskii [Wed, 3 Jul 2019 10:21:50 +0000 (10:21 +0000)]
[clang-tidy] Fix the YAML created for checks like modernize-pass-by-value

Currently this check generates the replacement with the newline in the end.
The proper way to export it to YAML is to have two \n\n instead of one.
Without this fix clients should reinterpret the replacement as
"#include <utility> " instead of "#include <utility>\n"

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365017 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoFix MSVC "not all control paths return a value" warnings. NFCI.
Simon Pilgrim [Wed, 3 Jul 2019 09:54:25 +0000 (09:54 +0000)]
Fix MSVC "not all control paths return a value" warnings. NFCI.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365012 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoChange std::{lower,upper}_bound to llvm::{lower,upper}_bound or llvm::partition_point...
Fangrui Song [Wed, 3 Jul 2019 08:13:17 +0000 (08:13 +0000)]
Change std::{lower,upper}_bound to llvm::{lower,upper}_bound or llvm::partition_point. NFC

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365006 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[clang][HeaderSearch] Shorten paths for includes in mainfile's directory
Kadir Cetinkaya [Wed, 3 Jul 2019 07:47:19 +0000 (07:47 +0000)]
[clang][HeaderSearch] Shorten paths for includes in mainfile's directory

Summary:
Currently HeaderSearch only looks at SearchDir's passed into it, but in
addition to those paths headers can be relative to including file's directory.

This patch makes sure that is taken into account.

Reviewers: gribozavr

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@365005 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: Implement bug nodes and sink nodes.
Artem Dergachev [Wed, 3 Jul 2019 01:26:41 +0000 (01:26 +0000)]
[analyzer] exploded-graph-rewriter: Implement bug nodes and sink nodes.

Add a label to nodes that have a bug report attached or on which
the analysis was generally interrupted.

Fix printing has_report and implement printing is_sink in the graph dumper.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364992 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: NFC: Add more comments.
Artem Dergachev [Wed, 3 Jul 2019 01:26:38 +0000 (01:26 +0000)]
[analyzer] exploded-graph-rewriter: NFC: Add more comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364991 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: Collapse very long statement pretty-prints.
Artem Dergachev [Wed, 3 Jul 2019 01:26:35 +0000 (01:26 +0000)]
[analyzer] exploded-graph-rewriter: Collapse very long statement pretty-prints.

When printing various statements that include braces (compound
statements, lambda expressions, statement-expressions, etc.),
replace the code between braces with '...'.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364990 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[analyzer] exploded-graph-rewriter: Implement checker messages.
Artem Dergachev [Wed, 3 Jul 2019 01:26:32 +0000 (01:26 +0000)]
[analyzer] exploded-graph-rewriter: Implement checker messages.

They are displayed as raw lines and diffed via difflib on a per-checker basis.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364989 91177308-0d34-0410-b5e6-96231b3b80d8

5 years ago[C++2a] Add __builtin_bit_cast, used to implement std::bit_cast
Erik Pilkington [Tue, 2 Jul 2019 18:28:13 +0000 (18:28 +0000)]
[C++2a] Add __builtin_bit_cast, used to implement std::bit_cast

This commit adds a new builtin, __builtin_bit_cast(T, v), which performs a
bit_cast from a value v to a type T. This expression can be evaluated at
compile time under specific circumstances.

The compile time evaluation currently doesn't support bit-fields, but I'm
planning on fixing this in a follow up (some of the logic for figuring this out
is in CodeGen). I'm also planning follow-ups for supporting some more esoteric
types that the constexpr evaluator supports, as well as extending
__builtin_memcpy constexpr evaluation to use the same infrastructure.

rdar://44987528

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364954 91177308-0d34-0410-b5e6-96231b3b80d8

5 years agoclang-format: Add new style option AlignConsecutiveMacros
Sam McCall [Tue, 2 Jul 2019 15:53:14 +0000 (15:53 +0000)]
clang-format: Add new style option AlignConsecutiveMacros

This option behaves similarly to AlignConsecutiveDeclarations and
AlignConsecutiveAssignments, aligning the assignment of C/C++
preprocessor macros on consecutive lines.

I've worked in many projects (embedded, mostly) where header files full
of large, well-aligned "#define" blocks are a common pattern. We
normally avoid using clang-format on these files, since it ruins any
existing alignment in said blocks. This style option will align "simple"
PP macros (no parameters) and PP macros with parameter lists on
consecutive lines.

Related Bugzilla entry (thanks mcuddie):
https://llvm.org/bugs/show_bug.cgi?id=20637

Patch by Nick Renieris (VelocityRa)!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364938 91177308-0d34-0410-b5e6-96231b3b80d8