[PATCH] D35020: [Modules] Add ability to specify module name to module file mapping

2017-08-24 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

Ping.


https://reviews.llvm.org/D35020



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


[PATCH] D37131: [coroutines] Support coroutine-handle returning await-suspend (i.e symmetric control transfer)

2017-08-24 Thread Gor Nishanov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311762: [coroutines] Support coroutine-handle returning 
await-suspend (i.e symmetric… (authored by GorNishanov).

Changed prior to commit:
  https://reviews.llvm.org/D37131?vs=112658=112659#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37131

Files:
  cfe/trunk/lib/CodeGen/CGCoroutine.cpp
  cfe/trunk/lib/Sema/SemaCoroutine.cpp
  cfe/trunk/test/CodeGenCoroutines/coro-await.cpp

Index: cfe/trunk/test/CodeGenCoroutines/coro-await.cpp
===
--- cfe/trunk/test/CodeGenCoroutines/coro-await.cpp
+++ cfe/trunk/test/CodeGenCoroutines/coro-await.cpp
@@ -12,6 +12,7 @@
 struct coroutine_handle {
   void *ptr;
   static coroutine_handle from_address(void *);
+  void *address();
 };
 
 template 
@@ -326,3 +327,20 @@
   // CHECK-NEXT: store %struct.RefTag* %[[RES3]], %struct.RefTag** %[[ZVAR]],
   RefTag& z = co_yield 42;
 }
+
+struct TailCallAwait {
+  bool await_ready();
+  std::experimental::coroutine_handle<> await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+
+// CHECK-LABEL: @TestTailcall(
+extern "C" void TestTailcall() {
+  co_await TailCallAwait{};
+
+  // CHECK: %[[RESULT:.+]] = call i8* @_ZN13TailCallAwait13await_suspendENSt12experimental16coroutine_handleIvEE(%struct.TailCallAwait*
+  // CHECK: %[[COERCE:.+]] = getelementptr inbounds %"struct.std::experimental::coroutine_handle", %"struct.std::experimental::coroutine_handle"* %[[TMP:.+]], i32 0, i32 0
+  // CHECK: store i8* %[[RESULT]], i8** %[[COERCE]]
+  // CHECK: %[[ADDR:.+]] = call i8* @_ZNSt12experimental16coroutine_handleIvE7addressEv(%"struct.std::experimental::coroutine_handle"* %[[TMP]])
+  // CHECK: call void @llvm.coro.resume(i8* %[[ADDR]])
+}
Index: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
===
--- cfe/trunk/lib/CodeGen/CGCoroutine.cpp
+++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp
@@ -181,10 +181,8 @@
   auto *SaveCall = Builder.CreateCall(CoroSave, {NullPtr});
 
   auto *SuspendRet = CGF.EmitScalarExpr(S.getSuspendExpr());
-  if (SuspendRet != nullptr) {
+  if (SuspendRet != nullptr && SuspendRet->getType()->isIntegerTy(1)) {
 // Veto suspension if requested by bool returning await_suspend.
-assert(SuspendRet->getType()->isIntegerTy(1) &&
-   "Sema should have already checked that it is void or bool");
 BasicBlock *RealSuspendBlock =
 CGF.createBasicBlock(Prefix + Twine(".suspend.bool"));
 CGF.Builder.CreateCondBr(SuspendRet, RealSuspendBlock, ReadyBlock);
Index: cfe/trunk/lib/Sema/SemaCoroutine.cpp
===
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp
@@ -363,6 +363,32 @@
   return S.ActOnCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr);
 }
 
+// See if return type is coroutine-handle and if so, invoke builtin coro-resume
+// on its address. This is to enable experimental support for coroutine-handle
+// returning await_suspend that results in a guranteed tail call to the target
+// coroutine.
+static Expr *maybeTailCall(Sema , QualType RetType, Expr *E,
+   SourceLocation Loc) {
+  if (RetType->isReferenceType())
+return nullptr;
+  Type const *T = RetType.getTypePtr();
+  if (!T->isClassType() && !T->isStructureType())
+return nullptr;
+
+  // FIXME: Add convertability check to coroutine_handle<>. Possibly via
+  // EvaluateBinaryTypeTrait(BTT_IsConvertible, ...) which is at the moment
+  // a private function in SemaExprCXX.cpp
+
+  ExprResult AddressExpr = buildMemberCall(S, E, Loc, "address", None);
+  if (AddressExpr.isInvalid())
+return nullptr;
+
+  Expr *JustAddress = AddressExpr.get();
+  // FIXME: Check that the type of AddressExpr is void*
+  return buildBuiltinCall(S, Loc, Builtin::BI__builtin_coro_resume,
+  JustAddress);
+}
+
 /// Build calls to await_ready, await_suspend, and await_resume for a co_await
 /// expression.
 static ReadySuspendResumeResult buildCoawaitCalls(Sema , VarDecl *CoroPromise,
@@ -412,16 +438,21 @@
 //   - await-suspend is the expression e.await_suspend(h), which shall be
 // a prvalue of type void or bool.
 QualType RetType = AwaitSuspend->getCallReturnType(S.Context);
-// non-class prvalues always have cv-unqualified types
-QualType AdjRetType = RetType.getUnqualifiedType();
-if (RetType->isReferenceType() ||
-(AdjRetType != S.Context.BoolTy && AdjRetType != S.Context.VoidTy)) {
-  S.Diag(AwaitSuspend->getCalleeDecl()->getLocation(),
- diag::err_await_suspend_invalid_return_type)
-  << RetType;
-  S.Diag(Loc, diag::note_coroutine_promise_call_implicitly_required)
-  << AwaitSuspend->getDirectCallee();
-  Calls.IsInvalid = true;
+// Experimental support for coroutine_handle returning 

r311762 - [coroutines] Support coroutine-handle returning await-suspend (i.e symmetric control transfer)

2017-08-24 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Thu Aug 24 21:46:54 2017
New Revision: 311762

URL: http://llvm.org/viewvc/llvm-project?rev=311762=rev
Log:
[coroutines] Support coroutine-handle returning await-suspend (i.e symmetric 
control transfer)

Summary:
If await_suspend returns a coroutine_handle, as in the example below:
```
  coroutine_handle<> await_suspend(coroutine_handle<> h) {
coro.promise().waiter = h;
return coro;
  }
```
suspensionExpression processing will resume the coroutine pointed at by that 
handle.
Related LLVM change rL311751 makes resume calls of this kind `musttail` at any 
optimization level.

This enables unlimited symmetric control transfer from coroutine to coroutine 
without blowing up the stack.

Reviewers: GorNishanov

Reviewed By: GorNishanov

Subscribers: rsmith, EricWF, cfe-commits

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

Modified:
cfe/trunk/lib/CodeGen/CGCoroutine.cpp
cfe/trunk/lib/Sema/SemaCoroutine.cpp
cfe/trunk/test/CodeGenCoroutines/coro-await.cpp

Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=311762=311761=311762=diff
==
--- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Thu Aug 24 21:46:54 2017
@@ -181,10 +181,8 @@ static LValueOrRValue emitSuspendExpress
   auto *SaveCall = Builder.CreateCall(CoroSave, {NullPtr});
 
   auto *SuspendRet = CGF.EmitScalarExpr(S.getSuspendExpr());
-  if (SuspendRet != nullptr) {
+  if (SuspendRet != nullptr && SuspendRet->getType()->isIntegerTy(1)) {
 // Veto suspension if requested by bool returning await_suspend.
-assert(SuspendRet->getType()->isIntegerTy(1) &&
-   "Sema should have already checked that it is void or bool");
 BasicBlock *RealSuspendBlock =
 CGF.createBasicBlock(Prefix + Twine(".suspend.bool"));
 CGF.Builder.CreateCondBr(SuspendRet, RealSuspendBlock, ReadyBlock);

Modified: cfe/trunk/lib/Sema/SemaCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCoroutine.cpp?rev=311762=311761=311762=diff
==
--- cfe/trunk/lib/Sema/SemaCoroutine.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCoroutine.cpp Thu Aug 24 21:46:54 2017
@@ -363,6 +363,32 @@ static ExprResult buildMemberCall(Sema &
   return S.ActOnCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr);
 }
 
+// See if return type is coroutine-handle and if so, invoke builtin coro-resume
+// on its address. This is to enable experimental support for coroutine-handle
+// returning await_suspend that results in a guranteed tail call to the target
+// coroutine.
+static Expr *maybeTailCall(Sema , QualType RetType, Expr *E,
+   SourceLocation Loc) {
+  if (RetType->isReferenceType())
+return nullptr;
+  Type const *T = RetType.getTypePtr();
+  if (!T->isClassType() && !T->isStructureType())
+return nullptr;
+
+  // FIXME: Add convertability check to coroutine_handle<>. Possibly via
+  // EvaluateBinaryTypeTrait(BTT_IsConvertible, ...) which is at the moment
+  // a private function in SemaExprCXX.cpp
+
+  ExprResult AddressExpr = buildMemberCall(S, E, Loc, "address", None);
+  if (AddressExpr.isInvalid())
+return nullptr;
+
+  Expr *JustAddress = AddressExpr.get();
+  // FIXME: Check that the type of AddressExpr is void*
+  return buildBuiltinCall(S, Loc, Builtin::BI__builtin_coro_resume,
+  JustAddress);
+}
+
 /// Build calls to await_ready, await_suspend, and await_resume for a co_await
 /// expression.
 static ReadySuspendResumeResult buildCoawaitCalls(Sema , VarDecl 
*CoroPromise,
@@ -412,16 +438,21 @@ static ReadySuspendResumeResult buildCoa
 //   - await-suspend is the expression e.await_suspend(h), which shall be
 // a prvalue of type void or bool.
 QualType RetType = AwaitSuspend->getCallReturnType(S.Context);
-// non-class prvalues always have cv-unqualified types
-QualType AdjRetType = RetType.getUnqualifiedType();
-if (RetType->isReferenceType() ||
-(AdjRetType != S.Context.BoolTy && AdjRetType != S.Context.VoidTy)) {
-  S.Diag(AwaitSuspend->getCalleeDecl()->getLocation(),
- diag::err_await_suspend_invalid_return_type)
-  << RetType;
-  S.Diag(Loc, diag::note_coroutine_promise_call_implicitly_required)
-  << AwaitSuspend->getDirectCallee();
-  Calls.IsInvalid = true;
+// Experimental support for coroutine_handle returning await_suspend.
+if (Expr *TailCallSuspend = maybeTailCall(S, RetType, AwaitSuspend, Loc))
+  Calls.Results[ACT::ACT_Suspend] = TailCallSuspend;
+else {
+  // non-class prvalues always have cv-unqualified types
+  QualType AdjRetType = RetType.getUnqualifiedType();
+  if (RetType->isReferenceType() ||
+  (AdjRetType != 

[PATCH] D37131: [coroutines] Support coroutine-handle returning await-suspend (i.e symmetric control transfer)

2017-08-24 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.

If await_suspend returns a coroutine_handle, as in the example below:

  coroutine_handle<> await_suspend(coroutine_handle<> h) {
coro.promise().waiter = h;
return coro;
  }

suspensionExpression processing will resume the coroutine pointed at by that 
handle.
Related LLVM change https://reviews.llvm.org/rL311751 makes resume calls of 
this kind `musttail` at any optimization level.

This enables unlimited symmetric control transfer from coroutine to coroutine 
without blowing up the stack.


https://reviews.llvm.org/D37131

Files:
  lib/CodeGen/CGCoroutine.cpp
  lib/Sema/SemaCoroutine.cpp
  test/CodeGenCoroutines/coro-await.cpp

Index: test/CodeGenCoroutines/coro-await.cpp
===
--- test/CodeGenCoroutines/coro-await.cpp
+++ test/CodeGenCoroutines/coro-await.cpp
@@ -12,6 +12,7 @@
 struct coroutine_handle {
   void *ptr;
   static coroutine_handle from_address(void *);
+  void *address();
 };
 
 template 
@@ -326,3 +327,20 @@
   // CHECK-NEXT: store %struct.RefTag* %[[RES3]], %struct.RefTag** %[[ZVAR]],
   RefTag& z = co_yield 42;
 }
+
+struct TailCallAwait {
+  bool await_ready();
+  std::experimental::coroutine_handle<> await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+
+// CHECK-LABEL: @TestTailcall(
+extern "C" void TestTailcall() {
+  co_await TailCallAwait{};
+
+  // CHECK: %[[RESULT:.+]] = call i8* @_ZN13TailCallAwait13await_suspendENSt12experimental16coroutine_handleIvEE(%struct.TailCallAwait*
+  // CHECK: %[[COERCE:.+]] = getelementptr inbounds %"struct.std::experimental::coroutine_handle", %"struct.std::experimental::coroutine_handle"* %[[TMP:.+]], i32 0, i32 0
+  // CHECK: store i8* %[[RESULT]], i8** %[[COERCE]]
+  // CHECK: %[[ADDR:.+]] = call i8* @_ZNSt12experimental16coroutine_handleIvE7addressEv(%"struct.std::experimental::coroutine_handle"* %[[TMP]])
+  // CHECK: call void @llvm.coro.resume(i8* %[[ADDR]])
+}
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -363,6 +363,32 @@
   return S.ActOnCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr);
 }
 
+// See if return type is coroutine-handle and if so, invoke builtin coro-resume
+// on its address. This is to enable experimental support for coroutine-handle
+// returning await_suspend that results in a guranteed tail call to the target
+// coroutine.
+static Expr *maybeTailCall(Sema , QualType RetType, Expr *E,
+   SourceLocation Loc) {
+  if (RetType->isReferenceType())
+return nullptr;
+  Type const *T = RetType.getTypePtr();
+  if (!T->isClassType() && !T->isStructureType())
+return nullptr;
+
+  // FIXME: Add convertability check to coroutine_handle<>. Possibly via
+  // EvaluateBinaryTypeTrait(BTT_IsConvertible, ...) which is at the moment
+  // a private function in SemaExprCXX.cpp
+
+  ExprResult AddressExpr = buildMemberCall(S, E, Loc, "address", None);
+  if (AddressExpr.isInvalid())
+return nullptr;
+
+  Expr *JustAddress = AddressExpr.get();
+  // FIXME: Check that the type of AddressExpr is void*
+  return buildBuiltinCall(S, Loc, Builtin::BI__builtin_coro_resume,
+  JustAddress);
+}
+
 /// Build calls to await_ready, await_suspend, and await_resume for a co_await
 /// expression.
 static ReadySuspendResumeResult buildCoawaitCalls(Sema , VarDecl *CoroPromise,
@@ -412,16 +438,21 @@
 //   - await-suspend is the expression e.await_suspend(h), which shall be
 // a prvalue of type void or bool.
 QualType RetType = AwaitSuspend->getCallReturnType(S.Context);
-// non-class prvalues always have cv-unqualified types
-QualType AdjRetType = RetType.getUnqualifiedType();
-if (RetType->isReferenceType() ||
-(AdjRetType != S.Context.BoolTy && AdjRetType != S.Context.VoidTy)) {
-  S.Diag(AwaitSuspend->getCalleeDecl()->getLocation(),
- diag::err_await_suspend_invalid_return_type)
-  << RetType;
-  S.Diag(Loc, diag::note_coroutine_promise_call_implicitly_required)
-  << AwaitSuspend->getDirectCallee();
-  Calls.IsInvalid = true;
+// Experimental support for coroutine_handle returning await_suspend.
+if (Expr *TailCallSuspend = maybeTailCall(S, RetType, AwaitSuspend, Loc))
+  Calls.Results[ACT::ACT_Suspend] = TailCallSuspend;
+else {
+  // non-class prvalues always have cv-unqualified types
+  QualType AdjRetType = RetType.getUnqualifiedType();
+  if (RetType->isReferenceType() ||
+  (AdjRetType != S.Context.BoolTy && AdjRetType != S.Context.VoidTy)) {
+S.Diag(AwaitSuspend->getCalleeDecl()->getLocation(),
+   diag::err_await_suspend_invalid_return_type)
+<< RetType;
+S.Diag(Loc, diag::note_coroutine_promise_call_implicitly_required)
+<< AwaitSuspend->getDirectCallee();
+  

[PATCH] D37131: [coroutines] Support coroutine-handle returning await-suspend (i.e symmetric control transfer)

2017-08-24 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov accepted this revision.
GorNishanov added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D37131



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


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 112651.
erichkeane added a comment.

Removed file due to git weirdness.


https://reviews.llvm.org/D37122

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/DiagnosticIDs.h
  lib/Basic/DiagnosticIDs.cpp

Index: lib/Basic/DiagnosticIDs.cpp
===
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -96,18 +96,6 @@
 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
 /// or null if the ID is invalid.
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
-  // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
-#ifndef NDEBUG
-  static bool IsFirst = true; // So the check is only performed on first call.
-  if (IsFirst) {
-assert(std::is_sorted(std::begin(StaticDiagInfo),
-  std::end(StaticDiagInfo)) &&
-   "Diag ID conflict, the enums at the start of clang::diag (in "
-   "DiagnosticIDs.h) probably need to be increased");
-IsFirst = false;
-  }
-#endif
-
   // Out of bounds diag. Can't be in the table.
   using namespace diag;
   if (DiagID >= DIAG_UPPER_LIMIT || DiagID <= DIAG_START_COMMON)
Index: include/clang/Basic/DiagnosticIDs.h
===
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -26,19 +26,32 @@
 
   // Import the diagnostic enums themselves.
   namespace diag {
+// Size of each of the diagnostic categories.
+enum {
+  DIAG_SIZE_COMMON=  300,
+  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_FRONTEND  =  100,
+  DIAG_SIZE_SERIALIZATION =  120,
+  DIAG_SIZE_LEX   =  400,
+  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_COMMENT   =  100,
+  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_ANALYSIS  =  100
+};
 // Start position for diagnostics.
 enum {
-  DIAG_START_COMMON= 0,
-  DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
-  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
-  DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  400,
-  DIAG_START_AST   = DIAG_START_PARSE   +  500,
-  DIAG_START_COMMENT   = DIAG_START_AST +  110,
-  DIAG_START_SEMA  = DIAG_START_COMMENT +  100,
-  DIAG_START_ANALYSIS  = DIAG_START_SEMA+ 3500,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS+  100
+  DIAG_START_COMMON=  0,
+  DIAG_START_DRIVER= DIAG_START_COMMON+ DIAG_SIZE_COMMON,
+  DIAG_START_FRONTEND  = DIAG_START_DRIVER+ DIAG_SIZE_DRIVER,
+  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND  + DIAG_SIZE_FRONTEND,
+  DIAG_START_LEX   = DIAG_START_SERIALIZATION + DIAG_SIZE_SERIALIZATION,
+  DIAG_START_PARSE = DIAG_START_LEX   + DIAG_SIZE_LEX,
+  DIAG_START_AST   = DIAG_START_PARSE + DIAG_SIZE_PARSE,
+  DIAG_START_COMMENT   = DIAG_START_AST   + DIAG_SIZE_AST,
+  DIAG_START_SEMA  = DIAG_START_COMMENT   + DIAG_SIZE_COMMENT,
+  DIAG_START_ANALYSIS  = DIAG_START_SEMA  + DIAG_SIZE_SEMA,
+  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS  + DIAG_SIZE_ANALYSIS
 };
 
 class CustomDiagInfo;
Index: include/clang/Basic/AllDiagnostics.h
===
--- include/clang/Basic/AllDiagnostics.h
+++ include/clang/Basic/AllDiagnostics.h
@@ -32,6 +32,29 @@
 public:
   enum { Size = SizeOfStr };
 };
+
+#define STRINGIFY_NAME(NAME) #NAME
+#define VALIDATE_DIAG_SIZE(NAME)   \
+  static_assert(   \
+  static_cast(diag::NUM_BUILTIN_##NAME##_DIAGNOSTICS) <  \
+  static_cast(diag::DIAG_START_##NAME) + \
+  static_cast(diag::DIAG_SIZE_##NAME),   \
+  STRINGIFY_NAME(  \
+  DIAG_SIZE_##NAME) " is insufficient to contain all " \
+"diagnostics, it may need to be made larger in "   \
+"DiagnosticIDs.h.");
+VALIDATE_DIAG_SIZE(COMMON)
+VALIDATE_DIAG_SIZE(DRIVER)
+VALIDATE_DIAG_SIZE(FRONTEND)
+VALIDATE_DIAG_SIZE(SERIALIZATION)
+VALIDATE_DIAG_SIZE(LEX)
+VALIDATE_DIAG_SIZE(PARSE)
+VALIDATE_DIAG_SIZE(AST)
+VALIDATE_DIAG_SIZE(COMMENT)
+VALIDATE_DIAG_SIZE(SEMA)
+VALIDATE_DIAG_SIZE(ANALYSIS)
+#undef VALIDATE_DIAG_SIZE
+#undef STRINGIFY_NAME
 } // 

r311758 - Rename diagnostic groups from CXX1z to CXX17. No functionality change.

2017-08-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 24 19:39:05 2017
New Revision: 311758

URL: http://llvm.org/viewvc/llvm-project?rev=311758=rev
Log:
Rename diagnostic groups from CXX1z to CXX17. No functionality change.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=311758=311757=311758=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Aug 24 19:39:05 2017
@@ -166,9 +166,9 @@ def NoexceptType : DiagGroup<"noexcept-t
 def CXXPre14Compat : DiagGroup<"c++98-c++11-compat">;
 def CXXPre14CompatPedantic : DiagGroup<"c++98-c++11-compat-pedantic",
[CXXPre14Compat]>;
-def CXXPre1zCompat : DiagGroup<"c++98-c++11-c++14-compat">;
-def CXXPre1zCompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
-   [CXXPre1zCompat]>;
+def CXXPre17Compat : DiagGroup<"c++98-c++11-c++14-compat">;
+def CXXPre17CompatPedantic : DiagGroup<"c++98-c++11-c++14-compat-pedantic",
+   [CXXPre17Compat]>;
 def CXXPre2aCompat : DiagGroup<"c++98-c++11-c++14-c++17-compat">;
 def CXXPre2aCompatPedantic : 
DiagGroup<"c++98-c++11-c++14-c++17-compat-pedantic",
[CXXPre2aCompat]>;
@@ -184,14 +184,14 @@ def CXX98Compat : DiagGroup<"c++98-compa
 [CXX98CompatLocalTypeTemplateArgs,
  CXX98CompatUnnamedTypeTemplateArgs,
  CXXPre14Compat,
- CXXPre1zCompat,
+ CXXPre17Compat,
  CXXPre2aCompat]>;
 // Warnings for C++11 features which are Extensions in C++98 mode.
 def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
 [CXX98Compat,
  CXX98CompatBindToTemporaryCopy,
  CXXPre14CompatPedantic,
- CXXPre1zCompatPedantic,
+ CXXPre17CompatPedantic,
  CXXPre2aCompatPedantic]>;
 
 def CXX11Narrowing : DiagGroup<"c++11-narrowing">;
@@ -217,20 +217,20 @@ def CXX11Compat : DiagGroup<"c++11-compa
  CXX11CompatReservedUserDefinedLiteral,
  CXX11CompatDeprecatedWritableStr,
  CXXPre14Compat,
- CXXPre1zCompat,
+ CXXPre17Compat,
  CXXPre2aCompat]>;
 def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
 def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",
 [CXX11Compat,
  CXXPre14CompatPedantic,
- CXXPre1zCompatPedantic,
+ CXXPre17CompatPedantic,
  CXXPre2aCompatPedantic]>;
 
-def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre1zCompat,
+def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre17Compat,
  CXXPre2aCompat]>;
 def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
 [CXX14Compat,
- CXXPre1zCompatPedantic,
+ CXXPre17CompatPedantic,
  CXXPre2aCompatPedantic]>;
 
 def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister,
@@ -798,7 +798,7 @@ def CXX11 : DiagGroup<"c++11-extensions"
 // earlier C++ versions.
 def CXX14 : DiagGroup<"c++14-extensions", [CXX14BinaryLiteral]>;
 
-// A warning group for warnings about using C++1z features as extensions in
+// A warning group for warnings about using C++17 features as extensions in
 // earlier C++ versions.
 def CXX17 : DiagGroup<"c++17-extensions">;
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=311758=311757=311758=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu Aug 24 19:39:05 2017
@@ -185,7 +185,7 @@ def ext_hex_literal_invalid : Extension<
 def warn_cxx17_hex_literal : Warning<
   "hexadecimal floating literals are incompatible with "
   "C++ standards before C++17">,
-  InGroup, DefaultIgnore;
+  

r311750 - Fix up the -Wc++XX-compat warnings to properly handle C++2a.

2017-08-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 24 19:25:07 2017
New Revision: 311750

URL: http://llvm.org/viewvc/llvm-project?rev=311750=rev
Log:
Fix up the -Wc++XX-compat warnings to properly handle C++2a.

Added:
cfe/trunk/test/SemaCXX/cxx17-compat.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=311750=311749=311750=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Aug 24 19:25:07 2017
@@ -184,13 +184,15 @@ def CXX98Compat : DiagGroup<"c++98-compa
 [CXX98CompatLocalTypeTemplateArgs,
  CXX98CompatUnnamedTypeTemplateArgs,
  CXXPre14Compat,
- CXXPre1zCompat]>;
+ CXXPre1zCompat,
+ CXXPre2aCompat]>;
 // Warnings for C++11 features which are Extensions in C++98 mode.
 def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
 [CXX98Compat,
  CXX98CompatBindToTemporaryCopy,
  CXXPre14CompatPedantic,
- CXXPre1zCompatPedantic]>;
+ CXXPre1zCompatPedantic,
+ CXXPre2aCompatPedantic]>;
 
 def CXX11Narrowing : DiagGroup<"c++11-narrowing">;
 
@@ -215,22 +217,34 @@ def CXX11Compat : DiagGroup<"c++11-compa
  CXX11CompatReservedUserDefinedLiteral,
  CXX11CompatDeprecatedWritableStr,
  CXXPre14Compat,
- CXXPre1zCompat]>;
+ CXXPre1zCompat,
+ CXXPre2aCompat]>;
 def : DiagGroup<"c++0x-compat", [CXX11Compat]>;
 def CXX11CompatPedantic : DiagGroup<"c++11-compat-pedantic",
-[CXXPre14CompatPedantic,
- CXXPre1zCompatPedantic]>;
+[CXX11Compat,
+ CXXPre14CompatPedantic,
+ CXXPre1zCompatPedantic,
+ CXXPre2aCompatPedantic]>;
 
-def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre1zCompat]>;
+def CXX14Compat : DiagGroup<"c++14-compat", [CXXPre1zCompat,
+ CXXPre2aCompat]>;
 def CXX14CompatPedantic : DiagGroup<"c++14-compat-pedantic",
-[CXXPre1zCompatPedantic]>;
+[CXX14Compat,
+ CXXPre1zCompatPedantic,
+ CXXPre2aCompatPedantic]>;
 
 def CXX17Compat : DiagGroup<"c++17-compat", [DeprecatedRegister,
  DeprecatedIncrementBool,
- CXX17CompatMangling]>;
+ CXX17CompatMangling,
+ CXXPre2aCompat]>;
+def CXX17CompatPedantic : DiagGroup<"c++17-compat-pedantic",
+[CXX17Compat,
+ CXXPre2aCompatPedantic]>;
 def : DiagGroup<"c++1z-compat", [CXX17Compat]>;
 
 def CXX2aCompat : DiagGroup<"c++2a-compat">;
+def CXX2aCompatPedantic : DiagGroup<"c++2a-compat-pedantic",
+[CXX2aCompat]>;
 
 def ExitTimeDestructors : DiagGroup<"exit-time-destructors">;
 def FlexibleArrayExtensions : DiagGroup<"flexible-array-extensions">;

Added: cfe/trunk/test/SemaCXX/cxx17-compat.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx17-compat.cpp?rev=311750=auto
==
--- cfe/trunk/test/SemaCXX/cxx17-compat.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx17-compat.cpp Thu Aug 24 19:25:07 2017
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++2a -Wc++17-compat-pedantic -verify %s
+
+struct A {};
+int (A::*pa)() const&;
+int use_pa = (A().*pa)();
+#if __cplusplus <= 201703L
+  // expected-warning@-2 {{invoking a pointer to a 'const &' member function 
on an rvalue is a C++2a extension}}
+#else
+  // expected-warning@-4 {{invoking a pointer to a 'const &' member function 
on an rvalue is incompatible with C++ standards before C++2a}}
+#endif
+
+struct B {
+  void b() {
+(void) [=, this] {};
+#if __cplusplus <= 201703L
+// expected-warning@-2 {{explicit capture of 'this' with a capture default 
of '=' is a C++2a extension}}
+#else
+// expected-warning@-4 {{explicit capture of 

Re: r311695 - [ubsan] PR34266: When sanitizing the 'this' value for a member function that happens to be a lambda call operator, use the lambda's 'this' pointer, not the captured enclosing 'this' poin

2017-08-24 Thread Richard Smith via cfe-commits
Hi Hans,

This fixes a regression in ubsan's handling of lambda expressions. Seems
like a reasonable candidate for Clang 5, but it is rather late in the day...

On 24 August 2017 at 13:10, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Thu Aug 24 13:10:33 2017
> New Revision: 311695
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311695=rev
> Log:
> [ubsan] PR34266: When sanitizing the 'this' value for a member function
> that happens to be a lambda call operator, use the lambda's 'this' pointer,
> not the captured enclosing 'this' pointer (if any).
>
> Do not sanitize the 'this' pointer of a member call operator for a lambda
> with
> no capture-default, since that call operator can legitimately be called
> with a
> null this pointer from the static invoker function. Any actual call with a
> null
> this pointer should still be caught in the caller (if it is being
> sanitized).
>
> This reinstates r311589 (reverted in r311680) with the above fix.
>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclCXX.h?rev=311695=311694=311695=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Aug 24 13:10:33 2017
> @@ -2027,7 +2027,10 @@ public:
>
>/// \brief Returns the type of the \c this pointer.
>///
> -  /// Should only be called for instance (i.e., non-static) methods.
> +  /// Should only be called for instance (i.e., non-static) methods. Note
> +  /// that for the call operator of a lambda closure type, this returns
> the
> +  /// desugared 'this' type (a pointer to the closure type), not the
> captured
> +  /// 'this' type.
>QualType getThisType(ASTContext ) const;
>
>unsigned getTypeQualifiers() const {
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CodeGenFunction.cpp?rev=311695=311694=311695=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Aug 24 13:10:33 2017
> @@ -22,6 +22,7 @@
>  #include "CodeGenPGO.h"
>  #include "TargetInfo.h"
>  #include "clang/AST/ASTContext.h"
> +#include "clang/AST/ASTLambda.h"
>  #include "clang/AST/Decl.h"
>  #include "clang/AST/DeclCXX.h"
>  #include "clang/AST/StmtCXX.h"
> @@ -1014,11 +1015,22 @@ void CodeGenFunction::StartFunction(Glob
>  }
>
>  // Check the 'this' pointer once per function, if it's available.
> -if (CXXThisValue) {
> +if (CXXABIThisValue) {
>SanitizerSet SkippedChecks;
>SkippedChecks.set(SanitizerKind::ObjectSize, true);
>QualType ThisTy = MD->getThisType(getContext());
> -  EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,
> +
> +  // If this is the call operator of a lambda with no
> capture-default, it
> +  // may have a static invoker function, which may call this operator
> with
> +  // a null 'this' pointer.
> +  if (isLambdaCallOperator(MD) &&
> +  cast(MD->getParent())->getLambdaCaptureDefault()
> ==
> +  LCD_None)
> +SkippedChecks.set(SanitizerKind::Null, true);
> +
> +  EmitTypeCheck(isa(MD) ? TCK_ConstructorCall
> +: TCK_MemberCall,
> +Loc, CXXABIThisValue, ThisTy,
>  getContext().getTypeAlignInChars(ThisTy->
> getPointeeType()),
>  SkippedChecks);
>  }
>
> Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/catch-undef-behavior.cpp?rev=311695=
> 311694=311695=diff
> 
> ==
> --- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Thu Aug 24
> 13:10:33 2017
> @@ -449,6 +449,28 @@ void upcast_to_vbase() {
>  }
>  }
>
> +struct ThisAlign {
> +  void this_align_lambda();
> +  void this_align_lambda_2();
> +};
> +void ThisAlign::this_align_lambda() {
> +  // CHECK-LABEL: define {{.*}}@"_ZZN9ThisAlign17this_
> align_lambdaEvENK3$_0clEv"
> +  // CHECK-SAME: (%{{.*}}* %[[this:[^)]*]])
> +  // CHECK: %[[this_addr:.*]] = alloca
> +  // CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],
> +  // CHECK: %[[this_inner:.*]] = load %{{.*}}*, %{{.*}}** %[[this_addr]],
> +  // CHECK: %[[this_outer_addr:.*]] = getelementptr inbounds %{{.*}},
> %{{.*}}* %[[this_inner]], i32 0, i32 0
> +  // CHECK: %[[this_outer:.*]] = load %{{.*}}*, %{{.*}}**
> %[[this_outer_addr]],
> +  //
> +  

[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2017-08-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:3851
+ ->getType()
+ ->getPointerAddressSpace();
 const unsigned ArgAddrSpace =

yaxunl wrote:
> rjmccall wrote:
> > Hmm.  Is there actually a test case where Addr.getType()->getAddressSpace() 
> > is not the lowering of LangAS::Default?  The correctness of the 
> > performAddrSpaceCast call you make depends on that.
> > 
> > If there isn't, I think it would be better to add a target hook to attempt 
> > to peephole an addrspace cast:
> >   llvm::Value *tryPeepholeAddrSpaceCast(llvm::Value*, unsigned valueAS, 
> > unsigned targetAS);
> > 
> > And then you can just do
> >   bool HasAddrSpaceMismatch = CGM.getASTAllocaAddrSpace() != 
> > LangAS::Default);
> >   if (HasAddrSpaceMismatch) {
> > if (llvm::Value *ptr = tryPeepholeAddrSpaceCast(Addr.getPointer(), 
> > LangAS::Default, getASTAllocAddrSpace())) {
> >   Addr = Address(ptr, Addr.getAlignment()); // might need to cast the 
> > element type for this
> >   HasAddrSpaceMismatch = false;
> > }
> >   }
> It is possible RVAddrSpace is not default addr space. e.g. in OpenCL
> 
> ```
> global struct S g_s;
> 
> void f(struct S s);
> 
> void g() {
>   f(g_s);
> }
> 
> ```
> 
> One thing that confuses me is that why creating temp and copying can be 
> skipped if RVAddrSpace equals alloca addr space. The callee is supposed to 
> work on a copy of the arg, not the arg itself, right? Shouldn't the arg 
> always be coped to a temp then pass to the callee?
The result of emitting an agg expression should already be a temporary.  All 
sorts of things would be broken if it we still had a direct reference to g_s 
when we got here.


https://reviews.llvm.org/D34367



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


r311746 - Fix MSVC bots which include '__attribute__((thiscall))' in pretty-printed member function types.

2017-08-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 24 18:55:50 2017
New Revision: 311746

URL: http://llvm.org/viewvc/llvm-project?rev=311746=rev
Log:
Fix MSVC bots which include '__attribute__((thiscall))' in pretty-printed 
member function types.

We really shouldn't be including inferred calling conventions here, but let's 
get the bots green first...

Modified:
cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp

Modified: cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp?rev=311746=311745=311746=diff
==
--- cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp Thu Aug 24 
18:55:50 2017
@@ -9,6 +9,6 @@ void test() {
   X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' 
with an expression of type 'X'}}
   X{}.cref(); // expected-no-error
 
-  (X{}.*::ref)(); // expected-error{{pointer-to-member function type 'void 
(X::*)() &' can only be called on an lvalue}}
+  (X{}.*::ref)(); // expected-error-re{{pointer-to-member function type 
'void (X::*)() {{.*}}&' can only be called on an lvalue}}
   (X{}.*::cref)(); // expected-no-error
 }


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


