r304190 - Diagnose attempts to build a preprocessed module that defines an unavailable submodule.

2017-05-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 30 00:22:59 2017
New Revision: 304190

URL: http://llvm.org/viewvc/llvm-project?rev=304190=rev
Log:
Diagnose attempts to build a preprocessed module that defines an unavailable 
submodule.

The errors we would otherwise get are incomprehensible, as we would enter the
module but not make its contents visible to itself.

Added:
cfe/trunk/test/Modules/preprocess-unavailable.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=304190=304189=304190=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue May 30 00:22:59 2017
@@ -525,6 +525,8 @@ def err_pp_module_begin_without_module_e
 def err_pp_module_end_without_module_begin : Error<
   "no matching '#pragma clang module begin' for this "
   "'#pragma clang module end'">;
+def note_pp_module_begin_here : Note<
+  "entering module '%0' due to this pragma">;
 
 def err_defined_macro_name : Error<"'defined' cannot be used as a macro name">;
 def err_paste_at_start : Error<

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=304190=304189=304190=diff
==
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Tue May 30 00:22:59 2017
@@ -1407,6 +1407,24 @@ struct PragmaModuleBeginHandler : public
   M = NewM;
 }
 
+// If the module isn't available, it doesn't make sense to enter it.
+if (!M->isAvailable()) {
+  Module::Requirement Requirement;
+  Module::UnresolvedHeaderDirective MissingHeader;
+  (void)M->isAvailable(PP.getLangOpts(), PP.getTargetInfo(),
+   Requirement, MissingHeader);
+  if (MissingHeader.FileNameLoc.isValid()) {
+PP.Diag(MissingHeader.FileNameLoc, diag::err_module_header_missing)
+  << MissingHeader.IsUmbrella << MissingHeader.FileName;
+  } else {
+PP.Diag(M->DefinitionLoc, diag::err_module_unavailable)
+  << M->getFullModuleName() << Requirement.second << Requirement.first;
+  }
+  PP.Diag(BeginLoc, diag::note_pp_module_begin_here)
+<< M->getTopLevelModuleName();
+  return;
+}
+
 // Enter the scope of the submodule.
 PP.EnterSubmodule(M, BeginLoc, /*ForPragma*/true);
 PP.EnterAnnotationToken(SourceRange(BeginLoc, ModuleName.back().second),

Added: cfe/trunk/test/Modules/preprocess-unavailable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/preprocess-unavailable.cpp?rev=304190=auto
==
--- cfe/trunk/test/Modules/preprocess-unavailable.cpp (added)
+++ cfe/trunk/test/Modules/preprocess-unavailable.cpp Tue May 30 00:22:59 2017
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -x c++-module-map %s -fmodule-name=a -verify
+module a {
+  module b {
+requires cplusplus11
+  }
+}
+#pragma clang module contents
+// expected-error@3 {{module 'a.b' requires feature 'cplusplus11'}}
+#pragma clang module begin a.b // expected-note {{entering module 'a' due to 
this pragma}}
+int f();
+int g() { f(); }
+#pragma clang module end // expected-error {{no matching '#pragma clang module 
begin'}}


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


r304188 - [trivial] fix a typo in comment, NFC

2017-05-29 Thread Hiroshi Inoue via cfe-commits
Author: inouehrs
Date: Tue May 30 00:06:46 2017
New Revision: 304188

URL: http://llvm.org/viewvc/llvm-project?rev=304188=rev
Log:
[trivial] fix a typo in comment, NFC

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

Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=304188=304187=304188=diff
==
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Tue May 30 00:06:46 
2017
@@ -506,7 +506,7 @@ void SDiagsWriter::EmitBlockInfoBlock()
   Abbrev->Add(BitCodeAbbrevOp(RECORD_FILENAME));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10)); // Mapped file ID.
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Size.
-  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Modifcation 
time.  
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Modification 
time.  
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Text size.
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // File name text.
   Abbrevs.set(RECORD_FILENAME, Stream.EmitBlockInfoAbbrev(BLOCK_DIAG,


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


[PATCH] D33663: CGCleanup: Use correct insertion point for AllocaInst

2017-05-29 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov created this revision.

This is a follow up for the https://reviews.llvm.org/rL297084 which made sure 
that dominance is preserved during expression cleanup emission.
We ran into a case where dominance fixup code was inserting the store in the 
middle of allocas.

  %x = alloca i32, align 4
  store i32* %x, i32** %tmp.exprcleanup, align 4 ; <= HERE
  %ref.tmp3 = alloca %struct.A, align 1
  %agg.tmp5 = alloca 
%"struct.std::experimental::coroutines_v1::coroutine_handle.0", align 4
  %tmp.exprcleanup = alloca i32*, align 4
  %allocapt = bitcast i32 undef to i32
  store i32 %0, i32* %.addr, align 4

This fix makes sure that if we are fixing up domination for an alloca 
instruction we will do it after the AllocaInsertPt


https://reviews.llvm.org/D33663

Files:
  lib/CodeGen/CGCleanup.cpp
  test/CodeGenCoroutines/coro-await-domination.cpp


Index: test/CodeGenCoroutines/coro-await-domination.cpp
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-await-domination.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 
-emit-llvm %s -o - | FileCheck %s
+#include "Inputs/coroutine.h"
+
+using namespace std::experimental;
+
+struct coro {
+  struct promise_type {
+coro get_return_object();
+suspend_never initial_suspend();
+suspend_never final_suspend();
+void return_void();
+static void unhandled_exception();
+  };
+};
+
+struct A {
+  ~A();
+  bool await_ready();
+  int await_resume();
+  template  void await_suspend(F);
+};
+
+// Verifies that domination is properly built during cleanup.
+// Without CGCleanup.cpp fix verifier was reporting:
+// Instruction does not dominate all uses!
+//  %tmp.exprcleanup = alloca i32*, align 8
+//  store i32* %x, i32** %tmp.exprcleanup, align 8
+
+
+// CHECK-LABEL: f(
+extern "C" coro f(int) {
+  int x = 42;
+  x = co_await A{};
+}
Index: lib/CodeGen/CGCleanup.cpp
===
--- lib/CodeGen/CGCleanup.cpp
+++ lib/CodeGen/CGCleanup.cpp
@@ -455,6 +455,8 @@
 llvm::BasicBlock::iterator InsertBefore;
 if (auto *Invoke = dyn_cast(Inst))
   InsertBefore = Invoke->getNormalDest()->getFirstInsertionPt();
+else if (isa(Inst))
+  InsertBefore = std::next(AllocaInsertPt->getIterator());
 else
   InsertBefore = std::next(Inst->getIterator());
 CGBuilderTy(CGM, &*InsertBefore).CreateStore(Inst, Tmp);


Index: test/CodeGenCoroutines/coro-await-domination.cpp
===
--- /dev/null
+++ test/CodeGenCoroutines/coro-await-domination.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcoroutines-ts -std=c++14 -emit-llvm %s -o - | FileCheck %s
+#include "Inputs/coroutine.h"
+
+using namespace std::experimental;
+
+struct coro {
+  struct promise_type {
+coro get_return_object();
+suspend_never initial_suspend();
+suspend_never final_suspend();
+void return_void();
+static void unhandled_exception();
+  };
+};
+
+struct A {
+  ~A();
+  bool await_ready();
+  int await_resume();
+  template  void await_suspend(F);
+};
+
+// Verifies that domination is properly built during cleanup.
+// Without CGCleanup.cpp fix verifier was reporting:
+// Instruction does not dominate all uses!
+//  %tmp.exprcleanup = alloca i32*, align 8
+//  store i32* %x, i32** %tmp.exprcleanup, align 8
+
+
+// CHECK-LABEL: f(
+extern "C" coro f(int) {
+  int x = 42;
+  x = co_await A{};
+}
Index: lib/CodeGen/CGCleanup.cpp
===
--- lib/CodeGen/CGCleanup.cpp
+++ lib/CodeGen/CGCleanup.cpp
@@ -455,6 +455,8 @@
 llvm::BasicBlock::iterator InsertBefore;
 if (auto *Invoke = dyn_cast(Inst))
   InsertBefore = Invoke->getNormalDest()->getFirstInsertionPt();
+else if (isa(Inst))
+  InsertBefore = std::next(AllocaInsertPt->getIterator());
 else
   InsertBefore = std::next(Inst->getIterator());
 CGBuilderTy(CGM, &*InsertBefore).CreateStore(Inst, Tmp);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r304183 - [modules] When we #include a local submodule header that we've already built,

2017-05-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon May 29 21:03:19 2017
New Revision: 304183

URL: http://llvm.org/viewvc/llvm-project?rev=304183=rev
Log:
[modules] When we #include a local submodule header that we've already built,
and it has an include guard, produce callbacks for a module import, not for a
skipped non-modular header.

Fixes -E output when preprocessing a module to list these cases as a module
import, rather than suppressing the #include and losing the import side effect.

Added:
cfe/trunk/test/Modules/Inputs/preprocess/a.h
cfe/trunk/test/Modules/Inputs/preprocess/b.h
cfe/trunk/test/Modules/Inputs/preprocess/c.h
cfe/trunk/test/Modules/preprocess-nested.cpp
Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/test/Modules/Inputs/preprocess/module.modulemap

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=304183=304182=304183=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon May 29 21:03:19 2017
@@ -1906,6 +1906,25 @@ void Preprocessor::HandleIncludeDirectiv
 }
   }
 
+  // The #included file will be considered to be a system header if either it 
is
+  // in a system include directory, or if the #includer is a system include
+  // header.
+  SrcMgr::CharacteristicKind FileCharacter =
+  SourceMgr.getFileCharacteristic(FilenameTok.getLocation());
+  if (File)
+FileCharacter = std::max(HeaderInfo.getFileDirFlavor(File), FileCharacter);
+
+  // Ask HeaderInfo if we should enter this #include file.  If not, #including
+  // this file will have no effect.
+  bool SkipHeader = false;
+  if (ShouldEnter && File &&
+  !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,
+ getLangOpts().Modules,
+ SuggestedModule.getModule())) {
+ShouldEnter = false;
+SkipHeader = true;
+  }
+
   if (Callbacks) {
 // Notify the callback object that we've seen an inclusion directive.
 Callbacks->InclusionDirective(
@@ -1913,18 +1932,13 @@ void Preprocessor::HandleIncludeDirectiv
 LangOpts.MSVCCompat ? NormalizedPath.c_str() : Filename, isAngled,
 FilenameRange, File, SearchPath, RelativePath,
 ShouldEnter ? nullptr : SuggestedModule.getModule());
+if (SkipHeader && !SuggestedModule.getModule())
+  Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);
   }
 
   if (!File)
 return;
 
-  // The #included file will be considered to be a system header if either it 
is
-  // in a system include directory, or if the #includer is a system include
-  // header.
-  SrcMgr::CharacteristicKind FileCharacter =
-std::max(HeaderInfo.getFileDirFlavor(File),
- SourceMgr.getFileCharacteristic(FilenameTok.getLocation()));
-
   // FIXME: If we have a suggested module, and we've already visited this file,
   // don't bother entering it again. We know it has no further effect.
 
@@ -1964,19 +1978,6 @@ void Preprocessor::HandleIncludeDirectiv
 }
   }
 
-  // Ask HeaderInfo if we should enter this #include file.  If not, #including
-  // this file will have no effect.
-  bool SkipHeader = false;
-  if (ShouldEnter &&
-  !HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,
- getLangOpts().Modules,
- SuggestedModule.getModule())) {
-ShouldEnter = false;
-SkipHeader = true;
-if (Callbacks)
-  Callbacks->FileSkipped(*File, FilenameTok, FileCharacter);
-  }
-
   // If we don't need to enter the file, stop now.
   if (!ShouldEnter) {
 // If this is a module import, make it visible if needed.

Added: cfe/trunk/test/Modules/Inputs/preprocess/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/preprocess/a.h?rev=304183=auto
==
--- cfe/trunk/test/Modules/Inputs/preprocess/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/preprocess/a.h Mon May 29 21:03:19 2017
@@ -0,0 +1,2 @@
+#include "c.h"
+T a();

Added: cfe/trunk/test/Modules/Inputs/preprocess/b.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/preprocess/b.h?rev=304183=auto
==
--- cfe/trunk/test/Modules/Inputs/preprocess/b.h (added)
+++ cfe/trunk/test/Modules/Inputs/preprocess/b.h Mon May 29 21:03:19 2017
@@ -0,0 +1,2 @@
+#include "c.h"
+T b();

Added: cfe/trunk/test/Modules/Inputs/preprocess/c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/preprocess/c.h?rev=304183=auto
==
--- cfe/trunk/test/Modules/Inputs/preprocess/c.h (added)
+++ cfe/trunk/test/Modules/Inputs/preprocess/c.h Mon May 29 21:03:19 2017
@@ -0,0 +1,4 @@

[PATCH] D32411: [libcxx] Provide #include_next alternative for MSVC

2017-05-29 Thread Ben Craig via Phabricator via cfe-commits
bcraig updated this revision to Diff 100650.
bcraig edited the summary of this revision.

https://reviews.llvm.org/D32411

Files:
  CMakeLists.txt
  docs/DesignDocs/IncludeNextEmulation.rst
  include/__config
  include/__config_site.in
  include/complex.h
  include/cstddef
  include/ctype.h
  include/errno.h
  include/float.h
  include/inttypes.h
  include/limits.h
  include/locale.h
  include/math.h
  include/setjmp.h
  include/stdbool.h
  include/stddef.h
  include/stdint.h
  include/stdio.h
  include/stdlib.h
  include/string.h
  include/wchar.h
  include/wctype.h
  utils/libcxx/test/config.py

Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -632,6 +632,8 @@
 for m in feature_macros:
 if m == '_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS':
 continue
+if m.startswith('_LIBCPP_INCLUDE_NEXT'):
+continue
 if m == '_LIBCPP_ABI_VERSION':
 self.config.available_features.add('libcpp-abi-version-v%s'
 % feature_macros[m])
Index: include/wctype.h
===
--- include/wctype.h
+++ include/wctype.h
@@ -51,7 +51,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(wctype.h)
+#else
 #include_next 
+#endif
 
 #ifdef __cplusplus
 
Index: include/wchar.h
===
--- include/wchar.h
+++ include/wchar.h
@@ -14,7 +14,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(wchar.h)
+#else
 #include_next 
+#endif
 
 #elif !defined(_LIBCPP_WCHAR_H)
 #define _LIBCPP_WCHAR_H
@@ -116,7 +120,11 @@
 #define __CORRECT_ISO_CPP_WCHAR_H_PROTO
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(wchar.h)
+#else
 #include_next 
+#endif
 
 // Determine whether we have const-correct overloads for wcschr and friends.
 #if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_)
Index: include/string.h
===
--- include/string.h
+++ include/string.h
@@ -58,7 +58,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(string.h)
+#else
 #include_next 
+#endif
 
 // MSVCRT, GNU libc and its derivates may already have the correct prototype in
 // . This macro can be defined by users if their C library provides
Index: include/stdlib.h
===
--- include/stdlib.h
+++ include/stdlib.h
@@ -14,7 +14,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(stdlib.h)
+#else
 #include_next 
+#endif
 
 #elif !defined(_LIBCPP_STDLIB_H)
 #define _LIBCPP_STDLIB_H
@@ -91,7 +95,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(stdlib.h)
+#else
 #include_next 
+#endif
 
 #ifdef __cplusplus
 
Index: include/stdio.h
===
--- include/stdio.h
+++ include/stdio.h
@@ -14,7 +14,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(stdio.h)
+#else
 #include_next 
+#endif
 
 #elif !defined(_LIBCPP_STDIO_H)
 #define _LIBCPP_STDIO_H
@@ -105,7 +109,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(stdio.h)
+#else
 #include_next 
+#endif
 
 #ifdef __cplusplus
 
Index: include/stdint.h
===
--- include/stdint.h
+++ include/stdint.h
@@ -116,6 +116,10 @@
 #   define __STDC_CONSTANT_MACROS
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_VC(stdint.h)
+#else
 #include_next 
+#endif
 
 #endif  // _LIBCPP_STDINT_H
Index: include/stddef.h
===
--- include/stddef.h
+++ include/stddef.h
@@ -15,7 +15,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(stddef.h)
+#else
 #include_next 
+#endif
 
 #elif !defined(_LIBCPP_STDDEF_H)
 #define _LIBCPP_STDDEF_H
@@ -43,7 +47,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_UCRT(stddef.h)
+#else
 #include_next 
+#endif
 
 #ifdef __cplusplus
 
Index: include/stdbool.h
===
--- include/stdbool.h
+++ include/stdbool.h
@@ -26,7 +26,11 @@
 #pragma GCC system_header
 #endif
 
+#if defined(_LIBCPP_HAS_NO_INCLUDE_NEXT)
+#include _LIBCPP_INCLUDE_NEXT_VC(stdbool.h)
+#else
 #include_next 

[PATCH] D33661: [Sema][ObjC] Don't emit availability diagnostics for categories extending unavailable interfaces

2017-05-29 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.

Previously, @implementations of categories that extended 
unavailable/deprecated/partial @interfaces triggered availability diagnostics. 
There was no way to turn this off, as we check the use of the unavailable decl 
outside of the context of the @implementation, so attaching an attribute to the 
category @interface doesn't do anything. Moreover, this diagnostic can't 
actually catch any bugs even if it worked correctly, there is no way to use 
stuff declared in a category without referencing the extended @interface 
(AFAIK, I'm not fluent in Objective-C), which will trigger the diagnostic.

rdar://32427296

Thanks for taking a look,
Erik


https://reviews.llvm.org/D33661

Files:
  lib/Sema/SemaDeclObjC.cpp
  test/SemaObjC/attr-deprecated.m
  test/SemaObjC/class-unavail-warning.m
  test/SemaObjC/warn-deprecated-implementations.m


Index: test/SemaObjC/warn-deprecated-implementations.m
===
--- test/SemaObjC/warn-deprecated-implementations.m
+++ test/SemaObjC/warn-deprecated-implementations.m
@@ -28,15 +28,14 @@
 - (void) G {}  // No warning, implementing its own deprecated method
 @end
 
-__attribute__((deprecated)) // expected-note 2 {{'CL' has been explicitly 
marked deprecated here}}
+__attribute__((deprecated)) // expected-note {{'CL' has been explicitly marked 
deprecated here}}
 @interface CL // expected-note 2 {{class declared here}} 
 @end
 
 @implementation CL // expected-warning {{Implementing deprecated class}}
 @end
 
