[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

2018-02-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC323952: [DebugInfo] Enable debug information for C99 VLA 
types (authored by s.desmalen, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41698?vs=132275=132350#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41698

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/debug-info-vla.c
  test/CodeGenCXX/debug-info-vla.cpp
  test/CodeGenCXX/vla-consruct.cpp
  test/CodeGenObjC/arc.m
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_parallel_codegen.cpp
  test/OpenMP/target_parallel_for_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/target_teams_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen.cpp

Index: test/CodeGenCXX/vla-consruct.cpp
===
--- test/CodeGenCXX/vla-consruct.cpp
+++ test/CodeGenCXX/vla-consruct.cpp
@@ -21,6 +21,8 @@
   // CHECK: define void {{.*test.*}}(i32 [[n:%.+]]) #
   // CHECK: [[n_addr:%.+]] = alloca
   // CHECK-NEXT: [[saved_stack:%.+]] = alloca
+  // CHECK-NEXT: [[vla_expr:%.+]] = alloca i64, align 8
+  // CHECK-NEXT: [[vla_expr1:%.+]] = alloca i64, align 8
   // CHECK-NEXT: [[sizeof_S:%.+]] = alloca
   // CHECK-NEXT: [[sizeof_array_t_0_0:%.+]] = alloca
   // CHECK-NEXT: [[sizeof_array_t_0:%.+]] = alloca
@@ -37,6 +39,8 @@
   // CHECK-NEXT: store i8* [[t4]], i8** [[saved_stack]]
   // CHECK-NEXT: [[t5:%.+]] = mul nuw i64 [[t1]], [[t3]]
   // CHECK-NEXT: [[vla:%.+]] = alloca [[struct_S]], i64 [[t5]]
+  // CHECK-NEXT: store i64 [[t1]], i64* [[vla_expr]]
+  // CHECK-NEXT: store i64 [[t3]], i64* [[vla_expr1]]
   // CHECK-NEXT: [[t6:%.+]] = mul nuw i64 [[t1]], [[t3]]
   // CHECK-NEXT: [[isempty:%.+]] = icmp eq i64 [[t6]], 0
   // CHECK-NEXT: br i1 [[isempty]], label %[[arrayctor_cont:.+]], label %[[new_ctorloop:.+]]
Index: test/CodeGenCXX/debug-info-vla.cpp
===
--- test/CodeGenCXX/debug-info-vla.cpp
+++ test/CodeGenCXX/debug-info-vla.cpp
@@ -13,8 +13,10 @@
 // CHECK: [[ELEM_TYPE]] = !{[[NOCOUNT:.*]]}
 // CHECK: [[NOCOUNT]] = !DISubrange(count: -1)
 //
+// CHECK: [[VAR:![0-9]+]] = !DILocalVariable(name: "vla_expr"
 // CHECK: !DICompositeType(tag: DW_TAG_array_type,
 // CHECK-NOT:   size:
 // CHECK-SAME:  elements: [[ELEM_TYPE:![0-9]+]]
-// CHECK: [[ELEM_TYPE]] = !{[[THREE:.*]], [[NOCOUNT]]}
+// CHECK: [[ELEM_TYPE]] = !{[[THREE:.*]], [[VARRANGE:![0-9]+]]}
 // CHECK: [[THREE]] = !DISubrange(count: 3)
+// CHECK: [[VARRANGE]] = !DISubrange(count: [[VAR]])
Index: test/CodeGen/debug-info-vla.c
===
--- test/CodeGen/debug-info-vla.c
+++ test/CodeGen/debug-info-vla.c
@@ -2,9 +2,11 @@
 
 void testVLAwithSize(int s)
 {
-// CHECK: dbg.declare
-// CHECK: dbg.declare({{.*}}, metadata ![[VAR:.*]], metadata !DIExpression())
-// CHECK: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+1]]
+// CHECK-DAG: dbg.declare({{.*}} %vla_expr, metadata ![[VLAEXPR:[0-9]+]]
+// CHECK-DAG: dbg.declare({{.*}} %vla, metadata ![[VAR:[0-9]+]]
+// CHECK-DAG: ![[VLAEXPR]] = !DILocalVariable(name: "vla_expr"
+// CHECK-DAG: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+2]]
+// CHECK-DAG: !DISubrange(count: ![[VLAEXPR]])
   int vla[s];
   int i;
   for (i = 0; i < s; i++) {
Index: test/CodeGenObjC/arc.m
===
--- test/CodeGenObjC/arc.m
+++ test/CodeGenObjC/arc.m
@@ -538,6 +538,7 @@
   // CHECK-LABEL: define void @test20
   // CHECK:  [[N:%.*]] = alloca i32, align 4
   // CHECK-NEXT: [[SAVED_STACK:%.*]] = alloca i8*
+  // CHECK-NEXT: [[VLA_EXPR:%.*]] = alloca i64, align 8
   // CHECK-NEXT: store i32 {{%.*}}, i32* [[N]], align 4
 
   id x[n];
@@ -553,6 +554,9 @@
   // Allocate the VLA.
   // CHECK-NEXT: [[VLA:%.*]] = alloca i8*, i64 [[DIM]], align 16
 
+  // Store the VLA #elements expression.
+  // CHECK-NEXT: store i64 %1, i64* [[VLA_EXPR]], align 8
+
   // Zero-initialize.
   // CHECK-NEXT: [[T0:%.*]] = bitcast i8** [[VLA]] to i8*
   // CHECK-NEXT: [[T1:%.*]] = mul nuw i64 [[DIM]], 8
@@ -579,6 +583,7 @@
   // CHECK-LABEL: define void @test21
   // CHECK:  [[N:%.*]] = alloca i32, align 4
   // CHECK-NEXT: [[SAVED_STACK:%.*]] = alloca i8*
+  // CHECK-NEXT: [[VLA_EXPR:%.*]] = alloca i64, align 8
   // CHECK-NEXT: store i32 {{%.*}}, i32* [[N]], align 4
 
   id x[2][n][3];
@@ -595,6 +600,9 @@
   // CHECK-NEXT: [[T0:%.*]] = mul nuw i64 2, [[DIM]]
  

[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

2018-02-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323952: [DebugInfo] Enable debug information for C99 VLA 
types (authored by s.desmalen, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D41698?vs=132275=132351#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41698

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/debug-info-vla.c
  cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp
  cfe/trunk/test/CodeGenCXX/vla-consruct.cpp
  cfe/trunk/test/CodeGenObjC/arc.m
  cfe/trunk/test/OpenMP/target_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
  cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
  cfe/trunk/test/OpenMP/target_simd_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_codegen.cpp
  cfe/trunk/test/OpenMP/target_teams_distribute_simd_codegen.cpp

Index: cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
@@ -555,6 +555,7 @@
 // CHECK-64:   store i32 %{{.+}}, i32* [[B_ADDR]],
 // CHECK-64:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_CADDR]],
 
+// CHECK-32:   store i32 %{{.+}}, i32* %vla_expr
 // CHECK-32:   store i32 %{{.+}}, i32* [[B_ADDR:%.+]],
 // CHECK-32:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_ADDR]],
 
Index: cfe/trunk/test/OpenMP/target_teams_distribute_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_teams_distribute_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_teams_distribute_codegen.cpp
@@ -564,6 +564,7 @@
 // CHECK-64:   store i32 %{{.+}}, i32* [[B_ADDR]],
 // CHECK-64:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_CADDR]],
 
+// CHECK-32:   store i32 %{{.+}}, i32* %vla_expr
 // CHECK-32:   store i32 %{{.+}}, i32* [[B_ADDR:%.+]],
 // CHECK-32:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_ADDR]],
 
Index: cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
@@ -528,6 +528,7 @@
 // CHECK-64:   store i32 %{{.+}}, i32* [[B_ADDR]],
 // CHECK-64:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_CADDR]],
 
+// CHECK-32:   store i32 %{{.+}}, i32* %vla_expr
 // CHECK-32:   store i32 %{{.+}}, i32* [[B_ADDR:%.+]],
 // CHECK-32:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_ADDR]],
 
Index: cfe/trunk/test/OpenMP/target_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_codegen.cpp
@@ -511,6 +511,7 @@
 // CHECK-64:   store i32 %{{.+}}, i32* [[B_ADDR]],
 // CHECK-64:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_CADDR]],
 
+// CHECK-32:   store i32 %{{.+}}, i32* %vla_expr
 // CHECK-32:   store i32 %{{.+}}, i32* [[B_ADDR:%.+]],
 // CHECK-32:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_ADDR]],
 
Index: cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
@@ -555,6 +555,7 @@
 // CHECK-64:   store i32 %{{.+}}, i32* [[B_ADDR]],
 // CHECK-64:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_CADDR]],
 
+// CHECK-32:   store i32 %{{.+}}, i32* %vla_expr
 // CHECK-32:   store i32 %{{.+}}, i32* [[B_ADDR:%.+]],
 // CHECK-32:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_ADDR]],
 
Index: cfe/trunk/test/OpenMP/target_teams_codegen.cpp
===
--- cfe/trunk/test/OpenMP/target_teams_codegen.cpp
+++ cfe/trunk/test/OpenMP/target_teams_codegen.cpp
@@ -553,6 +553,7 @@
 // CHECK-64:   store i32 %{{.+}}, i32* [[B_ADDR]],
 // CHECK-64:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_CADDR]],
 
+// CHECK-32:   store i32 %{{.+}}, i32* %vla_expr
 // CHECK-32:   store i32 %{{.+}}, i32* [[B_ADDR:%.+]],
 // CHECK-32:   [[B_CVAL:%.+]] = load i[[SZ]], i[[SZ]]* [[B_ADDR]],
 
Index: cfe/trunk/test/OpenMP/target_simd_codegen.cpp

[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

2018-02-01 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked an inline comment as done.
sdesmalen added a comment.

Thanks for your review @aprantl!


https://reviews.llvm.org/D41698



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


[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-01 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

You might doubt it, but having written the code I can tell you that it's the 
case. Shame on me for not writing a test, though.

I see the argument why this indentation is not necessary in exactly the case 
where the last parameter is multi-line and not wrapped to a new line itself: 
You always have some indentation anyway because of the preceding parameter on 
the same line.
However, for me the consistency is more important here, i.e.  achieving that we 
don't have a relative indentation change between:

  foo(a, bb +
 c);

and

  foo(a,
  bb +
  c);

This formatting can easily alter between these two when line length vary 
slightly and I think being able to pattern match that easily.
Yes, that means it is not consistent with:

  foo(bb +
  c);

But there is actually a substantial difference in structure and so, I think it 
is reasonable to not be consistent there.


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[clang-tools-extra] r323960 - [clangd] remove the unused code NFC.

2018-02-01 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Feb  1 05:06:58 2018
New Revision: 323960

URL: http://llvm.org/viewvc/llvm-project?rev=323960=rev
Log:
[clangd] remove the unused code NFC.

Modified:
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp?rev=323960=323959=323960=diff
==
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Thu Feb  
1 05:06:58 2018
@@ -53,9 +53,6 @@ MATCHER_P(LocationOffsets, Offsets, "")
   return arg.CanonicalDeclaration.StartOffset == Offsets.first &&
   arg.CanonicalDeclaration.EndOffset == Offsets.second - 1;
 }
-//MATCHER_P(FilePath, P, "") {
-  //return arg.CanonicalDeclaration.FilePath.contains(P);
-//}
 
 namespace clang {
 namespace clangd {


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


[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-01 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

> You might doubt it, but having written the code I can tell you that it's the 
> case.

Ok, you win :-)

> I see the argument why this indentation is not necessary in exactly the case 
> where the last parameter is multi-line and not wrapped to a new line itself: 
> You always have some indentation anyway because of the preceding parameter on 
> the same line.
>  However, for me the consistency is more important here, i.e. achieving that 
> we don't have a relative indentation change between:
>  [...] 
>  This formatting can easily alter between these two when line length vary 
> slightly and I think being able to pattern match that easily.

Not sure what you mean: a diff would not be trivial in either case...

> Yes, that means it is not consistent with:
> 
>   foo(bb +
>   c);
>
> 
> But there is actually a substantial difference in structure and so, I think 
> it is reasonable to not be consistent there.

It's reasonable from the perspective of the tool [i.e. to make the code of 
clang-format consistent], but IMHO not so consistent from the perspective of a 
user:
I (and most people I believe) would not manually add this seemingly unnecessary 
indentation, so I would prefer the tool to do the same; and fortunately it 
seems pretty trivial to implement.

Is there a way this can go in anyway, for exemple with a setting?


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[libcxx] r323971 - Remove ; use instead. See https://libcxx.llvm.org/TS_deprecation.html

2018-02-01 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Feb  1 06:54:25 2018
New Revision: 323971

URL: http://llvm.org/viewvc/llvm-project?rev=323971=rev
Log:
Remove ; use  instead. See 
https://libcxx.llvm.org/TS_deprecation.html

Removed:
libcxx/trunk/test/libcxx/experimental/optional/
libcxx/trunk/test/std/experimental/optional/
Modified:
libcxx/trunk/include/experimental/optional
libcxx/trunk/include/module.modulemap
libcxx/trunk/src/optional.cpp
libcxx/trunk/test/libcxx/double_include.sh.cpp
libcxx/trunk/test/libcxx/min_max_macros.sh.cpp

Modified: libcxx/trunk/include/experimental/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/optional?rev=323971=323970=323971=diff
==
--- libcxx/trunk/include/experimental/optional (original)
+++ libcxx/trunk/include/experimental/optional Thu Feb  1 06:54:25 2018
@@ -8,915 +8,4 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
-#define _LIBCPP_EXPERIMENTAL_OPTIONAL
-
-/*
-optional synopsis
-
-// C++1y
-
-namespace std { namespace experimental { inline namespace fundamentals_v1 {
-
-// 5.3, optional for object types
-template  class optional;
-
-// 5.4, In-place construction
-struct in_place_t{};
-constexpr in_place_t in_place{};
-
-// 5.5, No-value state indicator
-struct nullopt_t{see below};
-constexpr nullopt_t nullopt(unspecified);
-
-// 5.6, Class bad_optional_access
-class bad_optional_access;
-
-// 5.7, Relational operators
-template 
-  constexpr bool operator==(const optional&, const optional&);
-template 
-  constexpr bool operator!=(const optional&, const optional&);
-template 
-  constexpr bool operator<(const optional&, const optional&);
-template 
-  constexpr bool operator>(const optional&, const optional&);
-template 
-  constexpr bool operator<=(const optional&, const optional&);
-template 
-  constexpr bool operator>=(const optional&, const optional&);
-
-// 5.8, Comparison with nullopt
-template  constexpr bool operator==(const optional&, 
nullopt_t) noexcept;
-template  constexpr bool operator==(nullopt_t, const 
optional&) noexcept;
-template  constexpr bool operator!=(const optional&, 
nullopt_t) noexcept;
-template  constexpr bool operator!=(nullopt_t, const 
optional&) noexcept;
-template  constexpr bool operator<(const optional&, nullopt_t) 
noexcept;
-template  constexpr bool operator<(nullopt_t, const optional&) 
noexcept;
-template  constexpr bool operator<=(const optional&, 
nullopt_t) noexcept;
-template  constexpr bool operator<=(nullopt_t, const 
optional&) noexcept;
-template  constexpr bool operator>(const optional&, nullopt_t) 
noexcept;
-template  constexpr bool operator>(nullopt_t, const optional&) 
noexcept;
-template  constexpr bool operator>=(const optional&, 
nullopt_t) noexcept;
-template  constexpr bool operator>=(nullopt_t, const 
optional&) noexcept;
-
-// 5.9, Comparison with T
-template  constexpr bool operator==(const optional&, const T&);
-template  constexpr bool operator==(const T&, const optional&);
-template  constexpr bool operator!=(const optional&, const T&);
-template  constexpr bool operator!=(const T&, const optional&);
-template  constexpr bool operator<(const optional&, const T&);
-template  constexpr bool operator<(const T&, const optional&);
-template  constexpr bool operator<=(const optional&, const T&);
-template  constexpr bool operator<=(const T&, const optional&);
-template  constexpr bool operator>(const optional&, const T&);
-template  constexpr bool operator>(const T&, const optional&);
-template  constexpr bool operator>=(const optional&, const T&);
-template  constexpr bool operator>=(const T&, const optional&);
-
-// 5.10, Specialized algorithms
-template  void swap(optional&, optional&) noexcept(see 
below);
-template  constexpr optional make_optional(T&&);
-
-   template 
-   class optional
-   {
-   public:
- typedef T value_type;
-
- // 5.3.1, Constructors
- constexpr optional() noexcept;
- constexpr optional(nullopt_t) noexcept;
- optional(const optional&);
- optional(optional&&) noexcept(see below);
- constexpr optional(const T&);
- constexpr optional(T&&);
- template  constexpr explicit optional(in_place_t, 
Args&&...);
- template 
-   constexpr explicit optional(in_place_t, initializer_list, 
Args&&...);
-
- // 5.3.2, Destructor
- ~optional();
-
- // 5.3.3, Assignment
- optional& operator=(nullopt_t) noexcept;
- optional& operator=(const optional&);
- optional& operator=(optional&&) noexcept(see below);
- template  optional& 

[PATCH] D42693: [libcxx] Handle invalid escaped characters in POSIX regex

2018-02-01 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 132352.
miyuki edited the summary of this revision.
miyuki added a comment.

Updated __parse_QUOTED_CHAR_ERE. Added more test cases.


https://reviews.llvm.org/D42693

Files:
  include/regex
  test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp

Index: test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
===
--- test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
+++ test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp
@@ -19,11 +19,13 @@
 #include 
 #include "test_macros.h"
 
-static bool error_escape_thrown(const char *pat)
+static bool error_escape_thrown(const char *pat,
+std::regex_constants::syntax_option_type
+syntax = std::regex_constants::ECMAScript)
 {
 bool result = false;
 try {
-std::regex re(pat);
+std::regex re(pat, syntax);
 } catch (const std::regex_error ) {
 result = (ex.code() == std::regex_constants::error_escape);
 }
@@ -45,4 +47,58 @@
 assert(!error_escape_thrown("[\\cA]"));
 assert(!error_escape_thrown("\\cA"));
 
+const std::regex_constants::syntax_option_type basic =
+std::regex_constants::basic;
+
+assert(error_escape_thrown("\\a", basic));
+assert(error_escape_thrown("\\n", basic));
+assert(error_escape_thrown("\\t", basic));
+assert(error_escape_thrown("\\0", basic));
+assert(error_escape_thrown("\\/", basic));
+assert(error_escape_thrown("\\\n", basic));
+assert(error_escape_thrown("\\", basic));
+
+assert(!error_escape_thrown("[\\a]", basic));
+assert(!error_escape_thrown("\\(a\\)", basic));
+assert(!error_escape_thrown("\\(ab\\)\\1", basic));
+assert(!error_escape_thrown("a\\{1,2\\}", basic));
+assert(!error_escape_thrown("\\.", basic));
+assert(!error_escape_thrown("\\*", basic));
+
+const std::regex_constants::syntax_option_type extended =
+std::regex_constants::extended;
+
+assert(error_escape_thrown("\\a", extended));
+assert(error_escape_thrown("\\n", extended));
+assert(error_escape_thrown("\\t", extended));
+assert(error_escape_thrown("\\0", extended));
+assert(error_escape_thrown("(ab)\\1", extended));
+assert(error_escape_thrown("\\/", extended));
+assert(error_escape_thrown("\\\n", extended));
+assert(error_escape_thrown("\\", extended));
+
+assert(!error_escape_thrown("[\\a]", extended));
+assert(!error_escape_thrown("\\(a\\)", extended));
+assert(!error_escape_thrown("\\{\\}", extended));
+assert(!error_escape_thrown("\\.", extended));
+assert(!error_escape_thrown("\\*", extended));
+
+const std::regex_constants::syntax_option_type awk =
+std::regex_constants::awk;
+
+assert(error_escape_thrown("\\z", awk));
+assert(error_escape_thrown("[\\z]", awk));
+assert(error_escape_thrown("\\9", awk));
+assert(error_escape_thrown("\\\n", awk));
+assert(error_escape_thrown("\\", awk));
+
+assert(!error_escape_thrown("\\n", awk));
+assert(!error_escape_thrown("\\t", awk));
+assert(!error_escape_thrown("\\/", awk));
+assert(!error_escape_thrown("\\(a\\)", awk));
+assert(!error_escape_thrown("\\{\\}", awk));
+assert(!error_escape_thrown("\\0", awk));
+assert(!error_escape_thrown("\\1", awk));
+assert(!error_escape_thrown("\\.", awk));
+assert(!error_escape_thrown("\\*", awk));
 }
Index: include/regex
===
--- include/regex
+++ include/regex
@@ -3442,23 +3442,32 @@
 {
 if (__first != __last)
 {
-_ForwardIterator __temp = _VSTD::next(__first);
-if (__temp != __last)
+if (*__first == '\\')
 {
-if (*__first == '\\')
+_ForwardIterator __temp = _VSTD::next(__first);
+if (__temp == __last)
+__throw_regex_error();
+
+switch (*__temp)
 {
-switch (*__temp)
-{
-case '^':
-case '.':
-case '*':
-case '[':
-case '$':
-case '\\':
-__push_char(*__temp);
-__first = ++__temp;
+case '^':
+case '.':
+case '*':
+case '[':
+case '$':
+case '\\':
+__push_char(*__temp);
+__first = ++__temp;
+break;
+case '(':
+case ')':
+case '{':
+case '}':
+break;
+default:
+if (*__temp >= '1' && *__temp <= '9')
 break;
-}
+__throw_regex_error();
 }
 }
 }
@@ -3473,34 +3482,36 @@
 {
 if (__first != __last)
 {
-_ForwardIterator __temp = 

[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-01 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

I doubt this particular was intentional, esp. since this case never happens in 
the tests. I think it is more a side-effect of the (general) indent in "fake" 
parenthesis.
Here is an exemple:

Before this change:

  foo(a, bb +
 c);
  foo(b +
  c);
  foo(a,
  b +
  c,
  d);
  foo(b +
  c,
  d);

After this change:

  foo(a, bb +
 c);
  foo(b +
  c);
  foo(a,
  b +
  c,
  d);
  foo(b +
  c,
  d);

i.e. this patch only affect the 'first' scenario (e.g. wrapping expression in 
last argument) consistent with the second one (e.g. wrapping expression in 
first and only argument)


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[PATCH] D42361: [Tooling] Returns non-zero status code when files are skipped.

2018-02-01 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added inline comments.



Comment at: lib/Tooling/Tooling.cpp:404
 if (CompileCommandsForFile.empty()) {
   // FIXME: There are two use cases here: doing a fuzzy
   // "find . -name '*.cc' |xargs tool" match, where as a user I don't care

ioeric wrote:
> bkramer wrote:
> > This comment explains why the implementation doesn't error. Can you make 
> > sure the xargs use case is still working properly?
> I somehow missed the big `FIXME`... thanks for the catch! 
> 
> I don't think this is a very typical use case that should affect design 
> decision here, and I would expect `xargs` users to do something like `xargs 
> tool $@ || true` if they really want to ignore errors. WDYT?
Yeah. I think the only important thing is that xargs doesn't stop after the 
first error. But that seems to be the default behavior of xargs?


Repository:
  rC Clang

https://reviews.llvm.org/D42361



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


[PATCH] D42361: [Tooling] Returns non-zero status code when files are skipped.

2018-02-01 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: lib/Tooling/Tooling.cpp:404
 if (CompileCommandsForFile.empty()) {
   // FIXME: There are two use cases here: doing a fuzzy
   // "find . -name '*.cc' |xargs tool" match, where as a user I don't care

bkramer wrote:
> ioeric wrote:
> > bkramer wrote:
> > > This comment explains why the implementation doesn't error. Can you make 
> > > sure the xargs use case is still working properly?
> > I somehow missed the big `FIXME`... thanks for the catch! 
> > 
> > I don't think this is a very typical use case that should affect design 
> > decision here, and I would expect `xargs` users to do something like `xargs 
> > tool $@ || true` if they really want to ignore errors. WDYT?
> Yeah. I think the only important thing is that xargs doesn't stop after the 
> first error. But that seems to be the default behavior of xargs?
Looks like this is the case, from the manual:
```
If  any  invocation of the command exits with a status of 255, xargs will stop 
immediately without reading any further input.  An error message is issued on 
stderr when this happens.
```

Should I just remove the FIXME?


Repository:
  rC Clang

https://reviews.llvm.org/D42361



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


[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-01 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I don't mean trivial with a diff. What I mean is, users will find it surprising 
if whether or not a parameter gets wrapped leads to a different indentation 
internal to that parameter. I have not heard of a single user that would be 
surprised by this extra indentation.

I don't think this is worth an extra setting. I'll be somewhat resistant to 
getting this in because a) I think it's wrong and b) never change a running 
system (users will have at least gotten used to it). But I also don't want to 
assume total power here, I do not care that much about this issue. I'll add 
some other clang-format authors as reviewers here and you can also feel free to 
add more people. If the common opinion is that your change is good, I am happy 
to move forward.


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[PATCH] D42755: [libcxx] Fix last_write_time tests for filesystems that don't support very small times.

2018-02-01 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld requested changes to this revision.
Hahnfeld added a comment.
This revision now requires changes to proceed.

Can you please add a summary that describes which filesystem this problem can 
be seen with? I think outside people can't access rdar tickets, so I can only 
guess that it's related to APFS? Further guessing the filesystem supports 
negative timestamps in general but not `file_time_type::min()` (which probably 
is `-2 ** 63`)?

In https://reviews.llvm.org/D42755#993784, @vsapsai wrote:

> Don't like removing `new_time = file_time_type::min() + MicroSec(1);` part of 
> the `test_write_min_time` but it escapes `file_time_type::min()` check. If 
> somebody can explain the purpose of this test, I'd be glad to preserve it for 
> filesystems that support very small times.


I think the idea was to have something slightly larger than 
`file_time_type::min()` which generally makes sense for testing corner cases. 
However, there is no equivalent check for `file_time_type::max()` so I'd like 
to hear @EricWF whether we should keep it.


https://reviews.llvm.org/D42755



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


[PATCH] D42693: [libcxx] Handle invalid escaped characters in POSIX regex

2018-02-01 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added inline comments.



Comment at: include/regex:3490
 {
 switch (*__temp)
 {

mclow.lists wrote:
> Do we need any more cases here?
Probably not, but we should throw an exception here as well.


https://reviews.llvm.org/D42693



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


[clang-tools-extra] r323957 - [clangd] Fix URI scheme conflict and an unused variable warning in tests. NFC

2018-02-01 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Feb  1 04:44:52 2018
New Revision: 323957

URL: http://llvm.org/viewvc/llvm-project?rev=323957=rev
Log:
[clangd] Fix URI scheme conflict and an unused variable warning in tests. NFC

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/unittests/clangd/URITests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=323957=323956=323957=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Feb  1 04:44:52 2018
@@ -44,7 +44,8 @@ public:
 llvm::SmallVector Path(Body.begin(), Body.end());
 path::native(Path);
 auto Err = fs::make_absolute(TestDir, Path);
-assert(!Err);
+if (Err)
+  llvm_unreachable("Failed to make absolute path in test scheme.");
 return std::string(Path.begin(), Path.end());
   }
 

Modified: clang-tools-extra/trunk/unittests/clangd/URITests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/URITests.cpp?rev=323957=323956=323957=diff
==
--- clang-tools-extra/trunk/unittests/clangd/URITests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/URITests.cpp Thu Feb  1 04:44:52 
2018
@@ -49,7 +49,7 @@ public:
   }
 };
 
-const char *TestScheme::Scheme = "test";
+const char *TestScheme::Scheme = "unittest";
 const char *TestScheme::TestRoot = "/test-root/";
 
 static URISchemeRegistry::Add X(TestScheme::Scheme, "Test schema");
@@ -166,7 +166,7 @@ TEST(URITest, Resolve) {
 #else
   EXPECT_EQ(resolveOrDie(parseOrDie("file:/a/b/c")), "/a/b/c");
   EXPECT_EQ(resolveOrDie(parseOrDie("file://auth/a/b/c")), "/a/b/c");
-  EXPECT_EQ(resolveOrDie(parseOrDie("test:a/b/c"), "/dir/test-root/x/y/z"),
+  EXPECT_EQ(resolveOrDie(parseOrDie("unittest:a/b/c"), "/dir/test-root/x/y/z"),
 "/dir/test-root/a/b/c");
   EXPECT_THAT(resolveOrDie(parseOrDie("file://au%3dth/%28x%29/y/%20z")),
   "/(x)/y/ z");


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


[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-01 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Ah, Manuel and Krasimir are already on this thread, maybe they can comment? I 
also added Chandler and Sam who I know care about formatting somewhat.


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[PATCH] D42645: New simple Checker for mmap calls

2018-02-01 Thread David CARLIER via Phabricator via cfe-commits
devnexen added a comment.

Another example with pcre2, more specifically its JIT engine

  In file included from 
/home/dcarlier/Contribs/php-src/ext/pcre/pcre2lib/pcre2_jit_compile.c:78:
  In file included from 
/home/dcarlier/Contribs/php-src/ext/pcre/pcre2lib/sljit/sljitLir.c:261:
  
/home/dcarlier/Contribs/php-src/ext/pcre/pcre2lib/sljit/sljitExecAllocator.c:102:11:
 warning: Both PROT_WRITE and PROT_EXEC flags had been set. It can leads to 
exploitable memory regions, overwritten with malicious code
  retval = mmap(NULL, size, PROT_READ | PROT_WRITE | PROT_EXEC, 
MAP_PRIVATE | MAP_ANON, -1, 0);
   
^~~
  In file included from 
/home/dcarlier/Contribs/php-src/ext/pcre/pcre2lib/pcre2_jit_compile.c:78:
  In file included from 
/home/dcarlier/Contribs/php-src/ext/pcre/pcre2lib/sljit/sljitLir.c:1737:


Repository:
  rC Clang

https://reviews.llvm.org/D42645



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


[PATCH] D34249: [libc++] Don't use UTIME_OMIT to detect utimensat on Apple

2018-02-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

The powers that be updated the SDK on the chromium clang bots, so we need some 
solution for this issue soon.

The approach in this patch should work, but it seems conservative. Now libc++ 
only uses utimesat() if it's built with a deployment target of macOS 10.13. But 
if we were to set a deployment target of 10.12 and then _run_ on 10.13, we 
could use utimesat() as well, even though this patch currently doesn't. (Apple 
bundles libc++ with the system, so it's not a meaningful difference for 
Apple-built libc++'s, but applications can build libc++ themselves and 
statically link to it, and for those it would make a difference.)

https://clang.llvm.org/docs/LanguageExtensions.html#objective-c-available has 
some words on it (except that `@available` is spelled `__builtin_available` in 
non-Objective-C code) -- thoughts on using runtime detection of utimes() 
instead? That's how things are supposed to work on the Apple platforms.


https://reviews.llvm.org/D34249



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


[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2018-02-01 Thread Simon Marchi via Phabricator via cfe-commits
simark added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:302
 
+// FIXME: This function needs to be properly tested.
+void ClangdLSPServer::onChangeConfiguration(

ilya-biryukov wrote:
> simark wrote:
> > simark wrote:
> > > ilya-biryukov wrote:
> > > > simark wrote:
> > > > > ilya-biryukov wrote:
> > > > > > simark wrote:
> > > > > > > ilya-biryukov wrote:
> > > > > > > > Are you planning to to address this FIXME before checking the 
> > > > > > > > code in?
> > > > > > > Following what you said here:
> > > > > > > 
> > > > > > > https://reviews.llvm.org/D39571?id=124024#inline-359345
> > > > > > > 
> > > > > > > I have not really looked into what was wrong with the test, and 
> > > > > > > what is missing in the infrastructure to make it work.  But I 
> > > > > > > assumed that the situation did not change since then.  Can you 
> > > > > > > enlighten me on what the problem was, and what is missing?
> > > > > > We usually write unittests for that kind of thing, since they allow 
> > > > > > to plug an in-memory filesystem, but we only test `ClangdServer` 
> > > > > > (examples are in `unittests/clangd/ClangdTests.cpp`). 
> > > > > > `ClangdLSPServer` does not allow to plug in a virtual filesystem 
> > > > > > (vfs). Even if we add vfs, it's still hard to unit-test because 
> > > > > > we'll have to match the json input/output directly.
> > > > > > 
> > > > > > This leaves us with an option of a lit test that runs `clangd` 
> > > > > > directly, similar to tests in `test/clangd`.
> > > > > > The lit test would need to create a temporary directory, create 
> > > > > > proper `compile_commands.json` there, then send the LSP commands 
> > > > > > with the path to the test to clangd.
> > > > > > One major complication is that in LSP we have to specify the size 
> > > > > > of each message, but in our case the size would change depending on 
> > > > > > created temp path. It means we'll have to patch the test input to 
> > > > > > setup proper paths and message sizes.
> > > > > > If we choose to go down this path, 
> > > > > > `clang-tools-extra/test/clang-tidy/vfsoverlay.cpp` does a similar 
> > > > > > setup (create temp-dir, patch up some configuration files to point 
> > > > > > into the temp directory, etc) and could be used as a starting point.
> > > > > > 
> > > > > > It's not impossible to write that test, it's just a bit involved. 
> > > > > > Having a test would be nice, though, to ensure we don't break this 
> > > > > > method while doing other things. Especially given that this 
> > > > > > functionality is not used anywhere in clangd.
> > > > > > We usually write unittests for that kind of thing, since they allow 
> > > > > > to plug an in-memory filesystem, but we only test ClangdServer 
> > > > > > (examples are in unittests/clangd/ClangdTests.cpp). ClangdLSPServer 
> > > > > > does not allow to plug in a virtual filesystem (vfs). Even if we 
> > > > > > add vfs, it's still hard to unit-test because we'll have to match 
> > > > > > the json input/output directly.
> > > > > 
> > > > > What do you mean by "we'll have to match the json input/output 
> > > > > directly"?  That we'll have to match the complete JSON output 
> > > > > textually?  Couldn't the test parse the JSON into some data 
> > > > > structures, then we could assert specific things, like that this 
> > > > > particular field is present and contains a certain substring, for 
> > > > > example?
> > > > > 
> > > > > > This leaves us with an option of a lit test that runs clangd 
> > > > > > directly, similar to tests in test/clangd.
> > > > > > The lit test would need to create a temporary directory, create 
> > > > > > proper compile_commands.json there, then send the LSP commands with 
> > > > > > the path to the test to clangd.
> > > > > > One major complication is that in LSP we have to specify the size 
> > > > > > of each message, but in our case the size would change depending on 
> > > > > > created temp path. It means we'll have to patch the test input to 
> > > > > > setup proper paths and message sizes.
> > > > > > If we choose to go down this path, 
> > > > > > clang-tools-extra/test/clang-tidy/vfsoverlay.cpp does a similar 
> > > > > > setup (create temp-dir, patch up some configuration files to point 
> > > > > > into the temp directory, etc) and could be used as a starting point.
> > > > > 
> > > > > Ok, I see the complication with the Content-Length.  I am not 
> > > > > familiar with lit yet, so I don't know what it is capable of.  But 
> > > > > being able to craft and send arbitrary LSP messages would certainly 
> > > > > be helpful in the future for all kinds of black box test, so having a 
> > > > > framework that allows to do this would be helpful, I think.  I'm not 
> > > > > familiar enough with the ecosystem to do this right now, but I'll 
> > > > > keep it in mind.
> > > > > 
> > > > > One question about this particular test.  Would there be some race 
> > > > > 

[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-01 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

I am against this change. The current behavior here is intentional and IMO more 
consistent. If there is more than one precedence level in a set of parentheses, 
we add the additional indentation. If you don't like it, surround it with extra 
parentheses.

Generally, it'd be useful to have a "before" and "after" example in the patch 
description. That way, we can get more feedback from other people more easily.


Repository:
  rC Clang

https://reviews.llvm.org/D42787



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


[PATCH] D42729: clang-format: Fix formatting of function body followed by semicolon

2018-02-01 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

> I don't think cases where there is only a semicolon-less macro are 
> particularly frequent/important either. You probably could even add a 
> semicolon in those cases, right? How frequent are such cases in your 
> codebase? Either way, they aren't fixed by this patch, so they aren't a good 
> reason to move forward with it.

Adding a semicolon works for indentation and behavior, but leads to compiler 
warning.
So a proper fix would require to change the macro, which can easily be tricky 
with macros containings branches or loops...

It should not happen that often, but in reality it actually happens often 
enough that I found the bug while simply testing clang-format...

> I still believe that this patch adds complexity for very little gain. And I 
> am not even sure it is correct. 
> isFunctionDeclarationName/getFunctionParameterList is just yet another 
> heuristic that might go wrong. And it might go wrong in both ways. You might 
> still miss some cases and you might start incorrectly formatting stuff as 
> functions. Fundamentally clang-format just doesn't have enough info to do 
> this correctly.

As such, it does not add such complexity I think, but indeed it is not 
completely correct: it works only in the case where no line breaks are expected 
around the body (since it is still parsed as a single UnwrappedLine). So it is 
a slight improvement, but not a complete fix.

`isFunctionDeclarationName()` is an heuristic as well, but provides better 
result and does not break the existing one (since there are actually quite a 
few tests, and none get broken by this patch :-) )

I think "overall" clang-format has enough information for this case, it is just 
not available at the right time: Unwrapping is done first, then token and 
matching parenthesis are analysed and lines anotated, and these token 
anotations are needed to improve the unwrapping behavior...
I would really want to call `isFunctionDeclarationName()` from 
`UnwrappedLineParser::calculateBraceTypes()`, but parenthesis matching, nesting 
level and operators identification are not available yet.

> ".. which can easily be overlooked". If they are overlooked, nobody cares 
> about the space either, so no harm done ;).

We want to use a formatter to ensure the code is consistent: e.g. to ensure 
things that may be overlooked by a human are actually formatted according to 
the rules.
We want people to trust the tool to do the right thing, so it is best to avoid 
as many errors as possible...


Repository:
  rC Clang

https://reviews.llvm.org/D42729



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


[PATCH] D42787: clang-format: do not add extra indent when wrapping last parameter

2018-02-01 Thread Francois Ferrand via Phabricator via cfe-commits
Typz created this revision.
Typz added reviewers: krasimir, djasper, klimek.

There should be no extra indent when wrapping only the expression used
as last argument. This is consistent with the behavior when the first
(and only) argument's expression is wrapped.

  foo(a, bb +
 c);
  foo(b +
  c);

This does not affect all other cases, where the argument itself is
wrapped:

  foo(a,
  b +
  c,
  d);
  foo(b +
  c,
  d);


Repository:
  rC Clang

https://reviews.llvm.org/D42787

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -3998,6 +3998,21 @@
   verifyFormat("a(aa +\n"
"  aa,\n"
"  aa);");
+  verifyFormat(
+  "a(aa +\n"
+  "  aa) {}");
+  verifyFormat(
+  "a(aa +\n"
+  "  aa,\n"
+  "  b) {}");
+  verifyFormat(
+  "a(b, aaa +\n"
+  " aaa) {}");
+  verifyFormat(
+  "a(b,\n"
+  "  aaa +\n"
+  "  aaa,\n"
+  "  c) {}");
 
   // Indent consistently independent of call expression and unary operator.
   verifyFormat("aaa(bbb(\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1094,6 +1094,7 @@
   bool SkipFirstExtraIndent =
   (Previous && (Previous->opensScope() ||
 Previous->isOneOf(tok::semi, tok::kw_return) ||
+(Previous->is(tok::comma) && !Newline) ||
 (Previous->getPrecedence() == prec::Assignment &&
  Style.AlignOperands) ||
 Previous->is(TT_ObjCMethodExpr)));


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -3998,6 +3998,21 @@
   verifyFormat("a(aa +\n"
"  aa,\n"
"  aa);");
+  verifyFormat(
+  "a(aa +\n"
+  "  aa) {}");
+  verifyFormat(
+  "a(aa +\n"
+  "  aa,\n"
+  "  b) {}");
+  verifyFormat(
+  "a(b, aaa +\n"
+  " aaa) {}");
+  verifyFormat(
+  "a(b,\n"
+  "  aaa +\n"
+  "  aaa,\n"
+  "  c) {}");
 
   // Indent consistently independent of call expression and unary operator.
   verifyFormat("aaa(bbb(\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1094,6 +1094,7 @@
   bool SkipFirstExtraIndent =
   (Previous && (Previous->opensScope() ||
 Previous->isOneOf(tok::semi, tok::kw_return) ||
+(Previous->is(tok::comma) && !Newline) ||
 (Previous->getPrecedence() == prec::Assignment &&
  Style.AlignOperands) ||
 Previous->is(TT_ObjCMethodExpr)));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42035: [clang-format] Fixup #include guard indents after parseFile()

2018-02-01 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw added inline comments.



Comment at: lib/Format/UnwrappedLineParser.cpp:244
   PPBranchLevel = -1;
-  IfNdefCondition = nullptr;
-  FoundIncludeGuardStart = false;
-  IncludeGuardRejected = false;
+  IncludeGuard = IG_Inited;
+  IncludeGuardToken = nullptr;

Hm. From self review, I think this should be:

IncludeGuard = Style.IndentPPDirectives == FormatStyle::PPDIS_None ? 
IG_Rejected : IG_Inited;



Comment at: lib/Format/UnwrappedLineParser.cpp:736
   bool MaybeIncludeGuard = IfNDef;
-  if (!IncludeGuardRejected && !FoundIncludeGuardStart && MaybeIncludeGuard) {
+  if (IncludeGuard == IG_Inited && MaybeIncludeGuard) {
 for (auto  : Lines) {

technically I could drop the braces opened on this line. Would you like me to 
do that?


Repository:
  rC Clang

https://reviews.llvm.org/D42035



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


[PATCH] D42729: clang-format: Fix formatting of function body followed by semicolon

2018-02-01 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

- Of course you find all sorts of errors while testing clang-format on a 
large-enough codebase. That doesn't mean that users run into them much.
- We have had about 10k clang-format users internally for several years. The 
semicolon issue comes up but really rarely and if it does, people happily fix 
their code not blaming clang-format.

Unrelated, my point remains that setting BlockKind in TokenAnnotator is bad 
enough that I wouldn't want to do it for reaping this small benefit. And I 
can't see how you could easily achieve the same thing without doing that.


Repository:
  rC Clang

https://reviews.llvm.org/D42729



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


[PATCH] D42035: [clang-format] Fixup #include guard indents after parseFile()

2018-02-01 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw updated this revision to Diff 132394.
mzeren-vmw added a comment.

- Add comments to IncludeGuardState.
- Fix re-initialization of IncludeGuard in UnwrappedLineParser::reset.
- Remove unnecessary block after if.
- Rebase


Repository:
  rC Clang

https://reviews.llvm.org/D42035

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -2547,6 +2547,20 @@
"#elif FOO\n"
"#endif",
Style);
+  // Non-identifier #define after potential include guard.
+  verifyFormat("#ifndef FOO\n"
+   "#  define 1\n"
+   "#endif\n",
+   Style);
+  // #if closes past last non-preprocessor line.
+  verifyFormat("#ifndef FOO\n"
+   "#define FOO\n"
+   "#if 1\n"
+   "int i;\n"
+   "#  define A 0\n"
+   "#endif\n"
+   "#endif\n",
+   Style);
   // FIXME: This doesn't handle the case where there's code between the
   // #ifndef and #define but all other conditions hold. This is because when
   // the #define line is parsed, UnwrappedLineParser::Lines doesn't hold the
Index: lib/Format/UnwrappedLineParser.h
===
--- lib/Format/UnwrappedLineParser.h
+++ lib/Format/UnwrappedLineParser.h
@@ -248,10 +248,23 @@
   // sequence.
   std::stack PPChainBranchIndex;
 
-  // Contains the #ifndef condition for a potential include guard.
-  FormatToken *IfNdefCondition;
-  bool FoundIncludeGuardStart;
-  bool IncludeGuardRejected;
+  // Include guard search state. Used to fixup preprocessor indent levels
+  // so that include guards do not participate in indentation.
+  enum IncludeGuardState {
+IG_Inited,   // Search started, looking for #ifndef.
+IG_IfNdefed, // #ifndef found, IncludeGuardToken points to condition.
+IG_Defined,  // Matching #define found, checking other requirements.
+IG_Found,// All requirements met, need to fix indents.
+IG_Rejected, // Search failed or never started.
+  };
+
+  // Current state of include guard search.
+  IncludeGuardState IncludeGuard;
+
+  // Points to the #ifndef condition for a potential include guard. Null unless
+  // IncludeGuardState == IG_IfNdefed.
+  FormatToken *IncludeGuardToken;
+
   // Contains the first start column where the source begins. This is zero for
   // normal source code and may be nonzero when formatting a code fragment that
   // does not start at the beginning of the file.
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -234,14 +234,17 @@
   CurrentLines(), Style(Style), Keywords(Keywords),
   CommentPragmasRegex(Style.CommentPragmas), Tokens(nullptr),
   Callback(Callback), AllTokens(Tokens), PPBranchLevel(-1),
-  IfNdefCondition(nullptr), FoundIncludeGuardStart(false),
-  IncludeGuardRejected(false), FirstStartColumn(FirstStartColumn) {}
+  IncludeGuard(Style.IndentPPDirectives == FormatStyle::PPDIS_None
+   ? IG_Rejected
+   : IG_Inited),
+  IncludeGuardToken(nullptr), FirstStartColumn(FirstStartColumn) {}
 
 void UnwrappedLineParser::reset() {
   PPBranchLevel = -1;
-  IfNdefCondition = nullptr;
-  FoundIncludeGuardStart = false;
-  IncludeGuardRejected = false;
+  IncludeGuard = Style.IndentPPDirectives == FormatStyle::PPDIS_None
+ ? IG_Rejected
+ : IG_Inited;
+  IncludeGuardToken = nullptr;
   Line.reset(new UnwrappedLine);
   CommentsBeforeNextToken.clear();
   FormatTok = nullptr;
@@ -264,6 +267,14 @@
 
 readToken();
 parseFile();
+
+// If we found an include guard then all preprocessor directives (other than
+// the guard) are over-indented by one.
+if (IncludeGuard == IG_Found)
+  for (auto  : Lines)
+if (Line.InPPDirective && Line.Level > 0)
+  --Line.Level;
+
 // Create line with eof token.
 pushToken(FormatTok);
 addUnwrappedLine();
@@ -724,26 +735,27 @@
   // If there's a #ifndef on the first line, and the only lines before it are
   // comments, it could be an include guard.
   bool MaybeIncludeGuard = IfNDef;
-  if (!IncludeGuardRejected && !FoundIncludeGuardStart && MaybeIncludeGuard) {
+  if (IncludeGuard == IG_Inited && MaybeIncludeGuard)
 for (auto  : Lines) {
   if (!Line.Tokens.front().Tok->is(tok::comment)) {
 MaybeIncludeGuard = false;
-IncludeGuardRejected = true;
+IncludeGuard = IG_Rejected;
 break;
   }
 }
-  }
   --PPBranchLevel;
   parsePPUnknown();
   ++PPBranchLevel;
-  if (!IncludeGuardRejected && 

[PATCH] D42704: [clang-format] Do not break Objective-C string literals inside array literals

2018-02-01 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

Ping! Any comments?


Repository:
  rC Clang

https://reviews.llvm.org/D42704



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


[PATCH] D42796: [clangd] Skip inline namespace when collecting scopes for index symbols.

2018-02-01 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/index/SymbolCollector.cpp:69
+// qualifier. Inline namespaces and unscoped enums are skipped.
+llvm::Expected getScope(const NamedDecl *ND) {
+  llvm::SmallVector Contexts;

There is a `SuppressUnwrittenScope` option in `PrintingPolicy`,  I think we can 
probably use `printQualifiedName` with our customized policy (setting 
`SuppressUnwrittenScope` to true) here.



Comment at: clangd/index/SymbolCollector.cpp:195
 llvm::SmallString<128> USR;
+if (ND->getIdentifier() == nullptr)
+  return true;

Consider moving to `shouldFilterDecl`? We also have a check `if 
(ND->getDeclName().isEmpty())` there, which I assume does similar thing. 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42796



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


[PATCH] D42530: Clang permits assignment to vector/extvector elements in a const method

2018-02-01 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In fact we have here another problem: it is not an attempt to assign to const 
variable but it is an attempt to use the field assingment inside const  method: 
I'm working on it.


https://reviews.llvm.org/D42530



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


[PATCH] D42800: Let CUDA toolchain support amdgpu target

2018-02-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/Basic/Targets/AMDGPU.cpp:437
+  case CudaArch::UNKNOWN:
+assert(false && "No GPU arch when compiling CUDA device code.");
+return "";

llvm_unreachable



Comment at: lib/Driver/ToolChains/Cuda.cpp:359-361
+  addBCLib(C, Args, CmdArgs, LibraryPaths, "opencl.amdgcn.bc");
+  addBCLib(C, Args, CmdArgs, LibraryPaths, "ockl.amdgcn.bc");
+  addBCLib(C, Args, CmdArgs, LibraryPaths, "irif.amdgcn.bc");

Why is this done under an NVPTX:: class



Comment at: lib/Driver/ToolChains/Cuda.cpp:390
+  else {
+OptArgs.push_back(Args.MakeArgString("-O2"));
+OptArgs.push_back("-S");

Why is this hardcoded?


https://reviews.llvm.org/D42800



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


[PATCH] D42736: [DebugInfo] Improvements to representation of enumeration types (PR36168)

2018-02-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: test/CodeGen/debug-info-enum.cpp:2
+// RUN: %clang -target x86_64-linux -g -S -emit-llvm -o - %s | FileCheck %s
+enum class E0 : signed char {
+  A0 = -128,

Could you summarize the purpose of each of these tests (possibly in a comment 
above the enum in each case) - there look to be more test cases than I'd 
imagine being necessary, but I haven't carefully analyzed them.

For example: I wouldn't expect to test every integer type, if the code handling 
them is general enough to be demonstrated by one or two cases?



Comment at: test/CodeGen/debug-info-enum.cpp:6-10
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0"
+// CHECK-SAME: flags: DIFlagFixedEnum
+// CHECK: !DIBasicType(name: "signed char", size: 8, encoding: 
DW_ATE_signed_char)
+// CHECK: !DIEnumerator(name: "A0", value: -128)
+// CHECK: !DIEnumerator(name: "B0", value: 127)

Rather than relying on specific ordering of output, generally you should test 
that the actual references across different metadata records are correct (eg: 
check that the DICompositeType's member list elements are the DIEnumerators 
(use named matches, rather than hardcoding the metadata node numbers))

Though, admittedly, this is a lot easier to read as-is. 



Comment at: test/CodeGen/debug-info-enum.cpp:66
+// CHECK-SAME: baseType: ![[INT]]
+// CHECK-NOT: flags: DIFlagFixedEnum
+// CHECK: !DIEnumerator(name: "A8", value: -128)

Probably drop the "flags: " part of this NOT check - so that if other flags are 
added, this won't be overly constrained (eg: if this type ended up with "flags: 
X | DIFlagFixedEnum" this NOT check as-is wouldn't catch the regression)


https://reviews.llvm.org/D42736



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


[PATCH] D42803: [clangd] Log dropped diagnostics.

2018-02-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/ClangdUnit.cpp:182
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+

does Message include file:line? we probably want that in the log line.



Comment at: clangd/ClangdUnit.cpp:186
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+log("Ignored diagnostic outside main file: " + Twine(Message));
 return llvm::None;

Agree this is useful.

Have we turned off the diagnostics limit (or will we?) a misconfig of e.g. C vs 
C++ parsing of a header seems like it could produce 1000+ log lines from 
preamble that we should probably avoid somehow.
(Maybe even avoid paying to format)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42803



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


[PATCH] D42803: [clangd] Log dropped diagnostics.

2018-02-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE323992: [clangd] Log dropped diagnostics. (authored by 
ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42803?vs=132430=132432#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42803

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -178,15 +179,30 @@
 llvm::Optional toClangdDiag(const clang::Diagnostic ,
 DiagnosticsEngine::Level Level,
 const LangOptions ) {
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+
   if (!D.hasSourceManager() || !D.getLocation().isValid() ||
-  !D.getSourceManager().isInMainFile(D.getLocation()))
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+
+SmallString<64> Location;
+if (D.hasSourceManager() && D.getLocation().isValid()) {
+  auto  = D.getSourceManager();
+  auto Loc = SourceMgr.getFileLoc(D.getLocation());
+  llvm::raw_svector_ostream OS(Location);
+  Loc.print(OS, SourceMgr);
+} else {
+  Location = "";
+}
+
+log(llvm::formatv("Ignored diagnostic outside main file. {0}: {1}",
+  Location, Message));
 return llvm::None;
+  }
 
   DiagWithFixIts Result;
   Result.Diag.range = diagnosticRange(D, LangOpts);
   Result.Diag.severity = getSeverity(Level);
-  SmallString<64> Message;
-  D.FormatDiagnostic(Message);
   Result.Diag.message = Message.str();
   for (const FixItHint  : D.getFixItHints())
 Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -178,15 +179,30 @@
 llvm::Optional toClangdDiag(const clang::Diagnostic ,
 DiagnosticsEngine::Level Level,
 const LangOptions ) {
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+
   if (!D.hasSourceManager() || !D.getLocation().isValid() ||
-  !D.getSourceManager().isInMainFile(D.getLocation()))
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+
+SmallString<64> Location;
+if (D.hasSourceManager() && D.getLocation().isValid()) {
+  auto  = D.getSourceManager();
+  auto Loc = SourceMgr.getFileLoc(D.getLocation());
+  llvm::raw_svector_ostream OS(Location);
+  Loc.print(OS, SourceMgr);
+} else {
+  Location = "";
+}
+
+log(llvm::formatv("Ignored diagnostic outside main file. {0}: {1}",
+  Location, Message));
 return llvm::None;
+  }
 
   DiagWithFixIts Result;
   Result.Diag.range = diagnosticRange(D, LangOpts);
   Result.Diag.severity = getSeverity(Level);
-  SmallString<64> Message;
-  D.FormatDiagnostic(Message);
   Result.Diag.message = Message.str();
   for (const FixItHint  : D.getFixItHints())
 Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r323155 - Introduce the "retpoline" x86 mitigation technique for variant #2 of the speculative execution vulnerabilities disclosed today, specifically identified by CVE-2017-5715, "Branch Target

2018-02-01 Thread Chandler Carruth via cfe-commits
+Hans Wennborg  +tstel...@redhat.com


So the retpoline patch series we should get back ported start with this
revision and have two follow ups:
r323155
r323288
r323915

+Reid Kleckner  was going to look at doing the (likely more
involved) backport to the 5 branch

On Mon, Jan 22, 2018 at 2:06 PM Chandler Carruth via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: chandlerc
> Date: Mon Jan 22 14:05:25 2018
> New Revision: 323155
>
> URL: http://llvm.org/viewvc/llvm-project?rev=323155=rev
> Log:
> Introduce the "retpoline" x86 mitigation technique for variant #2 of the
> speculative execution vulnerabilities disclosed today, specifically
> identified by CVE-2017-5715, "Branch Target Injection", and is one of the
> two halves to Spectre..
>
> Summary:
> First, we need to explain the core of the vulnerability. Note that this
> is a very incomplete description, please see the Project Zero blog post
> for details:
>
> https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html
>
> The basis for branch target injection is to direct speculative execution
> of the processor to some "gadget" of executable code by poisoning the
> prediction of indirect branches with the address of that gadget. The
> gadget in turn contains an operation that provides a side channel for
> reading data. Most commonly, this will look like a load of secret data
> followed by a branch on the loaded value and then a load of some
> predictable cache line. The attacker then uses timing of the processors
> cache to determine which direction the branch took *in the speculative
> execution*, and in turn what one bit of the loaded value was. Due to the
> nature of these timing side channels and the branch predictor on Intel
> processors, this allows an attacker to leak data only accessible to
> a privileged domain (like the kernel) back into an unprivileged domain.
>
> The goal is simple: avoid generating code which contains an indirect
> branch that could have its prediction poisoned by an attacker. In many
> cases, the compiler can simply use directed conditional branches and
> a small search tree. LLVM already has support for lowering switches in
> this way and the first step of this patch is to disable jump-table
> lowering of switches and introduce a pass to rewrite explicit indirectbr
> sequences into a switch over integers.
>
> However, there is no fully general alternative to indirect calls. We
> introduce a new construct we call a "retpoline" to implement indirect
> calls in a non-speculatable way. It can be thought of loosely as
> a trampoline for indirect calls which uses the RET instruction on x86.
> Further, we arrange for a specific call->ret sequence which ensures the
> processor predicts the return to go to a controlled, known location. The
> retpoline then "smashes" the return address pushed onto the stack by the
> call with the desired target of the original indirect call. The result
> is a predicted return to the next instruction after a call (which can be
> used to trap speculative execution within an infinite loop) and an
> actual indirect branch to an arbitrary address.
>
> On 64-bit x86 ABIs, this is especially easily done in the compiler by
> using a guaranteed scratch register to pass the target into this device.
> For 32-bit ABIs there isn't a guaranteed scratch register and so several
> different retpoline variants are introduced to use a scratch register if
> one is available in the calling convention and to otherwise use direct
> stack push/pop sequences to pass the target address.
>
> This "retpoline" mitigation is fully described in the following blog
> post: https://support.google.com/faqs/answer/7625886
>
> We also support a target feature that disables emission of the retpoline
> thunk by the compiler to allow for custom thunks if users want them.
> These are particularly useful in environments like kernels that
> routinely do hot-patching on boot and want to hot-patch their thunk to
> different code sequences. They can write this custom thunk and use
> `-mretpoline-external-thunk` *in addition* to `-mretpoline`. In this
> case, on x86-64 thu thunk names must be:
> ```
>   __llvm_external_retpoline_r11
> ```
> or on 32-bit:
> ```
>   __llvm_external_retpoline_eax
>   __llvm_external_retpoline_ecx
>   __llvm_external_retpoline_edx
>   __llvm_external_retpoline_push
> ```
> And the target of the retpoline is passed in the named register, or in
> the case of the `push` suffix on the top of the stack via a `pushl`
> instruction.
>
> There is one other important source of indirect branches in x86 ELF
> binaries: the PLT. These patches also include support for LLD to
> generate PLT entries that perform a retpoline-style indirection.
>
> The only other indirect branches remaining that we are aware of are from
> precompiled runtimes (such as crt0.o and similar). The ones we have
> found are not really attackable, and so 

[PATCH] D42530: Clang permits assignment to vector/extvector elements in a const method

2018-02-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

That's still just const-propagation.  The const qualifier on the pointee type 
of this should propagate to the l-value resulting from the member access, and 
the vector-specific projection logic should continue to propagate const to the 
type of the element l-value.


https://reviews.llvm.org/D42530



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


[PATCH] D17700: [clang-format] Proposal for changes to Objective-C block formatting

2018-02-01 Thread Kent Sutherland via Phabricator via cfe-commits
ksuther added a comment.

It seems to have been. I've been using a modified version of clang-format with 
this change applied (as well as http://reviews.llvm.org/D17922) since I 
submitted this.


https://reviews.llvm.org/D17700



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


[PATCH] D42810: [Sema] Add implicit members even for invalid CXXRecordDecls

2018-02-01 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: bkramer.

It should be safe, since other code paths are already generating
implicit members even in invalid CXXRecordDecls (e.g. lookup).

If we don't generate implicit members on CXXRecordDecl's completion,
they will be generated by next lookup of constructors. This causes a
crash when the following conditions are met:

- a CXXRecordDecl is invalid,
- it is provided via ExternalASTSource (e.g. from PCH),
- it has inherited constructors (they create as ShadowDecl),
- lookup of its constructors was not run before ASTWriter serialized it.

This causes the ShadowDecls created for implicit constructors to be
removed from the class, but that's no longer possible since class is
provided by ExternalASTSource.

See provided lit test for an example.


Repository:
  rC Clang

https://reviews.llvm.org/D42810

Files:
  lib/Sema/SemaDecl.cpp
  test/Index/Inputs/crash-preamble-classes.h
  test/Index/crash-preamble-classes.cpp


Index: test/Index/crash-preamble-classes.cpp
===
--- /dev/null
+++ test/Index/crash-preamble-classes.cpp
@@ -0,0 +1,8 @@
+#include "crash-preamble-classes.h"
+
+struct Z : Y {
+  Z() {}
+};
+
+// RUN: env CINDEXTEST_EDITING=1 \
+// RUN: c-index-test -test-load-source-reparse 5 local -I %S/Inputs %s
Index: test/Index/Inputs/crash-preamble-classes.h
===
--- /dev/null
+++ test/Index/Inputs/crash-preamble-classes.h
@@ -0,0 +1,9 @@
+struct Incomplete;
+
+struct X : Incomplete {
+  X();
+};
+
+struct Y : X {
+  using X::X;
+};
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -15430,10 +15430,10 @@
   CXXRecord->getDestructor());
 }
 
-if (!CXXRecord->isInvalidDecl()) {
-  // Add any implicitly-declared members to this class.
-  AddImplicitlyDeclaredMembersToClass(CXXRecord);
+// Add any implicitly-declared members to this class.
+AddImplicitlyDeclaredMembersToClass(CXXRecord);
 
+if (!CXXRecord->isInvalidDecl()) {
   // If we have virtual base classes, we may end up finding multiple
   // final overriders for a given virtual function. Check for this
   // problem now.


Index: test/Index/crash-preamble-classes.cpp
===
--- /dev/null
+++ test/Index/crash-preamble-classes.cpp
@@ -0,0 +1,8 @@
+#include "crash-preamble-classes.h"
+
+struct Z : Y {
+  Z() {}
+};
+
+// RUN: env CINDEXTEST_EDITING=1 \
+// RUN: c-index-test -test-load-source-reparse 5 local -I %S/Inputs %s
Index: test/Index/Inputs/crash-preamble-classes.h
===
--- /dev/null
+++ test/Index/Inputs/crash-preamble-classes.h
@@ -0,0 +1,9 @@
+struct Incomplete;
+
+struct X : Incomplete {
+  X();
+};
+
+struct Y : X {
+  using X::X;
+};
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -15430,10 +15430,10 @@
   CXXRecord->getDestructor());
 }
 
-if (!CXXRecord->isInvalidDecl()) {
-  // Add any implicitly-declared members to this class.
-  AddImplicitlyDeclaredMembersToClass(CXXRecord);
+// Add any implicitly-declared members to this class.
+AddImplicitlyDeclaredMembersToClass(CXXRecord);
 
+if (!CXXRecord->isInvalidDecl()) {
   // If we have virtual base classes, we may end up finding multiple
   // final overriders for a given virtual function. Check for this
   // problem now.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r323998 - PR36157: When injecting an implicit function declaration in C89, find the right

2018-02-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Feb  1 12:01:49 2018
New Revision: 323998

URL: http://llvm.org/viewvc/llvm-project?rev=323998=rev
Log:
PR36157: When injecting an implicit function declaration in C89, find the right
DeclContext rather than injecting it wherever we happen to be.

This avoids creating functions whose DeclContext is a struct or similar.

Added:
cfe/trunk/test/Sema/cxx-as-c.c
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/bitfield.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=323998=323997=323998=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Feb  1 12:01:49 2018
@@ -12910,10 +12910,20 @@ void Sema::ActOnFinishDelayedAttribute(S
 /// call, forming a call to an implicitly defined function (per C99 6.5.1p2).
 NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
   IdentifierInfo , Scope *S) {
+  // Find the scope in which the identifier is injected and the corresponding
+  // DeclContext.
+  // FIXME: C89 does not say what happens if there is no enclosing block scope.
+  // In that case, we inject the declaration into the translation unit scope
+  // instead.
   Scope *BlockScope = S;
   while (!BlockScope->isCompoundStmtScope() && BlockScope->getParent())
 BlockScope = BlockScope->getParent();
 
+  Scope *ContextScope = BlockScope;
+  while (!ContextScope->getEntity())
+ContextScope = ContextScope->getParent();
+  ContextRAII SavedContext(*this, ContextScope->getEntity());
+
   // Before we produce a declaration for an implicitly defined
   // function, see whether there was a locally-scoped declaration of
   // this name as a function or variable. If so, use that

Modified: cfe/trunk/test/Sema/bitfield.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/bitfield.c?rev=323998=323997=323998=diff
==
--- cfe/trunk/test/Sema/bitfield.c (original)
+++ cfe/trunk/test/Sema/bitfield.c Thu Feb  1 12:01:49 2018
@@ -82,3 +82,7 @@ typedef __typeof__(+(t5.n--)) Unsigned;
 struct Test6 {
   : 0.0; // expected-error{{type name requires a specifier or qualifier}}
 };
+
+struct PR36157 {
+  int n : 1 ? 1 : implicitly_declare_function(); // expected-warning {{invalid 
in C99}}
+};

Added: cfe/trunk/test/Sema/cxx-as-c.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/cxx-as-c.c?rev=323998=auto
==
--- cfe/trunk/test/Sema/cxx-as-c.c (added)
+++ cfe/trunk/test/Sema/cxx-as-c.c Thu Feb  1 12:01:49 2018
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -verify
+
+// PR36157
+struct Foo {
+  Foo(int n) : n_(n) {} // expected-error 1+{{}} expected-warning 1+{{}}
+private:
+  int n;
+};
+int main() { Foo f; } // expected-error 1+{{}}


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


[PATCH] D42810: [Sema] Add implicit members even for invalid CXXRecordDecls

2018-02-01 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

The following assertion from `DeclContext::removeDecl` was failing before:

  assert((D->NextInContextAndBits.getPointer() || D == LastDecl) &&
 "decl is not in decls list");


Repository:
  rC Clang

https://reviews.llvm.org/D42810



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


[PATCH] D42457: [analyzer] Don't communicate evaluation failures through memregion hierarchy.

2018-02-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 132450.
NoQ added a comment.

Switched to plain bools and in-class initializers.


https://reviews.llvm.org/D42457

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/new.cpp

Index: test/Analysis/new.cpp
===
--- test/Analysis/new.cpp
+++ test/Analysis/new.cpp
@@ -311,8 +311,7 @@
 void testArrayDestr() {
   NoReturnDtor *p = new NoReturnDtor[2];
   delete[] p; // Calls the base destructor which aborts, checked below
-  //TODO: clang_analyzer_eval should not be called
-  clang_analyzer_eval(true); // expected-warning{{TRUE}}
+  clang_analyzer_eval(true); // no-warning
 }
 
 // Invalidate Region even in case of default destructor
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -616,15 +616,10 @@
   Bldr.generateNode(Call.getProgramPoint(), State, Pred);
 }
 
-enum CallInlinePolicy {
-  CIP_Allowed,
-  CIP_DisallowedOnce,
-  CIP_DisallowedAlways
-};
-
-static CallInlinePolicy mayInlineCallKind(const CallEvent ,
-  const ExplodedNode *Pred,
-  AnalyzerOptions ) {
+ExprEngine::CallInlinePolicy
+ExprEngine::mayInlineCallKind(const CallEvent , const ExplodedNode *Pred,
+  AnalyzerOptions ,
+  const ExprEngine::EvalCallOptions ) {
   const LocationContext *CurLC = Pred->getLocationContext();
   const StackFrameContext *CallerSFC = CurLC->getCurrentStackFrame();
   switch (Call.getKind()) {
@@ -658,18 +653,8 @@
 // initializers for array fields in default move/copy constructors.
 // We still allow construction into ElementRegion targets when they don't
 // represent array elements.
-const MemRegion *Target = Ctor.getCXXThisVal().getAsRegion();
-if (Target && isa(Target)) {
-  if (ParentExpr)
-if (const CXXNewExpr *NewExpr = dyn_cast(ParentExpr))
-  if (NewExpr->isArray())
-return CIP_DisallowedOnce;
-
-  if (const TypedValueRegion *TR = dyn_cast(
-  cast(Target)->getSuperRegion()))
-if (TR->getValueType()->isArrayType())
-  return CIP_DisallowedOnce;
-}
+if (CallOpts.IsArrayConstructorOrDestructor)
+  return CIP_DisallowedOnce;
 
 // Inlining constructors requires including initializers in the CFG.
 const AnalysisDeclContext *ADC = CallerSFC->getAnalysisDeclContext();
@@ -688,7 +673,7 @@
 // FIXME: This is a hack. We don't handle temporary destructors
 // right now, so we shouldn't inline their constructors.
 if (CtorExpr->getConstructionKind() == CXXConstructExpr::CK_Complete)
-  if (!Target || isa(Target))
+  if (CallOpts.IsConstructorWithImproperlyModeledTargetRegion)
 return CIP_DisallowedOnce;
 
 break;
@@ -702,11 +687,8 @@
 assert(ADC->getCFGBuildOptions().AddImplicitDtors && "No CFG destructors");
 (void)ADC;
 
-const CXXDestructorCall  = cast(Call);
-
 // FIXME: We don't handle constructors or destructors for arrays properly.
-const MemRegion *Target = Dtor.getCXXThisVal().getAsRegion();
-if (Target && isa(Target))
+if (CallOpts.IsArrayConstructorOrDestructor)
   return CIP_DisallowedOnce;
 
 break;
@@ -847,7 +829,8 @@
 }
 
 bool ExprEngine::shouldInlineCall(const CallEvent , const Decl *D,
-  const ExplodedNode *Pred) {
+  const ExplodedNode *Pred,
+  const EvalCallOptions ) {
   if (!D)
 return false;
 
@@ -894,7 +877,7 @@
   // FIXME: this checks both static and dynamic properties of the call, which
   // means we're redoing a bit of work that could be cached in the function
   // summary.
-  CallInlinePolicy CIP = mayInlineCallKind(Call, Pred, Opts);
+  CallInlinePolicy CIP = mayInlineCallKind(Call, Pred, Opts, CallOpts);
   if (CIP != CIP_Allowed) {
 if (CIP == CIP_DisallowedAlways) {
   assert(!MayInline.hasValue() || MayInline.getValue());
@@ -946,7 +929,8 @@
 }
 
 void ExprEngine::defaultEvalCall(NodeBuilder , ExplodedNode *Pred,
- const CallEvent ) {
+ const CallEvent ,
+ const EvalCallOptions ) {
   // Make sure we have the most recent state attached to the call.
   ProgramStateRef State = Pred->getState();
   CallEventRef<> Call = CallTemplate.cloneWithState(State);
@@ -969,7 +953,7 @@
   } else {
 RuntimeDefinition RD = Call->getRuntimeDefinition();
 const Decl *D = RD.getDecl();
-if (shouldInlineCall(*Call, D, Pred)) {
+if (shouldInlineCall(*Call, D, Pred, 

[PATCH] D17700: [clang-format] Proposal for changes to Objective-C block formatting

2018-02-01 Thread Daniel Casadevall Pino via Phabricator via cfe-commits
dcasadevall added a comment.

Was this lost in the woods? I believe this is a valid change when working in 
Objective-C


https://reviews.llvm.org/D17700



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


[PATCH] D42785: [Analyzer] Fix a typo in `ExprEngine::VisitMemberExpr`

2018-02-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Ew. So it means that checker transitions are currently discarded. Great catch. 
I guess we don't use this functionality yet, so we can't test it, but the fix 
should definitely go in.

Then, again, i'm suspecting that you may want to use `checkLocation` or 
`checkBind` instead of `checkPreStmt` - i doubt that there's 
anything special about member expressions that make them different from other 
sorts of bindings. And if you're tracking how a symbol is assigned to a field 
of the structure - well, you shouldn't, this info is already in the program 
state and you can retrieve it any time with `getSVal(Region)`.


Repository:
  rC Clang

https://reviews.llvm.org/D42785



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


[PATCH] D42644: [asan] Intercept std::rethrow_exception indirectly.

2018-02-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

I would not worry about cross platform here. You can patch just Linux and 
whoever have access (and issues) on other platforms can send a patch with 
similar changes.
Mac should use libc++.
I'd put the test outside of Posix, and mark failing platforms as "// XFAIL:", 
temporarily, as we suppose to handle all of them.




Comment at: lib/asan/asan_interceptors.cc:327
+INTERCEPTOR(void, __cxa_rethrow_primary_exception, void *a) {
+  CHECK(REAL(__cxa_throw));
+  __asan_handle_no_return();

Should this be: CHECK(REAL(__cxa_rethrow_primary_exception)); ?



Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D42644



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


[PATCH] D42803: [clangd] Log dropped diagnostics.

2018-02-01 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 132430.
ilya-biryukov added a comment.

- Show location of dropped diagnostic.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42803

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -178,15 +179,30 @@
 llvm::Optional toClangdDiag(const clang::Diagnostic ,
 DiagnosticsEngine::Level Level,
 const LangOptions ) {
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+
   if (!D.hasSourceManager() || !D.getLocation().isValid() ||
-  !D.getSourceManager().isInMainFile(D.getLocation()))
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+
+SmallString<64> Location;
+if (D.hasSourceManager() && D.getLocation().isValid()) {
+  auto  = D.getSourceManager();
+  auto Loc = SourceMgr.getFileLoc(D.getLocation());
+  llvm::raw_svector_ostream OS(Location);
+  Loc.print(OS, SourceMgr);
+} else {
+  Location = "";
+}
+
+log(llvm::formatv("Ignored diagnostic outside main file. {0}: {1}",
+  Location, Message));
 return llvm::None;
+  }
 
   DiagWithFixIts Result;
   Result.Diag.range = diagnosticRange(D, LangOpts);
   Result.Diag.severity = getSeverity(Level);
-  SmallString<64> Message;
-  D.FormatDiagnostic(Message);
   Result.Diag.message = Message.str();
   for (const FixItHint  : D.getFixItHints())
 Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -178,15 +179,30 @@
 llvm::Optional toClangdDiag(const clang::Diagnostic ,
 DiagnosticsEngine::Level Level,
 const LangOptions ) {
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+
   if (!D.hasSourceManager() || !D.getLocation().isValid() ||
-  !D.getSourceManager().isInMainFile(D.getLocation()))
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+
+SmallString<64> Location;
+if (D.hasSourceManager() && D.getLocation().isValid()) {
+  auto  = D.getSourceManager();
+  auto Loc = SourceMgr.getFileLoc(D.getLocation());
+  llvm::raw_svector_ostream OS(Location);
+  Loc.print(OS, SourceMgr);
+} else {
+  Location = "";
+}
+
+log(llvm::formatv("Ignored diagnostic outside main file. {0}: {1}",
+  Location, Message));
 return llvm::None;
+  }
 
   DiagWithFixIts Result;
   Result.Diag.range = diagnosticRange(D, LangOpts);
   Result.Diag.severity = getSeverity(Level);
-  SmallString<64> Message;
-  D.FormatDiagnostic(Message);
   Result.Diag.message = Message.str();
   for (const FixItHint  : D.getFixItHints())
 Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42644: [asan] Intercept std::rethrow_exception indirectly.

2018-02-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Could you please reformat it?
With git I usually use: git clang-format -f --style=file HEAD^


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D42644



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


[PATCH] D42645: New simple Checker for mmap calls

2018-02-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp:62
+
+  ExplodedNode *N = C.generateErrorNode();
+  if (!N)

You should also use `generateNonFatalErrorNode()` here so that not to prevent 
the analyzer from finding other bugs on that path, because your bug doesn't 
cause abnormal program termination or otherwise leave the analyzer in an 
inconsistent state.


Repository:
  rC Clang

https://reviews.llvm.org/D42645



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


r323986 - Mark fallthrough with LLVM_FALLTHROUGH

2018-02-01 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Feb  1 10:10:20 2018
New Revision: 323986

URL: http://llvm.org/viewvc/llvm-project?rev=323986=rev
Log:
Mark fallthrough with LLVM_FALLTHROUGH

Modified:
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=323986=323985=323986=diff
==
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Thu Feb  1 10:10:20 2018
@@ -948,7 +948,7 @@ void Type::applyModifier(char Mod) {
 break;
   case 'c':
 Constant = true;
-  // Fall through
+LLVM_FALLTHROUGH;
   case 'p':
 Pointer = true;
 Bitwidth = ElementBitwidth;


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


[PATCH] D42644: [asan] Intercept std::rethrow_exception indirectly.

2018-02-01 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek added a comment.

> This is our first patch so we're unfamiliar with the LLVM testing 
> infrastructure. Could you please tell us what kind of test you'd like? An 
> example would also be great.

Thank you for your first contribution! I'm going to comment on the testing 
infrastructure only, as I don't know the answer to the portability/mangling/ABI 
question.

Most user-visible features of ASan can usually be demonstrated in a single-file 
test that is completely standalone test program. E.g. ASan's ability to detect 
heap buffer overflows is demonstrated in `test/asan/TestCases/heap-overflow.cc` 
file. Notice that these tests don't include or reference any sanitizer internal 
functions. They are meant to be written in a way that user's code is written. 
Can you try adding such a test, which would be a standalone .cc file that would 
demonstrate the problematic scenario (C++ exception rethrow) without including 
ASan headers? The test's expectation should be that ASan doesn't report any 
issues, whereas without your patch, the test fails (or might fail). For an 
example of a negative test (that checks that ASan *doesn't* report any issues), 
see `test/asan/TestCases/Darwin/nil-return-struct.mm`.

If the test should work on all ASan supported platforms, put it directly into 
`test/asan/TestCases`. If it's POSIX-only, place it under `Posix/` subdirectory.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D42644



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


[PATCH] D42673: [RISCV] Pick the correct RISCV linker instead of calling riscv-gcc to link

2018-02-01 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang abandoned this revision.
mgrang added a comment.

For now, by setting the full triple (riscv-unknown-linux-gnu) we are able to 
invoke the correct gnu linker. So will abandon this patch.


Repository:
  rC Clang

https://reviews.llvm.org/D42673



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


[PATCH] D42800: Let CUDA toolchain support amdgpu target

2018-02-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

I don't have enough knowledge about compute on AMD's GPU and would appreciate 
if you could share your thoughts on how you think CUDA on AMD should work. Is 
there a good document describing how compute currently works (how do I launch a 
kernel using rough equivalent of nvidia's driver API 
 ) on AMD GPUs?

- Headers. clang pre-includes *a lot* of headers from NVidia's CUDA SDK. Some 
of them may work for AMD, but some certainly will not -- there are a lot of 
headers with nvidia-specific inline assembly or things that rely on 
nvidia-specific functionality. In the end, I think, we'll need some sort of 
CUDA SDK for AMD which would implement (possibly with asserts for unsupported 
functions) existing CUDA APIs. Or, perhaps the plan is to just use CUDA 
**syntax** only without providing complete API compatibility with nvidia.

- How will GPU-side object file be incorporated into the final executable? I 
believe OpenMP has a fairly generic way to deal with it in clang. I'm not sure 
if that would be suitable for use with AMD's runtime (whatever we need to use 
to launch the kernels).

- Launching kernels. Will it be similar to the way kernel launches are 
configured on NVidia? I.e. grid of blocks of threads with per-block shared 
memory.


https://reviews.llvm.org/D42800



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


[libcxx] r323989 - Put the exception classes for experimental::optional and experimental::any back in the dylib for binary compatibility

2018-02-01 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Feb  1 10:45:57 2018
New Revision: 323989

URL: http://llvm.org/viewvc/llvm-project?rev=323989=rev
Log:
Put the exception classes for experimental::optional and experimental::any back 
in the dylib for binary compatibility

Modified:
libcxx/trunk/src/any.cpp
libcxx/trunk/src/optional.cpp

Modified: libcxx/trunk/src/any.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/any.cpp?rev=323989=323988=323989=diff
==
--- libcxx/trunk/src/any.cpp (original)
+++ libcxx/trunk/src/any.cpp Thu Feb  1 10:45:57 2018
@@ -14,3 +14,22 @@ const char* bad_any_cast::what() const _
 return "bad any cast";
 }
 }
+
+
+#include 
+
+//  Preserve std::experimental::any_bad_cast for ABI compatibility
+//  Even though it no longer exists in a header file
+_LIBCPP_BEGIN_NAMESPACE_LFTS
+
+class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : 
public bad_cast
+{
+public:
+virtual const char* what() const _NOEXCEPT;
+};
+
+const char* bad_any_cast::what() const _NOEXCEPT {
+return "bad any cast";
+}
+
+_LIBCPP_END_NAMESPACE_LFTS

Modified: libcxx/trunk/src/optional.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/optional.cpp?rev=323989=323988=323989=diff
==
--- libcxx/trunk/src/optional.cpp (original)
+++ libcxx/trunk/src/optional.cpp Thu Feb  1 10:45:57 2018
@@ -20,3 +20,23 @@ const char* bad_optional_access::what()
 
 } // std
 
+
+#include 
+
+//  Preserve std::experimental::bad_optional_access for ABI compatibility
+//  Even though it no longer exists in a header file
+_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
+
+class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS 
bad_optional_access
+: public std::logic_error
+{
+public:
+   bad_optional_access() : std::logic_error("Bad optional Access") {}
+
+// Get the key function ~bad_optional_access() into the dylib
+virtual ~bad_optional_access() _NOEXCEPT;
+};
+
+bad_optional_access::~bad_optional_access() _NOEXCEPT = default;
+
+_LIBCPP_END_NAMESPACE_EXPERIMENTAL


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


[PATCH] D42803: [clangd] Log dropped diagnostics.

2018-02-01 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdUnit.cpp:182
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+

sammccall wrote:
> does Message include file:line? we probably want that in the log line.
No, it didn't include the line before. Now dumping the location too.



Comment at: clangd/ClangdUnit.cpp:186
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+log("Ignored diagnostic outside main file: " + Twine(Message));
 return llvm::None;

sammccall wrote:
> Agree this is useful.
> 
> Have we turned off the diagnostics limit (or will we?) a misconfig of e.g. C 
> vs C++ parsing of a header seems like it could produce 1000+ log lines from 
> preamble that we should probably avoid somehow.
> (Maybe even avoid paying to format)
I don't think we have changed default clang behavior.
This look like a good use-case for introducing log levels.
This information is definitely too verbose most of the time, but very useful 
when debugging failures


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42803



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


[PATCH] D42803: [clangd] Log dropped diagnostics.

2018-02-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323992: [clangd] Log dropped diagnostics. (authored by 
ibiryukov, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42803

Files:
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -178,15 +179,30 @@
 llvm::Optional toClangdDiag(const clang::Diagnostic ,
 DiagnosticsEngine::Level Level,
 const LangOptions ) {
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+
   if (!D.hasSourceManager() || !D.getLocation().isValid() ||
-  !D.getSourceManager().isInMainFile(D.getLocation()))
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+
+SmallString<64> Location;
+if (D.hasSourceManager() && D.getLocation().isValid()) {
+  auto  = D.getSourceManager();
+  auto Loc = SourceMgr.getFileLoc(D.getLocation());
+  llvm::raw_svector_ostream OS(Location);
+  Loc.print(OS, SourceMgr);
+} else {
+  Location = "";
+}
+
+log(llvm::formatv("Ignored diagnostic outside main file. {0}: {1}",
+  Location, Message));
 return llvm::None;
+  }
 
   DiagWithFixIts Result;
   Result.Diag.range = diagnosticRange(D, LangOpts);
   Result.Diag.severity = getSeverity(Level);
-  SmallString<64> Message;
-  D.FormatDiagnostic(Message);
   Result.Diag.message = Message.str();
   for (const FixItHint  : D.getFixItHints())
 Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));


Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -27,6 +27,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -178,15 +179,30 @@
 llvm::Optional toClangdDiag(const clang::Diagnostic ,
 DiagnosticsEngine::Level Level,
 const LangOptions ) {
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+
   if (!D.hasSourceManager() || !D.getLocation().isValid() ||
-  !D.getSourceManager().isInMainFile(D.getLocation()))
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+
+SmallString<64> Location;
+if (D.hasSourceManager() && D.getLocation().isValid()) {
+  auto  = D.getSourceManager();
+  auto Loc = SourceMgr.getFileLoc(D.getLocation());
+  llvm::raw_svector_ostream OS(Location);
+  Loc.print(OS, SourceMgr);
+} else {
+  Location = "";
+}
+
+log(llvm::formatv("Ignored diagnostic outside main file. {0}: {1}",
+  Location, Message));
 return llvm::None;
+  }
 
   DiagWithFixIts Result;
   Result.Diag.range = diagnosticRange(D, LangOpts);
   Result.Diag.severity = getSeverity(Level);
-  SmallString<64> Message;
-  D.FormatDiagnostic(Message);
   Result.Diag.message = Message.str();
   for (const FixItHint  : D.getFixItHints())
 Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r323992 - [clangd] Log dropped diagnostics.

2018-02-01 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Feb  1 11:06:45 2018
New Revision: 323992

URL: http://llvm.org/viewvc/llvm-project?rev=323992=rev
Log:
[clangd] Log dropped diagnostics.

Summary:
clangd drops diagnostics coming outside the main file, but it is still
useful to see that something went wrong in the logs.

Reviewers: hokein, ioeric, sammccall

Reviewed By: sammccall

Subscribers: klimek, jkorous-apple, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=323992=323991=323992=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Feb  1 11:06:45 2018
@@ -27,6 +27,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 
@@ -178,15 +179,30 @@ TextEdit toTextEdit(const FixItHint 
 llvm::Optional toClangdDiag(const clang::Diagnostic ,
 DiagnosticsEngine::Level Level,
 const LangOptions ) {
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+
   if (!D.hasSourceManager() || !D.getLocation().isValid() ||
-  !D.getSourceManager().isInMainFile(D.getLocation()))
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+
+SmallString<64> Location;
+if (D.hasSourceManager() && D.getLocation().isValid()) {
+  auto  = D.getSourceManager();
+  auto Loc = SourceMgr.getFileLoc(D.getLocation());
+  llvm::raw_svector_ostream OS(Location);
+  Loc.print(OS, SourceMgr);
+} else {
+  Location = "";
+}
+
+log(llvm::formatv("Ignored diagnostic outside main file. {0}: {1}",
+  Location, Message));
 return llvm::None;
+  }
 
   DiagWithFixIts Result;
   Result.Diag.range = diagnosticRange(D, LangOpts);
   Result.Diag.severity = getSeverity(Level);
-  SmallString<64> Message;
-  D.FormatDiagnostic(Message);
   Result.Diag.message = Message.str();
   for (const FixItHint  : D.getFixItHints())
 Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));


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


r323956 - Reverting patch rL323952 due to build errors that I

2018-02-01 Thread Sander de Smalen via cfe-commits
Author: s.desmalen
Date: Thu Feb  1 04:27:13 2018
New Revision: 323956

URL: http://llvm.org/viewvc/llvm-project?rev=323956=rev
Log:
Reverting patch rL323952 due to build errors that I
haven't encountered in local builds.


Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/debug-info-vla.c
cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp
cfe/trunk/test/CodeGenCXX/vla-consruct.cpp
cfe/trunk/test/CodeGenObjC/arc.m
cfe/trunk/test/OpenMP/target_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=323956=323955=323956=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Feb  1 04:27:13 2018
@@ -1479,8 +1479,8 @@ CodeGenFunction::GenerateBlockFunction(G
 const CGBlockInfo::Capture  = blockInfo.getCapture(variable);
 if (capture.isConstant()) {
   auto addr = LocalDeclMap.find(variable)->second;
-  (void)DI->EmitDeclareOfAutoVariable(variable, addr.getPointer(),
-  Builder);
+  DI->EmitDeclareOfAutoVariable(variable, addr.getPointer(),
+Builder);
   continue;
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=323956=323955=323956=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Feb  1 04:27:13 2018
@@ -2292,14 +2292,12 @@ llvm::DIType *CGDebugInfo::CreateType(co
   llvm::DIFile *Unit) {
   llvm::DIType *ElementTy = getOrCreateType(Ty->getElementType(), Unit);
   int64_t Count = Ty->getNumElements();
+  if (Count == 0)
+// If number of elements are not known then this is an unbounded array.
+// Use Count == -1 to express such arrays.
+Count = -1;
 
-  llvm::Metadata *Subscript;
-  QualType QTy(Ty, 0);
-  auto SizeExpr = SizeExprCache.find(QTy);
-  if (SizeExpr != SizeExprCache.end())
-Subscript = DBuilder.getOrCreateSubrange(0, SizeExpr->getSecond());
-  else
-Subscript = DBuilder.getOrCreateSubrange(0, Count ? Count : -1);
+  llvm::Metadata *Subscript = DBuilder.getOrCreateSubrange(0, Count);
   llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
 
   uint64_t Size = CGM.getContext().getTypeSize(Ty);
@@ -2356,12 +2354,8 @@ llvm::DIType *CGDebugInfo::CreateType(co
   }
 }
 
-auto SizeNode = SizeExprCache.find(EltTy);
-if (SizeNode != SizeExprCache.end())
-  Subscripts.push_back(
-  DBuilder.getOrCreateSubrange(0, SizeNode->getSecond()));
-else
-  Subscripts.push_back(DBuilder.getOrCreateSubrange(0, Count));
+// FIXME: Verify this is right for VLAs.
+Subscripts.push_back(DBuilder.getOrCreateSubrange(0, Count));
 EltTy = Ty->getElementType();
   }
 
@@ -3479,14 +3473,13 @@ llvm::DIType *CGDebugInfo::EmitTypeForVa
nullptr, Elements);
 }
 
-llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
-llvm::Value *Storage,
-llvm::Optional ArgNo,
-CGBuilderTy ) {
+void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::Value *Storage,
+  llvm::Optional ArgNo,
+  CGBuilderTy ) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
   if (VD->hasAttr())
-return nullptr;
+return;
 
   bool Unwritten =
   VD->isImplicit() || (isa(VD->getDeclContext()) &&
@@ -3504,7 +3497,7 @@ llvm::DILocalVariable *CGDebugInfo::Emit
   // If there is no debug info for this type then do not emit debug info
   // for this variable.
   if (!Ty)
-return nullptr;
+

r323952 - [DebugInfo] Enable debug information for C99 VLA types

2018-02-01 Thread Sander de Smalen via cfe-commits
Author: s.desmalen
Date: Thu Feb  1 03:25:10 2018
New Revision: 323952

URL: http://llvm.org/viewvc/llvm-project?rev=323952=rev
Log:
[DebugInfo] Enable debug information for C99 VLA types

Summary:
This patch enables debugging of C99 VLA types by generating more precise
LLVM Debug metadata, using the extended DISubrange 'count' field that
takes a DIVariable.

This should implement:
  Bug 30553: Debug info generated for arrays is not what GDB expects (not as 
good as GCC's)
https://bugs.llvm.org/show_bug.cgi?id=30553

Reviewers: echristo, aprantl, dexonsmith, clayborg, pcc, kristof.beyls, dblaikie

Reviewed By: aprantl

Subscribers: jholewinski, schweitz, davide, fhahn, JDevlieghere, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/debug-info-vla.c
cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp
cfe/trunk/test/CodeGenCXX/vla-consruct.cpp
cfe/trunk/test/CodeGenObjC/arc.m
cfe/trunk/test/OpenMP/target_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_simd_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_codegen.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=323952=323951=323952=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Thu Feb  1 03:25:10 2018
@@ -1479,8 +1479,8 @@ CodeGenFunction::GenerateBlockFunction(G
 const CGBlockInfo::Capture  = blockInfo.getCapture(variable);
 if (capture.isConstant()) {
   auto addr = LocalDeclMap.find(variable)->second;
-  DI->EmitDeclareOfAutoVariable(variable, addr.getPointer(),
-Builder);
+  (void)DI->EmitDeclareOfAutoVariable(variable, addr.getPointer(),
+  Builder);
   continue;
 }
 

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=323952=323951=323952=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Feb  1 03:25:10 2018
@@ -2292,12 +2292,14 @@ llvm::DIType *CGDebugInfo::CreateType(co
   llvm::DIFile *Unit) {
   llvm::DIType *ElementTy = getOrCreateType(Ty->getElementType(), Unit);
   int64_t Count = Ty->getNumElements();
-  if (Count == 0)
-// If number of elements are not known then this is an unbounded array.
-// Use Count == -1 to express such arrays.
-Count = -1;
 
-  llvm::Metadata *Subscript = DBuilder.getOrCreateSubrange(0, Count);
+  llvm::Metadata *Subscript;
+  QualType QTy(Ty, 0);
+  auto SizeExpr = SizeExprCache.find(QTy);
+  if (SizeExpr != SizeExprCache.end())
+Subscript = DBuilder.getOrCreateSubrange(0, SizeExpr->getSecond());
+  else
+Subscript = DBuilder.getOrCreateSubrange(0, Count ? Count : -1);
   llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
 
   uint64_t Size = CGM.getContext().getTypeSize(Ty);
@@ -2354,8 +2356,12 @@ llvm::DIType *CGDebugInfo::CreateType(co
   }
 }
 
-// FIXME: Verify this is right for VLAs.
-Subscripts.push_back(DBuilder.getOrCreateSubrange(0, Count));
+auto SizeNode = SizeExprCache.find(EltTy);
+if (SizeNode != SizeExprCache.end())
+  Subscripts.push_back(
+  DBuilder.getOrCreateSubrange(0, SizeNode->getSecond()));
+else
+  Subscripts.push_back(DBuilder.getOrCreateSubrange(0, Count));
 EltTy = Ty->getElementType();
   }
 
@@ -3473,13 +3479,14 @@ llvm::DIType *CGDebugInfo::EmitTypeForVa
nullptr, Elements);
 }
 
-void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::Value *Storage,
-  llvm::Optional ArgNo,
-  CGBuilderTy ) {
+llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
+llvm::Value *Storage,
+llvm::Optional ArgNo,

[PATCH] D42796: [clangd] Skip inline namespace when collecting scopes for index symbols.

2018-02-01 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: sammccall, hokein.
Herald added subscribers: cfe-commits, jkorous-apple, ilya-biryukov, klimek.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42796

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -201,8 +201,7 @@
   runSymbolCollector(Header, /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Red"), QName("Color"),
 QName("Green"), QName("Color2"),
-QName("ns"),
-QName("ns::Black")));
+QName("ns"), QName("ns::Black")));
 }
 
 TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
@@ -324,6 +323,41 @@
   EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo")));
 }
 
+TEST_F(SymbolCollectorTest, Scopes) {
+  const std::string Header = R"(
+namespace na {
+class Foo {};
+namespace nb {
+class Bar {};
+}
+}
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("na"), QName("na::nb"),
+   QName("na::Foo"), QName("na::nb::Bar")));
+}
+
+TEST_F(SymbolCollectorTest, SkipInlineNamespace) {
+  const std::string Header = R"(
+namespace na {
+inline namespace nb {
+class Foo {};
+}
+}
+namespace na {
+// This is still inlined.
+namespace nb {
+class Bar {};
+}
+}
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("na"), QName("na::nb"),
+   QName("na::Foo"), QName("na::Bar")));
+}
+
 TEST_F(SymbolCollectorTest, SymbolWithDocumentation) {
   const std::string Header = R"(
 namespace nx {
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -9,6 +9,7 @@
 
 #include "SymbolCollector.h"
 #include "../CodeCompletionStrings.h"
+#include "Logger.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/SourceManager.h"
@@ -63,14 +64,33 @@
   return AbsolutePath.str();
 }
 
-// "a::b::c", return {"a::b::", "c"}. Scope is empty if there's no qualifier.
-std::pair
-splitQualifiedName(llvm::StringRef QName) {
-  assert(!QName.startswith("::") && "Qualified names should not start with ::");
-  size_t Pos = QName.rfind("::");
-  if (Pos == llvm::StringRef::npos)
-return {StringRef(), QName};
-  return {QName.substr(0, Pos + 2), QName.substr(Pos + 2)};
+// For a symbol "a::b::c", return "a::b::". Scope is empty if there's no
+// qualifier. Inline namespaces and unscoped enums are skipped.
+llvm::Expected getScope(const NamedDecl *ND) {
+  llvm::SmallVector Contexts;
+  for (const auto *Context = ND->getDeclContext(); Context;
+   Context = Context->getParent()) {
+if (llvm::isa(Context) ||
+llvm::isa(Context))
+  break;
+
+if (const auto *NSD = dyn_cast(Context)) {
+  if (!NSD->isInlineNamespace())
+Contexts.push_back(NSD->getName());
+} else if (const auto *ED = dyn_cast(Context)) {
+  if (ED->isScoped())
+Contexts.push_back(ED->getName());
+} else {
+  return llvm::make_error(
+  llvm::Twine("Unexpected context type ") + Context->getDeclKindName() +
+  " for symbol " + ND->getQualifiedNameAsString(),
+  llvm::inconvertibleErrorCode());
+}
+  }
+  std::string Scope = llvm::join(Contexts.rbegin(), Contexts.rend(), "::");
+  if (!Scope.empty())
+Scope.append("::");
+  return Scope;
 }
 
 bool shouldFilterDecl(const NamedDecl *ND, ASTContext *ASTCtx,
@@ -172,19 +192,27 @@
 if (shouldFilterDecl(ND, ASTCtx, Opts))
   return true;
 llvm::SmallString<128> USR;
+if (ND->getIdentifier() == nullptr)
+  return true;
 if (index::generateUSRForDecl(ND, USR))
   return true;
 
 auto ID = SymbolID(USR);
 if (Symbols.find(ID) != nullptr)
   return true;
 
 auto  = ND->getASTContext().getSourceManager();
-std::string QName = ND->getQualifiedNameAsString();
+auto Scope = getScope(ND);
+if (!Scope) {
+  log(llvm::toString(Scope.takeError()));
+  return true;
+}
+std::string Name = ND->getName();
 
 Symbol S;
 S.ID = std::move(ID);
-std::tie(S.Scope, S.Name) = splitQualifiedName(QName);
+S.Scope = *Scope;
+S.Name = Name;
 S.SymInfo = index::getSymbolInfo(D);
 std::string FilePath;
 S.CanonicalDeclaration = GetSymbolLocation(ND, SM, Opts.FallbackDir, 

[libcxx] r323979 - Remove std::experimental::sample; use std::sample instead. See https://libcxx.llvm.org/TS_deprecation.html

2018-02-01 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Feb  1 08:36:08 2018
New Revision: 323979

URL: http://llvm.org/viewvc/llvm-project?rev=323979=rev
Log:
Remove std::experimental::sample; use std::sample instead. See 
https://libcxx.llvm.org/TS_deprecation.html

Removed:
libcxx/trunk/test/std/experimental/algorithms/alg.random.sample/
Modified:
libcxx/trunk/include/experimental/algorithm

Modified: libcxx/trunk/include/experimental/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/algorithm?rev=323979=323978=323979=diff
==
--- libcxx/trunk/include/experimental/algorithm (original)
+++ libcxx/trunk/include/experimental/algorithm Thu Feb  1 08:36:08 2018
@@ -23,11 +23,8 @@ inline namespace fundamentals_v1 {
 template 
 ForwardIterator search(ForwardIterator first, ForwardIterator last,
const Searcher );
-template 
-SampleIterator sample(PopulationIterator first, PopulationIterator last,
-  SampleIterator out, Distance n,
-  UniformRandomNumberGenerator &);
+
+// sample removed because it's now part of C++17
 
 } // namespace fundamentals_v1
 } // namespace experimental
@@ -56,16 +53,6 @@ _LIBCPP_INLINE_VISIBILITY
 _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const 
_Searcher &__s)
 { return __s(__f, __l).first; }
 
-
-template 
-inline _LIBCPP_INLINE_VISIBILITY
-_SampleIterator sample(_PopulationIterator __first, _PopulationIterator __last,
-   _SampleIterator __output_iter, _Distance __n,
-   _UniformRandomNumberGenerator &&__g) {
-  return _VSTD::__sample(__first, __last, __output_iter, __n, __g);
-}
-
 _LIBCPP_END_NAMESPACE_LFTS
 
 _LIBCPP_POP_MACROS


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


[PATCH] D42800: Let CUDA toolchain support amdgpu target

2018-02-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: gregrodgers, jlebar, b-sumner, t-tye, arsenm.
Herald added subscribers: tpr, dstuttard, nhaehnle, wdng, kzhuravl, jholewinski.

Currently CUDA toolchain only supports nvptx.

This patch will let CUDA toolchain support amdgpu target. It can also serve as 
an example for supporting CUDA on other targets.

Patch by Greg Rodgers.
Lit test added by Yaxun Liu.


https://reviews.llvm.org/D42800

Files:
  include/clang/Basic/Cuda.h
  include/clang/Driver/ToolChain.h
  lib/Basic/Cuda.cpp
  lib/Basic/Targets/AMDGPU.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/Basic/Targets/NVPTX.cpp
  lib/Driver/Driver.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  test/Driver/cuda-phases.cu

Index: test/Driver/cuda-phases.cu
===
--- test/Driver/cuda-phases.cu
+++ test/Driver/cuda-phases.cu
@@ -7,22 +7,25 @@
 // REQUIRES: clang-driver
 // REQUIRES: powerpc-registered-target
 // REQUIRES: nvptx-registered-target
-
+// REQUIRES: amdgpu-registered-target
 //
 // Test single gpu architecture with complete compilation.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s 2>&1 \
-// RUN: | FileCheck -check-prefix=BIN %s
+// RUN: | FileCheck -check-prefixes=BIN,BIN_NV %s
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=BIN,BIN_AMD %s
 // BIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
 // BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (host-cuda)
 // BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-cuda)
-// BIN-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, sm_30)
-// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, sm_30)
-// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, sm_30)
-// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, sm_30)
-// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P7]]}, object
-// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P6]]}, assembler
+// BIN_NV-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, [[ARCH:sm_30]])
+// BIN_AMD-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, [[ARCH:gfx803]])
+// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, [[ARCH]])
+// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, [[ARCH]])
+// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, [[ARCH]])
+// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, [[ARCH]])
+// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:[[ARCH]])" {[[P7]]}, object
+// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:[[ARCH]])" {[[P6]]}, assembler
 // BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-cuda)
 // BIN-DAG: [[P11:[0-9]+]]: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-cuda (nvptx64-nvidia-cuda)" {[[P10]]}, ir
 // BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-cuda)
@@ -34,11 +37,13 @@
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s -S 2>&1 \
 // RUN: | FileCheck -check-prefix=ASM %s
-// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// ASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (device-cuda, sm_30)
-// ASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-cuda, sm_30)
-// ASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-cuda, sm_30)
-// ASM-DAG: [[P4:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P3]]}, assembler
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM %s
+// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, [[ARCH:sm_30|gfx803]])
+// ASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (device-cuda, [[ARCH]])
+// ASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-cuda, [[ARCH]])
+// ASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-cuda, [[ARCH]])
+// ASM-DAG: [[P4:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:[[ARCH]])" {[[P3]]}, assembler
 // ASM-DAG: [[P5:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
 // ASM-DAG: [[P6:[0-9]+]]: preprocessor, {[[P5]]}, cuda-cpp-output, (host-cuda)
 // ASM-DAG: [[P7:[0-9]+]]: compiler, {[[P6]]}, ir, (host-cuda)
@@ -49,23 +54,25 @@
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
 // 

[clang-tools-extra] r323980 - [clang-tidy] misc-redundant-expression: fix a crash under ubsan

2018-02-01 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu Feb  1 08:39:12 2018
New Revision: 323980

URL: http://llvm.org/viewvc/llvm-project?rev=323980=rev
Log:
[clang-tidy] misc-redundant-expression: fix a crash under ubsan

Modified:
clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp?rev=323980=323979=323980=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/RedundantExpressionCheck.cpp Thu 
Feb  1 08:39:12 2018
@@ -22,7 +22,6 @@
 #include "llvm/Support/Casting.h"
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -967,6 +966,13 @@ void RedundantExpressionCheck::checkRela
   }
 }
 
+unsigned intLog2(uint64_t X) {
+  unsigned Result = 0;
+  while (X >>= 1)
+++Result;
+  return Result;
+}
+
 void RedundantExpressionCheck::check(const MatchFinder::MatchResult ) {
   if (const auto *BinOp = Result.Nodes.getNodeAs("binary")) {
 // If the expression's constants are macros, check whether they are
@@ -1043,11 +1049,11 @@ void RedundantExpressionCheck::check(con
 // If ShiftingConst is shifted left with more bits than the position of the
 // leftmost 1 in the bit representation of AndValue, AndConstant is
 // ineffective.
-if (floor(log2(AndValue.getExtValue())) >= ShiftingValue)
+if (intLog2(AndValue.getExtValue()) >= ShiftingValue)
   return;
 
 auto Diag = diag(BinaryAndExpr->getOperatorLoc(),
- "ineffective bitwise and operation.");
+ "ineffective bitwise and operation");
   }
 
   // Check for the following bound expressions:

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp?rev=323980=323979=323980=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp Thu 
Feb  1 08:39:12 2018
@@ -674,7 +674,7 @@ int operatorConfusion(int X, int Y, long
 {
   // Ineffective & expressions.
   Y = (Y << 8) & 0xff;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and 
operation.
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and 
operation
   Y = (Y << 12) & 0xfff;
   // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: ineffective bitwise and
   Y = (Y << 12) & 0xff;
@@ -686,7 +686,7 @@ int operatorConfusion(int X, int Y, long
 
   // Tests for unmatched types
   Z = (Z << 8) & 0xff;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and 
operation.
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and 
operation
   Y = (Y << 12) & 0xfffL;
   // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: ineffective bitwise and
   Z = (Y << 12) & 0xffLL;
@@ -694,6 +694,11 @@ int operatorConfusion(int X, int Y, long
   Y = (Z << 8L) & 0x77L;
   // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: ineffective bitwise and
 
+  Y = (Y << 8) & 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and
+
+  Y = (Y << 8) & -1;
+
   // Effective expressions. Do not check.
   Y = (Y << 4) & 0x15;
   Y = (Y << 3) & 0x250;


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


[PATCH] D42803: [clangd] Log dropped diagnostics.

2018-02-01 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: hokein, ioeric, sammccall.
Herald added subscribers: jkorous-apple, klimek.

clangd drops diagnostics coming outside the main file, but it is still
useful to see that something went wrong in the logs.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42803

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -178,15 +178,18 @@
 llvm::Optional toClangdDiag(const clang::Diagnostic ,
 DiagnosticsEngine::Level Level,
 const LangOptions ) {
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+
   if (!D.hasSourceManager() || !D.getLocation().isValid() ||
-  !D.getSourceManager().isInMainFile(D.getLocation()))
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+log("Ignored diagnostic outside main file: " + Twine(Message));
 return llvm::None;
+  }
 
   DiagWithFixIts Result;
   Result.Diag.range = diagnosticRange(D, LangOpts);
   Result.Diag.severity = getSeverity(Level);
-  SmallString<64> Message;
-  D.FormatDiagnostic(Message);
   Result.Diag.message = Message.str();
   for (const FixItHint  : D.getFixItHints())
 Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -178,15 +178,18 @@
 llvm::Optional toClangdDiag(const clang::Diagnostic ,
 DiagnosticsEngine::Level Level,
 const LangOptions ) {
+  SmallString<64> Message;
+  D.FormatDiagnostic(Message);
+
   if (!D.hasSourceManager() || !D.getLocation().isValid() ||
-  !D.getSourceManager().isInMainFile(D.getLocation()))
+  !D.getSourceManager().isInMainFile(D.getLocation())) {
+log("Ignored diagnostic outside main file: " + Twine(Message));
 return llvm::None;
+  }
 
   DiagWithFixIts Result;
   Result.Diag.range = diagnosticRange(D, LangOpts);
   Result.Diag.severity = getSeverity(Level);
-  SmallString<64> Message;
-  D.FormatDiagnostic(Message);
   Result.Diag.message = Message.str();
   for (const FixItHint  : D.getFixItHints())
 Result.FixIts.push_back(toTextEdit(Fix, D.getSourceManager(), LangOpts));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42796: [clangd] Skip inline namespace when collecting scopes for index symbols.

2018-02-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall requested changes to this revision.
sammccall added a comment.
This revision now requires changes to proceed.

Doh, nevermind - SuppressUnwrittenScopes is way simpler. Thanks @hokein for 
catching!


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42796



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


[PATCH] D16403: Add scope information to CFG

2018-02-01 Thread Maxim Ostapenko via Phabricator via cfe-commits
m.ostapenko updated this revision to Diff 132393.
m.ostapenko added a comment.

Fix scope ends order (as discussed above) and adjust a testcase.


Repository:
  rL LLVM

https://reviews.llvm.org/D16403

Files:
  include/clang/Analysis/AnalysisDeclContext.h
  include/clang/Analysis/CFG.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/AnalysisManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/scopes-cfg-output.cpp

Index: test/Analysis/scopes-cfg-output.cpp
===
--- /dev/null
+++ test/Analysis/scopes-cfg-output.cpp
@@ -0,0 +1,1168 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-scopes=true %s > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
+
+class A {
+public:
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  A() {}
+
+// CHECK:  [B1 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  ~A() {}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: 1
+// CHECK-NEXT:   2: return [B1.1];
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+  operator int() const { return 1; }
+};
+
+int getX();
+extern const bool UV;
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(a)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A [2])
+// CHECK-NEXT:   3: A a[2];
+// CHECK-NEXT:   4:  (CXXConstructExpr, class A [0])
+// CHECK-NEXT:   5: A b[0];
+// CHECK-NEXT:   6: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:   7: CFGScopeEnd(a)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_array() {
+  A a[2];
+  A b[0];
+}
+
+// CHECK:  [B2 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B1
+// CHECK:  [B1]
+// CHECK-NEXT:   1: CFGScopeBegin(a)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A a;
+// CHECK-NEXT:   4: CFGScopeBegin(c)
+// CHECK-NEXT:   5:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   6: A c;
+// CHECK-NEXT:   7:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   8: A d;
+// CHECK-NEXT:   9: [B1.8].~A() (Implicit destructor)
+// CHECK-NEXT:  10: [B1.6].~A() (Implicit destructor)
+// CHECK-NEXT:  11: CFGScopeEnd(c)
+// CHECK-NEXT:  12:  (CXXConstructExpr, class A)
+// CHECK-NEXT:  13: A b;
+// CHECK-NEXT:  14: [B1.13].~A() (Implicit destructor)
+// CHECK-NEXT:  15: [B1.3].~A() (Implicit destructor)
+// CHECK-NEXT:  16: CFGScopeEnd(a)
+// CHECK-NEXT:   Preds (1): B2
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (1): B1
+void test_scope() {
+  A a;
+  { A c;
+A d;
+  }
+  A b;
+}
+
+// CHECK:  [B4 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B3
+// CHECK:  [B1]
+// CHECK-NEXT:   1:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   2: A c;
+// CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B3.5].~A() (Implicit destructor)
+// CHECK-NEXT:   5: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:   6: CFGScopeEnd(a)
+// CHECK-NEXT:   Preds (1): B3
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B2]
+// CHECK-NEXT:   1: return;
+// CHECK-NEXT:   2: [B3.5].~A() (Implicit destructor)
+// CHECK-NEXT:   3: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:   4: CFGScopeEnd(a)
+// CHECK-NEXT:   Preds (1): B3
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B3]
+// CHECK-NEXT:   1: CFGScopeBegin(a)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A a;
+// CHECK-NEXT:   4:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   5: A b;
+// CHECK-NEXT:   6: UV
+// CHECK-NEXT:   7: [B3.6] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK-NEXT:   T: if [B3.7]
+// CHECK-NEXT:   Preds (1): B4
+// CHECK-NEXT:   Succs (2): B2 B1
+// CHECK:  [B0 (EXIT)]
+// CHECK-NEXT:   Preds (2): B1 B2
+void test_return() {
+  A a;
+  A b;
+  if (UV) return;
+  A c;
+}
+
+// CHECK:  [B5 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B4
+// CHECK:  [B1]
+// CHECK-NEXT:   1: [B4.8].~A() (Implicit destructor)
+// CHECK-NEXT:   2: CFGScopeEnd(b)
+// CHECK-NEXT:   3: [B4.3].~A() (Implicit destructor)
+// CHECK-NEXT:   4: CFGScopeEnd(a)
+// CHECK-NEXT:   Preds (2): B2 B3
+// CHECK-NEXT:   Succs (1): B0
+// CHECK:  [B2]
+// CHECK-NEXT:   1: CFGScopeBegin(c)
+// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// CHECK-NEXT:   3: A c;
+// CHECK-NEXT:   4: [B2.3].~A() (Implicit destructor)
+// CHECK-NEXT:   5: CFGScopeEnd(c)
+// CHECK-NEXT:   Preds (1): B4
+// 

[PATCH] D42800: Let CUDA toolchain support amdgpu target

2018-02-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D42800#994955, @Hahnfeld wrote:

> Only commenting on parts that I'm a bit familiar with. In general, does it 
> make sense to split this patch, are there different "stages" of support? Like 
> 1) being able to compile an empty file, 2) generate optimized code, 3) allow 
> using math functions?


Good suggestion. Actually this patch is mainly to let the toolchain recognise 
the amdgpu implementation of CUDA and create proper stages. I can try to create 
a test for compiling an empty file.


https://reviews.llvm.org/D42800



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


[PATCH] D42644: [asan] Intercept std::rethrow_exception indirectly.

2018-02-01 Thread Robert Schneider via Phabricator via cfe-commits
robot added a comment.

In https://reviews.llvm.org/D42644#993506, @kubamracek wrote:

> Cool. Can we get a lit test as well?


This is our first patch so we're unfamiliar with the LLVM testing 
infrastructure. Could you please tell us what kind of test you'd like? An 
example would also be great.

We still have some concerns regarding the portability of this patch: we don’t 
know how to portably intercept a C++ standard library function (name mangling, 
layout of types, …). In libc++abi, there’s `__cxa_rethrow_primary_exception` 
but it is not used by libstdc++. Instead, libstdc++’s implementation calls 
either `_Unwind_RaiseException` or `_Unwind_SjLj_RaiseException` directly – so 
we’ve intercepted those two for libstdc++. We didn’t check if this helps on 
other platforms (Mac and Windows come to mind).

Additionally, it might be possible there are some other interceptor functions 
missing such as `__cxa_rethrow` (for throw; statements in catch blocks) which 
might lead to analogous false positives (especially if you don’t intercept 
`_Unwind_RaiseException` in the libc++ case).

Arnaud & Robot


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D42644



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


[libcxx] r323975 - Remove ; use instead. See https://libcxx.llvm.org/TS_deprecation.html

2018-02-01 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Feb  1 07:49:27 2018
New Revision: 323975

URL: http://llvm.org/viewvc/llvm-project?rev=323975=rev
Log:
Remove ; use  instead. See 
https://libcxx.llvm.org/TS_deprecation.html

Removed:
libcxx/trunk/test/std/experimental/numeric/
Modified:
libcxx/trunk/include/experimental/numeric
libcxx/trunk/include/module.modulemap
libcxx/trunk/test/libcxx/double_include.sh.cpp
libcxx/trunk/test/libcxx/min_max_macros.sh.cpp

Modified: libcxx/trunk/include/experimental/numeric
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/numeric?rev=323975=323974=323975=diff
==
--- libcxx/trunk/include/experimental/numeric (original)
+++ libcxx/trunk/include/experimental/numeric Thu Feb  1 07:49:27 2018
@@ -8,112 +8,4 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
-#define _LIBCPP_EXPERIMENTAL_NUMERIC
-/*
-experimental/numeric synopsis
-
-// C++1z
-namespace std {
-namespace experimental {
-inline namespace fundamentals_v2 {
-
-  // 13.1.2, Greatest common divisor
-  template
-  constexpr common_type_t gcd(M m, N n);
-
-  // 13.1.3, Least common multiple
-  template
-  constexpr common_type_t lcm(M m, N n);
-
-} // namespace fundamentals_v2
-} // namespace experimental
-} // namespace std
-
- */
-
-#include 
-#include 
-#include   // is_integral
-#include// numeric_limits
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_PUSH_MACROS
-#include <__undef_macros>
-
-#if _LIBCPP_STD_VER > 11
-
-_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
-
-template ::value> struct __abs;
-
-template 
-struct __abs<_Result, _Source, true> {
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-_Result operator()(_Source __t) const noexcept
-{
-if (__t >= 0) return __t;
-if (__t == numeric_limits<_Source>::min()) return 
-static_cast<_Result>(__t);
-return -__t;
-}
-};
-
-template 
-struct __abs<_Result, _Source, false> {
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-_Result operator()(_Source __t) const noexcept { return __t; }
-};
-
-
-template
-_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN
-inline _Tp __gcd(_Tp __m, _Tp __n)
-{
-static_assert((!is_signed<_Tp>::value), "" );
-return __n == 0 ? __m : _VSTD_LFTS_V2::__gcd<_Tp>(__n, __m % __n);
-}
-
-
-template
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-common_type_t<_Tp,_Up>
-gcd(_Tp __m, _Up __n)
-{
-static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), 
"Arguments to gcd must be integer types");
-static_assert((!is_same::type, bool>::value), 
"First argument to gcd cannot be bool" );
-static_assert((!is_same::type, bool>::value), 
"Second argument to gcd cannot be bool" );
-using _Rp = common_type_t<_Tp,_Up>;
-using _Wp = make_unsigned_t<_Rp>;
-return static_cast<_Rp>(_VSTD_LFTS_V2::__gcd(
-  static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
-  static_cast<_Wp>(__abs<_Rp, _Up>()(__n;
-}
-
-template
-_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-common_type_t<_Tp,_Up>
-lcm(_Tp __m, _Up __n)
-{
-static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), 
"Arguments to lcm must be integer types");
-static_assert((!is_same::type, bool>::value), 
"First argument to lcm cannot be bool" );
-static_assert((!is_same::type, bool>::value), 
"Second argument to lcm cannot be bool" );
-if (__m == 0 || __n == 0)
-return 0;
-
-using _Rp = common_type_t<_Tp,_Up>;
-_Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD_LFTS_V2::gcd(__m, __n);
-_Rp __val2 = __abs<_Rp, _Up>()(__n);
-_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow 
in lcm");
-return __val1 * __val2;
-}
-
-_LIBCPP_END_NAMESPACE_LFTS_V2
-
-#endif /* _LIBCPP_STD_VER > 11 */
-
-_LIBCPP_POP_MACROS
-
-#endif /* _LIBCPP_EXPERIMENTAL_NUMERIC */
+#error " has been removed. Use  instead."

Modified: libcxx/trunk/include/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/module.modulemap?rev=323975=323974=323975=diff
==
--- libcxx/trunk/include/module.modulemap (original)
+++ libcxx/trunk/include/module.modulemap Thu Feb  1 07:49:27 2018
@@ -538,10 +538,6 @@ module std [system] {
   header "experimental/memory_resource"
   export *
 }
-module numeric {
-  header "experimental/numeric"
-  export *
-}
 module propagate_const {
   header "experimental/propagate_const"
   export *

Modified: libcxx/trunk/test/libcxx/double_include.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/double_include.sh.cpp?rev=323975=323974=323975=diff
==
--- libcxx/trunk/test/libcxx/double_include.sh.cpp 

[libcxx] r323972 - Remove ; use instead. See https://libcxx.llvm.org/TS_deprecation.html

2018-02-01 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Feb  1 07:21:14 2018
New Revision: 323972

URL: http://llvm.org/viewvc/llvm-project?rev=323972=rev
Log:
Remove ; use  instead. See 
https://libcxx.llvm.org/TS_deprecation.html

Removed:
libcxx/trunk/test/libcxx/experimental/any/
libcxx/trunk/test/std/experimental/any/
Modified:
libcxx/trunk/include/experimental/any
libcxx/trunk/include/module.modulemap
libcxx/trunk/src/any.cpp
libcxx/trunk/test/libcxx/double_include.sh.cpp
libcxx/trunk/test/libcxx/min_max_macros.sh.cpp

Modified: libcxx/trunk/include/experimental/any
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/any?rev=323972=323971=323972=diff
==
--- libcxx/trunk/include/experimental/any (original)
+++ libcxx/trunk/include/experimental/any Thu Feb  1 07:21:14 2018
@@ -8,585 +8,4 @@
 //
 
//===--===//
 
-#ifndef _LIBCPP_EXPERIMENTAL_ANY
-#define _LIBCPP_EXPERIMENTAL_ANY
-
-/*
-   experimental/any synopsis
-
-namespace std {
-namespace experimental {
-inline namespace fundamentals_v1 {
-
-  class bad_any_cast : public bad_cast
-  {
-  public:
-virtual const char* what() const noexcept;
-  };
-
-  class any
-  {
-  public:
-
-// 6.3.1 any construct/destruct
-any() noexcept;
-
-any(const any& other);
-any(any&& other) noexcept;
-
-template 
-  any(ValueType&& value);
-
-~any();
-
-// 6.3.2 any assignments
-any& operator=(const any& rhs);
-any& operator=(any&& rhs) noexcept;
-
-template 
-  any& operator=(ValueType&& rhs);
-
-// 6.3.3 any modifiers
-void clear() noexcept;
-void swap(any& rhs) noexcept;
-
-// 6.3.4 any observers
-bool empty() const noexcept;
-const type_info& type() const noexcept;
-  };
-
-   // 6.4 Non-member functions
-  void swap(any& x, any& y) noexcept;
-
-  template
-ValueType any_cast(const any& operand);
-  template
-ValueType any_cast(any& operand);
-  template
-ValueType any_cast(any&& operand);
-
-  template
-const ValueType* any_cast(const any* operand) noexcept;
-  template
-ValueType* any_cast(any* operand) noexcept;
-
-} // namespace fundamentals_v1
-} // namespace experimental
-} // namespace std
-
-*/
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
-#endif
-
-_LIBCPP_BEGIN_NAMESPACE_LFTS
-
-class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : 
public bad_cast
-{
-public:
-virtual const char* what() const _NOEXCEPT;
-};
-
-#if _LIBCPP_STD_VER > 11// C++ > 11
-
-_LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE
-_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-void __throw_bad_any_cast()
-{
-#ifndef _LIBCPP_NO_EXCEPTIONS
-throw bad_any_cast();
-#else
-_VSTD::abort();
-#endif
-}
-
-// Forward declarations
-class any;
-
-template 
-typename add_pointer::type>::type
-_LIBCPP_INLINE_VISIBILITY
-any_cast(any const *) _NOEXCEPT;
-
-template 
-typename add_pointer<_ValueType>::type
-_LIBCPP_INLINE_VISIBILITY
-any_cast(any *) _NOEXCEPT;
-
-namespace __any_imp
-{
-  typedef typename aligned_storage<3*sizeof(void*), 
alignment_of::value>::type
-_Buffer;
-
-  template 
-  struct _IsSmallObject
-: public integral_constant::value
- % alignment_of<_Tp>::value == 0
-  && is_nothrow_move_constructible<_Tp>::value
->
-  {};
-
-  enum class _Action
-  {
-_Destroy,
-_Copy,
-_Move,
-_Get,
-_TypeInfo
-  };
-
-  template 
-  struct _SmallHandler;
-
-  template 
-  struct _LargeHandler;
-
-  template 
-  using _Handler = typename conditional<_IsSmallObject<_Tp>::value
-  , _SmallHandler<_Tp>
-  , _LargeHandler<_Tp>
->::type;
-  template 
-  using _EnableIfNotAny = typename
-enable_if<
-  !is_same::type, any>::value
->::type;
-
-} // namespace __any_imp
-
-class any
-{
-public:
-  // 6.3.1 any construct/destruct
-  _LIBCPP_INLINE_VISIBILITY
-  any() _NOEXCEPT : __h(nullptr) {}
-
-  _LIBCPP_INLINE_VISIBILITY
-  any(any const & __other) : __h(nullptr)
-  {
-if (__other.__h) __other.__call(_Action::_Copy, this);
-  }
-
-  _LIBCPP_INLINE_VISIBILITY
-  any(any && __other) _NOEXCEPT : __h(nullptr)
-  {
-if (__other.__h) __other.__call(_Action::_Move, this);
-  }
-
-  template <
-  class _ValueType
-, class = __any_imp::_EnableIfNotAny<_ValueType>
->
-  _LIBCPP_INLINE_VISIBILITY
-  any(_ValueType && __value);
-
-  _LIBCPP_INLINE_VISIBILITY
-  ~any()
-  {
-this->clear();
-  }
-
-  // 6.3.2 any assignments
-  _LIBCPP_INLINE_VISIBILITY
-  any & operator=(any const & __rhs)
-  {
-any(__rhs).swap(*this);
-return *this;
-  }
-
-  _LIBCPP_INLINE_VISIBILITY
-  any & 

[PATCH] D42730: [clang-tidy]] Add check for use of types/classes/functions from header which are deprecated and removed in C++17

2018-02-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/AvoidFunctionalCheck.h:19
+
+/// Check for several deprecated types and classes from  header
+///

alexfh wrote:
> aaron.ballman wrote:
> > alexfh wrote:
> > > Quuxplusone wrote:
> > > > aaron.ballman wrote:
> > > > > alexfh wrote:
> > > > > > alexfh wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > massberg wrote:
> > > > > > > > > massberg wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > Missing full stop at the end of the sentence.
> > > > > > > > > > > 
> > > > > > > > > > > Why should this modernize check be limited to 
> > > > > > > > > > > ``? Just like we have a "deprecated headers" 
> > > > > > > > > > > check, perhaps this should be a "deprecated APIs" check?
> > > > > > > > > > Added full stop.
> > > > > > > > > > 
> > > > > > > > > > I'm not sure if this check should be limited to 
> > > > > > > > > >  or be extended to a full 'deprecated API' 
> > > > > > > > > > check.
> > > > > > > > > > This change is just a start, several more types and classes 
> > > > > > > > > > which are removed from  will follow, e.g:
> > > > > > > > > > 
> > > > > > > > > > - std::ptr_fun, std::mem_fun, std::mem_fun_ref
> > > > > > > > > > - std::bind1st, std::bind2nd
> > > > > > > > > > - std::unary_function, std::binary_function
> > > > > > > > > > - std::pointer_to_unary_function, 
> > > > > > > > > > std::pointer_to_binary_function, std::mem_fun_t, 
> > > > > > > > > > std::mem_fun1_t, std::const_mem_fun_t, 
> > > > > > > > > > - std::const_mem_fun1_t, std::mem_fun_ref_t, 
> > > > > > > > > > std::mem_fun1_ref_t, std::const_mem_fun_ref_t, 
> > > > > > > > > > std::const_mem_fun1_ref_t
> > > > > > > > > > - std::binder1st, std::binder2nd
> > > > > > > > > > 
> > > > > > > > > > As these are a bunch of functions and types, in my eyes a 
> > > > > > > > > > check just for  is fine. But I'm also fine with 
> > > > > > > > > > a general 'deprecated API' check.
> > > > > > > > > > Alex, can you comment on this?
> > > > > > > > > There are already other checks for functions which are 
> > > > > > > > > removed in C++17 like modernize-replace-random-shuffle.
> > > > > > > > > So I think having an separate check for functions and types 
> > > > > > > > > removed from  would be OK.
> > > > > > > > You've hit the nail on the head for what I'm trying to avoid -- 
> > > > > > > > we shouldn't have multiple checks unless they do drastically 
> > > > > > > > different things. Having a deprecated check like this really 
> > > > > > > > only makes sense for APIs that are deprecated but aren't 
> > > > > > > > uniformly marked as `[[deprecated]]` by the library. As such, I 
> > > > > > > > think we really only need one check for this rather than 
> > > > > > > > splitting it out over multiple checks -- the existing check 
> > > > > > > > functionality could be rolled into this one and its check 
> > > > > > > > become an alias.
> > > > > > > > I'm not sure if this check should be limited to  or 
> > > > > > > > be extended to a full 'deprecated API' check.
> > > > > > > 
> > > > > > > IIUC, it should be possible to implement fixits at least for some 
> > > > > > > use cases here. My impression was that Jens was at least 
> > > > > > > considering to work on fixits. The other check mentioned here - 
> > > > > > > `modernize-replace-random-shuffle` already implements fixits. 
> > > > > > > Fixits are specific to the API and some codebases may have better 
> > > > > > > replacement APIs than what the standard suggests, so different 
> > > > > > > users may want to apply different set of the fixes. Given all 
> > > > > > > that, I wouldn't just merge all of the checks dealing with 
> > > > > > > deprecated APIs. Splitting them at least by header seems like a 
> > > > > > > good start, maybe even finer granularity may be needed in some 
> > > > > > > cases.
> > > > > > TL;DR "they do drastically different things" is the case for this 
> > > > > > check and modernize-replace-random-shuffle.
> > > > > I disagree that they do drastically different things or that fix-its 
> > > > > are a problem. Some of these APIs have replacements, others do not. 
> > > > > At the end of the day, the basics are the same: the functionality is 
> > > > > deprecated and you should consider a replacement. Sometimes we know 
> > > > > that replacement up front, other times we don't. I don't think we 
> > > > > should make users reach for a per-header file answer to that problem 
> > > > > unless it provides them some benefit. I don't see users caring to 
> > > > > update  but not other headers.
> > > > > 
> > > > > I can see benefit to splitting the *implementations* of the checks 
> > > > > along arbitrary lines, but how we structure the implementation is 
> > > > > orthogonal to how we surface the functionality.
> > > > This sounds like clang-tidy ought to have an umbrella option here, 
> > > > analogous to how -Wformat 

[PATCH] D42800: Let CUDA toolchain support amdgpu target

2018-02-01 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Only commenting on parts that I'm a bit familiar with. In general, does it make 
sense to split this patch, are there different "stages" of support? Like 1) 
being able to compile an empty file, 2) generate optimized code, 3) allow using 
math functions?




Comment at: lib/Driver/ToolChains/Cuda.cpp:403-415
+  // If Verbose, save input for llc in /tmp and print all symbols
+  if (Args.hasArg(options::OPT_v)) {
+ArgStringList nmArgs;
+nmArgs.push_back(ResultingBitcodeF);
+nmArgs.push_back("-debug-syms");
+const char *nmExec = Args.MakeArgString(C.getDriver().Dir + "/llvm-nm");
+C.addCommand(llvm::make_unique(JA, *this, nmExec, nmArgs, 
Inputs));

This never gets cleaned up!



Comment at: lib/Driver/ToolChains/Cuda.cpp:531-534
+  SmallString<256> OutputFileName(Output.getFilename());
+  if (JA.isOffloading(Action::OFK_OpenMP))
+llvm::sys::path::replace_extension(OutputFileName, "cubin");
+  CmdArgs.push_back(Args.MakeArgString(OutputFileName));

That is already done in `TC.getInputFilename(Output)` (since rC318763), the 
same function call that you are removing here...



Comment at: lib/Driver/ToolChains/Cuda.cpp:639-640
+CmdArgs2.push_back(Args.MakeArgString(Output.getFilename()));
+const char *Exec2 =
+Args.MakeArgString(C.getDriver().Dir + "/clang-fixup-fatbin");
+C.addCommand(

`clang-fixup-fatbin` is not upstreamed and won't work. Sounds like a horrible 
name btw...



Comment at: lib/Driver/ToolChains/Cuda.cpp:788-793
+  // Do not add -link-cuda-bitcode or ptx42 features if gfx
+  for (Arg *A : DriverArgs)
+if (A->getOption().matches(options::OPT_cuda_gpu_arch_EQ) &&
+StringRef(A->getValue()).startswith("gfx"))
+  return;
+

You should use `GpuArch` which comes from `DriverArgs.getLastArgValue`: The 
last `-march` overrides previous arguments.


https://reviews.llvm.org/D42800



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


[PATCH] D42034: [clang-format] In tests, expected code should be format-stable

2018-02-01 Thread Mark Zeren via Phabricator via cfe-commits
mzeren-vmw updated this revision to Diff 132395.
mzeren-vmw added a comment.

- Reviewers: drop euhlmann, add djasper
- Rebase
- Ping


Repository:
  rC Clang

https://reviews.llvm.org/D42034

Files:
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -72,6 +72,7 @@
 
   void verifyFormat(llvm::StringRef Expected, llvm::StringRef Code,
 const FormatStyle  = getLLVMStyle()) {
+EXPECT_EQ(Expected.str(), format(Expected, Style));
 EXPECT_EQ(Expected.str(), format(Code, Style));
 if (Style.Language == FormatStyle::LK_Cpp) {
   // Objective-C++ is a superset of C++, so everything checked for C++


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -72,6 +72,7 @@
 
   void verifyFormat(llvm::StringRef Expected, llvm::StringRef Code,
 const FormatStyle  = getLLVMStyle()) {
+EXPECT_EQ(Expected.str(), format(Expected, Style));
 EXPECT_EQ(Expected.str(), format(Code, Style));
 if (Style.Language == FormatStyle::LK_Cpp) {
   // Objective-C++ is a superset of C++, so everything checked for C++
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D34249: [libc++] Don't use UTIME_OMIT to detect utimensat on Apple

2018-02-01 Thread Duncan P. N. Exon Smith via cfe-commits
Using runtime availability checking doesn't make sense for a system Libc++, as 
you point out.  If we add runtime checks they ought to be non-default, and 
hidden behind configuration flags.

Also, do I remember correctly that __builtin_available requires linking against 
Foundation (and thus the Obj-C runtime) for NSProcessInfo, or has that 
dependency been removed/avoided?  It would be surprising for the C++ standard 
library to pull in the Objective-C runtime.  A reasonable configuration option, 
but not a reasonable default behaviour IMO.

> On Feb 1, 2018, at 05:52, Nico Weber via Phabricator 
>  wrote:
> 
> thakis added a comment.
> 
> The powers that be updated the SDK on the chromium clang bots, so we need 
> some solution for this issue soon.
> 
> The approach in this patch should work, but it seems conservative. Now libc++ 
> only uses utimesat() if it's built with a deployment target of macOS 10.13. 
> But if we were to set a deployment target of 10.12 and then _run_ on 10.13, 
> we could use utimesat() as well, even though this patch currently doesn't. 
> (Apple bundles libc++ with the system, so it's not a meaningful difference 
> for Apple-built libc++'s, but applications can build libc++ themselves and 
> statically link to it, and for those it would make a difference.)
> 
> https://clang.llvm.org/docs/LanguageExtensions.html#objective-c-available has 
> some words on it (except that `@available` is spelled `__builtin_available` 
> in non-Objective-C code) -- thoughts on using runtime detection of utimes() 
> instead? That's how things are supposed to work on the Apple platforms.
> 
> 
> https://reviews.llvm.org/D34249
> 
> 
> 

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


Re: [PATCH] D34249: [libc++] Don't use UTIME_OMIT to detect utimensat on Apple

2018-02-01 Thread Nico Weber via cfe-commits
(To be clear, the patch as-is is 100% fine with me.)

On Thu, Feb 1, 2018 at 11:44 AM, Duncan P. N. Exon Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Using runtime availability checking doesn't make sense for a system
> Libc++, as you point out.  If we add runtime checks they ought to be
> non-default, and hidden behind configuration flags.
>
> Also, do I remember correctly that __builtin_available requires linking
> against Foundation (and thus the Obj-C runtime) for NSProcessInfo, or has
> that dependency been removed/avoided?  It would be surprising for the C++
> standard library to pull in the Objective-C runtime.  A reasonable
> configuration option, but not a reasonable default behaviour IMO.
>
> > On Feb 1, 2018, at 05:52, Nico Weber via Phabricator <
> revi...@reviews.llvm.org> wrote:
> >
> > thakis added a comment.
> >
> > The powers that be updated the SDK on the chromium clang bots, so we
> need some solution for this issue soon.
> >
> > The approach in this patch should work, but it seems conservative. Now
> libc++ only uses utimesat() if it's built with a deployment target of macOS
> 10.13. But if we were to set a deployment target of 10.12 and then _run_ on
> 10.13, we could use utimesat() as well, even though this patch currently
> doesn't. (Apple bundles libc++ with the system, so it's not a meaningful
> difference for Apple-built libc++'s, but applications can build libc++
> themselves and statically link to it, and for those it would make a
> difference.)
> >
> > https://clang.llvm.org/docs/LanguageExtensions.html#
> objective-c-available has some words on it (except that `@available` is
> spelled `__builtin_available` in non-Objective-C code) -- thoughts on using
> runtime detection of utimes() instead? That's how things are supposed to
> work on the Apple platforms.
> >
> >
> > https://reviews.llvm.org/D34249
> >
> >
> >
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42736: [DebugInfo] Improvements to representation of enumeration types (PR36168)

2018-02-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill updated this revision to Diff 132414.
chill added a comment.

Minor update, the parameter to `createEnumerator` is `IsUnsigned` now (instead 
of `IsSigned`), changed caller.


https://reviews.llvm.org/D42736

Files:
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGen/debug-info-enum.cpp
  test/CodeGenCXX/debug-info-enum-class.cpp
  test/CodeGenCXX/debug-info-enum.cpp
  test/Modules/ModuleDebugInfo.cpp

Index: test/Modules/ModuleDebugInfo.cpp
===
--- test/Modules/ModuleDebugInfo.cpp
+++ test/Modules/ModuleDebugInfo.cpp
@@ -48,7 +48,7 @@
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
 // CHECK-NOT:  name:
 // CHECK-SAME: )
-// CHECK: !DIEnumerator(name: "e5", value: 5)
+// CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true)
 
 // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
 // no mangled name here yet.
Index: test/CodeGenCXX/debug-info-enum.cpp
===
--- test/CodeGenCXX/debug-info-enum.cpp
+++ test/CodeGenCXX/debug-info-enum.cpp
@@ -11,7 +11,7 @@
 // CHECK-SAME:  identifier: "_ZTSN5test11eE"
 // CHECK: [[TEST1]] = !DINamespace(name: "test1"
 // CHECK: [[TEST1_ENUMS]] = !{[[TEST1_E:![0-9]*]]}
-// CHECK: [[TEST1_E]] = !DIEnumerator(name: "E", value: 0)
+// CHECK: [[TEST1_E]] = !DIEnumerator(name: "E", value: 0, isUnsigned: true)
 enum e { E };
 void foo() {
   int v = E;
Index: test/CodeGenCXX/debug-info-enum-class.cpp
===
--- test/CodeGenCXX/debug-info-enum-class.cpp
+++ test/CodeGenCXX/debug-info-enum-class.cpp
@@ -15,20 +15,20 @@
 // CHECK-SAME: baseType: ![[INT:[0-9]+]]
 // CHECK-SAME: size: 32
 // CHECK-NOT:  offset:
-// CHECK-NOT:  flags:
+// CHECK-SAME: flags: DIFlagFixedEnum
 // CHECK-SAME: ){{$}}
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "B"
 // CHECK-SAME: line: 4
 // CHECK-SAME: baseType: ![[ULONG:[0-9]+]]
 // CHECK-SAME: size: 64
 // CHECK-NOT:  offset:
-// CHECK-NOT:  flags:
+// CHECK-SAME: flags: DIFlagFixedEnum
 // CHECK-SAME: ){{$}}
 // CHECK: ![[ULONG]] = !DIBasicType(name: "long unsigned int"
 // CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "C"
 // CHECK-SAME: line: 5
-// CHECK-NOT:  baseType:
+// CHECK-SAME: baseType: ![[ULONG:[0-9]+]]
 // CHECK-SAME: size: 32
 // CHECK-NOT:  offset:
 // CHECK-NOT:  flags:
Index: test/CodeGen/debug-info-enum.cpp
===
--- /dev/null
+++ test/CodeGen/debug-info-enum.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang -target x86_64-linux -g -S -emit-llvm -o - %s | FileCheck %s
+enum class E0 : signed char {
+  A0 = -128,
+  B0 = 127,
+} x0;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E0"
+// CHECK-SAME: flags: DIFlagFixedEnum
+// CHECK: !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
+// CHECK: !DIEnumerator(name: "A0", value: -128)
+// CHECK: !DIEnumerator(name: "B0", value: 127)
+
+enum class E1 : unsigned char { A1 = 255 } x1;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E1"
+// CHECK-SAME: flags: DIFlagFixedEnum
+// CHECK: !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
+// CHECK: !DIEnumerator(name: "A1", value: 255, isUnsigned: true)
+
+enum class E2 : signed short {
+  A2 = -32768,
+  B2 = 32767,
+} x2;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E2"
+// CHECK-SAME: flags: DIFlagFixedEnum
+// CHECK: !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
+// CHECK: !DIEnumerator(name: "A2", value: -32768)
+// CHECK: !DIEnumerator(name: "B2", value: 32767)
+
+enum class E3 : unsigned short { A3 = 65535 } x3;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E3"
+// CHECK-SAME: DIFlagFixedEnum
+// CHECK: !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)
+// CHECK: !DIEnumerator(name: "A3", value: 65535, isUnsigned: true)
+
+enum class E4 : signed int { A4 = -2147483648, B4 = 2147483647 } x4;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E4"
+// CHECK-SAME: flags: DIFlagFixedEnum
+// CHECK: ![[INT:[0-9]+]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// CHECK: !DIEnumerator(name: "A4", value: -2147483648)
+// CHECK: !DIEnumerator(name: "B4", value: 2147483647)
+
+enum class E5 : unsigned int { A5 = 4294967295 } x5;
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "E5"
+// CHECK-SAME: flags: DIFlagFixedEnum
+// CHECK: !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+// CHECK: !DIEnumerator(name: "A5", value: 

r323896 - Revert "[AMDGPU] Add ds_fadd, ds_fmin, ds_fmax builtins functions"

2018-02-01 Thread Daniil Fukalov via cfe-commits
Author: dfukalov
Date: Wed Jan 31 10:49:49 2018
New Revision: 323896

URL: http://llvm.org/viewvc/llvm-project?rev=323896=rev
Log:
Revert "[AMDGPU] Add ds_fadd, ds_fmin, ds_fmax builtins functions"

This reverts https://reviews.llvm.org/rL323890

This reverts commit 251524ebd8c346a936f0e74b09d609d49fbaae4a.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=323896=323895=323896=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Wed Jan 31 10:49:49 2018
@@ -93,9 +93,6 @@ BUILTIN(__builtin_amdgcn_ds_bpermute, "i
 BUILTIN(__builtin_amdgcn_readfirstlane, "ii", "nc")
 BUILTIN(__builtin_amdgcn_readlane, "iii", "nc")
 BUILTIN(__builtin_amdgcn_fmed3f, "", "nc")
-BUILTIN(__builtin_amdgcn_ds_fadd, "ff*3fiib", "n")
-BUILTIN(__builtin_amdgcn_ds_fmin, "ff*3fiib", "n")
-BUILTIN(__builtin_amdgcn_ds_fmax, "ff*3fiib", "n")
 
 
//===--===//
 // VI+ only builtins.

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl?rev=323896=323895=323896=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl Wed Jan 31 10:49:49 2018
@@ -89,23 +89,3 @@ void test_mov_dpp(global int* out, int s
   *out = __builtin_amdgcn_mov_dpp(src, 0, 0, 0, false);
 }
 
-// CHECK-LABEL: @test_ds_fadd
-// CHECK: call float @llvm.amdgcn.ds.fadd(float addrspace(3)* %out, float 
%src, i32 0, i32 0, i1 false)
-void test_ds_fadd(local float *out, float src)
-{
-  *out = __builtin_amdgcn_ds_fadd(out, src, 0, 0, false);
-}
-
-// CHECK-LABEL: @test_ds_fmin
-// CHECK: call float @llvm.amdgcn.ds.fmin(float addrspace(3)* %out, float 
%src, i32 0, i32 0, i1 false)
-void test_ds_fmin(local float *out, float src)
-{
-  *out = __builtin_amdgcn_ds_fmin(out, src, 0, 0, false);
-}
-
-// CHECK-LABEL: @test_ds_fmax
-// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* %out, float 
%src, i32 0, i32 0, i1 false)
-void test_ds_fmax(local float *out, float src)
-{
-  *out = __builtin_amdgcn_ds_fmax(out, src, 0, 0, false);
-}


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


[PATCH] D42742: [clangd] Use pthread instead of thread_local to support more runtimes.

2018-02-01 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Is there some way to figure out what's going on in 
clang-x86_64-linux-selfhost-modules?

I believe there should be no linux builders which are missing this function -- 
it was added to libgcc in 4.8, and we don't support older versions, so I think 
missing this function on a linux build must be a misconfiguration of some sort.


Repository:
  rL LLVM

https://reviews.llvm.org/D42742



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


[PATCH] D42796: [clangd] Skip inline namespace when collecting scopes for index symbols.

2018-02-01 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice catch, and nice fix! Might be worth adding a motivating example to the 
patch description.




Comment at: clangd/index/SymbolCollector.cpp:68
+// For a symbol "a::b::c", return "a::b::". Scope is empty if there's no
+// qualifier. Inline namespaces and unscoped enums are skipped.
+llvm::Expected getScope(const NamedDecl *ND) {

I'd expand on this for inline namespaces a little, because it's non-obvious. 
e.g.

  // Inline namespaces are treated as transparent scopes.
  // This reflects the way they're most commonly used for lookup.
  // Ideally we'd include them, but at query time it's hard to find all the 
inline
  // namespaces to query: the preamble doesn't have a dedicated list.

Conversely, I don't think you need to explicitly mention unscoped enums 
anymore, because the behavior for transparent scopes is the obvious one, and we 
shouldn't need any special code handling enums (see below suggestions).



Comment at: clangd/index/SymbolCollector.cpp:71
+  llvm::SmallVector Contexts;
+  for (const auto *Context = ND->getDeclContext(); Context;
+   Context = Context->getParent()) {

if the condition is `!Context->isTranslationUnit()` you can skip the break 
inside, which I think reads more naturally. You'll never reach null - only TU 
can have a null parent I think.



Comment at: clangd/index/SymbolCollector.cpp:71
+  llvm::SmallVector Contexts;
+  for (const auto *Context = ND->getDeclContext(); Context;
+   Context = Context->getParent()) {

sammccall wrote:
> if the condition is `!Context->isTranslationUnit()` you can skip the break 
> inside, which I think reads more naturally. You'll never reach null - only TU 
> can have a null parent I think.
uber-nit: I think `DC` is pretty common in clang to refer to a DeclContext - 
once I got used to it, it seems less ambiguous than Context. Up to you though.



Comment at: clangd/index/SymbolCollector.cpp:73
+   Context = Context->getParent()) {
+if (llvm::isa(Context) ||
+llvm::isa(Context))

I'm not sure this is always correct: at least clang accepts this code:

  namespace X { extern "C++" { int y; }}

and you'll emit "y" instead of "X::y".

I think the check you want is

  if (Context->isTransparentContext() || Context->isInlineNamespace())
continue;

 isTransparentContext will handle the Namespace and Enum cases as you do below, 
including the enum/enum class distinction.

(The code you have below is otherwise correct, I think - but a reader needs to 
think about more separate cases in order to see that)



Comment at: clangd/index/SymbolCollector.cpp:76
+  break;
+
+if (const auto *NSD = dyn_cast(Context)) {

With the changes suggested above, I think we only get to this point in these 
cases:
 1. non-inline namespace
 2. decl is in some other named scope (class, scoped enum, ...)

Currently case 2 is symbols we're not indexing: shouldFilterDecl() should be 
false. So this is a programming error. So I think we just want

  Contexts.push_back(cast(Context)->getName());

which includes an assertion. Returning Expected seems weird here - we should 
never hit it unless a precondition is violated.



Comment at: clangd/index/SymbolCollector.cpp:90
+  }
+  std::string Scope = llvm::join(Contexts.rbegin(), Contexts.rend(), "::");
+  if (!Scope.empty())

(nit: might be slightly more obvious just to write the for loop and avoid the 
special case, up to you)



Comment at: clangd/index/SymbolCollector.cpp:113
   // violations.
   if (ND->isInAnonymousNamespace())
 return true;

Hmm, if this is ever hot-path, we may want to eventually combine "determine 
scope" and "shouldFilter" somewhat. shouldFilterDecl is doing much the same 
upwards-scope-traversal, and it seems pretty redundant.

Nothing to do for now though.



Comment at: clangd/index/SymbolCollector.cpp:195
 llvm::SmallString<128> USR;
+if (ND->getIdentifier() == nullptr)
+  return true;

hokein wrote:
> Consider moving to `shouldFilterDecl`? We also have a check `if 
> (ND->getDeclName().isEmpty())` there, which I assume does similar thing. 
hmm, what case is this handling? should `shouldFilterDecl` catch it?



Comment at: unittests/clangd/SymbolCollectorTests.cpp:326
 
+TEST_F(SymbolCollectorTest, Scopes) {
+  const std::string Header = R"(

you could consider modifying one of the testcases to have a weird 
linkage-spec-inside-namespace thing I mentioned :-)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42796



___
cfe-commits mailing list

[PATCH] D42812: [clang-tidy] ObjC ARC objects should not trigger performance-unnecessary-value-param

2018-02-01 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: alexfh, hokein.
Herald added subscribers: cfe-commits, xazax.hun, klimek.

The following Objective-C code currently incorrectly triggers
clang-tidy's performance-unnecessary-value-param check:

  % cat /tmp/performance-unnecessary-value-param-arc.m
  void foo(id object) { }
  
  clang-tidy /tmp/performance-unnecessary-value-param-arc.m
  -checks=-\*,performance-unnecessary-value-param -- -xobjective-c
  -fobjc-abi-version=2 -fobjc-arc
  1 warning generated.
  
/src/llvm/tools/clang/tools/extra/test/clang-tidy/performance-unnecessary-value-param-arc.m:10:13:
  warning: the parameter 'object' is copied for each invocation but only
  used as a const reference; consider making it a const reference
  [performance-unnecessary-value-param]
  void foo(id object) { }
   ~~ ^
   const &

This is wrong for a few reasons:

1. Objective-C doesn't have references, so `const &` is not going to help
2. ARC heavily optimizes the "expensive" copy which triggers the warning

This fixes the issue by disabling the warning for non-C++, as well as
disabling it for objects under ARC memory management for
Objective-C++.

Test Plan: New tests added. Ran tests with `make -j12 check-clang-tools`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D42812

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/utils/TypeTraits.cpp
  test/clang-tidy/performance-unnecessary-value-param-arc.m
  test/clang-tidy/performance-unnecessary-value-param-arc.mm


Index: test/clang-tidy/performance-unnecessary-value-param-arc.mm
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-arc.mm
@@ -0,0 +1,16 @@
+// RUN: clang-tidy %s -checks=-*,performance-unnecessary-value-param -- \
+// RUN:   -xobjective-c++ -fobjc-abi-version=2 -fobjc-arc | count 0
+
+#if !__has_feature(objc_arc)
+#error Objective-C ARC not enabled as expected
+#endif
+
+// Passing an Objective-C ARC-managed object to a C function should
+// not raise performance-unnecessary-value-param.
+void foo(id object) { }
+
+// Same for explcitly non-ARC-managed Objective-C objects.
+void bar(__unsafe_unretained id object) { }
+
+// Same for Objective-c classes.
+void baz(Class c) { }
Index: test/clang-tidy/performance-unnecessary-value-param-arc.m
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-arc.m
@@ -0,0 +1,16 @@
+// RUN: clang-tidy %s -checks=-*,performance-unnecessary-value-param -- \
+// RUN:   -xobjective-c -fobjc-abi-version=2 -fobjc-arc | count 0
+
+#if !__has_feature(objc_arc)
+#error Objective-C ARC not enabled as expected
+#endif
+
+// Passing an Objective-C ARC-managed object to a C function should
+// not raise performance-unnecessary-value-param.
+void foo(id object) { }
+
+// Same for explcitly non-ARC-managed Objective-C objects.
+void bar(__unsafe_unretained id object) { }
+
+// Same for Objective-c classes.
+void baz(Class c) { }
Index: clang-tidy/utils/TypeTraits.cpp
===
--- clang-tidy/utils/TypeTraits.cpp
+++ clang-tidy/utils/TypeTraits.cpp
@@ -45,7 +45,8 @@
 return llvm::None;
   return !Type.isTriviallyCopyableType(Context) &&
  !classHasTrivialCopyAndDestroy(Type) &&
- !hasDeletedCopyConstructor(Type);
+ !hasDeletedCopyConstructor(Type) &&
+ !Type->isObjCLifetimeType();
 }
 
 bool recordIsTriviallyDefaultConstructible(const RecordDecl ,
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -79,6 +79,10 @@
   Options.getLocalOrGlobal("IncludeStyle", "llvm"))) {}
 
 void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) {
+  // This check is specific to C++ and doesn't apply to languages like
+  // Objective-C.
+  if (!getLangOpts().CPlusPlus)
+return;
   const auto ExpensiveValueParamDecl =
   parmVarDecl(hasType(hasCanonicalType(allOf(
   unless(referenceType()), 
matchers::isExpensiveToCopy(,


Index: test/clang-tidy/performance-unnecessary-value-param-arc.mm
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param-arc.mm
@@ -0,0 +1,16 @@
+// RUN: clang-tidy %s -checks=-*,performance-unnecessary-value-param -- \
+// RUN:   -xobjective-c++ -fobjc-abi-version=2 -fobjc-arc | count 0
+
+#if !__has_feature(objc_arc)
+#error Objective-C ARC not enabled as expected
+#endif
+
+// Passing an Objective-C ARC-managed object to a C function should
+// not raise performance-unnecessary-value-param.
+void foo(id object) { }
+
+// Same for explcitly non-ARC-managed 

[PATCH] D42645: New simple Checker for mmap calls

2018-02-01 Thread David CARLIER via Phabricator via cfe-commits
devnexen updated this revision to Diff 132459.

Repository:
  rC Clang

https://reviews.llvm.org/D42645

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp

Index: lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -0,0 +1,78 @@
+// MmapWriteExecChecker.cpp - Check for the prot argument -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This checker tests the 3rd argument of mmap's calls to check if
+// it is writable and executable in the same time. It's somehow
+// an optional checker since for example in JIT libraries it is pretty common.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+using llvm::APSInt;
+
+namespace {
+class MmapWriteExecChecker : public Checker {
+  CallDescription MmapFn;
+  static int ProtWrite;
+  static int ProtExec;
+  mutable std::unique_ptr BT;
+public:
+  MmapWriteExecChecker() : MmapFn("mmap") {}
+  void checkPreCall(const CallEvent , CheckerContext ) const;
+};
+}
+
+int MmapWriteExecChecker::ProtWrite = 0x02;
+int MmapWriteExecChecker::ProtExec  = 0x04;
+
+void MmapWriteExecChecker::checkPreCall(const CallEvent ,
+ CheckerContext ) const {
+  if (Call.isCalled(MmapFn)) {
+if (Call.getNumArgs() < 3)
+  return;
+
+llvm::Triple Triple = C.getASTContext().getTargetInfo().getTriple();
+
+if (Triple.isOSGlibc())
+  ProtExec = 0x01;
+
+SVal ProtVal = Call.getArgSVal(2); 
+Optional ProtLoc = ProtVal.getAs();
+int64_t Prot = ProtLoc->getValue().getSExtValue();
+
+if ((Prot & (ProtWrite | ProtExec)) == (ProtWrite | ProtExec)) {
+  if (!BT)
+BT.reset(new BugType(this, "W^X check fails", "Write Exec prot flags set"));
+
+  ExplodedNode *N = C.generateNonFatalErrorNode();
+  if (!N)
+return;
+
+  auto Report = llvm::make_unique(
+  *BT, "Both PROT_WRITE and PROT_EXEC flags had been set. It can "
+   "leads to exploitable memory regions, overwritten with malicious code"
+ , N);
+  Report->addRange(Call.getArgSourceRange(2));
+  C.emitReport(std::move(Report));
+}
+  }
+}
+
+void ento::registerMmapWriteExecChecker(CheckerManager ) {
+  mgr.registerChecker();
+}
Index: lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -49,6 +49,7 @@
   MallocChecker.cpp
   MallocOverflowSecurityChecker.cpp
   MallocSizeofChecker.cpp
+  MmapWriteExecChecker.cpp
   MisusedMovedObjectChecker.cpp
   MPI-Checker/MPIBugReporter.cpp
   MPI-Checker/MPIChecker.cpp
Index: include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -86,7 +86,7 @@
 
 // The APIModeling package is for checkers that model APIs and don't perform
 // any diagnostics. These checkers are always turned on; this package is
-// intended for API modeling that is not controlled by the target triple.
+// intended for API modeling that is not controlled by the the target triple.
 def APIModeling : Package<"apiModeling">, Hidden;
 def GoogleAPIModeling : Package<"google">, InPackage;
 
@@ -394,6 +394,10 @@
   def FloatLoopCounter : Checker<"FloatLoopCounter">,
 HelpText<"Warn on using a floating point value as a loop counter (CERT: FLP30-C, FLP30-CPP)">,
 DescFile<"CheckSecuritySyntaxOnly.cpp">;
+
+  def MmapWriteExecChecker : Checker<"MmapWriteExec">,
+HelpText<"Check if mmap() call is not both writable and executable">,
+DescFile<"MmapWriteExecChecker.cpp">;
 }
 
 let ParentPackage = SecurityAlpha in {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42776: [Sema] Fix an assertion failure in constant expression evaluation of calls to functions with default arguments

2018-02-01 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Hi Akira, thanks for working on this!




Comment at: lib/AST/ExprConstant.cpp:1165-1173
+  auto LB = Temporaries.lower_bound(Key);
+
+  // If an element with key Key is found, reset the value and return it. This
+  // can happen if Key is part of a default argument expression.
+  if (LB != Temporaries.end() && LB->first == Key)
+return LB->second = APValue();
+

I think that the problem is more subtle than this. This static assert errors 
(previously clang would assert) when it really it should be fine.
```
constexpr const int (const int  = 0) { return p; }
static_assert(() != ());
```
Because default arguments are allocated on the caller side, both the calls to 
`x()` call createTemporary for the same MaterializeTemporaryExpr in the same 
CallStackFrame, when really that MTE should correspond to two distinct values. 
This patch just hides that underlying problem by recycling the value created 
during the first call during the second call.

Maybe we could have a fancier key that incorporates a node on the caller side, 
such as the CXXDefaultArgExpr as well at the MTE, and store that fancy key in 
APValue::LValueBases? That would allow us generate distinct values for these 
MTEs, and also remember what expression originated it. What do you think about 
that?

There is small discussion about this problem here: 
https://bugs.llvm.org/show_bug.cgi?id=33140


https://reviews.llvm.org/D42776



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


[PATCH] D42819: [analyzer] [tests] [NFC] Remove dead code from CmpRuns

2018-02-01 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC324027: [analyzer] [tests] [NFC] Remove dead code from 
CmpRuns (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D42819

Files:
  utils/analyzer/CmpRuns.py


Index: utils/analyzer/CmpRuns.py
===
--- utils/analyzer/CmpRuns.py
+++ utils/analyzer/CmpRuns.py
@@ -203,10 +203,8 @@
 compareResults - Generate a relation from diagnostics in run A to
 diagnostics in run B.
 
-The result is the relation as a list of triples (a, b, confidence) where
-each element {a,b} is None or an element from the respective run, and
-confidence is a measure of the match quality (where 0 indicates equality,
-and None is used if either element is None).
+The result is the relation as a list of triples (a, b) where
+each element {a,b} is None or a matching element from the respective run
 """
 
 res = []
@@ -236,7 +234,7 @@
 path_difference_data.append(
 a.getPathLength() - b.getPathLength())
 
-res.append((a, b, 0))
+res.append((a, b))
 elif a.getIssueIdentifier() > b.getIssueIdentifier():
 eltsB.append(b)
 neqA.append(a)
@@ -253,9 +251,9 @@
 # in any way on the diagnostic format.
 
 for a in neqA:
-res.append((a, None, None))
+res.append((a, None))
 for b in neqB:
-res.append((None, b, None))
+res.append((None, b))
 
 if opts.relative_log_path_histogram or opts.relative_path_histogram or \
 opts.absolute_path_histogram:
@@ -281,9 +279,8 @@
 foundDiffs = 0
 totalAdded = 0
 totalRemoved = 0
-totalChanged = 0
 for res in diff:
-a, b, confidence = res
+a, b = res
 if a is None:
 print "ADDED: %r" % b.getReadableName()
 foundDiffs += 1
@@ -298,26 +295,14 @@
 if auxLog:
 print >>auxLog, ("('REMOVED', %r, %r)" % (a.getReadableName(),
   a.getReport()))
-elif confidence:
-print "CHANGED: %r to %r" % (a.getReadableName(),
- b.getReadableName())
-foundDiffs += 1
-totalChanged += 1
-if auxLog:
-print >>auxLog, ("('CHANGED', %r, %r, %r, %r)"
- % (a.getReadableName(),
-b.getReadableName(),
-a.getReport(),
-b.getReport()))
 else:
 pass
 
 TotalReports = len(resultsB.diagnostics)
 print "TOTAL REPORTS: %r" % TotalReports
 print "TOTAL DIFFERENCES: %r" % foundDiffs
 print "TOTAL ADDED: %r" % totalAdded
 print "TOTAL REMOVED: %r" % totalRemoved
-print "TOTAL CHANGED: %r" % totalChanged
 if auxLog:
 print >>auxLog, "('TOTAL NEW REPORTS', %r)" % TotalReports
 print >>auxLog, "('TOTAL DIFFERENCES', %r)" % foundDiffs


Index: utils/analyzer/CmpRuns.py
===
--- utils/analyzer/CmpRuns.py
+++ utils/analyzer/CmpRuns.py
@@ -203,10 +203,8 @@
 compareResults - Generate a relation from diagnostics in run A to
 diagnostics in run B.
 
-The result is the relation as a list of triples (a, b, confidence) where
-each element {a,b} is None or an element from the respective run, and
-confidence is a measure of the match quality (where 0 indicates equality,
-and None is used if either element is None).
+The result is the relation as a list of triples (a, b) where
+each element {a,b} is None or a matching element from the respective run
 """
 
 res = []
@@ -236,7 +234,7 @@
 path_difference_data.append(
 a.getPathLength() - b.getPathLength())
 
-res.append((a, b, 0))
+res.append((a, b))
 elif a.getIssueIdentifier() > b.getIssueIdentifier():
 eltsB.append(b)
 neqA.append(a)
@@ -253,9 +251,9 @@
 # in any way on the diagnostic format.
 
 for a in neqA:
-res.append((a, None, None))
+res.append((a, None))
 for b in neqB:
-res.append((None, b, None))
+res.append((None, b))
 
 if opts.relative_log_path_histogram or opts.relative_path_histogram or \
 opts.absolute_path_histogram:
@@ -281,9 +279,8 @@
 foundDiffs = 0
 totalAdded = 0
 totalRemoved = 0
-totalChanged = 0
 for res in diff:
-a, b, confidence = res
+a, b = res
 if a is None:
 print "ADDED: %r" % b.getReadableName()
 foundDiffs += 1
@@ -298,26 +295,14 @@
 if auxLog:
 print 

r324018 - [analyzer] Don't communicate evaluation failures through memregion hierarchy.

2018-02-01 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Feb  1 14:17:05 2018
New Revision: 324018

URL: http://llvm.org/viewvc/llvm-project?rev=324018=rev
Log:
[analyzer] Don't communicate evaluation failures through memregion hierarchy.

We use CXXTempObjectRegion exclusively as a bailout value for construction
targets when we are unable to find the correct construction region.
Sometimes it works correctly, but rather accidentally than intentionally.

Now that we want to increase the amount of situations where it works correctly,
the first step is to introduce a different way of communicating our failure
to find the correct construction region. EvalCallOptions are introduced
for this purpose.

For now EvalCallOptions are communicating two kinds of problems:
- We have been completely unable to find the correct construction site.
- We have found the construction site correctly, and there's more than one of
  them (i.e. array construction which we currently don't support).

Accidentally find and fix a test in which the new approach to communicating
failures produces better results.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/test/Analysis/new.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=324018=324017=324018=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Thu 
Feb  1 14:17:05 2018
@@ -567,6 +567,13 @@ public:
   const LocationContext *LCtx,
   ProgramStateRef State);
 
+  struct EvalCallOptions {
+bool IsConstructorWithImproperlyModeledTargetRegion = false;
+bool IsArrayConstructorOrDestructor = false;
+
+EvalCallOptions() {}
+  };
+
   /// Evaluate a call, running pre- and post-call checks and allowing checkers
   /// to be responsible for handling the evaluation of the call itself.
   void evalCall(ExplodedNodeSet , ExplodedNode *Pred,
@@ -574,7 +581,9 @@ public:
 
   /// \brief Default implementation of call evaluation.
   void defaultEvalCall(NodeBuilder , ExplodedNode *Pred,
-   const CallEvent );
+   const CallEvent ,
+   const EvalCallOptions  = {});
+
 private:
   void evalLoadCommon(ExplodedNodeSet ,
   const Expr *NodeEx,  /* Eventually will be a CFGStmt */
@@ -598,9 +607,23 @@ private:
   void examineStackFrames(const Decl *D, const LocationContext *LCtx,
   bool , unsigned );
 
+  enum CallInlinePolicy {
+CIP_Allowed,
+CIP_DisallowedOnce,
+CIP_DisallowedAlways
+  };
+
+  /// \brief See if a particular call should be inlined, by only looking
+  /// at the call event and the current state of analysis.
+  CallInlinePolicy mayInlineCallKind(const CallEvent ,
+ const ExplodedNode *Pred,
+ AnalyzerOptions ,
+ const EvalCallOptions );
+
   /// Checks our policies and decides weither the given call should be inlined.
   bool shouldInlineCall(const CallEvent , const Decl *D,
-const ExplodedNode *Pred);
+const ExplodedNode *Pred,
+const EvalCallOptions  = {});
 
   bool inlineCall(const CallEvent , const Decl *D, NodeBuilder ,
   ExplodedNode *Pred, ProgramStateRef State);
@@ -650,11 +673,11 @@ private:
 
   /// For a given constructor, look forward in the current CFG block to
   /// determine the region into which an object will be constructed by \p CE.
-  /// Returns either a field or local variable region if the object will be
-  /// directly constructed in an existing region or a temporary object region
-  /// if not.
+  /// When the lookahead fails, a temporary region is returned, and the
+  /// IsConstructorWithImproperlyModeledTargetRegion flag is set in \p 
CallOpts.
   const MemRegion *getRegionForConstructedObject(const CXXConstructExpr *CE,
- ExplodedNode *Pred);
+ ExplodedNode *Pred,
+ EvalCallOptions );
 
   /// Store the region returned by operator new() so that the constructor
   /// that follows it knew what location to initialize. The value should be

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
URL: 

r324021 - [analyzer] [tests] Add an option to show the histogram of path differences between the analyzer runs

2018-02-01 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Feb  1 14:25:18 2018
New Revision: 324021

URL: http://llvm.org/viewvc/llvm-project?rev=324021=rev
Log:
[analyzer] [tests] Add an option to show the histogram of path differences 
between the analyzer runs

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

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

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=324021=324020=324021=diff
==
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Thu Feb  1 14:25:18 2018
@@ -28,6 +28,7 @@ Usage:
 
 import os
 import plistlib
+from math import log
 
 
 # Information about analysis run:
@@ -47,6 +48,7 @@ class AnalysisDiagnostic:
 self._loc = self._data['location']
 self._report = report
 self._htmlReport = htmlReport
+self._reportSize = len(self._data['path'])
 
 def getFileName(self):
 root = self._report.run.root
@@ -61,6 +63,9 @@ class AnalysisDiagnostic:
 def getColumn(self):
 return self._loc['col']
 
+def getPathLength(self):
+return self._reportSize
+
 def getCategory(self):
 return self._data['category']
 
@@ -193,7 +198,7 @@ def cmpAnalysisDiagnostic(d):
 return d.getIssueIdentifier()
 
 
-def compareResults(A, B):
+def compareResults(A, B, opts):
 """
 compareResults - Generate a relation from diagnostics in run A to
 diagnostics in run B.
@@ -206,6 +211,9 @@ def compareResults(A, B):
 
 res = []
 
+# Map size_before -> size_after
+path_difference_data = []
+
 # Quickly eliminate equal elements.
 neqA = []
 neqB = []
@@ -217,6 +225,17 @@ def compareResults(A, B):
 a = eltsA.pop()
 b = eltsB.pop()
 if (a.getIssueIdentifier() == b.getIssueIdentifier()):
+if a.getPathLength() != b.getPathLength():
+if opts.relative_path_histogram:
+path_difference_data.append(
+float(a.getPathLength()) / b.getPathLength())
+elif opts.relative_log_path_histogram:
+path_difference_data.append(
+log(float(a.getPathLength()) / b.getPathLength()))
+elif opts.absolute_path_histogram:
+path_difference_data.append(
+a.getPathLength() - b.getPathLength())
+
 res.append((a, b, 0))
 elif a.getIssueIdentifier() > b.getIssueIdentifier():
 eltsB.append(b)
@@ -238,6 +257,12 @@ def compareResults(A, B):
 for b in neqB:
 res.append((None, b, None))
 
+if opts.relative_log_path_histogram or opts.relative_path_histogram or \
+opts.absolute_path_histogram:
+from matplotlib import pyplot
+pyplot.hist(path_difference_data, bins=100)
+pyplot.show()
+
 return res
 
 
@@ -252,7 +277,7 @@ def dumpScanBuildResultsDiff(dirA, dirB,
 else:
 auxLog = None
 
-diff = compareResults(resultsA, resultsB)
+diff = compareResults(resultsA, resultsB, opts)
 foundDiffs = 0
 totalAdded = 0
 totalRemoved = 0
@@ -314,6 +339,21 @@ def main():
   [default=None]",
   action="store", type=str, default=None,
   metavar="LOG")
+parser.add_option("--relative-path-differences-histogram",
+  action="store_true", dest="relative_path_histogram",
+  default=False,
+  help="Show histogram of relative paths differences. \
+  Requires matplotlib")
+parser.add_option("--relative-log-path-differences-histogram",
+  action="store_true", dest="relative_log_path_histogram",
+  default=False,
+  help="Show histogram of log relative paths differences. \
+  Requires matplotlib")
+parser.add_option("--absolute-path-differences-histogram",
+  action="store_true", dest="absolute_path_histogram",
+  default=False,
+  help="Show histogram of absolute paths differences. \
+  Requires matplotlib")
 (opts, args) = parser.parse_args()
 
 if len(args) != 2:


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


[PATCH] D41746: Make std::get_temporary_buffer respect overaligned types when possible

2018-02-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX324020: Make std::get_temporary_buffer respect overaligned 
types when possible (authored by rsmith, committed by ).

Repository:
  rCXX libc++

https://reviews.llvm.org/D41746

Files:
  include/memory
  test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp

Index: include/memory
===
--- include/memory
+++ include/memory
@@ -2004,7 +2004,38 @@
 __n = __m;
 while (__n > 0)
 {
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
+#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
+if (std::alignment_of<_Tp>::value > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
+#else
+if (std::alignment_of<_Tp>::value >
+std::alignment_of::value)
+#endif
+{
+std::align_val_t __al =
+std::align_val_t(std::alignment_of<_Tp>::value);
+__r.first = static_cast<_Tp*>(::operator new(
+__n * sizeof(_Tp), __al, nothrow));
+} else {
+__r.first = static_cast<_Tp*>(::operator new(
+__n * sizeof(_Tp), nothrow));
+}
+#else
+#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
+if (std::alignment_of<_Tp>::value > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
+#else
+if (std::alignment_of<_Tp>::value >
+std::alignment_of::value)
+#endif
+{
+// Since aligned operator new is unavailable, return an empty
+// buffer rather than one with invalid alignment.
+return __r;
+}
+
 __r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), nothrow));
+#endif
+
 if (__r.first)
 {
 __r.second = __n;
@@ -2017,7 +2048,23 @@
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-void return_temporary_buffer(_Tp* __p) _NOEXCEPT {::operator delete(__p);}
+void return_temporary_buffer(_Tp* __p) _NOEXCEPT
+{
+#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION)
+#if defined(__STDCPP_DEFAULT_NEW_ALIGNMENT__)
+if (std::alignment_of<_Tp>::value > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
+#else
+if (std::alignment_of<_Tp>::value >
+std::alignment_of::value)
+#endif
+{
+std::align_val_t __al = std::align_val_t(std::alignment_of<_Tp>::value);
+::operator delete(__p, __al);
+return;
+}
+#endif
+::operator delete(__p);
+}
 
 #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
 template 
Index: test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
===
--- test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
+++ test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
@@ -0,0 +1,33 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template 
+//   pair
+//   get_temporary_buffer(ptrdiff_t n);
+//
+// template 
+//   void
+//   return_temporary_buffer(T* p);
+
+#include 
+#include 
+
+struct alignas(32) A {
+int field;
+};
+
+int main()
+{
+std::pair ip = std::get_temporary_buffer(5);
+assert(!(ip.first == nullptr) ^ (ip.second == 0));
+assert(reinterpret_cast(ip.first) % alignof(A) == 0);
+std::return_temporary_buffer(ip.first);
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r323155 - Introduce the "retpoline" x86 mitigation technique for variant #2 of the speculative execution vulnerabilities disclosed today, specifically identified by CVE-2017-5715, "Branch Target

2018-02-01 Thread Reid Kleckner via cfe-commits
I backported these to the release_50 branch in the following revisions:

llvm r324007, r324009
cfe r324012
lld r324025, r324026

The regression test suites pass on my machine with the exception of two
pre-existing failures. I also built my small retpoline execution test that
does a variety of indirect calls and tail calls, and it executes
successfully and the only indirect jumps in it come from crt0.o. That's the
same as what we get with trunk.

We might want to do more extensive testing of the flag with the 5.0
release, but I'm not sure what's next exactly.

On Thu, Feb 1, 2018 at 11:09 AM, Chandler Carruth 
wrote:

> +Hans Wennborg  +tstel...@redhat.com
> 
>
> So the retpoline patch series we should get back ported start with this
> revision and have two follow ups:
> r323155
> r323288
> r323915
>
> +Reid Kleckner  was going to look at doing the (likely
> more involved) backport to the 5 branch
>
> On Mon, Jan 22, 2018 at 2:06 PM Chandler Carruth via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: chandlerc
>> Date: Mon Jan 22 14:05:25 2018
>> New Revision: 323155
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=323155=rev
>> Log:
>> Introduce the "retpoline" x86 mitigation technique for variant #2 of the
>> speculative execution vulnerabilities disclosed today, specifically
>> identified by CVE-2017-5715, "Branch Target Injection", and is one of the
>> two halves to Spectre..
>>
>> Summary:
>> First, we need to explain the core of the vulnerability. Note that this
>> is a very incomplete description, please see the Project Zero blog post
>> for details:
>> https://googleprojectzero.blogspot.com/2018/01/reading-
>> privileged-memory-with-side.html
>>
>> The basis for branch target injection is to direct speculative execution
>> of the processor to some "gadget" of executable code by poisoning the
>> prediction of indirect branches with the address of that gadget. The
>> gadget in turn contains an operation that provides a side channel for
>> reading data. Most commonly, this will look like a load of secret data
>> followed by a branch on the loaded value and then a load of some
>> predictable cache line. The attacker then uses timing of the processors
>> cache to determine which direction the branch took *in the speculative
>> execution*, and in turn what one bit of the loaded value was. Due to the
>> nature of these timing side channels and the branch predictor on Intel
>> processors, this allows an attacker to leak data only accessible to
>> a privileged domain (like the kernel) back into an unprivileged domain.
>>
>> The goal is simple: avoid generating code which contains an indirect
>> branch that could have its prediction poisoned by an attacker. In many
>> cases, the compiler can simply use directed conditional branches and
>> a small search tree. LLVM already has support for lowering switches in
>> this way and the first step of this patch is to disable jump-table
>> lowering of switches and introduce a pass to rewrite explicit indirectbr
>> sequences into a switch over integers.
>>
>> However, there is no fully general alternative to indirect calls. We
>> introduce a new construct we call a "retpoline" to implement indirect
>> calls in a non-speculatable way. It can be thought of loosely as
>> a trampoline for indirect calls which uses the RET instruction on x86.
>> Further, we arrange for a specific call->ret sequence which ensures the
>> processor predicts the return to go to a controlled, known location. The
>> retpoline then "smashes" the return address pushed onto the stack by the
>> call with the desired target of the original indirect call. The result
>> is a predicted return to the next instruction after a call (which can be
>> used to trap speculative execution within an infinite loop) and an
>> actual indirect branch to an arbitrary address.
>>
>> On 64-bit x86 ABIs, this is especially easily done in the compiler by
>> using a guaranteed scratch register to pass the target into this device.
>> For 32-bit ABIs there isn't a guaranteed scratch register and so several
>> different retpoline variants are introduced to use a scratch register if
>> one is available in the calling convention and to otherwise use direct
>> stack push/pop sequences to pass the target address.
>>
>> This "retpoline" mitigation is fully described in the following blog
>> post: https://support.google.com/faqs/answer/7625886
>>
>> We also support a target feature that disables emission of the retpoline
>> thunk by the compiler to allow for custom thunks if users want them.
>> These are particularly useful in environments like kernels that
>> routinely do hot-patching on boot and want to hot-patch their thunk to
>> different code sequences. They can write this custom thunk and use
>> `-mretpoline-external-thunk` *in addition* to `-mretpoline`. In this
>> case, on x86-64 thu thunk names must be:
>> ```
>>   

[PATCH] D39571: [clangd] DidChangeConfiguration Notification

2018-02-01 Thread Simon Marchi via Phabricator via cfe-commits
simark added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:302
 
+// FIXME: This function needs to be properly tested.
+void ClangdLSPServer::onChangeConfiguration(

simark wrote:
> ilya-biryukov wrote:
> > simark wrote:
> > > simark wrote:
> > > > ilya-biryukov wrote:
> > > > > simark wrote:
> > > > > > ilya-biryukov wrote:
> > > > > > > simark wrote:
> > > > > > > > ilya-biryukov wrote:
> > > > > > > > > Are you planning to to address this FIXME before checking the 
> > > > > > > > > code in?
> > > > > > > > Following what you said here:
> > > > > > > > 
> > > > > > > > https://reviews.llvm.org/D39571?id=124024#inline-359345
> > > > > > > > 
> > > > > > > > I have not really looked into what was wrong with the test, and 
> > > > > > > > what is missing in the infrastructure to make it work.  But I 
> > > > > > > > assumed that the situation did not change since then.  Can you 
> > > > > > > > enlighten me on what the problem was, and what is missing?
> > > > > > > We usually write unittests for that kind of thing, since they 
> > > > > > > allow to plug an in-memory filesystem, but we only test 
> > > > > > > `ClangdServer` (examples are in 
> > > > > > > `unittests/clangd/ClangdTests.cpp`). `ClangdLSPServer` does not 
> > > > > > > allow to plug in a virtual filesystem (vfs). Even if we add vfs, 
> > > > > > > it's still hard to unit-test because we'll have to match the json 
> > > > > > > input/output directly.
> > > > > > > 
> > > > > > > This leaves us with an option of a lit test that runs `clangd` 
> > > > > > > directly, similar to tests in `test/clangd`.
> > > > > > > The lit test would need to create a temporary directory, create 
> > > > > > > proper `compile_commands.json` there, then send the LSP commands 
> > > > > > > with the path to the test to clangd.
> > > > > > > One major complication is that in LSP we have to specify the size 
> > > > > > > of each message, but in our case the size would change depending 
> > > > > > > on created temp path. It means we'll have to patch the test input 
> > > > > > > to setup proper paths and message sizes.
> > > > > > > If we choose to go down this path, 
> > > > > > > `clang-tools-extra/test/clang-tidy/vfsoverlay.cpp` does a similar 
> > > > > > > setup (create temp-dir, patch up some configuration files to 
> > > > > > > point into the temp directory, etc) and could be used as a 
> > > > > > > starting point.
> > > > > > > 
> > > > > > > It's not impossible to write that test, it's just a bit involved. 
> > > > > > > Having a test would be nice, though, to ensure we don't break 
> > > > > > > this method while doing other things. Especially given that this 
> > > > > > > functionality is not used anywhere in clangd.
> > > > > > > We usually write unittests for that kind of thing, since they 
> > > > > > > allow to plug an in-memory filesystem, but we only test 
> > > > > > > ClangdServer (examples are in unittests/clangd/ClangdTests.cpp). 
> > > > > > > ClangdLSPServer does not allow to plug in a virtual filesystem 
> > > > > > > (vfs). Even if we add vfs, it's still hard to unit-test because 
> > > > > > > we'll have to match the json input/output directly.
> > > > > > 
> > > > > > What do you mean by "we'll have to match the json input/output 
> > > > > > directly"?  That we'll have to match the complete JSON output 
> > > > > > textually?  Couldn't the test parse the JSON into some data 
> > > > > > structures, then we could assert specific things, like that this 
> > > > > > particular field is present and contains a certain substring, for 
> > > > > > example?
> > > > > > 
> > > > > > > This leaves us with an option of a lit test that runs clangd 
> > > > > > > directly, similar to tests in test/clangd.
> > > > > > > The lit test would need to create a temporary directory, create 
> > > > > > > proper compile_commands.json there, then send the LSP commands 
> > > > > > > with the path to the test to clangd.
> > > > > > > One major complication is that in LSP we have to specify the size 
> > > > > > > of each message, but in our case the size would change depending 
> > > > > > > on created temp path. It means we'll have to patch the test input 
> > > > > > > to setup proper paths and message sizes.
> > > > > > > If we choose to go down this path, 
> > > > > > > clang-tools-extra/test/clang-tidy/vfsoverlay.cpp does a similar 
> > > > > > > setup (create temp-dir, patch up some configuration files to 
> > > > > > > point into the temp directory, etc) and could be used as a 
> > > > > > > starting point.
> > > > > > 
> > > > > > Ok, I see the complication with the Content-Length.  I am not 
> > > > > > familiar with lit yet, so I don't know what it is capable of.  But 
> > > > > > being able to craft and send arbitrary LSP messages would certainly 
> > > > > > be helpful in the future for all kinds of black box test, so having 
> > > > > > a framework that allows to do this would be helpful, I think.  

[PATCH] D42810: [Sema] Add implicit members even for invalid CXXRecordDecls

2018-02-01 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


Repository:
  rC Clang

https://reviews.llvm.org/D42810



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


[PATCH] D42813: [Debug] Annotate compiler generated range-for loop variables.

2018-02-01 Thread Matt Davis via Phabricator via cfe-commits
mattd updated this revision to Diff 132464.
mattd added a comment.

Updating the diff, missed a few deltas that should have been in the original 
patch.


https://reviews.llvm.org/D42813

Files:
  include/clang/Sema/Scope.h
  lib/Sema/SemaStmt.cpp
  test/CodeGenCXX/debug-for-range-scope-hints.cpp
  test/CodeGenCXX/debug-info-scope.cpp
  test/CodeGenCXX/vla.cpp

Index: test/CodeGenCXX/vla.cpp
===
--- test/CodeGenCXX/vla.cpp
+++ test/CodeGenCXX/vla.cpp
@@ -68,8 +68,8 @@
 void test2(int b) {
   // CHECK-LABEL: define void {{.*}}test2{{.*}}(i32 %b)
   int varr[b];
-  // AMD: %__end = alloca i32*, align 8, addrspace(5)
-  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end to i32**
+  // AMD: %__end1 = alloca i32*, align 8, addrspace(5)
+  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end1 to i32**
   // get the address of %b by checking the first store that stores it 
   //CHECK: store i32 %b, i32* [[PTR_B:%.*]]
 
@@ -86,7 +86,7 @@
   //CHECK: [[VLA_SIZEOF:%.*]] = mul nuw i64 4, [[VLA_NUM_ELEMENTS_PRE]]
   //CHECK-NEXT: [[VLA_NUM_ELEMENTS_POST:%.*]] = udiv i64 [[VLA_SIZEOF]], 4
   //CHECK-NEXT: [[VLA_END_PTR:%.*]] = getelementptr inbounds i32, i32* {{%.*}}, i64 [[VLA_NUM_ELEMENTS_POST]]
-  //X64-NEXT: store i32* [[VLA_END_PTR]], i32** %__end
+  //X64-NEXT: store i32* [[VLA_END_PTR]], i32** %__end1
   //AMD-NEXT: store i32* [[VLA_END_PTR]], i32** [[END]]
   for (int d : varr) 0;
 }
@@ -94,8 +94,8 @@
 void test3(int b, int c) {
   // CHECK-LABEL: define void {{.*}}test3{{.*}}(i32 %b, i32 %c)
   int varr[b][c];
-  // AMD: %__end = alloca i32*, align 8, addrspace(5)
-  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end to i32**
+  // AMD: %__end1 = alloca i32*, align 8, addrspace(5)
+  // AMD: [[END:%.*]] = addrspacecast i32* addrspace(5)* %__end1 to i32**
   // get the address of %b by checking the first store that stores it 
   //CHECK: store i32 %b, i32* [[PTR_B:%.*]]
   //CHECK-NEXT: store i32 %c, i32* [[PTR_C:%.*]]
Index: test/CodeGenCXX/debug-info-scope.cpp
===
--- test/CodeGenCXX/debug-info-scope.cpp
+++ test/CodeGenCXX/debug-info-scope.cpp
@@ -58,7 +58,7 @@
   }
 
   int x[] = {1, 2};
-  // CHECK: = !DILocalVariable(name: "__range"
+  // CHECK: = !DILocalVariable(name: "__range1"
   // CHECK-SAME:   scope: [[RANGE_FOR:![0-9]*]]
   // CHECK-NOT:line:
   // CHECK-SAME:   ){{$}}
Index: test/CodeGenCXX/debug-for-range-scope-hints.cpp
===
--- test/CodeGenCXX/debug-for-range-scope-hints.cpp
+++ test/CodeGenCXX/debug-for-range-scope-hints.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
+struct vec {
+  using itr = int*;
+  itr begin() { return nullptr; }
+  itr end() { return nullptr; }
+};
+
+void test() {
+  vec as, bs, cs;
+
+  for (auto a : as)
+for (auto b : bs)
+  for (auto c : cs) {
+  }
+}
+
+// CHECK: define void @_Z4testv()
+// CHECK: call void @llvm.dbg.declare(metadata %struct.vec** {{.*}}, metadata ![[RANGE1:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[BEGIN1:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[END1:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata %struct.vec** {{.*}}, metadata ![[RANGE2:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[BEGIN2:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[END2:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata %struct.vec** {{.*}}, metadata ![[RANGE3:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[BEGIN3:[0-9]+]]
+// CHECK: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[END3:[0-9]+]]
+// CHECK: ![[RANGE1]] = !DILocalVariable(name: "__range1", {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[BEGIN1]] = !DILocalVariable(name: "__begin1", {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[END1]] = !DILocalVariable(name: "__end1",  {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[RANGE2]] = !DILocalVariable(name: "__range2",  {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[BEGIN2]] = !DILocalVariable(name: "__begin2", {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[END2]] = !DILocalVariable(name: "__end2",  {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[RANGE3]] = !DILocalVariable(name: "__range3",  {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[BEGIN3]] = !DILocalVariable(name: "__begin3", {{.*}}, flags: DIFlagArtificial)
+// CHECK: ![[END3]] = !DILocalVariable(name: "__end3", {{.*}}, flags: DIFlagArtificial)
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2025,7 +2025,7 @@
 
 /// Build a variable declaration for a for-range statement.

[PATCH] D42755: [libcxx] Fix last_write_time tests for filesystems that don't support very small times.

2018-02-01 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

In https://reviews.llvm.org/D42755#994775, @Hahnfeld wrote:

> Can you please add a summary that describes which filesystem this problem can 
> be seen with? I think outside people can't access rdar tickets, so I can only 
> guess that it's related to APFS? Further guessing the filesystem supports 
> negative timestamps in general but not `file_time_type::min()` (which 
> probably is `-2 ** 63`)?


Good suggestion for explaining the problem with `file_time_type::min()` in more 
detail. Also PR35990  has some 
details on how different filesystems handle `file_time_type::min()`. As the 
change doesn't fix the PR, I don't think it is worth mentioning it in the 
commit message but it can be still useful in code review discussion.


https://reviews.llvm.org/D42755



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


r324027 - [analyzer] [tests] [NFC] Remove dead code from CmpRuns

2018-02-01 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Feb  1 14:40:01 2018
New Revision: 324027

URL: http://llvm.org/viewvc/llvm-project?rev=324027=rev
Log:
[analyzer] [tests] [NFC] Remove dead code from CmpRuns

Indeed, "CHANGE" is not a thing yet, and we should probably not carry
around dead code which does not do anything apart from confusing the
reader.

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

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

Modified: cfe/trunk/utils/analyzer/CmpRuns.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/CmpRuns.py?rev=324027=324026=324027=diff
==
--- cfe/trunk/utils/analyzer/CmpRuns.py (original)
+++ cfe/trunk/utils/analyzer/CmpRuns.py Thu Feb  1 14:40:01 2018
@@ -203,10 +203,8 @@ def compareResults(A, B, opts):
 compareResults - Generate a relation from diagnostics in run A to
 diagnostics in run B.
 
-The result is the relation as a list of triples (a, b, confidence) where
-each element {a,b} is None or an element from the respective run, and
-confidence is a measure of the match quality (where 0 indicates equality,
-and None is used if either element is None).
+The result is the relation as a list of triples (a, b) where
+each element {a,b} is None or a matching element from the respective run
 """
 
 res = []
@@ -236,7 +234,7 @@ def compareResults(A, B, opts):
 path_difference_data.append(
 a.getPathLength() - b.getPathLength())
 
-res.append((a, b, 0))
+res.append((a, b))
 elif a.getIssueIdentifier() > b.getIssueIdentifier():
 eltsB.append(b)
 neqA.append(a)
@@ -253,9 +251,9 @@ def compareResults(A, B, opts):
 # in any way on the diagnostic format.
 
 for a in neqA:
-res.append((a, None, None))
+res.append((a, None))
 for b in neqB:
-res.append((None, b, None))
+res.append((None, b))
 
 if opts.relative_log_path_histogram or opts.relative_path_histogram or \
 opts.absolute_path_histogram:
@@ -281,9 +279,8 @@ def dumpScanBuildResultsDiff(dirA, dirB,
 foundDiffs = 0
 totalAdded = 0
 totalRemoved = 0
-totalChanged = 0
 for res in diff:
-a, b, confidence = res
+a, b = res
 if a is None:
 print "ADDED: %r" % b.getReadableName()
 foundDiffs += 1
@@ -298,17 +295,6 @@ def dumpScanBuildResultsDiff(dirA, dirB,
 if auxLog:
 print >>auxLog, ("('REMOVED', %r, %r)" % (a.getReadableName(),
   a.getReport()))
-elif confidence:
-print "CHANGED: %r to %r" % (a.getReadableName(),
- b.getReadableName())
-foundDiffs += 1
-totalChanged += 1
-if auxLog:
-print >>auxLog, ("('CHANGED', %r, %r, %r, %r)"
- % (a.getReadableName(),
-b.getReadableName(),
-a.getReport(),
-b.getReport()))
 else:
 pass
 
@@ -317,7 +303,6 @@ def dumpScanBuildResultsDiff(dirA, dirB,
 print "TOTAL DIFFERENCES: %r" % foundDiffs
 print "TOTAL ADDED: %r" % totalAdded
 print "TOTAL REMOVED: %r" % totalRemoved
-print "TOTAL CHANGED: %r" % totalChanged
 if auxLog:
 print >>auxLog, "('TOTAL NEW REPORTS', %r)" % TotalReports
 print >>auxLog, "('TOTAL DIFFERENCES', %r)" % foundDiffs


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


[PATCH] D42549: [CodeGen] Use the zero initializer instead of storing an all zero representation.

2018-02-01 Thread Matt Davis via Phabricator via cfe-commits
mattd added a comment.

Ping :)


https://reviews.llvm.org/D42549



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


[PATCH] D42813: [Debug] Annotate compiler generated range-for loop variables.

2018-02-01 Thread Matt Davis via Phabricator via cfe-commits
mattd created this revision.
mattd added a reviewer: rsmith.
mattd edited the summary of this revision.

This change aims to simplify debugging by annotating the range-for loop 
artificial variables (range, begin, end) with the scope depth.


https://reviews.llvm.org/D42813

Files:
  SemaStmt.cpp


Index: SemaStmt.cpp
===
--- SemaStmt.cpp
+++ SemaStmt.cpp
@@ -2025,7 +2025,7 @@
 
 /// Build a variable declaration for a for-range statement.
 VarDecl *BuildForRangeVarDecl(Sema , SourceLocation Loc,
-  QualType Type, const char *Name) {
+  QualType Type, StringRef Name) {
   DeclContext *DC = SemaRef.CurContext;
   IdentifierInfo *II = ().get(Name);
   TypeSourceInfo *TInfo = SemaRef.Context.getTrivialTypeSourceInfo(Type, Loc);
@@ -2093,11 +2093,13 @@
   return StmtError();
   }
 
-  // Build  auto && __range = range-init
+  // Build  auto && __range = range-init.
+  // Assume the variables are nested in the inner scope (loop body).
+  const auto DepthStr = std::to_string(S->getDepth() >> 1);
   SourceLocation RangeLoc = Range->getLocStart();
   VarDecl *RangeVar = BuildForRangeVarDecl(*this, RangeLoc,
Context.getAutoRRefDeductType(),
-   "__range");
+   std::string("__range") + DepthStr);
   if (FinishForRangeVarDecl(*this, RangeVar, Range, RangeLoc,
 diag::err_for_range_deduction_failure)) {
 LoopVar->setInvalidDecl();
@@ -2340,10 +2342,12 @@
   return StmtError();
 
 // Build auto __begin = begin-expr, __end = end-expr.
+// Assume the variables are nested in the inner scope (loop body).
+const auto DepthStr = std::to_string(S->getDepth() >> 1);
 VarDecl *BeginVar = BuildForRangeVarDecl(*this, ColonLoc, AutoType,
- "__begin");
+ std::string("__begin") + 
DepthStr);
 VarDecl *EndVar = BuildForRangeVarDecl(*this, ColonLoc, AutoType,
-   "__end");
+   std::string("__end") + DepthStr);
 
 // Build begin-expr and end-expr and attach to __begin and __end variables.
 ExprResult BeginExpr, EndExpr;


Index: SemaStmt.cpp
===
--- SemaStmt.cpp
+++ SemaStmt.cpp
@@ -2025,7 +2025,7 @@
 
 /// Build a variable declaration for a for-range statement.
 VarDecl *BuildForRangeVarDecl(Sema , SourceLocation Loc,
-  QualType Type, const char *Name) {
+  QualType Type, StringRef Name) {
   DeclContext *DC = SemaRef.CurContext;
   IdentifierInfo *II = ().get(Name);
   TypeSourceInfo *TInfo = SemaRef.Context.getTrivialTypeSourceInfo(Type, Loc);
@@ -2093,11 +2093,13 @@
   return StmtError();
   }
 
-  // Build  auto && __range = range-init
+  // Build  auto && __range = range-init.
+  // Assume the variables are nested in the inner scope (loop body).
+  const auto DepthStr = std::to_string(S->getDepth() >> 1);
   SourceLocation RangeLoc = Range->getLocStart();
   VarDecl *RangeVar = BuildForRangeVarDecl(*this, RangeLoc,
Context.getAutoRRefDeductType(),
-   "__range");
+   std::string("__range") + DepthStr);
   if (FinishForRangeVarDecl(*this, RangeVar, Range, RangeLoc,
 diag::err_for_range_deduction_failure)) {
 LoopVar->setInvalidDecl();
@@ -2340,10 +2342,12 @@
   return StmtError();
 
 // Build auto __begin = begin-expr, __end = end-expr.
+// Assume the variables are nested in the inner scope (loop body).
+const auto DepthStr = std::to_string(S->getDepth() >> 1);
 VarDecl *BeginVar = BuildForRangeVarDecl(*this, ColonLoc, AutoType,
- "__begin");
+ std::string("__begin") + DepthStr);
 VarDecl *EndVar = BuildForRangeVarDecl(*this, ColonLoc, AutoType,
-   "__end");
+   std::string("__end") + DepthStr);
 
 // Build begin-expr and end-expr and attach to __begin and __end variables.
 ExprResult BeginExpr, EndExpr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D42758: Support `#pragma comment(lib, "name")` in the frontend for ELF

2018-02-01 Thread Rui Ueyama via cfe-commits
On Wed, Jan 31, 2018 at 7:23 PM, Paul Robinson via Phabricator <
revi...@reviews.llvm.org> wrote:

> probinson added a comment.
>
> In https://reviews.llvm.org/D42758#993936, @ruiu wrote:
>
> > > I also wonder which is better `#pragma comment(lib, "m")` or `#pragma
> comment(lib, "m")`.
> >
> > Sorry, I meant `#pragma comment(lib, "m")` or `#pragma comment("lib",
> "m")`.
>
>
> I can't swear to it but I don't think Microsoft invented `#pragma
> comment`.  Various IBM compilers have it, with a syntax of `#pragma comment
> (  [ , "string" ] )`.  I'm not seeing a `lib` keyword specifically
> in the IBM docs, but being a keyword would be consistent with past practice.
>

Thank you for the info. If it's a common practice, I don't see a reason to
change that.

>
> 
> Comment at: lib/Parse/ParsePragma.cpp:299
> +  getTargetInfo().getTriple().isOSBinFormatELF()) {
>  MSCommentHandler.reset(new PragmaCommentHandler(Actions));
>  PP.AddPragmaHandler(MSCommentHandler.get());
> 
> PS4's binary format is ELF, so you should be able to remove the isPS4
> predicate.
>
>
> 
> Comment at: lib/Parse/ParsePragma.cpp:382
> +  getTargetInfo().getTriple().isOSBinFormatELF()) {
>  PP.RemovePragmaHandler(MSCommentHandler.get());
>  MSCommentHandler.reset();
> 
> Don't need isPS4, as it uses ELF.
>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D42758
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42811: [CodeGen][va_args] Correct Vector Struct va-arg 'in_reg' code gen

2018-02-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rsmith, rjmccall.

When trying to track down a different bug, we discovered
that calling `__builtin_va_arg` on a vec3f type caused
the SROA pass to issue a warning that there was an illegal
access.

Further research showed that the vec3f type is
alloca'ed as size '12', but the `_builtin_va_arg` code
on x86_64 was always loading this out of registers as 
{double, double}. Thus, the 2nd store into the vec3f
was storing in bytes 12-15!

This patch alters the original implementation which always
assumed {double, double} to use the actual coerced type 
instead, so the LLVM-IR generated is a load/GEP/store of
a <2 x float> and a float, rather than a double and a double.

Tests were added for all combinations I could think of that
would fit in 2 FP registers, and all work exactly as expected.


Repository:
  rC Clang

https://reviews.llvm.org/D42811

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/x86_64-floatvectors.c

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -3790,17 +3790,18 @@
 Address RegAddrHi =
   CGF.Builder.CreateConstInBoundsByteGEP(RegAddrLo,
  CharUnits::fromQuantity(16));
-llvm::Type *DoubleTy = CGF.DoubleTy;
-llvm::StructType *ST = llvm::StructType::get(DoubleTy, DoubleTy);
+llvm::Type *ST = AI.canHaveCoerceToType()
+ ? AI.getCoerceToType()
+ : llvm::StructType::get(CGF.DoubleTy, CGF.DoubleTy);
 llvm::Value *V;
 Address Tmp = CGF.CreateMemTemp(Ty);
 Tmp = CGF.Builder.CreateElementBitCast(Tmp, ST);
-V = CGF.Builder.CreateLoad(
-   CGF.Builder.CreateElementBitCast(RegAddrLo, DoubleTy));
+V = CGF.Builder.CreateLoad(CGF.Builder.CreateElementBitCast(
+RegAddrLo, ST->getStructElementType(0)));
 CGF.Builder.CreateStore(V,
CGF.Builder.CreateStructGEP(Tmp, 0, CharUnits::Zero()));
-V = CGF.Builder.CreateLoad(
-   CGF.Builder.CreateElementBitCast(RegAddrHi, DoubleTy));
+V = CGF.Builder.CreateLoad(CGF.Builder.CreateElementBitCast(
+RegAddrHi, ST->getStructElementType(1)));
 CGF.Builder.CreateStore(V,
   CGF.Builder.CreateStructGEP(Tmp, 1, CharUnits::fromQuantity(8)));
 
Index: test/CodeGen/x86_64-floatvectors.c
===
--- test/CodeGen/x86_64-floatvectors.c
+++ test/CodeGen/x86_64-floatvectors.c
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | \
+// RUN:   FileCheck %s
+
+// This test validates that the inreg branch generation for __builtin_va_arg 
+// does not exceed the alloca size of the type, which can cause the SROA pass to
+// eliminate the assignment.
+
+typedef struct { float x, y, z; } vec3f;
+
+double Vec3FTest(__builtin_va_list ap) {
+  vec3f vec = __builtin_va_arg(ap, vec3f);
+  return vec.x + vec.y + vec.z;
+}
+// CHECK: define double @Vec3FTest
+// CHECK: vaarg.in_reg:
+// CHECK: [[Vec3FLoad1:%.*]] = load <2 x float>, <2 x float>*
+// CHECK: [[Vec3FGEP1:%.*]] = getelementptr inbounds { <2 x float>, float }, { <2 x float>, float }* {{%.*}}, i32 0, i32 0
+// CHECK: store <2 x float> [[Vec3FLoad1]], <2 x float>* [[Vec3FGEP1]]
+// CHECK: [[Vec3FLoad2:%.*]] = load float, float*
+// CHECK: [[Vec3FGEP2:%.*]] = getelementptr inbounds { <2 x float>, float }, { <2 x float>, float }* {{%.*}}, i32 0, i32 1
+// CHECK: store float [[Vec3FLoad2]], float* [[Vec3FGEP2]]
+// CHECK: vaarg.in_mem:
+
+
+typedef struct { float x, y, z, q; } vec4f;
+
+double Vec4FTest(__builtin_va_list ap) {
+  vec4f vec = __builtin_va_arg(ap, vec4f);
+  return vec.x + vec.y + vec.z + vec.q;
+}
+// CHECK: define double @Vec4FTest
+// CHECK: vaarg.in_reg:
+// CHECK: [[Vec4FLoad1:%.*]] = load <2 x float>, <2 x float>*
+// CHECK: [[Vec4FGEP1:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* {{%.*}}, i32 0, i32 0
+// CHECK: store <2 x float> [[Vec4FLoad1]], <2 x float>* [[Vec4FGEP1]]
+// CHECK: [[Vec4FLoad2:%.*]] = load <2 x float>, <2 x float>*
+// CHECK: [[Vec4FGEP2:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, { <2 x float>, <2 x float> }* {{%.*}}, i32 0, i32 1
+// CHECK: store <2 x float> [[Vec4FLoad2]], <2 x float>* [[Vec4FGEP2]]
+// CHECK: vaarg.in_mem:
+
+typedef struct { double x, y; } vec2d;
+
+double Vec2DTest(__builtin_va_list ap) {
+  vec2d vec = __builtin_va_arg(ap, vec2d);
+  return vec.x + vec.y;
+}
+// CHECK: define double @Vec2DTest
+// CHECK: vaarg.in_reg:
+// CHECK: [[Vec2DLoad1:%.*]] = load double, double*
+// CHECK: [[Vec2DGEP1:%.*]] = getelementptr inbounds { double, double }, { double, double }* {{%.*}}, i32 0, i32 0
+// CHECK: store double [[Vec2DLoad1]], double* [[Vec2DGEP1]]
+// CHECK: [[Vec2DLoad2:%.*]] = load double, double*
+// CHECK: 

[PATCH] D42641: [MinGW] Emit typeinfo locally for dllimported classes without key functions

2018-02-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

This is actually consistent with what Microsoft does for dllimport classes. 
They don't have key functions, but they do import vftables when a class is 
dllimport and the constructor is inline. They never import RTTI and always emit 
it locally.

In any case, yes, this organization makes the most sense to me. Presumably GCC 
also exports its vtables so that we can import them and they don't need to be 
emitted locally, but we do need to emit RTTI locally.


https://reviews.llvm.org/D42641



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


[PATCH] D42457: [analyzer] Don't communicate evaluation failures through memregion hierarchy.

2018-02-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL324018: [analyzer] Dont communicate evaluation 
failures through memregion hierarchy. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42457?vs=132450=132473#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42457

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  cfe/trunk/test/Analysis/new.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -567,14 +567,23 @@
   const LocationContext *LCtx,
   ProgramStateRef State);
 
+  struct EvalCallOptions {
+bool IsConstructorWithImproperlyModeledTargetRegion = false;
+bool IsArrayConstructorOrDestructor = false;
+
+EvalCallOptions() {}
+  };
+
   /// Evaluate a call, running pre- and post-call checks and allowing checkers
   /// to be responsible for handling the evaluation of the call itself.
   void evalCall(ExplodedNodeSet , ExplodedNode *Pred,
 const CallEvent );
 
   /// \brief Default implementation of call evaluation.
   void defaultEvalCall(NodeBuilder , ExplodedNode *Pred,
-   const CallEvent );
+   const CallEvent ,
+   const EvalCallOptions  = {});
+
 private:
   void evalLoadCommon(ExplodedNodeSet ,
   const Expr *NodeEx,  /* Eventually will be a CFGStmt */
@@ -598,9 +607,23 @@
   void examineStackFrames(const Decl *D, const LocationContext *LCtx,
   bool , unsigned );
 
+  enum CallInlinePolicy {
+CIP_Allowed,
+CIP_DisallowedOnce,
+CIP_DisallowedAlways
+  };
+
+  /// \brief See if a particular call should be inlined, by only looking
+  /// at the call event and the current state of analysis.
+  CallInlinePolicy mayInlineCallKind(const CallEvent ,
+ const ExplodedNode *Pred,
+ AnalyzerOptions ,
+ const EvalCallOptions );
+
   /// Checks our policies and decides weither the given call should be inlined.
   bool shouldInlineCall(const CallEvent , const Decl *D,
-const ExplodedNode *Pred);
+const ExplodedNode *Pred,
+const EvalCallOptions  = {});
 
   bool inlineCall(const CallEvent , const Decl *D, NodeBuilder ,
   ExplodedNode *Pred, ProgramStateRef State);
@@ -650,11 +673,11 @@
 
   /// For a given constructor, look forward in the current CFG block to
   /// determine the region into which an object will be constructed by \p CE.
-  /// Returns either a field or local variable region if the object will be
-  /// directly constructed in an existing region or a temporary object region
-  /// if not.
+  /// When the lookahead fails, a temporary region is returned, and the
+  /// IsConstructorWithImproperlyModeledTargetRegion flag is set in \p CallOpts.
   const MemRegion *getRegionForConstructedObject(const CXXConstructExpr *CE,
- ExplodedNode *Pred);
+ ExplodedNode *Pred,
+ EvalCallOptions );
 
   /// Store the region returned by operator new() so that the constructor
   /// that follows it knew what location to initialize. The value should be
Index: cfe/trunk/test/Analysis/new.cpp
===
--- cfe/trunk/test/Analysis/new.cpp
+++ cfe/trunk/test/Analysis/new.cpp
@@ -311,8 +311,7 @@
 void testArrayDestr() {
   NoReturnDtor *p = new NoReturnDtor[2];
   delete[] p; // Calls the base destructor which aborts, checked below
-  //TODO: clang_analyzer_eval should not be called
-  clang_analyzer_eval(true); // expected-warning{{TRUE}}
+  clang_analyzer_eval(true); // no-warning
 }
 
 // Invalidate Region even in case of default destructor
Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -85,28 +85,32 @@
 
 
 /// Returns a region representing the first element of a (possibly
-/// multi-dimensional) array.
+/// multi-dimensional) array, for the purposes of element construction or
+/// destruction.
 ///
 /// On return, \p Ty will be set to the base type of the array.
 ///
 /// If the type is not an array type 

[PATCH] D42672: [CFG] [analyzer] Heavier CFGConstructor elements.

2018-02-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/Analysis/CFG.cpp:3899
+  if (auto *CE = const_cast(NE->getConstructExpr()))
+CurrentConstructionContext = {/*Constructor=*/CE, /*Trigger=*/NE};
+

dcoughlin wrote:
> Is it possible that there is already a CurrentConstructionContext? Will this 
> overwrite it?
> 
> Can you write an assertion to make sure that this doesn't happen?
> 
> Generally I would expect a context to have a well-defined start and end. I 
> think we should be explicit about where we expect it to start and end so we 
> can find violations of our expectations.
Yes, for now it'd be overwritten every time we meet a new constructor (this 
wasn't the case in the first version of this revision). However, the additional 
check (which should be eventually replaced with an assertion, but is for now 
needed) that we're picking the right context in `CXXConstructExpr` visit, 
together with only visiting every constructor once during CFG construction 
during normal visits (because weird stuff like `CXXDefaultArgExpr` isn't yet 
supported), guarantees that we're not doing anything wrong.

I should have cleaned this up, but i don't want to invest attention into that 
because subsequent patches will clearly make things way more complex than that, 
whenever we start dealing with a multitude of construction contexts or with 
partially-constructed contexts.

So for now it's a trivial kinda-safe solution.

I should document that though, for sure.



Comment at: lib/Analysis/CFG.cpp:4388
+case Stmt::WhileStmtClass: {
+  const VarDecl *var = cast(stmt)->getConditionVariable();
+  if (var)

dcoughlin wrote:
> Please, let's try to avoid changes that are unrelated to the functionality 
> being added.
I decreased indent of this whole huge for() loop, so the blame is already 
screwed (but phabricator carefully hides that), so i think this is a valid part 
of the patch.



Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:632
+
+void ExprEngine::ProcessConstructor(const CFGConstructor C,
+ExplodedNode *Pred) {

dcoughlin wrote:
> You don't seem to be using the constructor context for anything other than 
> getting the CXXConstructExpr. Will a later patch require having a 
> CFGConstructor here?
> 
> This seems like unnecessarily duplicated code. Can we just change ProcessStmt 
> to take a `Stmt *` rather than a CFGStmt and use it for all statements 
> including constructors?
> 
Hmm, well, yeah, i guess, there isn't much value in passing the `CFGElement` 
around as long as we can find the current `CFGElement` any time we want in 
`ExprEngine->currBldrCtx`.

But if not for that, it was the whole point to have the construction context 
there. Will fix.


https://reviews.llvm.org/D42672



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


[PATCH] D42672: [CFG] [analyzer] Heavier CFGConstructor elements.

2018-02-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 132476.
NoQ marked 5 inline comments as done.
NoQ added a comment.

Address comments. Most importantly, separate out sema and analyzer CFG tests.


https://reviews.llvm.org/D42672

Files:
  include/clang/Analysis/AnalysisDeclContext.h
  include/clang/Analysis/CFG.h
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/Analysis/AnalysisDeclContext.cpp
  lib/Analysis/CFG.cpp
  lib/Analysis/LiveVariables.cpp
  lib/StaticAnalyzer/Core/AnalysisManager.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/CoreEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/cfg.cpp

Index: test/Analysis/cfg.cpp
===
--- test/Analysis/cfg.cpp
+++ test/Analysis/cfg.cpp
@@ -1,5 +1,12 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 %s > %t 2>&1
-// RUN: FileCheck --input-file=%t %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=false %s > %t 2>&1
+// RUN: FileCheck --input-file=%t -check-prefixes=CHECK,WARNINGS %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -analyzer-config cfg-temporary-dtors=true -std=c++11 -analyzer-config cfg-rich-constructors=true %s > %t 2>&1
+// RUN: FileCheck --input-file=%t -check-prefixes=CHECK,ANALYZER %s
+
+// This file tests how we construct two different flavors of the Clang CFG -
+// the CFG used by the Sema analysis-based warnings and the CFG used by the
+// static analyzer. The difference in the behavior is checked via FileCheck
+// prefixes (WARNINGS and ANALYZER respectively).
 
 // CHECK-LABEL: void checkWrap(int i)
 // CHECK: ENTRY
@@ -116,7 +123,8 @@
 // CHECK-NEXT:   Succs (1): B1
 // CHECK: [B1]
 // CHECK-NEXT:   1:  CFGNewAllocator(A *)
-// CHECK-NEXT:   2:  (CXXConstructExpr, class A)
+// WARNINGS-NEXT:   2:  (CXXConstructExpr, class A)
+// ANALYZER-NEXT:   2:  (CXXConstructExpr, [B1.3], class A)
 // CHECK-NEXT:   3: new A([B1.2])
 // CHECK-NEXT:   4: A *a = new A();
 // CHECK-NEXT:   5: a
@@ -138,7 +146,8 @@
 // CHECK: [B1]
 // CHECK-NEXT:   1: 5
 // CHECK-NEXT:   2: CFGNewAllocator(A *)
-// CHECK-NEXT:   3:  (CXXConstructExpr, class A [5])
+// WARNINGS-NEXT:   3:  (CXXConstructExpr, class A [5])
+// ANALYZER-NEXT:   3:  (CXXConstructExpr, [B1.4], class A [5])
 // CHECK-NEXT:   4: new A {{\[\[}}B1.1]]
 // CHECK-NEXT:   5: A *a = new A [5];
 // CHECK-NEXT:   6: a
@@ -331,7 +340,8 @@
 // CHECK-NEXT:  3: [B1.2] (ImplicitCastExpr, ArrayToPointerDecay, int *)
 // CHECK-NEXT:  4: [B1.3] (ImplicitCastExpr, BitCast, void *)
 // CHECK-NEXT:  5: CFGNewAllocator(MyClass *)
-// CHECK-NEXT:  6:  (CXXConstructExpr, class MyClass)
+// WARNINGS-NEXT:  6:  (CXXConstructExpr, class MyClass)
+// ANALYZER-NEXT:  6:  (CXXConstructExpr, [B1.7], class MyClass)
 // CHECK-NEXT:  7: new ([B1.4]) MyClass([B1.6])
 // CHECK-NEXT:  8: MyClass *obj = new (buffer) MyClass();
 // CHECK-NEXT:  Preds (1): B2
@@ -363,7 +373,8 @@
 // CHECK-NEXT:  4: [B1.3] (ImplicitCastExpr, BitCast, void *)
 // CHECK-NEXT:  5: 5
 // CHECK-NEXT:  6: CFGNewAllocator(MyClass *)
-// CHECK-NEXT:  7:  (CXXConstructExpr, class MyClass [5])
+// WARNINGS-NEXT:  7:  (CXXConstructExpr, class MyClass [5])
+// ANALYZER-NEXT:  7:  (CXXConstructExpr, [B1.8], class MyClass [5])
 // CHECK-NEXT:  8: new ([B1.4]) MyClass {{\[\[}}B1.5]]
 // CHECK-NEXT:  9: MyClass *obj = new (buffer) MyClass [5];
 // CHECK-NEXT:  Preds (1): B2
Index: test/Analysis/analyzer-config.cpp
===
--- test/Analysis/analyzer-config.cpp
+++ test/Analysis/analyzer-config.cpp
@@ -26,6 +26,7 @@
 // CHECK-NEXT: cfg-implicit-dtors = true
 // CHECK-NEXT: cfg-lifetime = false
 // CHECK-NEXT: cfg-loopexit = false
+// CHECK-NEXT: cfg-rich-constructors = true
 // CHECK-NEXT: cfg-temporary-dtors = false
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: graph-trim-interval = 1000
@@ -42,4 +43,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 24
+// CHECK-NEXT: num-entries = 25
Index: test/Analysis/analyzer-config.c
===
--- test/Analysis/analyzer-config.c
+++ test/Analysis/analyzer-config.c
@@ -15,6 +15,7 @@
 // CHECK-NEXT: cfg-implicit-dtors = true
 // CHECK-NEXT: cfg-lifetime = false
 // CHECK-NEXT: cfg-loopexit = false
+// CHECK-NEXT: cfg-rich-constructors = true
 // CHECK-NEXT: cfg-temporary-dtors = false
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: 

[libcxx] r324033 - Disable test in C++<11 mode due to use of alignas.

2018-02-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Feb  1 15:31:22 2018
New Revision: 324033

URL: http://llvm.org/viewvc/llvm-project?rev=324033=rev
Log:
Disable test in C++<11 mode due to use of alignas.

Modified:
libcxx/trunk/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp?rev=324033=324032=324033=diff
==
--- 
libcxx/trunk/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/memory/temporary.buffer/overaligned.pass.cpp 
Thu Feb  1 15:31:22 2018
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// UNSUPPORTED: c++98, c++03
+
 // 
 
 // template 


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


[PATCH] D42343: [coroutines] Fix application of NRVO to Coroutine "Gro" or return object.

2018-02-01 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 132495.
EricWF added a comment.

I had to revert due to failing tests when using a non-assert Clang build.

This change fixes those tests to no longer depend on label names.


https://reviews.llvm.org/D42343

Files:
  lib/Sema/SemaCoroutine.cpp
  test/CodeGenCoroutines/coro-alloc.cpp
  test/CodeGenCoroutines/coro-gro-nrvo.cpp

Index: test/CodeGenCoroutines/coro-gro-nrvo.cpp
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-gro-nrvo.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
+
+#include "Inputs/coroutine.h"
+
+using namespace std::experimental;
+
+namespace std {
+
+struct nothrow_t {};
+constexpr nothrow_t nothrow = {};
+
+} // end namespace std
+
+// Required when get_return_object_on_allocation_failure() is defined by
+// the promise.
+void* operator new(__SIZE_TYPE__ __sz, const std::nothrow_t&) noexcept;
+void  operator delete(void* __p, const std::nothrow_t&) noexcept;
+
+
+template 
+struct promise_type {
+RetObject get_return_object();
+suspend_always initial_suspend();
+suspend_never final_suspend();
+void return_void();
+static void unhandled_exception();
+};
+
+struct coro {
+  using promise_type = promise_type;
+  coro(coro const&);
+  struct Impl;
+  Impl *impl;
+};
+
+// Verify that the NRVO is applied to the Gro object.
+// CHECK-LABEL: define void @_Z1fi(%struct.coro* noalias sret %agg.result, i32)
+coro f(int) {
+// CHECK: %call = call i8* @_Znwm(
+// CHECK-NEXT: br label %[[CoroInit:.*]]
+
+// CHECK: {{.*}}[[CoroInit]]:
+// CHECK: store i1 false, i1* %gro.active
+// CHECK-NEXT: call void @{{.*get_return_objectEv}}(%struct.coro* sret %agg.result
+// CHECK-NEXT: store i1 true, i1* %gro.active
+  co_return;
+}
+
+
+template 
+struct promise_type_with_on_alloc_failure {
+static RetObject get_return_object_on_allocation_failure();
+RetObject get_return_object();
+suspend_always initial_suspend();
+suspend_never final_suspend();
+void return_void();
+static void unhandled_exception();
+};
+
+struct coro_two {
+  using promise_type = promise_type_with_on_alloc_failure;
+  coro_two(coro_two const&);
+  struct Impl;
+  Impl *impl;
+};
+
+// Verify that the NRVO is applied to the Gro object.
+// CHECK-LABEL: define void @_Z1hi(%struct.coro_two* noalias sret %agg.result, i32)
+ coro_two h(int) {
+
+// CHECK: %call = call i8* @_ZnwmRKSt9nothrow_t
+// CHECK-NEXT: %[[CheckNull:.*]] = icmp ne i8* %call, null
+// CHECK-NEXT: br i1 %[[CheckNull]], label %[[InitOnSuccess:.*]], label %[[InitOnFailure:.*]]
+
+// CHECK: {{.*}}[[InitOnFailure]]:
+// CHECK-NEXT: call void @{{.*get_return_object_on_allocation_failureEv}}(%struct.coro_two* sret %agg.result
+// CHECK-NEXT: br label %[[RetLabel:.*]]
+
+// CHECK: {{.*}}[[InitOnSuccess]]:
+// CHECK: store i1 false, i1* %gro.active
+// CHECK-NEXT: call void @{{.*get_return_objectEv}}(%struct.coro_two* sret %agg.result
+// CHECK-NEXT: store i1 true, i1* %gro.active
+
+// CHECK: [[RetLabel]]:
+// CHECK-NEXT: ret void
+  co_return;
+}
Index: test/CodeGenCoroutines/coro-alloc.cpp
===
--- test/CodeGenCoroutines/coro-alloc.cpp
+++ test/CodeGenCoroutines/coro-alloc.cpp
@@ -173,6 +173,7 @@
 // CHECK-LABEL: f4(
 extern "C" int f4(promise_on_alloc_failure_tag) {
   // CHECK: %[[RetVal:.+]] = alloca i32
+  // CHECK: %[[Gro:.+]] = alloca i32
   // CHECK: %[[ID:.+]] = call token @llvm.coro.id(i32 16
   // CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
   // CHECK: %[[MEM:.+]] = call i8* @_ZnwmRKSt9nothrow_t(i64 %[[SIZE]], %"struct.std::nothrow_t"* dereferenceable(1) @_ZStL7nothrow)
@@ -186,7 +187,11 @@
 
   // CHECK: [[OKBB]]:
   // CHECK:   %[[OkRet:.+]] = call i32 @_ZNSt12experimental16coroutine_traitsIJi28promise_on_alloc_failure_tagEE12promise_type17get_return_objectEv(
-  // CHECK:   store i32 %[[OkRet]], i32* %[[RetVal]]
+  // CHECK:   store i32 %[[OkRet]], i32* %[[Gro]]
+
+  // CHECK: %[[Tmp1:.*]] = load i32, i32* %[[Gro]]
+  // CHECK-NEXT: store i32 %[[Tmp1]], i32* %[[RetVal]]
+  // CHECK-NEXT: br label %[[RetBB]]
 
   // CHECK: [[RetBB]]:
   // CHECK:   %[[LoadRet:.+]] = load i32, i32* %[[RetVal]], align 4
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -1316,10 +1316,6 @@
   if (Res.isInvalid())
 return false;
 
-  if (GroType == FnRetType) {
-GroDecl->setNRVOVariable(true);
-  }
-
   S.AddInitializerToDecl(GroDecl, Res.get(),
  /*DirectInit=*/false);
 
@@ -1343,6 +1339,8 @@
 noteMemberDeclaredHere(S, ReturnValue, Fn);
 return false;
   }
+  if (cast(ReturnStmt.get())->getNRVOCandidate() == GroDecl)
+GroDecl->setNRVOVariable(true);
 
   this->ReturnStmt = ReturnStmt.get();
   return true;

[PATCH] D42829: Emit label names according to -discard-value-names.

2018-02-01 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added reviewers: erichkeane, aaron.ballman, majnemer.

Previously, Clang only emitted label names in assert builds.
However there is a CC1 option -discard-value-names that should have been used 
to control emission instead.

  

This patch removes the NDEBUG preprocessor block and instead allows LLVM to 
handle removing the names in accordance with the option.


https://reviews.llvm.org/D42829

Files:
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/discard-name-values.cpp


Index: test/CodeGenCXX/discard-name-values.cpp
===
--- test/CodeGenCXX/discard-name-values.cpp
+++ test/CodeGenCXX/discard-name-values.cpp
@@ -1,10 +1,30 @@
-// RUN: %clang_cc1 -emit-llvm  -triple=armv7-apple-darwin -emit-llvm 
-std=c++11 %s -o - -O1 | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm  -triple=armv7-apple-darwin -emit-llvm 
-std=c++11 %s -o - -O1 -discard-value-names | FileCheck %s 
--check-prefix=DISCARDVALUE
+// RUN: %clang_cc1 -emit-llvm  -triple=armv7-apple-darwin -std=c++11 %s -o - 
-O1 \
+// RUN:| FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple=armv7-apple-darwin -std=c++11 %s -o - 
-O1 \
+// RUN:-discard-value-names | FileCheck %s --check-prefix=DISCARDVALUE
 
-int foo(int bar) {
-  return bar;
-}
 
-// CHECK: ret i32 %bar
-// DISCARDVALUE: ret i32 %0
+extern "C" void branch();
+
+bool test(bool pred) {
+// DISCARDVALUE: br i1 %0, label %2, label %3
+// CHECK: br i1 %pred, label %if.then, label %if.end
+
+  if (pred) {
+  // DISCARDVALUE: ; :2:
+  // DISCARDVALUE-NEXT: tail call void @branch()
+  // DISCARDVALUE-NEXT: br label %3
 
+  // CHECK: if.then:
+  // CHECK-NEXT: tail call void @branch()
+  // CHECK-NEXT: br label %if.end
+branch();
+  }
+
+// DISCARDVALUE: ; :3:
+// DISCARDVALUE-NEXT: ret i1 %0
+
+// CHECK: if.end:
+// CHECK-NEXT: ret i1 %pred
+  return pred;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1849,11 +1849,7 @@
   llvm::BasicBlock *createBasicBlock(const Twine  = "",
  llvm::Function *parent = nullptr,
  llvm::BasicBlock *before = nullptr) {
-#ifdef NDEBUG
-return llvm::BasicBlock::Create(getLLVMContext(), "", parent, before);
-#else
 return llvm::BasicBlock::Create(getLLVMContext(), name, parent, before);
-#endif
   }
 
   /// getBasicBlockForLabel - Return the LLVM basicblock that the specified


Index: test/CodeGenCXX/discard-name-values.cpp
===
--- test/CodeGenCXX/discard-name-values.cpp
+++ test/CodeGenCXX/discard-name-values.cpp
@@ -1,10 +1,30 @@
-// RUN: %clang_cc1 -emit-llvm  -triple=armv7-apple-darwin -emit-llvm -std=c++11 %s -o - -O1 | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm  -triple=armv7-apple-darwin -emit-llvm -std=c++11 %s -o - -O1 -discard-value-names | FileCheck %s --check-prefix=DISCARDVALUE
+// RUN: %clang_cc1 -emit-llvm  -triple=armv7-apple-darwin -std=c++11 %s -o - -O1 \
+// RUN:| FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -triple=armv7-apple-darwin -std=c++11 %s -o - -O1 \
+// RUN:-discard-value-names | FileCheck %s --check-prefix=DISCARDVALUE
 
-int foo(int bar) {
-  return bar;
-}
 
-// CHECK: ret i32 %bar
-// DISCARDVALUE: ret i32 %0
+extern "C" void branch();
+
+bool test(bool pred) {
+// DISCARDVALUE: br i1 %0, label %2, label %3
+// CHECK: br i1 %pred, label %if.then, label %if.end
+
+  if (pred) {
+  // DISCARDVALUE: ; :2:
+  // DISCARDVALUE-NEXT: tail call void @branch()
+  // DISCARDVALUE-NEXT: br label %3
 
+  // CHECK: if.then:
+  // CHECK-NEXT: tail call void @branch()
+  // CHECK-NEXT: br label %if.end
+branch();
+  }
+
+// DISCARDVALUE: ; :3:
+// DISCARDVALUE-NEXT: ret i1 %0
+
+// CHECK: if.end:
+// CHECK-NEXT: ret i1 %pred
+  return pred;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1849,11 +1849,7 @@
   llvm::BasicBlock *createBasicBlock(const Twine  = "",
  llvm::Function *parent = nullptr,
  llvm::BasicBlock *before = nullptr) {
-#ifdef NDEBUG
-return llvm::BasicBlock::Create(getLLVMContext(), "", parent, before);
-#else
 return llvm::BasicBlock::Create(getLLVMContext(), name, parent, before);
-#endif
   }
 
   /// getBasicBlockForLabel - Return the LLVM basicblock that the specified
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42768: AST: add an extension to support SwiftCC on MS ABI

2018-02-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D42768#994458, @rjmccall wrote:

> No, I mean things like `void foo(__attribute__((swiftcall)) void 
> (*fnptr)());`.


Yeah, this was the example I was going to bring up. There's no function 
parameter declaration to put the NNS on.

So, here's an idea that's probably general. It's what we do for vector types 
and (I think?) Obj-C blocks. Whenever we need to mangle a FunctionType with 
swiftcc, we look at the function type and mangle it as a `struct __swiftcc` 
where T is the FunctionType without the convention.


Repository:
  rC Clang

https://reviews.llvm.org/D42768



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


  1   2   >