[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

2017-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith closed this revision.
rsmith added a comment.

Committed as r311744.


https://reviews.llvm.org/D36855



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


r311744 - [c++2a] P0704R1: Allow pointers to const& member functions to be called on rvalues.

2017-08-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 24 18:47:55 2017
New Revision: 311744

URL: http://llvm.org/viewvc/llvm-project?rev=311744=rev
Log:
[c++2a] P0704R1: Allow pointers to const& member functions to be called on 
rvalues.

Patch by Blitz Rakete!

Added:
cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/www/cxx_status.html

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=311744=311743=311744=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Aug 24 18:47:55 
2017
@@ -4088,6 +4088,13 @@ def err_pointer_to_member_call_drops_qua
 def err_pointer_to_member_oper_value_classify: Error<
   "pointer-to-member function type %0 can only be called on an "
   "%select{rvalue|lvalue}1">;
+def ext_pointer_to_const_ref_member_on_rvalue : Extension<
+  "invoking a pointer to a 'const &' member function on an rvalue is a C++2a 
extension">,
+  InGroup, SFINAEFailure;
+def warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue : Warning<
+  "invoking a pointer to a 'const &' member function on an rvalue is "
+  "incompatible with C++ standards before C++2a">,
+  InGroup, DefaultIgnore;
 def ext_ms_deref_template_argument: ExtWarn<
   "non-type template argument containing a dereference operation is a "
   "Microsoft extension">, InGroup;

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=311744=311743=311744=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Thu Aug 24 18:47:55 2017
@@ -5175,9 +5175,16 @@ QualType Sema::CheckPointerToMemberOpera
   break;
 
 case RQ_LValue:
-  if (!isIndirect && !LHS.get()->Classify(Context).isLValue())
-Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
-  << RHSType << 1 << LHS.get()->getSourceRange();
+  if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
+// C++2a allows functions with ref-qualifier & if they are also 
'const'.
+if (Proto->isConst())
+  Diag(Loc, getLangOpts().CPlusPlus2a
+? 
diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
+: diag::ext_pointer_to_const_ref_member_on_rvalue);
+else
+  Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
+  << RHSType << 1 << LHS.get()->getSourceRange();
+  }
   break;
 
 case RQ_RValue:

Added: cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp?rev=311744=auto
==
--- cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp (added)
+++ cfe/trunk/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp Thu Aug 24 
18:47:55 2017
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++2a %s -verify
+
+struct X {
+  void ref() & {}
+  void cref() const& {}
+};
+
+void test() {
+  X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' 
with an expression of type 'X'}}
+  X{}.cref(); // expected-no-error
+
+  (X{}.*::ref)(); // expected-error{{pointer-to-member function type 'void 
(X::*)() &' can only be called on an lvalue}}
+  (X{}.*::cref)(); // expected-no-error
+}

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=311744=311743=311744=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Thu Aug 24 18:47:55 2017
@@ -802,7 +802,7 @@ as the draft C++2a standard evolves.
 
   const-qualified pointers to members
   http://wg21.link/p0704r1;>P0704R1
-  No
+  SVN
 
 
   Allow lambda-capture [=, this]


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


[PATCH] D36855: Fixed pointer to const& member function on rvalues, P0704r1

2017-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Sorry for the delay, this looks good to me.


https://reviews.llvm.org/D36855



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


[PATCH] D36806: Switch to cantFail(), since it does the same assertion.

2017-08-24 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

Any other comments?


https://reviews.llvm.org/D36806



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


[PATCH] D36501: Add flag to request Clang is ABI-compatible with older versions of itself

2017-08-24 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

I'm not familiar with the details of the ABI changes, but the mechanics of the 
code look good to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D36501



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


[PATCH] D36720: [libc++] Prevent stale site configuration headers

2017-08-24 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Ping.


https://reviews.llvm.org/D36720



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


[PATCH] D36719: [libc++] Add site config option for ABI macros

2017-08-24 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Ping.


https://reviews.llvm.org/D36719



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


[PATCH] D36713: [libc++] Add a persistent way to disable availability

2017-08-24 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Ping.


https://reviews.llvm.org/D36713



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


Re: r311683 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Stephen Hines via cfe-commits
Ah, sorry I had to run off for a meeting. Yes, I was able to finally fix
this. For anyone else who hits it, you can "git reset --hard" back to the
CL before the initial change. Then you can "git pull" to move past the
issue. Thanks for fixing this.

Steve

On Thu, Aug 24, 2017 at 4:35 PM, Keane, Erich  wrote:

> Alright, final update.  Thanks to some fantastic help on #llvm, I believe
> this is fixed.
>
>
>
> Stephen: You may have to do some shenanigans to fix your local stuff, but
> the monorepo and another repo both seem to work.  Sorry for this everyone :/
>
>
>
> *From:* Stephen Hines [mailto:srhi...@google.com]
> *Sent:* Thursday, August 24, 2017 3:18 PM
> *To:* Keane, Erich 
> *Cc:* cfe-commits 
> *Subject:* Re: r311683 - [Preprocessor] Correct internal token parsing of
> newline characters in CRLF
>
>
>
> This change seems to have broken the git mirrors, as I can no longer check
> out clang without having a merge conflict as git alters the line endings.
> Setting core.autocrlf to false doesn't help either. Does anyone have any
> idea how to fix this svn <-> git issue?
>
>
>
> Thanks,
>
> Steve
>
>
>
> On Thu, Aug 24, 2017 at 11:36 AM, Erich Keane via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: erichkeane
> Date: Thu Aug 24 11:36:07 2017
> New Revision: 311683
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311683=rev
> Log:
> [Preprocessor] Correct internal token parsing of newline characters in CRLF
>
> Discovered due to a goofy git setup, the test system-headerline-directive.c
> (and a few others) failed because the token-consumption will consume only
> the
> '\r' in CRLF, making the preprocessor's printed value give the wrong line
> number
> when returning from an include. For example:
>
> (line 1):#include \r\n
>
> The "file exit" code causes the printer to try to print the 'returned to
> the
> main file' line. It looks up what the current line number is. However,
> since the
> current 'token' is the '\n' (since only the \r was consumed), it will give
> the
> line number as '1", not '2'. This results in a few failed tests, but more
> importantly, results in error messages being incorrect when compiling a
> previously preprocessed file.
>
> Differential Revision: https://reviews.llvm.org/D37079
>
> Added:
> cfe/trunk/test/Frontend/.gitattributes
> cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
>  (with props)
> Modified:
> cfe/trunk/lib/Lex/Lexer.cpp
>
> Modified: cfe/trunk/lib/Lex/Lexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/
> Lexer.cpp?rev=311683=311682=311683=diff
> 
> ==
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
> +++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 24 11:36:07 2017
> @@ -3073,6 +3073,8 @@ LexNextToken:
>
>case '\n':
>case '\r':
> +if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
> +  Char = getAndAdvanceChar(CurPtr, Result);
>  // If we are inside a preprocessor directive and we see the end of
> line,
>  // we know we are done with the directive, so return an EOD token.
>  if (ParsingPreprocessorDirective) {
>
> Added: cfe/trunk/test/Frontend/.gitattributes
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Frontend/.gitattributes?rev=311683=auto
> 
> ==
> --- cfe/trunk/test/Frontend/.gitattributes (added)
> +++ cfe/trunk/test/Frontend/.gitattributes Thu Aug 24 11:36:07 2017
> @@ -0,0 +1,2 @@
> +# Below test validates crlf line endings, so it should stay crlf.
> +system-header-line-directive-ms-lineendings.c text eol=crlf
>
> Added: cfe/trunk/test/Frontend/system-header-line-directive-
> ms-lineendings.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Frontend/system-header-line-directive-ms-lineendings.c?
> rev=311683=auto
> 
> ==
> --- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
> (added)
> +++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
> Thu Aug 24 11:36:07 2017
> @@ -0,0 +1,21 @@
> +// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem
> %S/Inputs/SystemHeaderPrefix | FileCheck %s
> +#include 
> +#include 
> +
> +#include "line-directive.h"
> +
> +// This tests that the line numbers for the current file are correctly
> outputted
> +// for the include-file-completed test case.
> +
> +// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}noline.h" 1 3
> +// CHECK: foo();
> +// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
> +//  The "3" below indicates that "foo.h" is considered a system
> header.
> +// CHECK: # 1 "foo.h" 3
> +// CHECK: foo();
> +// CHECK: # 4 

RE: r311683 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Keane, Erich via cfe-commits
Alright, final update.  Thanks to some fantastic help on #llvm, I believe this 
is fixed.

Stephen: You may have to do some shenanigans to fix your local stuff, but the 
monorepo and another repo both seem to work.  Sorry for this everyone :/

From: Stephen Hines [mailto:srhi...@google.com]
Sent: Thursday, August 24, 2017 3:18 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r311683 - [Preprocessor] Correct internal token parsing of newline 
characters in CRLF

This change seems to have broken the git mirrors, as I can no longer check out 
clang without having a merge conflict as git alters the line endings. Setting 
core.autocrlf to false doesn't help either. Does anyone have any idea how to 
fix this svn <-> git issue?

Thanks,
Steve

On Thu, Aug 24, 2017 at 11:36 AM, Erich Keane via cfe-commits 
> wrote:
Author: erichkeane
Date: Thu Aug 24 11:36:07 2017
New Revision: 311683

URL: http://llvm.org/viewvc/llvm-project?rev=311683=rev
Log:
[Preprocessor] Correct internal token parsing of newline characters in CRLF

Discovered due to a goofy git setup, the test system-headerline-directive.c
(and a few others) failed because the token-consumption will consume only the
'\r' in CRLF, making the preprocessor's printed value give the wrong line number
when returning from an include. For example:

(line 1):#include \r\n

The "file exit" code causes the printer to try to print the 'returned to the
main file' line. It looks up what the current line number is. However, since the
current 'token' is the '\n' (since only the \r was consumed), it will give the
line number as '1", not '2'. This results in a few failed tests, but more
importantly, results in error messages being incorrect when compiling a
previously preprocessed file.

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

Added:
cfe/trunk/test/Frontend/.gitattributes
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c   
(with props)
Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=311683=311682=311683=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 24 11:36:07 2017
@@ -3073,6 +3073,8 @@ LexNextToken:

   case '\n':
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {

Added: cfe/trunk/test/Frontend/.gitattributes
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/.gitattributes?rev=311683=auto
==
--- cfe/trunk/test/Frontend/.gitattributes (added)
+++ cfe/trunk/test/Frontend/.gitattributes Thu Aug 24 11:36:07 2017
@@ -0,0 +1,2 @@
+# Below test validates crlf line endings, so it should stay crlf.
+system-header-line-directive-ms-lineendings.c text eol=crlf

Added: cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c?rev=311683=auto
==
--- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c 
(added)
+++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c Thu 
Aug 24 11:36:07 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem 
%S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly 
outputted
+// for the include-file-completed test case.
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2

Propchange: 
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
--
svn:eol-style = CRLF


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r311732 - Remove .gitattributes, add comment to lineendings.

2017-08-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Aug 24 16:25:05 2017
New Revision: 311732

URL: http://llvm.org/viewvc/llvm-project?rev=311732=rev
Log:
Remove .gitattributes, add comment to lineendings.

Removed:
cfe/trunk/test/Frontend/.gitattributes
Modified:
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c

Removed: cfe/trunk/test/Frontend/.gitattributes
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/.gitattributes?rev=311731=auto
==
--- cfe/trunk/test/Frontend/.gitattributes (original)
+++ cfe/trunk/test/Frontend/.gitattributes (removed)
@@ -1,2 +0,0 @@
-# Below test validates crlf line endings, so it should stay crlf.
-system-header-line-directive-ms-lineendings.c text eol=crlf

Modified: cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c?rev=311732=311731=311732=diff
==
--- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c 
(original)
+++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c Thu 
Aug 24 16:25:05 2017
@@ -5,7 +5,7 @@
 #include "line-directive.h"
 
 // This tests that the line numbers for the current file are correctly 
outputted
-// for the include-file-completed test case.  
+// for the include-file-completed test case. This file should be CRLF.
 
 // CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
 // CHECK: # 1 "{{.*}}noline.h" 1 3


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


[PATCH] D36501: Add flag to request Clang is ABI-compatible with older versions of itself

2017-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 112634.
rsmith retitled this revision from "add flag to undo ABI change in r310401" to 
"Add flag to request Clang is ABI-compatible with older versions of itself".
rsmith edited the summary of this revision.
Herald added a subscriber: srhines.

Repository:
  rL LLVM

https://reviews.llvm.org/D36501

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/ABIInfo.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/CodeGenTypes.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/clang-abi-compat.cpp
  test/CodeGenCXX/uncopyable-args.cpp
  test/Driver/flags.c
  test/Frontend/clang-abi-compat.cpp

Index: test/Frontend/clang-abi-compat.cpp
===
--- test/Frontend/clang-abi-compat.cpp
+++ test/Frontend/clang-abi-compat.cpp
@@ -0,0 +1,15 @@
+// RUN: not %clang_cc1 -fclang-abi-compat=banana %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: not %clang_cc1 -fclang-abi-compat=2.9 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: not %clang_cc1 -fclang-abi-compat=8 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: not %clang_cc1 -fclang-abi-compat=3.10 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: not %clang_cc1 -fclang-abi-compat=4.1 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: not %clang_cc1 -fclang-abi-compat=04 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: not %clang_cc1 -fclang-abi-compat=4. %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: not %clang_cc1 -fclang-abi-compat=4.00 %s -fsyntax-only 2>&1 | FileCheck --check-prefix=INVALID %s
+// INVALID: error: invalid value '{{.*}}' in '-fclang-abi-compat={{.*}}'
+//
+// RUN: %clang_cc1 -fclang-abi-compat=3.0 %s -fsyntax-only
+// RUN: %clang_cc1 -fclang-abi-compat=3.9 %s -fsyntax-only
+// RUN: %clang_cc1 -fclang-abi-compat=4 %s -fsyntax-only
+// RUN: %clang_cc1 -fclang-abi-compat=4.0 %s -fsyntax-only
+// RUN: %clang_cc1 -fclang-abi-compat=latest %s -fsyntax-only
Index: test/Driver/flags.c
===
--- test/Driver/flags.c
+++ test/Driver/flags.c
@@ -24,3 +24,6 @@
 
 // RUN: %clang -target armv7-apple-darwin10 -### -S -mno-implicit-float -mimplicit-float %s 2>&1 | FileCheck -check-prefix=TEST8 %s
 // TEST8-NOT: "-no-implicit-float"
+
+// RUN: %clang -target x86_64-linux-gnu -### -c -fclang-abi-compat=3.2 %s 2>&1 | FileCheck -check-prefix=TEST9 %s
+// TEST9: "-fclang-abi-compat=3.2"
Index: test/CodeGenCXX/uncopyable-args.cpp
===
--- test/CodeGenCXX/uncopyable-args.cpp
+++ test/CodeGenCXX/uncopyable-args.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=NEWABI
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=OLDABI
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-scei-ps4 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=OLDABI
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -emit-llvm -o - %s -fms-compatibility -fms-compatibility-version=18 | FileCheck %s -check-prefix=WIN64 -check-prefix=WIN64-18
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-msvc -emit-llvm -o - %s -fms-compatibility -fms-compatibility-version=19 | FileCheck %s -check-prefix=WIN64 -check-prefix=WIN64-19
 
@@ -56,8 +58,10 @@
 // CHECK-LABEL: define void @_ZN9move_ctor3barEv()
 // CHECK: call void @_Z{{.*}}C1Ev(
 // CHECK-NOT: call
-// CHECK: call void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"* %{{.*}})
-// CHECK-LABEL: declare void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"*)
+// NEWABI: call void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"* %{{.*}})
+// OLDABI: call void @_ZN9move_ctor3fooENS_1AE(i8* %{{.*}})
+// NEWABI-LABEL: declare void @_ZN9move_ctor3fooENS_1AE(%"struct.move_ctor::A"*)
+// OLDABI-LABEL: declare void @_ZN9move_ctor3fooENS_1AE(i8*)
 
 // WIN64-LABEL: declare void @"\01?foo@move_ctor@@YAXUA@1@@Z"(%"struct.move_ctor::A"*)
 }
@@ -76,8 +80,10 @@
 // CHECK-LABEL: define void @_ZN11all_deleted3barEv()
 // CHECK: call void @_Z{{.*}}C1Ev(
 // CHECK-NOT: call
-// CHECK: call void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"* %{{.*}})
-// CHECK-LABEL: declare void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"*)
+// NEWABI: call void @_ZN11all_deleted3fooENS_1AE(%"struct.all_deleted::A"* %{{.*}})
+// OLDABI: call void @_ZN11all_deleted3fooENS_1AE(i8* %{{.*}})
+// NEWABI-LABEL: declare 

[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D37122#852018, @rnk wrote:

> In https://reviews.llvm.org/D37122#851978, @erichkeane wrote:
>
> > Ugg... disregard the system-header-line-directive-ms-lineendings.c issue, 
> > I'm going to try to figure that out
>
>
> Yeah, I'm seeing issues with that as well. I'm not sure what's up.


I'm trying to research it... Some people (Stephen Hines & I) are having this 
issue with the git mirror, but others (CraigT) are not for some reason.  There 
is a cfe-dev discussion started by Stephen, but I've really got no idea whats 
wrong.


https://reviews.llvm.org/D37122



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


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D37122#851978, @erichkeane wrote:

> Ugg... disregard the system-header-line-directive-ms-lineendings.c issue, I'm 
> going to try to figure that out


Yeah, I'm seeing issues with that as well. I'm not sure what's up.


https://reviews.llvm.org/D37122



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


[PATCH] D36386: [clang] Remove unit test which uses reverse-iterate flag

2017-08-24 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

In https://reviews.llvm.org/D36386#851853, @dblaikie wrote:

> sounds good - so long as other tests would fail if the fix this test was 
> testing wasn't present (on a reverse iteration enabled build)


Thanks! Yes, I verified that the test objc-modern-metadata-visibility.mm would 
fail in a reverse iteration build w/o the fix this was testing.


Repository:
  rL LLVM

https://reviews.llvm.org/D36386



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


RE: r311683 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Keane, Erich via cfe-commits
1 more dataset, Craig has the git mirror working right, but with the public 
mirror…

From: Stephen Hines [mailto:srhi...@google.com]
Sent: Thursday, August 24, 2017 3:18 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r311683 - [Preprocessor] Correct internal token parsing of newline 
characters in CRLF

This change seems to have broken the git mirrors, as I can no longer check out 
clang without having a merge conflict as git alters the line endings. Setting 
core.autocrlf to false doesn't help either. Does anyone have any idea how to 
fix this svn <-> git issue?

Thanks,
Steve

On Thu, Aug 24, 2017 at 11:36 AM, Erich Keane via cfe-commits 
> wrote:
Author: erichkeane
Date: Thu Aug 24 11:36:07 2017
New Revision: 311683

URL: http://llvm.org/viewvc/llvm-project?rev=311683=rev
Log:
[Preprocessor] Correct internal token parsing of newline characters in CRLF

Discovered due to a goofy git setup, the test system-headerline-directive.c
(and a few others) failed because the token-consumption will consume only the
'\r' in CRLF, making the preprocessor's printed value give the wrong line number
when returning from an include. For example:

(line 1):#include \r\n

The "file exit" code causes the printer to try to print the 'returned to the
main file' line. It looks up what the current line number is. However, since the
current 'token' is the '\n' (since only the \r was consumed), it will give the
line number as '1", not '2'. This results in a few failed tests, but more
importantly, results in error messages being incorrect when compiling a
previously preprocessed file.

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

Added:
cfe/trunk/test/Frontend/.gitattributes
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c   
(with props)
Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=311683=311682=311683=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 24 11:36:07 2017
@@ -3073,6 +3073,8 @@ LexNextToken:

   case '\n':
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {

Added: cfe/trunk/test/Frontend/.gitattributes
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/.gitattributes?rev=311683=auto
==
--- cfe/trunk/test/Frontend/.gitattributes (added)
+++ cfe/trunk/test/Frontend/.gitattributes Thu Aug 24 11:36:07 2017
@@ -0,0 +1,2 @@
+# Below test validates crlf line endings, so it should stay crlf.
+system-header-line-directive-ms-lineendings.c text eol=crlf

Added: cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c?rev=311683=auto
==
--- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c 
(added)
+++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c Thu 
Aug 24 11:36:07 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem 
%S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly 
outputted
+// for the include-file-completed test case.
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2

Propchange: 
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
--
svn:eol-style = CRLF


___
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

r311720 - [clang] Remove unit test which uses reverse-iterate flag

2017-08-24 Thread Mandeep Singh Grang via cfe-commits
Author: mgrang
Date: Thu Aug 24 15:40:32 2017
New Revision: 311720

URL: http://llvm.org/viewvc/llvm-project?rev=311720=rev
Log:
[clang] Remove unit test which uses reverse-iterate flag

Summary: This patch is in response to https://reviews.llvm.org/D35043 which 
removed -reverse-iterate flag.

Reviewers: dblaikie, mehdi_amini

Reviewed By: dblaikie

Subscribers: cfe-commits, llvm-commits

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

Removed:
cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm

Removed: cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm?rev=311719=auto
==
--- cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm (original)
+++ cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm (removed)
@@ -1,45 +0,0 @@
-// REQUIRES: abi-breaking-checks
-// NOTE: This test has been split from objc-modern-metadata-visibility.mm in
-// order to test with -reverse-iterate as this flag is only present with
-// ABI_BREAKING_CHECKS.
-
-// RUN: %clang_cc1 -E %s -o %t.mm -mllvm -reverse-iterate
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc 
%t.mm -mllvm -reverse-iterate -o - | FileCheck %s
-// rdar://11144048
-
-@class NSString;
-
-@interface NSObject {
-Class isa;
-}
-@end
-
-@interface Sub : NSObject {
-int subIvar;
-NSString *nsstring;
-@private
-id PrivateIvar;
-}
-@end
-
-@implementation Sub
-- (id) MyNSString { return subIvar ? PrivateIvar : nsstring; }
-@end
-
-@interface NSString @end
-@implementation NSString @end
-
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$subIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long 
OBJC_IVAR_$_Sub$PrivateIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$nsstring;
-// CHECK: #pragma warning(disable:4273)
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$subIvar
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$nsstring
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long int 
OBJC_IVAR_$_Sub$PrivateIvar
-// CHECK: extern "C" __declspec(dllimport) struct _class_t 
OBJC_METACLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_Sub
-// CHECK: extern "C" __declspec(dllimport) struct _class_t 
OBJC_CLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_Sub
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 
OBJC_CLASS_$_NSString;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 
OBJC_METACLASS_$_NSString
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 
OBJC_CLASS_$_NSString


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


[PATCH] D36386: [clang] Remove unit test which uses reverse-iterate flag

2017-08-24 Thread Mandeep Singh Grang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311720: [clang] Remove unit test which uses reverse-iterate 
flag (authored by mgrang).

Changed prior to commit:
  https://reviews.llvm.org/D36386?vs=111557=112624#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D36386

Files:
  cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm


Index: cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm
===
--- cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm
+++ cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm
@@ -1,45 +0,0 @@
-// REQUIRES: abi-breaking-checks
-// NOTE: This test has been split from objc-modern-metadata-visibility.mm in
-// order to test with -reverse-iterate as this flag is only present with
-// ABI_BREAKING_CHECKS.
-
-// RUN: %clang_cc1 -E %s -o %t.mm -mllvm -reverse-iterate
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc 
%t.mm -mllvm -reverse-iterate -o - | FileCheck %s
-// rdar://11144048
-
-@class NSString;
-
-@interface NSObject {
-Class isa;
-}
-@end
-
-@interface Sub : NSObject {
-int subIvar;
-NSString *nsstring;
-@private
-id PrivateIvar;
-}
-@end
-
-@implementation Sub
-- (id) MyNSString { return subIvar ? PrivateIvar : nsstring; }
-@end
-
-@interface NSString @end
-@implementation NSString @end
-
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$subIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long 
OBJC_IVAR_$_Sub$PrivateIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$nsstring;
-// CHECK: #pragma warning(disable:4273)
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$subIvar
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
__declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$nsstring
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long int 
OBJC_IVAR_$_Sub$PrivateIvar
-// CHECK: extern "C" __declspec(dllimport) struct _class_t 
OBJC_METACLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_Sub
-// CHECK: extern "C" __declspec(dllimport) struct _class_t 
OBJC_CLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_Sub
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 
OBJC_CLASS_$_NSString;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 
OBJC_METACLASS_$_NSString
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 
OBJC_CLASS_$_NSString


Index: cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm
===
--- cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm
+++ cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm
@@ -1,45 +0,0 @@
-// REQUIRES: abi-breaking-checks
-// NOTE: This test has been split from objc-modern-metadata-visibility.mm in
-// order to test with -reverse-iterate as this flag is only present with
-// ABI_BREAKING_CHECKS.
-
-// RUN: %clang_cc1 -E %s -o %t.mm -mllvm -reverse-iterate
-// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -mllvm -reverse-iterate -o - | FileCheck %s
-// rdar://11144048
-
-@class NSString;
-
-@interface NSObject {
-Class isa;
-}
-@end
-
-@interface Sub : NSObject {
-int subIvar;
-NSString *nsstring;
-@private
-id PrivateIvar;
-}
-@end
-
-@implementation Sub
-- (id) MyNSString { return subIvar ? PrivateIvar : nsstring; }
-@end
-
-@interface NSString @end
-@implementation NSString @end
-
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$subIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long OBJC_IVAR_$_Sub$PrivateIvar;
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$nsstring;
-// CHECK: #pragma warning(disable:4273)
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$subIvar
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$nsstring
-// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long int OBJC_IVAR_$_Sub$PrivateIvar
-// CHECK: extern "C" __declspec(dllimport) struct _class_t OBJC_METACLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_METACLASS_$_Sub
-// CHECK: extern "C" __declspec(dllimport) struct _class_t OBJC_CLASS_$_NSObject;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_Sub
-// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_NSString;
-// CHECK: extern "C" __declspec(dllexport) struct _class_t 

r311719 - [sanitizer-coverage] document -fsanitize-coverage=pc-table and -fsanitize-coverage=inline-8bit-counters

2017-08-24 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Thu Aug 24 15:40:03 2017
New Revision: 311719

URL: http://llvm.org/viewvc/llvm-project?rev=311719=rev
Log:
[sanitizer-coverage] document -fsanitize-coverage=pc-table and 
-fsanitize-coverage=inline-8bit-counters

Modified:
cfe/trunk/docs/SanitizerCoverage.rst

Modified: cfe/trunk/docs/SanitizerCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerCoverage.rst?rev=311719=311718=311719=diff
==
--- cfe/trunk/docs/SanitizerCoverage.rst (original)
+++ cfe/trunk/docs/SanitizerCoverage.rst Thu Aug 24 15:40:03 2017
@@ -119,6 +119,51 @@ Example:
   guard: 0x71bcdc 4 PC 0x4ecdc7 in main trace-pc-guard-example.cc:4:17
   guard: 0x71bcd0 1 PC 0x4ecd20 in foo() trace-pc-guard-example.cc:2:14
 
+Inline 8bit-counters
+
+
+**Experimental, may change or disappear in future**
+
+With ``-fsanitize-coverage=inline-8bit-counters`` the compiler will insert
+inline counter increments on every edge.
+This is similar to ``-fsanitize-coverage=trace-pc-guard`` but instead of a
+callback the instrumentation simply increments a counter.
+
+Users need to implement a single function to capture the counters at startup.
+
+.. code-block:: c++
+
+  extern "C"
+  void __sanitizer_cov_8bit_counters_init(char *start, char *end) {
+// [start,end) is the array of 8-bit counters created for the current DSO.
+// Capture this array in order to read/modify the counters.
+  }
+
+PC-Table
+
+
+**Experimental, may change or disappear in future**
+
+With ``-fsanitize-coverage=pc-table`` the compiler will create a table of
+instrumented PCs. Requires either ``-fsanitize-coverage=inline-8bit-counters`` 
or
+``-fsanitize-coverage=trace-pc-guard``.
+
+Users need to implement a single function to capture the counters at startup:
+
+.. code-block:: c++
+
+  extern "C"
+  void __sanitizer_cov_pcs_init(const uint8_t *pcs_beg,
+const uint8_t *pcs_end) {
+// [pcs_beg,pcs_end) is the array of ptr-sized integers representing
+// PCs of the instrumented blocks in the current DSO.
+// Capture this array in order to read the PCs.
+// The number of PCs for a given DSO is the same as the number of
+// 8-bit counters (-fsanitize-coverage=inline-8bit-counters) or
+// trace_pc_guard callbacks (-fsanitize-coverage=trace-pc-guard)
+  }
+
+
 Tracing PCs
 ===
 
@@ -131,7 +176,6 @@ by the user.
 This mechanism is used for fuzzing the Linux kernel
 (https://github.com/google/syzkaller).
 
-
 Instrumentation points
 ==
 Sanitizer Coverage offers different levels of instrumentation.


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


RE: r311683 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Keane, Erich via cfe-commits
Hi Stephen-
I’m digging through this, and it seems odd.  SVN seems to store it with the 
CRLF line endings.  The Git mirror for some reason is not paying attention to 
the svn file attribute.  However, the .gitattribute file seems to convert it to 
the CRLF endings (as it should be), but it seems to think I’ve modified it now.

Are you seeing the same symptom?

From: Stephen Hines [mailto:srhi...@google.com]
Sent: Thursday, August 24, 2017 3:18 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r311683 - [Preprocessor] Correct internal token parsing of newline 
characters in CRLF

This change seems to have broken the git mirrors, as I can no longer check out 
clang without having a merge conflict as git alters the line endings. Setting 
core.autocrlf to false doesn't help either. Does anyone have any idea how to 
fix this svn <-> git issue?

Thanks,
Steve

On Thu, Aug 24, 2017 at 11:36 AM, Erich Keane via cfe-commits 
> wrote:
Author: erichkeane
Date: Thu Aug 24 11:36:07 2017
New Revision: 311683

URL: http://llvm.org/viewvc/llvm-project?rev=311683=rev
Log:
[Preprocessor] Correct internal token parsing of newline characters in CRLF

Discovered due to a goofy git setup, the test system-headerline-directive.c
(and a few others) failed because the token-consumption will consume only the
'\r' in CRLF, making the preprocessor's printed value give the wrong line number
when returning from an include. For example:

(line 1):#include \r\n

The "file exit" code causes the printer to try to print the 'returned to the
main file' line. It looks up what the current line number is. However, since the
current 'token' is the '\n' (since only the \r was consumed), it will give the
line number as '1", not '2'. This results in a few failed tests, but more
importantly, results in error messages being incorrect when compiling a
previously preprocessed file.

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

Added:
cfe/trunk/test/Frontend/.gitattributes
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c   
(with props)
Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=311683=311682=311683=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 24 11:36:07 2017
@@ -3073,6 +3073,8 @@ LexNextToken:

   case '\n':
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {

Added: cfe/trunk/test/Frontend/.gitattributes
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/.gitattributes?rev=311683=auto
==
--- cfe/trunk/test/Frontend/.gitattributes (added)
+++ cfe/trunk/test/Frontend/.gitattributes Thu Aug 24 11:36:07 2017
@@ -0,0 +1,2 @@
+# Below test validates crlf line endings, so it should stay crlf.
+system-header-line-directive-ms-lineendings.c text eol=crlf

Added: cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c?rev=311683=auto
==
--- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c 
(added)
+++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c Thu 
Aug 24 11:36:07 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem 
%S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly 
outputted
+// for the include-file-completed test case.
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2

Propchange: 
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
--
svn:eol-style = CRLF


___

[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ugg... disregard the system-header-line-directive-ms-lineendings.c issue, I'm 
going to try to figure that out


https://reviews.llvm.org/D37122



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


[PATCH] D37122: Change Diagnostic Category size error from runtime to compiletime

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

Diagnostic Categories are fairly annoying, and are only enforced
by a runtime-debug-only assert.  This puts in a touch more work
to get this all done at compile-time with static asserts.


https://reviews.llvm.org/D37122

Files:
  include/clang/Basic/AllDiagnostics.h
  include/clang/Basic/DiagnosticIDs.h
  lib/Basic/DiagnosticIDs.cpp
  test/Frontend/system-header-line-directive-ms-lineendings.c

Index: test/Frontend/system-header-line-directive-ms-lineendings.c
===
--- test/Frontend/system-header-line-directive-ms-lineendings.c
+++ test/Frontend/system-header-line-directive-ms-lineendings.c
@@ -1,21 +1,21 @@
-// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem %S/Inputs/SystemHeaderPrefix | FileCheck %s
-#include 
-#include 
-
-#include "line-directive.h"
-
-// This tests that the line numbers for the current file are correctly outputted
-// for the include-file-completed test case.  
-
-// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
-// CHECK: # 1 "{{.*}}noline.h" 1 3
-// CHECK: foo();
-// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
-// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
-//  The "3" below indicates that "foo.h" is considered a system header.
-// CHECK: # 1 "foo.h" 3
-// CHECK: foo();
-// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
-// CHECK: # 1 "{{.*}}line-directive.h" 1
-// CHECK: # 10 "foo.h"{{$}}
-// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem %S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly outputted
+// for the include-file-completed test case.  
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
Index: lib/Basic/DiagnosticIDs.cpp
===
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -96,18 +96,6 @@
 /// GetDiagInfo - Return the StaticDiagInfoRec entry for the specified DiagID,
 /// or null if the ID is invalid.
 static const StaticDiagInfoRec *GetDiagInfo(unsigned DiagID) {
-  // If assertions are enabled, verify that the StaticDiagInfo array is sorted.
-#ifndef NDEBUG
-  static bool IsFirst = true; // So the check is only performed on first call.
-  if (IsFirst) {
-assert(std::is_sorted(std::begin(StaticDiagInfo),
-  std::end(StaticDiagInfo)) &&
-   "Diag ID conflict, the enums at the start of clang::diag (in "
-   "DiagnosticIDs.h) probably need to be increased");
-IsFirst = false;
-  }
-#endif
-
   // Out of bounds diag. Can't be in the table.
   using namespace diag;
   if (DiagID >= DIAG_UPPER_LIMIT || DiagID <= DIAG_START_COMMON)
Index: include/clang/Basic/DiagnosticIDs.h
===
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -26,19 +26,32 @@
 
   // Import the diagnostic enums themselves.
   namespace diag {
+// Size of each of the diagnostic categories.
+enum {
+  DIAG_SIZE_COMMON=  300,
+  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_FRONTEND  =  100,
+  DIAG_SIZE_SERIALIZATION =  120,
+  DIAG_SIZE_LEX   =  400,
+  DIAG_SIZE_PARSE =  500,
+  DIAG_SIZE_AST   =  110,
+  DIAG_SIZE_COMMENT   =  100,
+  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_ANALYSIS  =  100
+};
 // Start position for diagnostics.
 enum {
-  DIAG_START_COMMON= 0,
-  DIAG_START_DRIVER= DIAG_START_COMMON  +  300,
-  DIAG_START_FRONTEND  = DIAG_START_DRIVER  +  200,
-  DIAG_START_SERIALIZATION = DIAG_START_FRONTEND+  100,
-  DIAG_START_LEX   = DIAG_START_SERIALIZATION   +  120,
-  DIAG_START_PARSE = DIAG_START_LEX +  400,
-  DIAG_START_AST   = DIAG_START_PARSE   +  500,
-  DIAG_START_COMMENT   = DIAG_START_AST +  110,
-  DIAG_START_SEMA  = DIAG_START_COMMENT +  100,
-  DIAG_START_ANALYSIS  = DIAG_START_SEMA+ 3500,
-  DIAG_UPPER_LIMIT = DIAG_START_ANALYSIS+  100
+  

RE: r311683 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Keane, Erich via cfe-commits
Can you better clarify what went wrong?  I included a ‘.gitattriutes’ that 
matches only the new test that is supposed to keep it as CLRF


From: Stephen Hines [mailto:srhi...@google.com]
Sent: Thursday, August 24, 2017 3:18 PM
To: Keane, Erich 
Cc: cfe-commits 
Subject: Re: r311683 - [Preprocessor] Correct internal token parsing of newline 
characters in CRLF

This change seems to have broken the git mirrors, as I can no longer check out 
clang without having a merge conflict as git alters the line endings. Setting 
core.autocrlf to false doesn't help either. Does anyone have any idea how to 
fix this svn <-> git issue?

Thanks,
Steve

On Thu, Aug 24, 2017 at 11:36 AM, Erich Keane via cfe-commits 
> wrote:
Author: erichkeane
Date: Thu Aug 24 11:36:07 2017
New Revision: 311683

URL: http://llvm.org/viewvc/llvm-project?rev=311683=rev
Log:
[Preprocessor] Correct internal token parsing of newline characters in CRLF

Discovered due to a goofy git setup, the test system-headerline-directive.c
(and a few others) failed because the token-consumption will consume only the
'\r' in CRLF, making the preprocessor's printed value give the wrong line number
when returning from an include. For example:

(line 1):#include \r\n

The "file exit" code causes the printer to try to print the 'returned to the
main file' line. It looks up what the current line number is. However, since the
current 'token' is the '\n' (since only the \r was consumed), it will give the
line number as '1", not '2'. This results in a few failed tests, but more
importantly, results in error messages being incorrect when compiling a
previously preprocessed file.

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

Added:
cfe/trunk/test/Frontend/.gitattributes
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c   
(with props)
Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=311683=311682=311683=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 24 11:36:07 2017
@@ -3073,6 +3073,8 @@ LexNextToken:

   case '\n':
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {

Added: cfe/trunk/test/Frontend/.gitattributes
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/.gitattributes?rev=311683=auto
==
--- cfe/trunk/test/Frontend/.gitattributes (added)
+++ cfe/trunk/test/Frontend/.gitattributes Thu Aug 24 11:36:07 2017
@@ -0,0 +1,2 @@
+# Below test validates crlf line endings, so it should stay crlf.
+system-header-line-directive-ms-lineendings.c text eol=crlf

Added: cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c?rev=311683=auto
==
--- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c 
(added)
+++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c Thu 
Aug 24 11:36:07 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem 
%S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly 
outputted
+// for the include-file-completed test case.
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2

Propchange: 
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
--
svn:eol-style = CRLF


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

___
cfe-commits mailing list

Re: r311683 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Stephen Hines via cfe-commits
This change seems to have broken the git mirrors, as I can no longer check
out clang without having a merge conflict as git alters the line endings.
Setting core.autocrlf to false doesn't help either. Does anyone have any
idea how to fix this svn <-> git issue?

Thanks,
Steve

On Thu, Aug 24, 2017 at 11:36 AM, Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Thu Aug 24 11:36:07 2017
> New Revision: 311683
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311683=rev
> Log:
> [Preprocessor] Correct internal token parsing of newline characters in CRLF
>
> Discovered due to a goofy git setup, the test system-headerline-directive.c
> (and a few others) failed because the token-consumption will consume only
> the
> '\r' in CRLF, making the preprocessor's printed value give the wrong line
> number
> when returning from an include. For example:
>
> (line 1):#include \r\n
>
> The "file exit" code causes the printer to try to print the 'returned to
> the
> main file' line. It looks up what the current line number is. However,
> since the
> current 'token' is the '\n' (since only the \r was consumed), it will give
> the
> line number as '1", not '2'. This results in a few failed tests, but more
> importantly, results in error messages being incorrect when compiling a
> previously preprocessed file.
>
> Differential Revision: https://reviews.llvm.org/D37079
>
> Added:
> cfe/trunk/test/Frontend/.gitattributes
> cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
>  (with props)
> Modified:
> cfe/trunk/lib/Lex/Lexer.cpp
>
> Modified: cfe/trunk/lib/Lex/Lexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/
> Lexer.cpp?rev=311683=311682=311683=diff
> 
> ==
> --- cfe/trunk/lib/Lex/Lexer.cpp (original)
> +++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 24 11:36:07 2017
> @@ -3073,6 +3073,8 @@ LexNextToken:
>
>case '\n':
>case '\r':
> +if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
> +  Char = getAndAdvanceChar(CurPtr, Result);
>  // If we are inside a preprocessor directive and we see the end of
> line,
>  // we know we are done with the directive, so return an EOD token.
>  if (ParsingPreprocessorDirective) {
>
> Added: cfe/trunk/test/Frontend/.gitattributes
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Frontend/.gitattributes?rev=311683=auto
> 
> ==
> --- cfe/trunk/test/Frontend/.gitattributes (added)
> +++ cfe/trunk/test/Frontend/.gitattributes Thu Aug 24 11:36:07 2017
> @@ -0,0 +1,2 @@
> +# Below test validates crlf line endings, so it should stay crlf.
> +system-header-line-directive-ms-lineendings.c text eol=crlf
>
> Added: cfe/trunk/test/Frontend/system-header-line-directive-
> ms-lineendings.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> Frontend/system-header-line-directive-ms-lineendings.c?
> rev=311683=auto
> 
> ==
> --- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
> (added)
> +++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
> Thu Aug 24 11:36:07 2017
> @@ -0,0 +1,21 @@
> +// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem
> %S/Inputs/SystemHeaderPrefix | FileCheck %s
> +#include 
> +#include 
> +
> +#include "line-directive.h"
> +
> +// This tests that the line numbers for the current file are correctly
> outputted
> +// for the include-file-completed test case.
> +
> +// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}noline.h" 1 3
> +// CHECK: foo();
> +// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
> +//  The "3" below indicates that "foo.h" is considered a system
> header.
> +// CHECK: # 1 "foo.h" 3
> +// CHECK: foo();
> +// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
> +// CHECK: # 1 "{{.*}}line-directive.h" 1
> +// CHECK: # 10 "foo.h"{{$}}
> +// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
>
> Propchange: cfe/trunk/test/Frontend/system-header-line-directive-
> ms-lineendings.c
> 
> --
> svn:eol-style = CRLF
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37120: [analyzer] Fix modeling arithmetic

2017-08-24 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap created this revision.
Herald added a subscriber: xazax.hun.

This diff attempts to fix modeling of arithmetic expressions
where pointers are treated as integers (i.e. via C-style / reinterpret casts).
In particular, it resolves https://bugs.llvm.org/show_bug.cgi?id=34309

Test plan: make check-all


Repository:
  rL LLVM

https://reviews.llvm.org/D37120

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/ptr-arith.cpp


Index: test/Analysis/ptr-arith.cpp
===
--- test/Analysis/ptr-arith.cpp
+++ test/Analysis/ptr-arith.cpp
@@ -105,3 +105,9 @@
 return 0;
   return N;
 }
+
+// Bug 34309
+bool ptrAsIntegerSubtractionNoCrash(long x, char *p) {
+  long y = (long)p - 1;
+  return y == x;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -364,6 +364,13 @@
  rhs.castAs().getLoc(),
  resultTy);
 case nonloc::ConcreteIntKind: {
+  // Evaluate pointers treated as integers
+  // (for example, results of C-style casts (long)((void *)ptr))
+  // in arithmetic expressions with integers.
+  if (!BinaryOperator::isComparisonOp(op))
+return makeSymExprValNN(
+state, op, lhs.castAs(),
+rhs.castAs(), resultTy);
   // Transform the integer into a location and compare.
   // FIXME: This only makes sense for comparisons. If we want to, say,
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,


Index: test/Analysis/ptr-arith.cpp
===
--- test/Analysis/ptr-arith.cpp
+++ test/Analysis/ptr-arith.cpp
@@ -105,3 +105,9 @@
 return 0;
   return N;
 }
+
+// Bug 34309
+bool ptrAsIntegerSubtractionNoCrash(long x, char *p) {
+  long y = (long)p - 1;
+  return y == x;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -364,6 +364,13 @@
  rhs.castAs().getLoc(),
  resultTy);
 case nonloc::ConcreteIntKind: {
+  // Evaluate pointers treated as integers
+  // (for example, results of C-style casts (long)((void *)ptr))
+  // in arithmetic expressions with integers.
+  if (!BinaryOperator::isComparisonOp(op))
+return makeSymExprValNN(
+state, op, lhs.castAs(),
+rhs.castAs(), resultTy);
   // Transform the integer into a location and compare.
   // FIXME: This only makes sense for comparisons. If we want to, say,
   // add 1 to a LocAsInteger, we'd better unpack the Loc and add to it,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311707 - Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread Dehao Chen via cfe-commits
Author: dehao
Date: Thu Aug 24 14:37:33 2017
New Revision: 311707

URL: http://llvm.org/viewvc/llvm-project?rev=311707=rev
Log:
Expose -mllvm -accurate-sample-profile to clang.

Summary: With accurate sample profile, we can do more aggressive size 
optimization. For some size-critical application, this can reduce the text size 
by 20%

Reviewers: davidxl, rsmith

Reviewed By: davidxl, rsmith

Subscribers: mehdi_amini, eraman, sanjoy, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/profile-sample-accurate.c
cfe/trunk/test/Integration/thinlto_profile_sample_accurate.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/clang_f_opts.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=311707=311706=311707=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Aug 24 14:37:33 2017
@@ -637,12 +637,25 @@ def fno_profile_sample_use : Flag<["-"],
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[DriverOption, CC1Option]>,
 HelpText<"Enable sample-based profile guided optimizations">;
+def fprofile_sample_accurate : Flag<["-"], "fprofile-sample-accurate">,
+Group, Flags<[DriverOption, CC1Option]>,
+HelpText<"Specifies that the sample profile is accurate">,
+DocBrief<[{Specifies that the sample profile is accurate. If the sample
+   profile is accurate, callsites without profile samples are 
marked
+   as cold. Otherwise, treat callsites without profile samples as 
if
+   we have no profile}]>;
+def fno_profile_sample_accurate : Flag<["-"], "fno-profile-sample-accurate">,
+  Group, Flags<[DriverOption]>;
 def fauto_profile : Flag<["-"], "fauto-profile">, Group,
 Alias;
 def fno_auto_profile : Flag<["-"], "fno-auto-profile">, Group,
 Alias;
 def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
 Alias;
+def fauto_profile_accurate : Flag<["-"], "fauto-profile-accurate">,
+Group, Alias;
+def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">,
+Group, Alias;
 def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">, 
Group,
 Flags<[CC1Option]>,
 HelpText<"Emit extra debug info to make sample profile more accurate.">;

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=311707=311706=311707=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Thu Aug 24 14:37:33 2017
@@ -183,6 +183,7 @@ CODEGENOPT(UnsafeFPMath  , 1, 0) ///
 CODEGENOPT(UnwindTables  , 1, 0) ///< Emit unwind tables.
 CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
 CODEGENOPT(VectorizeSLP  , 1, 0) ///< Run SLP vectorizer.
+CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
 
   /// Attempt to use register sized accesses to bit-fields in structures, when
   /// possible.

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=311707=311706=311707=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Aug 24 14:37:33 2017
@@ -838,6 +838,10 @@ void CodeGenFunction::StartFunction(Glob
   Fn->addFnAttr("no-jump-tables",
 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add profile-sample-accurate value.
+  if (CGM.getCodeGenOpts().ProfileSampleAccurate)
+Fn->addFnAttr("profile-sample-accurate");
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=311707=311706=311707=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Aug 24 14:37:33 2017
@@ -2340,6 +2340,10 @@ void Clang::ConstructJob(Compilation ,
 true))
 CmdArgs.push_back("-fno-jump-tables");
 
+  if (Args.hasFlag(options::OPT_fprofile_sample_accurate,
+   options::OPT_fno_profile_sample_accurate, 

[libcxx] r311705 - [libcxx] [test] Update for C++17 feature removals.

2017-08-24 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Aug 24 14:24:08 2017
New Revision: 311705

URL: http://llvm.org/viewvc/llvm-project?rev=311705=rev
Log:
[libcxx] [test] Update for C++17 feature removals.

test/std/containers/Emplaceable.h
test/std/containers/NotConstructible.h
test/support/counting_predicates.hpp
Replace unary_function/binary_function inheritance with typedefs.

test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp
test/std/utilities/function.objects/func.require/binary_function.pass.cpp
test/std/utilities/function.objects/func.require/unary_function.pass.cpp
Mark these tests as requiring 98/03/11/14 because 17 removed 
unary_function/binary_function.

test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp
test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp
Mark these tests as requiring 11/14 because 17 removed packaged_task allocator 
support.

test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp
This test doesn't need to be skipped in C++17 mode. Only the construction of
std::function from an allocator needs to be skipped in C++17 mode.

test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp
test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
When testing these reference_wrapper features, unary_function inheritance is 
totally irrelevant.

test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
Define and use my_unary_function/my_binary_function to test the weak result 
type machinery
(which is still present in C++17, although deprecated).

test/support/msvc_stdlib_force_include.hpp
Now we can test C++17 strictly, without enabling removed features.

Fixes D36503.

Modified:
libcxx/trunk/test/std/containers/Emplaceable.h
libcxx/trunk/test/std/containers/NotConstructible.h

libcxx/trunk/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp

libcxx/trunk/test/std/depr/depr.function.objects/depr.base/unary_function.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor_func_alloc.pass.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.nonmembers/uses_allocator.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/binary_function.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.require/unary_function.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.access/conversion.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/copy_ctor.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/refwrap/weak_result.pass.cpp
libcxx/trunk/test/support/counting_predicates.hpp
libcxx/trunk/test/support/msvc_stdlib_force_include.hpp

Modified: libcxx/trunk/test/std/containers/Emplaceable.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/Emplaceable.h?rev=311705=311704=311705=diff
==
--- libcxx/trunk/test/std/containers/Emplaceable.h (original)
+++ libcxx/trunk/test/std/containers/Emplaceable.h Thu Aug 24 14:24:08 2017
@@ -45,8 +45,10 @@ namespace std {
 
 template <>
 struct hash
-: public std::unary_function
 {
+typedef Emplaceable argument_type;
+typedef std::size_t result_type;
+
 std::size_t operator()(const Emplaceable& x) const {return x.get();}
 };
 

Modified: libcxx/trunk/test/std/containers/NotConstructible.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/NotConstructible.h?rev=311705=311704=311705=diff
==
--- libcxx/trunk/test/std/containers/NotConstructible.h (original)
+++ libcxx/trunk/test/std/containers/NotConstructible.h Thu Aug 24 14:24:08 2017
@@ -29,8 +29,10 @@ namespace std
 
 template <>
 struct hash
-: public std::unary_function
 {
+typedef NotConstructible argument_type;
+typedef std::size_t result_type;
+
 std::size_t operator()(const NotConstructible&) const {return 0;}
 };
 

Modified: 
libcxx/trunk/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.function.objects/depr.base/binary_function.pass.cpp?rev=311705=311704=311705=diff

[PATCH] D36503: [libcxx] [test] Update for C++17 feature removals.

2017-08-24 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT accepted this revision.
STL_MSFT added a comment.
This revision is now accepted and ready to land.

Looks good to myself.


https://reviews.llvm.org/D36503



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


[PATCH] D37101: [clangd] [WIP] Add support for snippet completions

2017-08-24 Thread Raoul Wols via Phabricator via cfe-commits
rwols marked 10 inline comments as done.
rwols added inline comments.



Comment at: clangd/ClangdUnit.cpp:321
+
+// Fill in the label, detail, documentation and insertText fields of the
+// CompletionItem.

ilya-biryukov wrote:
> Maybe split writes into `Item.label` and other `Item` fields?
> That would simplify the function, i.e. something like this:
> 
> ```
> // Set Item.label approriately.
> switch (Result.Kind) {
>   case RK_Declaration: Item.label = Result.Declaration->getNameAsString();
>   //... other enum value
> }
> 
> 
> // Set other Item fields.
> // Note that is also works as expected for RK_Pattern.
> auto Completion = Result.CreateCodeCompletionString(/**/);
> ProcessCodeCompleteString(/*...*/, Item);
> // 
> ```
From some experimentation and skimming over SemaCodeComplete.cpp I notice the 
result of `CreateCodeCompletionString(/**/)` is never null anyway, so one 
can just skip those switch cases. I'm not sure why a pointer is returned.



Comment at: clangd/ClangdUnit.cpp:381
+// a declarator or macro.
+Item.label += Chunk.Text;
+Item.insertText += Chunk.Text;

ilya-biryukov wrote:
> We set the label in `ProcessCodeCompleteResult`, why is there a need to 
> append to it here?
> Maybe we should set it here and not touch it in `ProcessCodeCompleteResult` 
> at all?
It's possible that maybe too much is going into the label now, I agree. For 
instance for a function the name of the function as well as the opening 
parenthesis, all of its parameters, and the closing brace go into the label. 
Maybe it's enough to only have the name of the function in the label. On the 
other hand, I don't think this will play nicely with VSCode and SublimeText, 
but this will ultimately depend on the language client plugins.



Comment at: clangd/ClangdUnit.cpp:406
+// but should not be inserted into the buffer.
+Item.documentation += "[" + std::string(Chunk.Text) + "] ";
+break;

ilya-biryukov wrote:
> Let's also add some description to `Item.documentation`. What kind of things 
> go into `CK_Informative` ?
> 
I've seen " const", " volatile" go into CK_Informative (note the prefix space). 
Another major chunk that goes into CK_Informative is the base class name 
suffixed with `::` if the completion is a method of the base class not 
overridden in the current class.



Comment at: clangd/ClangdUnit.cpp:413
+break;
+  case CodeCompletionString::CK_CurrentParameter:
+// A piece of text that describes the parameter that corresponds

ilya-biryukov wrote:
> How is `CK_CurrentParameter` different from `CK_Placeholder`? Maybe handle 
> them both simultaneously and add a comment on why we don't care about their 
> differences?
> I mean something like:
> ```
> // We don't distinguish between CK_Placeholder and CK_CurrentParameter 
> because 
> case CodeCompletionString::CK_Placeholder:
> case CodeCompletionString::CK_CurrentParameter:
> //... Code adding ${N:something}
> 
> ```
I'm still figuring out exactly what the difference is...



Comment at: clangd/ClangdUnit.cpp:452
+Item.insertText += Chunk.Text;
+Item.label += Chunk.Text;
+break;

ilya-biryukov wrote:
> Does adding vertical space to `label` plays well with editors? Maybe we 
> should replace with horizontal space instead?
I'll fix this later.


https://reviews.llvm.org/D37101



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


[PATCH] D37101: [clangd] [WIP] Add support for snippet completions

2017-08-24 Thread Raoul Wols via Phabricator via cfe-commits
rwols updated this revision to Diff 112609.
rwols added a comment.

[clangd] [WIP] Add support for snippet completions

- Restore the sortText logic
- Return CompletionItem instead of modifying a ref param
- Make all helper methods const
- Only set to Snippet once we encounter CK_Placeholder/CK_CurrentParameter
- More clear annotation handling
- Escape any $, } and \ for a snippet


https://reviews.llvm.org/D37101

Files:
  clangd/ClangdUnit.cpp
  clangd/Protocol.cpp

Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -724,8 +724,8 @@
   if (!CI.insertText.empty())
 Os << R"("insertText":")" << llvm::yaml::escape(CI.insertText) << R"(",)";
   if (CI.insertTextFormat != InsertTextFormat::Missing) {
-Os << R"("insertTextFormat":")" << static_cast(CI.insertTextFormat)
-   << R"(",)";
+Os << R"("insertTextFormat":)" << static_cast(CI.insertTextFormat)
+   << R"(,)";
   }
   if (CI.textEdit)
 Os << R"("textEdit":)" << TextEdit::unparse(*CI.textEdit) << ',';
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -288,45 +288,189 @@
   void ProcessCodeCompleteResults(Sema , CodeCompletionContext Context,
   CodeCompletionResult *Results,
   unsigned NumResults) override {
-for (unsigned I = 0; I != NumResults; ++I) {
-  CodeCompletionResult  = Results[I];
-  CodeCompletionString *CCS = Result.CreateCodeCompletionString(
+assert(Items && "We need a non-null items container here");
+Items->reserve(NumResults);
+for (unsigned I = 0; I < NumResults; ++I) {
+  auto  = Results[I];
+  const auto *CCS = Result.CreateCodeCompletionString(
   S, Context, *Allocator, CCTUInfo,
   CodeCompleteOpts.IncludeBriefComments);
-  if (CCS) {
-CompletionItem Item;
-for (CodeCompletionString::Chunk C : *CCS) {
-  switch (C.Kind) {
-  case CodeCompletionString::CK_ResultType:
-Item.detail = C.Text;
-break;
-  case CodeCompletionString::CK_Optional:
-break;
-  default:
-Item.label += C.Text;
-break;
-  }
-}
-assert(CCS->getTypedText());
-Item.kind = getKind(Result.CursorKind);
-// Priority is a 16-bit integer, hence at most 5 digits.
-assert(CCS->getPriority() < 9 && "Expecting code completion result "
- "priority to have at most "
- "5-digits");
-llvm::raw_string_ostream(Item.sortText)
-<< llvm::format("%05d%s", CCS->getPriority(), CCS->getTypedText());
-Item.insertText = Item.filterText = CCS->getTypedText();
-if (CCS->getBriefComment())
-  Item.documentation = CCS->getBriefComment();
-Items->push_back(std::move(Item));
-  }
+  assert(CCS && "Expected the CodeCompletionString to be non-null");
+  Items->push_back(ProcessCodeCompleteResult(Result, *CCS));
 }
   }
 
   GlobalCodeCompletionAllocator () override { return *Allocator; }
 
   CodeCompletionTUInfo () override { return CCTUInfo; }
-};
+
+private:
+  CompletionItem
+  ProcessCodeCompleteResult(const CodeCompletionResult ,
+const CodeCompletionString ) const {
+// The object that we'll return.
+CompletionItem Item;
+
+// By default InsertTextFormat::PlainText. When we encounter a
+// CK_Placeholder or CK_CurrentParameter, this will be modified to
+// InsertTextFormat::PlainText.
+Item.insertTextFormat = InsertTextFormat::PlainText;
+
+// Things like __attribute__((nonnull(1,3))) and [[noreturn]]. Present this
+// information in the documentation field.
+if (CCS.getAnnotationCount() > 0) {
+  Item.documentation += "Annotation";
+  if (CCS.getAnnotationCount() == 1) {
+Item.documentation += ": ";
+  } else /* CCS.getAnnotationCount() > 1 */ {
+Item.documentation += "s: ";
+  }
+  for (unsigned j = 0; j < CCS.getAnnotationCount(); ++j) {
+Item.documentation += CCS.getAnnotation(j);
+Item.documentation += j == CCS.getAnnotationCount() - 1 ? "\n\n" : " ";
+  }
+}
+
+// Fill in the label, detail, documentation and insertText fields of the
+// CompletionItem. The informative chunks are put into the documentation
+// field.
+ProcessChunks(CCS, Item);
+
+// Add brief documentation (if there is any).
+if (CCS.getBriefComment() != nullptr) {
+  Item.documentation += CCS.getBriefComment();
+}
+
+// Fill in the kind field of the CompletionItem.
+Item.kind = getKind(Result.CursorKind);
+
+// Fill in the sortText of the CompletionItem.
+assert(CCS.getPriority() < 9 && "Expecting code 

[PATCH] D15465: [git-clang-format]: New option to perform formatting against staged changes only

2017-08-24 Thread Alexander Shukaev via Phabricator via cfe-commits
Alexander-Shukaev added a comment.

Man, I have to admit it's really a shame that I didn't find time to work on 
this further but I'm truly too busy these days.  However, I believe the primary 
point why I didn't have motivation to do this is because the flaw that was 
pointed out actually never bothered me in real life simply because I've never 
ever hit this case in production.  I confess that I use this solution, namely 
the one linked on Stack Overflow (to my personal Bitbucket repository) every 
single day and we even introduced it in my company.  Nobody ever complained so 
far.  It's true that sometimes one would want to stage only some changes and 
commit them, while having other changes unstaged, but I don't remember when I 
was in that situation last time.  If you really want to leave something out for 
another commit, then you can also stash those unstaged changes before you 
format/commit the staged ones.  Furthermore, let me clarify why the proposal by 
@lodato might not even fit into the picture (i.e. there is no universal 
solution this problem as I see it until now).  In particular, his example does 
not illustrate another side of the medal, namely let's say that the staged code 
was, in fact, badly formatted (not like in his example), and then you apply 
some code on top of it that is not yet staged (same like in his example).  By 
"on top" I mean really like he shows it, that those changes overlap, that is if 
you'd stage them, they'd overwrite the previously staged ones (which in our 
imaginary example are badly formatted now).  Now let's think what will happen 
if we follow his proposal.  We'd apply formatting purely to the "staged" 
version of the file by piping it from index as a blob directly to formatter, so 
far so good.  Or wait a minute, how would you actually format that file in 
place then?  That is you already have unstaged and potentially conflicting 
changes with the ones you'd get as a result of formatting the staged ones but 
how to reconcile these two versions now?  That is how do you put those 
formatted changes into unstaged state when you already have something 
completely different but also unstaged at the same line?  Turns out that the 
answer is, you can't, without introducing explicit conflicts in the unstaged 
tree, which is even more confusing to my taste.  Or would you just report the 
diff with an error message to the user leaving the act of applying those to 
them manually?  You could, but then you give up on that cool feature of 
automatic formatting.  To conclude, which approach you take, is all about pros 
and cons.  On the daily basis and from productivity standpoint, I care more 
about doing my changes for the target commit, trying to commit, if something is 
wrong getting it automatically formatted in the unstaged tree, reviewing this 
unstaged diff quickly, staging it, and finally committing my work.  That corner 
case with some irrelevant changes hanging in the unstaged tree and fooling 
formatter can rarely be a problem.  And even then, I treat it more like an 
answer from a formatter: "Hey bro, you have some unstaged crap out there, can 
you please already decide whether you need it now or not, otherwise I can't do 
my job for you?!", in which case I will

- either actually stage them if I really need them,
- or stash them if I want to deal with them later,
- or discard them altogether if they are garbage,

all of which will allow formatter to do it's job and me to finally produce the 
commit.


Repository:
  rL LLVM

https://reviews.llvm.org/D15465



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


[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread David Li via Phabricator via cfe-commits
davidxl accepted this revision.
davidxl added a comment.

lgtm


https://reviews.llvm.org/D37091



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


RE: [PATCH] D36501: add flag to undo ABI change in r310401

2017-08-24 Thread Robinson, Paul via cfe-commits
Paul: is the PS4 toolchain's ABI based on that of a particular Clang release, 
or is it a branch from trunk at some point? Or something else? (And which 
release / revision?)

I am reminded that there are two parts to the ABI, the C++ part and the 
platform part.
PS4's C++ ABI is whatever Clang 3.2 did; the platform part is AMD64 (as of LLVM 
3.2) with (IIRC) a couple minor differences.

Whenever there is an ABI change (that we notice), we go through an exercise to 
determine whether it's benign or we have to undo it.  Games built with a 
3.2-based toolchain must be runnable on OS/middleware built with all subsequent 
versions.  It is never the case that a game built with version N must be 
runnable on an OS built with version N-1, if that helps.
--paulr
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks, looks great.


https://reviews.llvm.org/D37091



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


[PATCH] D36386: [clang] Remove unit test which uses reverse-iterate flag

2017-08-24 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

sounds good - so long as other tests would fail if the fix this test was 
testing wasn't present (on a reverse iteration enabled build)


https://reviews.llvm.org/D36386



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


[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 112604.
danielcdh marked an inline comment as done.
danielcdh added a comment.

update


https://reviews.llvm.org/D37091

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/profile-sample-accurate.c
  test/Driver/clang_f_opts.c
  test/Integration/thinlto_profile_sample_accurate.c

Index: test/Integration/thinlto_profile_sample_accurate.c
===
--- /dev/null
+++ test/Integration/thinlto_profile_sample_accurate.c
@@ -0,0 +1,9 @@
+// Test to ensure -emit-llvm profile-sample-accurate is honored in ThinLTO.
+// RUN: %clang -O2 %s -flto=thin -fprofile-sample-accurate -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm -o - | FileCheck %s
+
+// CHECK: define void @foo()
+// CHECK: attributes {{.*}} "profile-sample-accurate"
+void foo() {
+}
Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -53,6 +53,9 @@
 // CHECK-REROLL-LOOPS: "-freroll-loops"
 // CHECK-NO-REROLL-LOOPS-NOT: "-freroll-loops"
 
+// RUN: %clang -### -S -fprofile-sample-accurate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-SAMPLE-ACCURATE %s
+// CHECK-PROFILE-SAMPLE-ACCURATE: "-fprofile-sample-accurate"
+
 // RUN: %clang -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s
 // CHECK-SAMPLE-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
 
Index: test/CodeGen/profile-sample-accurate.c
===
--- /dev/null
+++ test/CodeGen/profile-sample-accurate.c
@@ -0,0 +1,7 @@
+// Test to ensure -emit-llvm profile-sample-accurate is honored by clang.
+// RUN: %clang -S -emit-llvm %s -fprofile-sample-accurate -o - | FileCheck %s
+
+// CHECK: define void @foo()
+// CHECK: attributes {{.*}} "profile-sample-accurate"
+void foo() {
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -652,6 +652,8 @@
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
+  Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate);
+
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.EmitSummaryIndex = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2340,6 +2340,10 @@
 true))
 CmdArgs.push_back("-fno-jump-tables");
 
+  if (Args.hasFlag(options::OPT_fprofile_sample_accurate,
+   options::OPT_fno_profile_sample_accurate, false))
+CmdArgs.push_back("-fprofile-sample-accurate");
+
   if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
 options::OPT_fno_preserve_as_comments, true))
 CmdArgs.push_back("-fno-preserve-as-comments");
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -837,6 +837,10 @@
   Fn->addFnAttr("no-jump-tables",
 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add profile-sample-accurate value.
+  if (CGM.getCodeGenOpts().ProfileSampleAccurate)
+Fn->addFnAttr("profile-sample-accurate");
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -183,6 +183,7 @@
 CODEGENOPT(UnwindTables  , 1, 0) ///< Emit unwind tables.
 CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
 CODEGENOPT(VectorizeSLP  , 1, 0) ///< Run SLP vectorizer.
+CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
 
   /// Attempt to use register sized accesses to bit-fields in structures, when
   /// possible.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -637,12 +637,25 @@
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[DriverOption, CC1Option]>,
 HelpText<"Enable sample-based profile guided optimizations">;
+def fprofile_sample_accurate : Flag<["-"], "fprofile-sample-accurate">,
+Group, Flags<[DriverOption, CC1Option]>,
+HelpText<"Specifies 

[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: test/CodeGen/thinlto-profile-sample-accurate.c:2-4
+// RUN: %clang -O2 %s -flto=thin -fprofile-sample-accurate -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm -o 
- | FileCheck %s

test/CodeGen tests should generally not run the optimizer; these tests are 
intended to check that the correct IR is produced by CodeGen prior to any 
optimization.

So: we should have a unit test that the IR produced by Clang contains the 
attribute in the right place (prior to any LLVM passes running), here in 
test/CodeGen. It seems fine to me to have an end-to-end integration test in 
addition to that (but not instead of it); we haven't yet established a 
systematic organization for those tests, but putting it in test/Integration for 
now will make it easier to find in the future when we work that out.


https://reviews.llvm.org/D37091



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


[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 112601.
danielcdh added a comment.
Herald added subscribers: eraman, mehdi_amini.

Add an end-to-end test.


https://reviews.llvm.org/D37091

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/thinlto-profile-sample-accurate.c
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -53,6 +53,9 @@
 // CHECK-REROLL-LOOPS: "-freroll-loops"
 // CHECK-NO-REROLL-LOOPS-NOT: "-freroll-loops"
 
+// RUN: %clang -### -S -fprofile-sample-accurate %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-SAMPLE-ACCURATE %s
+// CHECK-PROFILE-SAMPLE-ACCURATE: "-fprofile-sample-accurate"
+
 // RUN: %clang -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s
 // CHECK-SAMPLE-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
 
Index: test/CodeGen/thinlto-profile-sample-accurate.c
===
--- /dev/null
+++ test/CodeGen/thinlto-profile-sample-accurate.c
@@ -0,0 +1,9 @@
+// Test to ensure -emit-llvm profile-sample-accurate is honored in ThinLTO.
+// RUN: %clang -O2 %s -flto=thin -fprofile-sample-accurate -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm -o - | FileCheck %s
+
+// CHECK: define void @foo()
+// CHECK: attributes {{.*}} "profile-sample-accurate"
+void foo() {
+}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -652,6 +652,8 @@
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
+  Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate);
+
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.EmitSummaryIndex = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2340,6 +2340,10 @@
 true))
 CmdArgs.push_back("-fno-jump-tables");
 
+  if (Args.hasFlag(options::OPT_fprofile_sample_accurate,
+   options::OPT_fno_profile_sample_accurate, false))
+CmdArgs.push_back("-fprofile-sample-accurate");
+
   if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
 options::OPT_fno_preserve_as_comments, true))
 CmdArgs.push_back("-fno-preserve-as-comments");
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -837,6 +837,10 @@
   Fn->addFnAttr("no-jump-tables",
 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add profile-sample-accurate value.
+  if (CGM.getCodeGenOpts().ProfileSampleAccurate)
+Fn->addFnAttr("profile-sample-accurate");
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -183,6 +183,7 @@
 CODEGENOPT(UnwindTables  , 1, 0) ///< Emit unwind tables.
 CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
 CODEGENOPT(VectorizeSLP  , 1, 0) ///< Run SLP vectorizer.
+CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
 
   /// Attempt to use register sized accesses to bit-fields in structures, when
   /// possible.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -637,12 +637,25 @@
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[DriverOption, CC1Option]>,
 HelpText<"Enable sample-based profile guided optimizations">;
+def fprofile_sample_accurate : Flag<["-"], "fprofile-sample-accurate">,
+Group, Flags<[DriverOption, CC1Option]>,
+HelpText<"Specifies that the sample profile is accurate">,
+DocBrief<[{Specifies that the sample profile is accurate. If the sample
+   profile is accurate, callsites without profile samples are marked
+   as cold. Otherwise, treat callsites without profile samples as if
+   we have no profile}]>;
+def fno_profile_sample_accurate : Flag<["-"], "fno-profile-sample-accurate">,
+  Group, Flags<[DriverOption]>;
 def fauto_profile : Flag<["-"], 

[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Please add a test that the attribute is emitted into IR. Other than that, this 
looks good to me.




Comment at: include/clang/Driver/Options.td:645
+   profile is accurate, callsites without profile samples are 
marked
+   as cold. Otherwise, treat callsites without profile samples as 
if
+   we have no profile}]>;

Consistently use passive voice here: "treat callsites without profile samples" 
-> "callsites without profile samples are treated"



Comment at: include/clang/Driver/Options.td:646
+   as cold. Otherwise, treat callsites without profile samples as 
if
+   we have no profile}]>;
+def fno_profile_sample_accurate : Flag<["-"], "fno-profile-sample-accurate">,

Add a trailing period.


https://reviews.llvm.org/D37091



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


Re: r311589 - [ubsan] PR34266: When sanitizing the 'this' value for a member function that happens to be a lambda call operator, use the lambda's 'this' pointer, not the captured enclosing 'this' poin

2017-08-24 Thread Richard Smith via cfe-commits
Thanks for the revert; looks like there was another bug in the interaction
of lambdas an UBSan 'this' sanitization that was exposed by this (the
lambda static invoker calls the operator() with a null this pointer, and
the sanitizer doesn't know that's actually OK). Should be fixed in r311695.

On 24 August 2017 at 11:20, Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> I temporarily reverted the commit in r311680 to get the bots going again.
>
> -- adrian
>
> > On Aug 24, 2017, at 11:12 AM, Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > It looks like this broke / found errors on the green dragon bot:
> >
> > http://green.lab.llvm.org/green/job/clang-stage2-cmake-
> RgSan_check/4115/consoleFull#15752874848254eaf0-7326-4999-
> 85b0-388101f2d404
> >
> >  TEST 'LLVM-Unit :: ADT/./ADTTests/
> FilterIteratorTest.FunctionPointer' FAILED 
> >
> > Note: Google Test filter = FilterIteratorTest.FunctionPointer
> > [==] Running 1 test from 1 test case.
> > [--] Global test environment set-up.
> > [--] 1 test from FilterIteratorTest
> > [ RUN  ] FilterIteratorTest.FunctionPointer
> > /Users/buildslave/jenkins/sharedspace/clang-stage2-cmake-RgSan@2
> /llvm/unittests/ADT/IteratorTest.cpp:160:24: runtime error: load of null
> pointer of type 'const (lambda at /Users/buildslave/jenkins/
> sharedspace/clang-stage2-cmake-RgSan@2/llvm/unittests/ADT/IteratorTest.cpp:160:24)
> *'
> > SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
> /Users/buildslave/jenkins/sharedspace/clang-stage2-cmake-RgSan@2
> /llvm/unittests/ADT/IteratorTest.cpp:160:24 in
> >
> > 
> >
> > -- adrian
> >> On Aug 23, 2017, at 12:39 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: rsmith
> >> Date: Wed Aug 23 12:39:04 2017
> >> New Revision: 311589
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=311589=rev
> >> Log:
> >> [ubsan] PR34266: When sanitizing the 'this' value for a member function
> that happens to be a lambda call operator, use the lambda's 'this' pointer,
> not the captured enclosing 'this' pointer (if any).
> >>
> >> Modified:
> >>   cfe/trunk/include/clang/AST/DeclCXX.h
> >>   cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> >>   cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> >>
> >> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclCXX.h?rev=311589=311588=311589=diff
> >> 
> ==
> >> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> >> +++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Aug 23 12:39:04 2017
> >> @@ -2027,7 +2027,10 @@ public:
> >>
> >>  /// \brief Returns the type of the \c this pointer.
> >>  ///
> >> -  /// Should only be called for instance (i.e., non-static) methods.
> >> +  /// Should only be called for instance (i.e., non-static) methods.
> Note
> >> +  /// that for the call operator of a lambda closure type, this
> returns the
> >> +  /// desugared 'this' type (a pointer to the closure type), not the
> captured
> >> +  /// 'this' type.
> >>  QualType getThisType(ASTContext ) const;
> >>
> >>  unsigned getTypeQualifiers() const {
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CodeGenFunction.cpp?rev=311589=311588=311589=diff
> >> 
> ==
> >> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Aug 23 12:39:04 2017
> >> @@ -1014,11 +1014,11 @@ void CodeGenFunction::StartFunction(Glob
> >>}
> >>
> >>// Check the 'this' pointer once per function, if it's available.
> >> -if (CXXThisValue) {
> >> +if (CXXABIThisValue) {
> >>  SanitizerSet SkippedChecks;
> >>  SkippedChecks.set(SanitizerKind::ObjectSize, true);
> >>  QualType ThisTy = MD->getThisType(getContext());
> >> -  EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,
> >> +  EmitTypeCheck(TCK_Load, Loc, CXXABIThisValue, ThisTy,
> >>getContext().getTypeAlignInChars(ThisTy->
> getPointeeType()),
> >>SkippedChecks);
> >>}
> >>
> >> Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/catch-undef-behavior.cpp?rev=311589=
> 311588=311589=diff
> >> 
> ==
> >> --- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
> >> +++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Wed Aug 23
> 12:39:04 2017
> >> @@ -449,6 +449,27 @@ void upcast_to_vbase() {
> >> }
> >> }
> >>
> >> +struct ThisAlign {
> >> +  void this_align_lambda();
> >> +};
> >> +void 

[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 112597.
danielcdh marked 3 inline comments as done.
danielcdh added a comment.

update


https://reviews.llvm.org/D37091

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/clang_f_opts.c


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -53,6 +53,9 @@
 // CHECK-REROLL-LOOPS: "-freroll-loops"
 // CHECK-NO-REROLL-LOOPS-NOT: "-freroll-loops"
 
+// RUN: %clang -### -S -fprofile-sample-accurate %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-SAMPLE-ACCURATE %s
+// CHECK-PROFILE-SAMPLE-ACCURATE: "-fprofile-sample-accurate"
+
 // RUN: %clang -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | 
FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s
 // CHECK-SAMPLE-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -652,6 +652,8 @@
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
+  Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate);
+
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.EmitSummaryIndex = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2340,6 +2340,10 @@
 true))
 CmdArgs.push_back("-fno-jump-tables");
 
+  if (Args.hasFlag(options::OPT_fprofile_sample_accurate,
+   options::OPT_fno_profile_sample_accurate, false))
+CmdArgs.push_back("-fprofile-sample-accurate");
+
   if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
 options::OPT_fno_preserve_as_comments, true))
 CmdArgs.push_back("-fno-preserve-as-comments");
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -837,6 +837,10 @@
   Fn->addFnAttr("no-jump-tables",
 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add profile-sample-accurate value.
+  if (CGM.getCodeGenOpts().ProfileSampleAccurate)
+Fn->addFnAttr("profile-sample-accurate");
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -183,6 +183,7 @@
 CODEGENOPT(UnwindTables  , 1, 0) ///< Emit unwind tables.
 CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
 CODEGENOPT(VectorizeSLP  , 1, 0) ///< Run SLP vectorizer.
+CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
 
   /// Attempt to use register sized accesses to bit-fields in structures, when
   /// possible.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -637,12 +637,25 @@
 def fprofile_sample_use_EQ : Joined<["-"], "fprofile-sample-use=">,
 Group, Flags<[DriverOption, CC1Option]>,
 HelpText<"Enable sample-based profile guided optimizations">;
+def fprofile_sample_accurate : Flag<["-"], "fprofile-sample-accurate">,
+Group, Flags<[DriverOption, CC1Option]>,
+HelpText<"Specifies that the sample profile is accurate">,
+DocBrief<[{Specifies that the sample profile is accurate. If the sample
+   profile is accurate, callsites without profile samples are 
marked
+   as cold. Otherwise, treat callsites without profile samples as 
if
+   we have no profile}]>;
+def fno_profile_sample_accurate : Flag<["-"], "fno-profile-sample-accurate">,
+  Group, Flags<[DriverOption]>;
 def fauto_profile : Flag<["-"], "fauto-profile">, Group,
 Alias;
 def fno_auto_profile : Flag<["-"], "fno-auto-profile">, Group,
 Alias;
 def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
 Alias;
+def fauto_profile_accurate : Flag<["-"], "fauto-profile-accurate">,
+Group, Alias;
+def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">,
+Group, Alias;
 def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">, 
Group,
 Flags<[CC1Option]>,
 HelpText<"Emit extra debug info to make sample profile more accurate.">;


Index: test/Driver/clang_f_opts.c
===
--- 

r311695 - [ubsan] PR34266: When sanitizing the 'this' value for a member function that happens to be a lambda call operator, use the lambda's 'this' pointer, not the captured enclosing 'this' pointer

2017-08-24 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug 24 13:10:33 2017
New Revision: 311695

URL: http://llvm.org/viewvc/llvm-project?rev=311695=rev
Log:
[ubsan] PR34266: When sanitizing the 'this' value for a member function that 
happens to be a lambda call operator, use the lambda's 'this' pointer, not the 
captured enclosing 'this' pointer (if any).

Do not sanitize the 'this' pointer of a member call operator for a lambda with
no capture-default, since that call operator can legitimately be called with a
null this pointer from the static invoker function. Any actual call with a null
this pointer should still be caught in the caller (if it is being sanitized).

This reinstates r311589 (reverted in r311680) with the above fix.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=311695=311694=311695=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Aug 24 13:10:33 2017
@@ -2027,7 +2027,10 @@ public:
 
   /// \brief Returns the type of the \c this pointer.
   ///
-  /// Should only be called for instance (i.e., non-static) methods.
+  /// Should only be called for instance (i.e., non-static) methods. Note
+  /// that for the call operator of a lambda closure type, this returns the
+  /// desugared 'this' type (a pointer to the closure type), not the captured
+  /// 'this' type.
   QualType getThisType(ASTContext ) const;
 
   unsigned getTypeQualifiers() const {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=311695=311694=311695=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Aug 24 13:10:33 2017
@@ -22,6 +22,7 @@
 #include "CodeGenPGO.h"
 #include "TargetInfo.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTLambda.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtCXX.h"
@@ -1014,11 +1015,22 @@ void CodeGenFunction::StartFunction(Glob
 }
 
 // Check the 'this' pointer once per function, if it's available.
-if (CXXThisValue) {
+if (CXXABIThisValue) {
   SanitizerSet SkippedChecks;
   SkippedChecks.set(SanitizerKind::ObjectSize, true);
   QualType ThisTy = MD->getThisType(getContext());
-  EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,
+
+  // If this is the call operator of a lambda with no capture-default, it
+  // may have a static invoker function, which may call this operator with
+  // a null 'this' pointer.
+  if (isLambdaCallOperator(MD) &&
+  cast(MD->getParent())->getLambdaCaptureDefault() ==
+  LCD_None)
+SkippedChecks.set(SanitizerKind::Null, true);
+
+  EmitTypeCheck(isa(MD) ? TCK_ConstructorCall
+: TCK_MemberCall,
+Loc, CXXABIThisValue, ThisTy,
 getContext().getTypeAlignInChars(ThisTy->getPointeeType()),
 SkippedChecks);
 }

Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=311695=311694=311695=diff
==
--- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Thu Aug 24 13:10:33 2017
@@ -449,6 +449,28 @@ void upcast_to_vbase() {
 }
 }
 
+struct ThisAlign {
+  void this_align_lambda();
+  void this_align_lambda_2();
+};
+void ThisAlign::this_align_lambda() {
+  // CHECK-LABEL: define 
{{.*}}@"_ZZN9ThisAlign17this_align_lambdaEvENK3$_0clEv"
+  // CHECK-SAME: (%{{.*}}* %[[this:[^)]*]])
+  // CHECK: %[[this_addr:.*]] = alloca
+  // CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],
+  // CHECK: %[[this_inner:.*]] = load %{{.*}}*, %{{.*}}** %[[this_addr]],
+  // CHECK: %[[this_outer_addr:.*]] = getelementptr inbounds %{{.*}}, %{{.*}}* 
%[[this_inner]], i32 0, i32 0
+  // CHECK: %[[this_outer:.*]] = load %{{.*}}*, %{{.*}}** %[[this_outer_addr]],
+  //
+  // CHECK: %[[this_inner_isnonnull:.*]] = icmp ne %{{.*}}* %[[this_inner]], 
null
+  // CHECK: %[[this_inner_asint:.*]] = ptrtoint %{{.*}}* %[[this_inner]] to i
+  // CHECK: %[[this_inner_misalignment:.*]] = and i{{32|64}} 
%[[this_inner_asint]], {{3|7}},
+  // CHECK: %[[this_inner_isaligned:.*]] = icmp eq i{{32|64}} 
%[[this_inner_misalignment]], 0
+  // CHECK: %[[this_inner_valid:.*]] = and i1 %[[this_inner_isnonnull]], 
%[[this_inner_isaligned]],
+  // CHECK: br i1 

Re: [PATCH] D36501: add flag to undo ABI change in r310401

2017-08-24 Thread John McCall via cfe-commits
> On Aug 24, 2017, at 3:48 PM, Richard Smith  wrote:
> On 24 August 2017 at 12:24, Paul Robinson via Phabricator via cfe-commits 
> > wrote:
> probinson added a comment.
> 
> Locally we have a couple different tactics for dealing with changes that we 
> can't support.  A more coherent approach would be great.
> For example we defined a new TargetCXXABI::Kind value that is mostly 
> GenericItaniumABI except where it isn't.
> I personally did not do most of the various ABI-related tweaks so I don't 
> claim to have a good handle on them, and we have been slow to get these 
> things upstream; but I'd love to make that happen.
> 
> I'm looking into adding a more general mechanism to request ABI (bug) 
> compatibility with a prior version of Clang.
> 
> Paul: is the PS4 toolchain's ABI based on that of a particular Clang release, 
> or is it a branch from trunk at some point? Or something else? (And which 
> release / revision?)
> 
> John: X86_64ABIInfo::classifyIntegerMMXAsSSE() has a special case for Darwin 
> OSes for compatibility with older Clang compilers; likewise for 
> X86_64ABIInfo::honorsRevision0_98(). Is this a case of wanting compatibility 
> with an older version of Clang by default when targeting Darwin, or is it 
> just the case that the platform ABI is different for that target (where the 
> historical reason for the different choice in the platform ABI was a bug in 
> older versions of Clang)?

The latter.  There was a bug, and we decided that we weren't allowed to fix it, 
so it's the ABI now.  Note that there's no way to override the default.

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


[PATCH] D34367: CodeGen: Fix address space of indirect function argument

2017-08-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 5 inline comments as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:3832
+ "indirect-arg-temp");
+IRCallArgs[FirstIRArg] = CastToAllocaAddrSpace(Addr.getPointer());
 

rjmccall wrote:
> Isn't the original code here correct?  You're basically just adding 
> unnecessary casts.
will remove.



Comment at: lib/CodeGen/CGCall.cpp:3851
+ ->getType()
+ ->getPointerAddressSpace();
 const unsigned ArgAddrSpace =

rjmccall wrote:
> Hmm.  Is there actually a test case where Addr.getType()->getAddressSpace() 
> is not the lowering of LangAS::Default?  The correctness of the 
> performAddrSpaceCast call you make depends on that.
> 
> If there isn't, I think it would be better to add a target hook to attempt to 
> peephole an addrspace cast:
>   llvm::Value *tryPeepholeAddrSpaceCast(llvm::Value*, unsigned valueAS, 
> unsigned targetAS);
> 
> And then you can just do
>   bool HasAddrSpaceMismatch = CGM.getASTAllocaAddrSpace() != LangAS::Default);
>   if (HasAddrSpaceMismatch) {
> if (llvm::Value *ptr = tryPeepholeAddrSpaceCast(Addr.getPointer(), 
> LangAS::Default, getASTAllocAddrSpace())) {
>   Addr = Address(ptr, Addr.getAlignment()); // might need to cast the 
> element type for this
>   HasAddrSpaceMismatch = false;
> }
>   }
It is possible RVAddrSpace is not default addr space. e.g. in OpenCL

```
global struct S g_s;

void f(struct S s);

void g() {
  f(g_s);
}

```

One thing that confuses me is that why creating temp and copying can be skipped 
if RVAddrSpace equals alloca addr space. The callee is supposed to work on a 
copy of the arg, not the arg itself, right? Shouldn't the arg always be coped 
to a temp then pass to the callee?



Comment at: lib/CodeGen/CGCall.cpp:3865
+ "byval-temp");
+  IRCallArgs[FirstIRArg] = CastToAllocaAddrSpace(AI.getPointer());
   EmitAggregateCopy(AI, Addr, I->Ty, RV.isVolatileQualified());

rjmccall wrote:
> Same thing, no reason to do the casts here.
will remove



Comment at: lib/CodeGen/CGDecl.cpp:1828
+auto DestAS = getContext().getTargetAddressSpace(LangAS::Default);
+if (SrcAS != DestAS) {
+  assert(SrcAS == CGM.getDataLayout().getAllocaAddrSpace());

rjmccall wrote:
> This should be comparing AST address spaces.
will do.


https://reviews.llvm.org/D34367



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


Re: [PATCH] D36501: add flag to undo ABI change in r310401

2017-08-24 Thread Richard Smith via cfe-commits
On 24 August 2017 at 12:24, Paul Robinson via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> probinson added a comment.
>
> Locally we have a couple different tactics for dealing with changes that
> we can't support.  A more coherent approach would be great.
> For example we defined a new TargetCXXABI::Kind value that is mostly
> GenericItaniumABI except where it isn't.
> I personally did not do most of the various ABI-related tweaks so I don't
> claim to have a good handle on them, and we have been slow to get these
> things upstream; but I'd love to make that happen.


I'm looking into adding a more general mechanism to request ABI (bug)
compatibility with a prior version of Clang.

Paul: is the PS4 toolchain's ABI based on that of a particular Clang
release, or is it a branch from trunk at some point? Or something else?
(And which release / revision?)

John: X86_64ABIInfo::classifyIntegerMMXAsSSE() has a special case for
Darwin OSes for compatibility with older Clang compilers; likewise for
X86_64ABIInfo::honorsRevision0_98(). Is this a case of wanting
compatibility with an older version of Clang by default when targeting
Darwin, or is it just the case that the platform ABI is different for that
target (where the historical reason for the different choice in the
platform ABI was a bug in older versions of Clang)?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36501: add flag to undo ABI change in r310401

2017-08-24 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Locally we have a couple different tactics for dealing with changes that we 
can't support.  A more coherent approach would be great.
For example we defined a new TargetCXXABI::Kind value that is mostly 
GenericItaniumABI except where it isn't.
I personally did not do most of the various ABI-related tweaks so I don't claim 
to have a good handle on them, and we have been slow to get these things 
upstream; but I'd love to make that happen.


Repository:
  rL LLVM

https://reviews.llvm.org/D36501



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


[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: docs/ClangCommandLineReference.rst:173-180
+.. option:: -faccurate-sample-profile, -fno-accurate-sample-profile
+.. program:: clang
+
+If the sample profile is accurate, callsites without profile samples are marked
+as cold. Otherwise, treat un-sampled callsites as if we have no profile. This
+option can be used to enable more aggressive size optimization based on
+profiles.

This is a generated file; please don't modify it by hand.



Comment at: include/clang/Driver/Options.td:590
 def faccess_control : Flag<["-"], "faccess-control">, Group;
+def faccurate_sample_profile : Flag<["-"], "faccurate-sample-profile">,
+  Group, Flags<[DriverOption, CC1Option]>,

We generally try to group similar options together under a common prefix. Would 
`-fprofile-sample-accurate` work here?



Comment at: include/clang/Driver/Options.td:592-594
+  HelpText<"If sample profile is accurate, we will mark all un-sampled "
+   "callsite as cold. Otherwise, treat callsites without profile "
+   "samples as if we have no profile">;

`HelpText` should be a very brief string that can be included in a one-line 
description of the flag for `--help`. Longer text for inclusion in the option 
reference should be in a `DocBrief<{blah blah blah.}>`.

Also, it seems to me that this help text doesn't actually say what the option 
does. Does this request that accurate sample profiles be generated, or specify 
that an accurate sample profile was provided, or what? Suggestion:

```
HelpText<"Specifies that the sample profile is accurate">,
DocBrief<{Specifies that the sample profile is accurate. If the sample profile 
is accurate, callsites without profile samples are marked as cold. [...same as 
current reference documentation text...]}>
```


https://reviews.llvm.org/D37091



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


[PATCH] D36272: [CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Aaron would likely know better than me... but could it be the spelling type 
should be GCC instead of GNU?


https://reviews.llvm.org/D36272



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


Re: r298574 - Fix issues in clang-format's AlignConsecutive modes.

2017-08-24 Thread Hans Wennborg via cfe-commits
This caused https://bugs.llvm.org/show_bug.cgi?id=33507 which is one
of the last release blockers for 5.0.0.

Can someone who's familiar with this code please take a look?

On Thu, Aug 24, 2017 at 11:12 AM, Hans Wennborg  wrote:
> For reference, this was reviewed in https://reviews.llvm.org/D21279
>
> (Please always include review links in the future.)
>
> On Wed, Mar 22, 2017 at 7:51 PM, Nikola Smiljanic via cfe-commits
>  wrote:
>> Author: nikola
>> Date: Wed Mar 22 21:51:25 2017
>> New Revision: 298574
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=298574=rev
>> Log:
>> Fix issues in clang-format's AlignConsecutive modes.
>>
>> Patch by Ben Harper.
>>
>> Modified:
>> cfe/trunk/lib/Format/WhitespaceManager.cpp
>> cfe/trunk/lib/Format/WhitespaceManager.h
>> cfe/trunk/unittests/Format/FormatTest.cpp
>>
>> Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=298574=298573=298574=diff
>> ==
>> --- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
>> +++ cfe/trunk/lib/Format/WhitespaceManager.cpp Wed Mar 22 21:51:25 2017
>> @@ -50,9 +50,9 @@ void WhitespaceManager::replaceWhitespac
>>if (Tok.Finalized)
>>  return;
>>Tok.Decision = (Newlines > 0) ? FD_Break : FD_Continue;
>> -  Changes.push_back(Change(Tok, /*CreateReplacement=*/true,
>> -   Tok.WhitespaceRange, Spaces, StartOfTokenColumn,
>> -   Newlines, "", "", InPPDirective && !Tok.IsFirst,
>> +  Changes.push_back(Change(Tok, /*CreateReplacement=*/true, 
>> Tok.WhitespaceRange,
>> +   Spaces, StartOfTokenColumn, Newlines, "", "",
>> +   InPPDirective && !Tok.IsFirst,
>> /*IsInsideToken=*/false));
>>  }
>>
>> @@ -192,21 +192,56 @@ AlignTokenSequence(unsigned Start, unsig
>> SmallVector ) {
>>bool FoundMatchOnLine = false;
>>int Shift = 0;
>> +
>> +  // ScopeStack keeps track of the current scope depth. It contains indices 
>> of
>> +  // the first token on each scope.
>> +  // We only run the "Matches" function on tokens from the outer-most scope.
>> +  // However, we do need to pay special attention to one class of tokens
>> +  // that are not in the outer-most scope, and that is function parameters
>> +  // which are split across multiple lines, as illustrated by this example:
>> +  //   double a(int x);
>> +  //   intb(int  y,
>> +  //  double z);
>> +  // In the above example, we need to take special care to ensure that
>> +  // 'double z' is indented along with it's owning function 'b'.
>> +  SmallVector ScopeStack;
>> +
>>for (unsigned i = Start; i != End; ++i) {
>> -if (Changes[i].NewlinesBefore > 0) {
>> -  FoundMatchOnLine = false;
>> +if (ScopeStack.size() != 0 &&
>> +Changes[i].nestingAndIndentLevel() <
>> +Changes[ScopeStack.back()].nestingAndIndentLevel())
>> +  ScopeStack.pop_back();
>> +
>> +if (i != Start && Changes[i].nestingAndIndentLevel() >
>> +  Changes[i - 1].nestingAndIndentLevel())
>> +  ScopeStack.push_back(i);
>> +
>> +bool InsideNestedScope = ScopeStack.size() != 0;
>> +
>> +if (Changes[i].NewlinesBefore > 0 && !InsideNestedScope) {
>>Shift = 0;
>> +  FoundMatchOnLine = false;
>>  }
>>
>>  // If this is the first matching token to be aligned, remember by how 
>> many
>>  // spaces it has to be shifted, so the rest of the changes on the line 
>> are
>>  // shifted by the same amount
>> -if (!FoundMatchOnLine && Matches(Changes[i])) {
>> +if (!FoundMatchOnLine && !InsideNestedScope && Matches(Changes[i])) {
>>FoundMatchOnLine = true;
>>Shift = Column - Changes[i].StartOfTokenColumn;
>>Changes[i].Spaces += Shift;
>>  }
>>
>> +// This is for function parameters that are split across multiple lines,
>> +// as mentioned in the ScopeStack comment.
>> +if (InsideNestedScope && Changes[i].NewlinesBefore > 0) {
>> +  unsigned ScopeStart = ScopeStack.back();
>> +  if (Changes[ScopeStart - 1].Tok->is(TT_FunctionDeclarationName) ||
>> +  (ScopeStart > Start + 1 &&
>> +   Changes[ScopeStart - 2].Tok->is(TT_FunctionDeclarationName)))
>> +Changes[i].Spaces += Shift;
>> +}
>> +
>>  assert(Shift >= 0);
>>  Changes[i].StartOfTokenColumn += Shift;
>>  if (i + 1 != Changes.size())
>> @@ -214,15 +249,37 @@ AlignTokenSequence(unsigned Start, unsig
>>}
>>  }
>>
>> -// Walk through all of the changes and find sequences of matching tokens to
>> -// align. To do so, keep track of the lines and whether or not a matching 
>> token
>> -// was found on a line. If a matching token is found, extend the 

[PATCH] D36272: [CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64

2017-08-24 Thread Anatol Pomozov via Phabricator via cfe-commits
anatol.pomozov added a comment.

> Additionally, there is likely value to split the test run-line into 2, one 
> that specifies 64 bit Windows and one that is 64 bit Linux.  The value being 
> that they validate two different code paths (whereas 32 is the same code 
> path).

I added a RUN for triplet '-triple x86_64-pc-win32' and tests are failing for 
me. I rebuilt clang without my patches and still see the same failure. It looks 
like the original function-attributes currently does not work with win32 
triplet.

  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  /mnt/cold/sources/llvm/tools/clang/test/CodeGen/function-attributes.c:76:21: 
warning: unknown attribute 'force_align_arg_pointer' ignored
  void __attribute__((force_align_arg_pointer)) f16(void) {
  ^
  1 warning generated.
  /mnt/cold/sources/llvm/tools/clang/test/CodeGen/function-attributes.c:4:11: 
error: expected string not found in input
  // CHECK: define signext i8 @f0(i32 %x) [[NUW:#[0-9]+]]
^
  :1:1: note: scanning from here
  ; ModuleID = 
'/mnt/cold/sources/llvm/tools/clang/test/CodeGen/function-attributes.c'
  ^
  :7:1: note: possible intended match here
  define i8 @f0(i32 %x) #0 {
  ^
  /mnt/cold/sources/llvm/tools/clang/test/CodeGen/function-attributes.c:67:11: 
error: expected string not found in input
  // CHECK: [[NUW]]
^
  :158:17: note: scanning from here
  define void @f15() #0 {
  ^
  :158:17: note: uses undefined variable "NUW"
  define void @f15() #0 {
  ^
  /mnt/cold/sources/llvm/tools/clang/test/CodeGen/function-attributes.c:104:11: 
error: expected string not found in input
  // CHECK: call i32 @_setjmp(i32* null)
^
  :191:1: note: scanning from here
  entry:
  ^
  :193:7: note: possible intended match here
   %1 = call i32 @_setjmp(i8* null, i8* %0) #7
^
  
  --


https://reviews.llvm.org/D36272



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


[PATCH] D36272: [CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64

2017-08-24 Thread Anatol Pomozov via Phabricator via cfe-commits
anatol.pomozov added a comment.

Related maillist discussion is 
http://lists.llvm.org/pipermail/cfe-dev/2017-June/054359.html

> Are we SURE the stack alignment for this type is supposed to be 16 bit as 
> well?  I didn't see any discussion about it in the email conversation.
>  I have very little understanding of this attribute, but I would (perhaps 
> naiively) presume that it would be different on 64 bit targets.

x86_64 ABI requires 16-byte stack alignment and compiler already enforces it at 
the caller side. It does not work when we jump from 32bit code (where stack 
might not be 16-byte aligned) to 64bit code. So we need a way to enforce the 
stack alignment at  callee side. In this case the attribute above is helpful.


https://reviews.llvm.org/D36272



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


[PATCH] D37079: [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311683: [Preprocessor] Correct internal token parsing of 
newline characters in CRLF (authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D37079?vs=112581=112589#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37079

Files:
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/test/Frontend/.gitattributes
  cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c


Index: cfe/trunk/test/Frontend/.gitattributes
===
--- cfe/trunk/test/Frontend/.gitattributes
+++ cfe/trunk/test/Frontend/.gitattributes
@@ -0,0 +1,2 @@
+# Below test validates crlf line endings, so it should stay crlf.
+system-header-line-directive-ms-lineendings.c text eol=crlf
Index: cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
===
--- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
+++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem 
%S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly 
outputted
+// for the include-file-completed test case.  
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -3073,6 +3073,8 @@
   
   case '\n':
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {


Index: cfe/trunk/test/Frontend/.gitattributes
===
--- cfe/trunk/test/Frontend/.gitattributes
+++ cfe/trunk/test/Frontend/.gitattributes
@@ -0,0 +1,2 @@
+# Below test validates crlf line endings, so it should stay crlf.
+system-header-line-directive-ms-lineendings.c text eol=crlf
Index: cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
===
--- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
+++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem %S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly outputted
+// for the include-file-completed test case.  
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -3073,6 +3073,8 @@
   
   case '\n':
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r311683 - [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Aug 24 11:36:07 2017
New Revision: 311683

URL: http://llvm.org/viewvc/llvm-project?rev=311683=rev
Log:
[Preprocessor] Correct internal token parsing of newline characters in CRLF

Discovered due to a goofy git setup, the test system-headerline-directive.c 
(and a few others) failed because the token-consumption will consume only the 
'\r' in CRLF, making the preprocessor's printed value give the wrong line 
number 
when returning from an include. For example:

(line 1):#include \r\n

The "file exit" code causes the printer to try to print the 'returned to the 
main file' line. It looks up what the current line number is. However, since 
the 
current 'token' is the '\n' (since only the \r was consumed), it will give the 
line number as '1", not '2'. This results in a few failed tests, but more 
importantly, results in error messages being incorrect when compiling a 
previously preprocessed file.

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

Added:
cfe/trunk/test/Frontend/.gitattributes
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c   
(with props)
Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=311683=311682=311683=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Thu Aug 24 11:36:07 2017
@@ -3073,6 +3073,8 @@ LexNextToken:
   
   case '\n':
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {

Added: cfe/trunk/test/Frontend/.gitattributes
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/.gitattributes?rev=311683=auto
==
--- cfe/trunk/test/Frontend/.gitattributes (added)
+++ cfe/trunk/test/Frontend/.gitattributes Thu Aug 24 11:36:07 2017
@@ -0,0 +1,2 @@
+# Below test validates crlf line endings, so it should stay crlf.
+system-header-line-directive-ms-lineendings.c text eol=crlf

Added: cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c?rev=311683=auto
==
--- cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c 
(added)
+++ cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c Thu 
Aug 24 11:36:07 2017
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem 
%S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly 
outputted
+// for the include-file-completed test case.  
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2

Propchange: 
cfe/trunk/test/Frontend/system-header-line-directive-ms-lineendings.c
--
svn:eol-style = CRLF


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


[PATCH] D37115: [coroutines] Do not attempt to typo-correct when coroutine is looking for required members

2017-08-24 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.

When SemaCoroutine looks for await_resume, it means it. No need for helpful: 
"Did you mean await_ready?" messages.

Fixes PR33477 and a couple of FIXMEs in test/SemaCXX/coroutines.cpp


https://reviews.llvm.org/D37115

Files:
  lib/Sema/SemaCoroutine.cpp
  test/SemaCXX/coroutines.cpp


Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -500,8 +500,7 @@
 
 struct bad_promise_2 {
   coro get_return_object();
-  // FIXME: We shouldn't offer a typo-correction here!
-  suspend_always final_suspend(); // expected-note {{here}}
+  suspend_always final_suspend();
   void unhandled_exception();
   void return_void();
 };
@@ -512,8 +511,7 @@
 
 struct bad_promise_3 {
   coro get_return_object();
-  // FIXME: We shouldn't offer a typo-correction here!
-  suspend_always initial_suspend(); // expected-note {{here}}
+  suspend_always initial_suspend();
   void unhandled_exception();
   void return_void();
 };
@@ -1162,3 +1160,22 @@
 template CoroMemberTag DepTestType::test_static_template(const char 
*volatile &, unsigned);
 
 } // namespace CoroHandleMemberFunctionTest
+
+struct missing_await_ready {
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct missing_await_suspend {
+  bool await_ready();
+  void await_resume();
+};
+struct missing_await_resume {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+};
+
+void test_missing_awaitable_members() {
+  co_await missing_await_ready{}; // expected-error {{no member named 
'await_ready' in 'missing_await_ready'}}
+  co_await missing_await_suspend{}; // expected-error {{no member named 
'await_suspend' in 'missing_await_suspend'}}
+  co_await missing_await_resume{}; // expected-error {{no member named 
'await_resume' in 'missing_await_resume'}}
+}
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -360,6 +360,15 @@
   if (Result.isInvalid())
 return ExprError();
 
+  // We meant exactly what we asked for. No need for typo correction.
+  if (auto *TE = dyn_cast(Result.get())) {
+S.clearDelayedTypo(TE);
+S.Diag(Loc, diag::err_no_member)
+<< NameInfo.getName() << Base->getType()->getAsCXXRecordDecl()
+<< Base->getSourceRange();
+return ExprError();
+  }
+
   return S.ActOnCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr);
 }
 


Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -500,8 +500,7 @@
 
 struct bad_promise_2 {
   coro get_return_object();
-  // FIXME: We shouldn't offer a typo-correction here!
-  suspend_always final_suspend(); // expected-note {{here}}
+  suspend_always final_suspend();
   void unhandled_exception();
   void return_void();
 };
@@ -512,8 +511,7 @@
 
 struct bad_promise_3 {
   coro get_return_object();
-  // FIXME: We shouldn't offer a typo-correction here!
-  suspend_always initial_suspend(); // expected-note {{here}}
+  suspend_always initial_suspend();
   void unhandled_exception();
   void return_void();
 };
@@ -1162,3 +1160,22 @@
 template CoroMemberTag DepTestType::test_static_template(const char *volatile &, unsigned);
 
 } // namespace CoroHandleMemberFunctionTest
+
+struct missing_await_ready {
+  void await_suspend(std::experimental::coroutine_handle<>);
+  void await_resume();
+};
+struct missing_await_suspend {
+  bool await_ready();
+  void await_resume();
+};
+struct missing_await_resume {
+  bool await_ready();
+  void await_suspend(std::experimental::coroutine_handle<>);
+};
+
+void test_missing_awaitable_members() {
+  co_await missing_await_ready{}; // expected-error {{no member named 'await_ready' in 'missing_await_ready'}}
+  co_await missing_await_suspend{}; // expected-error {{no member named 'await_suspend' in 'missing_await_suspend'}}
+  co_await missing_await_resume{}; // expected-error {{no member named 'await_resume' in 'missing_await_resume'}}
+}
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -360,6 +360,15 @@
   if (Result.isInvalid())
 return ExprError();
 
+  // We meant exactly what we asked for. No need for typo correction.
+  if (auto *TE = dyn_cast(Result.get())) {
+S.clearDelayedTypo(TE);
+S.Diag(Loc, diag::err_no_member)
+<< NameInfo.getName() << Base->getType()->getAsCXXRecordDecl()
+<< Base->getSourceRange();
+return ExprError();
+  }
+
   return S.ActOnCallExpr(nullptr, Result.get(), Loc, Args, Loc, nullptr);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

Re: r311589 - [ubsan] PR34266: When sanitizing the 'this' value for a member function that happens to be a lambda call operator, use the lambda's 'this' pointer, not the captured enclosing 'this' poin

2017-08-24 Thread Adrian Prantl via cfe-commits
I temporarily reverted the commit in r311680 to get the bots going again.

-- adrian

> On Aug 24, 2017, at 11:12 AM, Adrian Prantl via cfe-commits 
>  wrote:
> 
> It looks like this broke / found errors on the green dragon bot:
> 
> http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_check/4115/consoleFull#15752874848254eaf0-7326-4999-85b0-388101f2d404
> 
>  TEST 'LLVM-Unit :: 
> ADT/./ADTTests/FilterIteratorTest.FunctionPointer' FAILED 
> 
> Note: Google Test filter = FilterIteratorTest.FunctionPointer
> [==] Running 1 test from 1 test case.
> [--] Global test environment set-up.
> [--] 1 test from FilterIteratorTest
> [ RUN  ] FilterIteratorTest.FunctionPointer
> /Users/buildslave/jenkins/sharedspace/clang-stage2-cmake-RgSan@2/llvm/unittests/ADT/IteratorTest.cpp:160:24:
>  runtime error: load of null pointer of type 'const (lambda at 
> /Users/buildslave/jenkins/sharedspace/clang-stage2-cmake-RgSan@2/llvm/unittests/ADT/IteratorTest.cpp:160:24)
>  *'
> SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
> /Users/buildslave/jenkins/sharedspace/clang-stage2-cmake-RgSan@2/llvm/unittests/ADT/IteratorTest.cpp:160:24
>  in 
> 
> 
> 
> -- adrian
>> On Aug 23, 2017, at 12:39 PM, Richard Smith via cfe-commits 
>>  wrote:
>> 
>> Author: rsmith
>> Date: Wed Aug 23 12:39:04 2017
>> New Revision: 311589
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=311589=rev
>> Log:
>> [ubsan] PR34266: When sanitizing the 'this' value for a member function that 
>> happens to be a lambda call operator, use the lambda's 'this' pointer, not 
>> the captured enclosing 'this' pointer (if any).
>> 
>> Modified:
>>   cfe/trunk/include/clang/AST/DeclCXX.h
>>   cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>>   cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
>> 
>> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=311589=311588=311589=diff
>> ==
>> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Aug 23 12:39:04 2017
>> @@ -2027,7 +2027,10 @@ public:
>> 
>>  /// \brief Returns the type of the \c this pointer.
>>  ///
>> -  /// Should only be called for instance (i.e., non-static) methods.
>> +  /// Should only be called for instance (i.e., non-static) methods. Note
>> +  /// that for the call operator of a lambda closure type, this returns the
>> +  /// desugared 'this' type (a pointer to the closure type), not the 
>> captured
>> +  /// 'this' type.
>>  QualType getThisType(ASTContext ) const;
>> 
>>  unsigned getTypeQualifiers() const {
>> 
>> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=311589=311588=311589=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Aug 23 12:39:04 2017
>> @@ -1014,11 +1014,11 @@ void CodeGenFunction::StartFunction(Glob
>>}
>> 
>>// Check the 'this' pointer once per function, if it's available.
>> -if (CXXThisValue) {
>> +if (CXXABIThisValue) {
>>  SanitizerSet SkippedChecks;
>>  SkippedChecks.set(SanitizerKind::ObjectSize, true);
>>  QualType ThisTy = MD->getThisType(getContext());
>> -  EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,
>> +  EmitTypeCheck(TCK_Load, Loc, CXXABIThisValue, ThisTy,
>>
>> getContext().getTypeAlignInChars(ThisTy->getPointeeType()),
>>SkippedChecks);
>>}
>> 
>> Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=311589=311588=311589=diff
>> ==
>> --- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
>> +++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Wed Aug 23 12:39:04 
>> 2017
>> @@ -449,6 +449,27 @@ void upcast_to_vbase() {
>> }
>> }
>> 
>> +struct ThisAlign {
>> +  void this_align_lambda();
>> +};
>> +void ThisAlign::this_align_lambda() {
>> +  // CHECK-LABEL: define 
>> {{.*}}@"_ZZN9ThisAlign17this_align_lambdaEvENK3$_0clEv"
>> +  // CHECK-SAME: (%{{.*}}* %[[this:[^)]*]])
>> +  // CHECK: %[[this_addr:.*]] = alloca
>> +  // CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],
>> +  // CHECK: %[[this_inner:.*]] = load %{{.*}}*, %{{.*}}** %[[this_addr]],
>> +  // CHECK: %[[this_outer_addr:.*]] = getelementptr inbounds %{{.*}}, 
>> %{{.*}}* %[[this_inner]], i32 0, i32 0
>> +  // CHECK: %[[this_outer:.*]] = load %{{.*}}*, %{{.*}}** 
>> %[[this_outer_addr]],
>> +  //
>> +  // 

r311680 - Revert "[ubsan] PR34266: When sanitizing the 'this' value for a member function that happens to be a lambda call operator, use the lambda's 'this' pointer, not the captured enclosing 'this'

2017-08-24 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Aug 24 11:18:24 2017
New Revision: 311680

URL: http://llvm.org/viewvc/llvm-project?rev=311680=rev
Log:
Revert "[ubsan] PR34266: When sanitizing the 'this' value for a member function 
that happens to be a lambda call operator, use the lambda's 'this' pointer, not 
the captured enclosing 'this' pointer (if any)."

This reverts commit r311589 because of bot breakage.
http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_check/4115/consoleFull#15752874848254eaf0-7326-4999-85b0-388101f2d404.

Modified:
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=311680=311679=311680=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Thu Aug 24 11:18:24 2017
@@ -2027,10 +2027,7 @@ public:
 
   /// \brief Returns the type of the \c this pointer.
   ///
-  /// Should only be called for instance (i.e., non-static) methods. Note
-  /// that for the call operator of a lambda closure type, this returns the
-  /// desugared 'this' type (a pointer to the closure type), not the captured
-  /// 'this' type.
+  /// Should only be called for instance (i.e., non-static) methods.
   QualType getThisType(ASTContext ) const;
 
   unsigned getTypeQualifiers() const {

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=311680=311679=311680=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu Aug 24 11:18:24 2017
@@ -1014,11 +1014,11 @@ void CodeGenFunction::StartFunction(Glob
 }
 
 // Check the 'this' pointer once per function, if it's available.
-if (CXXABIThisValue) {
+if (CXXThisValue) {
   SanitizerSet SkippedChecks;
   SkippedChecks.set(SanitizerKind::ObjectSize, true);
   QualType ThisTy = MD->getThisType(getContext());
-  EmitTypeCheck(TCK_Load, Loc, CXXABIThisValue, ThisTy,
+  EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,
 getContext().getTypeAlignInChars(ThisTy->getPointeeType()),
 SkippedChecks);
 }

Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=311680=311679=311680=diff
==
--- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Thu Aug 24 11:18:24 2017
@@ -449,27 +449,6 @@ void upcast_to_vbase() {
 }
 }
 
-struct ThisAlign {
-  void this_align_lambda();
-};
-void ThisAlign::this_align_lambda() {
-  // CHECK-LABEL: define 
{{.*}}@"_ZZN9ThisAlign17this_align_lambdaEvENK3$_0clEv"
-  // CHECK-SAME: (%{{.*}}* %[[this:[^)]*]])
-  // CHECK: %[[this_addr:.*]] = alloca
-  // CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],
-  // CHECK: %[[this_inner:.*]] = load %{{.*}}*, %{{.*}}** %[[this_addr]],
-  // CHECK: %[[this_outer_addr:.*]] = getelementptr inbounds %{{.*}}, %{{.*}}* 
%[[this_inner]], i32 0, i32 0
-  // CHECK: %[[this_outer:.*]] = load %{{.*}}*, %{{.*}}** %[[this_outer_addr]],
-  //
-  // CHECK: %[[this_inner_isnonnull:.*]] = icmp ne %{{.*}}* %[[this_inner]], 
null
-  // CHECK: %[[this_inner_asint:.*]] = ptrtoint %{{.*}}* %[[this_inner]] to i
-  // CHECK: %[[this_inner_misalignment:.*]] = and i{{32|64}} 
%[[this_inner_asint]], {{3|7}},
-  // CHECK: %[[this_inner_isaligned:.*]] = icmp eq i{{32|64}} 
%[[this_inner_misalignment]], 0
-  // CHECK: %[[this_inner_valid:.*]] = and i1 %[[this_inner_isnonnull]], 
%[[this_inner_isaligned]],
-  // CHECK: br i1 %[[this_inner_valid:.*]]
-  [&] { return this; } ();
-}
-
 namespace CopyValueRepresentation {
   // CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S3aSERKS0_
   // CHECK-NOT: call {{.*}} @__ubsan_handle_load_invalid_value


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


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-24 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

@arphaman

  The selection requirement is supposed to be orthogonal to AST matchers, not a 
replacement. It should be used when working with source selection in editors. 
  I did mess around with moving over clang-reorder-fields using this kind of 
model and didn't see any issues when using AST matchers. Essentially I used the 
 requiredOption requirements and mapped them to run my 
  matching code instead of using the selection requirement. Thus this 
requirement was satisfied only when the AST matchers were successful. 
  It might be possible to simplify that pattern even further to make it simpler.

that's great, i'm interested in this too and would be happy to see 
clang-reorder-fields moving to clang-refactor (pls, let me know if i can help 
make this happen)


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D36501: add flag to undo ABI change in r310401

2017-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D36501#836257, @rjmccall wrote:

> Yeah, I think having an internal C++ ABI version makes a lot more sense than 
> having a million different flags.  Is there a reason to expose this as a knob 
> to users at all?


I don't see any reason anyone would want to use this other than to restore the 
ABI to that of Clang <= 4, so an overall "clang ABI version" flag would seem 
reasonable to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D36501



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


Re: r298574 - Fix issues in clang-format's AlignConsecutive modes.

2017-08-24 Thread Hans Wennborg via cfe-commits
For reference, this was reviewed in https://reviews.llvm.org/D21279

(Please always include review links in the future.)

On Wed, Mar 22, 2017 at 7:51 PM, Nikola Smiljanic via cfe-commits
 wrote:
> Author: nikola
> Date: Wed Mar 22 21:51:25 2017
> New Revision: 298574
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298574=rev
> Log:
> Fix issues in clang-format's AlignConsecutive modes.
>
> Patch by Ben Harper.
>
> Modified:
> cfe/trunk/lib/Format/WhitespaceManager.cpp
> cfe/trunk/lib/Format/WhitespaceManager.h
> cfe/trunk/unittests/Format/FormatTest.cpp
>
> Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=298574=298573=298574=diff
> ==
> --- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
> +++ cfe/trunk/lib/Format/WhitespaceManager.cpp Wed Mar 22 21:51:25 2017
> @@ -50,9 +50,9 @@ void WhitespaceManager::replaceWhitespac
>if (Tok.Finalized)
>  return;
>Tok.Decision = (Newlines > 0) ? FD_Break : FD_Continue;
> -  Changes.push_back(Change(Tok, /*CreateReplacement=*/true,
> -   Tok.WhitespaceRange, Spaces, StartOfTokenColumn,
> -   Newlines, "", "", InPPDirective && !Tok.IsFirst,
> +  Changes.push_back(Change(Tok, /*CreateReplacement=*/true, 
> Tok.WhitespaceRange,
> +   Spaces, StartOfTokenColumn, Newlines, "", "",
> +   InPPDirective && !Tok.IsFirst,
> /*IsInsideToken=*/false));
>  }
>
> @@ -192,21 +192,56 @@ AlignTokenSequence(unsigned Start, unsig
> SmallVector ) {
>bool FoundMatchOnLine = false;
>int Shift = 0;
> +
> +  // ScopeStack keeps track of the current scope depth. It contains indices 
> of
> +  // the first token on each scope.
> +  // We only run the "Matches" function on tokens from the outer-most scope.
> +  // However, we do need to pay special attention to one class of tokens
> +  // that are not in the outer-most scope, and that is function parameters
> +  // which are split across multiple lines, as illustrated by this example:
> +  //   double a(int x);
> +  //   intb(int  y,
> +  //  double z);
> +  // In the above example, we need to take special care to ensure that
> +  // 'double z' is indented along with it's owning function 'b'.
> +  SmallVector ScopeStack;
> +
>for (unsigned i = Start; i != End; ++i) {
> -if (Changes[i].NewlinesBefore > 0) {
> -  FoundMatchOnLine = false;
> +if (ScopeStack.size() != 0 &&
> +Changes[i].nestingAndIndentLevel() <
> +Changes[ScopeStack.back()].nestingAndIndentLevel())
> +  ScopeStack.pop_back();
> +
> +if (i != Start && Changes[i].nestingAndIndentLevel() >
> +  Changes[i - 1].nestingAndIndentLevel())
> +  ScopeStack.push_back(i);
> +
> +bool InsideNestedScope = ScopeStack.size() != 0;
> +
> +if (Changes[i].NewlinesBefore > 0 && !InsideNestedScope) {
>Shift = 0;
> +  FoundMatchOnLine = false;
>  }
>
>  // If this is the first matching token to be aligned, remember by how 
> many
>  // spaces it has to be shifted, so the rest of the changes on the line 
> are
>  // shifted by the same amount
> -if (!FoundMatchOnLine && Matches(Changes[i])) {
> +if (!FoundMatchOnLine && !InsideNestedScope && Matches(Changes[i])) {
>FoundMatchOnLine = true;
>Shift = Column - Changes[i].StartOfTokenColumn;
>Changes[i].Spaces += Shift;
>  }
>
> +// This is for function parameters that are split across multiple lines,
> +// as mentioned in the ScopeStack comment.
> +if (InsideNestedScope && Changes[i].NewlinesBefore > 0) {
> +  unsigned ScopeStart = ScopeStack.back();
> +  if (Changes[ScopeStart - 1].Tok->is(TT_FunctionDeclarationName) ||
> +  (ScopeStart > Start + 1 &&
> +   Changes[ScopeStart - 2].Tok->is(TT_FunctionDeclarationName)))
> +Changes[i].Spaces += Shift;
> +}
> +
>  assert(Shift >= 0);
>  Changes[i].StartOfTokenColumn += Shift;
>  if (i + 1 != Changes.size())
> @@ -214,15 +249,37 @@ AlignTokenSequence(unsigned Start, unsig
>}
>  }
>
> -// Walk through all of the changes and find sequences of matching tokens to
> -// align. To do so, keep track of the lines and whether or not a matching 
> token
> -// was found on a line. If a matching token is found, extend the current
> -// sequence. If the current line cannot be part of a sequence, e.g. because
> -// there is an empty line before it or it contains only non-matching tokens,
> -// finalize the previous sequence.
> +// Walk through a subset of the changes, starting at StartAt, and find
> +// sequences of matching tokens to align. To do so, keep track of the lines 
> and
> 

Re: r311589 - [ubsan] PR34266: When sanitizing the 'this' value for a member function that happens to be a lambda call operator, use the lambda's 'this' pointer, not the captured enclosing 'this' poin

2017-08-24 Thread Adrian Prantl via cfe-commits
It looks like this broke / found errors on the green dragon bot:

http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_check/4115/consoleFull#15752874848254eaf0-7326-4999-85b0-388101f2d404

 TEST 'LLVM-Unit :: 
ADT/./ADTTests/FilterIteratorTest.FunctionPointer' FAILED 

Note: Google Test filter = FilterIteratorTest.FunctionPointer
[==] Running 1 test from 1 test case.
[--] Global test environment set-up.
[--] 1 test from FilterIteratorTest
[ RUN  ] FilterIteratorTest.FunctionPointer
/Users/buildslave/jenkins/sharedspace/clang-stage2-cmake-RgSan@2/llvm/unittests/ADT/IteratorTest.cpp:160:24:
 runtime error: load of null pointer of type 'const (lambda at 
/Users/buildslave/jenkins/sharedspace/clang-stage2-cmake-RgSan@2/llvm/unittests/ADT/IteratorTest.cpp:160:24)
 *'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
/Users/buildslave/jenkins/sharedspace/clang-stage2-cmake-RgSan@2/llvm/unittests/ADT/IteratorTest.cpp:160:24
 in 



-- adrian
> On Aug 23, 2017, at 12:39 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Wed Aug 23 12:39:04 2017
> New Revision: 311589
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=311589=rev
> Log:
> [ubsan] PR34266: When sanitizing the 'this' value for a member function that 
> happens to be a lambda call operator, use the lambda's 'this' pointer, not 
> the captured enclosing 'this' pointer (if any).
> 
> Modified:
>cfe/trunk/include/clang/AST/DeclCXX.h
>cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
>cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> 
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=311589=311588=311589=diff
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Aug 23 12:39:04 2017
> @@ -2027,7 +2027,10 @@ public:
> 
>   /// \brief Returns the type of the \c this pointer.
>   ///
> -  /// Should only be called for instance (i.e., non-static) methods.
> +  /// Should only be called for instance (i.e., non-static) methods. Note
> +  /// that for the call operator of a lambda closure type, this returns the
> +  /// desugared 'this' type (a pointer to the closure type), not the captured
> +  /// 'this' type.
>   QualType getThisType(ASTContext ) const;
> 
>   unsigned getTypeQualifiers() const {
> 
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=311589=311588=311589=diff
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Aug 23 12:39:04 2017
> @@ -1014,11 +1014,11 @@ void CodeGenFunction::StartFunction(Glob
> }
> 
> // Check the 'this' pointer once per function, if it's available.
> -if (CXXThisValue) {
> +if (CXXABIThisValue) {
>   SanitizerSet SkippedChecks;
>   SkippedChecks.set(SanitizerKind::ObjectSize, true);
>   QualType ThisTy = MD->getThisType(getContext());
> -  EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,
> +  EmitTypeCheck(TCK_Load, Loc, CXXABIThisValue, ThisTy,
> 
> getContext().getTypeAlignInChars(ThisTy->getPointeeType()),
> SkippedChecks);
> }
> 
> Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=311589=311588=311589=diff
> ==
> --- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Wed Aug 23 12:39:04 
> 2017
> @@ -449,6 +449,27 @@ void upcast_to_vbase() {
> }
> }
> 
> +struct ThisAlign {
> +  void this_align_lambda();
> +};
> +void ThisAlign::this_align_lambda() {
> +  // CHECK-LABEL: define 
> {{.*}}@"_ZZN9ThisAlign17this_align_lambdaEvENK3$_0clEv"
> +  // CHECK-SAME: (%{{.*}}* %[[this:[^)]*]])
> +  // CHECK: %[[this_addr:.*]] = alloca
> +  // CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],
> +  // CHECK: %[[this_inner:.*]] = load %{{.*}}*, %{{.*}}** %[[this_addr]],
> +  // CHECK: %[[this_outer_addr:.*]] = getelementptr inbounds %{{.*}}, 
> %{{.*}}* %[[this_inner]], i32 0, i32 0
> +  // CHECK: %[[this_outer:.*]] = load %{{.*}}*, %{{.*}}** 
> %[[this_outer_addr]],
> +  //
> +  // CHECK: %[[this_inner_isnonnull:.*]] = icmp ne %{{.*}}* %[[this_inner]], 
> null
> +  // CHECK: %[[this_inner_asint:.*]] = ptrtoint %{{.*}}* %[[this_inner]] to i
> +  // CHECK: %[[this_inner_misalignment:.*]] = and i{{32|64}} 
> %[[this_inner_asint]], {{3|7}},
> +  // CHECK: %[[this_inner_isaligned:.*]] = icmp eq 

[PATCH] D36272: [CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Are we SURE the stack alignment for this type is supposed to be 16 bit as well? 
 I didn't see any discussion about it in the email conversation.

I have very little understanding of this attribute, but I would (perhaps 
naiively) presume that it would be different on 64 bit targets.

Additionally, there is likely value to split the test run-line into 2, one that 
specifies 64 bit Windows and one that is 64 bit Linux.  The value being that 
they validate two different code paths (whereas 32 is the same code path).


https://reviews.llvm.org/D36272



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


[PATCH] D36564: [analyzer] Fix SimpleSValBuilder::simplifySVal

2017-08-24 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

@alexfh, thanks for letting me know, i will take a closer look at 
https://bugs.llvm.org/show_bug.cgi?id=34309 soon.


Repository:
  rL LLVM

https://reviews.llvm.org/D36564



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


[PATCH] D36272: [CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64

2017-08-24 Thread Anatol Pomozov via Phabricator via cfe-commits
anatol.pomozov added a comment.

Erich, done.

I also rerun tests and this time they are green.


https://reviews.llvm.org/D36272



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


[PATCH] D36272: [CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64

2017-08-24 Thread Anatol Pomozov via Phabricator via cfe-commits
anatol.pomozov updated this revision to Diff 112582.

https://reviews.llvm.org/D36272

Files:
  include/clang/Basic/Attr.td
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/function-attributes.c


Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm 
-disable-llvm-passes -Os -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm 
-disable-llvm-passes -Os -std=c99 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm 
-disable-llvm-passes -Os -std=c99 -o - %s | FileCheck %s
 // CHECK: define signext i8 @f0(i32 %x) [[NUW:#[0-9]+]]
 // CHECK: define zeroext i8 @f1(i32 %x) [[NUW]]
 // CHECK: define void @f2(i8 signext %x) [[NUW]]
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -2288,6 +2288,15 @@
 if (!IsForDefinition)
   return;
 if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+  if (FD->hasAttr()) {
+// Get the LLVM function.
+llvm::Function *Fn = cast(GV);
+
+// Now add the 'alignstack' attribute with a value of 16.
+llvm::AttrBuilder B;
+B.addStackAlignmentAttr(16);
+Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  }
   if (FD->hasAttr()) {
 llvm::Function *Fn = cast(GV);
 Fn->setCallingConv(llvm::CallingConv::X86_INTR);
@@ -2416,6 +2425,15 @@
   if (!IsForDefinition)
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if (FD->hasAttr()) {
+  // Get the LLVM function.
+  llvm::Function *Fn = cast(GV);
+
+  // Now add the 'alignstack' attribute with a value of 16.
+  llvm::AttrBuilder B;
+  B.addStackAlignmentAttr(16);
+  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+}
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);
   Fn->setCallingConv(llvm::CallingConv::X86_INTR);
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2042,7 +2042,7 @@
   let Documentation = [AnyX86NoCallerSavedRegistersDocs];
 }
 
-def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr {
+def X86ForceAlignArgPointer : InheritableAttr, 
TargetSpecificAttr {
   let Spellings = [GNU<"force_align_arg_pointer">];
   // Technically, this appertains to a FunctionDecl, but the target-specific
   // code silently allows anything function-like (such as typedefs or function


Index: test/CodeGen/function-attributes.c
===
--- test/CodeGen/function-attributes.c
+++ test/CodeGen/function-attributes.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -disable-llvm-passes -Os -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -disable-llvm-passes -Os -std=c99 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -disable-llvm-passes -Os -std=c99 -o - %s | FileCheck %s
 // CHECK: define signext i8 @f0(i32 %x) [[NUW:#[0-9]+]]
 // CHECK: define zeroext i8 @f1(i32 %x) [[NUW]]
 // CHECK: define void @f2(i8 signext %x) [[NUW]]
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -2288,6 +2288,15 @@
 if (!IsForDefinition)
   return;
 if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+  if (FD->hasAttr()) {
+// Get the LLVM function.
+llvm::Function *Fn = cast(GV);
+
+// Now add the 'alignstack' attribute with a value of 16.
+llvm::AttrBuilder B;
+B.addStackAlignmentAttr(16);
+Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  }
   if (FD->hasAttr()) {
 llvm::Function *Fn = cast(GV);
 Fn->setCallingConv(llvm::CallingConv::X86_INTR);
@@ -2416,6 +2425,15 @@
   if (!IsForDefinition)
 return;
   if (const FunctionDecl *FD = dyn_cast_or_null(D)) {
+if (FD->hasAttr()) {
+  // Get the LLVM function.
+  llvm::Function *Fn = cast(GV);
+
+  // Now add the 'alignstack' attribute with a value of 16.
+  llvm::AttrBuilder B;
+  B.addStackAlignmentAttr(16);
+  Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+}
 if (FD->hasAttr()) {
   llvm::Function *Fn = cast(GV);
   Fn->setCallingConv(llvm::CallingConv::X86_INTR);
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -2042,7 +2042,7 @@
   let Documentation = [AnyX86NoCallerSavedRegistersDocs];
 }
 
-def 

[PATCH] D37079: [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D37079



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


[PATCH] D37079: [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

Decided there were a few additional advantages to just handling \r\n, so Added 
them.


https://reviews.llvm.org/D37079



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


[PATCH] D37079: [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Lex/Lexer.cpp:3076-3077
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,

erichkeane wrote:
> rnk wrote:
> > Should we only do this in the `\r` case? If I understand correctly, we're 
> > basically saying, if this is a CR, and the next byte is an LF, advance one 
> > more and do the pre-processor stuff.
> That is exactly what we're doing.
> 
> I debated that personally, and am a bit on the fence.  It seems a number of 
> places like to treat a '\r\n' and a '\n\r' as the same thing, though it seems 
>  a little foolish to me.  If you fall toward that opinion, I'll definitely 
> change it, just say the word :)
The bug probably doesn't happen in the \n\r case, because don't we count '\n's 
to compute our line numbers?

Anyway, yeah, I think we should make this specific to '\r'. In that case, we 
peek one ahead, and if we see a simple '\n' byte, we advance one more so that 
our line numbers stay correct.


https://reviews.llvm.org/D37079



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


[PATCH] D37079: [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 112581.
erichkeane added a comment.

Switched to simply \r\n instead of both cases.  This fixes the issue, is likely 
faster (important, since this is a performance critical part of code), and a 
smaller-hammer.


https://reviews.llvm.org/D37079

Files:
  lib/Lex/Lexer.cpp
  test/Frontend/.gitattributes
  test/Frontend/system-header-line-directive-ms-lineendings.c


Index: test/Frontend/system-header-line-directive-ms-lineendings.c
===
--- /dev/null
+++ test/Frontend/system-header-line-directive-ms-lineendings.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem 
%S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly 
outputted
+// for the include-file-completed test case.  
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
Index: test/Frontend/.gitattributes
===
--- /dev/null
+++ test/Frontend/.gitattributes
@@ -0,0 +1,2 @@
+# Below test validates crlf line endings, so it should stay crlf.
+system-header-line-directive-ms-lineendings.c text eol=crlf
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -3070,9 +3070,12 @@
 // If Microsoft extensions are disabled, this is just random garbage.
 Kind = tok::unknown;
 break;
-  
-  case '\n':
+
   case '\r':
+if (CurPtr[0] == '\n')
+  Char = getAndAdvanceChar(CurPtr, Result);
+LLVM_FALLTHROUGH;
+  case '\n':
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {


Index: test/Frontend/system-header-line-directive-ms-lineendings.c
===
--- /dev/null
+++ test/Frontend/system-header-line-directive-ms-lineendings.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -E -o - -I %S/Inputs -isystem %S/Inputs/SystemHeaderPrefix | FileCheck %s
+#include 
+#include 
+
+#include "line-directive.h"
+
+// This tests that the line numbers for the current file are correctly outputted
+// for the include-file-completed test case.  
+
+// CHECK: # 1 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}noline.h" 1 3
+// CHECK: foo();
+// CHECK: # 3 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive-in-system.h" 1 3
+//  The "3" below indicates that "foo.h" is considered a system header.
+// CHECK: # 1 "foo.h" 3
+// CHECK: foo();
+// CHECK: # 4 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
+// CHECK: # 1 "{{.*}}line-directive.h" 1
+// CHECK: # 10 "foo.h"{{$}}
+// CHECK: # 6 "{{.*}}system-header-line-directive-ms-lineendings.c" 2
Index: test/Frontend/.gitattributes
===
--- /dev/null
+++ test/Frontend/.gitattributes
@@ -0,0 +1,2 @@
+# Below test validates crlf line endings, so it should stay crlf.
+system-header-line-directive-ms-lineendings.c text eol=crlf
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -3070,9 +3070,12 @@
 // If Microsoft extensions are disabled, this is just random garbage.
 Kind = tok::unknown;
 break;
-  
-  case '\n':
+
   case '\r':
+if (CurPtr[0] == '\n')
+  Char = getAndAdvanceChar(CurPtr, Result);
+LLVM_FALLTHROUGH;
+  case '\n':
 // If we are inside a preprocessor directive and we see the end of line,
 // we know we are done with the directive, so return an EOD token.
 if (ParsingPreprocessorDirective) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36272: [CodeGen][x86_64] Enable 'force_align_arg_pointer' attribute at x86_64

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Mind doing the diff with -U9 so I can see TargetInfo.cpp with the full 
context?


Repository:
  rL LLVM

https://reviews.llvm.org/D36272



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


Re: r311589 - [ubsan] PR34266: When sanitizing the 'this' value for a member function that happens to be a lambda call operator, use the lambda's 'this' pointer, not the captured enclosing 'this' poin

2017-08-24 Thread Matt Morehouse via cfe-commits
Hi Richard,

It looks like this revision is breaking the x86_64-linux-bootstrap bot
.
Most of the UBSan checks are failing with the attached error.
Full log at:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/2104/steps/check-llvm%20ubsan/logs/stdio

I haven't looked in much detail, so I'm not sure if your change uncovered a
bug in LLVM or if the change is faulty.  Could you please take a look?

Thanks,
Matt Morehouse



On Wed, Aug 23, 2017 at 12:39 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Wed Aug 23 12:39:04 2017
> New Revision: 311589
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311589=rev
> Log:
> [ubsan] PR34266: When sanitizing the 'this' value for a member function
> that happens to be a lambda call operator, use the lambda's 'this' pointer,
> not the captured enclosing 'this' pointer (if any).
>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclCXX.h?rev=311589=311588=311589=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Aug 23 12:39:04 2017
> @@ -2027,7 +2027,10 @@ public:
>
>/// \brief Returns the type of the \c this pointer.
>///
> -  /// Should only be called for instance (i.e., non-static) methods.
> +  /// Should only be called for instance (i.e., non-static) methods. Note
> +  /// that for the call operator of a lambda closure type, this returns
> the
> +  /// desugared 'this' type (a pointer to the closure type), not the
> captured
> +  /// 'this' type.
>QualType getThisType(ASTContext ) const;
>
>unsigned getTypeQualifiers() const {
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CodeGenFunction.cpp?rev=311589=311588=311589=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Aug 23 12:39:04 2017
> @@ -1014,11 +1014,11 @@ void CodeGenFunction::StartFunction(Glob
>  }
>
>  // Check the 'this' pointer once per function, if it's available.
> -if (CXXThisValue) {
> +if (CXXABIThisValue) {
>SanitizerSet SkippedChecks;
>SkippedChecks.set(SanitizerKind::ObjectSize, true);
>QualType ThisTy = MD->getThisType(getContext());
> -  EmitTypeCheck(TCK_Load, Loc, CXXThisValue, ThisTy,
> +  EmitTypeCheck(TCK_Load, Loc, CXXABIThisValue, ThisTy,
>  getContext().getTypeAlignInChars(ThisTy->
> getPointeeType()),
>  SkippedChecks);
>  }
>
> Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/catch-undef-behavior.cpp?rev=311589=
> 311588=311589=diff
> 
> ==
> --- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Wed Aug 23
> 12:39:04 2017
> @@ -449,6 +449,27 @@ void upcast_to_vbase() {
>  }
>  }
>
> +struct ThisAlign {
> +  void this_align_lambda();
> +};
> +void ThisAlign::this_align_lambda() {
> +  // CHECK-LABEL: define {{.*}}@"_ZZN9ThisAlign17this_
> align_lambdaEvENK3$_0clEv"
> +  // CHECK-SAME: (%{{.*}}* %[[this:[^)]*]])
> +  // CHECK: %[[this_addr:.*]] = alloca
> +  // CHECK: store %{{.*}}* %[[this]], %{{.*}}** %[[this_addr]],
> +  // CHECK: %[[this_inner:.*]] = load %{{.*}}*, %{{.*}}** %[[this_addr]],
> +  // CHECK: %[[this_outer_addr:.*]] = getelementptr inbounds %{{.*}},
> %{{.*}}* %[[this_inner]], i32 0, i32 0
> +  // CHECK: %[[this_outer:.*]] = load %{{.*}}*, %{{.*}}**
> %[[this_outer_addr]],
> +  //
> +  // CHECK: %[[this_inner_isnonnull:.*]] = icmp ne %{{.*}}*
> %[[this_inner]], null
> +  // CHECK: %[[this_inner_asint:.*]] = ptrtoint %{{.*}}* %[[this_inner]]
> to i
> +  // CHECK: %[[this_inner_misalignment:.*]] = and i{{32|64}}
> %[[this_inner_asint]], {{3|7}},
> +  // CHECK: %[[this_inner_isaligned:.*]] = icmp eq i{{32|64}}
> %[[this_inner_misalignment]], 0
> +  // CHECK: %[[this_inner_valid:.*]] = and i1 %[[this_inner_isnonnull]],
> %[[this_inner_isaligned]],
> +  // CHECK: br i1 %[[this_inner_valid:.*]]
> +  [&] { return this; } ();
> +}
> +
>  namespace CopyValueRepresentation {
>// CHECK-LABEL: define {{.*}} @_ZN23CopyValueRepresentation2S3aSERKS0_
>// CHECK-NOT: call {{.*}} @__ubsan_handle_load_invalid_value
>
>
> ___
> cfe-commits mailing list
> 

[PATCH] D37079: [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Lex/Lexer.cpp:3076-3077
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,

rnk wrote:
> Should we only do this in the `\r` case? If I understand correctly, we're 
> basically saying, if this is a CR, and the next byte is an LF, advance one 
> more and do the pre-processor stuff.
That is exactly what we're doing.

I debated that personally, and am a bit on the fence.  It seems a number of 
places like to treat a '\r\n' and a '\n\r' as the same thing, though it seems  
a little foolish to me.  If you fall toward that opinion, I'll definitely 
change it, just say the word :)


https://reviews.llvm.org/D37079



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


[PATCH] D37079: [Preprocessor] Correct internal token parsing of newline characters in CRLF

2017-08-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Lex/Lexer.cpp:3076-3077
   case '\r':
+if (CurPtr[0] != Char && (CurPtr[0] == '\n' || CurPtr[0] == '\r'))
+  Char = getAndAdvanceChar(CurPtr, Result);
 // If we are inside a preprocessor directive and we see the end of line,

Should we only do this in the `\r` case? If I understand correctly, we're 
basically saying, if this is a CR, and the next byte is an LF, advance one more 
and do the pre-processor stuff.


https://reviews.llvm.org/D37079



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


[PATCH] D37090: Implement CFG construction for __finally.

2017-08-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Re: jumps out of __try, I wonder if you can tie __finally into whatever the CFG 
does for C++ destructors.




Comment at: test/Sema/warn-unreachable-ms.c:49
 __try {
-  f();
+  throw 1;
 } __except (1) {

Nice. Would any noreteurn call work here to eliminate the re-run and ifdef?


https://reviews.llvm.org/D37090



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


[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

Looks fine to me, but please wait for Richard's comment.


https://reviews.llvm.org/D37091



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


[PATCH] D37109: [clang-format] Emit absolute splits before lines for comments, try 2

2017-08-24 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311672: [clang-format] Emit absolute splits before lines for 
comments, try 2 (authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D37109

Files:
  cfe/trunk/lib/Format/BreakableToken.cpp
  cfe/trunk/unittests/Format/FormatTestComments.cpp


Index: cfe/trunk/lib/Format/BreakableToken.cpp
===
--- cfe/trunk/lib/Format/BreakableToken.cpp
+++ cfe/trunk/lib/Format/BreakableToken.cpp
@@ -545,15 +545,18 @@
 }
 
 BreakableToken::Split BreakableBlockComment::getSplitBefore(
-unsigned LineIndex,
-unsigned PreviousEndColumn,
-unsigned ColumnLimit,
+unsigned LineIndex, unsigned PreviousEndColumn, unsigned ColumnLimit,
 llvm::Regex ) const {
   if (!mayReflow(LineIndex, CommentPragmasRegex))
 return Split(StringRef::npos, 0);
   StringRef TrimmedContent = Content[LineIndex].ltrim(Blanks);
-  return getReflowSplit(TrimmedContent, ReflowPrefix, PreviousEndColumn,
-ColumnLimit);
+  Split Result = getReflowSplit(TrimmedContent, ReflowPrefix, 
PreviousEndColumn,
+ColumnLimit);
+  // Result is relative to TrimmedContent. Adapt it relative to
+  // Content[LineIndex].
+  if (Result.first != StringRef::npos)
+Result.first += Content[LineIndex].size() - TrimmedContent.size();
+  return Result;
 }
 
 unsigned BreakableBlockComment::getReflownColumn(
@@ -633,17 +636,12 @@
 /*CurrentPrefix=*/ReflowPrefix, InPPDirective, /*Newlines=*/0,
 /*Spaces=*/0);
 // Check if we need to also insert a break at the whitespace range.
-// For this we first adapt the reflow split relative to the beginning of 
the
-// content.
 // Note that we don't need a penalty for this break, since it doesn't 
change
 // the total number of lines.
-Split BreakSplit = SplitBefore;
-BreakSplit.first += TrimmedContent.data() - Content[LineIndex].data();
 unsigned ReflownColumn =
 getReflownColumn(TrimmedContent, LineIndex, PreviousEndColumn);
-if (ReflownColumn > ColumnLimit) {
-  insertBreak(LineIndex, 0, BreakSplit, Whitespaces);
-}
+if (ReflownColumn > ColumnLimit)
+  insertBreak(LineIndex, 0, SplitBefore, Whitespaces);
 return;
   }
 
Index: cfe/trunk/unittests/Format/FormatTestComments.cpp
===
--- cfe/trunk/unittests/Format/FormatTestComments.cpp
+++ cfe/trunk/unittests/Format/FormatTestComments.cpp
@@ -2787,6 +2787,24 @@
"* long */",
getLLVMStyleWithColumns(20)));
 }
+
+TEST_F(FormatTestComments, NoCrush_Bug34236) {
+  // This is a test case from a crasher reported in:
+  // https://bugs.llvm.org/show_bug.cgi?id=34236
+  // Temporarily disable formatting for readability.
+  // clang-format off
+  EXPECT_EQ(
+"/**/ /*\n"
+"  *   
a\n"
+"  * b c\n"
+"  * d*/",
+  format(
+"/**/ /*\n"
+" *   a b\n"
+" *   c d*/",
+  getLLVMStyleWithColumns(80)));
+  // clang-format on
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang


Index: cfe/trunk/lib/Format/BreakableToken.cpp
===
--- cfe/trunk/lib/Format/BreakableToken.cpp
+++ cfe/trunk/lib/Format/BreakableToken.cpp
@@ -545,15 +545,18 @@
 }
 
 BreakableToken::Split BreakableBlockComment::getSplitBefore(
-unsigned LineIndex,
-unsigned PreviousEndColumn,
-unsigned ColumnLimit,
+unsigned LineIndex, unsigned PreviousEndColumn, unsigned ColumnLimit,
 llvm::Regex ) const {
   if (!mayReflow(LineIndex, CommentPragmasRegex))
 return Split(StringRef::npos, 0);
   StringRef TrimmedContent = Content[LineIndex].ltrim(Blanks);
-  return getReflowSplit(TrimmedContent, ReflowPrefix, PreviousEndColumn,
-ColumnLimit);
+  Split Result = getReflowSplit(TrimmedContent, ReflowPrefix, PreviousEndColumn,
+ColumnLimit);
+  // Result is relative to TrimmedContent. Adapt it relative to
+  // Content[LineIndex].
+  if (Result.first != StringRef::npos)
+Result.first += Content[LineIndex].size() - TrimmedContent.size();
+  return Result;
 }
 
 unsigned BreakableBlockComment::getReflownColumn(
@@ -633,17 +636,12 @@
 /*CurrentPrefix=*/ReflowPrefix, InPPDirective, /*Newlines=*/0,
 /*Spaces=*/0);
 // Check if we need to also insert a break at the whitespace range.
-// For this we first adapt the reflow split relative to the beginning of the
-// content.
 // Note 

r311672 - [clang-format] Emit absolute splits before lines for comments, try 2

2017-08-24 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Aug 24 09:41:10 2017
New Revision: 311672

URL: http://llvm.org/viewvc/llvm-project?rev=311672=rev
Log:
[clang-format] Emit absolute splits before lines for comments, try 2

Summary:
This recommits https://reviews.llvm.org/D36956 with an update to the added test
case to not use raw string literals, since this makes gcc unhappy.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/BreakableToken.cpp
cfe/trunk/unittests/Format/FormatTestComments.cpp

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=311672=311671=311672=diff
==
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Thu Aug 24 09:41:10 2017
@@ -545,15 +545,18 @@ void BreakableBlockComment::insertBreak(
 }
 
 BreakableToken::Split BreakableBlockComment::getSplitBefore(
-unsigned LineIndex,
-unsigned PreviousEndColumn,
-unsigned ColumnLimit,
+unsigned LineIndex, unsigned PreviousEndColumn, unsigned ColumnLimit,
 llvm::Regex ) const {
   if (!mayReflow(LineIndex, CommentPragmasRegex))
 return Split(StringRef::npos, 0);
   StringRef TrimmedContent = Content[LineIndex].ltrim(Blanks);
-  return getReflowSplit(TrimmedContent, ReflowPrefix, PreviousEndColumn,
-ColumnLimit);
+  Split Result = getReflowSplit(TrimmedContent, ReflowPrefix, 
PreviousEndColumn,
+ColumnLimit);
+  // Result is relative to TrimmedContent. Adapt it relative to
+  // Content[LineIndex].
+  if (Result.first != StringRef::npos)
+Result.first += Content[LineIndex].size() - TrimmedContent.size();
+  return Result;
 }
 
 unsigned BreakableBlockComment::getReflownColumn(
@@ -633,17 +636,12 @@ void BreakableBlockComment::replaceWhite
 /*CurrentPrefix=*/ReflowPrefix, InPPDirective, /*Newlines=*/0,
 /*Spaces=*/0);
 // Check if we need to also insert a break at the whitespace range.
-// For this we first adapt the reflow split relative to the beginning of 
the
-// content.
 // Note that we don't need a penalty for this break, since it doesn't 
change
 // the total number of lines.
-Split BreakSplit = SplitBefore;
-BreakSplit.first += TrimmedContent.data() - Content[LineIndex].data();
 unsigned ReflownColumn =
 getReflownColumn(TrimmedContent, LineIndex, PreviousEndColumn);
-if (ReflownColumn > ColumnLimit) {
-  insertBreak(LineIndex, 0, BreakSplit, Whitespaces);
-}
+if (ReflownColumn > ColumnLimit)
+  insertBreak(LineIndex, 0, SplitBefore, Whitespaces);
 return;
   }
 

Modified: cfe/trunk/unittests/Format/FormatTestComments.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestComments.cpp?rev=311672=311671=311672=diff
==
--- cfe/trunk/unittests/Format/FormatTestComments.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestComments.cpp Thu Aug 24 09:41:10 2017
@@ -2787,6 +2787,24 @@ TEST_F(FormatTestComments, AlignsBlockCo
"* long */",
getLLVMStyleWithColumns(20)));
 }
+
+TEST_F(FormatTestComments, NoCrush_Bug34236) {
+  // This is a test case from a crasher reported in:
+  // https://bugs.llvm.org/show_bug.cgi?id=34236
+  // Temporarily disable formatting for readability.
+  // clang-format off
+  EXPECT_EQ(
+"/**/ /*\n"
+"  *   
a\n"
+"  * b c\n"
+"  * d*/",
+  format(
+"/**/ /*\n"
+" *   a b\n"
+" *   c d*/",
+  getLLVMStyleWithColumns(80)));
+  // clang-format on
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang


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


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Tooling/Refactoring/SourceSelectionConstraints.cpp:13
+
+using namespace clang;
+using namespace tooling;

ioeric wrote:
> We are tempted to avoid `using namespace` if possible. 
Why? It's not in a header. `using namespace clang` is the common practice 
across all of Clang's sources.


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-24 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Tooling/Refactoring/RefactoringResult.h:21
+struct RefactoringResult {
+  enum ResultKind {
+/// A set of source replacements represented using a vector of

ioeric wrote:
> arphaman wrote:
> > ioeric wrote:
> > > I'm a bit unsure about the abstraction of the refactoring result. I would 
> > > expected refactoring results to be source changes always. Do you have any 
> > > refactoring tool that outputs occurrences in mind?
> > In Xcode we require rename to return symbol occurrences because the IDE is 
> > responsible for figuring out: 
> > 1) The new name. Thus we can't produce replacements when renaming because 
> > we don't know what the new name is when gathering the occurrences.
> > 2) Whether these occurrences should be actually applied. Thus we can't 
> > produce replacements because it's up to the user to decide if they want to 
> > rename some occurrence in a comment for example.
> > 
> > In general 2) can be applied to tools like clang-refactor that could allow 
> > users to select occurrences that don't guarantee a direct semantic match 
> > (comments, etc.) in an interactive manner.
> > 
> > I think clangd has a rather naive rename support, so these points may not 
> > apply, but we may want to extend clangd's support for rename in the future 
> > as well.
> I feel occurrences are more of an intermediate state of a refactoring action 
> than a result. I'm wondering if it makes sense to introduce a separate class 
> to represent such intermediate states? I am a bit nervous to fuse multiple 
> classes into one; the interfaces can get pretty ugly when more result kinds 
> are added. 
Good point. I agree.

I think it would be better to differentiate between `RefactoringActionRules` 
then. Ordinary rules return a set of AtomicChanges instead of 
RefactoringResult. But then we could also have "interactive" rules that return 
"partial" results like symbol occurrences.

I think I'll try the following approach:

```
class RefactoringActionRule {
  virtual ~RefactoringActionRule() {}
};

class RefactoringActionSourceChangeRule: public RefactoringActionRule {
public:
  virtual Expected
  createSourceReplacements(RefactoringOperation ) = 0;
};

class RefactoringActionSymbolOccurrencesRule: public RefactoringActionRule {
public:
  virtual Expected
  findSymbolOccurrences(RefactoringOperation ) = 0;
};
```


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D37091: Expose -mllvm -accurate-sample-profile to clang.

2017-08-24 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 112574.
danielcdh marked 2 inline comments as done.
danielcdh added a comment.

updated the patch to put it into function attribute so that it works with 
ThinLTO


https://reviews.llvm.org/D37091

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/clang_f_opts.c

Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -53,6 +53,9 @@
 // CHECK-REROLL-LOOPS: "-freroll-loops"
 // CHECK-NO-REROLL-LOOPS-NOT: "-freroll-loops"
 
+// RUN: %clang -### -S -faccurate-sample-profile %s 2>&1 | FileCheck -check-prefix=CHECK-ACCURATE-SAMPLE-PROFILE %s
+// CHECK-ACCURATE-SAMPLE-PROFILE: "-faccurate-sample-profile"
+
 // RUN: %clang -### -S -fprofile-sample-use=%S/Inputs/file.prof %s 2>&1 | FileCheck -check-prefix=CHECK-SAMPLE-PROFILE %s
 // CHECK-SAMPLE-PROFILE: "-fprofile-sample-use={{.*}}/file.prof"
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -652,6 +652,8 @@
 
   Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables);
 
+  Opts.AccurateSampleProfile = Args.hasArg(OPT_faccurate_sample_profile);
+
   Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
   Opts.EmitSummaryIndex = false;
   if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -2340,6 +2340,10 @@
 true))
 CmdArgs.push_back("-fno-jump-tables");
 
+  if (Args.hasFlag(options::OPT_faccurate_sample_profile,
+   options::OPT_fno_accurate_sample_profile, false))
+CmdArgs.push_back("-faccurate-sample-profile");
+
   if (!Args.hasFlag(options::OPT_fpreserve_as_comments,
 options::OPT_fno_preserve_as_comments, true))
 CmdArgs.push_back("-fno-preserve-as-comments");
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -837,6 +837,10 @@
   Fn->addFnAttr("no-jump-tables",
 llvm::toStringRef(CGM.getCodeGenOpts().NoUseJumpTables));
 
+  // Add accurate-sample-profile value.
+  if (CGM.getCodeGenOpts().AccurateSampleProfile)
+Fn->addFnAttr("accurate-sample-profile");
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -183,6 +183,7 @@
 CODEGENOPT(UnwindTables  , 1, 0) ///< Emit unwind tables.
 CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
 CODEGENOPT(VectorizeSLP  , 1, 0) ///< Run SLP vectorizer.
+CODEGENOPT(AccurateSampleProfile, 1, 0) ///< Sample profile is accurate.
 
   /// Attempt to use register sized accesses to bit-fields in structures, when
   /// possible.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -587,6 +587,14 @@
 def fPIE : Flag<["-"], "fPIE">, Group;
 def fno_PIE : Flag<["-"], "fno-PIE">, Group;
 def faccess_control : Flag<["-"], "faccess-control">, Group;
+def faccurate_sample_profile : Flag<["-"], "faccurate-sample-profile">,
+  Group, Flags<[DriverOption, CC1Option]>,
+  HelpText<"If sample profile is accurate, we will mark all un-sampled "
+   "callsite as cold. Otherwise, treat callsites without profile "
+   "samples as if we have no profile">;
+def fno_accurate_sample_profile : Flag<["-"], "fno-accurate-sample-profile">,
+  Group, Flags<[DriverOption]>;
+
 def fallow_unsupported : Flag<["-"], "fallow-unsupported">, Group;
 def fapple_kext : Flag<["-"], "fapple-kext">, Group, Flags<[CC1Option]>,
   HelpText<"Use Apple's kernel extensions ABI">;
@@ -643,6 +651,10 @@
 Alias;
 def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
 Alias;
+def fauto_profile_accurate : Flag<["-"], "fauto-profile-accurate">,
+Group, Alias;
+def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">,
+Group, Alias;
 def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">, Group,
 Flags<[CC1Option]>,
 HelpText<"Emit extra debug info to make sample profile more accurate.">;
Index: docs/ClangCommandLineReference.rst
===

Re: r311601 - Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be

2017-08-24 Thread Hans Wennborg via cfe-commits
Merged to 5.0 in r311671.

On Wed, Aug 23, 2017 at 2:24 PM, Adrian Prantl via cfe-commits
 wrote:
> Author: adrian
> Date: Wed Aug 23 14:24:12 2017
> New Revision: 311601
>
> URL: http://llvm.org/viewvc/llvm-project?rev=311601=rev
> Log:
> Fix a bug in CGDebugInfo::EmitInlineFunctionStart causing DILocations to be
> parented in function declarations.
>
> Fixes PR33997.
> https://bugs.llvm.org/show_bug.cgi?id=33997
>
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=311601=311600=311601=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Wed Aug 23 14:24:12 2017
> @@ -3287,7 +3287,7 @@ void CGDebugInfo::EmitInlineFunctionStar
>llvm::DISubprogram *SP = nullptr;
>if (FI != SPCache.end())
>  SP = dyn_cast_or_null(FI->second);
> -  if (!SP)
> +  if (!SP || !SP->isDefinition())
>  SP = getFunctionStub(GD);
>FnBeginRegionCount.push_back(LexicalBlockStack.size());
>LexicalBlockStack.emplace_back(SP);
>
> Added: cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp?rev=311601=auto
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-inlined.cpp Wed Aug 23 14:24:12 2017
> @@ -0,0 +1,45 @@
> +// RUN: %clang_cc1 -emit-llvm -triple i686-pc-windows-msvc19.0.24213 
> -gcodeview -debug-info-kind=limited -std=c++14 %s -o - | FileCheck %s
> +// PR33997.
> +struct already_AddRefed {
> +  ~already_AddRefed();
> +};
> +struct RefPtr {
> +  operator int *();
> +};
> +struct ServoCssRulesStrong {
> +  already_AddRefed Consume();
> +};
> +struct GroupRule {
> +  GroupRule(already_AddRefed);
> +};
> +class ConditionRule : GroupRule {
> +  using GroupRule::GroupRule;
> +};
> +class CSSMediaRule : ConditionRule {
> +  using ConditionRule::ConditionRule;
> +};
> +class CSSMozDocumentRule : ConditionRule {
> +  using ConditionRule::ConditionRule;
> +};
> +class ServoDocumentRule : CSSMozDocumentRule {
> +  ServoDocumentRule(RefPtr);
> +};
> +class ServoMediaRule : CSSMediaRule {
> +  ServoMediaRule(RefPtr);
> +};
> +ServoCssRulesStrong Servo_MediaRule_GetRules(int *);
> +ServoCssRulesStrong Servo_DocumentRule_GetRules(int *);
> +ServoDocumentRule::ServoDocumentRule(RefPtr aRawRule)
> +: CSSMozDocumentRule(Servo_DocumentRule_GetRules(aRawRule).Consume()) {}
> +
> +ServoMediaRule::ServoMediaRule(RefPtr aRawRule)
> +: CSSMediaRule(Servo_MediaRule_GetRules(aRawRule).Consume()) {}
> +
> +// CHECK: define{{.*}}ServoMediaRule
> +// CHECK-NOT: {{ ret }}
> +// CHECK: store %class.ConditionRule* %
> +// CHECK-SAME: %class.ConditionRule** %
> +// CHECK-SAME: !dbg ![[INL:[0-9]+]]
> +
> +// CHECK: ![[INL]] = !DILocation(line: 16, scope: ![[SP:[0-9]+]], inlinedAt:
> +// CHECK: ![[SP]] = distinct !DISubprogram(name: "GroupRule", 
> {{.*}}isDefinition: true
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36075: [refactor] Initial support for refactoring action rules

2017-08-24 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h:26
+template 
+detail::SourceSelectionRequirement<
+typename selection::detail::EvaluateSelectionChecker<

arphaman wrote:
> ioeric wrote:
> > Could you help me understand this class? 
> > 
> > This seems to be a selection-specific requirement and should live in 
> > `selection`. It is also used in `BaseSpecializedRule` which seems to be a 
> > higher level of abstraction. 
> It's just a container class that stores all information about the 
> `requiredSelection` requirement. I agree about `BaseSpecializedRule`, that 
> connection should be chopped. I will move the evaluation code into the 
> requirement itself when I update the patch.
> 
> I would tend to disagree about moving it though, as 
> `SourceSelectionRequirement` is a requirement first and I think that's why it 
> should live with other requirements. Yes, it's related to selections, but it 
> uses them to implement the requirement. I think it's better to keep 
> requirements together, as opposed to having `option` requirements close to 
> options, selection requirements close to selection, and so on. WDYT?
Thanks! 

Makes sense. We might want to put individual requirements into their own 
headers so that this doesn't grow into a huge file when more requirements are 
supported.



Comment at: 
include/clang/Tooling/Refactoring/RefactoringActionRuleRequirementsInternal.h:42
+ RequirementBase>::type {
+  using OutputType = typename DropExpectedOptional::Type;
+

It might worth having a comment explaining why and how `Expected` is 
wrapped and unwrapped during the evaluation.



Comment at: include/clang/Tooling/Refactoring/RefactoringActionRules.h:33
+///
+///  - requiredSelection: The refactoring function won't be invoked unless the
+///   given selection requirement is satisfied.

We might want to document supported requirements somewhere else so that we 
don't need to update this file every time a new requirement is added.



Comment at: include/clang/Tooling/Refactoring/RefactoringOperation.h:1
+//===--- RefactoringOperationController.h - Clang refactoring library 
-===//
+//

s/RefactoringOperationController.h/RefactoringOperation.h/ :)



Comment at: include/clang/Tooling/Refactoring/RefactoringOperation.h:29
+/// to represent a selection in an editor.
+class RefactoringOperation {
+public:

I found the name a bit confusing - `RefactoringOperation` sounds a bit like 
`RefactoringAction`.

Would it make sense to call this `RefactoringContext` or 
`RefactoringRuleContext`, if this stores states of a refactoring rule?



Comment at: include/clang/Tooling/Refactoring/RefactoringResult.h:21
+struct RefactoringResult {
+  enum ResultKind {
+/// A set of source replacements represented using a vector of

arphaman wrote:
> ioeric wrote:
> > I'm a bit unsure about the abstraction of the refactoring result. I would 
> > expected refactoring results to be source changes always. Do you have any 
> > refactoring tool that outputs occurrences in mind?
> In Xcode we require rename to return symbol occurrences because the IDE is 
> responsible for figuring out: 
> 1) The new name. Thus we can't produce replacements when renaming because we 
> don't know what the new name is when gathering the occurrences.
> 2) Whether these occurrences should be actually applied. Thus we can't 
> produce replacements because it's up to the user to decide if they want to 
> rename some occurrence in a comment for example.
> 
> In general 2) can be applied to tools like clang-refactor that could allow 
> users to select occurrences that don't guarantee a direct semantic match 
> (comments, etc.) in an interactive manner.
> 
> I think clangd has a rather naive rename support, so these points may not 
> apply, but we may want to extend clangd's support for rename in the future as 
> well.
I feel occurrences are more of an intermediate state of a refactoring action 
than a result. I'm wondering if it makes sense to introduce a separate class to 
represent such intermediate states? I am a bit nervous to fuse multiple classes 
into one; the interfaces can get pretty ugly when more result kinds are added. 



Comment at: lib/Tooling/Refactoring/SourceSelectionConstraints.cpp:13
+
+using namespace clang;
+using namespace tooling;

We are tempted to avoid `using namespace` if possible. 


Repository:
  rL LLVM

https://reviews.llvm.org/D36075



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


[PATCH] D31370: [clang-tidy] Prototype to check for exception specification

2017-08-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth abandoned this revision.
JonasToth added a comment.

exception checking seems to end in the front end for such cases, so nothing to 
do here anymore. reimplement if there is need later.


Repository:
  rL LLVM

https://reviews.llvm.org/D31370



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


[PATCH] D36586: [clang-tidy] hicpp bitwise operations on signed integers

2017-08-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 112573.
JonasToth added a comment.

- fix indendation in testcase


https://reviews.llvm.org/D36586

Files:
  clang-tidy/hicpp/CMakeLists.txt
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/hicpp/SignedBitwiseCheck.cpp
  clang-tidy/hicpp/SignedBitwiseCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/hicpp-signed-bitwise.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/hicpp-signed-bitwise.cpp

Index: test/clang-tidy/hicpp-signed-bitwise.cpp
===
--- /dev/null
+++ test/clang-tidy/hicpp-signed-bitwise.cpp
@@ -0,0 +1,240 @@
+// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t
+
+// These could cause false positives and should not be considered.
+struct StreamClass {
+};
+StreamClass <<(StreamClass , unsigned int i) {
+  return os;
+}
+StreamClass <<(StreamClass , int i) {
+  return os;
+}
+StreamClass >>(StreamClass , unsigned int i) {
+  return os;
+}
+StreamClass >>(StreamClass , int i) {
+  return os;
+}
+struct AnotherStream {
+  AnotherStream <<(unsigned char c) { return *this; }
+  AnotherStream <<(char c) { return *this; }
+
+  AnotherStream >>(unsigned char c) { return *this; }
+  AnotherStream >>(char c) { return *this; }
+};
+
+void binary_bitwise() {
+  int SValue = 42;
+  int SResult;
+
+  unsigned int UValue = 42;
+  unsigned int UResult;
+
+  SResult = SValue & 1; // Bad, one operand signed and result is signed, maybe fix with suffix
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  SResult = SValue & -1; // Bad, both are signed and result is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  SResult = SValue & SValue; // Bad, both are sigend and result is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+
+  UResult = SValue & 1; // Bad, operation on signed, maybe fix with suffix
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  UResult = SValue & -1; // Bad, operations are signed, and even negative
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+
+  UResult = UValue & 1u; // Ok
+  UResult = UValue & UValue; // Ok
+
+  unsigned char UByte1 = 0u;
+  unsigned char UByte2 = 16u;
+  char SByte1 = 0;
+  char SByte2 = 16;
+
+  UByte1 = UByte1 & UByte2; // Ok
+  UByte1 = SByte1 & UByte2; // Bad, one is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1 = SByte1 & SByte2; // Bad, both are signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  SByte1 = SByte1 & SByte2; // Bad, both are signed and result is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+
+  // More complex expressions.
+  UResult = UValue & (SByte1 + (SByte1 | SByte2)); // Bad, RHS is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  // CHECK-MESSAGES: :[[@LINE-2]]:33: warning: use of a signed integer operand with a binary bitwise operator
+
+  // The rest is to demonstrate functionality but all operators are matched equally.
+  // Therefore functionality is the same for all binary operations.
+  UByte1 = UByte1 | UByte2; // Ok
+  UByte1 = UByte1 | SByte2; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+
+  UByte1 = UByte1 ^ UByte2; // Ok
+  UByte1 = UByte1 ^ SByte2; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+
+  UByte1 = UByte1 >> UByte2; // Ok
+  UByte1 = UByte1 >> SByte2; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+
+  UByte1 = UByte1 << UByte2; // Ok
+  UByte1 = UByte1 << SByte2; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+}
+
+void f1(unsigned char c) {}
+void f2(char c) {}
+void f3(int c) {}
+
+void unary_bitwise() {
+  unsigned char UByte1 = 0u;
+  char SByte1 = 0;
+
+  UByte1 = ~UByte1; // Ok
+  SByte1 = ~UByte1; // Bad?
+  SByte1 = ~SByte1; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a unary bitwise operator
+  UByte1 = ~SByte1; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a unary bitwise operator
+
+  unsigned int UInt = 0u;
+  int SInt = 0;
+
+  f1(~UByte1); // Ok
+  f1(~SByte1); // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use of a signed integer operand with a unary bitwise operator
+  f1(~UInt); // 

[PATCH] D36586: [clang-tidy] hicpp bitwise operations on signed integers

2017-08-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 112572.
JonasToth added a comment.

- get up to date with master
- added testcase for enums


https://reviews.llvm.org/D36586

Files:
  clang-tidy/hicpp/CMakeLists.txt
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/hicpp/SignedBitwiseCheck.cpp
  clang-tidy/hicpp/SignedBitwiseCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/hicpp-signed-bitwise.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/hicpp-signed-bitwise.cpp

Index: test/clang-tidy/hicpp-signed-bitwise.cpp
===
--- /dev/null
+++ test/clang-tidy/hicpp-signed-bitwise.cpp
@@ -0,0 +1,239 @@
+// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t
+
+// These could cause false positives and should not be considered.
+struct StreamClass {
+};
+StreamClass <<(StreamClass , unsigned int i) {
+  return os;
+}
+StreamClass <<(StreamClass , int i) {
+  return os;
+}
+StreamClass >>(StreamClass , unsigned int i) {
+  return os;
+}
+StreamClass >>(StreamClass , int i) {
+  return os;
+}
+struct AnotherStream {
+  AnotherStream <<(unsigned char c) { return *this; }
+  AnotherStream <<(char c) { return *this; }
+
+  AnotherStream >>(unsigned char c) { return *this; }
+  AnotherStream >>(char c) { return *this; }
+};
+
+void binary_bitwise() {
+  int SValue = 42;
+  int SResult;
+
+  unsigned int UValue = 42;
+  unsigned int UResult;
+
+  SResult = SValue & 1; // Bad, one operand signed and result is signed, maybe fix with suffix
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  SResult = SValue & -1; // Bad, both are signed and result is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  SResult = SValue & SValue; // Bad, both are sigend and result is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+
+  UResult = SValue & 1; // Bad, operation on signed, maybe fix with suffix
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  UResult = SValue & -1; // Bad, operations are signed, and even negative
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+
+  UResult = UValue & 1u; // Ok
+  UResult = UValue & UValue; // Ok
+
+  unsigned char UByte1 = 0u;
+  unsigned char UByte2 = 16u;
+  char SByte1 = 0;
+  char SByte2 = 16;
+
+  UByte1 = UByte1 & UByte2; // Ok
+  UByte1 = SByte1 & UByte2; // Bad, one is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1 = SByte1 & SByte2; // Bad, both are signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  SByte1 = SByte1 & SByte2; // Bad, both are signed and result is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+
+  // More complex expressions.
+  UResult = UValue & (SByte1 + (SByte1 | SByte2)); // Bad, RHS is signed
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  // CHECK-MESSAGES: :[[@LINE-2]]:33: warning: use of a signed integer operand with a binary bitwise operator
+
+  // The rest is to demonstrate functionality but all operators are matched equally.
+  // Therefore functionality is the same for all binary operations.
+  UByte1 = UByte1 | UByte2; // Ok
+  UByte1 = UByte1 | SByte2; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+
+  UByte1 = UByte1 ^ UByte2; // Ok
+  UByte1 = UByte1 ^ SByte2; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+
+  UByte1 = UByte1 >> UByte2; // Ok
+  UByte1 = UByte1 >> SByte2; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+
+  UByte1 = UByte1 << UByte2; // Ok
+  UByte1 = UByte1 << SByte2; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+}
+
+void f1(unsigned char c) {}
+void f2(char c) {}
+void f3(int c) {}
+
+void unary_bitwise() {
+  unsigned char UByte1 = 0u;
+  char SByte1 = 0;
+
+  UByte1 = ~UByte1; // Ok
+  SByte1 = ~UByte1; // Bad?
+  SByte1 = ~SByte1; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a unary bitwise operator
+  UByte1 = ~SByte1; // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a unary bitwise operator
+
+  unsigned int UInt = 0u;
+  int SInt = 0;
+
+  f1(~UByte1); // Ok
+  f1(~SByte1); // Bad
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use of a signed integer operand with a unary bitwise 

[PATCH] D35982: [mips] Introducing option -mabs=[legacy/2008]

2017-08-24 Thread Petar Jovanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311669: [mips] Introducing option -mabs=[legacy/2008] 
(authored by petarj).

Changed prior to commit:
  https://reviews.llvm.org/D35982?vs=112534=112571#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35982

Files:
  cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets/Mips.cpp
  cfe/trunk/lib/Basic/Targets/Mips.h
  cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
  cfe/trunk/test/Driver/mips-features.c
  cfe/trunk/test/Driver/mips-mabs-warning.c
  cfe/trunk/test/Preprocessor/init.c

Index: cfe/trunk/lib/Basic/Targets/Mips.cpp
===
--- cfe/trunk/lib/Basic/Targets/Mips.cpp
+++ cfe/trunk/lib/Basic/Targets/Mips.cpp
@@ -149,6 +149,9 @@
   if (IsNan2008)
 Builder.defineMacro("__mips_nan2008", Twine(1));
 
+  if (IsAbs2008)
+Builder.defineMacro("__mips_abs2008", Twine(1));
+
   switch (DspRev) {
   default:
 break;
Index: cfe/trunk/lib/Basic/Targets/Mips.h
===
--- cfe/trunk/lib/Basic/Targets/Mips.h
+++ cfe/trunk/lib/Basic/Targets/Mips.h
@@ -46,6 +46,7 @@
   bool IsMips16;
   bool IsMicromips;
   bool IsNan2008;
+  bool IsAbs2008;
   bool IsSingleFloat;
   bool IsNoABICalls;
   bool CanUseBSDABICalls;
@@ -61,9 +62,9 @@
 public:
   MipsTargetInfo(const llvm::Triple , const TargetOptions &)
   : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
-IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
-CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
-HasMSA(false), DisableMadd4(false), HasFP64(false) {
+IsNan2008(false), IsAbs2008(false), IsSingleFloat(false),
+IsNoABICalls(false), CanUseBSDABICalls(false), FloatABI(HardFloat),
+DspRev(NoDSP), HasMSA(false), DisableMadd4(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
 setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -300,6 +301,7 @@
 IsMips16 = false;
 IsMicromips = false;
 IsNan2008 = isIEEE754_2008Default();
+IsAbs2008 = isIEEE754_2008Default();
 IsSingleFloat = false;
 FloatABI = HardFloat;
 DspRev = NoDSP;
@@ -330,6 +332,10 @@
 IsNan2008 = true;
   else if (Feature == "-nan2008")
 IsNan2008 = false;
+  else if (Feature == "+abs2008")
+IsAbs2008 = true;
+  else if (Feature == "-abs2008")
+IsAbs2008 = false;
   else if (Feature == "+noabicalls")
 IsNoABICalls = true;
 }
Index: cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -283,6 +283,28 @@
   << A->getOption().getName() << Val;
   }
 
+  if (Arg *A = Args.getLastArg(options::OPT_mabs_EQ)) {
+StringRef Val = StringRef(A->getValue());
+if (Val == "2008") {
+  if (mips::getIEEE754Standard(CPUName) & mips::Std2008) {
+Features.push_back("+abs2008");
+  } else {
+Features.push_back("-abs2008");
+D.Diag(diag::warn_target_unsupported_abs2008) << CPUName;
+  }
+} else if (Val == "legacy") {
+  if (mips::getIEEE754Standard(CPUName) & mips::Legacy) {
+Features.push_back("-abs2008");
+  } else {
+Features.push_back("+abs2008");
+D.Diag(diag::warn_target_unsupported_abslegacy) << CPUName;
+  }
+} else {
+  D.Diag(diag::err_drv_unsupported_option_argument)
+  << A->getOption().getName() << Val;
+}
+  }
+
   AddTargetFeature(Args, Features, options::OPT_msingle_float,
options::OPT_mdouble_float, "single-float");
   AddTargetFeature(Args, Features, options::OPT_mips16, options::OPT_mno_mips16,
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2066,6 +2066,7 @@
   HelpText<"Do not place constants in the .rodata section instead of the "
".sdata if they meet the -G  threshold (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
+def mabs_EQ : Joined<["-"], "mabs=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;
 def mno_abicalls : Flag<["-"], "mno-abicalls">, Group,
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -61,6 +61,7 @@
 def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def 

r311669 - [mips] Introducing option -mabs=[legacy/2008]

2017-08-24 Thread Petar Jovanovic via cfe-commits
Author: petarj
Date: Thu Aug 24 09:06:30 2017
New Revision: 311669

URL: http://llvm.org/viewvc/llvm-project?rev=311669=rev
Log:
[mips] Introducing option -mabs=[legacy/2008]

In patch r205628 using abs.[ds] instruction is forced, as they should behave
in accordance with flags Has2008 and ABS2008. Unfortunately for revisions
prior mips32r6 and mips64r6, abs.[ds] is not generating correct result when
working with NaNs. To generate a sequence which always produce a correct
result but also to allow user more control on how his code is compiled,
option -mabs is added where user can choose legacy or 2008.
By default legacy mode is used on revisions prior R6. Mips32r6 and mips64r6
use abs2008 mode by default.

Patch by Aleksandar Beserminji

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

Added:
cfe/trunk/test/Driver/mips-mabs-warning.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/Mips.cpp
cfe/trunk/lib/Basic/Targets/Mips.h
cfe/trunk/lib/Driver/ToolChains/Arch/Mips.cpp
cfe/trunk/test/Driver/mips-features.c
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=311669=311668=311669=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Thu Aug 24 09:06:30 
2017
@@ -285,6 +285,12 @@ def warn_target_unsupported_nan2008 : Wa
 def warn_target_unsupported_nanlegacy : Warning<
   "ignoring '-mnan=legacy' option because the '%0' architecture does not 
support it">,
   InGroup;
+def warn_target_unsupported_abslegacy : Warning<
+  "ignoring '-mabs=legacy' option because the '%0' architecture does not 
support it">,
+  InGroup;
+def warn_target_unsupported_abs2008 : Warning<
+  "ignoring '-mabs=2008' option because the '%0' architecture does not support 
it">,
+  InGroup;
 def warn_target_unsupported_compact_branches : Warning<
   "ignoring '-mcompact-branches=' option because the '%0' architecture does 
not"
   " support it">, InGroup;

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=311669=311668=311669=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu Aug 24 09:06:30 2017
@@ -61,6 +61,7 @@ def FloatConversion :
 def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
+def UnsupportedAbs : DiagGroup<"unsupported-abs">;
 def UnsupportedCB : DiagGroup<"unsupported-cb">;
 def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
 def NonLiteralNullConversion : DiagGroup<"non-literal-null-conversion">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=311669=311668=311669=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Aug 24 09:06:30 2017
@@ -2066,6 +2066,7 @@ def mno_embedded_data : Flag<["-"], "mno
   HelpText<"Do not place constants in the .rodata section instead of the "
".sdata if they meet the -G  threshold (MIPS)">;
 def mnan_EQ : Joined<["-"], "mnan=">, Group;
+def mabs_EQ : Joined<["-"], "mabs=">, Group;
 def mabicalls : Flag<["-"], "mabicalls">, Group,
   HelpText<"Enable SVR4-style position-independent code (Mips only)">;
 def mno_abicalls : Flag<["-"], "mno-abicalls">, Group,

Modified: cfe/trunk/lib/Basic/Targets/Mips.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Mips.cpp?rev=311669=311668=311669=diff
==
--- cfe/trunk/lib/Basic/Targets/Mips.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/Mips.cpp Thu Aug 24 09:06:30 2017
@@ -149,6 +149,9 @@ void MipsTargetInfo::getTargetDefines(co
   if (IsNan2008)
 Builder.defineMacro("__mips_nan2008", Twine(1));
 
+  if (IsAbs2008)
+Builder.defineMacro("__mips_abs2008", Twine(1));
+
   switch (DspRev) {
   default:
 break;

Modified: cfe/trunk/lib/Basic/Targets/Mips.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/Mips.h?rev=311669=311668=311669=diff
==
--- cfe/trunk/lib/Basic/Targets/Mips.h (original)
+++ cfe/trunk/lib/Basic/Targets/Mips.h Thu Aug 24 09:06:30 2017
@@ -46,6 +46,7 @@ class 

[PATCH] D36915: [Sema] Diagnose local variables and parameters captured by lambda and block expressions in a default argument

2017-08-24 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D36915#849622, @faisalv wrote:

> I don't think this approach is entirely correct for at least the following 
> reasons:
>
> 1. in the lambda case the machinery that diagnoses capture failures should be 
> the machinery erroring on the lambda (when the parameter is odr-used)
> 2. in the unevaluated case, once you disable the error, the instantiation 
> machinery will fail to find the corresponding instantiated parmvardecl.


Oh right, it stills assert in the unevaluated case. I should have a test case 
for that too.

I also found that the following code, which has a lambda that doesn't capture 
anything, asserts (in IRGen):

  struct S {
template
S(T&&) {}
  };
  
  template
  void foo1() {
struct S2 {
  void foo2(S s = [](){}) {
  }
};
  
S2 s2;
s2.foo2();
  }
  
  void foo3() {
foo1();
  }


https://reviews.llvm.org/D36915



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


[PATCH] D36586: [clang-tidy] hicpp bitwise operations on signed integers

2017-08-24 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/hicpp/SignedBitwiseCheck.cpp:23
+  const auto SignedIntegerOperand =
+  
expr(ignoringImpCasts(hasType(isSignedInteger(.bind("signed_operand");
+

aaron.ballman wrote:
> JonasToth wrote:
> > aaron.ballman wrote:
> > > JonasToth wrote:
> > > > aaron.ballman wrote:
> > > > > Is ignoring implicit casts the correct behavior here as far as the 
> > > > > coding standard is concerned? Consider:
> > > > > ```
> > > > > unsigned char c = 128;
> > > > > f(~c); // c promotes to int before ~ is applied
> > > > > ```
> > > > > Looking at the coding standard, I get the impression this is not 
> > > > > allowed, but I'm not *super* familiar with HIC++.
> > > > I first implemented it without ignoring the implicit integer casts, the 
> > > > result was, that most cases (in test cases) where not found. therefore 
> > > > i implemented it that way. I add an testcase for this and see how i 
> > > > need to adjust the matcher.
> > > > 
> > > > Could you help me there with the semantic, since i am not so fluent in 
> > > > C/C++ standardese, but i think the findings are reasonable.
> > > It kind of boils down to the intention from the HIC++. Consider a test 
> > > case like:
> > > ```
> > > void f(int i);
> > > 
> > > void g() {
> > >   unsigned char c = 127;
> > >   f(~c);
> > > }
> > > 
> > > ```
> > > Does `f()` expect to receive `-128` or `128`? I think this code will pass 
> > > your check (ignoring the promotion means the type is `unsigned char`), 
> > > but the actual bitwise operation is on a signed integer value because 
> > > there is an integer promotion. So 127 is promoted to int, then ~ is 
> > > applied, resulting in the value `-128` being passed to the function.
> > Yeah i see, i have such cases added in the tests.
> > TBH. i don't know if the standard wants this covered, but the demonstrated 
> > case is definitly bad.
> > 
> > Would it be a good idea, to warn on assigning/initializing `signed` 
> > integers with `unsigned` integers?
> > 
> > The CppCoreGuidelines have some sections on that as well: [[ 
> > https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#arithmetic
> >  | Section ES.100-103 ]]
> > 
> > Not sure if this check should care. On the other hand, would it  be nice to 
> > have a check that covers all "integer problems".
> > Yeah i see, i have such cases added in the tests.
> > TBH. i don't know if the standard wants this covered, but the demonstrated 
> > case is definitly bad.
> 
> I think you should ask the HIC++ people what they think; the rule text does 
> not make it clear what the behavior should be here.
> 
> > Would it be a good idea, to warn on assigning/initializing signed integers 
> > with unsigned integers?
> 
> We already have such a warning in clang (-Wsign-conversion).
> 
> >The CppCoreGuidelines have some sections on that as well: Section ES.100-103
> >
> >Not sure if this check should care. On the other hand, would it be nice to 
> >have a check that covers all "integer problems".
> 
> Any such check will require so many options that it is likely to be almost 
> unusable. However, I would not be opposed to seeing a clang-tidy module that 
> has a bunch of checks in it that relate to integer problems.
i think, those could land in `bugprone-`, and be aliases to hicpp and the 
cppcoreguidelines if appropriate.

depending on my time (i should have a lot of free time for 2 months) 
i will try to implement some.
is there a resource with all common problems found with integers?


https://reviews.llvm.org/D36586



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


[PATCH] D35955: clang-format: Add preprocessor directive indentation

2017-08-24 Thread Erik Uhlmann via Phabricator via cfe-commits
euhlmann added a comment.

I'm glad this is finally in a state to land. Thanks for the helpful reviews!


https://reviews.llvm.org/D35955



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


  1   2   >