-@implementation CL ( SomeCategory ) // expected-warning {{'CL' is deprecated}} 
\
-// expected-warning {{Implementing 
deprecated category}}
+@implementation CL (SomeCategory) // expected-warning {{Implementing 
deprecated category}}
 @end
 
 @interface CL_SUB : CL // expected-warning {{'CL' is deprecated}}
Index: test/SemaObjC/class-unavail-warning.m
===
--- test/SemaObjC/class-unavail-warning.m
+++ test/SemaObjC/class-unavail-warning.m
@@ -2,7 +2,7 @@
 // rdar://9092208
 
 __attribute__((unavailable("not available")))
-@interface MyClass { // expected-note 8 {{'MyClass' has been explicitly marked 
unavailable here}}
+@interface MyClass { // expected-note 7 {{'MyClass' has been explicitly marked 
unavailable here}}
 @public
 void *_test;
 MyClass *ivar; // no error.
@@ -28,7 +28,7 @@
 @interface MyClass (Cat2) // no error.
 @end
 
-@implementation MyClass (Cat2) // expected-error {{unavailable}}
+@implementation MyClass (Cat2) // no error.
 @end
 
 int main() {
Index: test/SemaObjC/attr-deprecated.m
===
--- test/SemaObjC/attr-deprecated.m
+++ test/SemaObjC/attr-deprecated.m
@@ -83,7 +83,7 @@
 }
 
 
-__attribute ((deprecated)) // expected-note 2 {{'DEPRECATED' has been 
explicitly marked deprecated here}}
+__attribute ((deprecated)) // expected-note {{'DEPRECATED' has been explicitly 
marked deprecated here}}
 @interface DEPRECATED { 
   @public int ivar; 
   DEPRECATED *ivar2; // no warning.
@@ -98,9 +98,17 @@
 @end
 
 @interface DEPRECATED (Category2) // no warning.
+- (id)meth;
 @end
 
-@implementation DEPRECATED (Category2) // expected-warning {{'DEPRECATED' is 
deprecated}}
+__attribute__((deprecated))
+void depr_function();
+
+@implementation DEPRECATED (Category2) // no warning
+- (id)meth {
+  depr_function(); // no warning.
+  return 0;
+}
 @end
 
 @interface NS : DEPRECATED  // expected-warning {{'DEPRECATED' is deprecated}}
Index: lib/Sema/SemaDeclObjC.cpp
===
--- lib/Sema/SemaDeclObjC.cpp
+++ lib/Sema/SemaDeclObjC.cpp
@@ -1851,10 +1851,6 @@
   // FIXME: PushOnScopeChains?
   CurContext->addDecl(CDecl);
 
-  // If the interface is deprecated/unavailable, warn/error about it.
-  if (IDecl)
-DiagnoseUseOfDecl(IDecl, ClassLoc);
-
   // If the interface has the objc_runtime_visible attribute, we
   // cannot implement a category for it.
   if (IDecl && IDecl->hasAttr()) {


Index: test/SemaObjC/warn-deprecated-implementations.m
===
--- test/SemaObjC/warn-deprecated-implementations.m
+++ test/SemaObjC/warn-deprecated-implementations.m
@@ -28,15 +28,14 @@
 - (void) G {} 	// No warning, implementing its own deprecated method
 @end
 
-__attribute__((deprecated)) // expected-note 2 {{'CL' has been explicitly marked deprecated here}}
+__attribute__((deprecated)) // expected-note {{'CL' has been explicitly marked deprecated here}}
 @interface CL // expected-note 2 {{class declared here}} 
 @end
 
 @implementation CL // expected-warning {{Implementing deprecated class}}
 @end
 
-@implementation CL ( SomeCategory ) // expected-warning {{'CL' is deprecated}} \
-// expected-warning {{Implementing deprecated category}}
+@implementation CL 

[PATCH] D33082: Fix Libc++ build with MinGW64

2017-05-29 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.

LGTM. Thanks for all the revisions!


https://reviews.llvm.org/D33082



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


Re: r303934 - "*" => "+" to avoid matching on empty string.

2017-05-29 Thread Richard Trieu via cfe-commits
On some Windows bots, multiple back slashes are used as a single path
separator so the path looks like:

build_dirbinclang

PREFIX_DIR would match "build_dirbin\\", the path separator matches
"\", then the directory would match the empty string, and the final path
separator would match the "\" before clang.

On Mon, May 29, 2017 at 11:18 AM, David Blaikie  wrote:

> Why would matching on an empty string be bad in this case?
>
> On Thu, May 25, 2017 at 4:25 PM Richard Trieu via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rtrieu
>> Date: Thu May 25 18:25:36 2017
>> New Revision: 303934
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=303934=rev
>> Log:
>> "*" => "+" to avoid matching on empty string.
>>
>> Modified:
>> cfe/trunk/test/Driver/baremetal.cpp
>>
>> Modified: cfe/trunk/test/Driver/baremetal.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ba
>> remetal.cpp?rev=303934=303933=303934=diff
>> 
>> ==
>> --- cfe/trunk/test/Driver/baremetal.cpp (original)
>> +++ cfe/trunk/test/Driver/baremetal.cpp Thu May 25 18:25:36 2017
>> @@ -4,7 +4,7 @@
>>  // RUN: -L some/directory/user/asked/for \
>>  // RUN: --sysroot=%S/Inputs/baremetal_arm \
>>  // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
>> -// CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{
>> [^/^\\]*}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none--eabi"
>> +// CHECK-V6M-C: "[[PREFIX_DIR:.*]]{{[/\\]+}}{{
>> [^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1" "-triple" "thumbv6m-none--eabi"
>>  // CHECK-V6M-C-SAME: "-resource-dir" "[[PREFIX_DIR]]{{[/\\]+}}lib{{
>> [/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
>>  // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
>>  // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{
>> {[/\\]+}}c++{{[/\\]+}}v1"
>>
>>
>> ___
>> 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] D33563: Track whether a unary operation can overflow

2017-05-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:9
+VK_LValue, OK_Ordinary, Loc, true);
 
   // Construct the loop that copies all elements of this array.

Can we pass false here if we know the array size is not too large and the 
pre-increment won't cause overflow?


https://reviews.llvm.org/D33563



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


[libcxx] r304180 - Add missing 'requires coroutines' to module map

2017-05-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 29 18:17:28 2017
New Revision: 304180

URL: http://llvm.org/viewvc/llvm-project?rev=304180=rev
Log:
Add missing 'requires coroutines' to module map

Modified:
libcxx/trunk/include/module.modulemap

Modified: libcxx/trunk/include/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/module.modulemap?rev=304180=304179=304180=diff
==
--- libcxx/trunk/include/module.modulemap (original)
+++ libcxx/trunk/include/module.modulemap Mon May 29 18:17:28 2017
@@ -502,6 +502,7 @@ module std [system] {
   export *
 }
  module coroutine {
+  requires coroutines
   header "experimental/coroutine"
   export *
 }


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


Re: r303714 - [coroutines] Fix leak in CGCoroutine.cpp

2017-05-29 Thread David Blaikie via cfe-commits
Fair enough. I don't have all the context there either.

Perhaps Richard Smith could sanity check what the right memory management
scheme is here.

On Mon, May 29, 2017 at 3:54 PM Gor Nishanov  wrote:

> My clang-foo is not strong enough :) .
>
> I wanted to make sure that: "CurCoro.Data->FinalJD =
> getJumpDestInCurrentScope(FinalBB);" is in the correct scope where I want
> it. As opposed to creating it in whatever scope co_return statement is
> encountered. But that could be simply my misundersanding of the
> frontend/scopes/etc and it is quite possible that the code can be
> refactored along the lines you are thinking about.
>
> On Mon, May 29, 2017 at 3:44 PM, David Blaikie  wrote:
>
>>
>>
>> On Mon, May 29, 2017 at 2:12 PM Gor Nishanov 
>> wrote:
>>
>>> It is not known in advance whether the final block is needed or not. It
>>> will become known once the user-authored body of the coroutine is emitted.
>>> I cannot defer creation of it up until that point, since final bb acts as a
>>> jump target for co_returns which could be in the user authored body and I
>>> need it to set up a jump destination beforehand.
>>>
>>
>> Not sure I follow - presumably those jumps could only be emitted if the
>> block would be emitted - so if the entity is created the first time it's
>> needed as a jump destination,then that should be OK?
>>
>>
>>>
>>> Ack on formatting change.
>>>
>>> On Mon, May 29, 2017 at 12:11 PM, David Blaikie 
>>> wrote:
>>>
 Could you avoid creating the FinalBB unless it's needed rather than
 creating it and then adding it so it can be removed? (or, if the creation
 can't be avoided, maybe it's OK to 'delete FinalBB' here, rather than
 adding it for it to be removed later?)

 (also bracing seems off - could you run your changes through
 clang-format? I'd expect '} else {' on the same line.

 On Tue, May 23, 2017 at 6:54 PM Gor Nishanov via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: gornishanov
> Date: Tue May 23 20:54:37 2017
> New Revision: 303714
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303714=rev
> Log:
> [coroutines] Fix leak in CGCoroutine.cpp
>
> FinalBB need to be emitted even when unused to make sure it is deleted
>
> Modified:
> cfe/trunk/lib/CodeGen/CGCoroutine.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=303714=303713=303714=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Tue May 23 20:54:37 2017
> @@ -430,6 +430,10 @@ void CodeGenFunction::EmitCoroutineBody(
>CurCoro.Data->CurrentAwaitKind = AwaitKind::Final;
>EmitStmt(S.getFinalSuspendStmt());
>  }
> +else {
> +  // We don't need FinalBB. Emit it to make sure the block is
> deleted.
> +  EmitBlock(FinalBB, /*IsFinished=*/true);
> +}
>}
>
>EmitBlock(RetBB);
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>

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


Re: r303714 - [coroutines] Fix leak in CGCoroutine.cpp

2017-05-29 Thread Gor Nishanov via cfe-commits
My clang-foo is not strong enough :) .

I wanted to make sure that: "CurCoro.Data->FinalJD =
getJumpDestInCurrentScope(FinalBB);" is in the correct scope where I want
it. As opposed to creating it in whatever scope co_return statement is
encountered. But that could be simply my misundersanding of the
frontend/scopes/etc and it is quite possible that the code can be
refactored along the lines you are thinking about.

On Mon, May 29, 2017 at 3:44 PM, David Blaikie  wrote:

>
>
> On Mon, May 29, 2017 at 2:12 PM Gor Nishanov 
> wrote:
>
>> It is not known in advance whether the final block is needed or not. It
>> will become known once the user-authored body of the coroutine is emitted.
>> I cannot defer creation of it up until that point, since final bb acts as a
>> jump target for co_returns which could be in the user authored body and I
>> need it to set up a jump destination beforehand.
>>
>
> Not sure I follow - presumably those jumps could only be emitted if the
> block would be emitted - so if the entity is created the first time it's
> needed as a jump destination,then that should be OK?
>
>
>>
>> Ack on formatting change.
>>
>> On Mon, May 29, 2017 at 12:11 PM, David Blaikie 
>> wrote:
>>
>>> Could you avoid creating the FinalBB unless it's needed rather than
>>> creating it and then adding it so it can be removed? (or, if the creation
>>> can't be avoided, maybe it's OK to 'delete FinalBB' here, rather than
>>> adding it for it to be removed later?)
>>>
>>> (also bracing seems off - could you run your changes through
>>> clang-format? I'd expect '} else {' on the same line.
>>>
>>> On Tue, May 23, 2017 at 6:54 PM Gor Nishanov via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: gornishanov
 Date: Tue May 23 20:54:37 2017
 New Revision: 303714

 URL: http://llvm.org/viewvc/llvm-project?rev=303714=rev
 Log:
 [coroutines] Fix leak in CGCoroutine.cpp

 FinalBB need to be emitted even when unused to make sure it is deleted

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

 Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
 CGCoroutine.cpp?rev=303714=303713=303714=diff
 
 ==
 --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
 +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Tue May 23 20:54:37 2017
 @@ -430,6 +430,10 @@ void CodeGenFunction::EmitCoroutineBody(
CurCoro.Data->CurrentAwaitKind = AwaitKind::Final;
EmitStmt(S.getFinalSuspendStmt());
  }
 +else {
 +  // We don't need FinalBB. Emit it to make sure the block is
 deleted.
 +  EmitBlock(FinalBB, /*IsFinished=*/true);
 +}
}

EmitBlock(RetBB);


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

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


Re: r303714 - [coroutines] Fix leak in CGCoroutine.cpp

2017-05-29 Thread David Blaikie via cfe-commits
On Mon, May 29, 2017 at 2:12 PM Gor Nishanov  wrote:

> It is not known in advance whether the final block is needed or not. It
> will become known once the user-authored body of the coroutine is emitted.
> I cannot defer creation of it up until that point, since final bb acts as a
> jump target for co_returns which could be in the user authored body and I
> need it to set up a jump destination beforehand.
>

Not sure I follow - presumably those jumps could only be emitted if the
block would be emitted - so if the entity is created the first time it's
needed as a jump destination,then that should be OK?


>
> Ack on formatting change.
>
> On Mon, May 29, 2017 at 12:11 PM, David Blaikie 
> wrote:
>
>> Could you avoid creating the FinalBB unless it's needed rather than
>> creating it and then adding it so it can be removed? (or, if the creation
>> can't be avoided, maybe it's OK to 'delete FinalBB' here, rather than
>> adding it for it to be removed later?)
>>
>> (also bracing seems off - could you run your changes through
>> clang-format? I'd expect '} else {' on the same line.
>>
>> On Tue, May 23, 2017 at 6:54 PM Gor Nishanov via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: gornishanov
>>> Date: Tue May 23 20:54:37 2017
>>> New Revision: 303714
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=303714=rev
>>> Log:
>>> [coroutines] Fix leak in CGCoroutine.cpp
>>>
>>> FinalBB need to be emitted even when unused to make sure it is deleted
>>>
>>> Modified:
>>> cfe/trunk/lib/CodeGen/CGCoroutine.cpp
>>>
>>> Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=303714=303713=303714=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
>>> +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Tue May 23 20:54:37 2017
>>> @@ -430,6 +430,10 @@ void CodeGenFunction::EmitCoroutineBody(
>>>CurCoro.Data->CurrentAwaitKind = AwaitKind::Final;
>>>EmitStmt(S.getFinalSuspendStmt());
>>>  }
>>> +else {
>>> +  // We don't need FinalBB. Emit it to make sure the block is
>>> deleted.
>>> +  EmitBlock(FinalBB, /*IsFinished=*/true);
>>> +}
>>>}
>>>
>>>EmitBlock(RetBB);
>>>
>>>
>>> ___
>>> 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] D33526: Fix spurious Wunused-lambda-capture warning

2017-05-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/Sema/SemaLambda.cpp:1524-1526
+  if (!CurContext->isDependentContext() && !IsImplicit)
+if ((IsGenericLambda && !From.isNonODRUsed()) ||
+(!IsGenericLambda && !From.isODRUsed()))

kongyi wrote:
> malcolm.parsons wrote:
> > Should generic lambdas and lambdas in a dependent context be treated the 
> > same?
> > 
> > Is a lambda inside a generic lambda in a dependent context?
> Generic lambdas are essentially templated lambdas. For diagnosing unused 
> captures, they can be treated as the same. However we are not generating 
> diagnoses within dependent contexts right now (L1524), so this is not really 
> related to this fix.
It looks like clang stops warning about the unnecessary capture in the 
following code when this patch is applied:

```
void foo2(int);

void foo1() {
  const int c = 10;
  auto lambda1 = [c](auto a) { // clang used to issue warning "lambda capture 
'c' is not required to be captured for this use"
foo2(c);
  };
  lambda1(100);
}
```

Is it possible to suppress the warning if From is an init capture instead?


Repository:
  rL LLVM

https://reviews.llvm.org/D33526



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


[PATCH] D33660: [coroutines] Fix assertion during -Wuninitialized analysis

2017-05-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

@rsmith Is there a better place to put this test?


https://reviews.llvm.org/D33660

Files:
  lib/Sema/SemaCoroutine.cpp
  test/SemaCXX/coreturn.cpp
  test/SemaCXX/coroutine-uninitialized-warning-crash.cpp


