[PATCH] D43992: [Frontend] Avoid including default system header paths on Fuchsia

2018-03-01 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326542: [Frontend] Avoid including default system header 
paths on Fuchsia (authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43992?vs=136662=136682#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43992

Files:
  cfe/trunk/lib/Frontend/InitHeaderSearch.cpp


Index: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
===
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
@@ -216,6 +216,7 @@
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
 case llvm::Triple::ELFIAMCU:
+case llvm::Triple::Fuchsia:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -322,6 +323,7 @@
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
   case llvm::Triple::ELFIAMCU:
+  case llvm::Triple::Fuchsia:
 break;
   case llvm::Triple::PS4: {
 //  gets prepended later in AddPath().


Index: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
===
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
@@ -216,6 +216,7 @@
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
 case llvm::Triple::ELFIAMCU:
+case llvm::Triple::Fuchsia:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -322,6 +323,7 @@
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
   case llvm::Triple::ELFIAMCU:
+  case llvm::Triple::Fuchsia:
 break;
   case llvm::Triple::PS4: {
 //  gets prepended later in AddPath().
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r326542 - [Frontend] Avoid including default system header paths on Fuchsia

2018-03-01 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Mar  1 23:19:42 2018
New Revision: 326542

URL: http://llvm.org/viewvc/llvm-project?rev=326542=rev
Log:
[Frontend] Avoid including default system header paths on Fuchsia

These paths aren't used and don't make sense on Fuchsia.

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

Modified:
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp

Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=326542=326541=326542=diff
==
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Thu Mar  1 23:19:42 2018
@@ -216,6 +216,7 @@ void InitHeaderSearch::AddDefaultCInclud
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
 case llvm::Triple::ELFIAMCU:
+case llvm::Triple::Fuchsia:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -322,6 +323,7 @@ void InitHeaderSearch::AddDefaultCInclud
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
   case llvm::Triple::ELFIAMCU:
+  case llvm::Triple::Fuchsia:
 break;
   case llvm::Triple::PS4: {
 //  gets prepended later in AddPath().


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


[PATCH] D43741: [Analyzer] More accurate modeling about the increment operator of the operand with type bool.

2018-03-01 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

i see, but just in case - what about the decrement operator ?


Repository:
  rC Clang

https://reviews.llvm.org/D43741



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


[PATCH] D43992: [Frontend] Avoid including default system header paths on Fuchsia

2018-03-01 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

https://reviews.llvm.org/D43992



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


[PATCH] D43995: Do not generate calls to fentry with __attribute__((no_instrument_function))

2018-03-01 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta created this revision.
manojgupta added reviewers: hfinkel, rengolin, srhines, chandlerc.

Currently only calls to mcount were suppressed with
no_instrument_function attribute.
Linux kernel requires that calls to fentry should also not be
generated.
This is an extended fix for PR PR33515.


Repository:
  rC Clang

https://reviews.llvm.org/D43995

Files:
  lib/CodeGen/CodeGenFunction.cpp
  test/CodeGen/fentry.c


Index: test/CodeGen/fentry.c
===
--- test/CodeGen/fentry.c
+++ test/CodeGen/fentry.c
@@ -7,5 +7,12 @@
   return 0;
 }
 
-//CHECK: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"="true"{{.*}} }
-//NOPG-NOT: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"{{.*}} }
+int __attribute__((no_instrument_function)) no_instrument(void) {
+  return foo();
+}
+
+//CHECK: attributes #0 = { {{.*}}"fentry-call"="true"{{.*}} }
+//CHECK: attributes #1 = { {{.*}} }
+//CHECK-NOT: attributes #1 = { {{.*}}"fentry-call"="true"{{.*}} }
+//NOPG-NOT: attributes #0 = { {{.*}}"fentry-call"{{.*}} }
+//NOPG-NOT: attributes #1 = { {{.*}}"fentry-call"{{.*}} }
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1016,10 +1016,12 @@
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
   if (CGM.getCodeGenOpts().InstrumentForProfiling) {
-if (CGM.getCodeGenOpts().CallFEntry)
-  Fn->addFnAttr("fentry-call", "true");
-else {
-  if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
+// Calls to fentry/mcount should not be generated if function has
+// the no_instrument_function attribute.
+if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
+  if (CGM.getCodeGenOpts().CallFEntry)
+Fn->addFnAttr("fentry-call", "true");
+  else {
 Fn->addFnAttr("instrument-function-entry-inlined",
   getTarget().getMCountName());
   }


Index: test/CodeGen/fentry.c
===
--- test/CodeGen/fentry.c
+++ test/CodeGen/fentry.c
@@ -7,5 +7,12 @@
   return 0;
 }
 
-//CHECK: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"="true"{{.*}} }
-//NOPG-NOT: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"{{.*}} }
+int __attribute__((no_instrument_function)) no_instrument(void) {
+  return foo();
+}
+
+//CHECK: attributes #0 = { {{.*}}"fentry-call"="true"{{.*}} }
+//CHECK: attributes #1 = { {{.*}} }
+//CHECK-NOT: attributes #1 = { {{.*}}"fentry-call"="true"{{.*}} }
+//NOPG-NOT: attributes #0 = { {{.*}}"fentry-call"{{.*}} }
+//NOPG-NOT: attributes #1 = { {{.*}}"fentry-call"{{.*}} }
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1016,10 +1016,12 @@
   // The attribute "counting-function" is set to mcount function name which is
   // architecture dependent.
   if (CGM.getCodeGenOpts().InstrumentForProfiling) {
-if (CGM.getCodeGenOpts().CallFEntry)
-  Fn->addFnAttr("fentry-call", "true");
-else {
-  if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
+// Calls to fentry/mcount should not be generated if function has
+// the no_instrument_function attribute.
+if (!CurFuncDecl || !CurFuncDecl->hasAttr()) {
+  if (CGM.getCodeGenOpts().CallFEntry)
+Fn->addFnAttr("fentry-call", "true");
+  else {
 Fn->addFnAttr("instrument-function-entry-inlined",
   getTarget().getMCountName());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43992: [Frontend] Avoid including default system header paths on Fuchsia

2018-03-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, jakehehrlich.
Herald added a subscriber: cfe-commits.

These paths aren't used and don't make sense on Fuchsia.


Repository:
  rC Clang

https://reviews.llvm.org/D43992

Files:
  clang/lib/Frontend/InitHeaderSearch.cpp


Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -216,6 +216,7 @@
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
 case llvm::Triple::ELFIAMCU:
+case llvm::Triple::Fuchsia:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -322,6 +323,7 @@
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
   case llvm::Triple::ELFIAMCU:
+  case llvm::Triple::Fuchsia:
 break;
   case llvm::Triple::PS4: {
 //  gets prepended later in AddPath().


Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -216,6 +216,7 @@
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
 case llvm::Triple::ELFIAMCU:
+case llvm::Triple::Fuchsia:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -322,6 +323,7 @@
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
   case llvm::Triple::ELFIAMCU:
+  case llvm::Triple::Fuchsia:
 break;
   case llvm::Triple::PS4: {
 //  gets prepended later in AddPath().
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-03-01 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 136660.
juliehockett marked an inline comment as done.
juliehockett added a comment.

Cleaning up some and updating based on changes to the parent diff.


https://reviews.llvm.org/D43341

Files:
  clang-doc/BitcodeReader.cpp
  clang-doc/BitcodeReader.h
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/Reducer.cpp
  clang-doc/Reducer.h
  clang-doc/Representation.cpp
  clang-doc/Representation.h
  clang-doc/tool/ClangDocMain.cpp
  test/clang-doc/mapper-class-in-class.cpp
  test/clang-doc/mapper-class-in-function.cpp
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-comments.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp
  test/clang-doc/namespace-bc.cpp
  test/clang-doc/record-bc.cpp

Index: test/clang-doc/record-bc.cpp
===
--- /dev/null
+++ test/clang-doc/record-bc.cpp
@@ -0,0 +1,133 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/docs.bc --dump | FileCheck %s
+
+union A { int X; int Y; };
+
+enum B { X, Y };
+
+struct C { int i; };
+
+class D {};
+
+class E {
+public:
+  E() {}
+  ~E() {}
+
+protected:
+  void ProtectedMethod();
+};
+
+void E::ProtectedMethod() {}
+
+class F : virtual private D, public E {};
+
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@E@F@E#'
+  // CHECK:  blob data = 'E'
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+// CHECK:  blob data = 'void'
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@E@F@~E#'
+  // CHECK:  blob data = '~E'
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+// CHECK:  blob data = 'void'
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@E@F@ProtectedMethod#'
+  // CHECK:  blob data = 'ProtectedMethod'
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+// CHECK:  blob data = 'void'
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@E@F@ProtectedMethod#'
+  // CHECK:  blob data = 'ProtectedMethod'
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK: 
+// CHECK:  blob data = 'void'
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@U@A'
+  // CHECK:  blob data = 'A'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'A::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'A::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@C'
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@D'
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK:  blob data = 'E'
+  // CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@F'
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@E'
+  // CHECK:  blob data = 'c:@S@D'
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@E@B'
+  // CHECK:  blob data = 'B'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'X'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'Y'
+  // CHECK: 
+// CHECK: 
Index: test/clang-doc/namespace-bc.cpp
===
--- /dev/null
+++ test/clang-doc/namespace-bc.cpp
@@ -0,0 +1,74 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/docs.bc --dump | FileCheck %s
+
+namespace A {
+
+void f();
+void f() {};
+
+} // A
+
+namespace A {
+namespace B {
+
+enum E { X };
+
+E func(int i) { 
+  return X;
+}
+
+}
+}
+
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@N@A'
+  // CHECK:  blob data = 'A'
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@N@A@N@B'
+  // CHECK:  blob data = 'B'
+  // CHECK:  blob data = 'c:@N@A'
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@N@A@F@f#'
+  // CHECK:  blob data = 'f'
+  // CHECK:  blob data = 'c:@N@A'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'void'

r326531 - Remove debugging code I accidentally committed in r326530.

2018-03-01 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Mar  1 18:03:21 2018
New Revision: 326531

URL: http://llvm.org/viewvc/llvm-project?rev=326531=rev
Log:
Remove debugging code I accidentally committed in r326530.

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

Modified: cfe/trunk/lib/Sema/SemaPseudoObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaPseudoObject.cpp?rev=326531=326530=326531=diff
==
--- cfe/trunk/lib/Sema/SemaPseudoObject.cpp (original)
+++ cfe/trunk/lib/Sema/SemaPseudoObject.cpp Thu Mar  1 18:03:21 2018
@@ -993,7 +993,6 @@ ObjCSubscriptOpBuilder::buildAssignmentO
 SourceLocation opcLoc,
 BinaryOperatorKind opcode,
 Expr *LHS, Expr *RHS) {
-  assert(false);
   assert(BinaryOperator::isAssignmentOp(opcode));
   // There must be a method to do the Index'ed assignment.
   if (!findAtIndexSetter())


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


[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-03-01 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326530: Add an option to disable tail-call optimization for 
escaping blocks. (authored by ahatanak, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43841?vs=136584=136658#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43841

Files:
  cfe/trunk/include/clang/AST/Decl.h
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/lib/Sema/SemaExprObjC.cpp
  cfe/trunk/lib/Sema/SemaPseudoObject.cpp
  cfe/trunk/test/CodeGenObjC/disable-tail-call-escaping-block.m
  cfe/trunk/test/Driver/fno-escaping-block-tail-calls.c

Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -62,6 +62,8 @@
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
+CODEGENOPT(NoEscapingBlockTailCalls, 1, 0) ///< Do not emit tail calls from
+   ///< escaping blocks.
 CODEGENOPT(EmitDeclMetadata  , 1, 0) ///< Emit special metadata indicating what
  ///< Decl* various IR entities came from.
  ///< Only useful when running CodeGen as a
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1430,6 +1430,8 @@
 def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, Group, Flags<[CC1Option, NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, Group;
+def fno_escaping_block_tail_calls : Flag<["-"], "fno-escaping-block-tail-calls">, Group, Flags<[CC1Option]>;
+def fescaping_block_tail_calls : Flag<["-"], "fescaping-block-tail-calls">, Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;
 def force__flat__namespace : Flag<["-"], "force_flat_namespace">;
 def force__load : Separate<["-"], "force_load">;
Index: cfe/trunk/include/clang/AST/Decl.h
===
--- cfe/trunk/include/clang/AST/Decl.h
+++ cfe/trunk/include/clang/AST/Decl.h
@@ -3802,6 +3802,10 @@
   bool BlockMissingReturnType : 1;
   bool IsConversionFromLambda : 1;
 
+  /// A bit that indicates this block is passed directly to a function as a
+  /// non-escaping parameter.
+  bool DoesNotEscape : 1;
+
   /// A new[]'d array of pointers to ParmVarDecls for the formal
   /// parameters of this function.  This is null if a prototype or if there are
   /// no formals.
@@ -3821,7 +3825,7 @@
   BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
   : Decl(Block, DC, CaretLoc), DeclContext(Block), IsVariadic(false),
 CapturesCXXThis(false), BlockMissingReturnType(true),
-IsConversionFromLambda(false) {}
+IsConversionFromLambda(false), DoesNotEscape(false) {}
 
 public:
   static BlockDecl *Create(ASTContext , DeclContext *DC, SourceLocation L); 
@@ -3893,6 +3897,9 @@
   bool isConversionFromLambda() const { return IsConversionFromLambda; }
   void setIsConversionFromLambda(bool val) { IsConversionFromLambda = val; }
 
+  bool doesNotEscape() const { return DoesNotEscape; }
+  void setDoesNotEscape() { DoesNotEscape = true; }
+
   bool capturesVariable(const VarDecl *var) const;
 
   void setCaptures(ASTContext , ArrayRef Captures,
Index: cfe/trunk/test/CodeGenObjC/disable-tail-call-escaping-block.m
===
--- cfe/trunk/test/CodeGenObjC/disable-tail-call-escaping-block.m
+++ cfe/trunk/test/CodeGenObjC/disable-tail-call-escaping-block.m
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -fno-escaping-block-tail-calls -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @test(
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE0:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE1:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE2:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE3:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE4:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE5:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE6:.*]] to i8*)
+
+// 

r326530 - Add an option to disable tail-call optimization for escaping blocks.

2018-03-01 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Mar  1 17:53:15 2018
New Revision: 326530

URL: http://llvm.org/viewvc/llvm-project?rev=326530=rev
Log:
Add an option to disable tail-call optimization for escaping blocks.

This makes it easier to debug crashes and hangs in block functions since
users can easily find out where the block is called from. The option
doesn't disable tail-calls from non-escaping blocks since non-escaping
blocks are not as hard to debug as escaping blocks.

rdar://problem/35758207

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

Added:
cfe/trunk/test/CodeGenObjC/disable-tail-call-escaping-block.m
cfe/trunk/test/Driver/fno-escaping-block-tail-calls.c
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaPseudoObject.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=326530=326529=326530=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Mar  1 17:53:15 2018
@@ -3802,6 +3802,10 @@ private:
   bool BlockMissingReturnType : 1;
   bool IsConversionFromLambda : 1;
 
+  /// A bit that indicates this block is passed directly to a function as a
+  /// non-escaping parameter.
+  bool DoesNotEscape : 1;
+
   /// A new[]'d array of pointers to ParmVarDecls for the formal
   /// parameters of this function.  This is null if a prototype or if there are
   /// no formals.
@@ -3821,7 +3825,7 @@ protected:
   BlockDecl(DeclContext *DC, SourceLocation CaretLoc)
   : Decl(Block, DC, CaretLoc), DeclContext(Block), IsVariadic(false),
 CapturesCXXThis(false), BlockMissingReturnType(true),
-IsConversionFromLambda(false) {}
+IsConversionFromLambda(false), DoesNotEscape(false) {}
 
 public:
   static BlockDecl *Create(ASTContext , DeclContext *DC, SourceLocation L); 
@@ -3893,6 +3897,9 @@ public:
   bool isConversionFromLambda() const { return IsConversionFromLambda; }
   void setIsConversionFromLambda(bool val) { IsConversionFromLambda = val; }
 
+  bool doesNotEscape() const { return DoesNotEscape; }
+  void setDoesNotEscape() { DoesNotEscape = true; }
+
   bool capturesVariable(const VarDecl *var) const;
 
   void setCaptures(ASTContext , ArrayRef Captures,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=326530=326529=326530=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Mar  1 17:53:15 2018
@@ -1430,6 +1430,8 @@ def fopenmp_cuda_mode : Flag<["-"], "fop
 def fno_openmp_cuda_mode : Flag<["-"], "fno-openmp-cuda-mode">, 
Group, Flags<[CC1Option, NoArgumentUnused]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
+def fno_escaping_block_tail_calls : Flag<["-"], 
"fno-escaping-block-tail-calls">, Group, Flags<[CC1Option]>;
+def fescaping_block_tail_calls : Flag<["-"], "fescaping-block-tail-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;
 def force__flat__namespace : Flag<["-"], "force_flat_namespace">;
 def force__load : Separate<["-"], "force_load">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=326530=326529=326530=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Mar  1 17:53:15 2018
@@ -62,6 +62,8 @@ CODEGENOPT(DebugPassManager, 1, 0) ///<
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
+CODEGENOPT(NoEscapingBlockTailCalls, 1, 0) ///< Do not emit tail calls from
+   ///< escaping blocks.
 CODEGENOPT(EmitDeclMetadata  , 1, 0) ///< Emit special metadata indicating what
  ///< Decl* various IR entities came from.
  ///< Only useful when running CodeGen as a

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=326530=326529=326530=diff

[PATCH] D43990: set dso_local on tls init functions

2018-03-01 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola created this revision.
espindola added a reviewer: echristo.

We copy the visibility, so copying the dso_local flag seems the natural thing 
to do.


https://reviews.llvm.org/D43990

Files:
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/runtime-dllstorage.cpp


Index: test/CodeGenCXX/runtime-dllstorage.cpp
===
--- test/CodeGenCXX/runtime-dllstorage.cpp
+++ test/CodeGenCXX/runtime-dllstorage.cpp
@@ -114,6 +114,7 @@
 // CHECK-MS-DAG: declare void @_Init_thread_header(i32*)
 // CHECK-MS-DAG: declare void @_Init_thread_footer(i32*)
 
+// CHECK-IA-DAG: @_ZTH1t = dso_local alias void (), void ()* @__tls_init
 // CHECK-IA-DAG: declare i32 @__gxx_personality_v0(...)
 // CHECK-IA-DAG: define linkonce_odr hidden void @__clang_call_terminate(i8*)
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2399,8 +2399,10 @@
   CGM.SetLLVMFunctionAttributes(nullptr, FI, cast(Init));
 }
 
-if (Init)
+if (Init) {
   Init->setVisibility(Var->getVisibility());
+  Init->setDSOLocal(Var->isDSOLocal());
+}
 
 llvm::LLVMContext  = CGM.getModule().getContext();
 llvm::BasicBlock *Entry = llvm::BasicBlock::Create(Context, "", Wrapper);


Index: test/CodeGenCXX/runtime-dllstorage.cpp
===
--- test/CodeGenCXX/runtime-dllstorage.cpp
+++ test/CodeGenCXX/runtime-dllstorage.cpp
@@ -114,6 +114,7 @@
 // CHECK-MS-DAG: declare void @_Init_thread_header(i32*)
 // CHECK-MS-DAG: declare void @_Init_thread_footer(i32*)
 
+// CHECK-IA-DAG: @_ZTH1t = dso_local alias void (), void ()* @__tls_init
 // CHECK-IA-DAG: declare i32 @__gxx_personality_v0(...)
 // CHECK-IA-DAG: define linkonce_odr hidden void @__clang_call_terminate(i8*)
 
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2399,8 +2399,10 @@
   CGM.SetLLVMFunctionAttributes(nullptr, FI, cast(Init));
 }
 
-if (Init)
+if (Init) {
   Init->setVisibility(Var->getVisibility());
+  Init->setDSOLocal(Var->isDSOLocal());
+}
 
 llvm::LLVMContext  = CGM.getModule().getContext();
 llvm::BasicBlock *Entry = llvm::BasicBlock::Create(Context, "", Wrapper);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r326529 - [analyzer] [tests] Again, make tests more resilient to changes in exploration strategy

2018-03-01 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Mar  1 17:41:19 2018
New Revision: 326529

URL: http://llvm.org/viewvc/llvm-project?rev=326529=rev
Log:
[analyzer] [tests] Again, make tests more resilient to changes in exploration 
strategy

Modified:
cfe/trunk/test/Analysis/MisusedMovedObject.cpp
cfe/trunk/test/Analysis/loop-unrolling.cpp

Modified: cfe/trunk/test/Analysis/MisusedMovedObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/MisusedMovedObject.cpp?rev=326529=326528=326529=diff
==
--- cfe/trunk/test/Analysis/MisusedMovedObject.cpp (original)
+++ cfe/trunk/test/Analysis/MisusedMovedObject.cpp Thu Mar  1 17:41:19 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -analyze 
-analyzer-checker=alpha.cplusplus.MisusedMovedObject -std=c++11 -verify 
-analyzer-output=text %s
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=alpha.cplusplus.MisusedMovedObject -std=c++11 -verify 
-analyzer-output=text -analyzer-config 
exploration_strategy=unexplored_first_queue %s
 // RUN: %clang_cc1 -analyze 
-analyzer-checker=alpha.cplusplus.MisusedMovedObject -std=c++11 
-analyzer-config exploration_strategy=dfs -verify -analyzer-output=text -DDFS=1 
%s
 
 namespace std {

Modified: cfe/trunk/test/Analysis/loop-unrolling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/loop-unrolling.cpp?rev=326529=326528=326529=diff
==
--- cfe/trunk/test/Analysis/loop-unrolling.cpp (original)
+++ cfe/trunk/test/Analysis/loop-unrolling.cpp Thu Mar  1 17:41:19 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++11 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config unroll-loops=true,cfg-loopexit=true -verify -std=c++11 
-analyzer-config exploration_strategy=unexplored_first_queue %s
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config unroll-loops=true,cfg-loopexit=true,exploration_strategy=dfs 
-verify -std=c++11 -DDFS=1 %s
 
 void clang_analyzer_numTimesReached();


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


[PATCH] D43797: [CMake] Copy the generated __config header into build directory

2018-03-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Ping? Can we land this as a temporary solution until the config generator logic 
is rewritten? This is currently breaking the libFuzzer build for us.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43797



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


r326527 - Always set dso_local in CodeGenModule::setDSOLocal.

2018-03-01 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Thu Mar  1 17:29:51 2018
New Revision: 326527

URL: http://llvm.org/viewvc/llvm-project?rev=326527=rev
Log:
Always set dso_local in CodeGenModule::setDSOLocal.

This shouldn't change any results for now, but is more consistent with
how we set dllimport/dllexport and will make future changes easier.

Since clang produces IR as it parses, it can find out mid file that
something is dllimport. When that happens we have to drop
dso_local. This is not a problem right now because
CodeGenModule::setDSOLocal is called from relatively few places at
the moment.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=326527=326526=326527=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Mar  1 17:29:51 2018
@@ -716,6 +716,12 @@ void CodeGenModule::setGlobalVisibility(
 
 static bool shouldAssumeDSOLocal(const CodeGenModule ,
  llvm::GlobalValue *GV) {
+  if (GV->hasLocalLinkage())
+return true;
+
+  if (!GV->hasDefaultVisibility() && !GV->hasExternalWeakLinkage())
+return true;
+
   // DLLImport explicitly marks the GV as external.
   if (GV->hasDLLImportStorageClass())
 return false;
@@ -773,8 +779,7 @@ static bool shouldAssumeDSOLocal(const C
 }
 
 void CodeGenModule::setDSOLocal(llvm::GlobalValue *GV) const {
-  if (shouldAssumeDSOLocal(*this, GV))
-GV->setDSOLocal(true);
+  GV->setDSOLocal(shouldAssumeDSOLocal(*this, GV));
 }
 
 void CodeGenModule::setDLLImportDLLExport(llvm::GlobalValue *GV,


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


[PATCH] D41102: Setup clang-doc frontend framework

2018-03-01 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-doc/BitcodeWriter.cpp:196
+/// \brief Emits a record name to the BLOCKINFO block.
+void ClangDocBitcodeWriter::emitRecordID(RecordId ID) {
+  assert(RecordIdNameMap[ID] && "Unknown Abbreviation");

lebedev.ri wrote:
> juliehockett wrote:
> > lebedev.ri wrote:
> > > Hmm, so i've been staring at this and 
> > > http://llvm.org/doxygen/classllvm_1_1BitstreamWriter.html and i must say 
> > > i'm not fond of this indirection.
> > > 
> > > What i don't understand is, in previous function, we don't store 
> > > `BlockId`, why do we want to store `RecordId`?
> > > Aren't they both unstable, and are implementation detail?
> > > Do we want to store it (`RecordId`)? If yes, please explain it as a new 
> > > comment in code.
> > > 
> > > If no, i guess this would work too?
> > > ```
> > > assert(RecordIdNameMap[ID] && "Unknown Abbreviation");
> > > Record.clear();
> > > Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETRECORDNAME, 
> > > RecordIdNameMap[ID].Name);
> > > ```
> > > And after that you can lower the default size of `SmallVector<> Record` 
> > > down to, hm, `4`?
> > I'm not entirely certain what you mean -- in `emitBlockId()`, we are 
> > storing both the block id and the block name in separate records 
> > (`BLOCKINFO_CODE_SETBID`, `BLOCKINFO_CODE_BLOCKNAME`, respectively). In 
> > `emitRecordId()`, we're doing something slightly different, in that we emit 
> > one record with both the record id and the record name (in record 
> > `BLOCKINFO_CODE_SETRECORDNAME`). 
> > 
> > Replacing the copy loop here has the same issue as above, namely that there 
> > isn't an easy way to convert between a `StringRef` and an array of 
> > `unsigned char`.
> Tried locally, and yes, we do need to output record id.
> 
> What we could **actually** do, is simply inline that `EmitRecord()`, first 
> emitting the RID, and then the name.
> ```
> template 
> void EmitRecord(unsigned Code, int ID, const Container ) {
>   // If we don't have an abbrev to use, emit this in its fully unabbreviated
>   // form.
>   auto Count = static_cast(makeArrayRef(Vals).size());
>   EmitCode(bitc::UNABBREV_RECORD);
>   EmitVBR(Code, 6);
>   EmitVBR(Count + 1, 6); // Including ID
>   EmitVBR64(ID, 6); // 'Prefix' with ID
>   for (unsigned i = 0, e = Count; i != e; ++i)
> EmitVBR64(Vals[i], 6);
> }
> ```
> 
> But that will result in rather ugly code.
> So given that the record names are quite short, and all the other strings we 
> output directly, maybe leave it as it is for now, until it shows in profiles?
> 
If that makes sense to you, sounds good to me!



Comment at: clang-doc/BitcodeWriter.cpp:139
+  {COMMENT_NAME, {"Name", }},
+  {COMMENT_POSITION, {"Position", }},
+  {COMMENT_DIRECTION, {"Direction", }},

lebedev.ri wrote:
> This change is not covered by tests.
> (I've actually found out that the hard way, by trying to find why it didn't 
> trigger any asssertions, oh well)
So after a some digging, this particular field can't be tested right now as the 
mapper doesn't look at any `TemplateDecl`s (something that definitely needs to 
be implemented, but in a follow-on patch). I've removed it for now, until it 
can be properly used/tested.



Comment at: clang-doc/BitcodeWriter.h:37
+  static constexpr unsigned SubblockIDSize = 4U;
+  static constexpr unsigned BoolSize = 1U;
+  static constexpr unsigned IntSize = 16U;

lebedev.ri wrote:
> juliehockett wrote:
> > lebedev.ri wrote:
> > > Hmm, you build with asserts enabled, right?
> > > I tried testing this, and three tests fail with
> > > ```
> > > clang-doc: /build/llvm/include/llvm/Bitcode/BitstreamWriter.h:122: void 
> > > llvm::BitstreamWriter::Emit(uint32_t, unsigned int): Assertion `(Val & 
> > > ~(~0U >> (32-NumBits))) == 0 && "High bits set!"' failed.
> > > ```
> > > ```
> > > Failing Tests (3):
> > > Clang Tools :: clang-doc/mapper-class-in-function.cpp
> > > Clang Tools :: clang-doc/mapper-function.cpp
> > > Clang Tools :: clang-doc/mapper-method.cpp
> > > 
> > >   Expected Passes: 6
> > >   Unexpected Failures: 3
> > > ```
> > > At least one failure is because of `BoolSize`, so i'd suspect the 
> > > assertion itself is wrong...
> > I do, and I've definitely seen that one triggered before but it's been 
> > because something was off in how the data was being outputted as I was 
> > shifting things around. That said, I'm not seeing it in my local build with 
> > this diff though -- I'll update it again just to make sure they're in sync.
> I did not retry with updated tree/patch, but i'm quite sure i did hit those 
> asserts.
> My current build line:
> ```
> -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
> -DLLVM_BINUTILS_INCDIR:PATH=/usr/include
> -DLLVM_BUILD_TESTS:BOOL=ON
> -DLLVM_ENABLE_ASSERTIONS:BOOL=ON
> -DLLVM_ENABLE_LLD:BOOL=ON
> 

[PATCH] D41102: Setup clang-doc frontend framework

2018-03-01 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 136650.
juliehockett marked 16 inline comments as done.
juliehockett added a comment.

Adding tests, fixing comments, and removing an (as-of-yet) unused element of 
the CommentInfo struct.


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/Serialize.cpp
  clang-doc/Serialize.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class-in-class.cpp
  test/clang-doc/mapper-class-in-function.cpp
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-comments.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,28 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@U@D'
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@c.bc --dump | FileCheck %s
+
+struct C { int i; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@C'
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,16 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@n...@a.bc --dump | FileCheck %s
+
+namespace A {}
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@N@A'
+  // CHECK:  blob data = 'A'
+// CHECK: 
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@S@G@F@Method#I#.bc --dump | FileCheck %s --check-prefix CHECK-G-F
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@g.bc --dump | FileCheck %s --check-prefix CHECK-G
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+
+// CHECK-G: 
+// CHECK-G: 
+  // CHECK-G: 
+// CHECK-G: 
+// CHECK-G: 
+  // CHECK-G:  blob data = 'c:@S@G'
+  // CHECK-G:  blob data = 'G'
+  // CHECK-G: 
+  // CHECK-G: 
+// CHECK-G: 
+
+
+// CHECK-G-F: 
+// CHECK-G-F: 
+  // CHECK-G-F: 
+// CHECK-G-F: 
+// CHECK-G-F: 
+  // CHECK-G-F:  blob data = 'c:@S@G@F@Method#I#'
+  // CHECK-G-F:  blob data = 'Method'
+  // CHECK-G-F:  blob data = 'c:@S@G'
+  // CHECK-G-F: 
+  // CHECK-G-F: 
+  // CHECK-G-F:  blob data = 'c:@S@G'
+  // CHECK-G-F: 
+// CHECK-G-F:  blob data = 'int'
+  // CHECK-G-F: 
+  // CHECK-G-F: 
+// CHECK-G-F:  blob data = 'int'
+// CHECK-G-F:  blob data = 'param'
+  // CHECK-G-F: 
+// CHECK-G-F: 
Index: test/clang-doc/mapper-function.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-function.cpp
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@F@F#I#.bc --dump | FileCheck %s
+
+int F(int param) { return param; }
+// CHECK: 

[PATCH] D43925: [analyzer] Prevent crashing in NonNullParamChecker

2018-03-01 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC326520: [analyzer] Prevent crashing in NonNullParamChecker 
(authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D43925

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/nonnullparamchecker-crash.cpp


Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1405,6 +1405,8 @@
 assert(!T.isNull() && "Unable to auto-detect binding type!");
 assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
 MR = GetElementZeroRegion(cast(MR), T);
+  } else {
+T = cast(MR)->getValueType();
   }
 
   // FIXME: Perhaps this method should just take a 'const MemRegion*' argument
Index: test/Analysis/nonnullparamchecker-crash.cpp
===
--- test/Analysis/nonnullparamchecker-crash.cpp
+++ test/Analysis/nonnullparamchecker-crash.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+class C {};
+
+// expected-no-diagnostics
+void f(C i) {
+  auto lambda = [&] { f(i); };
+  typedef decltype(lambda) T;
+  T* blah = new T(lambda);
+  (*blah)();
+  delete blah;
+}


Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1405,6 +1405,8 @@
 assert(!T.isNull() && "Unable to auto-detect binding type!");
 assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
 MR = GetElementZeroRegion(cast(MR), T);
+  } else {
+T = cast(MR)->getValueType();
   }
 
   // FIXME: Perhaps this method should just take a 'const MemRegion*' argument
Index: test/Analysis/nonnullparamchecker-crash.cpp
===
--- test/Analysis/nonnullparamchecker-crash.cpp
+++ test/Analysis/nonnullparamchecker-crash.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+class C {};
+
+// expected-no-diagnostics
+void f(C i) {
+  auto lambda = [&] { f(i); };
+  typedef decltype(lambda) T;
+  T* blah = new T(lambda);
+  (*blah)();
+  delete blah;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43731: [clang-format] Fix documentation for SpaceAfterCStyleCast option

2018-03-01 Thread Eric Marti via Phabricator via cfe-commits
EricMarti updated this revision to Diff 136645.
EricMarti added a comment.
Herald added a subscriber: klimek.

Updated the comment in Format.h and ran the python script. Looks like a few 
more changes got pulled into the rst file.


https://reviews.llvm.org/D43731

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h


Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1506,7 +1506,7 @@
   /// \brief If ``true``, a space is inserted after C style casts.
   /// \code
   ///true:  false:
-  ///(int)i;vs. (int) i;
+  ///(int) i;   vs. (int)i;
   /// \endcode
   bool SpaceAfterCStyleCast;
 
Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -629,7 +629,9 @@
   int bar();
   }
 
-  * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (``@autoreleasepool``, 
interfaces, ..).
+  * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (interfaces, 
implementations...).
+@autoreleasepool and @synchronized blocks are wrapped
+according to `AfterControlStatement` flag.
 
   * ``bool AfterStruct`` Wrap struct definitions.
 
@@ -1508,6 +1510,52 @@
 
 
 
+**ObjCBinPackProtocolList** (``BinPackStyle``)
+  Controls bin-packing Objective-C protocol conformance list
+  items into as few lines as possible when they go over ``ColumnLimit``.
+
+  If ``Auto`` (the default), delegates to the value in
+  ``BinPackParameters``. If that is ``true``, bin-packs Objective-C
+  protocol conformance list items into as few lines as possible
+  whenever they go over ``ColumnLimit``.
+
+  If ``Always``, always bin-packs Objective-C protocol conformance
+  list items into as few lines as possible whenever they go over
+  ``ColumnLimit``.
+
+  If ``Never``, lays out Objective-C protocol conformance list items
+  onto individual lines whenever they go over ``ColumnLimit``.
+
+
+  .. code-block:: c++
+
+ Always (or Auto, if BinPackParameters=true):
+ @interface c () <
+ c, c,
+ c, c> {
+ }
+
+ Never (or Auto, if BinPackParameters=false):
+ @interface d () <
+ d,
+ d,
+ d,
+ d> {
+ }
+
+  Possible values:
+
+  * ``BPS_Auto`` (in configuration: ``Auto``)
+Automatically determine parameter bin-packing behavior.
+
+  * ``BPS_Always`` (in configuration: ``Always``)
+Always bin-pack parameters.
+
+  * ``BPS_Never`` (in configuration: ``Never``)
+Never bin-pack parameters.
+
+
+
 **ObjCBlockIndentWidth** (``unsigned``)
   The number of characters to use for indentation of ObjC blocks.
 
@@ -1662,7 +1710,7 @@
   .. code-block:: c++
 
  true:  false:
- (int)i;vs. (int) i;
+ (int) i;   vs. (int)i;
 
 **SpaceAfterTemplateKeyword** (``bool``)
   If ``true``, a space will be inserted after the 'template' keyword.


Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1506,7 +1506,7 @@
   /// \brief If ``true``, a space is inserted after C style casts.
   /// \code
   ///true:  false:
-  ///(int)i;vs. (int) i;
+  ///(int) i;   vs. (int)i;
   /// \endcode
   bool SpaceAfterCStyleCast;
 
Index: docs/ClangFormatStyleOptions.rst
===
--- docs/ClangFormatStyleOptions.rst
+++ docs/ClangFormatStyleOptions.rst
@@ -629,7 +629,9 @@
   int bar();
   }
 
-  * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (``@autoreleasepool``, interfaces, ..).
+  * ``bool AfterObjCDeclaration`` Wrap ObjC definitions (interfaces, implementations...).
+@autoreleasepool and @synchronized blocks are wrapped
+according to `AfterControlStatement` flag.
 
   * ``bool AfterStruct`` Wrap struct definitions.
 
@@ -1508,6 +1510,52 @@
 
 
 
+**ObjCBinPackProtocolList** (``BinPackStyle``)
+  Controls bin-packing Objective-C protocol conformance list
+  items into as few lines as possible when they go over ``ColumnLimit``.
+
+  If ``Auto`` (the default), delegates to the value in
+  ``BinPackParameters``. If that is ``true``, bin-packs Objective-C
+  protocol conformance list items into as few lines as possible
+  whenever they go over ``ColumnLimit``.
+
+  If ``Always``, always bin-packs Objective-C protocol conformance
+  list items into as few lines as possible whenever they go over
+  ``ColumnLimit``.
+
+  If 

r326520 - [analyzer] Prevent crashing in NonNullParamChecker

2018-03-01 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Mar  1 16:55:59 2018
New Revision: 326520

URL: http://llvm.org/viewvc/llvm-project?rev=326520=rev
Log:
[analyzer] Prevent crashing in NonNullParamChecker

https://bugs.llvm.org/show_bug.cgi?id=36381
rdar://37543426

Turns out, the type passed for the lambda capture was incorrect.
One more argument to abandon the getSVal overload which does not require the
type information.

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

Added:
cfe/trunk/test/Analysis/nonnullparamchecker-crash.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=326520=326519=326520=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Thu Mar  1 16:55:59 2018
@@ -1405,6 +1405,8 @@ SVal RegionStoreManager::getBinding(Regi
 assert(!T.isNull() && "Unable to auto-detect binding type!");
 assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
 MR = GetElementZeroRegion(cast(MR), T);
+  } else {
+T = cast(MR)->getValueType();
   }
 
   // FIXME: Perhaps this method should just take a 'const MemRegion*' argument

Added: cfe/trunk/test/Analysis/nonnullparamchecker-crash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nonnullparamchecker-crash.cpp?rev=326520=auto
==
--- cfe/trunk/test/Analysis/nonnullparamchecker-crash.cpp (added)
+++ cfe/trunk/test/Analysis/nonnullparamchecker-crash.cpp Thu Mar  1 16:55:59 
2018
@@ -0,0 +1,11 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+class C {};
+
+// expected-no-diagnostics
+void f(C i) {
+  auto lambda = [&] { f(i); };
+  typedef decltype(lambda) T;
+  T* blah = new T(lambda);
+  (*blah)();
+  delete blah;
+}


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


r326519 - [StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2018-03-01 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Mar  1 16:54:51 2018
New Revision: 326519

URL: http://llvm.org/viewvc/llvm-project?rev=326519=rev
Log:
[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use 
warnings; other minor fixes (NFC).

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.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=326519=326518=326519=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Thu 
Mar  1 16:54:51 2018
@@ -1,4 +1,4 @@
-//===-- ExprEngine.h - Path-Sensitive Expression-Level Dataflow ---*- C++ 
-*-=//
+//===- ExprEngine.h - Path-Sensitive Expression-Level Dataflow --*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -18,36 +18,68 @@
 
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
+#include "clang/Analysis/CFG.h"
 #include "clang/Analysis/DomainSpecific/ObjCNoReturn.h"
+#include "clang/Analysis/ProgramPoint.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CoreEngine.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/WorkList.h"
+#include "llvm/ADT/ArrayRef.h"
+#include 
+#include 
 
 namespace clang {
 
 class AnalysisDeclContextManager;
+class AnalyzerOptions;
+class ASTContext;
+class ConstructionContext;
+class CXXBindTemporaryExpr;
 class CXXCatchStmt;
 class CXXConstructExpr;
 class CXXDeleteExpr;
 class CXXNewExpr;
-class CXXTemporaryObjectExpr;
 class CXXThisExpr;
+class Decl;
+class DeclStmt;
+class GCCAsmStmt;
+class LambdaExpr;
+class LocationContext;
 class MaterializeTemporaryExpr;
+class MSAsmStmt;
+class NamedDecl;
 class ObjCAtSynchronizedStmt;
 class ObjCForCollectionStmt;
+class ObjCIvarRefExpr;
+class ObjCMessageExpr;
+class ReturnStmt;
+class Stmt;
 
 namespace cross_tu {
+
 class CrossTranslationUnitContext;
-}
+
+} // namespace cross_tu
   
 namespace ento {
 
-class AnalysisManager;
+class BasicValueFactory;
 class CallEvent;
-class CXXConstructorCall;
+class CheckerManager;
+class ConstraintManager;
+class CXXTempObjectRegion;
+class MemRegion;
+class RegionAndSymbolInvalidationTraits;
+class SymbolManager;
 
 class ExprEngine : public SubEngine {
 public:
@@ -55,6 +87,7 @@ public:
   enum InliningModes {
 /// Follow the default settings for inlining callees.
 Inline_Regular = 0,
+
 /// Do minimal inlining of callees.
 Inline_Minimal = 0x1
   };
@@ -64,11 +97,14 @@ public:
 /// This call is a constructor or a destructor for which we do not 
currently
 /// compute the this-region correctly.
 bool IsCtorOrDtorWithImproperlyModeledTargetRegion = false;
+
 /// This call is a constructor or a destructor for a single element within
 /// an array, a part of array construction or destruction.
 bool IsArrayCtorOrDtor = false;
+
 /// This call is a constructor or a destructor of a temporary value.
 bool IsTemporaryCtorOrDtor = false;
+
 /// This call is a constructor for a temporary that is lifetime-extended
 /// by binding a smaller object within it to a reference, for example
 /// 'const int  = C().x;'.
@@ -87,19 +123,19 @@ private:
   CoreEngine Engine;
 
   /// G - the simulation graph.
-  ExplodedGraph& G;
+  ExplodedGraph 
 
   /// StateMgr - Object that manages the data for all created states.
   ProgramStateManager StateMgr;
 
   /// SymMgr - Object that manages the symbol information.
-  SymbolManager& SymMgr;
+  SymbolManager 
 
   /// svalBuilder - SValBuilder object that creates SVals from expressions.
   SValBuilder 
 
-  unsigned int currStmtIdx;
-  const NodeBuilderContext *currBldrCtx;
+  unsigned int currStmtIdx = 0;
+  const NodeBuilderContext *currBldrCtx = nullptr;
   
   /// Helper object to determine if an Objective-C message expression
   /// implicitly never returns.
@@ -153,7 +189,7 @@ public:
 
   SValBuilder () { return svalBuilder; }
 
-  BugReporter& getBugReporter() { return BR; }
+  BugReporter () { return BR; }
 
   cross_tu::CrossTranslationUnitContext *
   

r326518 - [analyzer] [NFC] [tests] Make test more resilient to changes in exploration strategy

2018-03-01 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Mar  1 16:54:05 2018
New Revision: 326518

URL: http://llvm.org/viewvc/llvm-project?rev=326518=rev
Log:
[analyzer] [NFC] [tests] Make test more resilient to changes in exploration 
strategy

Modified:
cfe/trunk/test/Analysis/MisusedMovedObject.cpp

Modified: cfe/trunk/test/Analysis/MisusedMovedObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/MisusedMovedObject.cpp?rev=326518=326517=326518=diff
==
--- cfe/trunk/test/Analysis/MisusedMovedObject.cpp (original)
+++ cfe/trunk/test/Analysis/MisusedMovedObject.cpp Thu Mar  1 16:54:05 2018
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -analyze 
-analyzer-checker=alpha.cplusplus.MisusedMovedObject -std=c++11 -verify 
-analyzer-output=text %s
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=alpha.cplusplus.MisusedMovedObject -std=c++11 
-analyzer-config exploration_strategy=dfs -verify -analyzer-output=text -DDFS=1 
%s
 
 namespace std {
 
@@ -474,12 +475,16 @@ void differentBranchesTest(int i) {
   // A variation on the theme above.
   {
 A a;
+#ifdef DFS
+a.foo() > 0 ? a.foo() : A(std::move(a)).foo(); // expected-note {{Assuming 
the condition is false}} expected-note {{'?' condition is false}}
+#else
 a.foo() > 0 ? a.foo() : A(std::move(a)).foo(); // expected-note {{Assuming 
the condition is true}} expected-note {{'?' condition is true}}
+#endif
   }
   // Same thing, but with a switch statement.
   {
 A a, b;
-switch (i) { // expected-note {{Control jumps to 'case 1:'  at line 483}}
+switch (i) { // expected-note {{Control jumps to 'case 1:'}}
 case 1:
   b = std::move(a); // no-warning
   break;// expected-note {{Execution jumps to the end of the 
function}}
@@ -491,7 +496,7 @@ void differentBranchesTest(int i) {
   // However, if there's a fallthrough, we do warn.
   {
 A a, b;
-switch (i) { // expected-note {{Control jumps to 'case 1:'  at line 495}}
+switch (i) { // expected-note {{Control jumps to 'case 1:'}}
 case 1:
   b = std::move(a); // expected-note {{'a' became 'moved-from' here}}
 case 2:


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


[PATCH] D43681: [WebAssembly] Add exception handling option

2018-03-01 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326517: [WebAssembly] Add exception handling option 
(authored by aheejin, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D43681

Files:
  cfe/trunk/docs/ClangCommandLineReference.rst
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
  cfe/trunk/lib/Basic/Targets/WebAssembly.h


Index: cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
===
--- cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
@@ -37,6 +37,7 @@
   .Case("simd128", SIMDLevel >= SIMD128)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
+  .Case("exception-handling", HasExceptionHandling)
   .Default(false);
 }
 
@@ -83,6 +84,14 @@
   HasSignExt = false;
   continue;
 }
+if (Feature == "+exception-handling") {
+  HasExceptionHandling = true;
+  continue;
+}
+if (Feature == "-exception-handling") {
+  HasExceptionHandling = false;
+  continue;
+}
 
 Diags.Report(diag::err_opt_not_valid_with_opt)
 << Feature << "-target-feature";
Index: cfe/trunk/lib/Basic/Targets/WebAssembly.h
===
--- cfe/trunk/lib/Basic/Targets/WebAssembly.h
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.h
@@ -32,11 +32,12 @@
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
+  bool HasExceptionHandling;
 
 public:
   explicit WebAssemblyTargetInfo(const llvm::Triple , const TargetOptions &)
   : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
-HasSignExt(false) {
+HasSignExt(false), HasExceptionHandling(false) {
 NoAsmVariants = true;
 SuitableAlign = 128;
 LargeArrayMinWidth = 128;
Index: cfe/trunk/docs/ClangCommandLineReference.rst
===
--- cfe/trunk/docs/ClangCommandLineReference.rst
+++ cfe/trunk/docs/ClangCommandLineReference.rst
@@ -2352,6 +2352,8 @@
 
 .. option:: -msimd128, -mno-simd128
 
+.. option:: -mexception-handling, -mno-exception-handling
+
 X86
 ---
 .. option:: -m3dnow, -mno-3dnow
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1917,6 +1917,8 @@
 def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, 
Group;
 def msign_ext : Flag<["-"], "msign-ext">, Group;
 def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group;
+def mexception_handing : Flag<["-"], "mexception-handling">, 
Group;
+def mno_exception_handing : Flag<["-"], "mno-exception-handling">, 
Group;
 
 def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
   Flags<[HelpHidden]>,


Index: cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
===
--- cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
@@ -37,6 +37,7 @@
   .Case("simd128", SIMDLevel >= SIMD128)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
+  .Case("exception-handling", HasExceptionHandling)
   .Default(false);
 }
 
@@ -83,6 +84,14 @@
   HasSignExt = false;
   continue;
 }
+if (Feature == "+exception-handling") {
+  HasExceptionHandling = true;
+  continue;
+}
+if (Feature == "-exception-handling") {
+  HasExceptionHandling = false;
+  continue;
+}
 
 Diags.Report(diag::err_opt_not_valid_with_opt)
 << Feature << "-target-feature";
Index: cfe/trunk/lib/Basic/Targets/WebAssembly.h
===
--- cfe/trunk/lib/Basic/Targets/WebAssembly.h
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.h
@@ -32,11 +32,12 @@
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
+  bool HasExceptionHandling;
 
 public:
   explicit WebAssemblyTargetInfo(const llvm::Triple , const TargetOptions &)
   : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
-HasSignExt(false) {
+HasSignExt(false), HasExceptionHandling(false) {
 NoAsmVariants = true;
 SuitableAlign = 128;
 LargeArrayMinWidth = 128;
Index: cfe/trunk/docs/ClangCommandLineReference.rst
===
--- cfe/trunk/docs/ClangCommandLineReference.rst
+++ cfe/trunk/docs/ClangCommandLineReference.rst
@@ -2352,6 +2352,8 @@
 
 .. option:: -msimd128, -mno-simd128
 
+.. option:: -mexception-handling, -mno-exception-handling
+
 X86
 ---
 .. option:: -m3dnow, -mno-3dnow
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- 

r326517 - [WebAssembly] Add exception handling option

2018-03-01 Thread Heejin Ahn via cfe-commits
Author: aheejin
Date: Thu Mar  1 16:39:16 2018
New Revision: 326517

URL: http://llvm.org/viewvc/llvm-project?rev=326517=rev
Log:
[WebAssembly] Add exception handling option

Summary: Add exception handling option to clang.

Reviewers: dschuff

Subscribers: jfb, sbc100, jgravelle-google, sunfish, cfe-commits

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

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
cfe/trunk/lib/Basic/Targets/WebAssembly.h

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=326517=326516=326517=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Thu Mar  1 16:39:16 2018
@@ -2352,6 +2352,8 @@ WebAssembly
 
 .. option:: -msimd128, -mno-simd128
 
+.. option:: -mexception-handling, -mno-exception-handling
+
 X86
 ---
 .. option:: -m3dnow, -mno-3dnow

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=326517=326516=326517=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Mar  1 16:39:16 2018
@@ -1917,6 +1917,8 @@ def mnontrapping_fptoint : Flag<["-"], "
 def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, 
Group;
 def msign_ext : Flag<["-"], "msign-ext">, Group;
 def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group;
+def mexception_handing : Flag<["-"], "mexception-handling">, 
Group;
+def mno_exception_handing : Flag<["-"], "mno-exception-handling">, 
Group;
 
 def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
   Flags<[HelpHidden]>,

Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.cpp?rev=326517=326516=326517=diff
==
--- cfe/trunk/lib/Basic/Targets/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.cpp Thu Mar  1 16:39:16 2018
@@ -37,6 +37,7 @@ bool WebAssemblyTargetInfo::hasFeature(S
   .Case("simd128", SIMDLevel >= SIMD128)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
+  .Case("exception-handling", HasExceptionHandling)
   .Default(false);
 }
 
@@ -83,6 +84,14 @@ bool WebAssemblyTargetInfo::handleTarget
   HasSignExt = false;
   continue;
 }
+if (Feature == "+exception-handling") {
+  HasExceptionHandling = true;
+  continue;
+}
+if (Feature == "-exception-handling") {
+  HasExceptionHandling = false;
+  continue;
+}
 
 Diags.Report(diag::err_opt_not_valid_with_opt)
 << Feature << "-target-feature";

Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.h?rev=326517=326516=326517=diff
==
--- cfe/trunk/lib/Basic/Targets/WebAssembly.h (original)
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.h Thu Mar  1 16:39:16 2018
@@ -32,11 +32,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssembl
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
+  bool HasExceptionHandling;
 
 public:
   explicit WebAssemblyTargetInfo(const llvm::Triple , const TargetOptions &)
   : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
-HasSignExt(false) {
+HasSignExt(false), HasExceptionHandling(false) {
 NoAsmVariants = true;
 SuitableAlign = 128;
 LargeArrayMinWidth = 128;


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


[PATCH] D43980: Push a function scope when parsing function bodies without a declaration

2018-03-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added a reviewer: rsmith.

This is PR36536.

There are a few ways to reach Sema::ActOnStartOfFunctionDef with a null
Decl. Currently, the parser continues on to attempt to parse the
statements in the function body without pushing a function scope or
declaration context. However, lots of statement parsing logic relies on
getCurFunction() returning something reasonable. It turns out that
getCurFunction() will never return null today because of an optimization
where Sema pre-allocates one FunctionScopeIfno and reuses it when
possible. This goes wrong when something inside the function body causes
us to push another function scope, such as requiring an implicit
definition of a special member function. Reusing the state clears it
out, which will lead to bugs. In PR36536, we found that the SwitchStack
gets unbalanced, because we push a switch, clear out the stack, and then
try to pop a switch that isn't there.

As a follow-up, I plan to move the pre-allocated FunctionScopeInfo out
of the FunctionScopes stack. This means the FunctionScopes stack will
often be empty, which will make getCurFunction() assert. That's a
high-risk change, so I want to separate it out.


https://reviews.llvm.org/D43980

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/pr36536.cpp


Index: clang/test/SemaCXX/pr36536.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr36536.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking
+
+// These test cases are constructed to make clang call ActOnStartOfFunctionDef
+// with nullptr.
+
+struct ImplicitDefaultCtor1 {};
+struct Foo {
+  typedef int NameInClass;
+  void f();
+};
+namespace bar {
+// expected-error@+1 {{cannot define or redeclare 'f' here}}
+void Foo::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+
+  // FIXME: If we improved our recovery to redeclare Foo::f in the wrong
+  // namespace, we could find the right type name here. Users probably run into
+  // this when they forget to close a namespace, and we'd generate far fewer
+  // errors if names in Foo were in scope.
+  // expected-error@+1 {{unknown type name 'NameInClass'}}
+  NameInClass var;
+}
+} // namespace bar
+
+struct ImplicitDefaultCtor2 {};
+template  class TFoo { void f(); };
+// expected-error@+1 {{nested name specifier 'decltype(TFoo())::'}}
+template  void decltype(TFoo())::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+}
+
+namespace tpl2 {
+struct ImplicitDefaultCtor3 {};
+template  class A {
+  template  class B {
+void mf2();
+  };
+};
+template 
+template <>
+// expected-error@+1 {{nested name specifier 'A::B::'}}
+void A::B::mf2() {
+  switch (0) { case 0: ImplicitDefaultCtor3 o; }
+}
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12406,8 +12406,13 @@
 
 Decl *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Decl *D,
 SkipBodyInfo *SkipBody) {
-  if (!D)
+  if (!D) {
+// Parsing the function declaration failed in some way. Push on a fake 
scope
+// anyway so we can try to parse the function body.
+PushFunctionScope();
 return D;
+  }
+
   FunctionDecl *FD = nullptr;
 
   if (FunctionTemplateDecl *FunTmpl = dyn_cast(D))
@@ -12816,6 +12821,9 @@
   getCurFunction()->ObjCWarnForNoInitDelegation = false;
 }
   } else {
+// Parsing the function declaration failed in some way. Pop the fake scope
+// we pushed on.
+PopFunctionScopeInfo(ActivePolicy, dcl);
 return nullptr;
   }
 


Index: clang/test/SemaCXX/pr36536.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr36536.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++11 %s -verify -fno-spell-checking
+
+// These test cases are constructed to make clang call ActOnStartOfFunctionDef
+// with nullptr.
+
+struct ImplicitDefaultCtor1 {};
+struct Foo {
+  typedef int NameInClass;
+  void f();
+};
+namespace bar {
+// expected-error@+1 {{cannot define or redeclare 'f' here}}
+void Foo::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+
+  // FIXME: If we improved our recovery to redeclare Foo::f in the wrong
+  // namespace, we could find the right type name here. Users probably run into
+  // this when they forget to close a namespace, and we'd generate far fewer
+  // errors if names in Foo were in scope.
+  // expected-error@+1 {{unknown type name 'NameInClass'}}
+  NameInClass var;
+}
+} // namespace bar
+
+struct ImplicitDefaultCtor2 {};
+template  class TFoo { void f(); };
+// expected-error@+1 {{nested name specifier 'decltype(TFoo())::'}}
+template  void decltype(TFoo())::f() {
+  switch (0) { case 0: ImplicitDefaultCtor1 o; }
+}
+
+namespace tpl2 {
+struct ImplicitDefaultCtor3 {};
+template  class A {
+  template  class B {
+void mf2();
+  };

r326512 - [NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying r326501.)

2018-03-01 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Mar  1 16:07:45 2018
New Revision: 326512

URL: http://llvm.org/viewvc/llvm-project?rev=326512=rev
Log:
[NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying 
r326501.)

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc
   comments or not.
2. "Maybe-doc" comments, like <, !, etc, are saved as such, instead of marking
   them as ordinary comments. The maybe-doc type of comment is never saved
   otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are 
ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Subscribers: cfe-commits

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RawCommentList.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/RawCommentList.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=326512=326511=326512=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Mar  1 16:07:45 2018
@@ -784,7 +784,7 @@ public:
   void addComment(const RawComment ) {
 assert(LangOpts.RetainCommentsFromSystemHeaders ||
!SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
-Comments.addComment(RC, BumpAlloc);
+Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
   }
 
   /// \brief Return the documentation comment attached to a given declaration.

Modified: cfe/trunk/include/clang/AST/RawCommentList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RawCommentList.h?rev=326512=326511=326512=diff
==
--- cfe/trunk/include/clang/AST/RawCommentList.h (original)
+++ cfe/trunk/include/clang/AST/RawCommentList.h Thu Mar  1 16:07:45 2018
@@ -41,7 +41,7 @@ public:
   RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }
 
   RawComment(const SourceManager , SourceRange SR,
- bool Merged, bool ParseAllComments);
+ const CommentOptions , bool Merged);
 
   CommentKind getKind() const LLVM_READONLY {
 return (CommentKind) Kind;
@@ -70,7 +70,6 @@ public:
   /// \code /**< stuff */ \endcode
   /// \code /*!< stuff */ \endcode
   bool isTrailingComment() const LLVM_READONLY {
-assert(isDocumentation());
 return IsTrailingComment;
   }
 
@@ -83,8 +82,7 @@ public:
 
   /// Returns true if this comment is not a documentation comment.
   bool isOrdinary() const LLVM_READONLY {
-return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) &&
-!ParseAllComments;
+return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC));
   }
 
   /// Returns true if this comment any kind of a documentation comment.
@@ -92,11 +90,6 @@ public:
 return !isInvalid() && !isOrdinary();
   }
 
-  /// Returns whether we are parsing all comments.
-  bool isParseAllComments() const LLVM_READONLY {
-return ParseAllComments;
-  }
-
   /// Returns raw comment text with comment markers.
   StringRef getRawText(const SourceManager ) const {
 if (RawTextValid)
@@ -139,18 +132,12 @@ private:
   bool IsTrailingComment : 1;
   bool IsAlmostTrailingComment : 1;
 
-  /// When true, ordinary comments starting with "//" and "/*" will be
-  /// considered as documentation comments.
-  bool ParseAllComments : 1;
-
   /// \brief Constructor for AST deserialization.
   RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
- bool IsAlmostTrailingComment,
- bool ParseAllComments) :
+ bool IsAlmostTrailingComment) :
 Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
 IsAttached(false), IsTrailingComment(IsTrailingComment),
-IsAlmostTrailingComment(IsAlmostTrailingComment),
-ParseAllComments(ParseAllComments)
+IsAlmostTrailingComment(IsAlmostTrailingComment)
   { }
 
   StringRef getRawTextSlow(const SourceManager ) const;
@@ -183,7 +170,8 @@ class RawCommentList {
 public:
   RawCommentList(SourceManager ) : SourceMgr(SourceMgr) {}
 
-  void addComment(const RawComment , llvm::BumpPtrAllocator );
+  void addComment(const RawComment , const CommentOptions ,
+  llvm::BumpPtrAllocator );
 
   ArrayRef getComments() const {
 return Comments;

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 

[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-01 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added inline comments.



Comment at: include/clang/AST/Attr.h:206
+
+  void cmpable(const ParamIdx ) const {
+assert(isValid() && I.isValid() &&

aaron.ballman wrote:
> jdenny wrote:
> > aaron.ballman wrote:
> > > The name here can be improved. How about `checkInvariants()`? Might as 
> > > well make this inline while you're at it.
> > Sure, I can change the name.
> > 
> > It's inside the class, so specifying inline is against the LLVM coding 
> > standards, right?
> Derp, you're correct, it's already implicitly inline. Ignore that part of the 
> suggestion.
> The name here can be improved. How about checkInvariants()?

I went with assertComparable because, in my view, this is not so much a class 
invariant as it is an assertion about correct usage of comparison operators.  
But I'm not married to it.




https://reviews.llvm.org/D43248



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


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-01 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 136624.
jdenny marked 23 inline comments as done.
jdenny edited the summary of this revision.
jdenny added a comment.

This update should address all outstanding comments.


https://reviews.llvm.org/D43248

Files:
  include/clang/AST/Attr.h
  include/clang/Basic/Attr.td
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  test/CodeGenCXX/alloc-size.cpp
  test/Misc/ast-dump-attr.cpp
  test/Sema/attr-ownership.cpp
  test/Sema/attr-print.cpp
  test/Sema/error-type-safety.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -302,9 +302,6 @@
 std::string getIsOmitted() const override {
   if (type == "IdentifierInfo *")
 return "!get" + getUpperName().str() + "()";
-  // FIXME: Do this declaratively in Attr.td.
-  if (getAttrName() == "AllocSize")
-return "0 == get" + getUpperName().str() + "()";
   return "false";
 }
 
@@ -748,6 +745,138 @@
 }
   };
 
+  class VariadicParamIdxArgument : public VariadicArgument {
+  public:
+VariadicParamIdxArgument(const Record , StringRef Attr)
+: VariadicArgument(Arg, Attr, "ParamIdx") {}
+
+  public:
+void writeCtorBody(raw_ostream ) const override {
+  VariadicArgument::writeCtorBody(OS);
+  OS << "#ifndef NDEBUG\n"
+ << "if (" << getLowerName() << "_size()) {\n"
+ << "  bool HasThis = " << getLowerName()
+ << "_begin()->hasThis();\n"
+ << "  for (const auto Idx : " << getLowerName() << "()) {\n"
+ << "assert(Idx.isValid() && \"ParamIdx must be valid\");\n"
+ << "assert(HasThis == Idx.hasThis() && "
+"\"HasThis must be consistent\");\n"
+ << "  }\n"
+ << "}\n"
+ << "#endif\n";
+}
+
+void writePCHReadDecls(raw_ostream ) const override {
+  OS << "unsigned " << getUpperName() << "Size = Record.readInt();\n";
+  OS << "bool " << getUpperName() << "HasThis = " << getUpperName()
+ << "Size ? Record.readInt() : false;\n";
+  OS << "SmallVector " << getUpperName() << ";\n"
+ << "" << getUpperName() << ".reserve(" << getUpperName()
+ << "Size);\n"
+ << "for (unsigned i = 0; i != " << getUpperName()
+ << "Size; ++i) {\n"
+ << "  " << getUpperName()
+ << ".push_back(ParamIdx(Record.readInt(), " << getUpperName()
+ << "HasThis));\n"
+ << "}\n";
+}
+
+void writePCHReadArgs(raw_ostream ) const override {
+  OS << getUpperName() << ".data(), " << getUpperName() << "Size";
+}
+
+void writePCHWrite(raw_ostream ) const override {
+  OS << "Record.push_back(SA->" << getLowerName() << "_size());\n";
+  OS << "if (SA->" << getLowerName() << "_size())\n"
+ << "  Record.push_back(SA->" << getLowerName()
+ << "_begin()->hasThis());\n";
+  OS << "for (auto Idx : SA->" << getLowerName() << "())\n"
+ << "  Record.push_back(Idx.getSourceIndex());\n";
+}
+
+void writeValueImpl(raw_ostream ) const override {
+  OS << "OS << Val.getSourceIndex();\n";
+}
+
+void writeDump(raw_ostream ) const override {
+  OS << "for (auto Idx : SA->" << getLowerName() << "())\n";
+  OS << "  OS << \" \" << Idx.getSourceIndex();\n";
+}
+  };
+
+  class ParamIdxArgument : public Argument {
+std::string IdxName;
+
+  public:
+ParamIdxArgument(const Record , StringRef Attr)
+: Argument(Arg, Attr), IdxName(getUpperName()) {}
+
+void writeDeclarations(raw_ostream ) const override {
+  OS << "ParamIdx " << IdxName << ";\n";
+}
+
+void writeAccessors(raw_ostream ) const override {
+  OS << "\n"
+ << "  ParamIdx " << getLowerName() << "() const {"
+ << " return " << IdxName << "; }\n";
+}
+
+void writeCtorParameters(raw_ostream ) const override {
+  OS << "ParamIdx " << IdxName;
+}
+
+void writeCloneArgs(raw_ostream ) const override { OS << IdxName; }
+
+void writeTemplateInstantiationArgs(raw_ostream ) const override {
+  OS << "A->" << getLowerName() << "()";
+}
+
+void writeImplicitCtorArgs(raw_ostream ) const override {
+  OS << IdxName;
+}
+
+void writeCtorInitializers(raw_ostream ) const override {
+  OS << IdxName << "(" << IdxName << ")";
+}
+
+void writeCtorDefaultInitializers(raw_ostream ) const override {
+  OS << IdxName << "()";
+}
+
+void writePCHReadDecls(raw_ostream ) const override {
+  OS << "unsigned 

Re: r326141 - Re-land "Emit proper CodeView when -gcodeview is passed without the cl driver."

2018-03-01 Thread Reid Kleckner via cfe-commits
I want to do that, but it will surely break the LLDB test suite, which
assumes `clang -g` makes dwarf. It's just a matter of fixing up the flags
their test makefiles use.


On Thu, Mar 1, 2018 at 3:22 PM Nico Weber  wrote:

> Should we key the default off the triple? (I thought that what was the
> patch did, but I misread.) I.e. with an MSVC triple, default to emitting
> codeview?
>
> On Mon, Feb 26, 2018 at 5:55 PM, Reid Kleckner via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rnk
>> Date: Mon Feb 26 14:55:33 2018
>> New Revision: 326141
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=326141=rev
>> Log:
>> Re-land "Emit proper CodeView when -gcodeview is passed without the cl
>> driver."
>>
>> Reverts r326116 and re-lands r326113 with a fix to ASan so that it
>> enables column info in its test suite.
>>
>> Added:
>> cfe/trunk/test/Driver/codeview-column-info.c
>> Modified:
>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=326141=326140=326141=diff
>>
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Feb 26 14:55:33 2018
>> @@ -2968,7 +2968,7 @@ static void RenderDebugOptions(const Too
>>
>>// Forward -gcodeview. EmitCodeView might have been set by
>> CL-compatibility
>>// argument parsing.
>> -  if (Args.hasArg(options::OPT_gcodeview) || EmitCodeView) {
>> +  if (EmitCodeView) {
>>  // DWARFVersion remains at 0 if no explicit choice was made.
>>  CmdArgs.push_back("-gcodeview");
>>} else if (DWARFVersion == 0 &&
>> @@ -3567,6 +3567,8 @@ void Clang::ConstructJob(Compilation ,
>>types::ID InputType = Input.getType();
>>if (D.IsCLMode())
>>  AddClangCLArgs(Args, InputType, CmdArgs, ,
>> );
>> +  else
>> +EmitCodeView = Args.hasArg(options::OPT_gcodeview);
>>
>>const Arg *SplitDWARFArg = nullptr;
>>RenderDebugOptions(getToolChain(), D, RawTriple, Args, EmitCodeView,
>>
>> Added: cfe/trunk/test/Driver/codeview-column-info.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/codeview-column-info.c?rev=326141=auto
>>
>> ==
>> --- cfe/trunk/test/Driver/codeview-column-info.c (added)
>> +++ cfe/trunk/test/Driver/codeview-column-info.c Mon Feb 26 14:55:33 2018
>> @@ -0,0 +1,13 @@
>> +// Check that -dwarf-column-info does not get added to the cc1 line:
>> +// 1) When -gcodeview is present via the clang or clang++ driver
>> +// 2) When /Z7 is present via the cl driver.
>> +
>> +// RUN: %clang -### -c -g -gcodeview %s 2> %t1
>> +// RUN: FileCheck < %t1 %s
>> +// RUN: %clangxx -### -c -g -gcodeview %s 2> %t2
>> +// RUN: FileCheck < %t2 %s
>> +// RUN: %clang_cl -### /c /Z7 %s 2> %t2
>> +// RUN: FileCheck < %t2 %s
>> +
>> +// CHECK: "-cc1"
>> +// CHECK-NOT: "-dwarf-column-info"
>>
>>
>> ___
>> 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


Re: r326141 - Re-land "Emit proper CodeView when -gcodeview is passed without the cl driver."

2018-03-01 Thread Nico Weber via cfe-commits
Should we key the default off the triple? (I thought that what was the
patch did, but I misread.) I.e. with an MSVC triple, default to emitting
codeview?

On Mon, Feb 26, 2018 at 5:55 PM, Reid Kleckner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rnk
> Date: Mon Feb 26 14:55:33 2018
> New Revision: 326141
>
> URL: http://llvm.org/viewvc/llvm-project?rev=326141=rev
> Log:
> Re-land "Emit proper CodeView when -gcodeview is passed without the cl
> driver."
>
> Reverts r326116 and re-lands r326113 with a fix to ASan so that it
> enables column info in its test suite.
>
> Added:
> cfe/trunk/test/Driver/codeview-column-info.c
> Modified:
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains/Clang.cpp?rev=326141=326140=326141=diff
> 
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Feb 26 14:55:33 2018
> @@ -2968,7 +2968,7 @@ static void RenderDebugOptions(const Too
>
>// Forward -gcodeview. EmitCodeView might have been set by
> CL-compatibility
>// argument parsing.
> -  if (Args.hasArg(options::OPT_gcodeview) || EmitCodeView) {
> +  if (EmitCodeView) {
>  // DWARFVersion remains at 0 if no explicit choice was made.
>  CmdArgs.push_back("-gcodeview");
>} else if (DWARFVersion == 0 &&
> @@ -3567,6 +3567,8 @@ void Clang::ConstructJob(Compilation ,
>types::ID InputType = Input.getType();
>if (D.IsCLMode())
>  AddClangCLArgs(Args, InputType, CmdArgs, ,
> );
> +  else
> +EmitCodeView = Args.hasArg(options::OPT_gcodeview);
>
>const Arg *SplitDWARFArg = nullptr;
>RenderDebugOptions(getToolChain(), D, RawTriple, Args, EmitCodeView,
>
> Added: cfe/trunk/test/Driver/codeview-column-info.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/
> codeview-column-info.c?rev=326141=auto
> 
> ==
> --- cfe/trunk/test/Driver/codeview-column-info.c (added)
> +++ cfe/trunk/test/Driver/codeview-column-info.c Mon Feb 26 14:55:33 2018
> @@ -0,0 +1,13 @@
> +// Check that -dwarf-column-info does not get added to the cc1 line:
> +// 1) When -gcodeview is present via the clang or clang++ driver
> +// 2) When /Z7 is present via the cl driver.
> +
> +// RUN: %clang -### -c -g -gcodeview %s 2> %t1
> +// RUN: FileCheck < %t1 %s
> +// RUN: %clangxx -### -c -g -gcodeview %s 2> %t2
> +// RUN: FileCheck < %t2 %s
> +// RUN: %clang_cl -### /c /Z7 %s 2> %t2
> +// RUN: FileCheck < %t2 %s
> +
> +// CHECK: "-cc1"
> +// CHECK-NOT: "-dwarf-column-info"
>
>
> ___
> 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


r326508 - Revert r326501 due to buildbot breakage.

2018-03-01 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Mar  1 15:14:00 2018
New Revision: 326508

URL: http://llvm.org/viewvc/llvm-project?rev=326508=rev
Log:
Revert r326501 due to buildbot breakage.

Original change:

[NFC] Move CommentOpts checks to the call sites that depend on it.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc 
comments or not.
2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of 
marking them as ordinary comments. The maybe-doc type of comment is never saved 
otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are 
ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.



Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RawCommentList.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/RawCommentList.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=326508=326507=326508=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Mar  1 15:14:00 2018
@@ -784,7 +784,7 @@ public:
   void addComment(const RawComment ) {
 assert(LangOpts.RetainCommentsFromSystemHeaders ||
!SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
-Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
+Comments.addComment(RC, BumpAlloc);
   }
 
   /// \brief Return the documentation comment attached to a given declaration.

Modified: cfe/trunk/include/clang/AST/RawCommentList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RawCommentList.h?rev=326508=326507=326508=diff
==
--- cfe/trunk/include/clang/AST/RawCommentList.h (original)
+++ cfe/trunk/include/clang/AST/RawCommentList.h Thu Mar  1 15:14:00 2018
@@ -41,7 +41,7 @@ public:
   RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }
 
   RawComment(const SourceManager , SourceRange SR,
- const CommentOptions , bool Merged);
+ bool Merged, bool ParseAllComments);
 
   CommentKind getKind() const LLVM_READONLY {
 return (CommentKind) Kind;
@@ -83,7 +83,8 @@ public:
 
   /// Returns true if this comment is not a documentation comment.
   bool isOrdinary() const LLVM_READONLY {
-return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC));
+return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) &&
+!ParseAllComments;
   }
 
   /// Returns true if this comment any kind of a documentation comment.
@@ -91,6 +92,11 @@ public:
 return !isInvalid() && !isOrdinary();
   }
 
+  /// Returns whether we are parsing all comments.
+  bool isParseAllComments() const LLVM_READONLY {
+return ParseAllComments;
+  }
+
   /// Returns raw comment text with comment markers.
   StringRef getRawText(const SourceManager ) const {
 if (RawTextValid)
@@ -133,12 +139,18 @@ private:
   bool IsTrailingComment : 1;
   bool IsAlmostTrailingComment : 1;
 
+  /// When true, ordinary comments starting with "//" and "/*" will be
+  /// considered as documentation comments.
+  bool ParseAllComments : 1;
+
   /// \brief Constructor for AST deserialization.
   RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
- bool IsAlmostTrailingComment) :
+ bool IsAlmostTrailingComment,
+ bool ParseAllComments) :
 Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
 IsAttached(false), IsTrailingComment(IsTrailingComment),
-IsAlmostTrailingComment(IsAlmostTrailingComment)
+IsAlmostTrailingComment(IsAlmostTrailingComment),
+ParseAllComments(ParseAllComments)
   { }
 
   StringRef getRawTextSlow(const SourceManager ) const;
@@ -171,8 +183,7 @@ class RawCommentList {
 public:
   RawCommentList(SourceManager ) : SourceMgr(SourceMgr) {}
 
-  void addComment(const RawComment , const CommentOptions ,
-  llvm::BumpPtrAllocator );
+  void addComment(const RawComment , llvm::BumpPtrAllocator );
 
   ArrayRef getComments() const {
 return Comments;

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=326508=326507=326508=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)

[PATCH] D43663: [NFC] Move CommentOpts checks to the call sites that depend on it.

2018-03-01 Thread David L. Jones via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326501: [NFC] Move CommentOpts checks to the call sites that 
depend on it. (authored by dlj, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43663?vs=135573=136610#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43663

Files:
  cfe/trunk/include/clang/AST/ASTContext.h
  cfe/trunk/include/clang/AST/RawCommentList.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/RawCommentList.cpp
  cfe/trunk/lib/Sema/Sema.cpp
  cfe/trunk/lib/Serialization/ASTReader.cpp

Index: cfe/trunk/include/clang/AST/ASTContext.h
===
--- cfe/trunk/include/clang/AST/ASTContext.h
+++ cfe/trunk/include/clang/AST/ASTContext.h
@@ -784,7 +784,7 @@
   void addComment(const RawComment ) {
 assert(LangOpts.RetainCommentsFromSystemHeaders ||
!SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
-Comments.addComment(RC, BumpAlloc);
+Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
   }
 
   /// \brief Return the documentation comment attached to a given declaration.
Index: cfe/trunk/include/clang/AST/RawCommentList.h
===
--- cfe/trunk/include/clang/AST/RawCommentList.h
+++ cfe/trunk/include/clang/AST/RawCommentList.h
@@ -41,7 +41,7 @@
   RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }
 
   RawComment(const SourceManager , SourceRange SR,
- bool Merged, bool ParseAllComments);
+ const CommentOptions , bool Merged);
 
   CommentKind getKind() const LLVM_READONLY {
 return (CommentKind) Kind;
@@ -83,20 +83,14 @@
 
   /// Returns true if this comment is not a documentation comment.
   bool isOrdinary() const LLVM_READONLY {
-return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) &&
-!ParseAllComments;
+return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC));
   }
 
   /// Returns true if this comment any kind of a documentation comment.
   bool isDocumentation() const LLVM_READONLY {
 return !isInvalid() && !isOrdinary();
   }
 
-  /// Returns whether we are parsing all comments.
-  bool isParseAllComments() const LLVM_READONLY {
-return ParseAllComments;
-  }
-
   /// Returns raw comment text with comment markers.
   StringRef getRawText(const SourceManager ) const {
 if (RawTextValid)
@@ -139,18 +133,12 @@
   bool IsTrailingComment : 1;
   bool IsAlmostTrailingComment : 1;
 
-  /// When true, ordinary comments starting with "//" and "/*" will be
-  /// considered as documentation comments.
-  bool ParseAllComments : 1;
-
   /// \brief Constructor for AST deserialization.
   RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
- bool IsAlmostTrailingComment,
- bool ParseAllComments) :
+ bool IsAlmostTrailingComment) :
 Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
 IsAttached(false), IsTrailingComment(IsTrailingComment),
-IsAlmostTrailingComment(IsAlmostTrailingComment),
-ParseAllComments(ParseAllComments)
+IsAlmostTrailingComment(IsAlmostTrailingComment)
   { }
 
   StringRef getRawTextSlow(const SourceManager ) const;
@@ -183,7 +171,8 @@
 public:
   RawCommentList(SourceManager ) : SourceMgr(SourceMgr) {}
 
-  void addComment(const RawComment , llvm::BumpPtrAllocator );
+  void addComment(const RawComment , const CommentOptions ,
+  llvm::BumpPtrAllocator );
 
   ArrayRef getComments() const {
 return Comments;
Index: cfe/trunk/lib/AST/RawCommentList.cpp
===
--- cfe/trunk/lib/AST/RawCommentList.cpp
+++ cfe/trunk/lib/AST/RawCommentList.cpp
@@ -107,21 +107,22 @@
 }
 
 RawComment::RawComment(const SourceManager , SourceRange SR,
-   bool Merged, bool ParseAllComments) :
+   const CommentOptions , bool Merged) :
 Range(SR), RawTextValid(false), BriefTextValid(false),
-IsAttached(false), IsTrailingComment(false), IsAlmostTrailingComment(false),
-ParseAllComments(ParseAllComments) {
+IsAttached(false), IsTrailingComment(false),
+IsAlmostTrailingComment(false) {
   // Extract raw comment text, if possible.
   if (SR.getBegin() == SR.getEnd() || getRawText(SourceMgr).empty()) {
 Kind = RCK_Invalid;
 return;
   }
 
   // Guess comment kind.
-  std::pair K = getCommentKind(RawText, ParseAllComments);
+  std::pair K =
+  getCommentKind(RawText, CommentOpts.ParseAllComments);
 
   // Guess whether an ordinary comment is trailing.
-  if (ParseAllComments && isOrdinaryKind(K.first)) {
+  if (CommentOpts.ParseAllComments && isOrdinaryKind(K.first)) {
 FileID BeginFileID;
 unsigned BeginOffset;
 std::tie(BeginFileID, BeginOffset) =
@@ -270,6 +271,7 @@
 

r326501 - [NFC] Move CommentOpts checks to the call sites that depend on it.

2018-03-01 Thread David L. Jones via cfe-commits
Author: dlj
Date: Thu Mar  1 14:41:53 2018
New Revision: 326501

URL: http://llvm.org/viewvc/llvm-project?rev=326501=rev
Log:
[NFC] Move CommentOpts checks to the call sites that depend on it.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

 1. All comments are saved during parsing, regardless of whether they are doc
comments or not.
 2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of
marking them as ordinary comments. The maybe-doc type of comment is never
saved otherwise. (Warning on these is the impetus of -Wdocumentation.)
 3. All comments are treated as doc comments in ASTContext, even if they are
ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Reviewers: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RawCommentList.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/RawCommentList.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=326501=326500=326501=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Mar  1 14:41:53 2018
@@ -784,7 +784,7 @@ public:
   void addComment(const RawComment ) {
 assert(LangOpts.RetainCommentsFromSystemHeaders ||
!SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
-Comments.addComment(RC, BumpAlloc);
+Comments.addComment(RC, LangOpts.CommentOpts, BumpAlloc);
   }
 
   /// \brief Return the documentation comment attached to a given declaration.

Modified: cfe/trunk/include/clang/AST/RawCommentList.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RawCommentList.h?rev=326501=326500=326501=diff
==
--- cfe/trunk/include/clang/AST/RawCommentList.h (original)
+++ cfe/trunk/include/clang/AST/RawCommentList.h Thu Mar  1 14:41:53 2018
@@ -41,7 +41,7 @@ public:
   RawComment() : Kind(RCK_Invalid), IsAlmostTrailingComment(false) { }
 
   RawComment(const SourceManager , SourceRange SR,
- bool Merged, bool ParseAllComments);
+ const CommentOptions , bool Merged);
 
   CommentKind getKind() const LLVM_READONLY {
 return (CommentKind) Kind;
@@ -83,8 +83,7 @@ public:
 
   /// Returns true if this comment is not a documentation comment.
   bool isOrdinary() const LLVM_READONLY {
-return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC)) &&
-!ParseAllComments;
+return ((Kind == RCK_OrdinaryBCPL) || (Kind == RCK_OrdinaryC));
   }
 
   /// Returns true if this comment any kind of a documentation comment.
@@ -92,11 +91,6 @@ public:
 return !isInvalid() && !isOrdinary();
   }
 
-  /// Returns whether we are parsing all comments.
-  bool isParseAllComments() const LLVM_READONLY {
-return ParseAllComments;
-  }
-
   /// Returns raw comment text with comment markers.
   StringRef getRawText(const SourceManager ) const {
 if (RawTextValid)
@@ -139,18 +133,12 @@ private:
   bool IsTrailingComment : 1;
   bool IsAlmostTrailingComment : 1;
 
-  /// When true, ordinary comments starting with "//" and "/*" will be
-  /// considered as documentation comments.
-  bool ParseAllComments : 1;
-
   /// \brief Constructor for AST deserialization.
   RawComment(SourceRange SR, CommentKind K, bool IsTrailingComment,
- bool IsAlmostTrailingComment,
- bool ParseAllComments) :
+ bool IsAlmostTrailingComment) :
 Range(SR), RawTextValid(false), BriefTextValid(false), Kind(K),
 IsAttached(false), IsTrailingComment(IsTrailingComment),
-IsAlmostTrailingComment(IsAlmostTrailingComment),
-ParseAllComments(ParseAllComments)
+IsAlmostTrailingComment(IsAlmostTrailingComment)
   { }
 
   StringRef getRawTextSlow(const SourceManager ) const;
@@ -183,7 +171,8 @@ class RawCommentList {
 public:
   RawCommentList(SourceManager ) : SourceMgr(SourceMgr) {}
 
-  void addComment(const RawComment , llvm::BumpPtrAllocator );
+  void addComment(const RawComment , const CommentOptions ,
+  llvm::BumpPtrAllocator );
 
   ArrayRef getComments() const {
 return Comments;

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=326501=326500=326501=diff

[PATCH] D43965: [Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS

2018-03-01 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326499: [Driver] Pass -f[no-]emulated-tls and set up 
ExplicitEmulatedTLS (authored by chh, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43965?vs=136601=136608#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43965

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Driver/emulated-tls.cpp

Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3937,13 +3937,9 @@
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
-  // Emulated TLS is enabled by default on Android and OpenBSD, and can be enabled
-  // manually with -femulated-tls.
-  bool EmulatedTLSDefault = Triple.isAndroid() || Triple.isOSOpenBSD() ||
-Triple.isWindowsCygwinEnvironment();
-  if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls,
-   EmulatedTLSDefault))
-CmdArgs.push_back("-femulated-tls");
+  Args.AddLastArg(CmdArgs, options::OPT_femulated_tls,
+  options::OPT_fno_emulated_tls);
+
   // AltiVec-like language extensions aren't relevant for assembling.
   if (!isa(JA) || Output.getType() != types::TY_PP_Asm)
 Args.AddLastArg(CmdArgs, options::OPT_fzvector);
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -942,8 +942,12 @@
 }
   }
 
-  Opts.EmulatedTLS =
-  Args.hasFlag(OPT_femulated_tls, OPT_fno_emulated_tls, false);
+  if (Args.getLastArg(OPT_femulated_tls) ||
+  Args.getLastArg(OPT_fno_emulated_tls)) {
+Opts.ExplicitEmulatedTLS = true;
+Opts.EmulatedTLS =
+Args.hasFlag(OPT_femulated_tls, OPT_fno_emulated_tls, false);
+  }
 
   if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
 StringRef Name = A->getValue();
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -433,6 +433,7 @@
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
+  Options.ExplicitEmulatedTLS = CodeGenOpts.ExplicitEmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
 
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -69,7 +69,8 @@
 CODEGENOPT(EmitGcovArcs  , 1, 0) ///< Emit coverage data files, aka. GCDA.
 CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka GCNO.
 CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata.
-CODEGENOPT(EmulatedTLS   , 1, 0) ///< Set when -femulated-tls is enabled.
+CODEGENOPT(EmulatedTLS   , 1, 0) ///< Set by default or -f[no-]emulated-tls.
+CODEGENOPT(ExplicitEmulatedTLS , 1, 0) ///< Set if -f[no-]emulated-tls is used.
 /// \brief Embed Bitcode mode (off/all/bitcode/marker).
 ENUM_CODEGENOPT(EmbedBitcode, EmbedBitcodeKind, 2, Embed_Off)
 CODEGENOPT(ForbidGuardVariables , 1, 0) ///< Issue errors if C++ guard variables
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -815,7 +815,7 @@
   HelpText<"Emit all declarations, even if unused">;
 def femulated_tls : Flag<["-"], "femulated-tls">, Group, Flags<[CC1Option]>,
   HelpText<"Use emutls functions to access thread_local variables">;
-def fno_emulated_tls : Flag<["-"], "fno-emulated-tls">, Group;
+def fno_emulated_tls : Flag<["-"], "fno-emulated-tls">, Group, Flags<[CC1Option]>;
 def fencoding_EQ : Joined<["-"], "fencoding=">, Group;
 def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, Flags<[CoreOption]>;
 def fexceptions : Flag<["-"], "fexceptions">, Group, Flags<[CC1Option]>,
Index: cfe/trunk/test/Driver/emulated-tls.cpp
===
--- cfe/trunk/test/Driver/emulated-tls.cpp
+++ cfe/trunk/test/Driver/emulated-tls.cpp
@@ -1,7 +1,42 @@
-// 

r326499 - [Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS

2018-03-01 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Thu Mar  1 14:26:19 2018
New Revision: 326499

URL: http://llvm.org/viewvc/llvm-project?rev=326499=rev
Log:
[Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS

Since LLVM r326341, default EmulatedTLS mode is decided in backend
according to target triple. Any front-end should pass -f[no]-emulated-tls
to backend and set up ExplicitEmulatedTLS only when the flags are used.

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



Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/emulated-tls.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=326499=326498=326499=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Mar  1 14:26:19 2018
@@ -815,7 +815,7 @@ def femit_all_decls : Flag<["-"], "femit
   HelpText<"Emit all declarations, even if unused">;
 def femulated_tls : Flag<["-"], "femulated-tls">, Group, 
Flags<[CC1Option]>,
   HelpText<"Use emutls functions to access thread_local variables">;
-def fno_emulated_tls : Flag<["-"], "fno-emulated-tls">, Group;
+def fno_emulated_tls : Flag<["-"], "fno-emulated-tls">, Group, 
Flags<[CC1Option]>;
 def fencoding_EQ : Joined<["-"], "fencoding=">, Group;
 def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, 
Flags<[CoreOption]>;
 def fexceptions : Flag<["-"], "fexceptions">, Group, 
Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=326499=326498=326499=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Mar  1 14:26:19 2018
@@ -69,7 +69,8 @@ CODEGENOPT(EmitDeclMetadata  , 1, 0) ///
 CODEGENOPT(EmitGcovArcs  , 1, 0) ///< Emit coverage data files, aka. GCDA.
 CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka 
GCNO.
 CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata.
-CODEGENOPT(EmulatedTLS   , 1, 0) ///< Set when -femulated-tls is enabled.
+CODEGENOPT(EmulatedTLS   , 1, 0) ///< Set by default or 
-f[no-]emulated-tls.
+CODEGENOPT(ExplicitEmulatedTLS , 1, 0) ///< Set if -f[no-]emulated-tls is used.
 /// \brief Embed Bitcode mode (off/all/bitcode/marker).
 ENUM_CODEGENOPT(EmbedBitcode, EmbedBitcodeKind, 2, Embed_Off)
 CODEGENOPT(ForbidGuardVariables , 1, 0) ///< Issue errors if C++ guard 
variables

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=326499=326498=326499=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Mar  1 14:26:19 2018
@@ -433,6 +433,7 @@ static void initTargetOptions(llvm::Targ
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
+  Options.ExplicitEmulatedTLS = CodeGenOpts.ExplicitEmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=326499=326498=326499=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Mar  1 14:26:19 2018
@@ -3937,13 +3937,9 @@ void Clang::ConstructJob(Compilation ,
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
-  // Emulated TLS is enabled by default on Android and OpenBSD, and can be 
enabled
-  // manually with -femulated-tls.
-  bool EmulatedTLSDefault = Triple.isAndroid() || Triple.isOSOpenBSD() ||
-Triple.isWindowsCygwinEnvironment();
-  if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls,
-   EmulatedTLSDefault))
-CmdArgs.push_back("-femulated-tls");
+  Args.AddLastArg(CmdArgs, options::OPT_femulated_tls,
+  options::OPT_fno_emulated_tls);
+
   // AltiVec-like language extensions aren't relevant for assembling.
   if (!isa(JA) || Output.getType() != types::TY_PP_Asm)
 

r326496 - [modules] Don't diagnose "redefinition" of a friend with a pending definition

2018-03-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Mar  1 14:20:13 2018
New Revision: 326496

URL: http://llvm.org/viewvc/llvm-project?rev=326496=rev
Log:
[modules] Don't diagnose "redefinition" of a friend with a pending definition
if the other definition is a merged copy of the same function.

Added:
cfe/trunk/test/Modules/friend-definition.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=326496=326495=326496=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Mar  1 14:20:13 2018
@@ -12303,6 +12303,15 @@ Sema::CheckForFunctionRedefinition(Funct
   if (I != FD && !I->isInvalidDecl() &&
   I->getFriendObjectKind() != Decl::FOK_None) {
 if (FunctionDecl *Original = I->getInstantiatedFromMemberFunction()) {
+  if (FunctionDecl *OrigFD = FD->getInstantiatedFromMemberFunction()) {
+// A merged copy of the same function, instantiated as a member of
+// the same class, is OK.
+if (declaresSameEntity(OrigFD, Original) &&
+declaresSameEntity(cast(I->getLexicalDeclContext()),
+   cast(FD->getLexicalDeclContext(
+  continue;
+  }
+
   if (Original->isThisDeclarationADefinition()) {
 Definition = I;
 break;

Added: cfe/trunk/test/Modules/friend-definition.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/friend-definition.cpp?rev=326496=auto
==
--- cfe/trunk/test/Modules/friend-definition.cpp (added)
+++ cfe/trunk/test/Modules/friend-definition.cpp Thu Mar  1 14:20:13 2018
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fmodules -std=c++14 %s -verify
+// expected-no-diagnostics
+
+#pragma clang module build A
+module A {}
+#pragma clang module contents
+#pragma clang module begin A
+template struct A {
+  friend A operator+(const A&, const A&) { return {}; }
+};
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module build B
+module B {}
+#pragma clang module contents
+#pragma clang module begin B
+#pragma clang module import A
+inline void f() { A a; }
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module build C
+module C {}
+#pragma clang module contents
+#pragma clang module begin C
+#pragma clang module import A
+inline void g() { A a; }
+#pragma clang module end
+#pragma clang module endbuild
+
+#pragma clang module import A
+#pragma clang module import B
+#pragma clang module import C
+
+void h() {
+  A a;
+  a + a;
+}


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


[PATCH] D43965: [Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS

2018-03-01 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Tested on the case that was broken before, and seems to work fine. Thanks!


https://reviews.llvm.org/D43965



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


[PATCH] D43965: [Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS

2018-03-01 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

Martin, thanks for finding this problem.
Please review/accept my new change if it passes your tests.
After this and https://reviews.llvm.org/D42999, the default emulated TLS mode 
should only be decided in
llvm/trunk/include/llvm/ADT/Triple.h hasDefaultEmulatedTLS().


https://reviews.llvm.org/D43965



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


[PATCH] D43965: [Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS

2018-03-01 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

LGTM (although I didn't test run it).


https://reviews.llvm.org/D43965



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


r326493 - [www] Capitalize "Clang" when referring to the project, and generalize the

2018-03-01 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Mar  1 14:01:06 2018
New Revision: 326493

URL: http://llvm.org/viewvc/llvm-project?rev=326493=rev
Log:
[www] Capitalize "Clang" when referring to the project, and generalize the
introduction on the front page page.

We still use the lowercase "clang" spelling when referring to the driver binary.

Modified:
cfe/trunk/www/comparison.html
cfe/trunk/www/index.html

Modified: cfe/trunk/www/comparison.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/comparison.html?rev=326493=326492=326493=diff
==
--- cfe/trunk/www/comparison.html (original)
+++ cfe/trunk/www/comparison.html Thu Mar  1 14:01:06 2018
@@ -4,7 +4,7 @@
 
 
   
-  Comparing clang to other open source compilers
+  Comparing Clang to other open source compilers
   
   
 
@@ -14,7 +14,7 @@
 Clang vs Other Open Source Compilers
 
 Building an entirely new compiler front-end is a big task, and it isn't
-   always clear to people why we decided to do this.  Here we compare clang
+   always clear to people why we decided to do this.  Here we compare Clang
and its goals to other open source compiler front-ends that are
available.  We restrict the discussion to very specific objective points
to avoid controversy where possible.  Also, software is infinitely
@@ -24,7 +24,7 @@

 The goal of this list is to describe how differences in goals lead to
different strengths and weaknesses, not to make some compiler look bad.
-   This will hopefully help you to evaluate whether using clang is a good
+   This will hopefully help you to evaluate whether using Clang is a good
idea for your personal goals.  Because we don't know specifically what
you want to do, we describe the features of these compilers in
terms of our goals: if you are only interested in static
@@ -45,10 +45,10 @@
 Clang vs GCC (GNU Compiler Collection)
 

 
-Pro's of GCC vs clang:
+Pro's of GCC vs Clang:
 
 
-GCC supports languages that clang does not aim to, such as Java, Ada,
+GCC supports languages that Clang does not aim to, such as Java, Ada,
 FORTRAN, Go, etc.
 GCC supports more targets than LLVM.
 GCC supports many language extensions, some of which are not 
implemented
@@ -59,7 +59,7 @@
 allowing VLAs in structs.
 
 
-Pro's of clang vs GCC:
+Pro's of Clang vs GCC:
 
 
 The Clang ASTs and design are intended to be 
 GCC is licensed under the GPL license. 
-clang uses a BSD license, which allows it to be embedded in
+Clang uses a BSD license, which allows it to be embedded in
 software that is not GPL-licensed.
 Clang inherits a number of features from its use of LLVM as a backend,
 including support for a bytecode representation for intermediate code,
@@ -122,7 +122,7 @@
 Clang vs Elsa (Elkhound-based C++ Parser)
 

 
-Pro's of Elsa vs clang:
+Pro's of Elsa vs Clang:
 
 
 Elsa's parser and AST is designed to be easily extensible by adding
@@ -130,7 +130,7 @@
 but requires you to write C++ code to do it.
 
 
-Pro's of clang vs Elsa:
+Pro's of Clang vs Elsa:
 
 
 Clang's C and C++ support is far more mature and practically useful 
than
@@ -143,7 +143,7 @@
 file bugs against Clang and they will often be fixed for you.  If you
 use Elsa, you are (mostly) on your own for bug fixes and feature
 enhancements.
-Elsa is not built as a stack of reusable libraries like clang is.  It 
is
+Elsa is not built as a stack of reusable libraries like Clang is.  It 
is
 very difficult to use part of Elsa without the whole front-end.  For
 example, you cannot use Elsa to parse C/ObjC code without building an
 AST.  You can do this in Clang and it is much faster than building an
@@ -153,7 +153,7 @@
 its original position before preprocessing.  Like GCC, it does not keep
 track of macro expansions.
 Elsa is even slower and uses more memory than GCC, which itself 
requires 
-far more space and time than clang.
+far more space and time than Clang.
 Elsa only does partial semantic analysis.  It is intended to work on
 code that is already validated by GCC, so it does not do many semantic
 checks required by the languages it implements.
@@ -166,18 +166,18 @@
 Clang vs PCC (Portable C Compiler)
 

 
-Pro's of PCC vs clang:
+Pro's of PCC vs Clang:
 
 
 The PCC source base is very small and builds quickly with just a C
 compiler.
 
 
-Pro's of clang vs PCC:
+Pro's of Clang vs PCC:
 
 
 PCC dates from the 1970's and has been dormant for most of that time.
-The clang + llvm communities are very active.
+The Clang and LLVM communities 

[PATCH] D43965: [Driver] Pass -f[no-]emulated-tls and set up ExplicitEmulatedTLS

2018-03-01 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 136601.
chh retitled this revision from "[CodeGen] Force the backend to follow clang's 
EmulatedTLS flag" to "[Driver] Pass -f[no-]emulated-tls and set up 
ExplicitEmulatedTLS".
chh edited the summary of this revision.
chh added a reviewer: srhines.

https://reviews.llvm.org/D43965

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/emulated-tls.cpp

Index: test/Driver/emulated-tls.cpp
===
--- test/Driver/emulated-tls.cpp
+++ test/Driver/emulated-tls.cpp
@@ -1,7 +1,42 @@
-// Cygwin and OpenBSD use emutls. Clang should pass -femulated-tls to cc1
-// and cc1 should pass EmulatedTLS to LLVM CodeGen.
-// FIXME: Add more targets here to use emutls.
-// RUN: %clang -### -std=c++11 -target i686-pc-cygwin %s 2>&1 | FileCheck %s
-// RUN: %clang -### -std=c++11 -target i686-pc-openbsd %s 2>&1 | FileCheck %s
+// Android, Cygwin and OpenBSD use emutls by default.
+// Clang should pass -femulated-tls or -fno-emulated-tls to cc1 if they are used,
+// and cc1 should set up EmulatedTLS and ExplicitEmulatedTLS to LLVM CodeGen.
+//
+// RUN: %clang -### -target arm-linux-androideabi %s 2>&1 \
+// RUN: | FileCheck -check-prefix=DEFAULT %s
+// RUN: %clang -### -target arm-linux-gnu %s 2>&1 \
+// RUN: | FileCheck -check-prefix=DEFAULT %s
+// RUN: %clang -### -target i686-pc-cygwin %s 2>&1 \
+// RUN: | FileCheck -check-prefix=DEFAULT %s
+// RUN: %clang -### -target i686-pc-openbsd %s 2>&1 \
+// RUN: | FileCheck -check-prefix=DEFAULT %s
 
-// CHECK: "-cc1" {{.*}}"-femulated-tls"
+// RUN: %clang -### -target arm-linux-androideabi -fno-emulated-tls -femulated-tls %s 2>&1 \
+// RUN: | FileCheck -check-prefix=EMU %s
+// RUN: %clang -### -target arm-linux-gnu %s -fno-emulated-tls -femulated-tls 2>&1 \
+// RUN: | FileCheck -check-prefix=EMU %s
+// RUN: %clang -### -target i686-pc-cygwin %s -fno-emulated-tls -femulated-tls 2>&1 \
+// RUN: | FileCheck -check-prefix=EMU %s
+// RUN: %clang -### -target i686-pc-openbsd %s -fno-emulated-tls -femulated-tls 2>&1 \
+// RUN: | FileCheck -check-prefix=EMU %s
+
+// RUN: %clang -### -target arm-linux-androideabi -femulated-tls -fno-emulated-tls %s 2>&1 \
+// RUN: | FileCheck -check-prefix=NOEMU %s
+// RUN: %clang -### -target arm-linux-gnu %s -femulated-tls -fno-emulated-tls 2>&1 \
+// RUN: | FileCheck -check-prefix=NOEMU %s
+// RUN: %clang -### -target i686-pc-cygwin %s -femulated-tls -fno-emulated-tls 2>&1 \
+// RUN: | FileCheck -check-prefix=NOEMU %s
+// RUN: %clang -### -target i686-pc-openbsd %s -femulated-tls -fno-emulated-tls 2>&1 \
+// RUN: | FileCheck -check-prefix=NOEMU %s
+
+
+// Default without -f[no-]emulated-tls, will be decided by the target triple.
+// DEFAULT-NOT: "-cc1" {{.*}}"-femulated-tls"
+// DEFAULT-NOT: "-cc1" {{.*}}"-fno-emulated-tls"
+
+// Explicit and last -f[no-]emulated-tls flag will be passed to cc1.
+// EMU: "-cc1" {{.*}}"-femulated-tls"
+// EMU-NOT: "-cc1" {{.*}}"-fno-emulated-tls"
+
+// NOEMU: "-cc1" {{.*}}"-fno-emulated-tls"
+// NOEMU-NOT: "-cc1" {{.*}}"-femulated-tls"
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -942,8 +942,12 @@
 }
   }
 
-  Opts.EmulatedTLS =
-  Args.hasFlag(OPT_femulated_tls, OPT_fno_emulated_tls, false);
+  if (Args.getLastArg(OPT_femulated_tls) ||
+  Args.getLastArg(OPT_fno_emulated_tls)) {
+Opts.ExplicitEmulatedTLS = true;
+Opts.EmulatedTLS =
+Args.hasFlag(OPT_femulated_tls, OPT_fno_emulated_tls, false);
+  }
 
   if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
 StringRef Name = A->getValue();
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3937,13 +3937,9 @@
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
-  // Emulated TLS is enabled by default on Android and OpenBSD, and can be enabled
-  // manually with -femulated-tls.
-  bool EmulatedTLSDefault = Triple.isAndroid() || Triple.isOSOpenBSD() ||
-Triple.isWindowsCygwinEnvironment();
-  if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls,
-   EmulatedTLSDefault))
-CmdArgs.push_back("-femulated-tls");
+  Args.AddLastArg(CmdArgs, options::OPT_femulated_tls,
+  options::OPT_fno_emulated_tls);
+
   // AltiVec-like language extensions aren't relevant for assembling.
   if (!isa(JA) || Output.getType() != types::TY_PP_Asm)
 Args.AddLastArg(CmdArgs, options::OPT_fzvector);
Index: lib/CodeGen/BackendUtil.cpp

[PATCH] D43969: Improve completion experience for headers

2018-03-01 Thread Philipp via Phabricator via cfe-commits
phst updated this revision to Diff 136598.
phst added a comment.

Fix condition


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43969

Files:
  include-fixer/tool/clang-include-fixer.el


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; 
https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test 
#'string=)))
-(cl-assert info)
+(unless info (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test #'string=)))
-(cl-assert info)
+(unless info (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43969: Improve completion experience for headers

2018-03-01 Thread Philipp via Phabricator via cfe-commits
phst updated this revision to Diff 136597.
phst added a comment.

Revert bogus additions


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43969

Files:
  include-fixer/tool/clang-include-fixer.el


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; 
https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test 
#'string=)))
-(cl-assert info)
+(unless header (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test #'string=)))
-(cl-assert info)
+(unless header (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43969: Improve completion experience for headers

2018-03-01 Thread Philipp via Phabricator via cfe-commits
phst created this revision.
phst added a reviewer: klimek.
Herald added a subscriber: cfe-commits.

When calling `completing-read', we should provide a default to prevent the 
behavior described in 
https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
  Also, don't use an assertion to check whether the user selected a header; 
raise a proper signal instead.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43969

Files:
  include-fixer/tool/clang-include-fixer.el
  tools/
  tools/clang-format/


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; 
https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test 
#'string=)))
-(cl-assert info)
+(unless header (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)


Index: include-fixer/tool/clang-include-fixer.el
===
--- include-fixer/tool/clang-include-fixer.el
+++ include-fixer/tool/clang-include-fixer.el
@@ -314,14 +314,18 @@
   (goto-char (clang-include-fixer--closest-overlay overlays)))
 (cl-flet ((header (info) (let-alist info .Header)))
   ;; The header-infos is already sorted by include-fixer.
-  (let* ((header (completing-read
+  (let* ((headers (mapcar #'header .HeaderInfos))
+ (header (completing-read
   (clang-include-fixer--format-message
"Select include for '%s': " symbol)
-  (mapcar #'header .HeaderInfos)
-  nil :require-match nil
-  'clang-include-fixer--history))
+  headers nil :require-match nil
+  'clang-include-fixer--history
+  ;; Specify a default to prevent the behavior
+  ;; described in
+  ;; https://github.com/DarwinAwardWinner/ido-completing-read-plus#why-does-ret-sometimes-not-select-the-first-completion-on-the-list--why-is-there-an-empty-entry-at-the-beginning-of-the-completion-list--what-happened-to-old-style-default-selection.
+  (car headers)))
  (info (cl-find header .HeaderInfos :key #'header :test #'string=)))
-(cl-assert info)
+(unless header (user-error "No header selected"))
 (setcar .HeaderInfos info)
 (setcdr .HeaderInfos nil
 (mapc #'delete-overlay overlays)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43965: [CodeGen] Force the backend to follow clang's EmulatedTLS flag

2018-03-01 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Ok, thanks. Yes, this should probably only set it if some of those flags are 
set here.

FWIW, clang also has got a list of targets where emulated TLS is enabled by 
default - could this be omitted somehow, now that LLVM can handle that on its 
own?


Repository:
  rC Clang

https://reviews.llvm.org/D43965



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


[PATCH] D43967: Add test helper Fixture

2018-03-01 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

We add several test cases here, some of them are disabled.
We plan to pass the disabled tests in different patches.


Repository:
  rC Clang

https://reviews.llvm.org/D43967



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


[PATCH] D43967: Add test helper Fixture

2018-03-01 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a.sidorin, xazax.hun, szepet.
Herald added subscribers: cfe-commits, dkrupp, rnkovacs.

[ASTImporter] Add a helper test Fixture, so we can add tests which may
check internal attributes of AST nodes. Also it makes possible to import from
several "From" contexts.


Repository:
  rC Clang

https://reviews.llvm.org/D43967

Files:
  unittests/AST/ASTImporterTest.cpp
  unittests/AST/DeclMatcher.h

Index: unittests/AST/DeclMatcher.h
===
--- /dev/null
+++ unittests/AST/DeclMatcher.h
@@ -0,0 +1,68 @@
+//===- unittest/AST/DeclMatcher.h - AST unit test support ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_UNITTESTS_AST_DECLMATCHER_H
+#define LLVM_CLANG_UNITTESTS_AST_DECLMATCHER_H
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+namespace clang {
+namespace ast_matchers {
+
+enum class DeclMatcherKind { First, Last };
+
+// Matcher class to retrieve the first/last matched node under a given AST.
+template 
+class DeclMatcher : public MatchFinder::MatchCallback {
+  NodeType *Node = nullptr;
+  void run(const MatchFinder::MatchResult ) override {
+if ((MatcherKind == DeclMatcherKind::First && Node == nullptr) ||
+MatcherKind == DeclMatcherKind::Last) {
+  Node = const_cast(Result.Nodes.getNodeAs(""));
+}
+  }
+public:
+  // Returns the first/last matched node under the tree rooted in `D`.
+  template 
+  NodeType *match(const Decl *D, const MatcherType ) {
+MatchFinder Finder;
+Finder.addMatcher(AMatcher.bind(""), this);
+Finder.matchAST(D->getASTContext());
+assert(Node);
+return Node;
+  }
+};
+template 
+using LastDeclMatcher = DeclMatcher;
+template 
+using FirstDeclMatcher = DeclMatcher;
+
+template 
+class DeclCounter : public MatchFinder::MatchCallback {
+  unsigned count = 0;
+  void run(const MatchFinder::MatchResult ) override {
+  if(Result.Nodes.getNodeAs("")) {
+++count;
+  }
+  }
+public:
+  // Returns the number of matched nodes under the tree rooted in `D`.
+  template 
+  unsigned match(const Decl *D, const MatcherType ) {
+MatchFinder Finder;
+Finder.addMatcher(AMatcher.bind(""), this);
+Finder.matchAST(D->getASTContext());
+return count;
+  }
+};
+
+} // end namespace ast_matchers
+} // end namespace clang
+
+#endif
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -17,6 +17,8 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/Tooling.h"
+
+#include "DeclMatcher.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -29,7 +31,7 @@
   return Lang == Lang_CXX || Lang == Lang_CXX11;
 }
 
-static RunOptions getRunOptionsForLanguage(Language Lang) {
+static ArgVector getBasicRunOptionsForLanguage(Language Lang) {
   ArgVector BasicArgs;
   // Test with basic arguments.
   switch (Lang) {
@@ -49,6 +51,11 @@
   case Lang_OBJCXX:
 llvm_unreachable("Not implemented yet!");
   }
+  return BasicArgs;
+}
+
+static RunOptions getRunOptionsForLanguage(Language Lang) {
+  ArgVector BasicArgs = getBasicRunOptionsForLanguage(Lang);
 
   // For C++, test with "-fdelayed-template-parsing" enabled to handle MSVC
   // default behaviour.
@@ -133,6 +140,146 @@
  Verifier, AMatcher));
 }
 
+class Fixture : public ::testing::Test {
+
+  const char *const InputFileName = "input.cc";
+  const char *const OutputFileName = "output.cc";
+
+  //Buffers for the contexts, must live in test scope
+  std::string ToCode;
+
+  struct TU {
+std::string Code;
+std::string FileName;
+std::unique_ptr Unit;
+TranslationUnitDecl *TUDecl = nullptr;
+TU(StringRef Code, StringRef FileName, ArgVector Args)
+: Code(Code), FileName(FileName),
+  Unit(tooling::buildASTFromCodeWithArgs(this->Code, Args,
+ this->FileName)),
+  TUDecl(Unit->getASTContext().getTranslationUnitDecl()) {}
+  };
+  // We may have several From context and related translation units.
+  std::list FromTUs;
+
+  // Creates a virtual file and assigns that to the To context.  If the file
+  // already exists then the file will not be created again as a duplicate.
+  void createVirtualFile(StringRef FileName, const std::string ) {
+assert(ToAST);
+ASTContext  = ToAST->getASTContext();
+vfs::OverlayFileSystem *OFS = static_cast(
+ToCtx.getSourceManager().getFileManager().getVirtualFileSystem().get());
+

[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-01 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked 3 inline comments as done.
jdenny added inline comments.



Comment at: include/clang/Basic/Attr.td:172-174
+  // Whether the C++ implicit this parameter is allowed.  Users that construct
+  // attributes from the source code use this information when validating
+  // parameter indices.

aaron.ballman wrote:
> jdenny wrote:
> > aaron.ballman wrote:
> > > I still find the `AllowThis` parts to be hard to follow, so I want to be 
> > > sure I understand your design properly. Everything that uses this new 
> > > argument type sets `AllowsThis` to 0. As written, it sounds like setting 
> > > that to 0 means that the parameter index cannot be used on a C++ instance 
> > > method, and I know that's not the correct interpretation. Under what 
> > > circumstances would this be set to 1 instead?
> > > 
> > > Looking at the existing code, the only circumstances under which 
> > > `checkFunctionOrMethodParameterIndex()` was being passed `true` for 
> > > "allow this" was for XRayLogArgs, which doesn't even use `ParamIdx`. 
> > > Perhaps this member isn't necessary any longer?
> > > I still find the AllowThis parts to be hard to follow, so I want to be 
> > > sure I understand your design properly. Everything that uses this new 
> > > argument type sets AllowsThis to 0. As written, it sounds like setting 
> > > that to 0 means that the parameter index cannot be used on a C++ instance 
> > > method, and I know that's not the correct interpretation.
> > 
> > Right. AllowsThis=0 means it is an error for the attribute in the source 
> > code to specify the C++ implicit this parameter (index 1).
> > 
> > > Under what circumstances would this be set to 1 instead?
> > >
> > > Looking at the existing code, the only circumstances under which 
> > > checkFunctionOrMethodParameterIndex() was being passed true for "allow 
> > > this" was for XRayLogArgs, which doesn't even use ParamIdx. Perhaps this 
> > > member isn't necessary any longer?
> > 
> > Right.  I also noticed this issue, but I probably should have mentioned 
> > that in a comment in the source instead of just rewording the last 
> > paragraph of the patch summary.  Sorry.
> > 
> > I thought about removing AllowsThis, but I hesitated because I had already 
> > implemented it by the time I noticed this issue and because I assumed there 
> > must be some reason why attributes for C++ have index 1 mean the this 
> > parameter, so there might be some attribute that could eventually take 
> > advantage of AllowsThis=1.  Moreover, it makes the related argument to 
> > checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp clearer.
> > 
> > I don't feel strongly either way, so I'm happy to remove it or keep it.
> > Right. AllowsThis=0 means it is an error for the attribute in the source 
> > code to specify the C++ implicit this parameter (index 1).
> 
> Then if we keep this functionality, I think a better identifier would be 
> something like `CanIndexImplicitThis` and the comments could be updated to 
> more clearly state what is allowed/disallowed. Then the other uses of "allow 
> this" can be updated to use similar terminology for clarity.
> 
> > so there might be some attribute that could eventually take advantage of 
> > AllowsThis=1. Moreover, it makes the related argument to 
> > checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp clearer.
> 
> My gut feeling is that this functionality isn't going to be needed all that 
> frequently. If we get a second case where we need it, then I'd say it might 
> make more sense to add it.
> 
> Attributes that use positional arguments should hopefully be the exception, 
> not the rule, because those indexes are horribly fragile.
> 
> What do you think?
> My gut feeling is that this functionality isn't going to be needed all that 
> frequently. If we get a second case where we need it, then I'd say it might 
> make more sense to add it.
> 
> Attributes that use positional arguments should hopefully be the exception, 
> not the rule, because those indexes are horribly fragile.
> 
> What do you think?

I'm guessing you have more experience with attributes in general, so let's go 
with your gut.  :-)



Comment at: lib/Sema/SemaDeclAttr.cpp:4549-4551
+if (ArgumentIdx.getASTIndex() >= getFunctionOrMethodNumParams(D) ||
+!getFunctionOrMethodParamType(D, ArgumentIdx.getASTIndex())
+ ->isPointerType())

aaron.ballman wrote:
> jdenny wrote:
> > aaron.ballman wrote:
> > > Is this formatting produced by clang-format?
> > Yes.
> How funky. :-)
Agreed.


https://reviews.llvm.org/D43248



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


[PATCH] D43965: [CodeGen] Force the backend to follow clang's EmulatedTLS flag

2018-03-01 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh commandeered this revision.
chh edited reviewers, added: mstorsjo; removed: chh.
chh added a comment.

I will upload a different fix soon.
We should set ExplicitEmulatedTLS only when -f[no-]emulated-tls flag is found 
at command line.
Any front-end should only pass the flag and let backend decide the default 
based on target.


Repository:
  rC Clang

https://reviews.llvm.org/D43965



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


[libcxx] r326485 - Added P0805 to the list of ready bits

2018-03-01 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu Mar  1 13:16:07 2018
New Revision: 326485

URL: http://llvm.org/viewvc/llvm-project?rev=326485=rev
Log:
Added P0805 to the list of ready bits

Modified:
libcxx/trunk/www/upcoming_meeting.html

Modified: libcxx/trunk/www/upcoming_meeting.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/upcoming_meeting.html?rev=326485=326484=326485=diff
==
--- libcxx/trunk/www/upcoming_meeting.html (original)
+++ libcxx/trunk/www/upcoming_meeting.html Thu Mar  1 13:16:07 2018
@@ -48,7 +48,8 @@
 
   Paper Status
   
-   Paper #GroupPaper 
NameMeetingStatusFirst released version
+   Paper #Paper 
NameMeetingStatus
+   https://wg21.link/P0805R1;>P0805R1Comparing 
ContainersJacksonvillePatch Ready: https://reviews.llvm.org/D43773;>D43773
 
@@ -150,7 +151,7 @@
  2936 - Eric - don't we do this already?
 
 
-Last Updated: 7-Feb-2018
+Last Updated: 1-Mar-2018
 
 
 


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


[PATCH] D43965: [CodeGen] Force the backend to follow clang's EmulatedTLS flag

2018-03-01 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: chh, jyknight.

Since LLVM r326341, this is needed for the backend to actually respect the 
EmulatedTLS flag that is set, otherwise it just uses the target default flag 
instead.


Repository:
  rC Clang

https://reviews.llvm.org/D43965

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -432,6 +432,7 @@
   Options.FunctionSections = CodeGenOpts.FunctionSections;
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
+  Options.ExplicitEmulatedTLS = true;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -432,6 +432,7 @@
   Options.FunctionSections = CodeGenOpts.FunctionSections;
   Options.DataSections = CodeGenOpts.DataSections;
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
+  Options.ExplicitEmulatedTLS = true;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

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



Comment at: include/clang/AST/Attr.h:206
+
+  void cmpable(const ParamIdx ) const {
+assert(isValid() && I.isValid() &&

jdenny wrote:
> aaron.ballman wrote:
> > The name here can be improved. How about `checkInvariants()`? Might as well 
> > make this inline while you're at it.
> Sure, I can change the name.
> 
> It's inside the class, so specifying inline is against the LLVM coding 
> standards, right?
Derp, you're correct, it's already implicitly inline. Ignore that part of the 
suggestion.



Comment at: include/clang/AST/Attr.h:236
+  /// parameter.
+  ParamIdx(unsigned Idx, bool HasThis)
+  : Idx(Idx), HasThis(HasThis), IsValid(true) {}

jdenny wrote:
> aaron.ballman wrote:
> > Is this constructor used anywhere? I didn't see it being used, but I could 
> > have missed something. If it's not used, go ahead and remove it.
> It's used by the deserialization code generated by ClangAttrEmitter.cpp.
That'd explain why I hadn't seen it.



Comment at: include/clang/AST/Attr.h:281-284
+  bool operator<(const ParamIdx ) const { cmpable(I); return Idx < I.Idx; }
+  bool operator>(const ParamIdx ) const { cmpable(I); return Idx > I.Idx; }
+  bool operator<=(const ParamIdx ) const { cmpable(I); return Idx <= I.Idx; }
+  bool operator>=(const ParamIdx ) const { cmpable(I); return Idx >= I.Idx; }

jdenny wrote:
> aaron.ballman wrote:
> > Are all of these operations required for the class?
> operator== and operator< are needed for sorting and finding.  It seems 
> strange to me not to finish the set.
I don't think it's actively harmful to do so, but I also don't think it's 
really needed either. Your call.



Comment at: include/clang/Basic/Attr.td:172-174
+  // Whether the C++ implicit this parameter is allowed.  Users that construct
+  // attributes from the source code use this information when validating
+  // parameter indices.

jdenny wrote:
> aaron.ballman wrote:
> > I still find the `AllowThis` parts to be hard to follow, so I want to be 
> > sure I understand your design properly. Everything that uses this new 
> > argument type sets `AllowsThis` to 0. As written, it sounds like setting 
> > that to 0 means that the parameter index cannot be used on a C++ instance 
> > method, and I know that's not the correct interpretation. Under what 
> > circumstances would this be set to 1 instead?
> > 
> > Looking at the existing code, the only circumstances under which 
> > `checkFunctionOrMethodParameterIndex()` was being passed `true` for "allow 
> > this" was for XRayLogArgs, which doesn't even use `ParamIdx`. Perhaps this 
> > member isn't necessary any longer?
> > I still find the AllowThis parts to be hard to follow, so I want to be sure 
> > I understand your design properly. Everything that uses this new argument 
> > type sets AllowsThis to 0. As written, it sounds like setting that to 0 
> > means that the parameter index cannot be used on a C++ instance method, and 
> > I know that's not the correct interpretation.
> 
> Right. AllowsThis=0 means it is an error for the attribute in the source code 
> to specify the C++ implicit this parameter (index 1).
> 
> > Under what circumstances would this be set to 1 instead?
> >
> > Looking at the existing code, the only circumstances under which 
> > checkFunctionOrMethodParameterIndex() was being passed true for "allow 
> > this" was for XRayLogArgs, which doesn't even use ParamIdx. Perhaps this 
> > member isn't necessary any longer?
> 
> Right.  I also noticed this issue, but I probably should have mentioned that 
> in a comment in the source instead of just rewording the last paragraph of 
> the patch summary.  Sorry.
> 
> I thought about removing AllowsThis, but I hesitated because I had already 
> implemented it by the time I noticed this issue and because I assumed there 
> must be some reason why attributes for C++ have index 1 mean the this 
> parameter, so there might be some attribute that could eventually take 
> advantage of AllowsThis=1.  Moreover, it makes the related argument to 
> checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp clearer.
> 
> I don't feel strongly either way, so I'm happy to remove it or keep it.
> Right. AllowsThis=0 means it is an error for the attribute in the source code 
> to specify the C++ implicit this parameter (index 1).

Then if we keep this functionality, I think a better identifier would be 
something like `CanIndexImplicitThis` and the comments could be updated to more 
clearly state what is allowed/disallowed. Then the other uses of "allow this" 
can be updated to use similar terminology for clarity.

> so there might be some attribute that could eventually take advantage of 
> AllowsThis=1. Moreover, it makes the related argument to 
> checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp clearer.

My gut feeling is that this 

[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-01 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D43248#1024183, @aaron.ballman wrote:

> In https://reviews.llvm.org/D43248#1023720, @jdenny wrote:
>
> > Hi Aaron.  It occurs to me now that this patch has grown rather large and, 
> > in some places, a little subtle.  Would it help the review if I were to 
> > break it up into a patch series that introduces ParamIdx to each attribute, 
> > one at a time?  I'm not trying to rush you, but I hate for the review to be 
> > painful for you if it doesn't have to be.
>
>
> No need to do that -- this review just takes a bit more time for me to 
> complete, but it's reasonably well-factored. Thank you, though!


Sure!  Thanks for the review.




Comment at: include/clang/AST/Attr.h:206
+
+  void cmpable(const ParamIdx ) const {
+assert(isValid() && I.isValid() &&

aaron.ballman wrote:
> The name here can be improved. How about `checkInvariants()`? Might as well 
> make this inline while you're at it.
Sure, I can change the name.

It's inside the class, so specifying inline is against the LLVM coding 
standards, right?



Comment at: include/clang/AST/Attr.h:236
+  /// parameter.
+  ParamIdx(unsigned Idx, bool HasThis)
+  : Idx(Idx), HasThis(HasThis), IsValid(true) {}

aaron.ballman wrote:
> Is this constructor used anywhere? I didn't see it being used, but I could 
> have missed something. If it's not used, go ahead and remove it.
It's used by the deserialization code generated by ClangAttrEmitter.cpp.



Comment at: include/clang/AST/Attr.h:281-284
+  bool operator<(const ParamIdx ) const { cmpable(I); return Idx < I.Idx; }
+  bool operator>(const ParamIdx ) const { cmpable(I); return Idx > I.Idx; }
+  bool operator<=(const ParamIdx ) const { cmpable(I); return Idx <= I.Idx; }
+  bool operator>=(const ParamIdx ) const { cmpable(I); return Idx >= I.Idx; }

aaron.ballman wrote:
> Are all of these operations required for the class?
operator== and operator< are needed for sorting and finding.  It seems strange 
to me not to finish the set.



Comment at: include/clang/Basic/Attr.td:172-174
+  // Whether the C++ implicit this parameter is allowed.  Users that construct
+  // attributes from the source code use this information when validating
+  // parameter indices.

aaron.ballman wrote:
> I still find the `AllowThis` parts to be hard to follow, so I want to be sure 
> I understand your design properly. Everything that uses this new argument 
> type sets `AllowsThis` to 0. As written, it sounds like setting that to 0 
> means that the parameter index cannot be used on a C++ instance method, and I 
> know that's not the correct interpretation. Under what circumstances would 
> this be set to 1 instead?
> 
> Looking at the existing code, the only circumstances under which 
> `checkFunctionOrMethodParameterIndex()` was being passed `true` for "allow 
> this" was for XRayLogArgs, which doesn't even use `ParamIdx`. Perhaps this 
> member isn't necessary any longer?
> I still find the AllowThis parts to be hard to follow, so I want to be sure I 
> understand your design properly. Everything that uses this new argument type 
> sets AllowsThis to 0. As written, it sounds like setting that to 0 means that 
> the parameter index cannot be used on a C++ instance method, and I know 
> that's not the correct interpretation.

Right. AllowsThis=0 means it is an error for the attribute in the source code 
to specify the C++ implicit this parameter (index 1).

> Under what circumstances would this be set to 1 instead?
>
> Looking at the existing code, the only circumstances under which 
> checkFunctionOrMethodParameterIndex() was being passed true for "allow this" 
> was for XRayLogArgs, which doesn't even use ParamIdx. Perhaps this member 
> isn't necessary any longer?

Right.  I also noticed this issue, but I probably should have mentioned that in 
a comment in the source instead of just rewording the last paragraph of the 
patch summary.  Sorry.

I thought about removing AllowsThis, but I hesitated because I had already 
implemented it by the time I noticed this issue and because I assumed there 
must be some reason why attributes for C++ have index 1 mean the this 
parameter, so there might be some attribute that could eventually take 
advantage of AllowsThis=1.  Moreover, it makes the related argument to 
checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp clearer.

I don't feel strongly either way, so I'm happy to remove it or keep it.



Comment at: lib/Sema/SemaDeclAttr.cpp:1650-1651
   OwnershipAttr(AL.getLoc(), S.Context, nullptr, nullptr, 0,
-AL.getAttributeSpellingListIndex()).getOwnKind();
+AL.getAttributeSpellingListIndex())
+  .getOwnKind();
 

aaron.ballman wrote:
> This change looks to be unrelated to the patch?
Sorry, I think clang-format 

[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-03-01 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Alright, this looks good to me.




Comment at: lib/Sema/SemaExpr.cpp:4846
+if (auto *BE = dyn_cast(Arg->IgnoreParenNoopCasts(Context)))
+  BE->getBlockDecl()->setDoesNotEscape();
+

ahatanak wrote:
> rjmccall wrote:
> > Can this be based on the noescape parameter bit on the function type?
> Oh that's right. It should be able to set the DoesNotEscape bit of a block 
> when it's passed to an indirect function call. I added an IRGen test case 
> that checks tail-call is enabled in such cases.
> 
Thanks!


https://reviews.llvm.org/D43841



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


[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-03-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 136584.
ahatanak marked an inline comment as done.
ahatanak added a comment.

Check the function prototype's noescape bit.


https://reviews.llvm.org/D43841

Files:
  include/clang/AST/Decl.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprObjC.cpp
  test/CodeGenObjC/disable-tail-call-escaping-block.m
  test/Driver/fno-escaping-block-tail-calls.c

Index: test/Driver/fno-escaping-block-tail-calls.c
===
--- /dev/null
+++ test/Driver/fno-escaping-block-tail-calls.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### %s -fescaping-block-tail-calls -fno-escaping-block-tail-calls 2> %t
+// RUN: FileCheck --check-prefix=CHECK-DISABLE < %t %s
+// CHECK-DISABLE: "-fno-escaping-block-tail-calls"
+
+// RUN: %clang -### %s -fno-escaping-block-tail-calls -fescaping-block-tail-calls 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NO-DISABLE < %t %s
+// CHECK-NO-DISABLE-NOT: "-fno-escaping-block-tail-calls"
Index: test/CodeGenObjC/disable-tail-call-escaping-block.m
===
--- /dev/null
+++ test/CodeGenObjC/disable-tail-call-escaping-block.m
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -fno-escaping-block-tail-calls -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @test(
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE0:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE1:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE2:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE3:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE4:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE5:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE6:.*]] to i8*)
+
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE0]]({{.*}}) #[[DISABLEATTR:.*]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE1]]({{.*}}) #[[ENABLEATTR:.*]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE2]]({{.*}}) #[[DISABLEATTR]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE3]]({{.*}}) #[[DISABLEATTR]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE4]]({{.*}}) #[[ENABLEATTR]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE5]]({{.*}}) #[[DISABLEATTR]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE6]]({{.*}}) #[[ENABLEATTR]] {
+
+// CHECK: attributes #[[ENABLEATTR]] = {{{.*}}"disable-tail-calls"="false"{{.*}}}
+// CHECK: attributes #[[DISABLEATTR]] = {{{.*}}"disable-tail-calls"="true"{{.*}}}
+
+typedef void (^BlockTy)(void);
+typedef void (*NoEscapeFnTy)(__attribute__((noescape)) BlockTy);
+
+void callee0(__attribute__((noescape)) BlockTy);
+void callee1(BlockTy);
+
+__attribute__((objc_root_class))
+@interface C0
+-(void)m0:(__attribute__((noescape)) BlockTy)p;
+-(void)m1:(BlockTy)p;
+@end
+
+@implementation C0
+-(void)m0:(__attribute__((noescape)) BlockTy)p {}
+-(void)m1:(BlockTy)p {}
+@end
+
+NoEscapeFnTy noescapefunc;
+
+void test(id a, C0 *c0) {
+  BlockTy b0 = ^{ (void)a; }; // disable tail-call optimization.
+  callee0(b0);
+  callee0(^{ (void)a; }); // enable tail-call optimization.
+  callee1(^{ (void)a; }); // disable tail-call optimization.
+
+  BlockTy b1 = ^{ (void)a; }; // disable tail-call optimization.
+  [c0 m0:b1];
+  [c0 m0:^{ (void)a; }]; // enable tail-call optimization.
+  [c0 m1:^{ (void)a; }]; // disable tail-call optimization.
+
+  noescapefunc(^{ (void)a; }); // enable tail-call optimization.
+}
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -1613,6 +1613,11 @@
 ParmVarDecl *param = Method->parameters()[i];
 assert(argExpr && "CheckMessageArgumentTypes(): missing expression");
 
+if (param->hasAttr())
+  if (auto *BE = dyn_cast(
+  argExpr->IgnoreParenNoopCasts(Context)))
+BE->getBlockDecl()->setDoesNotEscape();
+
 // Strip the unbridged-cast placeholder expression off unless it's
 // a consumed argument.
 if (argExpr->hasPlaceholderType(BuiltinType::ARCUnbridgedCast) &&
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -4841,6 +4841,10 @@
(!Param || !Param->hasAttr()))
 CFAudited = true;
 
+  if (Proto->getExtParameterInfo(i).isNoEscape())
+if (auto *BE = dyn_cast(Arg->IgnoreParenNoopCasts(Context)))
+  BE->getBlockDecl()->setDoesNotEscape();
+
   InitializedEntity Entity =
   Param ? InitializedEntity::InitializeParameter(Context, Param,
  

[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-03-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done.
ahatanak added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:4846
+if (auto *BE = dyn_cast(Arg->IgnoreParenNoopCasts(Context)))
+  BE->getBlockDecl()->setDoesNotEscape();
+

rjmccall wrote:
> Can this be based on the noescape parameter bit on the function type?
Oh that's right. It should be able to set the DoesNotEscape bit of a block when 
it's passed to an indirect function call. I added an IRGen test case that 
checks tail-call is enabled in such cases.



https://reviews.llvm.org/D43841



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


[PATCH] D43908: [RecordLayout] Only assert that fundamental type sizes are power of two on MSVC

2018-03-01 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326476: [RecordLayout] Only assert that fundamental type 
sizes are power of two on MSVC (authored by mstorsjo, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43908?vs=136471=136583#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43908

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
  cfe/trunk/test/CodeGen/ms_struct-long-double.c


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -759,6 +759,10 @@
   Warning<"ms_struct may not produce Microsoft-compatible layouts for classes "
   "with base classes or virtual functions">,
   DefaultError, InGroup;
+def warn_npot_ms_struct :
+  Warning<"ms_struct may not produce Microsoft-compatible layouts with 
fundamental "
+  "data types with sizes that aren't a power of two">,
+  DefaultError, InGroup;
 def err_section_conflict : Error<"%0 causes a section type conflict with %1">;
 def err_no_base_classes : Error<"invalid use of '__super', %0 has no base 
classes">;
 def err_invalid_super_scope : Error<"invalid use of '__super', "
Index: cfe/trunk/test/CodeGen/ms_struct-long-double.c
===
--- cfe/trunk/test/CodeGen/ms_struct-long-double.c
+++ cfe/trunk/test/CodeGen/ms_struct-long-double.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-windows-gnu 
-fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-linux -fdump-record-layouts 
-Wno-incompatible-ms-struct %s | FileCheck %s
+// RUN: not %clang_cc1 -emit-llvm-only -triple i686-linux 
-fdump-record-layouts %s 2>&1 | FileCheck %s -check-prefix=ERROR
+
+struct ldb_struct {
+  char c;
+  long double ldb;
+} __attribute__((__ms_struct__));
+
+struct ldb_struct a;
+
+// CHECK: 0 | struct ldb_struct
+// CHECK-NEXT:0 |   char c
+// CHECK-NEXT:4 |   long double ldb
+// CHECK-NEXT:  | [sizeof=16, align=4]
+
+// ERROR: error: ms_struct may not produce Microsoft-compatible layouts with 
fundamental data types with sizes that aren't a power of two
Index: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
===
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
@@ -1752,10 +1752,32 @@
   QualType T = Context.getBaseElementType(D->getType());
   if (const BuiltinType *BTy = T->getAs()) {
 CharUnits TypeSize = Context.getTypeSizeInChars(BTy);
-assert(
-(llvm::isPowerOf2_64(TypeSize.getQuantity()) ||
- Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
-"Non PowerOf2 size outside of GNU mode");
+
+if (!llvm::isPowerOf2_64(TypeSize.getQuantity())) {
+  assert(
+  !Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment() 
&&
+  "Non PowerOf2 size in MSVC mode");
+  // Base types with sizes that aren't a power of two don't work
+  // with the layout rules for MS structs. This isn't an issue in
+  // MSVC itself since there are no such base data types there.
+  // On e.g. x86_32 mingw and linux, long double is 12 bytes though.
+  // Any structs involving that data type obviously can't be ABI
+  // compatible with MSVC regardless of how it is laid out.
+
+  // Since ms_struct can be mass enabled (via a pragma or via the
+  // -mms-bitfields command line parameter), this can trigger for
+  // structs that don't actually need MSVC compatibility, so we
+  // need to be able to sidestep the ms_struct layout for these types.
+
+  // Since the combination of -mms-bitfields together with structs
+  // like max_align_t (which contains a long double) for mingw is
+  // quite comon (and GCC handles it silently), just handle it
+  // silently there. For other targets that have ms_struct enabled
+  // (most probably via a pragma or attribute), trigger a diagnostic
+  // that defaults to an error.
+  if (!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
+Diag(D->getLocation(), diag::warn_npot_ms_struct);
+}
 if (TypeSize > FieldAlign &&
 llvm::isPowerOf2_64(TypeSize.getQuantity()))
   FieldAlign = TypeSize;


Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -759,6 +759,10 @@
   

r326476 - [RecordLayout] Only assert that fundamental type sizes are power of two on MSVC

2018-03-01 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Thu Mar  1 12:22:57 2018
New Revision: 326476

URL: http://llvm.org/viewvc/llvm-project?rev=326476=rev
Log:
[RecordLayout] Only assert that fundamental type sizes are power of two on MSVC

Make types with sizes that aren't a power of two an error (that can
be disabled) in structs with ms_struct layout, except on mingw where
the situation is quite likely to occur and GCC handles it silently.

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

Added:
cfe/trunk/test/CodeGen/ms_struct-long-double.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=326476=326475=326476=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Mar  1 12:22:57 
2018
@@ -759,6 +759,10 @@ def warn_cxx_ms_struct :
   Warning<"ms_struct may not produce Microsoft-compatible layouts for classes "
   "with base classes or virtual functions">,
   DefaultError, InGroup;
+def warn_npot_ms_struct :
+  Warning<"ms_struct may not produce Microsoft-compatible layouts with 
fundamental "
+  "data types with sizes that aren't a power of two">,
+  DefaultError, InGroup;
 def err_section_conflict : Error<"%0 causes a section type conflict with %1">;
 def err_no_base_classes : Error<"invalid use of '__super', %0 has no base 
classes">;
 def err_invalid_super_scope : Error<"invalid use of '__super', "

Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=326476=326475=326476=diff
==
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Thu Mar  1 12:22:57 2018
@@ -1752,10 +1752,32 @@ void ItaniumRecordLayoutBuilder::LayoutF
   QualType T = Context.getBaseElementType(D->getType());
   if (const BuiltinType *BTy = T->getAs()) {
 CharUnits TypeSize = Context.getTypeSizeInChars(BTy);
-assert(
-(llvm::isPowerOf2_64(TypeSize.getQuantity()) ||
- Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) &&
-"Non PowerOf2 size outside of GNU mode");
+
+if (!llvm::isPowerOf2_64(TypeSize.getQuantity())) {
+  assert(
+  !Context.getTargetInfo().getTriple().isWindowsMSVCEnvironment() 
&&
+  "Non PowerOf2 size in MSVC mode");
+  // Base types with sizes that aren't a power of two don't work
+  // with the layout rules for MS structs. This isn't an issue in
+  // MSVC itself since there are no such base data types there.
+  // On e.g. x86_32 mingw and linux, long double is 12 bytes though.
+  // Any structs involving that data type obviously can't be ABI
+  // compatible with MSVC regardless of how it is laid out.
+
+  // Since ms_struct can be mass enabled (via a pragma or via the
+  // -mms-bitfields command line parameter), this can trigger for
+  // structs that don't actually need MSVC compatibility, so we
+  // need to be able to sidestep the ms_struct layout for these types.
+
+  // Since the combination of -mms-bitfields together with structs
+  // like max_align_t (which contains a long double) for mingw is
+  // quite comon (and GCC handles it silently), just handle it
+  // silently there. For other targets that have ms_struct enabled
+  // (most probably via a pragma or attribute), trigger a diagnostic
+  // that defaults to an error.
+  if (!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
+Diag(D->getLocation(), diag::warn_npot_ms_struct);
+}
 if (TypeSize > FieldAlign &&
 llvm::isPowerOf2_64(TypeSize.getQuantity()))
   FieldAlign = TypeSize;

Added: cfe/trunk/test/CodeGen/ms_struct-long-double.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms_struct-long-double.c?rev=326476=auto
==
--- cfe/trunk/test/CodeGen/ms_struct-long-double.c (added)
+++ cfe/trunk/test/CodeGen/ms_struct-long-double.c Thu Mar  1 12:22:57 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-windows-gnu 
-fdump-record-layouts %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm-only -triple i686-linux -fdump-record-layouts 
-Wno-incompatible-ms-struct %s | FileCheck %s
+// RUN: not %clang_cc1 -emit-llvm-only -triple i686-linux 
-fdump-record-layouts %s 2>&1 | FileCheck %s -check-prefix=ERROR
+
+struct ldb_struct {
+  char c;
+  long double ldb;

[PATCH] D41102: Setup clang-doc frontend framework

2018-03-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you for working on this!
Some more nitpicking.

//Please// consider adding even more tests (ideally, all this code should have 
100% test coverage)




Comment at: clang-doc/BitcodeWriter.cpp:139
+  {COMMENT_NAME, {"Name", }},
+  {COMMENT_POSITION, {"Position", }},
+  {COMMENT_DIRECTION, {"Direction", }},

This change is not covered by tests.
(I've actually found out that the hard way, by trying to find why it didn't 
trigger any asssertions, oh well)



Comment at: clang-doc/BitcodeWriter.cpp:325
+  emitHeader();
+  Stream.EnterBlockInfoBlock();
+

I think it would be cleaner to move it (at least the enterblock, it might make 
sense to leave the header at the very top) after the static variable



Comment at: clang-doc/BitcodeWriter.cpp:363
+
+  for (const auto  : TheBlocks) {
+assert(Block.second.size() < (1U << BitCodeConstants::SubblockIDSize));

I.e.
```
...
, FUNCTION_IS_METHOD}}};

  Stream.EnterBlockInfoBlock();
  for (const auto  : TheBlocks) {
assert(Block.second.size() < (1U << BitCodeConstants::SubblockIDSize));
emitBlockInfo(Block.first, Block.second);
  }
  Stream.ExitBlock();

  emitVersion();
}
```



Comment at: clang-doc/BitcodeWriter.h:19
+
+#include 
+#include 

Please sort includes, clang-tidy complains.



Comment at: clang-doc/BitcodeWriter.h:32
+// BitCodeConstants, though they can be added without breaking it.
+static const unsigned VERSION_NUMBER = 1;
+

```
/build/clang-tools-extra/clang-doc/BitcodeWriter.h:32:23: warning: invalid case 
style for variable 'VERSION_NUMBER' [readability-identifier-naming]
static const unsigned VERSION_NUMBER = 1;
  ^~
  VersionNumber

```



Comment at: clang-doc/BitcodeWriter.h:163
+ public:
+  ClangDocBitcodeWriter(llvm::BitstreamWriter ,
+bool OmitFilenames = false)

The simplest solution would be
```
#ifndef NDEBUG // Don't want explicit dtor unless needed
~ClangDocBitcodeWriter() {
  // Check that the static size is large-enough.
  assert(Record.capacity() == BitCodeConstants::RecordSize);
}
#endif
```



Comment at: clang-doc/BitcodeWriter.h:228
+  // Static size is the maximum length of the block/record names we're pushing
+  // to this + 1. Longest is currently `MemberTypeBlock` at 15 chars.
+  SmallVector Record;

So you want to be really definitive with this. I wanted to avoid that, 
actually..
Then i'm afraid one more assert is needed, to make sure this is *actually* true.

I'm not seeing any way to make `SmallVector` completely static,
so you could either add one more wrapper around it (rather ugly),
or check the final size in the `ClangDocBitcodeWriter` destructor (will not 
pinpoint when the size has 'overflowed')



Comment at: clang-doc/BitcodeWriter.h:246
+void ClangDocBitcodeWriter::writeBitstream(const T , bool WriteBlockInfo) {
+  if (WriteBlockInfo) emitBlockInfoBlock();
+  StreamSubBlockGuard Block(Stream, MapFromInfoToBlockId::ID);

Does it *ever* make sense to output `BlockInfoBlock` anywhere else other than 
once at the very beginning?
I'd think you should drop the boolean param, and unconditinally call the 
`emitBlockInfoBlock();` from `ClangDocBitcodeWriter::ClangDocBitcodeWriter()` 
ctor.



Comment at: clang-doc/BitcodeWriter.h:248
+  StreamSubBlockGuard Block(Stream, MapFromInfoToBlockId::ID);
+  emitBlock(I);
+}

The naming choices confuse me.
There is `writeBitstream()` and `emitBlock()`, which is called from 
`writeBitstream()` to write the actual contents of the block.

Why one is `write` and another is `emit`?
To match the `BitstreamWriter` naming choices? (which uses `Emit` prefix)?
To avoid the confusion of which one outputs the actual content, and which one 
outputs the whole block?

I think it should be:
*
```
- void emitBlock(const NamespaceInfo );
+ void emitBlockContent(const NamespaceInfo );
```
*
```
- void ClangDocBitcodeWriter::writeBitstream(const T , bool WriteBlockInfo);
+ void ClangDocBitcodeWriter::emitBlock(const T , bool EmitBlockInfo);
```

This way, *i think* their names would clearner-er state what they do, and won't 
be weirdly different.
What do you think?



Comment at: clang-doc/Representation.h:18
+
+#include 
+#include "clang/AST/Type.h"

Please sort includes, clang-tidy complains.



Comment at: clang-doc/Serialize.cpp:88
+  CurrentCI.Name = getCommandName(C->getCommandID());
+  for (unsigned i = 0, e = C->getNumArgs(); i < e; ++i)
+CurrentCI.Args.push_back(C->getArgText(i));

```
/build/clang-tools-extra/clang-doc/Serialize.cpp:88:17: warning: invalid 

[PATCH] D43961: OpenBSD Driver basic sanitiser support

2018-03-01 Thread David CARLIER via Phabricator via cfe-commits
devnexen created this revision.
devnexen added reviewers: krytarowski, vitalybuka, kettenis.
devnexen created this object with visibility "All Users".
Herald added a subscriber: cfe-commits.

Basic support of Sanitiser to follow-up ubsan support in compiler-rt.
Needs to use lld instead of base ld to be fully workable.


Repository:
  rC Clang

https://reviews.llvm.org/D43961

Files:
  lib/Driver/ToolChains/OpenBSD.cpp
  lib/Driver/ToolChains/OpenBSD.h


Index: lib/Driver/ToolChains/OpenBSD.h
===
--- lib/Driver/ToolChains/OpenBSD.h
+++ lib/Driver/ToolChains/OpenBSD.h
@@ -64,6 +64,8 @@
   }
   unsigned GetDefaultDwarfVersion() const override { return 2; }
 
+  SanitizerMask getSupportedSanitizers() const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: lib/Driver/ToolChains/OpenBSD.cpp
===
--- lib/Driver/ToolChains/OpenBSD.cpp
+++ lib/Driver/ToolChains/OpenBSD.cpp
@@ -13,6 +13,7 @@
 #include "CommonArgs.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
 
 using namespace clang::driver;
@@ -97,6 +98,8 @@
const InputInfoList ,
const ArgList ,
const char *LinkingOutput) const {
+  const toolchains::OpenBSD  =
+  static_cast(getToolChain());
   const Driver  = getToolChain().getDriver();
   ArgStringList CmdArgs;
 
@@ -170,11 +173,13 @@
 Triple.replace(0, 6, "amd64");
   CmdArgs.push_back(
   Args.MakeArgString("-L/usr/lib/gcc-lib/" + Triple + "/4.2.1"));
+  CmdArgs.push_back(Args.MakeArgString("-L/usr/lib"));
 
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
+  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
@@ -186,7 +191,10 @@
   else
 CmdArgs.push_back("-lm");
 }
-
+if (NeedsSanitizerDeps) {
+  CmdArgs.push_back(ToolChain.getCompilerRTArgString(Args, "builtins", 
false));
+  linkSanitizerRuntimeDeps(ToolChain, CmdArgs);
+}
 // FIXME: For some reason GCC passes -lgcc before adding
 // the default system libraries. Just mimic this for now.
 CmdArgs.push_back("-lgcc");
@@ -221,6 +229,19 @@
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
+SanitizerMask OpenBSD::getSupportedSanitizers() const {
+  const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
+
+  // For future use, only UBsan at the moment
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+
+  if (IsX86 || IsX86_64)
+Res |= SanitizerKind::Vptr;
+
+  return Res;
+}
+
 /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
 
 OpenBSD::OpenBSD(const Driver , const llvm::Triple ,


Index: lib/Driver/ToolChains/OpenBSD.h
===
--- lib/Driver/ToolChains/OpenBSD.h
+++ lib/Driver/ToolChains/OpenBSD.h
@@ -64,6 +64,8 @@
   }
   unsigned GetDefaultDwarfVersion() const override { return 2; }
 
+  SanitizerMask getSupportedSanitizers() const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: lib/Driver/ToolChains/OpenBSD.cpp
===
--- lib/Driver/ToolChains/OpenBSD.cpp
+++ lib/Driver/ToolChains/OpenBSD.cpp
@@ -13,6 +13,7 @@
 #include "CommonArgs.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
 
 using namespace clang::driver;
@@ -97,6 +98,8 @@
const InputInfoList ,
const ArgList ,
const char *LinkingOutput) const {
+  const toolchains::OpenBSD  =
+  static_cast(getToolChain());
   const Driver  = getToolChain().getDriver();
   ArgStringList CmdArgs;
 
@@ -170,11 +173,13 @@
 Triple.replace(0, 6, "amd64");
   CmdArgs.push_back(
   Args.MakeArgString("-L/usr/lib/gcc-lib/" + Triple + "/4.2.1"));
+  CmdArgs.push_back(Args.MakeArgString("-L/usr/lib"));
 
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});
 
+  bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
   

[PATCH] D43773: Implement the container bits of P0805R1

2018-03-01 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 136582.
mclow.lists added a comment.

Add the `tuple` bits. Regularize the equality comparisons of the containers; 
i.e, don't try to be clever - let the compiler be clever.


https://reviews.llvm.org/D43773

Files:
  include/array
  include/deque
  include/forward_list
  include/list
  include/tuple
  include/vector
  test/std/containers/sequences/array/compare.fail.cpp
  test/std/containers/sequences/array/compare.pass.cpp
  test/std/containers/sequences/deque/compare.fail.cpp
  test/std/containers/sequences/deque/compare.pass.cpp
  test/std/containers/sequences/forwardlist/compare.fail.cpp
  test/std/containers/sequences/forwardlist/compare.pass.cpp
  test/std/containers/sequences/list/compare.fail.cpp
  test/std/containers/sequences/list/compare.pass.cpp
  test/std/containers/sequences/vector/compare.fail.cpp
  test/std/containers/sequences/vector/compare.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp

Index: test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
@@ -35,6 +35,16 @@
 
 #include "test_macros.h"
 
+
+template 
+void compare (const T1 , const T2 )
+{
+assert((t1  < t2) == ( isLess));
+assert((t1  > t2) == (!isLess && !isEqual));
+assert((t1 <= t2) == ( isLess ||  isEqual));
+assert((t1 >= t2) == (!isLess ||  isEqual));
+}
+
 int main()
 {
 {
@@ -208,5 +218,57 @@
 static_assert(!(t1 >  t2), "");
 static_assert(!(t1 >= t2), "");
 }
+{ // P0805
+typedef std::tuple<> T0;
+typedef std::tuple T1;
+typedef std::tuple T2;
+constexpr T0 t0;
+constexpr T1 t1(1, 2, 3);
+constexpr T2 t2(1, 2);
+constexpr T1 t3(0, 1, 2); // common tail
+
+// less, equal
+compare(t0, t0);
+static_assert(!(t0  < t0), "");
+static_assert(!(t0  > t0), "");
+static_assert( (t0 <= t0), "");
+static_assert( (t0 >= t0), "");
+
+compare(t0, t1);
+static_assert( (t0  < t1), "");
+static_assert(!(t0  > t1), "");
+static_assert( (t0 <= t1), "");
+static_assert(!(t0 >= t1), "");
+
+compare(t1, t0);
+static_assert(!(t1  < t0), "");
+static_assert( (t1  > t0), "");
+static_assert(!(t1 <= t0), "");
+static_assert( (t1 >= t0), "");
+
+compare(t1, t2);
+static_assert(!(t1  < t2), "");
+static_assert( (t1  > t2), "");
+static_assert(!(t1 <= t2), "");
+static_assert( (t1 >= t2), "");
+
+compare(t2, t1);
+static_assert( (t2  < t1), "");
+static_assert(!(t2  > t1), "");
+static_assert( (t2 <= t1), "");
+static_assert(!(t2 >= t1), "");
+
+compare(t2, t3);
+static_assert(!(t2  < t3), "");
+static_assert( (t2  > t3), "");
+static_assert(!(t2 <= t3), "");
+static_assert( (t2 >= t3), "");
+
+compare(t3, t2);
+static_assert( (t3  < t2), "");
+static_assert(!(t3  > t2), "");
+static_assert( (t3 <= t2), "");
+static_assert(!(t3 >= t2), "");
+}
 #endif
 }
Index: test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
@@ -154,5 +154,20 @@
 static_assert(!(t1 == t2), "");
 static_assert(t1 != t2, "");
 }
+{ // P0805
+typedef std::tuple T1;
+typedef std::tuple T2;
+constexpr T1 t1(1, 2, 3);
+constexpr T2 t2(1.1, 3);
+constexpr T2 t3(1, 2);
+static_assert(!(t1 == t2), "");
+static_assert(!(t2 == t1), "");
+static_assert(!(t1 == t3), "");
+static_assert(!(t3 == t1), "");
+static_assert(  t1 != t2,  "");
+static_assert(  t2 != t1,  "");
+static_assert(  t1 != t3,  "");
+static_assert(  t3 != t1,  "");
+}
 #endif
 }
Index: test/std/containers/sequences/vector/compare.pass.cpp
===
--- test/std/containers/sequences/vector/compare.pass.cpp
+++ test/std/containers/sequences/vector/compare.pass.cpp
@@ -0,0 +1,90 @@
+//===--===//
+//
+// 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.
+//

[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-03-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:4846
+if (auto *BE = dyn_cast(Arg->IgnoreParenNoopCasts(Context)))
+  BE->getBlockDecl()->setDoesNotEscape();
+

Can this be based on the noescape parameter bit on the function type?


https://reviews.llvm.org/D43841



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


[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-03-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 136580.
ahatanak marked 3 inline comments as done.
ahatanak added a comment.

Address review comments.


https://reviews.llvm.org/D43841

Files:
  include/clang/AST/Decl.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprObjC.cpp
  test/CodeGenObjC/disable-tail-call-escaping-block.m
  test/Driver/fno-escaping-block-tail-calls.c

Index: test/Driver/fno-escaping-block-tail-calls.c
===
--- /dev/null
+++ test/Driver/fno-escaping-block-tail-calls.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### %s -fescaping-block-tail-calls -fno-escaping-block-tail-calls 2> %t
+// RUN: FileCheck --check-prefix=CHECK-DISABLE < %t %s
+// CHECK-DISABLE: "-fno-escaping-block-tail-calls"
+
+// RUN: %clang -### %s -fno-escaping-block-tail-calls -fescaping-block-tail-calls 2> %t
+// RUN: FileCheck --check-prefix=CHECK-NO-DISABLE < %t %s
+// CHECK-NO-DISABLE-NOT: "-fno-escaping-block-tail-calls"
Index: test/CodeGenObjC/disable-tail-call-escaping-block.m
===
--- /dev/null
+++ test/CodeGenObjC/disable-tail-call-escaping-block.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fblocks -fno-escaping-block-tail-calls -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @test(
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE0:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE1:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE2:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE3:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE4:.*]] to i8*)
+// CHECK: store i8* bitcast (void (i8*)* @[[TEST_BLOCK_INVOKE5:.*]] to i8*)
+
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE0]]({{.*}}) #[[DISABLEATTR:.*]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE1]]({{.*}}) #[[ENABLEATTR:.*]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE2]]({{.*}}) #[[DISABLEATTR]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE3]]({{.*}}) #[[DISABLEATTR]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE4]]({{.*}}) #[[ENABLEATTR]] {
+// CHECK: define internal void @[[TEST_BLOCK_INVOKE5]]({{.*}}) #[[DISABLEATTR]] {
+
+// CHECK: attributes #[[ENABLEATTR]] = {{{.*}}"disable-tail-calls"="false"{{.*}}}
+// CHECK: attributes #[[DISABLEATTR]] = {{{.*}}"disable-tail-calls"="true"{{.*}}}
+
+typedef void (^BlockTy)(void);
+
+void callee0(__attribute__((noescape)) BlockTy);
+void callee1(BlockTy);
+
+__attribute__((objc_root_class))
+@interface C0
+-(void)m0:(__attribute__((noescape)) BlockTy)p;
+-(void)m1:(BlockTy)p;
+@end
+
+@implementation C0
+-(void)m0:(__attribute__((noescape)) BlockTy)p {}
+-(void)m1:(BlockTy)p {}
+@end
+
+void test(id a, C0 *c0) {
+  BlockTy b0 = ^{ (void)a; }; // disable tail-call optimization.
+  callee0(b0);
+  callee0(^{ (void)a; }); // enable tail-call optimization.
+  callee1(^{ (void)a; }); // disable tail-call optimization.
+
+  BlockTy b1 = ^{ (void)a; }; // disable tail-call optimization.
+  [c0 m0:b1];
+  [c0 m0:^{ (void)a; }]; // enable tail-call optimization.
+  [c0 m1:^{ (void)a; }]; // disable tail-call optimization.
+}
Index: lib/Sema/SemaExprObjC.cpp
===
--- lib/Sema/SemaExprObjC.cpp
+++ lib/Sema/SemaExprObjC.cpp
@@ -1613,6 +1613,11 @@
 ParmVarDecl *param = Method->parameters()[i];
 assert(argExpr && "CheckMessageArgumentTypes(): missing expression");
 
+if (param->hasAttr())
+  if (auto *BE = dyn_cast(
+  argExpr->IgnoreParenNoopCasts(Context)))
+BE->getBlockDecl()->setDoesNotEscape();
+
 // Strip the unbridged-cast placeholder expression off unless it's
 // a consumed argument.
 if (argExpr->hasPlaceholderType(BuiltinType::ARCUnbridgedCast) &&
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -4841,6 +4841,10 @@
(!Param || !Param->hasAttr()))
 CFAudited = true;
 
+  if (Param && Param->hasAttr())
+if (auto *BE = dyn_cast(Arg->IgnoreParenNoopCasts(Context)))
+  BE->getBlockDecl()->setDoesNotEscape();
+
   InitializedEntity Entity =
   Param ? InitializedEntity::InitializeParameter(Context, Param,
  ProtoArgType)
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -640,6 +640,8 @@
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
   Opts.DiscardValueNames = 

[PATCH] D43841: Add an option to disable tail-call optimization for escaping blocks

2018-03-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/Driver/Options.td:1419
+def fno_disable_tail_calls_escaping_blocks : Flag<["-"], 
"fno-disable-tail-calls-escaping-blocks">, Group, Flags<[CC1Option]>;
+def fdisable_tail_calls_escaping_blocks : Flag<["-"], 
"fdisable-tail-calls-escaping-blocks">, Group, Flags<[CC1Option]>;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;

rjmccall wrote:
> rjmccall wrote:
> > These are pretty unidiomatic option names.  I would suggest one of these:
> >   - [fixed]-fescaping-block-tail-calls[/fixed] (the default) and 
> > [fixed]-fno-escaping-block-tail-calls[/fixed]
> >   - [fixed]-enable-escaping-block-tail-calls[/fixed] (the default) and 
> > [fixed]-disable-escaping-block-tail-calls[/fixed]
> Wow, this is not even close to Phabricator markup, I don't know what I was 
> thinking.
I chose the first option 
"-fno-escaping-block-tail-calls/-fescaping-block-tail-calls".


https://reviews.llvm.org/D43841



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


[PATCH] D42938: [Sema] Emit -Winteger-overflow for arguments in function calls, ObjC messages.

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

Ping. It would be helpful to know how reasonable is the idea to handle more 
expression types in `Sema::CheckForIntOverflow`.


https://reviews.llvm.org/D42938



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


[PATCH] D43908: [RecordLayout] Only assert that fundamental type sizes are power of two on MSVC

2018-03-01 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.

Awesome, thanks, this makes me feel much more comfortable.


https://reviews.llvm.org/D43908



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


r326469 - Driver: hoist `-fno-rtti-data` to a driver flag

2018-03-01 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu Mar  1 11:13:43 2018
New Revision: 326469

URL: http://llvm.org/viewvc/llvm-project?rev=326469=rev
Log:
Driver: hoist `-fno-rtti-data` to a driver flag

This is needed for building with the GNU driver (`clang++`) when
targeting Windows and using msvcprt.  This flag is the equivalent of
`/GR-`.

Added:
cfe/trunk/test/Driver/fno-rtti-data.cpp
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=326469=326468=326469=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Mar  1 11:13:43 2018
@@ -707,8 +707,6 @@ def fobjc_subscripting_legacy_runtime :
   HelpText<"Allow Objective-C array and dictionary subscripting in legacy 
runtime">;
 def vtordisp_mode_EQ : Joined<["-"], "vtordisp-mode=">,
   HelpText<"Control vtordisp placement on win32 targets">;
-def fno_rtti_data : Flag<["-"], "fno-rtti-data">,
-  HelpText<"Control emission of RTTI data">;
 def fnative_half_type: Flag<["-"], "fnative-half-type">,
   HelpText<"Use the native half type for __fp16 instead of promoting to 
float">;
 def fnative_half_arguments_and_returns : Flag<["-"], 
"fnative-half-arguments-and-returns">,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=326469=326468=326469=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Mar  1 11:13:43 2018
@@ -1315,6 +1315,8 @@ def fno_operator_names : Flag<["-"], "fn
 def fno_pascal_strings : Flag<["-"], "fno-pascal-strings">, Group;
 def fno_rtti : Flag<["-"], "fno-rtti">, Group, Flags<[CC1Option]>,
   HelpText<"Disable generation of rtti information">;
+def fno_rtti_data : Flag<["-"], "fno-rtti-data">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Control emission of RTTI data">;
 def fno_short_enums : Flag<["-"], "fno-short-enums">, Group;
 def fno_show_column : Flag<["-"], "fno-show-column">, Group, 
Flags<[CC1Option]>,
   HelpText<"Do not include column number on diagnostics">;

Added: cfe/trunk/test/Driver/fno-rtti-data.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fno-rtti-data.cpp?rev=326469=auto
==
--- cfe/trunk/test/Driver/fno-rtti-data.cpp (added)
+++ cfe/trunk/test/Driver/fno-rtti-data.cpp Thu Mar  1 11:13:43 2018
@@ -0,0 +1,2 @@
+// RUN: %clang -### -fno-rtti-data %s 2>&1 | FileCheck %s
+// CHECK: -fno-rtti-data


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


[PATCH] D43681: [WebAssembly] Add exception handling option

2018-03-01 Thread Derek Schuff via Phabricator via cfe-commits
dschuff accepted this revision.
dschuff added a comment.
This revision is now accepted and ready to land.

This flag turns on CPU features (i.e. there's one for each new wasm feature 
proposal that has to be feature-detected), so I think this makes sense to be 
consistent with all the others. I could imagine enabling exceptions in the 
frontend but having some kind of emulation in the backend (like we do today for 
emscripten). More generally the semantics `-fno-exceptions` unfortunately 
doesn't exactly match the kind of behavior people typically want because it 
doesn't allow you to compile code that has try/catch/throw at all. In PNaCl and 
emscripten the default behavior is instead to compile that code but to lower it 
away and turn throw into abort. Also IIRC even with `-fno-exceptions` the code 
still has to allow exceptions to propagate which means you end up with invokes 
everywhere instead of calls, so you are still paying most of the costs of 
enabling EH. So that bit is a little bit complex and we'll probably want to 
think a bit more carefully about what options we want to have. But a machine 
flag for enabling the CPU feature makes sense to start.


Repository:
  rC Clang

https://reviews.llvm.org/D43681



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


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

2018-03-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D43248#1023720, @jdenny wrote:

> Hi Aaron.  It occurs to me now that this patch has grown rather large and, in 
> some places, a little subtle.  Would it help the review if I were to break it 
> up into a patch series that introduces ParamIdx to each attribute, one at a 
> time?  I'm not trying to rush you, but I hate for the review to be painful 
> for you if it doesn't have to be.


No need to do that -- this review just takes a bit more time for me to 
complete, but it's reasonably well-factored. Thank you, though!


https://reviews.llvm.org/D43248



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


[PATCH] D43248: [Attr] Fix parameter indexing for attributes

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



Comment at: include/clang/AST/Attr.h:206
+
+  void cmpable(const ParamIdx ) const {
+assert(isValid() && I.isValid() &&

The name here can be improved. How about `checkInvariants()`? Might as well 
make this inline while you're at it.



Comment at: include/clang/AST/Attr.h:236
+  /// parameter.
+  ParamIdx(unsigned Idx, bool HasThis)
+  : Idx(Idx), HasThis(HasThis), IsValid(true) {}

Is this constructor used anywhere? I didn't see it being used, but I could have 
missed something. If it's not used, go ahead and remove it.



Comment at: include/clang/AST/Attr.h:267
+assert(isValid() && "ParamIdx must be valid");
+return Idx - 1 - HasThis;
+  }

Please assert that `Idx` won't wrap before doing the return.



Comment at: include/clang/AST/Attr.h:276
+assert(isValid() && "ParamIdx must be valid");
+return Idx - 1;
+  }

Likewise here.



Comment at: include/clang/AST/Attr.h:281-284
+  bool operator<(const ParamIdx ) const { cmpable(I); return Idx < I.Idx; }
+  bool operator>(const ParamIdx ) const { cmpable(I); return Idx > I.Idx; }
+  bool operator<=(const ParamIdx ) const { cmpable(I); return Idx <= I.Idx; }
+  bool operator>=(const ParamIdx ) const { cmpable(I); return Idx >= I.Idx; }

Are all of these operations required for the class?



Comment at: include/clang/Basic/Attr.td:172-174
+  // Whether the C++ implicit this parameter is allowed.  Users that construct
+  // attributes from the source code use this information when validating
+  // parameter indices.

I still find the `AllowThis` parts to be hard to follow, so I want to be sure I 
understand your design properly. Everything that uses this new argument type 
sets `AllowsThis` to 0. As written, it sounds like setting that to 0 means that 
the parameter index cannot be used on a C++ instance method, and I know that's 
not the correct interpretation. Under what circumstances would this be set to 1 
instead?

Looking at the existing code, the only circumstances under which 
`checkFunctionOrMethodParameterIndex()` was being passed `true` for "allow 
this" was for XRayLogArgs, which doesn't even use `ParamIdx`. Perhaps this 
member isn't necessary any longer?



Comment at: lib/Sema/SemaChecking.cpp:2622
 
-  for (unsigned Val : NonNull->args()) {
-if (Val >= Args.size())
+  for (ParamIdx Idx : NonNull->args()) {
+if (Idx.getASTIndex() >= Args.size())

`const ParamIdx &`



Comment at: lib/Sema/SemaChecking.cpp:10083
 
-  for (unsigned ArgNo : NonNull->args()) {
-if (ArgNo == ParamNo) {
+  for (ParamIdx ArgNo : NonNull->args()) {
+if (ArgNo.getASTIndex() == ParamNo) {

`const ParamIdx &`



Comment at: lib/Sema/SemaChecking.cpp:12244
   }
-  const Expr *TypeTagExpr = ExprArgs[Attr->getTypeTagIdx()];
+  const Expr *TypeTagExpr = ExprArgs[Attr->typeTagIdx().getASTIndex()];
   bool FoundWrongKind;

Hoist the AST index so you don't have to call for it twice. (Same applies 
elsewhere.)



Comment at: lib/Sema/SemaDeclAttr.cpp:785-786
-  const ParmVarDecl *Param = FD->getParamDecl(Idx);
-  if (AllowDependentType && Param->getType()->isDependentType())
-return true;
   if (!Param->getType()->isIntegerType() && !Param->getType()->isCharType()) {

Good catch about this not being needed any longer!



Comment at: lib/Sema/SemaDeclAttr.cpp:1650-1651
   OwnershipAttr(AL.getLoc(), S.Context, nullptr, nullptr, 0,
-AL.getAttributeSpellingListIndex()).getOwnKind();
+AL.getAttributeSpellingListIndex())
+  .getOwnKind();
 

This change looks to be unrelated to the patch?



Comment at: lib/Sema/SemaDeclAttr.cpp:4549-4551
+if (ArgumentIdx.getASTIndex() >= getFunctionOrMethodNumParams(D) ||
+!getFunctionOrMethodParamType(D, ArgumentIdx.getASTIndex())
+ ->isPointerType())

Is this formatting produced by clang-format?



Comment at: lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp:61
 }
-for (unsigned Val : NonNull->args()) {
-  if (Val >= NumArgs)
+for (ParamIdx Idx : NonNull->args()) {
+  if (Idx.getASTIndex() >= NumArgs)

`const ParamIdx &`


https://reviews.llvm.org/D43248



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


[PATCH] D43804: [analyzer] Enable cfg-temporary-dtors by default?

2018-03-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326461: [analyzer] Enable cfg-temporary-dtors by default. 
(authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43804?vs=136428=136578#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43804

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/test/Analysis/analyzer-config.c
  cfe/trunk/test/Analysis/analyzer-config.cpp
  cfe/trunk/test/Analysis/inlining/temp-dtors-path-notes.cpp
  cfe/trunk/test/Analysis/lifetime-cfg-output.cpp
  cfe/trunk/test/Analysis/lifetime-extension.cpp
  cfe/trunk/test/Analysis/temporaries.cpp

Index: cfe/trunk/test/Analysis/lifetime-cfg-output.cpp
===
--- cfe/trunk/test/Analysis/lifetime-cfg-output.cpp
+++ cfe/trunk/test/Analysis/lifetime-cfg-output.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true,cfg-rich-constructors=false -analyzer-config cfg-implicit-dtors=false %s > %t 2>&1
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-lifetime=true,cfg-temporary-dtors=false,cfg-rich-constructors=false -analyzer-config cfg-implicit-dtors=false %s > %t 2>&1
 // RUN: FileCheck --input-file=%t %s
 
 extern bool UV;
Index: cfe/trunk/test/Analysis/analyzer-config.cpp
===
--- cfe/trunk/test/Analysis/analyzer-config.cpp
+++ cfe/trunk/test/Analysis/analyzer-config.cpp
@@ -13,7 +13,7 @@
 class Foo {
 public:
   ~Foo() {}
-  void baz();
+  void baz() { Foo(); }
 	void bar() { const Foo  = Foo(); }
 	void foo() { bar(); }
 };
@@ -23,13 +23,14 @@
 // CHECK-NEXT: c++-inlining = destructors
 // CHECK-NEXT: c++-shared_ptr-inlining = false
 // CHECK-NEXT: c++-stdlib-inlining = true
+// CHECK-NEXT: c++-temp-dtor-inlining = false
 // CHECK-NEXT: c++-template-inlining = true
 // CHECK-NEXT: cfg-conditional-static-initializers = true
 // 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: cfg-temporary-dtors = true
 // CHECK-NEXT: experimental-enable-naive-ctu-analysis = false
 // CHECK-NEXT: exploration_strategy = unexplored_first_queue
 // CHECK-NEXT: faux-bodies = true
@@ -48,4 +49,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 28
+// CHECK-NEXT: num-entries = 29
Index: cfe/trunk/test/Analysis/inlining/temp-dtors-path-notes.cpp
===
--- cfe/trunk/test/Analysis/inlining/temp-dtors-path-notes.cpp
+++ cfe/trunk/test/Analysis/inlining/temp-dtors-path-notes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyze -analyzer-checker core -analyzer-config cfg-temporary-dtors=true -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker core -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=true -analyzer-output=text -verify %s
 
 namespace test_simple_temporary {
 class C {
Index: cfe/trunk/test/Analysis/lifetime-extension.cpp
===
--- cfe/trunk/test/Analysis/lifetime-extension.cpp
+++ cfe/trunk/test/Analysis/lifetime-extension.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -verify %s
-// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true -DTEMPORARIES -verify %s
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=false -verify %s
+// RUN: %clang_analyze_cc1 -Wno-unused -std=c++11 -analyzer-checker=core,debug.ExprInspection -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=true -DTEMPORARIES -verify %s
 
 void clang_analyzer_eval(bool);
 
Index: cfe/trunk/test/Analysis/analyzer-config.c
===
--- cfe/trunk/test/Analysis/analyzer-config.c
+++ cfe/trunk/test/Analysis/analyzer-config.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT: cfg-lifetime = false
 // CHECK-NEXT: cfg-loopexit = false
 // CHECK-NEXT: cfg-rich-constructors = true
-// CHECK-NEXT: cfg-temporary-dtors = false
+// CHECK-NEXT: cfg-temporary-dtors = true
 // CHECK-NEXT: exploration_strategy = unexplored_first_queue
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: graph-trim-interval = 1000
Index: cfe/trunk/test/Analysis/temporaries.cpp
===
--- cfe/trunk/test/Analysis/temporaries.cpp
+++ 

r326461 - [analyzer] Enable cfg-temporary-dtors by default.

2018-03-01 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Mar  1 10:53:13 2018
New Revision: 326461

URL: http://llvm.org/viewvc/llvm-project?rev=326461=rev
Log:
[analyzer] Enable cfg-temporary-dtors by default.

Don't enable c++-temp-dtor-inlining by default yet, due to this reference
counting pointe problem.

Otherwise the new mode seems stable and allows us to incrementally fix C++
problems in much less hacky ways.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp
cfe/trunk/test/Analysis/inlining/temp-dtors-path-notes.cpp
cfe/trunk/test/Analysis/lifetime-cfg-output.cpp
cfe/trunk/test/Analysis/lifetime-extension.cpp
cfe/trunk/test/Analysis/temporaries.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp?rev=326461=326460=326461=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp Thu Mar  1 10:53:13 
2018
@@ -193,7 +193,7 @@ bool AnalyzerOptions::getBooleanOption(O
 bool AnalyzerOptions::includeTemporaryDtorsInCFG() {
   return getBooleanOption(IncludeTemporaryDtorsInCFG,
   "cfg-temporary-dtors",
-  /* Default = */ false);
+  /* Default = */ true);
 }
 
 bool AnalyzerOptions::includeImplicitDtorsInCFG() {
@@ -251,7 +251,7 @@ bool AnalyzerOptions::mayInlineCXXShared
 bool AnalyzerOptions::mayInlineCXXTemporaryDtors() {
   return getBooleanOption(InlineCXXTemporaryDtors,
   "c++-temp-dtor-inlining",
-  /*Default=*/true);
+  /*Default=*/false);
 }
 
 bool AnalyzerOptions::mayInlineObjCMethod() {

Modified: cfe/trunk/test/Analysis/analyzer-config.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-config.c?rev=326461=326460=326461=diff
==
--- cfe/trunk/test/Analysis/analyzer-config.c (original)
+++ cfe/trunk/test/Analysis/analyzer-config.c Thu Mar  1 10:53:13 2018
@@ -16,7 +16,7 @@ void foo() {
 // CHECK-NEXT: cfg-lifetime = false
 // CHECK-NEXT: cfg-loopexit = false
 // CHECK-NEXT: cfg-rich-constructors = true
-// CHECK-NEXT: cfg-temporary-dtors = false
+// CHECK-NEXT: cfg-temporary-dtors = true
 // CHECK-NEXT: exploration_strategy = unexplored_first_queue
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: graph-trim-interval = 1000

Modified: cfe/trunk/test/Analysis/analyzer-config.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-config.cpp?rev=326461=326460=326461=diff
==
--- cfe/trunk/test/Analysis/analyzer-config.cpp (original)
+++ cfe/trunk/test/Analysis/analyzer-config.cpp Thu Mar  1 10:53:13 2018
@@ -13,7 +13,7 @@ void foo() {
 class Foo {
 public:
   ~Foo() {}
-  void baz();
+  void baz() { Foo(); }
void bar() { const Foo  = Foo(); }
void foo() { bar(); }
 };
@@ -23,13 +23,14 @@ public:
 // CHECK-NEXT: c++-inlining = destructors
 // CHECK-NEXT: c++-shared_ptr-inlining = false
 // CHECK-NEXT: c++-stdlib-inlining = true
+// CHECK-NEXT: c++-temp-dtor-inlining = false
 // CHECK-NEXT: c++-template-inlining = true
 // CHECK-NEXT: cfg-conditional-static-initializers = true
 // 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: cfg-temporary-dtors = true
 // CHECK-NEXT: experimental-enable-naive-ctu-analysis = false
 // CHECK-NEXT: exploration_strategy = unexplored_first_queue
 // CHECK-NEXT: faux-bodies = true
@@ -48,4 +49,4 @@ public:
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 28
+// CHECK-NEXT: num-entries = 29

Modified: cfe/trunk/test/Analysis/inlining/temp-dtors-path-notes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/temp-dtors-path-notes.cpp?rev=326461=326460=326461=diff
==
--- cfe/trunk/test/Analysis/inlining/temp-dtors-path-notes.cpp (original)
+++ cfe/trunk/test/Analysis/inlining/temp-dtors-path-notes.cpp Thu Mar  1 
10:53:13 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyze -analyzer-checker core -analyzer-config 
cfg-temporary-dtors=true -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker core -analyzer-config 
cfg-temporary-dtors=true,c++-temp-dtor-inlining=true -analyzer-output=text 
-verify %s
 
 namespace 

[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-03-01 Thread Frederic Tingaud via Phabricator via cfe-commits
ftingaud added inline comments.



Comment at: test/clang-tidy/modernize-make-unique-cxx14.cpp:10
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
+  // CHECK-FIXES: auto my_ptr = std::make_unique(1);
+  return 0;

Quuxplusone wrote:
> IIUC above, you allow the user to pass in the name of a custom 
> `my::make_unique` function. Could you add a test case for that?
It is tested by modernize-make-unique-header.cpp and the patch doesn't change 
the feature.


https://reviews.llvm.org/D43766



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


[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-03-01 Thread Frederic Tingaud via Phabricator via cfe-commits
ftingaud updated this revision to Diff 136575.
ftingaud added a comment.

Remove customizable c++ version that added no real value.


https://reviews.llvm.org/D43766

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tidy/modernize/MakeUniqueCheck.cpp
  clang-tidy/modernize/MakeUniqueCheck.h
  test/clang-tidy/modernize-make-unique-cxx11.cpp
  test/clang-tidy/modernize-make-unique-cxx14.cpp
  test/clang-tidy/modernize-make-unique-macros.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++11 \
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++14 \
 // RUN:   -I%S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
Index: test/clang-tidy/modernize-make-unique-macros.cpp
===
--- test/clang-tidy/modernize-make-unique-macros.cpp
+++ test/clang-tidy/modernize-make-unique-macros.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-make-unique %t -- \
 // RUN:   -config="{CheckOptions: [{key: modernize-make-unique.IgnoreMacros, value: 0}]}" \
-// RUN:   -- -std=c++11  -I%S/Inputs/modernize-smart-ptr
+// RUN:   -- -std=c++14  -I%S/Inputs/modernize-smart-ptr
 
 #include "unique_ptr.h"
 
Index: test/clang-tidy/modernize-make-unique-cxx14.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-cxx14.cpp
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++14 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include 
+
+int main() {
+  auto my_ptr = std::unique_ptr(new int(1));
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
+  // CHECK-FIXES: auto my_ptr = std::make_unique(1);
+  return 0;
+}
Index: test/clang-tidy/modernize-make-unique-cxx11.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-make-unique-cxx11.cpp
@@ -0,0 +1,11 @@
+// RUN: %check_clang_tidy %s modernize-make-unique %t -- -- -std=c++11 \
+// RUN:   -I%S/Inputs/modernize-smart-ptr
+
+#include "unique_ptr.h"
+// CHECK-FIXES: #include "unique_ptr.h"
+
+int main() {
+  auto my_ptr = std::unique_ptr(new int(1));
+  // CHECK-FIXES: auto my_ptr = std::unique_ptr(new int(1));
+  return 0;
+}
Index: clang-tidy/modernize/MakeUniqueCheck.h
===
--- clang-tidy/modernize/MakeUniqueCheck.h
+++ clang-tidy/modernize/MakeUniqueCheck.h
@@ -31,6 +31,11 @@
 
 protected:
   SmartPtrTypeMatcher getSmartPointerTypeMatcher() const override;
+
+  bool isLanguageVersionSupported(const LangOptions ) const override;
+
+private:
+  const bool RequireCPlusPlus14;
 };
 
 } // namespace modernize
Index: clang-tidy/modernize/MakeUniqueCheck.cpp
===
--- clang-tidy/modernize/MakeUniqueCheck.cpp
+++ clang-tidy/modernize/MakeUniqueCheck.cpp
@@ -17,7 +17,8 @@
 
 MakeUniqueCheck::MakeUniqueCheck(StringRef Name,
  clang::tidy::ClangTidyContext *Context)
-: MakeSmartPtrCheck(Name, Context, "std::make_unique") {}
+: MakeSmartPtrCheck(Name, Context, "std::make_unique"),
+  RequireCPlusPlus14(Options.get("MakeSmartPtrFunction", "").empty()) {}
 
 MakeUniqueCheck::SmartPtrTypeMatcher
 MakeUniqueCheck::getSmartPointerTypeMatcher() const {
@@ -36,6 +37,13 @@
 equalsBoundNode(PointerType;
 }
 
+bool MakeUniqueCheck::isLanguageVersionSupported(
+const LangOptions ) const {
+  if (RequireCPlusPlus14)
+return LangOpts.CPlusPlus14;
+  return LangOpts.CPlusPlus11;
+}
+
 } // namespace modernize
 } // namespace tidy
 } // namespace clang
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -40,6 +40,9 @@
   /// in this class.
   virtual SmartPtrTypeMatcher getSmartPointerTypeMatcher() const = 0;
 
+  /// Returns whether the C++ version is compatible with current check.
+  virtual bool isLanguageVersionSupported(const LangOptions ) const;
+
   static const char PointerType[];
   static const char ConstructorCall[];
   static const char ResetCall[];
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -61,16 +61,21 @@
   Options.store(Opts, "IgnoreMacros", IgnoreMacros);
 }
 
+bool 

[PATCH] D40737: [clang-tidy] Resubmit hicpp-multiway-paths-covered without breaking test

2018-03-01 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

After long inactivity (sorry!) i had a chance to look at it again:

  switch(i) {
  case 0:;
  case 1:;
  case 2:;
  ...
  }

does *NOT* lead to the stack overflow. This is most likely an issue in the AST:
https://godbolt.org/g/vZw2BD

Empty case labels do nest, an empty statement prevents this. The nesting leads 
most likely to the deep recursion. I will file a bug for it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40737



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


[clang-tools-extra] r326458 - [clangd] Make symbol name a required parameter for CanonicalIncludes::mapHeader

2018-03-01 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Mar  1 10:30:48 2018
New Revision: 326458

URL: http://llvm.org/viewvc/llvm-project?rev=326458=rev
Log:
[clangd] Make symbol name a required parameter for CanonicalIncludes::mapHeader

Modified:
clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=326458=326457=326458=diff
==
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp Thu Mar  1 
10:30:48 2018
@@ -35,11 +35,9 @@ void CanonicalIncludes::addSymbolMapping
 llvm::StringRef
 CanonicalIncludes::mapHeader(llvm::StringRef Header,
  llvm::StringRef QualifiedName) const {
-  if (!QualifiedName.empty()) {
-auto SE = SymbolMapping.find(QualifiedName);
-if (SE != SymbolMapping.end())
-  return SE->second;
-  }
+  auto SE = SymbolMapping.find(QualifiedName);
+  if (SE != SymbolMapping.end())
+return SE->second;
   std::lock_guard Lock(RegexMutex);
   for (auto  : RegexHeaderMappingTable) {
 #ifndef NDEBUG

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h?rev=326458=326457=326458=diff
==
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h Thu Mar  1 
10:30:48 2018
@@ -48,12 +48,10 @@ public:
   void addSymbolMapping(llvm::StringRef QualifiedName,
 llvm::StringRef CanonicalPath);
 
-  /// \return \p Header itself if there is no mapping for it; otherwise, return
-  /// a canonical header name.
-  /// \p QualifiedName of a symbol declared in \p Header can be provided to
-  /// check against the symbol mapping.
+  /// Returns the canonical include for symbol with \p QualifiedName, which is
+  /// declared in \p Header
   llvm::StringRef mapHeader(llvm::StringRef Header,
-llvm::StringRef QualifiedName = "") const;
+llvm::StringRef QualifiedName) const;
 
 private:
   // A map from header patterns to header names. This needs to be mutable so


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


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-03-01 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose added a comment.

It's been a long time since that commit, but I think the difference is that 
`-pedantic` / `Extension`-type diagnostics are magic and 
`-Wc++98-compat-pedantic` is not. I like Richard's way better and if it could 
be applied to -Wnewline-eof later as well then that sounds great.


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[PATCH] D43625: [OpenMP] Remove implicit data sharing code gen that aims to use device shared memory

2018-03-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rC Clang

https://reviews.llvm.org/D43625



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


[PATCH] D43625: [OpenMP] Remove implicit data sharing code gen that aims to use device shared memory

2018-03-01 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 136570.
gtbercea added a comment.

Add Source location.


Repository:
  rC Clang

https://reviews.llvm.org/D43625

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_data_sharing.cpp
  test/OpenMP/nvptx_parallel_codegen.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_codegen.cpp
@@ -60,7 +60,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args, i16 1)
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i16 1)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -146,7 +146,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args, i16 1)
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i16 1)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
Index: test/OpenMP/nvptx_parallel_codegen.cpp
===
--- test/OpenMP/nvptx_parallel_codegen.cpp
+++ test/OpenMP/nvptx_parallel_codegen.cpp
@@ -78,7 +78,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -92,20 +92,20 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF1:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1:@.+]]_wrapper to i8*)
+  // CHECK: [[WM1:%.+]] = icmp eq i8* [[WF1]], bitcast (void (i32*, i32*)* [[PARALLEL_FN1:@.+]] to i8*)
   // CHECK: br i1 [[WM1]], label {{%?}}[[EXEC_PFN1:.+]], label {{%?}}[[CHECK_NEXT1:.+]]
   //
   // CHECK: [[EXEC_PFN1]]
-  // CHECK: call void [[PARALLEL_FN1]]_wrapper(
+  // CHECK: call void [[PARALLEL_FN1]](
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT1]]
   // CHECK: [[WF2:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2:@.+]]_wrapper to i8*)
+  // CHECK: [[WM2:%.+]] = icmp eq i8* [[WF2]], bitcast (void (i32*, i32*)* [[PARALLEL_FN2:@.+]] to i8*)
   // CHECK: br i1 [[WM2]], label {{%?}}[[EXEC_PFN2:.+]], label {{%?}}[[CHECK_NEXT2:.+]]
   //
   // CHECK: [[EXEC_PFN2]]
-  // CHECK: call void [[PARALLEL_FN2]]_wrapper(
+  // CHECK: call void [[PARALLEL_FN2]](
   // CHECK: br label {{%?}}[[TERM_PARALLEL:.+]]
   //
   // CHECK: [[CHECK_NEXT2]]
@@ -152,13 +152,13 @@
   // CHECK-DAG: [[MWS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
   // CHECK: [[MTMP1:%.+]] = sub i32 [[MNTH]], [[MWS]]
   // CHECK: call void @__kmpc_kernel_init(i32 [[MTMP1]]
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN1]]_wrapper to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN1]] to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @__kmpc_serialized_parallel(
   // CHECK: {{call|invoke}} void [[PARALLEL_FN3:@.+]](
   // CHECK: call void @__kmpc_end_serialized_parallel(
-  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i16, i32, i8**)* [[PARALLEL_FN2]]_wrapper to i8*),
+  // CHECK: call void @__kmpc_kernel_prepare_parallel(i8* bitcast (void (i32*, i32*)* [[PARALLEL_FN2]] to i8*),
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK: call void @llvm.nvvm.barrier0()
   // CHECK-64-DAG: load i32, i32* [[REF_A]]
@@ -203,7 +203,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]],
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]]
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -217,11 +217,11 @@
   //
   // CHECK: [[EXEC_PARALLEL]]
   // CHECK: [[WF:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
-  // CHECK: [[WM:%.+]] = icmp eq i8* 

[PATCH] D43957: Fixing issue where a space was not added before a global namespace variable when SpacesInParentheses is set

2018-03-01 Thread Darby Payne via Phabricator via cfe-commits
dpayne created this revision.
dpayne added a reviewer: djasper.
Herald added subscribers: cfe-commits, klimek.

When SpacesInParentheses is set to true clang-format does not add a space 
before a global namespace variable. For example this is the output of 
clang-format for a somewhat contrived exampled.

  #include 
  
  void print_val( std::ostream  ) { s << "Hello world" << std::endl; }
  
  int main( void ) {
print_val(::std::cout );
return 0;
  }

The .clang-format looked like

  Language:Cpp
  SpacesInParentheses: true


Repository:
  rC Clang

https://reviews.llvm.org/D43957

Files:
  lib/Format/TokenAnnotator.cpp


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2631,7 +2631,8 @@
 Style.Standard == FormatStyle::LS_Cpp03) ||
!(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
   tok::kw___super, TT_TemplateCloser,
-  TT_TemplateOpener));
+  TT_TemplateOpener)) ||
+   (Left.is(tok ::l_paren) && Style.SpacesInParentheses);
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
 return Style.SpacesInAngles;
   // Space before TT_StructuredBindingLSquare.


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2631,7 +2631,8 @@
 Style.Standard == FormatStyle::LS_Cpp03) ||
!(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
   tok::kw___super, TT_TemplateCloser,
-  TT_TemplateOpener));
+  TT_TemplateOpener)) ||
+   (Left.is(tok ::l_paren) && Style.SpacesInParentheses);
   if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
 return Style.SpacesInAngles;
   // Space before TT_StructuredBindingLSquare.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43745: Fix cppcoreguidelines-pro-bounds-pointer-arithmetic not working for functions with auto return specifier.

2018-03-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Some minor formatting nits, but otherwise LGTM. You should run the patch 
through clang-format: 
https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting




Comment at: clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp:29
 hasOperatorName("+="), hasOperatorName("-=")),
-  hasType(pointerType()),
+  anyOf(hasType(pointerType()), 
hasType(autoType(hasDeducedType(pointerType(),
   unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit()))

This extends past the 80-col limit.



Comment at: 
test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp:12
 
+int* pointer() {
+  return nullptr;

Should be `int *` instead of `int*` (elsewhere as well).



Comment at: 
test/clang-tidy/cppcoreguidelines-pro-bounds-pointer-arithmetic.cpp:26
+  auto x = (int*) nullptr;
+  p = x + 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: do not use pointer arithmetic

Can you remove the whitespace alignment from the new tests?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43745



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


[PATCH] D43869: [clangd] Support include canonicalization in symbol leve.

2018-03-01 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE326456: [clangd] Support include canonicalization in 
symbol leve. (authored by ioeric, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43869?vs=136561=136565#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43869

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

Index: clangd/index/CanonicalIncludes.h
===
--- clangd/index/CanonicalIncludes.h
+++ clangd/index/CanonicalIncludes.h
@@ -43,9 +43,17 @@
   /// Maps all files matching \p RE to \p CanonicalPath
   void addRegexMapping(llvm::StringRef RE, llvm::StringRef CanonicalPath);
 
+  /// Sets the canonical include for any symbol with \p QualifiedName.
+  /// Symbol mappings take precedence over header mappings.
+  void addSymbolMapping(llvm::StringRef QualifiedName,
+llvm::StringRef CanonicalPath);
+
   /// \return \p Header itself if there is no mapping for it; otherwise, return
   /// a canonical header name.
-  llvm::StringRef mapHeader(llvm::StringRef Header) const;
+  /// \p QualifiedName of a symbol declared in \p Header can be provided to
+  /// check against the symbol mapping.
+  llvm::StringRef mapHeader(llvm::StringRef Header,
+llvm::StringRef QualifiedName = "") const;
 
 private:
   // A map from header patterns to header names. This needs to be mutable so
@@ -55,6 +63,8 @@
   // arbitrary regexes.
   mutable std::vector>
   RegexHeaderMappingTable;
+  // A map from fully qualified symbol names to header names.
+  llvm::StringMap SymbolMapping;
   // Guards Regex matching as it's not thread-safe.
   mutable std::mutex RegexMutex;
 };
@@ -68,8 +78,9 @@
 std::unique_ptr
 collectIWYUHeaderMaps(CanonicalIncludes *Includes);
 
-/// Adds mapping for system headers. Approximately, the following system headers
-/// are handled:
+/// Adds mapping for system headers and some special symbols (e.g. STL symbols
+/// in  need to be mapped individually). Approximately, the following
+/// system headers are handled:
 ///   - C++ standard library e.g. bits/basic_string.h$ -> 
 ///   - Posix library e.g. bits/pthreadtypes.h$ -> 
 ///   - Compiler extensions, e.g. include/avx512bwintrin.h$ -> 
Index: clangd/index/CanonicalIncludes.cpp
===
--- clangd/index/CanonicalIncludes.cpp
+++ clangd/index/CanonicalIncludes.cpp
@@ -27,7 +27,19 @@
   this->RegexHeaderMappingTable.emplace_back(llvm::Regex(RE), CanonicalPath);
 }
 
-llvm::StringRef CanonicalIncludes::mapHeader(llvm::StringRef Header) const {
+void CanonicalIncludes::addSymbolMapping(llvm::StringRef QualifiedName,
+ llvm::StringRef CanonicalPath) {
+  this->SymbolMapping[QualifiedName] = CanonicalPath;
+}
+
+llvm::StringRef
+CanonicalIncludes::mapHeader(llvm::StringRef Header,
+ llvm::StringRef QualifiedName) const {
+  if (!QualifiedName.empty()) {
+auto SE = SymbolMapping.find(QualifiedName);
+if (SE != SymbolMapping.end())
+  return SE->second;
+  }
   std::lock_guard Lock(RegexMutex);
   for (auto  : RegexHeaderMappingTable) {
 #ifndef NDEBUG
@@ -67,6 +79,53 @@
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
+  static const std::vector SymbolMap = {
+  // Map symbols in  to their preferred includes.
+  {"std::basic_filebuf", ""},
+  {"std::basic_fstream", ""},
+  {"std::basic_ifstream", ""},
+  {"std::basic_ofstream", ""},
+  {"std::filebuf", ""},
+  {"std::fstream", ""},
+  {"std::ifstream", ""},
+  {"std::ofstream", ""},
+  {"std::wfilebuf", ""},
+  {"std::wfstream", ""},
+  {"std::wifstream", ""},
+  {"std::wofstream", ""},
+  {"std::basic_ios", ""},
+  {"std::ios", ""},
+  {"std::wios", ""},
+  {"std::basic_iostream", ""},
+  {"std::iostream", ""},
+  {"std::wiostream", ""},
+  {"std::basic_istream", ""},
+  {"std::istream", ""},
+  {"std::wistream", ""},
+  {"std::istreambuf_iterator", ""},
+  {"std::ostreambuf_iterator", ""},
+  {"std::basic_ostream", ""},
+  {"std::ostream", ""},
+  {"std::wostream", ""},
+  {"std::basic_istringstream", ""},
+  {"std::basic_ostringstream", ""},
+  {"std::basic_stringbuf", ""},
+  {"std::basic_stringstream", ""},
+  {"std::istringstream", ""},
+  {"std::ostringstream", ""},
+  {"std::stringbuf", ""},
+  {"std::stringstream", ""},
+  {"std::wistringstream", ""},
+  {"std::wostringstream", ""},
+  {"std::wstringbuf", ""},
+  {"std::wstringstream", ""},
+  {"std::basic_streambuf", ""},
+  {"std::streambuf", ""},
+  {"std::wstreambuf", ""},
+  

[clang-tools-extra] r326456 - [clangd] Support include canonicalization in symbol leve.

2018-03-01 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Mar  1 10:06:40 2018
New Revision: 326456

URL: http://llvm.org/viewvc/llvm-project?rev=326456=rev
Log:
[clangd] Support include canonicalization in symbol leve.

Summary:
Symbols with different canonical includes might be defined in the same header
(e.g. symbols defined in STL ). This patch adds support for mapping from
qualified symbol names to canonical headers and special mapping for symbols in 


Reviewers: sammccall, hokein

Reviewed By: sammccall

Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=326456=326455=326456=diff
==
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp Thu Mar  1 
10:06:40 2018
@@ -27,7 +27,19 @@ void CanonicalIncludes::addRegexMapping(
   this->RegexHeaderMappingTable.emplace_back(llvm::Regex(RE), CanonicalPath);
 }
 
-llvm::StringRef CanonicalIncludes::mapHeader(llvm::StringRef Header) const {
+void CanonicalIncludes::addSymbolMapping(llvm::StringRef QualifiedName,
+ llvm::StringRef CanonicalPath) {
+  this->SymbolMapping[QualifiedName] = CanonicalPath;
+}
+
+llvm::StringRef
+CanonicalIncludes::mapHeader(llvm::StringRef Header,
+ llvm::StringRef QualifiedName) const {
+  if (!QualifiedName.empty()) {
+auto SE = SymbolMapping.find(QualifiedName);
+if (SE != SymbolMapping.end())
+  return SE->second;
+  }
   std::lock_guard Lock(RegexMutex);
   for (auto  : RegexHeaderMappingTable) {
 #ifndef NDEBUG
@@ -67,6 +79,53 @@ collectIWYUHeaderMaps(CanonicalIncludes
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
+  static const std::vector SymbolMap = {
+  // Map symbols in  to their preferred includes.
+  {"std::basic_filebuf", ""},
+  {"std::basic_fstream", ""},
+  {"std::basic_ifstream", ""},
+  {"std::basic_ofstream", ""},
+  {"std::filebuf", ""},
+  {"std::fstream", ""},
+  {"std::ifstream", ""},
+  {"std::ofstream", ""},
+  {"std::wfilebuf", ""},
+  {"std::wfstream", ""},
+  {"std::wifstream", ""},
+  {"std::wofstream", ""},
+  {"std::basic_ios", ""},
+  {"std::ios", ""},
+  {"std::wios", ""},
+  {"std::basic_iostream", ""},
+  {"std::iostream", ""},
+  {"std::wiostream", ""},
+  {"std::basic_istream", ""},
+  {"std::istream", ""},
+  {"std::wistream", ""},
+  {"std::istreambuf_iterator", ""},
+  {"std::ostreambuf_iterator", ""},
+  {"std::basic_ostream", ""},
+  {"std::ostream", ""},
+  {"std::wostream", ""},
+  {"std::basic_istringstream", ""},
+  {"std::basic_ostringstream", ""},
+  {"std::basic_stringbuf", ""},
+  {"std::basic_stringstream", ""},
+  {"std::istringstream", ""},
+  {"std::ostringstream", ""},
+  {"std::stringbuf", ""},
+  {"std::stringstream", ""},
+  {"std::wistringstream", ""},
+  {"std::wostringstream", ""},
+  {"std::wstringbuf", ""},
+  {"std::wstringstream", ""},
+  {"std::basic_streambuf", ""},
+  {"std::streambuf", ""},
+  {"std::wstreambuf", ""},
+  };
+  for (const auto  : SymbolMap)
+Includes->addSymbolMapping(Pair.first, Pair.second);
+
   static const std::vector
   SystemHeaderMap = {
   {"include/__stddef_max_align_t.h$", ""},

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h?rev=326456=326455=326456=diff
==
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.h Thu Mar  1 
10:06:40 2018
@@ -43,9 +43,17 @@ public:
   /// Maps all files matching \p RE to \p CanonicalPath
   void addRegexMapping(llvm::StringRef RE, llvm::StringRef CanonicalPath);
 
+  /// Sets the canonical include for any symbol with \p QualifiedName.
+  /// Symbol mappings take precedence over header mappings.
+  void addSymbolMapping(llvm::StringRef QualifiedName,
+llvm::StringRef CanonicalPath);
+
   /// \return \p Header itself if there is no mapping for it; otherwise, return
   /// a canonical header name.
-  llvm::StringRef mapHeader(llvm::StringRef Header) const;
+  /// \p QualifiedName of a symbol 

[PATCH] D43869: [clangd] Support include canonicalization in symbol leve.

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



Comment at: clangd/index/CanonicalIncludes.h:54
   /// a canonical header name.
-  llvm::StringRef mapHeader(llvm::StringRef Header) const;
+  /// An optional qualified symbol name can be provided to check against the
+  /// symbol mapping.

sammccall wrote:
> Why can't we always provide this?
I think it would be better to keep supporting the header-only mapping use case.



Comment at: unittests/clangd/SymbolCollectorTests.cpp:561
+  class no_map {};
+  class ios {};
+  class ostream {};

sammccall wrote:
> ioeric wrote:
> > hokein wrote:
> > > The STL implementation of `ios` is a typedef `typedef basic_ios  
> > > ios; `, I think we should make the test align with it?
> > The symbol mapping doesn't make a difference between symbol types, and 
> > symbol kind test is not in the scope of this patch,  so I think this 
> > wouldn't be necessary here.
> I'd be +1 on matching the real header a bit more so it's more obvious how 
> this relates to the standard library. As long as it's not too hard!
I'd prefer to keep the test case minimum so that it's clear that we are only 
matching on names.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43869



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


[PATCH] D43847: [clang-tidy] Add check: replace string::find(...) == 0 with absl::StartsWith

2018-03-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D43847#1023452, @hokein wrote:

> In https://reviews.llvm.org/D43847#1021967, @aaron.ballman wrote:
>
> > I need a bit more context because I'm unfamiliar with `absl`. What is this 
> > module's intended use?
>
>
> As `absl` has been open-sourced (https://github.com/abseil/abseil-cpp), I 
> think there will be more absl-related checks contributed from google or 
> external contributors in the future, so it make sense to create a new module.


Ah, so this is for abseil, good to know. Yeah, I think we should have a new 
module for it but perhaps with the full name instead of this shortened version?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43847



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


[PATCH] D43869: [clangd] Support include canonicalization in symbol leve.

2018-03-01 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 136561.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Merge with origin/master
- Address review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43869

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

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -547,6 +547,32 @@
 }
 #endif
 
+TEST_F(SymbolCollectorTest, STLiosfwd) {
+  CollectorOpts.CollectIncludePath = true;
+  CanonicalIncludes Includes;
+  addSystemHeadersMapping();
+  CollectorOpts.Includes = 
+  // Symbols from  should be mapped individually.
+  TestHeaderName = testPath("iosfwd");
+  TestFileName = testPath("iosfwd.cpp");
+  std::string Header = R"(
+namespace std {
+  class no_map {};
+  class ios {};
+  class ostream {};
+  class filebuf {};
+} // namespace std
+  )";
+  runSymbolCollector(Header, /*Main=*/"");
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  QName("std"),
+  AllOf(QName("std::no_map"), IncludeHeader("")),
+  AllOf(QName("std::ios"), IncludeHeader("")),
+  AllOf(QName("std::ostream"), IncludeHeader("")),
+  AllOf(QName("std::filebuf"), IncludeHeader("";
+}
+
 TEST_F(SymbolCollectorTest, IWYUPragma) {
   CollectorOpts.CollectIncludePath = true;
   CanonicalIncludes Includes;
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -154,13 +154,13 @@
 /// FIXME: we should handle .inc files whose symbols are expected be exported by
 /// their containing headers.
 llvm::Optional
-getIncludeHeader(const SourceManager , SourceLocation Loc,
- const SymbolCollector::Options ) {
+getIncludeHeader(llvm::StringRef QName, const SourceManager ,
+ SourceLocation Loc, const SymbolCollector::Options ) {
   llvm::StringRef FilePath = SM.getFilename(Loc);
   if (FilePath.empty())
 return llvm::None;
   if (Opts.Includes) {
-llvm::StringRef Mapped = Opts.Includes->mapHeader(FilePath);
+llvm::StringRef Mapped = Opts.Includes->mapHeader(FilePath, QName);
 if (Mapped != FilePath)
   return (Mapped.startswith("<") || Mapped.startswith("\""))
  ? Mapped.str()
@@ -316,8 +316,8 @@
   if (Opts.CollectIncludePath && shouldCollectIncludePath(S.SymInfo.Kind)) {
 // Use the expansion location to get the #include header since this is
 // where the symbol is exposed.
-if (auto Header =
-getIncludeHeader(SM, SM.getExpansionLoc(ND.getLocation()), Opts))
+if (auto Header = getIncludeHeader(
+QName, SM, SM.getExpansionLoc(ND.getLocation()), Opts))
   Include = std::move(*Header);
   }
   S.CompletionFilterText = FilterText;
Index: clangd/index/CanonicalIncludes.h
===
--- clangd/index/CanonicalIncludes.h
+++ clangd/index/CanonicalIncludes.h
@@ -43,9 +43,17 @@
   /// Maps all files matching \p RE to \p CanonicalPath
   void addRegexMapping(llvm::StringRef RE, llvm::StringRef CanonicalPath);
 
+  /// Sets the canonical include for any symbol with \p QualifiedName.
+  /// Symbol mappings take precedence over header mappings.
+  void addSymbolMapping(llvm::StringRef QualifiedName,
+llvm::StringRef CanonicalPath);
+
   /// \return \p Header itself if there is no mapping for it; otherwise, return
   /// a canonical header name.
-  llvm::StringRef mapHeader(llvm::StringRef Header) const;
+  /// \p QualifiedName of a symbol declared in \p Header can be provided to
+  /// check against the symbol mapping.
+  llvm::StringRef mapHeader(llvm::StringRef Header,
+llvm::StringRef QualifiedName = "") const;
 
 private:
   // A map from header patterns to header names. This needs to be mutable so
@@ -55,6 +63,8 @@
   // arbitrary regexes.
   mutable std::vector>
   RegexHeaderMappingTable;
+  // A map from fully qualified symbol names to header names.
+  llvm::StringMap SymbolMapping;
   // Guards Regex matching as it's not thread-safe.
   mutable std::mutex RegexMutex;
 };
@@ -68,8 +78,9 @@
 std::unique_ptr
 collectIWYUHeaderMaps(CanonicalIncludes *Includes);
 
-/// Adds mapping for system headers. Approximately, the following system headers
-/// are handled:
+/// Adds mapping for system headers and some special symbols (e.g. STL symbols
+/// in  need to be mapped individually). Approximately, the following
+/// system headers are handled:
 ///   - C++ standard library e.g. bits/basic_string.h$ -> 
 ///   - Posix 

[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-03-01 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:21
+: MakeSmartPtrCheck(Name, Context, "std::make_unique"),
+  MinimumLanguageVersion(Options.get("MakeUniqueLanguageVersion",
+ getDefaultMinimumLanguageVersion())) 
{}

aaron.ballman wrote:
> alexfh wrote:
> > ftingaud wrote:
> > > aaron.ballman wrote:
> > > > Why is this is a user-facing option?
> > > > 
> > > > If it needs to be a user-facing option, you also need to implement an 
> > > > override for `storeOptions()` as well.
> > > As the rule was very customizable, I also made the c++ version 
> > > customizable. But the option is only useful if a user has a custom 
> > > make_unique that needs c++14 (uses std::make_unique internally) and 
> > > multiple versions of C++ in their codeline. I agree this is a rather 
> > > specific usecase. I can remove it and make the code simpler if it is your 
> > > recommendation.
> > > if a user has a custom make_unique that needs c++14
> > 
> > The only reason to have a custom make_unique that I know is to workaround 
> > the absence of std::make_unique in c++11. So this looks like a not very 
> > useful case to support.
> Agreed, I'd drop it.
From the peanut gallery: IIUC, yes, this is not a useful case to support.
If the user has a custom `my::make_unique`, then it is *by definition* usable 
in C++11. Now, it might still be implemented as a call to `std::make_unique` in 
C++14... but it will not *require* C++14.
The user's `my::make_unique` will likely require C++11 (not just C++03), but I 
personally don't think clang-tidy ought to cater to corner cases that involve 
C++03. I'd just assume that an instruction to "use `my::make_unique`" is 
appropriate for any translation unit that's being tidied with a custom 
make_unique.



Comment at: test/clang-tidy/modernize-make-unique-cxx14.cpp:10
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
+  // CHECK-FIXES: auto my_ptr = std::make_unique(1);
+  return 0;

IIUC above, you allow the user to pass in the name of a custom 
`my::make_unique` function. Could you add a test case for that?


https://reviews.llvm.org/D43766



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


[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

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



Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:21
+: MakeSmartPtrCheck(Name, Context, "std::make_unique"),
+  MinimumLanguageVersion(Options.get("MakeUniqueLanguageVersion",
+ getDefaultMinimumLanguageVersion())) 
{}

alexfh wrote:
> ftingaud wrote:
> > aaron.ballman wrote:
> > > Why is this is a user-facing option?
> > > 
> > > If it needs to be a user-facing option, you also need to implement an 
> > > override for `storeOptions()` as well.
> > As the rule was very customizable, I also made the c++ version 
> > customizable. But the option is only useful if a user has a custom 
> > make_unique that needs c++14 (uses std::make_unique internally) and 
> > multiple versions of C++ in their codeline. I agree this is a rather 
> > specific usecase. I can remove it and make the code simpler if it is your 
> > recommendation.
> > if a user has a custom make_unique that needs c++14
> 
> The only reason to have a custom make_unique that I know is to workaround the 
> absence of std::make_unique in c++11. So this looks like a not very useful 
> case to support.
Agreed, I'd drop it.


https://reviews.llvm.org/D43766



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


[PATCH] D43800: [ASTMatchers] Allow file-based narrowing matches to work with NestedNameSpecifierLocs.

2018-03-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Please add some test coverage for the NNS case.


Repository:
  rC Clang

https://reviews.llvm.org/D43800



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


[PATCH] D42684: clang-format: Allow optimizer to break template declaration.

2018-03-01 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 136557.
Typz added a comment.

Change options values to No/MultiLine/Yes.


Repository:
  rC Clang

https://reviews.llvm.org/D42684

Files:
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5445,7 +5445,7 @@
"const typename  aaa);");
 
   FormatStyle AlwaysBreak = getLLVMStyle();
-  AlwaysBreak.AlwaysBreakTemplateDeclarations = true;
+  AlwaysBreak.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
   verifyFormat("template \nclass C {};", AlwaysBreak);
   verifyFormat("template \nvoid f();", AlwaysBreak);
   verifyFormat("template \nvoid f() {}", AlwaysBreak);
@@ -5463,6 +5463,32 @@
"public:\n"
"  E *f();\n"
"};");
+
+  FormatStyle NeverBreak = getLLVMStyle();
+  NeverBreak.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_No;
+  verifyFormat("template  class C {};", NeverBreak);
+  verifyFormat("template  void f();", NeverBreak);
+  verifyFormat("template  void f() {}", NeverBreak);
+  verifyFormat("template \nvoid foo(aa ) {}",
+   NeverBreak);
+  verifyFormat("void aaa(\n"
+   "ccc);",
+   NeverBreak);
+  verifyFormat("template  class Fooo,\n"
+   "  template  class Baaar>\n"
+   "struct C {};",
+   NeverBreak);
+  verifyFormat("template  // T can be A, B or C.\n"
+   "struct C {};",
+   NeverBreak);
+  verifyFormat("template  class A {\n"
+   "public:\n"
+   "  E *f();\n"
+   "};", NeverBreak);
+  NeverBreak.PenaltyBreakTemplateDeclaration = 100;
+  verifyFormat("template  void\nfoo(aa ) {}",
+   NeverBreak);
 }
 
 TEST_F(FormatTest, WrapsTemplateParameters) {
@@ -10352,7 +10378,6 @@
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortIfStatementsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
-  CHECK_PARSE_BOOL(AlwaysBreakTemplateDeclarations);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
@@ -10418,6 +10443,8 @@
   PenaltyBreakAssignment, 1234u);
   CHECK_PARSE("PenaltyBreakBeforeFirstCallParameter: 1234",
   PenaltyBreakBeforeFirstCallParameter, 1234u);
+  CHECK_PARSE("PenaltyBreakTemplateDeclaration: 1234",
+  PenaltyBreakTemplateDeclaration, 1234u);
   CHECK_PARSE("PenaltyExcessCharacter: 1234", PenaltyExcessCharacter, 1234u);
   CHECK_PARSE("PenaltyReturnTypeOnItsOwnLine: 1234",
   PenaltyReturnTypeOnItsOwnLine, 1234u);
@@ -10572,6 +10599,18 @@
   AlwaysBreakAfterReturnType,
   FormatStyle::RTBS_TopLevelDefinitions);
 
+  Style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: No", AlwaysBreakTemplateDeclarations,
+  FormatStyle::BTDS_No);
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: MultiLine", AlwaysBreakTemplateDeclarations,
+  FormatStyle::BTDS_MultiLine);
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: Yes", AlwaysBreakTemplateDeclarations,
+  FormatStyle::BTDS_Yes);
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: false", AlwaysBreakTemplateDeclarations,
+  FormatStyle::BTDS_MultiLine);
+  CHECK_PARSE("AlwaysBreakTemplateDeclarations: true", AlwaysBreakTemplateDeclarations,
+  FormatStyle::BTDS_Yes);
+
   Style.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_All;
   CHECK_PARSE("AlwaysBreakAfterDefinitionReturnType: None",
   AlwaysBreakAfterDefinitionReturnType, FormatStyle::DRTBS_None);
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2244,6 +2244,8 @@
   return 2;
 return 1;
   }
+  if (Left.ClosesTemplateDeclaration)
+  return Style.PenaltyBreakTemplateDeclaration;
   if (Left.is(TT_ConditionalExpr))
 return prec::Conditional;
   prec::Level Level = Left.getPrecedence();
@@ -2753,7 +2755,7 @@
   if (Right.Previous->ClosesTemplateDeclaration &&
   Right.Previous->MatchingParen &&
   Right.Previous->MatchingParen->NestingLevel == 0 &&
-  Style.AlwaysBreakTemplateDeclarations)
+  Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes)
  

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

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



Comment at: clang-tidy/modernize/DeprecatedFunctionalCheck.cpp:48-54
+  } else if (const auto *const Call =
+ Result.Nodes.getNodeAs("ptr_fun_call")) {
+diag(Call->getLocStart(), Message) << "'std::ptr_fun'";
+  } else if (const auto *const Call =
+ Result.Nodes.getNodeAs("mem_fun_call")) {
+diag(Call->getLocStart(), Message) << "'std::mem_fun'";
+  }

alexfh wrote:
> alexfh wrote:
> > aaron.ballman wrote:
> > > massberg wrote:
> > > > aaron.ballman wrote:
> > > > > I think that this code should be generalized (same with the matchers) 
> > > > > so that you match on `hasAnyName()` for the function calls and use 
> > > > > `CallExpr::getCalleeDecl()` to get the declaration. e.g.,
> > > > > ```
> > > > > if (const auto *Call = Result.Nodes.getNodeAs("blech")) {
> > > > >   if (const Decl *Callee = Call->getCalleeDecl())
> > > > > diag(Call->getLocStart(), Message) << Calleee;
> > > > > }
> > > > > ```
> > > > > This way you can add more named without having to add extra logic for 
> > > > > the diagnostics.
> > > > I generalized the code and the matcher.
> > > > When we use
> > > > ```
> > > > << cast(Callee);
> > > > ```
> > > > we get the template arguments in the name , e.g. `ptr_fun`, 
> > > > so I chose to use `getQualifiedNameAsString`.
> > > > If there is there a better way to get the function name without 
> > > > template arguments I appreciate any suggestions.
> > > > 
> > > > 
> > > Nope, in that case, your code is correct. However, we generally provide 
> > > the template arguments in diagnostics. I see @alexfh was asking for them 
> > > to be removed as not being useful, but I'm not certain I agree with his 
> > > rationale. Yes, all instances are deprecated and thus the template 
> > > arguments don't discern between good and bad cases, but showing the 
> > > template arguments is also consistent with the other diagnostics we emit. 
> > > For instance, other "deprecated" diagnostics also emit the template 
> > > arguments. I'm not certain we should be inconsistent with the way we 
> > > produce diagnostics, but I'll defer to Alex if he still feels strongly 
> > > about leaving them off here.
> > Indeed, -Wdeprecated-declarations warnings print template arguments. 
> > Moreover, they seem to be issued only on instantiations, see 
> > https://godbolt.org/g/W563gw.
> > 
> > But I have a number of concerns with template arguments in the deprecation 
> > warnings:
> > 
> > 1. The note attached to the warning lies. Consider a warning from the test 
> > above:
> >   ...
> >   :11:1: warning: 'B' is deprecated: bbb 
> > [-Wdeprecated-declarations]
> >   B e;
> >   ^
> >   :7:10: note: 'B' has been explicitly marked deprecated here
> >   struct [[deprecated("bbb")]] B {};
> > 
> >  But `B` hasn't been explicitly marked deprecated, only the template 
> > definition of `B` has been. Template arguments are important in the case of 
> > the explicit template specialization `A` in the same example, but not 
> > in cases where the template definition was marked deprecated, since 
> > template arguments only add noise and no useful information there.
> > 2. Warnings can easily become unreadable: https://godbolt.org/g/AFdznH
> > 3. Certain coding patterns can result in numerous deprecation warnings 
> > differing only in template arguments: https://godbolt.org/g/U2JCbG. 
> > Clang-tidy can deduplicate warnings, if they have identical text and 
> > location, but adding template arguments to the message will prevent 
> > deduplication. I've seen a case where thousands of deprecation warnings 
> > were generated for a single line in a widely used header.
> > 
> > So yes, I feel strongly about leaving off template arguments in case the 
> > whole template was marked deprecated. I think it would be the right thing 
> > to do for the -Wdeprecated-declarations diagnostic as well.
> s/leaving off/leaving out/
> The note attached to the warning lies.

No it doesn't? The attribute is inherited from the primary template unless your 
explicit specialization *removes* the attribute. https://godbolt.org/g/ZuXZds

> Warnings can easily become unreadable

This is true of all template diagnostics and isn't specific to clang-tidy's 
treatment of them.

> I've seen a case where thousands of deprecation warnings were generated for a 
> single line in a widely used header.

This sounds more worrying, but at the same time, your link behaving by design 
and doing what I would want it to do. The presence of the deprecated primary 
template isn't what gets diagnosed, it's the *uses* of the deprecated entity. 
This is called out explicitly in [dcl.attr.deprecated]p4.

> So yes, I feel strongly about leaving off template arguments in case the 
> whole template was marked deprecated. I think it would be the right thing to 
> do for the -Wdeprecated-declarations diagnostic as well.

I would be strongly opposed to 

[PATCH] D43015: clang-format: Introduce BreakInheritanceList option

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

ping?


Repository:
  rC Clang

https://reviews.llvm.org/D43015



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


[PATCH] D43281: [AMDGPU] fixes for lds f32 builtins

2018-03-01 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov added a comment.

The problem is that if set addrspace "2" in description string, 
CanT.getAddressSpace() returns target addrspace value "11" (shifted in the 
enum) and compares it with input LangAS addrspace ("2", "opencl_local" in our 
case).
So I cannot set a number a description string that will be equal to LangAS 
addrspace "opencl_local".

Moreover, this change is preparation to move to custom processing of these 
builtins. Then I'm going to remove link (GCCBuiltin in IntrinsicsAMDGPU.td) 
from the llvm intrinsics definitions. Then I'll be able to switch on custom 
processing in cfe.


https://reviews.llvm.org/D43281



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


[clang-tools-extra] r326452 - [clangd] Forward all environment variables along with CLANGD_TRACE to clangd.

2018-03-01 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Mar  1 09:42:27 2018
New Revision: 326452

URL: http://llvm.org/viewvc/llvm-project?rev=326452=rev
Log:
[clangd] Forward all environment variables along with CLANGD_TRACE to clangd.

Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts

Modified: clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts?rev=326452=326451=326452=diff
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts 
(original)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/src/extension.ts Thu 
Mar  1 09:42:27 2018
@@ -23,8 +23,10 @@ export function activate(context: vscode
 args: getConfig('arguments')
 };
 const traceFile = getConfig('trace');
-if (traceFile != null)
-clangd.options = {env: {CLANGD_TRACE: traceFile}};
+if (traceFile != '') {
+  const trace = {CLANGD_TRACE : traceFile};
+  clangd.options = {env : {...process.env, ...trace}};
+}
 const serverOptions: vscodelc.ServerOptions = clangd;
 
 const filePattern: string = '**/*.{' +


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


[PATCH] D43953: clangformat-vs: Fix plugin not correctly loading in some cases

2018-03-01 Thread François-Xavier Roure via Phabricator via cfe-commits
fxroure-ubisoft created this revision.
fxroure-ubisoft added a reviewer: clang.
fxroure-ubisoft created this object with edit policy "Only User: 
fxroure-ubisoft (François-Xavier Roure)".
Herald added a subscriber: cfe-commits.

When installing the clang-format visual studio plugin 

 sometimes it won't be loaded correctly (some users seem to have the same issue 
)
 and we must do

  devenv.exe /updateconfiguration

in order to fix the installation (normally visual studio should automatically 
execute this command whenever you install a plugin).
This issue seems to come from the fact that the plugin manifest does not list a 
VsPackage as an asset.
After adding it to assets list (code change in this review) installation of the 
plugin was working and when uninstalling the plugin visual correctly ask to 
restart it (that was not the case before).


Repository:
  rC Clang

https://reviews.llvm.org/D43953

Files:
  tools/clang-format-vs/source.extension.vsixmanifest.in


Index: tools/clang-format-vs/source.extension.vsixmanifest.in
===
--- tools/clang-format-vs/source.extension.vsixmanifest.in
+++ tools/clang-format-vs/source.extension.vsixmanifest.in
@@ -16,4 +16,7 @@
   
 
   
+  
+
+  
 


Index: tools/clang-format-vs/source.extension.vsixmanifest.in
===
--- tools/clang-format-vs/source.extension.vsixmanifest.in
+++ tools/clang-format-vs/source.extension.vsixmanifest.in
@@ -16,4 +16,7 @@
   
 
   
+  
+
+  
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43928: [analyzer] Correctly measure array size in security.insecureAPI.strcpy

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



Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:517
 if (const auto *Array = dyn_cast(DeclRef->getType())) {
-  uint64_t ArraySize = BR.getContext().getTypeSize(Array) / 8;
+  auto ArraySize = BR.getContext().getTypeSizeInChars(Array).getQuantity();
   if (const auto *String = dyn_cast(Source)) {

I suggest not using `auto` here, because it makes it harder to understand 
integer promotions (potential overflows or sign extensions) in the comparison.


https://reviews.llvm.org/D43928



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


[PATCH] D43108: Support for the mno-stack-arg-probe flag

2018-03-01 Thread Ruslan Nikolaev via Phabricator via cfe-commits
nruslan added a comment.

@aemerson : yes, it is just part of MS ABI


Repository:
  rC Clang

https://reviews.llvm.org/D43108



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


[PATCH] D43162: [Parser] (C++) Make -Wextra-semi slightly more useful

2018-03-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

**If** i'm reading `git blame` correctly, the `-Wnewline-eof` diag, which i 
used as a base to model the previous version of this diff on,
was added in https://reviews.llvm.org/rL189110 / 
https://github.com/llvm-mirror/clang/commit/7865b8e4324378e06f59adb4d60bec26a7d3d584
 by @jordan_rose.
Since the @rsmith's review note suggests the approach is incorrect, i've added 
the author of that commit as a subscriber, just in case.


Repository:
  rC Clang

https://reviews.llvm.org/D43162



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


[PATCH] D43817: [x86] wbnoinvd intrinsic

2018-03-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D43817



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


[PATCH] D43766: [clang-tidy][modernize-make-unique] Checks c++14 flag before using std::make_unique

2018-03-01 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/modernize/MakeUniqueCheck.cpp:21
+: MakeSmartPtrCheck(Name, Context, "std::make_unique"),
+  MinimumLanguageVersion(Options.get("MakeUniqueLanguageVersion",
+ getDefaultMinimumLanguageVersion())) 
{}

ftingaud wrote:
> aaron.ballman wrote:
> > Why is this is a user-facing option?
> > 
> > If it needs to be a user-facing option, you also need to implement an 
> > override for `storeOptions()` as well.
> As the rule was very customizable, I also made the c++ version customizable. 
> But the option is only useful if a user has a custom make_unique that needs 
> c++14 (uses std::make_unique internally) and multiple versions of C++ in 
> their codeline. I agree this is a rather specific usecase. I can remove it 
> and make the code simpler if it is your recommendation.
> if a user has a custom make_unique that needs c++14

The only reason to have a custom make_unique that I know is to workaround the 
absence of std::make_unique in c++11. So this looks like a not very useful case 
to support.


https://reviews.llvm.org/D43766



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


[PATCH] D43500: [clang-tidy]: modernize-use-default-member-init: Remove trailing comma and colon.

2018-03-01 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: unittests/clang-tidy/ClangTidyTest.h:145
+
+  if (Options.FormatStyle) {
+llvm::Expected Style = format::getStyle(

I wonder whether it's better to use lit for the tests that require formatting 
than to expand clang-tidy unit test utilities with runCheckAndFormatOnCode? 
What was the reason to use unit tests in this patch as opposed to lit tests?


https://reviews.llvm.org/D43500



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


  1   2   >