Index: test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
===
--- /dev/null
+++ test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts 
-fsyntax-only -Wall -Wextra -Wuninitialized  -fblocks
+#include "Inputs/std-coroutine.h"
+
+using namespace std::experimental;
+
+
+struct A {
+  bool await_ready() { return true; }
+  int await_resume() { return 42; }
+  template 
+  void await_suspend(F) {}
+};
+
+
+struct coro_t {
+  struct promise_type {
+coro_t get_return_object() { return {}; }
+suspend_never initial_suspend() { return {}; }
+suspend_never final_suspend() { return {}; }
+A yield_value(int) { return {}; }
+void return_void() {}
+static void unhandled_exception() {}
+  };
+};
+
+coro_t f(int n) {
+  if (n == 0)
+co_return;
+  co_yield 42;
+  int x = co_await A{};
+}
+
+template 
+coro_t g(int n) {
+  if (n == 0)
+co_return;
+  co_yield 42;
+  int x = co_await Await{};
+}
+
+int main() {
+  f(0);
+  g(0);
+}
Index: test/SemaCXX/coreturn.cpp
===
--- test/SemaCXX/coreturn.cpp
+++ test/SemaCXX/coreturn.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts 
-fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks 
-Wno-unreachable-code -Wno-unused-value
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts 
-fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks 
-Wall -Wextra -Wno-error=unreachable-code
 #include "Inputs/std-coroutine.h"
 
 using std::experimental::suspend_always;
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -437,6 +437,7 @@
   if (VD->isInvalidDecl())
 return nullptr;
   ActOnUninitializedDecl(VD);
+  FD->addDecl(VD);
   assert(!VD->isInvalidDecl());
   return VD;
 }


Index: test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
===
--- /dev/null
+++ test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wall -Wextra -Wuninitialized  -fblocks
+#include "Inputs/std-coroutine.h"
+
+using namespace std::experimental;
+
+
+struct A {
+  bool await_ready() { return true; }
+  int await_resume() { return 42; }
+  template 
+  void await_suspend(F) {}
+};
+
+
+struct coro_t {
+  struct promise_type {
+coro_t get_return_object() { return {}; }
+suspend_never initial_suspend() { return {}; }
+suspend_never final_suspend() { return {}; }
+A yield_value(int) { return {}; }
+void return_void() {}
+static void unhandled_exception() {}
+  };
+};
+
+coro_t f(int n) {
+  if (n == 0)
+co_return;
+  co_yield 42;
+  int x = co_await A{};
+}
+
+template 
+coro_t g(int n) {
+  if (n == 0)
+co_return;
+  co_yield 42;
+  int x = co_await Await{};
+}
+
+int main() {
+  f(0);
+  g(0);
+}
Index: test/SemaCXX/coreturn.cpp
===
--- test/SemaCXX/coreturn.cpp
+++ test/SemaCXX/coreturn.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wno-unreachable-code -Wno-unused-value
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wignored-qualifiers -Wno-error=return-type -verify -fblocks -Wall -Wextra -Wno-error=unreachable-code
 #include "Inputs/std-coroutine.h"
 
 using std::experimental::suspend_always;
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -437,6 +437,7 @@
   if (VD->isInvalidDecl())
 return nullptr;
   ActOnUninitializedDecl(VD);
+  FD->addDecl(VD);
   assert(!VD->isInvalidDecl());
   return VD;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30909: [Analyzer] Finish taint propagation to derived symbols of tainted regions

2017-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yep, fixed indeed.


https://reviews.llvm.org/D30909



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


[PATCH] D33437: Emit available_externally vtables opportunistically

2017-05-29 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 100641.
Prazek added a comment.

changed assert


https://reviews.llvm.org/D33437

Files:
  include/clang/AST/VTableBuilder.h
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/vtable-available-externally.cpp
  test/CodeGenCXX/vtable-linkage.cpp

Index: test/CodeGenCXX/vtable-linkage.cpp
===
--- test/CodeGenCXX/vtable-linkage.cpp
+++ test/CodeGenCXX/vtable-linkage.cpp
@@ -145,12 +145,14 @@
 // F is an explicit template instantiation declaration without a
 // key function, so its vtable should have external linkage.
 // CHECK-DAG: @_ZTV1FIiE = external unnamed_addr constant
-// CHECK-OPT-DAG: @_ZTV1FIiE = external unnamed_addr constant
+// CHECK-OPT-DAG: @_ZTV1FIiE = available_externally unnamed_addr constant
 
 // E is an explicit template instantiation declaration. It has a
 // key function is not instantiated, so we know that vtable definition
 // will be generated in TU where key function will be defined
-// so we can mark it as available_externally (only with optimizations)
+// so we can mark it as external (without optimizations) and
+// available_externally (with optimizations) because all of the inline
+// virtual functions have been emitted.
 // CHECK-DAG: @_ZTV1EIiE = external unnamed_addr constant
 // CHECK-OPT-DAG: @_ZTV1EIiE = available_externally unnamed_addr constant
 
Index: test/CodeGenCXX/vtable-available-externally.cpp
===
--- test/CodeGenCXX/vtable-available-externally.cpp
+++ test/CodeGenCXX/vtable-available-externally.cpp
@@ -12,6 +12,7 @@
 // RUN: FileCheck --check-prefix=CHECK-TEST14 %s < %t.opt
 // RUN: FileCheck --check-prefix=CHECK-TEST15 %s < %t.opt
 // RUN: FileCheck --check-prefix=CHECK-TEST16 %s < %t.opt
+// RUN: FileCheck --check-prefix=CHECK-TEST17 %s < %t.opt
 
 #include 
 
@@ -274,8 +275,8 @@
   virtual D& operator=(const D&);
 };
 
-// Cannot emit B's vtable available_externally, because we cannot create
-// a reference to the inline virtual B::operator= function.
+// Cannot emit D's vtable available_externally, because we cannot create
+// a reference to the inline virtual D::operator= function.
 // CHECK-TEST11: @_ZTVN6Test111DE = external unnamed_addr constant
 struct D : C {
   virtual void key();
@@ -391,3 +392,30 @@
 }
 }
 
+namespace Test17 {
+// This test checks if we emit vtables opportunistically.
+// CHECK-TEST17-DAG: @_ZTVN6Test171AE = available_externally
+// CHECK-TEST17-DAG: @_ZTVN6Test171BE = external
+
+struct A {
+  virtual void key();
+  virtual void bar() {}
+};
+
+// We won't gonna use deleting destructor for this type, which will disallow
+// emitting vtable as available_externally
+struct B {
+  virtual void key();
+  virtual ~B() {}
+};
+
+void testcaseA() {
+  A a;
+  a.bar(); // this forces to emit definition of bar
+}
+
+void testcaseB() {
+  B b; // This only forces emitting of complete object destructor
+}
+
+} // namespace Test17
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3756,6 +3756,9 @@
   if (llvm::GlobalVariable *GV = CGM.getModule().getNamedGlobal(MangledName))
 return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
 
+  // Note for the future: If we would ever like to do deferred emission of
+  // RTTI, check if emitting vtables opportunistically need any adjustment.
+
   // Compute the fields for the TypeDescriptor.
   SmallString<256> TypeInfoString;
   {
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -366,20 +366,30 @@
   void emitCXXStructor(const CXXMethodDecl *MD, StructorType Type) override;
 
  private:
-   bool hasAnyVirtualInlineFunction(const CXXRecordDecl *RD) const {
-const auto  =
-CGM.getItaniumVTableContext().getVTableLayout(RD);
-
-for (const auto  : VtableLayout.vtable_components()) {
-  // Skip empty slot.
-  if (!VtableComponent.isUsedFunctionPointerKind())
-continue;
-
-  const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
-  if (Method->getCanonicalDecl()->isInlined())
-return true;
-}
-return false;
+   bool hasAnyUnusedVirtualInlineFunction(const CXXRecordDecl *RD) const {
+ const auto  =
+ CGM.getItaniumVTableContext().getVTableLayout(RD);
+
+ for (const auto  : VtableLayout.vtable_components()) {
+   // Skip empty slot.
+   if (!VtableComponent.isUsedFunctionPointerKind())
+ continue;
+
+   const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
+   if (!Method->getCanonicalDecl()->isInlined())
+ continue;
+
+   StringRef Name = 

r304176 - CGCoroutine.cpp: (NFC) clang-format misplaced brace

2017-05-29 Thread Gor Nishanov via cfe-commits
Author: gornishanov
Date: Mon May 29 16:15:31 2017
New Revision: 304176

URL: http://llvm.org/viewvc/llvm-project?rev=304176=rev
Log:
CGCoroutine.cpp: (NFC) clang-format misplaced brace

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

Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=304176=304175=304176=diff
==
--- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Mon May 29 16:15:31 2017
@@ -578,8 +578,7 @@ void CodeGenFunction::EmitCoroutineBody(
   EmitBlock(FinalBB);
   CurCoro.Data->CurrentAwaitKind = AwaitKind::Final;
   EmitStmt(S.getFinalSuspendStmt());
-}
-else {
+} else {
   // We don't need FinalBB. Emit it to make sure the block is deleted.
   EmitBlock(FinalBB, /*IsFinished=*/true);
 }


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


Re: r303714 - [coroutines] Fix leak in CGCoroutine.cpp

2017-05-29 Thread Gor Nishanov via cfe-commits
It is not known in advance whether the final block is needed or not. It
will become known once the user-authored body of the coroutine is emitted.
I cannot defer creation of it up until that point, since final bb acts as a
jump target for co_returns which could be in the user authored body and I
need it to set up a jump destination beforehand.

Ack on formatting change.

On Mon, May 29, 2017 at 12:11 PM, David Blaikie  wrote:

> Could you avoid creating the FinalBB unless it's needed rather than
> creating it and then adding it so it can be removed? (or, if the creation
> can't be avoided, maybe it's OK to 'delete FinalBB' here, rather than
> adding it for it to be removed later?)
>
> (also bracing seems off - could you run your changes through clang-format?
> I'd expect '} else {' on the same line.
>
> On Tue, May 23, 2017 at 6:54 PM Gor Nishanov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: gornishanov
>> Date: Tue May 23 20:54:37 2017
>> New Revision: 303714
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=303714=rev
>> Log:
>> [coroutines] Fix leak in CGCoroutine.cpp
>>
>> FinalBB need to be emitted even when unused to make sure it is deleted
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGCoroutine.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
>> CGCoroutine.cpp?rev=303714=303713=303714=diff
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Tue May 23 20:54:37 2017
>> @@ -430,6 +430,10 @@ void CodeGenFunction::EmitCoroutineBody(
>>CurCoro.Data->CurrentAwaitKind = AwaitKind::Final;
>>EmitStmt(S.getFinalSuspendStmt());
>>  }
>> +else {
>> +  // We don't need FinalBB. Emit it to make sure the block is
>> deleted.
>> +  EmitBlock(FinalBB, /*IsFinished=*/true);
>> +}
>>}
>>
>>EmitBlock(RetBB);
>>
>>
>> ___
>> 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] D33659: Extend DynamicLibrary class to be usable without loading permanently.

2017-05-29 Thread Frederich Munch via Phabricator via cfe-commits
marsupial created this revision.

https://reviews.llvm.org/D33659

Files:
  lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp


Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -53,8 +53,8 @@
i != e; ++i) {
 // Get access to the plugin.
 std::string err;
-DynamicLibrary lib = DynamicLibrary::getPermanentLibrary(i->c_str(), );
-if (!lib.isValid()) {
+DynamicLibrary *lib = DynamicLibrary::getPermanentLibrary(i->c_str(), 
);
+if (!lib) {
   diags->Report(diag::err_fe_unable_to_load_plugin) << *i << err;
   continue;
 }


Index: lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistration.cpp
@@ -53,8 +53,8 @@
i != e; ++i) {
 // Get access to the plugin.
 std::string err;
-DynamicLibrary lib = DynamicLibrary::getPermanentLibrary(i->c_str(), );
-if (!lib.isValid()) {
+DynamicLibrary *lib = DynamicLibrary::getPermanentLibrary(i->c_str(), );
+if (!lib) {
   diags->Report(diag::err_fe_unable_to_load_plugin) << *i << err;
   continue;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r304173 - Fix in C++03

2017-05-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 29 14:46:16 2017
New Revision: 304173

URL: http://llvm.org/viewvc/llvm-project?rev=304173=rev
Log:
Fix  in C++03

Modified:
libcxx/trunk/include/experimental/coroutine

Modified: libcxx/trunk/include/experimental/coroutine
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/coroutine?rev=304173=304172=304173=diff
==
--- libcxx/trunk/include/experimental/coroutine (original)
+++ libcxx/trunk/include/experimental/coroutine Mon May 29 14:46:16 2017
@@ -148,7 +148,7 @@ public:
 // FIXME: Should from_address(nullptr) be allowed?
 _LIBCPP_ALWAYS_INLINE
 static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
-  return {};
+  return coroutine_handle(nullptr);
 }
 
 template 
@@ -231,7 +231,7 @@ public:
 // FIXME: should from_address work with nullptr?
 _LIBCPP_ALWAYS_INLINE
 static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
-  return {};
+  return coroutine_handle(nullptr);
 }
 
 template 


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


[libcxx] r304172 - [coroutines] Make coroutine_handle::from_address ill-formed for everything but void*.

2017-05-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 29 14:24:25 2017
New Revision: 304172

URL: http://llvm.org/viewvc/llvm-project?rev=304172=rev
Log:
[coroutines] Make coroutine_handle::from_address ill-formed for everything 
but void*.

from_address requires that the provided pointer refer to the suspended 
coroutine,
which doesn't have a type, or at least not one knowable by the user. Therefore
every use of `from_address` with a typed pointer is almost certainly a bug.

This behavior is a part of the TS specification, but hopefully it will be
in the future.

Added:

libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/lit.local.cfg
Modified:
libcxx/trunk/include/experimental/coroutine

Modified: libcxx/trunk/include/experimental/coroutine
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/coroutine?rev=304172=304171=304172=diff
==
--- libcxx/trunk/include/experimental/coroutine (original)
+++ libcxx/trunk/include/experimental/coroutine Mon May 29 14:24:25 2017
@@ -145,6 +145,19 @@ public:
 return __tmp;
 }
 
+// FIXME: Should from_address(nullptr) be allowed?
+_LIBCPP_ALWAYS_INLINE
+static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
+  return {};
+}
+
+template 
+static coroutine_handle from_address(_Tp*) {
+  static_assert(_CallIsValid,
+   "coroutine_handle::from_address cannot be called with "
+"non-void pointers");
+}
+
 private:
   bool __is_suspended() const _NOEXCEPT  {
 // FIXME actually implement a check for if the coro is suspended.
@@ -221,8 +234,19 @@ public:
   return {};
 }
 
-// from_address cannot be used with the coroutines promise type.
-static coroutine_handle from_address(_Promise*) = delete;
+template 
+static coroutine_handle from_address(_Tp*) {
+  static_assert(_CallIsValid,
+   "coroutine_handle::from_address cannot be called with "
+"non-void pointers");
+}
+
+template 
+static coroutine_handle from_address(_Promise*) {
+  static_assert(_CallIsValid,
+   "coroutine_handle::from_address cannot be used with "
+"pointers to the coroutine's promise type; use 'from_promise' 
instead");
+}
 
 _LIBCPP_ALWAYS_INLINE
 static coroutine_handle from_promise(_Promise& __promise) _NOEXCEPT {

Added: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp?rev=304172=auto
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp
 Mon May 29 14:24:25 2017
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11
+// 
+
+// template 
+// struct coroutine_handle;
+
+// static coroutine_handle from_address(void*) noexcept
+
+// Test that `from_address` is explicitly ill-formed when called with a typed
+// pointer. The user cannot possibly have a typed pointer to the coroutine.
+// FIXME: This behavior is an extension, and should upstreamed into the TS or
+// the test removed if the TS changes are rejected.
+
+#include 
+#include 
+#include 
+
+namespace coro = std::experimental;
+
+int main()
+{
+  {
+using H = coro::coroutine_handle<>;
+// expected-error@experimental/coroutine:* 3 
{{coroutine_handle::from_address cannot be called with non-void pointers}}
+H::from_address((int*)nullptr); // expected-note {{requested here}}
+H::from_address((const void*)nullptr); // expected-note {{requested here}}
+H::from_address((const char*)nullptr); // expected-note {{requested here}}
+  }
+  {
+using H = coro::coroutine_handle;
+// expected-error@experimental/coroutine:* 1 {{static_assert failed 
"coroutine_handle::from_address cannot be used with pointers to 
the coroutine's promise type; use 'from_promise' instead"}}
+H::from_address((const char*)nullptr); // expected-note {{requested here}}
+// expected-error@experimental/coroutine:* 1 

Re: r303714 - [coroutines] Fix leak in CGCoroutine.cpp

2017-05-29 Thread David Blaikie via cfe-commits
Could you avoid creating the FinalBB unless it's needed rather than
creating it and then adding it so it can be removed? (or, if the creation
can't be avoided, maybe it's OK to 'delete FinalBB' here, rather than
adding it for it to be removed later?)

(also bracing seems off - could you run your changes through clang-format?
I'd expect '} else {' on the same line.

On Tue, May 23, 2017 at 6:54 PM Gor Nishanov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: gornishanov
> Date: Tue May 23 20:54:37 2017
> New Revision: 303714
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303714=rev
> Log:
> [coroutines] Fix leak in CGCoroutine.cpp
>
> FinalBB need to be emitted even when unused to make sure it is deleted
>
> Modified:
> cfe/trunk/lib/CodeGen/CGCoroutine.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=303714=303713=303714=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Tue May 23 20:54:37 2017
> @@ -430,6 +430,10 @@ void CodeGenFunction::EmitCoroutineBody(
>CurCoro.Data->CurrentAwaitKind = AwaitKind::Final;
>EmitStmt(S.getFinalSuspendStmt());
>  }
> +else {
> +  // We don't need FinalBB. Emit it to make sure the block is deleted.
> +  EmitBlock(FinalBB, /*IsFinished=*/true);
> +}
>}
>
>EmitBlock(RetBB);
>
>
> ___
> 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] D30909: [Analyzer] Finish taint propagation to derived symbols of tainted regions

2017-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

We've broken something:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5288/steps/check-clang%20asan/logs/stdio

I hope i fixed it in https://reviews.llvm.org/rL304170.


https://reviews.llvm.org/D30909



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


r304170 - [analyzer] Fix immutable map factory lifetime for partial taint.

2017-05-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon May 29 13:54:02 2017
New Revision: 304170

URL: http://llvm.org/viewvc/llvm-project?rev=304170=rev
Log:
[analyzer] Fix immutable map factory lifetime for partial taint.

This should fix the leaks found by asan buildbot in r304162.

Also don't store a reference to the factory with every map value,
which is the only difference between ImmutableMap and ImmutableMapRef.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=304170=304169=304170=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
Mon May 29 13:54:02 2017
@@ -44,8 +44,6 @@ typedef std::unique_ptr(*StoreManagerCreator)(
 ProgramStateManager &);
 typedef llvm::ImmutableMap TaintedSubRegions;
-typedef llvm::ImmutableMapRef
-  TaintedSubRegionsRef;
 
 
//===--===//
 // ProgramStateTrait - Traits used by the Generic Data Map of a ProgramState.
@@ -90,7 +88,6 @@ private:
   Store store;   // Maps a location to its current value.
   GenericDataMap   GDM;  // Custom data stored by a client of this class.
   unsigned refCount;
-  TaintedSubRegions::Factory TSRFactory;
 
   /// makeWithStore - Return a ProgramState with the same values as the current
   ///  state with the exception of using the specified Store.
@@ -468,6 +465,7 @@ private:
   std::unique_ptr   ConstraintMgr;
 
   ProgramState::GenericDataMap::Factory GDMFactory;
+  TaintedSubRegions::Factory TSRFactory;
 
   typedef llvm::DenseMap > 
GDMContextsTy;
   GDMContextsTy GDMContexts;

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h?rev=304170=304169=304170=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h 
Mon May 29 13:54:02 2017
@@ -39,7 +39,7 @@ template<> struct ProgramStateTrait 
DerivedSymTaintImpl;
+typedef llvm::ImmutableMap DerivedSymTaintImpl;
 template<> struct ProgramStateTrait
 :  public ProgramStatePartialTrait {
   static void *GDMIndex() { static int index; return  }

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=304170=304169=304170=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Mon May 29 13:54:02 2017
@@ -703,13 +703,12 @@ ProgramStateRef ProgramState::addPartial
   if (SubRegion == SubRegion->getBaseRegion())
 return addTaint(ParentSym, Kind);
 
-  TaintedSubRegionsRef TaintedSubRegions(0, TSRFactory.getTreeFactory());
-  if (const TaintedSubRegionsRef *SavedTaintedRegions =
-get(ParentSym))
-TaintedSubRegions = *SavedTaintedRegions;
+  const TaintedSubRegions *SavedRegs = get(ParentSym);
+  TaintedSubRegions Regs =
+  SavedRegs ? *SavedRegs : stateMgr->TSRFactory.getEmptyMap();
 
-  TaintedSubRegions = TaintedSubRegions.add(SubRegion, Kind);
-  ProgramStateRef NewState = set(ParentSym, 
TaintedSubRegions);
+  Regs = stateMgr->TSRFactory.add(Regs, SubRegion, Kind);
+  ProgramStateRef NewState = set(ParentSym, Regs);
   assert(NewState);
   return NewState;
 }
@@ -772,18 +771,16 @@ bool ProgramState::isTainted(SymbolRef S
   // If this is a SymbolDerived with the same parent symbol as another
   // tainted SymbolDerived and a region that's a sub-region of that tainted
   // symbol, it's also tainted.
-  if (const TaintedSubRegionsRef *SymRegions =
-get(SD->getParentSymbol())) {
+  if (const TaintedSubRegions *Regs =
+  get(SD->getParentSymbol())) {
 const TypedValueRegion *R = SD->getRegion();
-for (TaintedSubRegionsRef::iterator I = SymRegions->begin(),
-E = SymRegions->end();
- I != E; ++I) {
+for (auto I : *Regs) {
   // FIXME: The logic to identify tainted regions could be more
   // complete. For example, this would not currently identify
   // 

Re: r303934 - "*" => "+" to avoid matching on empty string.

2017-05-29 Thread David Blaikie via cfe-commits
Why would matching on an empty string be bad in this case?

On Thu, May 25, 2017 at 4:25 PM Richard Trieu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rtrieu
> Date: Thu May 25 18:25:36 2017
> New Revision: 303934
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303934=rev
> Log:
> "*" => "+" to avoid matching on empty string.
>
> Modified:
> cfe/trunk/test/Driver/baremetal.cpp
>
> Modified: cfe/trunk/test/Driver/baremetal.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/baremetal.cpp?rev=303934=303933=303934=diff
>
> ==
> --- cfe/trunk/test/Driver/baremetal.cpp (original)
> +++ cfe/trunk/test/Driver/baremetal.cpp Thu May 25 18:25:36 2017
> @@ -4,7 +4,7 @@
>  // RUN: -L some/directory/user/asked/for \
>  // RUN: --sysroot=%S/Inputs/baremetal_arm \
>  // RUN:   | FileCheck --check-prefix=CHECK-V6M-C %s
> -// CHECK-V6M-C:
> "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]*}}{{[/\\]+}}clang{{.*}}" "-cc1"
> "-triple" "thumbv6m-none--eabi"
> +// CHECK-V6M-C:
> "[[PREFIX_DIR:.*]]{{[/\\]+}}{{[^/^\\]+}}{{[/\\]+}}clang{{.*}}" "-cc1"
> "-triple" "thumbv6m-none--eabi"
>  // CHECK-V6M-C-SAME: "-resource-dir"
> "[[PREFIX_DIR]]{{[/\\]+}}lib{{[/\\]+}}clang{{[/\\]+}}[[VERSION:[^"]*]]"
>  // CHECK-V6M-C-SAME: "-isysroot" "[[SYSROOT:[^"]*]]"
>  // CHECK-V6M-C-SAME: "-internal-isystem"
> "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r304127 - IRGen: Add optnone attribute on function during O0

2017-05-29 Thread David Blaikie via cfe-commits
I'm assuming  most of these tests aren't actually testing for attributes -
perhaps it'd be better to remove their dependence on a particular attribute
list number so future changes to attributes don't require so many touches?

On Sun, May 28, 2017 at 10:38 PM Mehdi Amini via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: mehdi_amini
> Date: Mon May 29 00:38:20 2017
> New Revision: 304127
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304127=rev
> Log:
> IRGen: Add optnone attribute on function during O0
>
> Amongst other, this will help LTO to correctly handle/honor files
> compiled with O0, helping debugging failures.
> It also seems in line with how we handle other options, like how
> -fnoinline adds the appropriate attribute as well.
>
> Differential Revision: https://reviews.llvm.org/D28404
>
> Modified:
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
> cfe/trunk/test/CodeGen/aarch64-neon-3v.c
> cfe/trunk/test/CodeGen/aarch64-neon-across.c
> cfe/trunk/test/CodeGen/aarch64-neon-extract.c
> cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
> cfe/trunk/test/CodeGen/aarch64-neon-fma.c
> cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
> cfe/trunk/test/CodeGen/aarch64-neon-ldst-one.c
> cfe/trunk/test/CodeGen/aarch64-neon-misc.c
> cfe/trunk/test/CodeGen/aarch64-neon-perm.c
> cfe/trunk/test/CodeGen/aarch64-neon-scalar-copy.c
> cfe/trunk/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
> cfe/trunk/test/CodeGen/aarch64-neon-shifts.c
> cfe/trunk/test/CodeGen/aarch64-neon-tbl.c
> cfe/trunk/test/CodeGen/aarch64-neon-vcombine.c
> cfe/trunk/test/CodeGen/aarch64-neon-vget-hilo.c
> cfe/trunk/test/CodeGen/aarch64-neon-vget.c
> cfe/trunk/test/CodeGen/aarch64-poly128.c
> cfe/trunk/test/CodeGen/aarch64-poly64.c
> cfe/trunk/test/CodeGen/address-safety-attr-kasan.cpp
> cfe/trunk/test/CodeGen/address-safety-attr.cpp
> cfe/trunk/test/CodeGen/arm-crc32.c
> cfe/trunk/test/CodeGen/arm-neon-directed-rounding.c
> cfe/trunk/test/CodeGen/arm-neon-fma.c
> cfe/trunk/test/CodeGen/arm-neon-numeric-maxmin.c
> cfe/trunk/test/CodeGen/arm-neon-shifts.c
> cfe/trunk/test/CodeGen/arm-neon-vcvtX.c
> cfe/trunk/test/CodeGen/arm-neon-vget.c
> cfe/trunk/test/CodeGen/arm64-crc32.c
> cfe/trunk/test/CodeGen/arm64-lanes.c
> cfe/trunk/test/CodeGen/arm64_vcopy.c
> cfe/trunk/test/CodeGen/arm64_vdupq_n_f64.c
> cfe/trunk/test/CodeGen/attr-coldhot.c
> cfe/trunk/test/CodeGen/attr-naked.c
> cfe/trunk/test/CodeGen/builtins-arm-exclusive.c
> cfe/trunk/test/CodeGen/builtins-arm.c
> cfe/trunk/test/CodeGen/builtins-arm64.c
> cfe/trunk/test/CodeGen/noduplicate-cxx11-test.cpp
> cfe/trunk/test/CodeGen/pragma-weak.c
> cfe/trunk/test/CodeGen/unwind-attr.c
> cfe/trunk/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
> cfe/trunk/test/CodeGenCXX/apple-kext-no-staticinit-section.cpp
> cfe/trunk/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
> cfe/trunk/test/CodeGenCXX/optnone-templates.cpp
> cfe/trunk/test/CodeGenCXX/static-init-wasm.cpp
> cfe/trunk/test/CodeGenCXX/thunks.cpp
> cfe/trunk/test/CodeGenObjC/gnu-exceptions.m
> cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
> cfe/trunk/test/Driver/darwin-iphone-defaults.m
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=304127=304126=304127=diff
>
> ==
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon May 29 00:38:20 2017
> @@ -172,6 +172,8 @@ def disable_llvm_optzns : Flag<["-"], "d
>  def disable_lifetimemarkers : Flag<["-"], "disable-lifetime-markers">,
>HelpText<"Disable lifetime-markers emission even when optimizations are
> "
> "enabled">;
> +def disable_O0_optnone : Flag<["-"], "disable-O0-optnone">,
> +  HelpText<"Disable adding the optnone attribute to functions at O0">;
>  def disable_red_zone : Flag<["-"], "disable-red-zone">,
>HelpText<"Do not emit code that uses the red zone.">;
>  def dwarf_column_info : Flag<["-"], "dwarf-column-info">,
>
> Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=304127=304126=304127=diff
>
> ==
> --- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
> +++ 

r304167 - Unbreak long test after r304127.

2017-05-29 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon May 29 13:11:11 2017
New Revision: 304167

URL: http://llvm.org/viewvc/llvm-project?rev=304167=rev
Log:
Unbreak long test after r304127.

Modified:
cfe/trunk/test/CodeGen/arm_neon_intrinsics.c

Modified: cfe/trunk/test/CodeGen/arm_neon_intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm_neon_intrinsics.c?rev=304167=304166=304167=diff
==
--- cfe/trunk/test/CodeGen/arm_neon_intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/arm_neon_intrinsics.c Mon May 29 13:11:11 2017
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple thumbv7s-apple-darwin -target-abi apcs-gnu\
-// RUN:  -target-cpu swift -fallow-half-arguments-and-returns -ffreestanding 
-emit-llvm -o - %s \
+// RUN:  -target-cpu swift -fallow-half-arguments-and-returns -ffreestanding \
+// RUN:  -disable-O0-optnone -emit-llvm -o - %s \
 // RUN:  | opt -S -mem2reg | FileCheck %s
 
 // REQUIRES: long-tests


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


[PATCH] D33437: Emit available_externally vtables opportunistically

2017-05-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: lib/CodeGen/CodeGenModule.cpp:1383-1385
+  if (!OpportunisticVTables.empty())
+assert(shouldOpportunisticallyEmitVTables() &&
+   "Only emit opportunistic vtables with optimizations");

Perhaps this:
  assert(OpportunisticVTables.empty() || shouldOpportunisticallyEmitVTables() 
&& ... )

(it's a bit odd to have a condition that only goes to an assert - rather than 
having both conditions inside the assertion)


https://reviews.llvm.org/D33437



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


[PATCH] D33437: Emit available_externally vtables opportunistically

2017-05-29 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 100623.
Prazek marked an inline comment as done.
Prazek added a comment.

- Final changes


https://reviews.llvm.org/D33437

Files:
  include/clang/AST/VTableBuilder.h
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/vtable-available-externally.cpp
  test/CodeGenCXX/vtable-linkage.cpp

Index: test/CodeGenCXX/vtable-linkage.cpp
===
--- test/CodeGenCXX/vtable-linkage.cpp
+++ test/CodeGenCXX/vtable-linkage.cpp
@@ -145,12 +145,14 @@
 // F is an explicit template instantiation declaration without a
 // key function, so its vtable should have external linkage.
 // CHECK-DAG: @_ZTV1FIiE = external unnamed_addr constant
-// CHECK-OPT-DAG: @_ZTV1FIiE = external unnamed_addr constant
+// CHECK-OPT-DAG: @_ZTV1FIiE = available_externally unnamed_addr constant
 
 // E is an explicit template instantiation declaration. It has a
 // key function is not instantiated, so we know that vtable definition
 // will be generated in TU where key function will be defined
-// so we can mark it as available_externally (only with optimizations)
+// so we can mark it as external (without optimizations) and
+// available_externally (with optimizations) because all of the inline
+// virtual functions have been emitted.
 // CHECK-DAG: @_ZTV1EIiE = external unnamed_addr constant
 // CHECK-OPT-DAG: @_ZTV1EIiE = available_externally unnamed_addr constant
 
Index: test/CodeGenCXX/vtable-available-externally.cpp
===
--- test/CodeGenCXX/vtable-available-externally.cpp
+++ test/CodeGenCXX/vtable-available-externally.cpp
@@ -12,6 +12,7 @@
 // RUN: FileCheck --check-prefix=CHECK-TEST14 %s < %t.opt
 // RUN: FileCheck --check-prefix=CHECK-TEST15 %s < %t.opt
 // RUN: FileCheck --check-prefix=CHECK-TEST16 %s < %t.opt
+// RUN: FileCheck --check-prefix=CHECK-TEST17 %s < %t.opt
 
 #include 
 
@@ -274,8 +275,8 @@
   virtual D& operator=(const D&);
 };
 
-// Cannot emit B's vtable available_externally, because we cannot create
-// a reference to the inline virtual B::operator= function.
+// Cannot emit D's vtable available_externally, because we cannot create
+// a reference to the inline virtual D::operator= function.
 // CHECK-TEST11: @_ZTVN6Test111DE = external unnamed_addr constant
 struct D : C {
   virtual void key();
@@ -391,3 +392,30 @@
 }
 }
 
+namespace Test17 {
+// This test checks if we emit vtables opportunistically.
+// CHECK-TEST17-DAG: @_ZTVN6Test171AE = available_externally
+// CHECK-TEST17-DAG: @_ZTVN6Test171BE = external
+
+struct A {
+  virtual void key();
+  virtual void bar() {}
+};
+
+// We won't gonna use deleting destructor for this type, which will disallow
+// emitting vtable as available_externally
+struct B {
+  virtual void key();
+  virtual ~B() {}
+};
+
+void testcaseA() {
+  A a;
+  a.bar(); // this forces to emit definition of bar
+}
+
+void testcaseB() {
+  B b; // This only forces emitting of complete object destructor
+}
+
+} // namespace Test17
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3756,6 +3756,9 @@
   if (llvm::GlobalVariable *GV = CGM.getModule().getNamedGlobal(MangledName))
 return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
 
+  // Note for the future: If we would ever like to do deferred emission of
+  // RTTI, check if emitting vtables opportunistically need any adjustment.
+
   // Compute the fields for the TypeDescriptor.
   SmallString<256> TypeInfoString;
   {
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -366,20 +366,30 @@
   void emitCXXStructor(const CXXMethodDecl *MD, StructorType Type) override;
 
  private:
-   bool hasAnyVirtualInlineFunction(const CXXRecordDecl *RD) const {
-const auto  =
-CGM.getItaniumVTableContext().getVTableLayout(RD);
-
-for (const auto  : VtableLayout.vtable_components()) {
-  // Skip empty slot.
-  if (!VtableComponent.isUsedFunctionPointerKind())
-continue;
-
-  const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
-  if (Method->getCanonicalDecl()->isInlined())
-return true;
-}
-return false;
+   bool hasAnyUnusedVirtualInlineFunction(const CXXRecordDecl *RD) const {
+ const auto  =
+ CGM.getItaniumVTableContext().getVTableLayout(RD);
+
+ for (const auto  : VtableLayout.vtable_components()) {
+   // Skip empty slot.
+   if (!VtableComponent.isUsedFunctionPointerKind())
+ continue;
+
+   const CXXMethodDecl *Method = VtableComponent.getFunctionDecl();
+   if (!Method->getCanonicalDecl()->isInlined())
+

[PATCH] D33437: Emit available_externally vtables opportunistically

2017-05-29 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek marked 4 inline comments as done.
Prazek added inline comments.



Comment at: include/clang/AST/VTableBuilder.h:160
+   "GlobalDecl can be created only from virtual function");
+if (getKind() == CK_FunctionPointer)
+  return GlobalDecl(getFunctionDecl());

rjmccall wrote:
> Prazek wrote:
> > rjmccall wrote:
> > > Please use an exhaustive switch.  You can put llvm_unreachable in the 
> > > other cases.
> > Should I implement this for RTTI fields? Or maybe leave a fixme comment 
> > that it could also work for some other fields in vtable, but is not 
> > currently used?
> I think your precondition of isUsedFunctionPointerKind() is fine, you don't 
> need to handle RTTI in this function.
> 
> This does raise the interesting question, though, of whether this approach is 
> safe for lazily-emitted RTTI.  I guess it currently works because IRGen 
> doesn't use the normal deferred-emission mechanism for RTTI objects, so if 
> the RTTI object is lazily-emitted, we'll just eagerly emit it instead of 
> potentially ending up with an illegal reference to external RTTI.  You should 
> add a comment to the appropriate place in CGRTTI (i.e. where we fill in the 
> global definition) saying that this optimization may need adjustment if we 
> ever switch to using deferred emission for some reason.
I couldn't find CGRTTI, so I added comment in Itanium and Microsoft ABI where 
we create RTTI fields, but maybe the CodeGenModule::GetAddrOfRTTIDescriptor 
would be a better place instead?

I also added small note to the EmitVTablesOpportunistically about this.


https://reviews.llvm.org/D33437



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


[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

2017-05-29 Thread Will Dietz via Phabricator via cfe-commits
dtzWill added a comment.

LGTM!

I've built quite a bit with this (ground-up Linux distribution) which attests 
to it being fairly robust (no crashing or new errors not experienced with 
unpatched clang) and the bugs found so far are all true positives (few of which 
were caught and reported last time around).

For what it's worth, this needs to be adjusted slightly to work with latest 
Clang.  Changes were straightforward as I recall, updated patch attached.

F3381492: D33305.diff 


https://reviews.llvm.org/D33305



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


[PATCH] D33437: Emit available_externally vtables opportunistically

2017-05-29 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek marked an inline comment as done.
Prazek added inline comments.



Comment at: include/clang/AST/VTableBuilder.h:169
+  return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Deleting);
+default:
+  llvm_unreachable("Only function pointers kinds");

rjmccall wrote:
> By "exhaustive" I mean that you should list out all the cases instead of 
> using default.  It means that someone who adds a new kind of v-table entry 
> will get alerted to fix this switch.  There's only five other cases, it's not 
> too bad.
Oh right, that make sense


https://reviews.llvm.org/D33437



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


[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-05-29 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 100621.
Prazek added a comment.

Add test


https://reviews.llvm.org/D31830

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp

Index: test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- test/CodeGenCXX/strict-vtable-pointers.cpp
+++ test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -disable-llvm-passes -O2 -emit-llvm -o %t.ll
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -std=c++11 -disable-llvm-passes -O2 -emit-llvm -o %t.ll
 // RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
@@ -180,6 +180,112 @@
 // CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
 // CHECK-CTORS-LABEL: {{^}}}
 
+struct A {
+  virtual void foo();
+};
+struct B : A {
+  virtual void foo();
+};
+
+union U {
+  A a;
+  B b;
+};
+
+void changeToB(U *u);
+void changeToA(U *u);
+
+void g2(A *a) {
+  a->foo();
+}
+// We have to guard access to union fields with invariant.group, because
+// it is very easy to skip the barrier with unions. In this example the inlined
+// g2 will produce loads with the same !invariant.group metadata, and
+// u->a and u->b would use the same pointer.
+// CHECK-NEW-LABEL: define void @_Z14UnionsBarriersP1U
+void UnionsBarriers(U *u) {
+  // CHECK-NEW: call void @_Z9changeToBP1U(
+  changeToB(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
+  g2(>b);
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  changeToA(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // call void @_Z2g2P1A(%struct.A* %a)
+  g2(>a);
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+}
+
+struct HoldingVirtuals {
+  A a;
+};
+
+struct Empty {};
+struct AnotherEmpty {
+  Empty e;
+};
+union NoVptrs {
+  int a;
+  AnotherEmpty empty;
+};
+void take(AnotherEmpty &);
+
+// CHECK-NEW-LABEL: noBarriers
+void noBarriers(NoVptrs ) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  noVptrs.a += 42;
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR12AnotherEmpty(
+  take(noVptrs.empty);
+}
+
+union U2 {
+  HoldingVirtuals h;
+  int z;
+};
+void take(HoldingVirtuals &);
+
+// CHECK-NEW-LABEL: define void @_Z15UnionsBarriers2R2U2
+void UnionsBarriers2(U2 ) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR15HoldingVirtuals(
+  take(u.h);
+}
+
+struct VirtualInBase : HoldingVirtuals, Empty {
+};
+
+struct VirtualInVBase : virtual Empty, HoldingVirtuals {
+};
+
+union U3 {
+  VirtualInBase v1;
+  VirtualInBase v2;
+  int z;
+};
+
+void take(VirtualInBase &);
+void take(VirtualInVBase &);
+
+void UnionsBarrier3(U3 ) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR13VirtualInBase(
+  take(u.v1);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR13VirtualInBase(
+  take(u.v2);
+}
+
+
+
 
 /** DTORS **/
 // CHECK-DTORS-LABEL: define linkonce_odr void @_ZN10StaticBaseD2Ev(
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3528,6 +3528,25 @@
   return CGF.Builder.CreateStructGEP(base, idx, offset, field->getName());
 }
 
+static bool hasAnyVptr(const QualType Type, const ASTContext ) {
+  const auto *RD = Type.getTypePtr()->getAsCXXRecordDecl();
+  if (!RD)
+return false;
+
+  if (RD->isDynamicClass())
+return true;
+
+  for (const auto  : RD->bases())
+if (hasAnyVptr(Base.getType(), Context))
+  return true;
+
+  for (const FieldDecl *Field : RD->fields())
+if (hasAnyVptr(Field->getType(), Context))
+  return true;
+
+  return false;
+}
+
 LValue CodeGenFunction::EmitLValueForField(LValue base,
const FieldDecl *field) {
   LValueBaseInfo BaseInfo = base.getBaseInfo();
@@ -3569,6 +3588,14 @@
 assert(!type->isReferenceType() && "union has reference member");
 // TODO: handle path-aware TBAA for union.
 TBAAPath = false;
+
+const auto FieldType = field->getType();
+if (CGM.getCodeGenOpts().StrictVTablePointers &&
+hasAnyVptr(FieldType, getContext()))
+  // Because unions can easily skip invariant.barriers, we need to add
+  // a barrier every time CXXRecord field with vptr is referenced.
+  addr = Address(Builder.CreateInvariantGroupBarrier(addr.getPointer()),
+   

[PATCH] D33648: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element

2017-05-29 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand accepted this revision.
uweigand added a comment.
This revision is now accepted and ready to land.

Yes, this works for me now.  Thanks!


https://reviews.llvm.org/D33648



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


[PATCH] D30909: [Analyzer] Finish taint propagation to derived symbols of tainted regions

2017-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ closed this revision.
NoQ added a comment.

Uhm, messed up the phabricator link in https://reviews.llvm.org/rL304162, which 
should have been pointing here but points to https://reviews.llvm.org/D28445 
instead.


https://reviews.llvm.org/D30909



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


[PATCH] D28445: [Analyzer] Extend taint propagation and checking

2017-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Uhm, messed up the phabricator link in https://reviews.llvm.org/rL304162, which 
should have been pointing to https://reviews.llvm.org/D30909 but points here 
instead.


Repository:
  rL LLVM

https://reviews.llvm.org/D28445



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


r304162 - [analyzer] Support partially tainted records.

2017-05-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon May 29 10:42:56 2017
New Revision: 304162

URL: http://llvm.org/viewvc/llvm-project?rev=304162=rev
Log:
[analyzer] Support partially tainted records.

The analyzer's taint analysis can now reason about structures or arrays
originating from taint sources in which only certain sections are tainted.

In particular, it also benefits modeling functions like read(), which may
read tainted data into a section of a structure, but RegionStore is incapable of
expressing the fact that the rest of the structure remains intact, even if we
try to model read() directly.

Patch by Vlad Tsyrklevich!

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/test/Analysis/taint-generic.c

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=304162=304161=304162=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
Mon May 29 10:42:56 2017
@@ -43,6 +43,9 @@ typedef std::unique_ptr(*StoreManagerCreator)(
 ProgramStateManager &);
+typedef llvm::ImmutableMap TaintedSubRegions;
+typedef llvm::ImmutableMapRef
+  TaintedSubRegionsRef;
 
 
//===--===//
 // ProgramStateTrait - Traits used by the Generic Data Map of a ProgramState.
@@ -87,6 +90,7 @@ private:
   Store store;   // Maps a location to its current value.
   GenericDataMap   GDM;  // Custom data stored by a client of this class.
   unsigned refCount;
+  TaintedSubRegions::Factory TSRFactory;
 
   /// makeWithStore - Return a ProgramState with the same values as the current
   ///  state with the exception of using the specified Store.
@@ -343,6 +347,9 @@ public:
   ProgramStateRef addTaint(const Stmt *S, const LocationContext *LCtx,
TaintTagType Kind = TaintTagGeneric) const;
 
+  /// Create a new state in which the value is marked as tainted.
+  ProgramStateRef addTaint(SVal V, TaintTagType Kind = TaintTagGeneric) const;
+
   /// Create a new state in which the symbol is marked as tainted.
   ProgramStateRef addTaint(SymbolRef S,
TaintTagType Kind = TaintTagGeneric) const;
@@ -351,6 +358,14 @@ public:
   ProgramStateRef addTaint(const MemRegion *R,
TaintTagType Kind = TaintTagGeneric) const;
 
+  /// Create a new state in a which a sub-region of a given symbol is tainted.
+  /// This might be necessary when referring to regions that can not have an
+  /// individual symbol, e.g. if they are represented by the default binding of
+  /// a LazyCompoundVal.
+  ProgramStateRef addPartialTaint(SymbolRef ParentSym,
+  const SubRegion *SubRegion,
+  TaintTagType Kind = TaintTagGeneric) const;
+
   /// Check if the statement is tainted in the current state.
   bool isTainted(const Stmt *S, const LocationContext *LCtx,
  TaintTagType Kind = TaintTagGeneric) const;

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h?rev=304162=304161=304162=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h 
Mon May 29 10:42:56 2017
@@ -35,6 +35,16 @@ template<> struct ProgramStateTrait 
DerivedSymTaintImpl;
+template<> struct ProgramStateTrait
+:  public ProgramStatePartialTrait {
+  static void *GDMIndex() { static int index; return  }
+};
+
 class TaintManager {
 
   TaintManager() {}

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp?rev=304162=304161=304162=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp Mon May 29 
10:42:56 2017
@@ -65,21 +65,8 @@ private:
   /// and thus, is tainted.
   static bool isStdin(const Expr *E, CheckerContext );
 
-  /// This is called from 

[PATCH] D32592: [Analyzer] Iterator Checker - Part 1: Minimal Checker for a Simple Test Case

2017-05-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304160: [analyzer] Initial commit for the upcoming 
refactoring of the IteratorChecker. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D32592?vs=100239=100616#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32592

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp
  cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
  cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp
  cfe/trunk/test/Analysis/iterator-past-end.cpp
  cfe/trunk/test/Analysis/iterator-range.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -39,7 +39,7 @@
   GenericTaintChecker.cpp
   GTestChecker.cpp
   IdenticalExprChecker.cpp
-  IteratorPastEndChecker.cpp
+  IteratorChecker.cpp
   IvarInvalidationChecker.cpp
   LLVMConventionsChecker.cpp
   LocalizationChecker.cpp
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -0,0 +1,833 @@
+//===-- IteratorChecker.cpp ---*- C++ -*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a checker for using iterators outside their range (past end). Usage
+// means here dereferencing, incrementing etc.
+//
+//===--===//
+//
+// In the code, iterator can be represented as a:
+// * type-I: typedef-ed pointer. Operations over such iterator, such as
+//   comparisons or increments, are modeled straightforwardly by the
+//   analyzer.
+// * type-II: structure with its method bodies available.  Operations over such
+//iterator are inlined by the analyzer, and results of modeling
+//these operations are exposing implementation details of the
+//iterators, which is not necessarily helping.
+// * type-III: completely opaque structure. Operations over such iterator are
+// modeled conservatively, producing conjured symbols everywhere.
+//
+// To handle all these types in a common way we introduce a structure called
+// IteratorPosition which is an abstraction of the position the iterator
+// represents using symbolic expressions. The checker handles all the
+// operations on this structure.
+//
+// Additionally, depending on the circumstances, operators of types II and III
+// can be represented as:
+// * type-IIa, type-IIIa: conjured structure symbols - when returned by value
+//from conservatively evaluated methods such as
+//`.begin()`.
+// * type-IIb, type-IIIb: memory regions of iterator-typed objects, such as
+//variables or temporaries, when the iterator object is
+//currently treated as an lvalue.
+// * type-IIc, type-IIIc: compound values of iterator-typed objects, when the
+//iterator object is treated as an rvalue taken of a
+//particular lvalue, eg. a copy of "type-a" iterator
+//object, or an iterator that existed before the
+//analysis has started.
+//
+// To handle any of these three different representations stored in an SVal we
+// use setter and getters functions which separate the three cases. To store
+// them we use a pointer union of symbol and memory region.
+//
+// The checker works the following way: We record the past-end iterator for
+// all containers whenever their `.end()` is called. Since the Constraint
+// Manager cannot handle SVals we need to take over its role. We post-check
+// equality and non-equality comparisons and propagate the position of the
+// iterator to the other side of the comparison if it is past-end and we are in
+// the 'equal' branch (true-branch for `==` and false-branch for `!=`).
+//
+// In case of type-I or type-II iterators we get a concrete integer as a result
+// of the comparison (1 or 0) but in case of type-III we only get a Symbol. In
+// this latter case we record the symbol and reload it in evalAssume() and do
+// the propagation there. We also handle (maybe double) negated comparisons
+// which are represented in the form 

r304160 - [analyzer] Initial commit for the upcoming refactoring of the IteratorChecker.

2017-05-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon May 29 10:03:20 2017
New Revision: 304160

URL: http://llvm.org/viewvc/llvm-project?rev=304160=rev
Log:
[analyzer] Initial commit for the upcoming refactoring of the IteratorChecker.

The new checker currently contains the very core infrastructure for tracking
the state of iterator-type objects in the analyzer: relating iterators to
their containers, tracking symbolic begin and end iterator values for
containers, and solving simple equality-type constraints over iterators.
A single specific check over this infrastructure is capable of finding usage of
out-of-range iterators in some simple cases.

Patch by Ádám Balogh!

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

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
cfe/trunk/test/Analysis/iterator-range.cpp
Removed:
cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp
cfe/trunk/test/Analysis/iterator-past-end.cpp
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/trunk/test/Analysis/diagnostics/explicit-suppression.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=304160=304159=304160=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon May 29 
10:03:20 2017
@@ -279,15 +279,15 @@ def VirtualCallChecker : Checker<"Virtua
 
 let ParentPackage = CplusplusAlpha in {
 
+def IteratorRangeChecker : Checker<"IteratorRange">,
+  HelpText<"Check for iterators used outside their valid ranges">,
+  DescFile<"IteratorChecker.cpp">;
+
 def MisusedMovedObjectChecker: Checker<"MisusedMovedObject">,
  HelpText<"Method calls on a moved-from object and copying a moved-from "
   "object will be reported">,
  DescFile<"MisusedMovedObjectChecker.cpp">;
 
-def IteratorPastEndChecker : Checker<"IteratorPastEnd">,
-  HelpText<"Check iterators used past end">,
-  DescFile<"IteratorPastEndChecker.cpp">;
-
 } // end: "alpha.cplusplus"
 
 

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=304160=304159=304160=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon May 29 10:03:20 
2017
@@ -39,7 +39,7 @@ add_clang_library(clangStaticAnalyzerChe
   GenericTaintChecker.cpp
   GTestChecker.cpp
   IdenticalExprChecker.cpp
-  IteratorPastEndChecker.cpp
+  IteratorChecker.cpp
   IvarInvalidationChecker.cpp
   LLVMConventionsChecker.cpp
   LocalizationChecker.cpp

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp?rev=304160=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp (added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp Mon May 29 
10:03:20 2017
@@ -0,0 +1,833 @@
+//===-- IteratorChecker.cpp ---*- C++ 
-*--//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Defines a checker for using iterators outside their range (past end). Usage
+// means here dereferencing, incrementing etc.
+//
+//===--===//
+//
+// In the code, iterator can be represented as a:
+// * type-I: typedef-ed pointer. Operations over such iterator, such as
+//   comparisons or increments, are modeled straightforwardly by the
+//   analyzer.
+// * type-II: structure with its method bodies available.  Operations over such
+//iterator are inlined by the analyzer, and results of modeling
+//these operations are exposing implementation details of the
+//iterators, which is not necessarily helping.
+// * type-III: completely opaque structure. Operations over such iterator are
+// modeled conservatively, producing conjured symbols everywhere.
+//
+// To handle all these types in a common way we introduce a structure called
+// IteratorPosition which is an abstraction of the position the iterator
+// represents using symbolic expressions. The checker handles all the
+// operations on this structure.
+//
+// 

[PATCH] D32449: Modifying PthreadLockChecker.cpp to reduce false positives.

2017-05-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304159: [analyzer] PthreadLockChecker: model failed 
pthread_mutex_destroy() calls. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D32449?vs=99970=100615#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32449

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
  cfe/trunk/test/Analysis/pthreadlock.c

Index: cfe/trunk/test/Analysis/pthreadlock.c
===
--- cfe/trunk/test/Analysis/pthreadlock.c
+++ cfe/trunk/test/Analysis/pthreadlock.c
@@ -176,6 +176,42 @@
   pthread_mutex_unlock(pmtx);  // no-warning
 }
 
+void ok23(void) {
+  if (pthread_mutex_destroy() != 0) // no-warning
+pthread_mutex_destroy();// no-warning
+}
+
+void ok24(void) {
+  if (pthread_mutex_destroy() != 0) // no-warning
+pthread_mutex_lock();   // no-warning
+}
+
+void ok25(void) {
+  if (pthread_mutex_destroy() != 0) // no-warning
+pthread_mutex_unlock(); // no-warning
+}
+
+void ok26(void) {
+  pthread_mutex_unlock();   // no-warning
+  if (pthread_mutex_destroy() != 0) // no-warning
+pthread_mutex_lock();   // no-warning
+}
+
+void ok27(void) {
+  pthread_mutex_unlock();   // no-warning
+  if (pthread_mutex_destroy() != 0) // no-warning
+pthread_mutex_lock();   // no-warning
+  else
+pthread_mutex_init(, NULL); // no-warning
+}
+
+void ok28(void) {
+  if (pthread_mutex_destroy() != 0) { // no-warning
+pthread_mutex_lock(); // no-warning
+pthread_mutex_unlock();   // no-warning
+pthread_mutex_destroy();  // no-warning
+  }
+}
 
 void
 bad1(void)
@@ -392,3 +428,46 @@
 	pthread_mutex_unlock();		// no-warning
 	pthread_mutex_init(, NULL);	// expected-warning{{This lock has already been initialized}}
 }
+
+void bad27(void) {
+  pthread_mutex_unlock();// no-warning
+  int ret = pthread_mutex_destroy(); // no-warning
+  if (ret != 0)   // no-warning
+pthread_mutex_lock();// no-warning
+  else
+pthread_mutex_unlock(); // expected-warning{{This lock has already been destroyed}}
+}
+
+void bad28(void) {
+  pthread_mutex_unlock();// no-warning
+  int ret = pthread_mutex_destroy(); // no-warning
+  if (ret != 0)   // no-warning
+pthread_mutex_lock();// no-warning
+  else
+pthread_mutex_lock(); // expected-warning{{This lock has already been destroyed}}
+}
+
+void bad29(void) {
+  pthread_mutex_lock(); // no-warning
+  pthread_mutex_unlock();   // no-warning
+  if (pthread_mutex_destroy() != 0) // no-warning
+pthread_mutex_init(, NULL); // expected-warning{{This lock has already been initialized}}
+  else
+pthread_mutex_init(, NULL); // no-warning
+}
+
+void bad30(void) {
+  pthread_mutex_lock(); // no-warning
+  pthread_mutex_unlock();   // no-warning
+  if (pthread_mutex_destroy() != 0) // no-warning
+pthread_mutex_init(, NULL); // expected-warning{{This lock has already been initialized}}
+  else
+pthread_mutex_destroy(); // expected-warning{{This lock has already been destroyed}}
+}
+
+void bad31(void) {
+  int ret = pthread_mutex_destroy(); // no-warning
+  pthread_mutex_lock();  // expected-warning{{This lock has already been destroyed}}
+  if (ret != 0)
+pthread_mutex_lock();
+}
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -25,30 +25,49 @@
 namespace {
 
 struct LockState {
-  enum Kind { Destroyed, Locked, Unlocked } K;
+  enum Kind {
+Destroyed,
+Locked,
+Unlocked,
+UntouchedAndPossiblyDestroyed,
+UnlockedAndPossiblyDestroyed
+  } K;
 
 private:
   LockState(Kind K) : K(K) {}
 
 public:
   static LockState getLocked() { return LockState(Locked); }
   static LockState getUnlocked() { return LockState(Unlocked); }
   static LockState getDestroyed() { return LockState(Destroyed); }
+  static LockState getUntouchedAndPossiblyDestroyed() {
+return LockState(UntouchedAndPossiblyDestroyed);
+  }
+  static LockState getUnlockedAndPossiblyDestroyed() {
+return LockState(UnlockedAndPossiblyDestroyed);
+  }
 
   bool operator==(const LockState ) const {
 return K == X.K;
   }
 
   bool isLocked() const { return K == Locked; }
   bool isUnlocked() const { return K == Unlocked; }
   bool isDestroyed() const { return K == Destroyed; }
+  bool isUntouchedAndPossiblyDestroyed() const {
+return K == UntouchedAndPossiblyDestroyed;
+  }
+  bool isUnlockedAndPossiblyDestroyed() const {
+return K == UnlockedAndPossiblyDestroyed;
+  }
 
   void Profile(llvm::FoldingSetNodeID ) const {
 

r304159 - [analyzer] PthreadLockChecker: model failed pthread_mutex_destroy() calls.

2017-05-29 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Mon May 29 09:51:39 2017
New Revision: 304159

URL: http://llvm.org/viewvc/llvm-project?rev=304159=rev
Log:
[analyzer] PthreadLockChecker: model failed pthread_mutex_destroy() calls.

pthread_mutex_destroy() may fail, returning a non-zero error number, and
keeping the mutex untouched. The mutex can be used on the execution branch
that follows such failure, so the analyzer shouldn't warn on using
a mutex that was previously destroyed, when in fact the destroy call has failed.

Patch by Malhar Thakkar!

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
cfe/trunk/test/Analysis/pthreadlock.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp?rev=304159=304158=304159=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp Mon May 29 
09:51:39 2017
@@ -25,7 +25,13 @@ using namespace ento;
 namespace {
 
 struct LockState {
-  enum Kind { Destroyed, Locked, Unlocked } K;
+  enum Kind {
+Destroyed,
+Locked,
+Unlocked,
+UntouchedAndPossiblyDestroyed,
+UnlockedAndPossiblyDestroyed
+  } K;
 
 private:
   LockState(Kind K) : K(K) {}
@@ -34,6 +40,12 @@ public:
   static LockState getLocked() { return LockState(Locked); }
   static LockState getUnlocked() { return LockState(Unlocked); }
   static LockState getDestroyed() { return LockState(Destroyed); }
+  static LockState getUntouchedAndPossiblyDestroyed() {
+return LockState(UntouchedAndPossiblyDestroyed);
+  }
+  static LockState getUnlockedAndPossiblyDestroyed() {
+return LockState(UnlockedAndPossiblyDestroyed);
+  }
 
   bool operator==(const LockState ) const {
 return K == X.K;
@@ -42,13 +54,20 @@ public:
   bool isLocked() const { return K == Locked; }
   bool isUnlocked() const { return K == Unlocked; }
   bool isDestroyed() const { return K == Destroyed; }
+  bool isUntouchedAndPossiblyDestroyed() const {
+return K == UntouchedAndPossiblyDestroyed;
+  }
+  bool isUnlockedAndPossiblyDestroyed() const {
+return K == UnlockedAndPossiblyDestroyed;
+  }
 
   void Profile(llvm::FoldingSetNodeID ) const {
 ID.AddInteger(K);
   }
 };
 
-class PthreadLockChecker : public Checker< check::PostStmt > {
+class PthreadLockChecker
+: public Checker {
   mutable std::unique_ptr BT_doublelock;
   mutable std::unique_ptr BT_doubleunlock;
   mutable std::unique_ptr BT_destroylock;
@@ -61,22 +80,31 @@ class PthreadLockChecker : public Checke
   };
 public:
   void checkPostStmt(const CallExpr *CE, CheckerContext ) const;
+  void checkDeadSymbols(SymbolReaper , CheckerContext ) const;
 
   void AcquireLock(CheckerContext , const CallExpr *CE, SVal lock,
bool isTryLock, enum LockingSemantics semantics) const;
 
   void ReleaseLock(CheckerContext , const CallExpr *CE, SVal lock) const;
-  void DestroyLock(CheckerContext , const CallExpr *CE, SVal Lock) const;
+  void DestroyLock(CheckerContext , const CallExpr *CE, SVal Lock,
+   enum LockingSemantics semantics) const;
   void InitLock(CheckerContext , const CallExpr *CE, SVal Lock) const;
   void reportUseDestroyedBug(CheckerContext , const CallExpr *CE) const;
+  ProgramStateRef resolvePossiblyDestroyedMutex(ProgramStateRef state,
+const MemRegion *lockR,
+const SymbolRef *sym) const;
 };
 } // end anonymous namespace
 
-// GDM Entry for tracking lock state.
+// A stack of locks for tracking lock-unlock order.
 REGISTER_LIST_WITH_PROGRAMSTATE(LockSet, const MemRegion *)
 
+// An entry for tracking lock states.
 REGISTER_MAP_WITH_PROGRAMSTATE(LockMap, const MemRegion *, LockState)
 
+// Return values for unresolved calls to pthread_mutex_destroy().
+REGISTER_MAP_WITH_PROGRAMSTATE(DestroyRetVal, const MemRegion *, SymbolRef)
+
 void PthreadLockChecker::checkPostStmt(const CallExpr *CE,
CheckerContext ) const {
   ProgramStateRef state = C.getState();
@@ -113,13 +141,49 @@ void PthreadLockChecker::checkPostStmt(c
FName == "lck_mtx_unlock" ||
FName == "lck_rw_done")
 ReleaseLock(C, CE, state->getSVal(CE->getArg(0), LCtx));
-  else if (FName == "pthread_mutex_destroy" ||
-   FName == "lck_mtx_destroy")
-DestroyLock(C, CE, state->getSVal(CE->getArg(0), LCtx));
+  else if (FName == "pthread_mutex_destroy")
+DestroyLock(C, CE, state->getSVal(CE->getArg(0), LCtx), PthreadSemantics);
+  else if (FName == "lck_mtx_destroy")
+DestroyLock(C, CE, state->getSVal(CE->getArg(0), LCtx), XNUSemantics);
   else if (FName == "pthread_mutex_init")
 

[PATCH] D30909: [Analyzer] Finish taint propagation to derived symbols of tainted regions

2017-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

I'll land this. Thanks again for working on all that stuff!


https://reviews.llvm.org/D30909



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


[clang-tools-extra] r304154 - [clang-tidy] Use getLocalOrGlobal for the StrictMode option

2017-05-29 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon May 29 08:59:27 2017
New Revision: 304154

URL: http://llvm.org/viewvc/llvm-project?rev=304154=rev
Log:
[clang-tidy] Use getLocalOrGlobal for the StrictMode option

Modified:
clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp

clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp?rev=304154=304153=304154=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/SuspiciousEnumUsageCheck.cpp Mon 
May 29 08:59:27 2017
@@ -108,7 +108,8 @@ static bool isPossiblyBitMask(const Enum
 
 SuspiciousEnumUsageCheck::SuspiciousEnumUsageCheck(StringRef Name,
ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context), StrictMode(Options.get("StrictMode", 0)) 
{}
+: ClangTidyCheck(Name, Context),
+  StrictMode(Options.getLocalOrGlobal("StrictMode", 0)) {}
 
 void SuspiciousEnumUsageCheck::storeOptions(ClangTidyOptions::OptionMap ) 
{
   Options.store(Opts, "StrictMode", StrictMode);

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp?rev=304154=304153=304154=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/InefficientStringConcatenationCheck.cpp
 Mon May 29 08:59:27 2017
@@ -24,7 +24,8 @@ void InefficientStringConcatenationCheck
 
 InefficientStringConcatenationCheck::InefficientStringConcatenationCheck(
 StringRef Name, ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context), StrictMode(Options.get("StrictMode", 0)) 
{}
+: ClangTidyCheck(Name, Context),
+  StrictMode(Options.getLocalOrGlobal("StrictMode", 0)) {}
 
 void InefficientStringConcatenationCheck::registerMatchers(
 MatchFinder *Finder) {


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


[PATCH] D33648: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element

2017-05-29 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
Herald added a subscriber: yaxunl.

This is the fix for patch https://reviews.llvm.org/D33353
@uweigand, could you please verify that everything will be good on SystemZ?
I added triple spir-unknown-unknown.
Thank you in advance!


https://reviews.llvm.org/D33648

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/SemaOpenCL/arithmetic-conversions.cl
  test/SemaOpenCL/cond.cl

Index: test/SemaOpenCL/cond.cl
===
--- test/SemaOpenCL/cond.cl
+++ test/SemaOpenCL/cond.cl
@@ -89,7 +89,7 @@
 
 float2 ntest05(int2 C, int2 X, float Y)
 {
-  return C ? X : Y; // expected-error {{cannot convert between vector values of different size ('int2' (vector of 2 'int' values) and 'float')}}
+  return C ? X : Y; // expected-error {{scalar operand type has greater rank than the type of the vector element. ('int2' (vector of 2 'int' values) and 'float'}}
 }
 
 char2 ntest06(int2 C, char2 X, char2 Y)
Index: test/SemaOpenCL/arithmetic-conversions.cl
===
--- /dev/null
+++ test/SemaOpenCL/arithmetic-conversions.cl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2
+
+typedef float float2 __attribute__((ext_vector_type(2)));
+typedef long long2 __attribute__((ext_vector_type(2)));
+typedef int int2 __attribute__((ext_vector_type(2)));
+
+kernel void foo1(float2 in, global float2 *out) { *out = in + 0.5;} // expected-error {{scalar operand type has greater rank than the type of the vector element. ('float2' (vector of 2 'float' values) and 'double')}}
+
+kernel void foo2(float2 in, global float2 *out) { *out = 0.5 + in;} // expected-error {{scalar operand type has greater rank than the type of the vector element. ('double' and 'float2' (vector of 2 'float' values))}}
+
+kernel void foo3(float2 in, global float2 *out) { *out = 0.5f + in;}
+
+kernel void foo4(long2 in, global long2 *out) { *out = 5 + in;}
+
+kernel void foo5(float2 in, global float2 *out) {
+float* f;
+*out = f + in; // expected-error{{cannot convert between vector and non-scalar values ('float *' and 'float2' (vector of 2 'float' values))}}
+}
+
+kernel void foo6(int2 in, global int2 *out) {
+int* f;
+*out = f + in; // expected-error{{cannot convert between vector and non-scalar values ('int *' and 'int2' (vector of 2 'int' values))}}
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -8064,28 +8064,38 @@
 /// rank; for C, Obj-C, and C++ we allow any real scalar conversion except
 /// for float->int.
 ///
+/// OpenCL V2.0 6.2.6.p2:
+/// An error shall occur if any scalar operand type has greater rank
+/// than the type of the vector element.
+///
 /// \param scalar - if non-null, actually perform the conversions
 /// \return true if the operation fails (but without diagnosing the failure)
 static bool tryVectorConvertAndSplat(Sema , ExprResult *scalar,
  QualType scalarTy,
  QualType vectorEltTy,
- QualType vectorTy) {
+ QualType vectorTy,
+ unsigned ) {
   // The conversion to apply to the scalar before splatting it,
   // if necessary.
   CastKind scalarCast = CK_Invalid;
   
   if (vectorEltTy->isIntegralType(S.Context)) {
-if (!scalarTy->isIntegralType(S.Context))
+if (S.getLangOpts().OpenCL && (scalarTy->isRealFloatingType() ||
+(scalarTy->isIntegerType() &&
+ S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0))) {
+  DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
   return true;
-if (S.getLangOpts().OpenCL &&
-S.Context.getIntegerTypeOrder(vectorEltTy, scalarTy) < 0)
+}
+if (!scalarTy->isIntegralType(S.Context))
   return true;
 scalarCast = CK_IntegralCast;
   } else if (vectorEltTy->isRealFloatingType()) {
 if (scalarTy->isRealFloatingType()) {
   if (S.getLangOpts().OpenCL &&
-  S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0)
+  S.Context.getFloatingTypeOrder(vectorEltTy, scalarTy) < 0) {
+DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
 return true;
+  }
   scalarCast = CK_FloatingCast;
 }
 else if (scalarTy->isIntegralType(S.Context))
@@ -8331,10 +8341,12 @@
 
   // If there's a vector type and a scalar, try to convert the scalar to
   // the vector element type and splat.
+  unsigned DiagID = diag::err_typecheck_vector_not_convertable;
   if (!RHSVecType) {
 if (isa(LHSVecType)) {
   if (!tryVectorConvertAndSplat(*this, , RHSType,
-LHSVecType->getElementType(), LHSType))
+

[PATCH] D33531: Clang-tidy readability: avoid const value return

2017-05-29 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

> Would it make sense to silence this diagnostic in the presence of also 
> checking for cert-dcl21-cpp for such operators?

Currently there's no mechanism in clang-tidy to express dependencies or 
compatibility issues between checks. Moreover, we already have checks that are 
not meant to be run together, for example, readability-braces-around-statements 
and its google- incarnation (and other alias checks with different settings). 
That said, we could whitelist postfix increment and decrement operators in this 
check. Camillo, WDYT?

On a side note, the check's performance implications might be more important 
than the readability aspect of dropping the `const`, so the check might be a 
better fit for the `performance` category.


Repository:
  rL LLVM

https://reviews.llvm.org/D33531



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


[PATCH] D33365: [clang-tidy] misc-assertion-count: A New Check

2017-05-29 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I will obviously try to add lambda handling, but until then, the general idea 
and design should be pretty much done, so i'd love to hear any feedback about 
the current diff :)


Repository:
  rL LLVM

https://reviews.llvm.org/D33365



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


[PATCH] D33645: [analyzer] Add missing documentation for static analyzer checkers

2017-05-29 Thread Dominik Szabó via Phabricator via cfe-commits
szdominik created this revision.

Some checks did not have documentation in the www/analyzer/ folder, and also 
some alpha checks became non-alpha.


https://reviews.llvm.org/D33645

Files:
  www/analyzer/alpha_checks.html
  www/analyzer/available_checks.html
  www/analyzer/implicit_checks.html

Index: www/analyzer/implicit_checks.html
===
--- www/analyzer/implicit_checks.html
+++ www/analyzer/implicit_checks.html
@@ -27,7 +27,7 @@
 OS X Implicit Checkers
 
 
-
+
 Core Implicit Checkers
 
 
@@ -124,7 +124,7 @@
 
 
 
-
+
 OS X Implicit Checkers
 
 
Index: www/analyzer/available_checks.html
===
--- www/analyzer/available_checks.html
+++ www/analyzer/available_checks.html
@@ -38,12 +38,14 @@
 Core Checkers model core language features and perform general-purpose checks such as division by zero, null pointer dereference, usage of uninitialized values, etc.
 C++ Checkers perform C++-specific checks
 Dead Code Checkers check for unused code
+Nullability Checkers 
+Optin Checkers 
 OS X Checkers perform Objective-C-specific checks and check the use of Apple's SDKs (OS X and iOS)
 Security Checkers check for insecure API usage and perform checks based on the CERT Secure Coding Standards
 Unix Checkers check the use of Unix and POSIX APIs
 
 
-
+
 Core Checkers
 
 
@@ -360,7 +362,7 @@
 
 
 
-
+
 C++ Checkers
 
 
@@ -421,9 +423,29 @@
 }
 
 
+
+cplusplus.NewDeleteLeaks
+(C++)
+Check for memory leaks. Traces memory managed by new/
+delete.
+
+
+void test() {
+  int *p = new int;
+} // warn
+
+
+
+
+cplusplus.SelfAssignment
+(C++)
+Checks C++ copy and move assignment operators for self assignment,
+but itself doesn't warn. It's for modeling self assignment -
+other checkers could find errors.
+
 
 
-
+
 Dead Code Checkers
 
 
@@ -444,7 +466,157 @@
 
 
 
-
+
+Nullability Checkers
+
+
+Name, DescriptionExample
+
+
+
+nullability.NullPassedToNonnull
+(ObjC)
+Warns when a null pointer is passed to a pointer which has a 
+_Nonnull type.
+
+
+typedef struct Dummy { int val; } Dummy;
+void takesNonnull(Dummy *_Nonnull);
+
+void test() {
+  Dummy *q = 0;
+  takesNonnull(q); // warn
+}
+
+
+
+
+nullability.NullReturnedFromNonnull
+(ObjC)
+Warns when a null pointer is returned from a function that has 
+_Nonnull return type.
+
+
+typedef struct Dummy { int val; } Dummy;
+
+Dummy *_Nonnull test() {
+  Dummy *p = 0;
+  return p; // warn
+}
+
+
+
+
+nullability.NullableDereferenced
+(ObjC)
+Warns when a nullable pointer is dereferenced.
+
+
+typedef struct Dummy { int val; } Dummy;
+Dummy *_Nullable returnsNullable();
+
+void test() {
+  Dummy *p = returnsNullable();
+  Dummy  = *p; // warn
+}
+
+
+
+
+nullability.NullablePassedToNonnull
+(ObjC)
+Warns when a nullable pointer is passed to a pointer which has a _Nonnull type.
+
+
+typedef struct Dummy { int val; } Dummy;
+Dummy *_Nullable returnsNullable();
+void takesNonnull(Dummy *_Nonnull);
+
+void test() {
+  Dummy *p = returnsNullable();
+  takesNonnull(p); // warn
+}
+
+
+
+
+
+Optin Checkers
+
+
+Name, DescriptionExample
+
+
+
+optin.mpi.MPI-Checker
+(C)
+Checks MPI code
+
+
+void test() {
+  double buf = 0;
+  MPI_Request sendReq1;
+  MPI_Ireduce(MPI_IN_PLACE, , 1, MPI_DOUBLE, MPI_SUM, 
+  0, MPI_COMM_WORLD, );
+} // warn: request 'sendReq1' has no matching wait.
+
+
+void test() {
+  double buf = 0;
+  MPI_Request sendReq;
+  MPI_Isend(, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, );
+  MPI_Irecv(, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, ); // warn
+  MPI_Isend(, 1, MPI_DOUBLE, 0, 0, MPI_COMM_WORLD, ); // warn
+  MPI_Wait(, MPI_STATUS_IGNORE);
+}
+
+
+void missingNonBlocking() {
+  int rank = 0;
+  MPI_Comm_rank(MPI_COMM_WORLD, );
+  MPI_Request sendReq1[10][10][10];
+  MPI_Wait([1][7][9], MPI_STATUS_IGNORE); // warn
+}
+
+
+
+
+optin.osx.cocoa.localizability.EmptyLocalizationContextChecker
+(ObjC)
+Check that NSLocalizedString macros include a comment for context.
+
+
+- (void)test {
+  NSString *string = NSLocalizedString(@"LocalizedString", nil); // warn
+  NSString *string2 = NSLocalizedString(@"LocalizedString", @" "); // warn
+  NSString *string3 = NSLocalizedStringWithDefaultValue(
+@"LocalizedString", nil, [[NSBundle alloc] init], nil,@""); // warn
+}
+
+
+
+
+optin.osx.cocoa.localizability.NonLocalizedStringChecker
+(ObjC)
+Warns about uses of non-localized NSStrings passed to UI methods 
+expecting localized NSStrings
+
+
+- (void)test {
+  UILabel *testLabel = [[UILabel alloc] init];
+  NSString *bar = NSLocalizedString(@"Hello", @"Comment");
+
+  if (random()) { 
+bar = @"Unlocalized string";
+  }
+
+  [testLabel setText:bar]; // warn
+}
+
+
+
+
+
 OS X Checkers
 
 
@@ -466,6 +638,37 @@
 
 
 
+osx.NumberObjectConversion
+(C, C++, ObjC)
+Check for erroneous conversions of objects representing numbers 
+into numbers
+
+
+typedef const struct __CFNumber *CFNumberRef;
+void takes_int(int);
+
+void test(CFNumberRef p) {
+#ifdef PEDANTIC
+ 

[PATCH] D33644: Add default values for function parameter chunks

2017-05-29 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan created this revision.

Append optional chunks with their default values. For example: before - "int 
i", after - "int i = 10". This change affects only simple types.


https://reviews.llvm.org/D33644

Files:
  lib/Sema/SemaCodeComplete.cpp


Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -2279,6 +2279,15 @@
 } else {
   Type.getAsStringInternal(Result, Policy);
 }
+if (Param->hasDefaultArg()) {
+  APValue *defaultValue = Param->evaluateValue();
+  if (defaultValue) {
+std::string defaultValueStr = defaultValue->getAsString(
+Param->getASTContext(), Param->getType());
+if (!defaultValueStr.empty())
+  Result += " = " + defaultValueStr;
+  }
+}
 return Result;
   }
 


Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -2279,6 +2279,15 @@
 } else {
   Type.getAsStringInternal(Result, Policy);
 }
+if (Param->hasDefaultArg()) {
+  APValue *defaultValue = Param->evaluateValue();
+  if (defaultValue) {
+std::string defaultValueStr = defaultValue->getAsString(
+Param->getASTContext(), Param->getType());
+if (!defaultValueStr.empty())
+  Result += " = " + defaultValueStr;
+  }
+}
 return Result;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33493: Speed up preamble loading, reduce global completion cache calls

2017-05-29 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 100605.
yvvan added a comment.

diff with -U


https://reviews.llvm.org/D33493

Files:
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -470,7 +470,7 @@
   }
   
   // Save the current top-level hash value.
-  CompletionCacheTopLevelHashValue = CurrentTopLevelHashValue;
+  CompletionCacheTopLevelHashValue = PreambleTopLevelHashValue;
 }
 
 void ASTUnit::ClearCachedCompletionResults() {
@@ -1148,6 +1148,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+SrcLocCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -1506,6 +1508,8 @@
   SimpleTimer PreambleTimer(WantTiming);
   PreambleTimer.setOutput("Precompiling preamble");
 
+  CompletionCacheTopLevelHashValue = 0;
+
   // Save the preamble text for later; we'll need to compare against it for
   // subsequent reparses.
   StringRef MainFilename = FrontendOpts.Inputs[0].getFile();
@@ -1656,7 +1660,6 @@
   // entities the last time we rebuilt the preamble, clear out the completion
   // cache.
   if (CurrentTopLevelHashValue != PreambleTopLevelHashValue) {
-CompletionCacheTopLevelHashValue = 0;
 PreambleTopLevelHashValue = CurrentTopLevelHashValue;
   }
 
@@ -2105,7 +2108,7 @@
   // If we're caching global code-completion results, and the top-level 
   // declarations have changed, clear out the code-completion cache.
   if (!Result && ShouldCacheCodeCompletionResults &&
-  CurrentTopLevelHashValue != CompletionCacheTopLevelHashValue)
+  PreambleTopLevelHashValue != CompletionCacheTopLevelHashValue)
 CacheCodeCompletionResults();
 
   // We now need to clear out the completion info related to this translation
@@ -2579,20 +2582,25 @@
 
   SmallVector Result;
   Result.reserve(Diags.size());
-  const FileEntry *PreviousFE = nullptr;
-  FileID FID;
+
   for (const StandaloneDiagnostic  : Diags) {
 // Rebuild the StoredDiagnostic.
 if (SD.Filename.empty())
   continue;
 const FileEntry *FE = FileMgr.getFile(SD.Filename);
 if (!FE)
   continue;
-if (FE != PreviousFE) {
+FileID FID;
+SourceLocation FileLoc;
+auto ItFileID = SrcLocCache.find(SD.Filename);
+if (ItFileID == SrcLocCache.end()) {
   FID = SrcMgr.translateFile(FE);
-  PreviousFE = FE;
+  FileLoc = SrcMgr.getLocForStartOfFile(FID);
+  SrcLocCache.insert(std::make_pair(SD.Filename, FileLoc));
+} else {
+  FileLoc = ItFileID->second;
 }
-SourceLocation FileLoc = SrcMgr.getLocForStartOfFile(FID);
+
 if (FileLoc.isInvalid())
   continue;
 SourceLocation L = FileLoc.getLocWithOffset(SD.LocOffset);
Index: include/clang/Frontend/ASTUnit.h
===
--- include/clang/Frontend/ASTUnit.h
+++ include/clang/Frontend/ASTUnit.h
@@ -185,6 +185,12 @@
   /// some number of calls.
   unsigned PreambleRebuildCounter;
 
+  /// \brief Cache pairs "filename - source location"
+  ///
+  /// This cache is used when loading preambule to increase performance
+  /// of that loading
+  std::map SrcLocCache;
+
 public:
   class PreambleData {
 const FileEntry *File;


Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -470,7 +470,7 @@
   }
   
   // Save the current top-level hash value.
-  CompletionCacheTopLevelHashValue = CurrentTopLevelHashValue;
+  CompletionCacheTopLevelHashValue = PreambleTopLevelHashValue;
 }
 
 void ASTUnit::ClearCachedCompletionResults() {
@@ -1148,6 +1148,8 @@
   if (SavedMainFileBuffer)
 TranslateStoredDiagnostics(getFileManager(), getSourceManager(),
PreambleDiagnostics, StoredDiagnostics);
+  else
+SrcLocCache.clear();
 
   if (!Act->Execute())
 goto error;
@@ -1506,6 +1508,8 @@
   SimpleTimer PreambleTimer(WantTiming);
   PreambleTimer.setOutput("Precompiling preamble");
 
+  CompletionCacheTopLevelHashValue = 0;
+
   // Save the preamble text for later; we'll need to compare against it for
   // subsequent reparses.
   StringRef MainFilename = FrontendOpts.Inputs[0].getFile();
@@ -1656,7 +1660,6 @@
   // entities the last time we rebuilt the preamble, clear out the completion
   // cache.
   if (CurrentTopLevelHashValue != PreambleTopLevelHashValue) {
-CompletionCacheTopLevelHashValue = 0;
 PreambleTopLevelHashValue = CurrentTopLevelHashValue;
   }
 
@@ -2105,7 +2108,7 @@
   // If we're caching global code-completion results, and the top-level 
   // declarations have changed, clear out the code-completion cache.
   if (!Result && ShouldCacheCodeCompletionResults &&
-  CurrentTopLevelHashValue 

[PATCH] D33353: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element

2017-05-29 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

The problem is that the new test case you added does not contain a -triple 
argument in the compile command.  This means that the compile targets the 
native architecture on the build system, whatever this is.  Since OpenCL 
support on different architectures may be different (e.g. some may support the 
cl_khr_fp64 extension by default while others do not), you see the error only 
on some build architectures.

If you want to see the error, I guess you can force targeting SystemZ by adding 
"-triple s390x-ibm-linux-gnu" to the compile command.

To actually fix the problem, as mentioned above, add a -triple line that 
specifies an architecture where the extension is always known to be present.  
(Or else, I think you can force the extension to be available even if it is not 
by default on a target.)


https://reviews.llvm.org/D33353



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


[PATCH] D32592: [Analyzer] Iterator Checker - Part 1: Minimal Checker for a Simple Test Case

2017-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

I believe we can move on to the next one :) Just hope we didn't screw up the 
rebase too much here. Thanks again!


https://reviews.llvm.org/D32592



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


[PATCH] D32449: Modifying PthreadLockChecker.cpp to reduce false positives.

2017-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

I'd commit your patch without the .gitignore change, as it deserves a separate 
commit and more attention; will have a look at it myself - llvm's and clang's 
.gitignores have diverged quite a bit.

Thanks for taking this up!~


Repository:
  rL LLVM

https://reviews.llvm.org/D32449



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


[PATCH] D33353: [OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element

2017-05-29 Thread Egor Churaev via Phabricator via cfe-commits
echuraev added a comment.

Hi all,

I tried to reproduce this problem but I'm not able to do it...
I tried to do it in two different ways:

1. I tried to build llvm by the following steps:

1.1. Checkout llvm and clang:

  svn co https://echur...@llvm.org/svn/llvm-project/llvm/trunk llvm
  svn co https://echur...@llvm.org/svn/llvm-project/cfe/trunk llvm/tools/clang

1.2. Applied patch by the following line: `arc patch D33353`
1.3. Build llvm:

  mkdir build
  
  cd build
  
  cmake -G "Unix Makefiles" ../llvm
  
  make -j 8

1.4. Run tests: `make check-clang`
Also, I tried to run `make check-all`

1.5. As a result: all tests were passed.

2. I tried to build llvm with ninja.

2.1. This step is the same with 1.1. In the next steps I used commands from the 
following log: http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/8741
2.2. Go to llvm dir and update svn to the target revision: `cd llvm && svn 
update --non-interactive --no-auth-cache --revision 303986`
2.3. Go to clang dif and update svn to the target revision: `cd tools/clang/ && 
svn update --non-interactive --no-auth-cache --revision 303986`
2.4. Create extra dir and update svn: `mkdir tools/extra && cd tools/extra && 
svn update --non-interactive --no-auth-cache --revision 303986`
2.5. Create compiler-rt dir and update svn: `cd ../../../../projects && mkdir 
compiler-rt && cd compiler-rt && svn update --non-interactive --no-auth-cache 
--revision 303986`
2.6. Generate build ninja files:

  cd ../../../
  mkdir ninja_build && cd ninja_build
  cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release 
-DLLVM_ENABLE_ASSERTIONS=True '-DLLVM_LIT_ARGS='"'"'-v'"'"'' 
-DCMAKE_INSTALL_PREFIX=../stage1.install -DLLVM_ENABLE_ASSERTIONS=ON

2.7. Run build by the following command: `ninja`
2.8. Run tests: `ninja check-all`
2.9. And also all tests were passed.

Could you please help me? How can I reproduce this issue?

Thank you in advance!


https://reviews.llvm.org/D33353



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


r304134 - [OpenCL] Test on half immediate support.

2017-05-29 Thread Egor Churaev via cfe-commits
Author: echuraev
Date: Mon May 29 02:44:22 2017
New Revision: 304134

URL: http://llvm.org/viewvc/llvm-project?rev=304134=rev
Log:
[OpenCL] Test on half immediate support.

Reviewers: Anastasia

Reviewed By: Anastasia

Subscribers: yaxunl, cfe-commits, bader

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

Modified:
cfe/trunk/test/CodeGenOpenCL/half.cl

Modified: cfe/trunk/test/CodeGenOpenCL/half.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/half.cl?rev=304134=304133=304134=diff
==
--- cfe/trunk/test/CodeGenOpenCL/half.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/half.cl Mon May 29 02:44:22 2017
@@ -21,3 +21,20 @@ half test_inc(half x)
 {
   return ++x;
 }
+
+__attribute__((overloadable)) int min(int, int);
+__attribute__((overloadable)) half min(half, half);
+__attribute__((overloadable)) float min(float, float);
+
+__kernel void foo( __global half* buf, __global float* buf2 )
+{
+buf[0] = min( buf[0], 1.5h );
+// CHECK: half 0xH3E00
+buf[0] = min( buf2[0], 1.5f );
+// CHECK: float 1.50e+00
+
+const half one = 1.;
+buf[1] = min( buf[1], one );
+// CHECK: half 0xH3EAB
+}
+


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


[PATCH] D33531: Clang-tidy readability: avoid const value return

2017-05-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm not opposed to this check, but I'm not keen on having a check that directly 
contradicts the output from another check. The `cert-dcl21-cpp` check will 
diagnose user's code when a postfix operator ++ or -- is *not* const-qualified. 
Would it make sense to silence this diagnostic in the presence of also checking 
for `cert-dcl21-cpp` for such operators?


Repository:
  rL LLVM

https://reviews.llvm.org/D33531



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


[PATCH] D33531: Clang-tidy readability: avoid const value return

2017-05-29 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:27
+  // skip those too.
+  Finder->addMatcher(functionDecl(returns(qualType(
+isConstQualified(),

How about just matching definitions to avoid duplicate warnings?



Comment at: test/clang-tidy/readability-const-value-return.cpp:1
+// RUN: %check_clang_tidy %s readability-const-value-return %t
+

Please add tests for:
1. a function with multiple declarations and a definition
2. function declarations/definitions in macros
3. a class method
4. implicit stuff (I'm not sure if a lambda can be made to return a const type 
without an explicit return type specification)



Comment at: test/clang-tidy/readability-const-value-return.cpp:50
+template 
+const T f_returns_template_param();
+

It would be nice to ensure the check doesn't trigger on template instantiation 
of this function as well.


Repository:
  rL LLVM

https://reviews.llvm.org/D33531



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


[PATCH] D33531: Clang-tidy readability: avoid const value return

2017-05-29 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

> The check ignores returns of const pointers (meaning * const, not const *); 
> while pointless, these are not particularly harmful. It could be made laxer 
> by ignoring all trivially copyable types (on the grounds that they won't have 
> interesting move constructors/assigners anyway), or stricter by ignoring all 
> const returns (on the grounds that, in the best case, it's just pointless 
> verbosity). Or it could be made an option.

I'd prefer an option. It could be `StrictMode`, which is also supported as a 
global option, for example, by clang-tidy/misc/ArgumentCommentCheck.cpp.


Repository:
  rL LLVM

https://reviews.llvm.org/D33531



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


[PATCH] D33042: [libclang] Allow to suspend a translation unit.

2017-05-29 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

I'm new to this review tool. I've addressed the comments and rebased. Does this 
needs a re-review? Note that this is my first change and I probably do not have 
any permissions to submit this change.


https://reviews.llvm.org/D33042



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


r304141 - clang-format: [JS] do not clean up duplicated commas.

2017-05-29 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Mon May 29 03:41:11 2017
New Revision: 304141

URL: http://llvm.org/viewvc/llvm-project?rev=304141=rev
Log:
clang-format: [JS] do not clean up duplicated commas.

Summary:
In JavaScript, duplicated commas have semantic meaning.
x = [a,,b];

The statement above creates an array with three entries, the middle being 
undefined. Because clang-format should not change semantics, disable this 
cleanup in JS.

Reviewers: djasper

Subscribers: klimek

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

Modified:
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/unittests/Format/CleanupTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=304141=304140=304141=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Mon May 29 03:41:11 2017
@@ -1910,6 +1910,9 @@ tooling::Replacements reformat(const For
 tooling::Replacements cleanup(const FormatStyle , StringRef Code,
   ArrayRef Ranges,
   StringRef FileName) {
+  // cleanups only apply to C++ (they mostly concern ctor commas etc.)
+  if (Style.Language != FormatStyle::LK_Cpp)
+return tooling::Replacements();
   std::unique_ptr Env =
   Environment::CreateVirtualEnvironment(Code, FileName, Ranges);
   Cleaner Clean(*Env, Style);

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=304141=304140=304141=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Mon May 29 03:41:11 2017
@@ -36,11 +36,12 @@ protected:
 
   // Returns code after cleanup around \p Offsets.
   std::string cleanupAroundOffsets(llvm::ArrayRef Offsets,
-   llvm::StringRef Code) {
+   llvm::StringRef Code,
+   const FormatStyle  = getLLVMStyle()) {
 std::vector Ranges;
 for (auto Offset : Offsets)
   Ranges.push_back(tooling::Range(Offset, 0));
-return cleanup(Code, Ranges);
+return cleanup(Code, Ranges, Style);
   }
 };
 
@@ -171,6 +172,14 @@ TEST_F(CleanupTest, ListRedundantComma)
   EXPECT_EQ(Expected, cleanupAroundOffsets({17, 22}, Code));
 }
 
+TEST_F(CleanupTest, NoCleanupsForJavaScript) {
+  std::string Code = "function f() { var x = [a, b, , c]; }";
+  std::string Expected = "function f() { var x = [a, b, , c]; }";
+  const FormatStyle  = getGoogleStyle(FormatStyle::LK_JavaScript);
+
+  EXPECT_EQ(Expected, cleanupAroundOffsets({30}, Code, Style));
+}
+
 TEST_F(CleanupTest, TrailingCommaInParens) {
   std::string Code = "int main() { f(,1,,2,3,f(1,2,),4,,);}";
   std::string Expected = "int main() { f(1,2,3,f(1,2),4);}";


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


[PATCH] D33416: [clangd] Allow to use vfs::FileSystem for file accesses.

2017-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for fixing the failures. Sorry for not being around to look into that 
myself.




Comment at: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp:123
+  TmpDirs.push_back(TmpDir1.str());
+  if (TmpDir2 != TmpDir2)
+TmpDirs.push_back(TmpDir2.str());

chapuni wrote:
> Did you mean, "TmpDir1 != TmpDir2" ?
> Fixed in r304067.
I sure did. Thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D33416



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


r304135 - clang-format: [JS] fix indenting bound functions.

2017-05-29 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Mon May 29 02:50:52 2017
New Revision: 304135

URL: http://llvm.org/viewvc/llvm-project?rev=304135=rev
Log:
clang-format: [JS] fix indenting bound functions.

Summary:
The previous fix to force build style wrapping if the previous token is a 
closing parenthesis broke a peculiar pattern where users parenthesize the 
function declaration in a bind call:
fn((function() { ... }).bind(this));

This restores the previous behaviour by reverting that change, but narrowing 
the special case for unindenting closing parentheses to those followed by 
semicolons and opening braces, i.e. immediate calls and function declarations.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=304135=304134=304135=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon May 29 02:50:52 2017
@@ -215,7 +215,7 @@ bool ContinuationIndenter::mustBreak(con
   // ...
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn &&
 Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
@@ -689,7 +689,18 @@ unsigned ContinuationIndenter::getNewLin
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
-  if (Current.is(tok::r_paren) && State.Stack.size() > 1)
+  // Indent a closing parenthesis at the previous level if followed by a semi 
or
+  // opening brace. This allows indentations such as:
+  // foo(
+  //   a,
+  // );
+  // function foo(
+  //   a,
+  // ) {
+  //   code(); //
+  // }
+  if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
+  (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=304135=304134=304135=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon May 29 02:50:52 2017
@@ -717,6 +717,11 @@ TEST_F(FormatTestJS, FunctionLiterals) {
"  bar();\n"
"}.bind(this));");
 
+  verifyFormat("SomeFunction((function() {\n"
+   "   foo();\n"
+   "   bar();\n"
+   " }).bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"


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


[PATCH] D33640: clang-format: [JS] fix indenting bound functions.

2017-05-29 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL304135: clang-format: [JS] fix indenting bound functions. 
(authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D33640?vs=100589=100591#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D33640

Files:
  cfe/trunk/lib/Format/ContinuationIndenter.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -717,6 +717,11 @@
"  bar();\n"
"}.bind(this));");
 
+  verifyFormat("SomeFunction((function() {\n"
+   "   foo();\n"
+   "   bar();\n"
+   " }).bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"
Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -215,7 +215,7 @@
   // ...
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn &&
 Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
@@ -689,7 +689,18 @@
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
-  if (Current.is(tok::r_paren) && State.Stack.size() > 1)
+  // Indent a closing parenthesis at the previous level if followed by a semi 
or
+  // opening brace. This allows indentations such as:
+  // foo(
+  //   a,
+  // );
+  // function foo(
+  //   a,
+  // ) {
+  //   code(); //
+  // }
+  if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
+  (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;


Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -717,6 +717,11 @@
"  bar();\n"
"}.bind(this));");
 
+  verifyFormat("SomeFunction((function() {\n"
+   "   foo();\n"
+   "   bar();\n"
+   " }).bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"
Index: cfe/trunk/lib/Format/ContinuationIndenter.cpp
===
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp
@@ -215,7 +215,7 @@
   // ...
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn &&
 Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
@@ -689,7 +689,18 @@
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
-  if (Current.is(tok::r_paren) && State.Stack.size() > 1)
+  // Indent a closing parenthesis at the previous level if followed by a semi or
+  // opening brace. This allows indentations such as:
+  // foo(
+  //   a,
+  // );
+  // function foo(
+  //   a,
+  // ) {
+  //   code(); //
+  // }
+  if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
+  (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33640: clang-format: [JS] fix indenting bound functions.

2017-05-29 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 100589.
mprobst added a comment.

- fix comment


https://reviews.llvm.org/D33640

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


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -717,6 +717,11 @@
"  bar();\n"
"}.bind(this));");
 
+  verifyFormat("SomeFunction((function() {\n"
+   "   foo();\n"
+   "   bar();\n"
+   " }).bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -207,7 +207,7 @@
   // ...
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn &&
 Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
@@ -676,7 +676,18 @@
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
-  if (Current.is(tok::r_paren) && State.Stack.size() > 1)
+  // Indent a closing parenthesis at the previous level if followed by a semi 
or
+  // opening brace. This allows indentations such as:
+  // foo(
+  //   a,
+  // );
+  // function foo(
+  //   a,
+  // ) {
+  //   code(); //
+  // }
+  if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
+  (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -717,6 +717,11 @@
"  bar();\n"
"}.bind(this));");
 
+  verifyFormat("SomeFunction((function() {\n"
+   "   foo();\n"
+   "   bar();\n"
+   " }).bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -207,7 +207,7 @@
   // ...
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn &&
 Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
@@ -676,7 +676,18 @@
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
-  if (Current.is(tok::r_paren) && State.Stack.size() > 1)
+  // Indent a closing parenthesis at the previous level if followed by a semi or
+  // opening brace. This allows indentations such as:
+  // foo(
+  //   a,
+  // );
+  // function foo(
+  //   a,
+  // ) {
+  //   code(); //
+  // }
+  if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
+  (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33640: clang-format: [JS] fix indenting bound functions.

2017-05-29 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Format/ContinuationIndenter.cpp:210
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn && // Current.TokenText == "bind" &&
 Style.Language == FormatStyle::LK_JavaScript))

Delete?


https://reviews.llvm.org/D33640



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


[PATCH] D33640: clang-format: [JS] fix indenting bound functions.

2017-05-29 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 100588.
mprobst added a comment.

- fix comment


https://reviews.llvm.org/D33640

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


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -717,6 +717,11 @@
"  bar();\n"
"}.bind(this));");
 
+  verifyFormat("SomeFunction((function() {\n"
+   "   foo();\n"
+   "   bar();\n"
+   " }).bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -207,7 +207,7 @@
   // ...
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn && // Current.TokenText == "bind" &&
 Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
@@ -676,7 +676,18 @@
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
-  if (Current.is(tok::r_paren) && State.Stack.size() > 1)
+  // Indent a closing parenthesis at the previous level if followed by a semi 
or
+  // opening brace. This allows indentations such as:
+  // foo(
+  //   a,
+  // );
+  // function foo(
+  //   a,
+  // ) {
+  //   code(); //
+  // }
+  if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
+  (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -717,6 +717,11 @@
"  bar();\n"
"}.bind(this));");
 
+  verifyFormat("SomeFunction((function() {\n"
+   "   foo();\n"
+   "   bar();\n"
+   " }).bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -207,7 +207,7 @@
   // ...
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn && // Current.TokenText == "bind" &&
 Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
@@ -676,7 +676,18 @@
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
-  if (Current.is(tok::r_paren) && State.Stack.size() > 1)
+  // Indent a closing parenthesis at the previous level if followed by a semi or
+  // opening brace. This allows indentations such as:
+  // foo(
+  //   a,
+  // );
+  // function foo(
+  //   a,
+  // ) {
+  //   code(); //
+  // }
+  if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
+  (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33640: clang-format: [JS] fix indenting bound functions.

2017-05-29 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

The previous fix to force build style wrapping if the previous token is a 
closing parenthesis broke a peculiar pattern where users parenthesize the 
function declaration in a bind call:

  fn((function() { ... }).bind(this));

This restores the previous behaviour by reverting that change, but narrowing 
the special case for unindenting closing parentheses to those followed by 
semicolons and opening braces, i.e. immediate calls and function declarations.


https://reviews.llvm.org/D33640

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


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -717,6 +717,11 @@
"  bar();\n"
"}.bind(this));");
 
+  verifyFormat("SomeFunction((function() {\n"
+   "   foo();\n"
+   "   bar();\n"
+   " }).bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -207,7 +207,7 @@
   // ...
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn && // Current.TokenText == "bind" &&
 Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
@@ -676,7 +676,18 @@
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
-  if (Current.is(tok::r_paren) && State.Stack.size() > 1)
+  // Indent a closing parenthesis at the previous level if followed by a semi 
or
+  // opening brace. This allows indentations such as:
+  // foo(
+  //   a,
+  // );
+  // foo(
+  //   a,
+  // ) {
+  //   code(); //
+  // ) {
+  if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
+  (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -717,6 +717,11 @@
"  bar();\n"
"}.bind(this));");
 
+  verifyFormat("SomeFunction((function() {\n"
+   "   foo();\n"
+   "   bar();\n"
+   " }).bind(this));");
+
   // FIXME: This is bad, we should be wrapping before "function() {".
   verifyFormat("someFunction(function() {\n"
"  doSomething();  // break\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -207,7 +207,7 @@
   // ...
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
-  !(State.Column <= NewLineColumn && Previous.isNot(tok::r_paren) &&
+  !(State.Column <= NewLineColumn && // Current.TokenText == "bind" &&
 Style.Language == FormatStyle::LK_JavaScript))
 return true;
 
@@ -676,7 +676,18 @@
   return State.Stack[State.Stack.size() - 2].LastSpace;
 return State.FirstIndent;
   }
-  if (Current.is(tok::r_paren) && State.Stack.size() > 1)
+  // Indent a closing parenthesis at the previous level if followed by a semi or
+  // opening brace. This allows indentations such as:
+  // foo(
+  //   a,
+  // );
+  // foo(
+  //   a,
+  // ) {
+  //   code(); //
+  // ) {
+  if (Current.is(tok::r_paren) && State.Stack.size() > 1 &&
+  (!Current.Next || Current.Next->isOneOf(tok::semi, tok::l_brace)))
 return State.Stack[State.Stack.size() - 2].LastSpace;
   if (NextNonComment->is(TT_TemplateString) && NextNonComment->closesScope())
 return State.Stack[State.Stack.size() - 2].LastSpace;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r304131 - Fix coroutine test failures caused by API misusages.

2017-05-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon May 29 01:42:01 2017
New Revision: 304131

URL: http://llvm.org/viewvc/llvm-project?rev=304131=rev
Log:
Fix coroutine test failures caused by API misusages.

More tests to come. I think that from_address overload should be deleted
or ill-formed, except for the 'void*' one; The user cannot possibly
have a typed pointer to the coroutine state.

Modified:
libcxx/trunk/include/experimental/coroutine

libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp

libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp

Modified: libcxx/trunk/include/experimental/coroutine
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/coroutine?rev=304131=304130=304131=diff
==
--- libcxx/trunk/include/experimental/coroutine (original)
+++ libcxx/trunk/include/experimental/coroutine Mon May 29 01:42:01 2017
@@ -212,6 +212,15 @@ public:
 return __tmp;
 }
 
+// NOTE: this overload isn't required by the standard but is needed so
+// the deleted _Promise* overload doesn't make from_address(nullptr)
+// ambiguous.
+// FIXME: should from_address work with nullptr?
+_LIBCPP_ALWAYS_INLINE
+static coroutine_handle from_address(nullptr_t) _NOEXCEPT {
+  return {};
+}
+
 // from_address cannot be used with the coroutines promise type.
 static coroutine_handle from_address(_Promise*) = delete;
 

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp?rev=304131=304130=304131=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.capacity/operator_bool.sh.cpp
 Mon May 29 01:42:01 2017
@@ -48,8 +48,8 @@ void do_test() {
 assert(bool(c) == false);
   }
   { // non-null case
-int dummy = 42;
-C c = C::from_address();
+char dummy = 42;
+C c = C::from_address((void*));
 assert(c.address() == );
 assert(bool(c) == true);
   }

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp?rev=304131=304130=304131=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/address.sh.cpp
 Mon May 29 01:42:01 2017
@@ -42,8 +42,8 @@ void do_test() {
 assert(c.address() == nullptr);
   }
   {
-int dummy = 42;
-C c = C::from_address();
+char dummy = 42;
+C c = C::from_address((void*));
 assert(c.address() == );
   }
 }

Modified: 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp?rev=304131=304130=304131=diff
==
--- 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.sh.cpp
 Mon May 29 01:42:01 2017
@@ -37,8 +37,8 @@ void do_test() {
 assert(c.address() == nullptr);
   }
   {
-int dummy = 42;
-C c = C::from_address();
+char dummy = 42;
+C c = C::from_address((void*));
 assert(c.address() == );
   }
 }


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