[PATCH] D49580: [clang-format] Adding style option for absolute formatting

2018-08-02 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak added a comment.

Thanks!


https://reviews.llvm.org/D49580



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


[PATCH] D50170: [libcxxabi] Fix test_exception_address_alignment test for ARM

2018-08-02 Thread Yvan Roux via Phabricator via cfe-commits
yroux created this revision.
yroux added reviewers: mclow.lists, hans.
Herald added a reviewer: EricWF.
Herald added a reviewer: javed.absar.
Herald added subscribers: ldionne, chrib, kristof.beyls.

Check _LIBCXXABI_ARM_EHABI macro instead of libunwind version


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D50170

Files:
  test/test_exception_address_alignment.pass.cpp


Index: test/test_exception_address_alignment.pass.cpp
===
--- test/test_exception_address_alignment.pass.cpp
+++ test/test_exception_address_alignment.pass.cpp
@@ -20,14 +20,15 @@
 
 #include 
 #include 
+#include <__cxxabi_config.h>
 
 #include 
 
 struct __attribute__((aligned)) AlignedType {};
 
 // EHABI  : 8-byte aligned
 // Itanium: Largest supported alignment for the system
-#if defined(_LIBUNWIND_ARM_EHABI)
+#if defined(_LIBCXXABI_ARM_EHABI)
 #  define EXPECTED_ALIGNMENT 8
 #else
 #  define EXPECTED_ALIGNMENT alignof(AlignedType)


Index: test/test_exception_address_alignment.pass.cpp
===
--- test/test_exception_address_alignment.pass.cpp
+++ test/test_exception_address_alignment.pass.cpp
@@ -20,14 +20,15 @@
 
 #include 
 #include 
+#include <__cxxabi_config.h>
 
 #include 
 
 struct __attribute__((aligned)) AlignedType {};
 
 // EHABI  : 8-byte aligned
 // Itanium: Largest supported alignment for the system
-#if defined(_LIBUNWIND_ARM_EHABI)
+#if defined(_LIBCXXABI_ARM_EHABI)
 #  define EXPECTED_ALIGNMENT 8
 #else
 #  define EXPECTED_ALIGNMENT alignof(AlignedType)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50171: [python] [tests] Update test_code_completion

2018-08-02 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: ilya-biryukov, arphaman, bkramer, gribozavr.

Update expected completions to match output generated by clang-7.0.

Disclaimer: I have no clue if the results are correct. I'm kinda wondering why 
the '::' part is no longer included immediately.

Also PR38417 .


Repository:
  rC Clang

https://reviews.llvm.org/D50171

Files:
  bindings/python/tests/cindex/test_code_completion.py


Index: bindings/python/tests/cindex/test_code_completion.py
===
--- bindings/python/tests/cindex/test_code_completion.py
+++ bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || 
Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available 
|| Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available 
|| Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || 
Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 


Index: bindings/python/tests/cindex/test_code_completion.py
===
--- bindings/python/tests/cindex/test_code_completion.py
+++ bindings/python/tests/cindex/test_code_completion.py
@@ -61,11 +61,11 @@
 cr = tu.codeComplete('fake.cpp', 12, 5, unsaved_files=files)
 
 expected = [
-  "{'const', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'volatile', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
+  "{'const', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'volatile', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
   "{'operator', TypedText} || Priority: 40 || Availability: Available || Brief comment: None",
-  "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None",
-  "{'Q', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None"
+  "{'P', TypedText} || Priority: 50 || Availability: Available || Brief comment: None",
+  "{'Q', TypedText} || Priority: 50 || Availability: Available || Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50104: [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-08-02 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


https://reviews.llvm.org/D50104



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


[PATCH] D32747: [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments

2018-08-02 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 158701.
baloghadamsoftware added a comment.

Copying iterator position for the `this` pointer of C++ operators from the 
caller's context to the callee's context is no longer needed.


https://reviews.llvm.org/D32747

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/invalidated-iterator.cpp

Index: test/Analysis/invalidated-iterator.cpp
===
--- /dev/null
+++ test/Analysis/invalidated-iterator.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.InvalidatedIterator -analyzer-eagerly-assume -analyzer-config aggressive-relational-comparison-simplification=true -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.InvalidatedIterator -analyzer-eagerly-assume -analyzer-config aggressive-relational-comparison-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void bad_copy_assign_operator_list1(std::list &L1,
+const std::list &L2) {
+  auto i0 = L1.cbegin();
+  L1 = L2;
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_copy_assign_operator_vector1(std::vector &V1,
+  const std::vector &V2) {
+  auto i0 = V1.cbegin();
+  V1 = V2;
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_copy_assign_operator_deque1(std::deque &D1,
+ const std::deque &D2) {
+  auto i0 = D1.cbegin();
+  D1 = D2;
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
+
+void bad_copy_assign_operator_forward_list1(std::forward_list &FL1,
+const std::forward_list &FL2) {
+  auto i0 = FL1.cbegin();
+  FL1 = FL2;
+  *i0; // expected-warning{{Invalidated iterator accessed}}
+}
Index: test/Analysis/diagnostics/explicit-suppression.cpp
===
--- test/Analysis/diagnostics/explicit-suppression.cpp
+++ test/Analysis/diagnostics/explicit-suppression.cpp
@@ -19,6 +19,6 @@
 void testCopyNull(C *I, C *E) {
   std::copy(I, E, (C *)0);
 #ifndef SUPPRESSED
-  // expected-warning@../Inputs/system-header-simulator-cxx.h:514 {{Called C++ object pointer is null}}
+  // expected-warning@../Inputs/system-header-simulator-cxx.h:554 {{Called C++ object pointer is null}}
 #endif
 }
Index: test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- test/Analysis/Inputs/system-header-simulator-cxx.h
+++ test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -252,6 +252,15 @@
   return size_t(_finish - _start);
 }
 
+vector& operator=(const vector &other);
+vector& operator=(vector &&other);
+vector& operator=(std::initializer_list ilist);
+
+void assign(size_type count, const T &value);
+template 
+void assign(InputIterator first, InputIterator last);
+void assign(std::initializer_list ilist);
+
 void clear();
 
 void push_back(const T &value);
@@ -301,8 +310,21 @@
 list& operator=(list &&other);
 list& operator=(std::initializer_list ilist);
 
+void assign(size_type count, const T &value);
+template 
+void assign(InputIterator first, InputIterator last);
+void assign(std::initializer_list ilist);
+
 void clear();
 
+void push_back(const T &value);
+void push_back(T &&value);
+void pop_back();
+
+void push_front(const T &value);
+void push_front(T &&value);
+void pop_front();
+
 iterator begin() { return iterator(_start); }
 const_iterator begin() const { return const_iterator(_start); }
 const_iterator cbegin() const { return const_iterator(_start); }
@@ -338,6 +360,15 @@
   return size_t(_finish - _start);
 }
 
+deque& operator=(const deque &other);
+deque& operator=(deque &&other);
+deque& operator=(std::initializer_list ilist);
+
+void assign(size_type count, const T &value);
+template 
+void assign(InputIterator first, InputIterator last);
+void assign(std::initializer_list ilist);
+
 void clear();
 
 void push_back(const T &value);
@@ -351,11 +382,11 @@
 T &operator[](size_t n) {
   return _start[n];
 }
-
+
 const T &operator[](size_t n) const {
   return _start[n];
 }
-
+
 iterator begin() { return iterator(_start); }
 const_iterator begin() const { return const_iterator(_start); }
 const_iterator cbegin() const { return const_iterator(_start); }
@@ -367,7 +398,7 @@
 T& back() { return *(end() - 1); }
 con

[PATCH] D32747: [Analyzer] Iterator Checker - Part 3: Invalidation check, first for (copy) assignments

2018-08-02 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Yes, it is working now without the hack.


https://reviews.llvm.org/D32747



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


Re: r338552 - Add REQUIRES: native to a test that assumes it

2018-08-02 Thread Hans Wennborg via cfe-commits
Merged to 6.0 in r338687.

On Wed, Aug 1, 2018 at 3:41 PM, Filipe Cabecinhas via cfe-commits
 wrote:
> Author: filcab
> Date: Wed Aug  1 06:41:11 2018
> New Revision: 338552
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338552&view=rev
> Log:
> Add REQUIRES: native to a test that assumes it
>
> Modified:
> cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c
>
> Modified: cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c?rev=338552&r1=338551&r2=338552&view=diff
> ==
> --- cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c (original)
> +++ cfe/trunk/test/Driver/darwin-infer-simulator-sdkroot.c Wed Aug  1 
> 06:41:11 2018
> @@ -1,6 +1,6 @@
>  // Check that SDKROOT does not infer simulator on when it points to a regular
>  // SDK.
> -// REQUIRES: system-darwin
> +// REQUIRES: system-darwin && native
>  //
>  // RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
>  // RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
>
>
> ___
> 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: r338553 - Use a dummy target so the test passes when default target is for a toolchain implements useIntegratedAs() -> true

2018-08-02 Thread Hans Wennborg via cfe-commits
Merged to 7.0 in r338688.

On Wed, Aug 1, 2018 at 3:41 PM, Filipe Cabecinhas via cfe-commits
 wrote:
> Author: filcab
> Date: Wed Aug  1 06:41:42 2018
> New Revision: 338553
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338553&view=rev
> Log:
> Use a dummy target so the test passes when default target is for a toolchain 
> implements useIntegratedAs() -> true
>
> Modified:
> cfe/trunk/test/Driver/integrated-as.c
>
> Modified: cfe/trunk/test/Driver/integrated-as.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/integrated-as.c?rev=338553&r1=338552&r2=338553&view=diff
> ==
> --- cfe/trunk/test/Driver/integrated-as.c (original)
> +++ cfe/trunk/test/Driver/integrated-as.c Wed Aug  1 06:41:42 2018
> @@ -7,7 +7,7 @@
>
>  // FIAS: cc1as
>
> -// RUN: %clang -### -fno-integrated-as -S %s 2>&1 \
> +// RUN: %clang -target none -### -fno-integrated-as -S %s 2>&1 \
>  // RUN: | FileCheck %s -check-prefix NOFIAS
>
>  // NOFIAS-NOT: cc1as
>
>
> ___
> 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] D50154: [clangd] capitalize diagnostic messages if '-capitialize-diagnostic-text' is provided

2018-08-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Is it possible for clangd to always capitalize diagnostics if 
`-capitialize-diagnostic-text` is found in the compile comand?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50154



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


[clang-tools-extra] r338696 - Replace hardcoded format styles in a few tools with the default style in libFormat.

2018-08-02 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu Aug  2 03:30:56 2018
New Revision: 338696

URL: http://llvm.org/viewvc/llvm-project?rev=338696&view=rev
Log:
Replace hardcoded format styles in a few tools with the default style in 
libFormat.

Modified:
clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp

clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
clang-tools-extra/trunk/clang-move/ClangMove.cpp
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=338696&r1=338695&r2=338696&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Thu Aug  2 
03:30:56 2018
@@ -989,7 +989,8 @@ void ChangeNamespaceTool::onEndOfTransla
 // Add replacements referring to the changed code to existing replacements,
 // which refers to the original code.
 Replaces = Replaces.merge(NewReplacements);
-auto Style = format::getStyle("file", FilePath, FallbackStyle);
+auto Style =
+format::getStyle(format::DefaultFormatStyle, FilePath, FallbackStyle);
 if (!Style) {
   llvm::errs() << llvm::toString(Style.takeError()) << "\n";
   continue;

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp?rev=338696&r1=338695&r2=338696&view=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
 Thu Aug  2 03:30:56 2018
@@ -97,8 +97,8 @@ int main(int argc, char **argv) {
   IntrusiveRefCntPtr(new DiagnosticIDs()), DiagOpts.get());
 
   // Determine a formatting style from options.
-  auto FormatStyleOrError =
-  format::getStyle(FormatStyleOpt, FormatStyleConfig, "LLVM");
+  auto FormatStyleOrError = format::getStyle(FormatStyleOpt, FormatStyleConfig,
+ format::DefaultFallbackStyle);
   if (!FormatStyleOrError) {
 llvm::errs() << llvm::toString(FormatStyleOrError.takeError()) << "\n";
 return 1;

Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=338696&r1=338695&r2=338696&view=diff
==
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Thu Aug  2 03:30:56 2018
@@ -795,7 +795,8 @@ void ClangMoveTool::removeDeclsInOldFile
 // Ignore replacements for new.h/cc.
 if (SI == FilePathToFileID.end()) continue;
 llvm::StringRef Code = SM.getBufferData(SI->second);
-auto Style = format::getStyle("file", FilePath, Context->FallbackStyle);
+auto Style = format::getStyle(format::DefaultFormatStyle, FilePath,
+  Context->FallbackStyle);
 if (!Style) {
   llvm::errs() << llvm::toString(Style.takeError()) << "\n";
   continue;

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=338696&r1=338695&r2=338696&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Thu Aug  2 
03:30:56 2018
@@ -324,7 +324,8 @@ int includeFixerMain(int argc, const cha
const IncludeFixerContext::HeaderInfo &RHS) {
   return LHS.QualifiedName == RHS.QualifiedName;
 });
-auto InsertStyle = format::getStyle("file", Context.getFilePath(), Style);
+auto InsertStyle = format::getStyle(format::DefaultFormatStyle,
+Context.getFilePath(), Style);
 if (!InsertStyle) {
   llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n";
   return 1;
@@ -402,7 +403,8 @@ int includeFixerMain(int argc, const cha
   std::vector FixerReplacements;
   for (const auto &Context : Contexts) {
 StringRef FilePath = Context.getFilePath();
-auto InsertStyle = format::getStyle("file", FilePath, Style);
+auto InsertStyle =
+format::getStyle(format::DefaultFormatStyle, FilePath, Style);
 if (!InsertStyle) {
   llvm::errs() << llvm::toString(InsertStyle.takeError()) << "\n";
   return 1;



[PATCH] D50175: [AArch64][NFC] better matching of AArch64 target in aarch64-cpus.c tests

2018-08-02 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: olista01, ab.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.

In https://reviews.llvm.org/D50068, @ab noticed that it would be better to 
match aarch64-{{.*}} for
tests that use "-target aarch64_be -mlittle-endian" instead of just
aarch64{{.*}}.


https://reviews.llvm.org/D50175

Files:
  test/Driver/aarch64-cpus.c

Index: test/Driver/aarch64-cpus.c
===
--- test/Driver/aarch64-cpus.c
+++ test/Driver/aarch64-cpus.c
@@ -4,9 +4,10 @@
 // RUN: %clang -target aarch64 -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s
 // RUN: %clang -target aarch64 -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s
-// RUN: %clang -target aarch64_be -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s
-// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC %s
-// GENERIC: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic"
+// RUN: %clang -target aarch64_be -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC-LE %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=GENERIC-LE %s
+// GENERIC: "-cc1"{{.*}} "-triple" "aarch64"{{.*}} "-target-cpu" "generic"
+// GENERIC-LE: "-cc1"{{.*}} "-triple" "aarch64--"{{.*}} "-target-cpu" "generic"
 
 // RUN: %clang -target arm64 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s
 // RUN: %clang -target arm64 -mcpu=generic -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERIC %s
@@ -25,12 +26,14 @@
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35 %s
-// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35 %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-LE %s
 // RUN: %clang -target aarch64 -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s
 // RUN: %clang -target aarch64 -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s
-// RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE %s
-// CA35: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a35"
-// CA35-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic"
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=CA35-TUNE-LE %s
+// CA35: "-cc1"{{.*}} "-triple" "aarch64"{{.*}} "-target-cpu" "cortex-a35"
+// CA35-LE: "-cc1"{{.*}} "-triple" "aarch64--"{{.*}} "-target-cpu" "cortex-a35"
+// CA35-TUNE: "-cc1"{{.*}} "-triple" "aarch64"{{.*}} "-target-cpu" "generic"
+// CA35-TUNE-LE: "-cc1"{{.*}} "-triple" "aarch64--"{{.*}} "-target-cpu" "generic"
 
 // RUN: %clang -target arm64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA35 %s
 // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA35 %s
@@ -41,11 +44,13 @@
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s
-// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53 %s
+// RUN: %clang -target aarch64_be -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-LE %s
 // RUN: %clang -target aarch64 -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-TUNE %s
-// RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-TUNE %s
-// CA53: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a53"
-// CA53-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic"
+// RUN: %clang -target aarch64_be -mlittle-endian -mtune=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=CA53-TUNE-LE %s
+// CA53: "-cc1"{{.*}} "-triple" "aarch64"{{.*}} "-target-cpu" "cortex-a53"
+// CA53-LE: "-cc1"{{.*}} "-triple" "aarch64--"{{.*}} "-target-cpu" "cortex-a53"
+// CA53-TUNE: "-cc1"{{.*}} "-triple" "aarch64"{{.*}} "-target-cpu" "generic"
+// CA53-TUNE-LE: "-cc1"{{.*}} "-triple" "aarch64--"{{.*}} "-target-cpu" "generic"
 
 // RUN: %clang -target arm64 -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s
 // RUN: %clang -target arm64 -mlittle-endian -mcpu=cortex-a53 -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-CA53 %s
@@ -56,11 +61,13 @@
 
 // RUN: %cl

[PATCH] D48341: [clang-doc] Refactoring mapper to map by scope

2018-08-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/test/clang-doc/bc-linkage.cpp:106
+// CHECK-0-NEXT: 
+// CHECK-0-NEXT:   
+// CHECK-0-NEXT:blob data = 'InnerClass'

juliehockett wrote:
> ioeric wrote:
> > I'm still a bit concerned about hardcoding a lot of USRs in tests. They are 
> > not interpretable and generally not interesting for testing. Also as they 
> > are auto-generated,   it's hard to tell whether they are actually the 
> > desired USRs. I'm concerned because the maintenance is getting higher as 
> > number of tests grows - everyone changing USR semantics in the future has 
> > to know to regenerate clang-doc tests, this can be annoying and potentially 
> > unmanageable when a small change in clang USR requires changes to many test 
> > files in clang-tools-extra :( Comparing to the value it brings to test USRs 
> > in all tests, I'd still suggest  simply matching them with a `{{.*}}`and 
> > only test USRs in few tests where you are actually interested in them.
> Okay, I updated it to only check the length -- is that reasonable?
Thanks! 

FWIW, I wouldn't check the length either as it seems to add too much overhead; 
I think checking length/USR in one test should get it well covered. 


https://reviews.llvm.org/D48341



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


[PATCH] D50177: clang-format: fix a crash in comment wraps.

2018-08-02 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: krasimir.

Previously, clang-format would crash if it tried to wrap an overlong
single line comment, because two parts of the code inserted a break in
the same location.

  /** heregoesalongcommentwithnospace */

This wasn't previously noticed as it could only trigger for an overlong
single line comment that did have no breaking opportunities except for a
whitespace at the very beginning.

This also introduces a check for JavaScript to not ever wrap a comment
before an opening curly brace:

  /** @mods {donotbreakbeforethecurly} */

This is because some machinery parsing these tags sometimes supports
breaks before a possible `{`, but in some other cases does not.
Previously clang-format was careful never to wrap a line with certain
tags on it. The better solution is to specifically disable wrapping
before the problematic token: this allows wrapping and aligning comments
but still avoids the problem.


Repository:
  rC Clang

https://reviews.llvm.org/D50177

Files:
  lib/Format/BreakableToken.cpp
  unittests/Format/FormatTestComments.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -191,31 +191,32 @@
 
   // Break a single line long jsdoc comment pragma.
   EXPECT_EQ("/**\n"
-" * @returns\n"
-" * {string}\n"
-" * jsdoc line 12\n"
+" * @returns {string} jsdoc line 12\n"
 " */",
 format("/** @returns {string} jsdoc line 12 */",
getGoogleJSStyleWithColumns(20)));
-
   EXPECT_EQ("/**\n"
-" * @returns\n"
-" * {string}\n"
+" * @returns {string}\n"
 " * jsdoc line 12\n"
 " */",
+format("/** @returns {string} jsdoc line 12 */",
+   getGoogleJSStyleWithColumns(25)));
+
+  EXPECT_EQ("/**\n"
+" * @returns {string} jsdoc line 12\n"
+" */",
 format("/** @returns {string} jsdoc line 12  */",
getGoogleJSStyleWithColumns(20)));
 
   // FIXME: this overcounts the */ as a continuation of the 12 when breaking.
   // Related to the FIXME in BreakableBlockComment::getRangeLength.
   EXPECT_EQ("/**\n"
-" * @returns\n"
-" * {string}\n"
-" * jsdoc line\n"
+" * @returns {string}\n"
+" * jsdoc line line\n"
 " * 12\n"
 " */",
-format("/** @returns {string} jsdoc line 12*/",
-   getGoogleJSStyleWithColumns(20)));
+format("/** @returns {string} jsdoc line line 12*/",
+   getGoogleJSStyleWithColumns(25)));
 
   // Fix a multiline jsdoc comment ending in a comment pragma.
   EXPECT_EQ("/**\n"
@@ -2038,27 +2039,32 @@
 
 TEST_F(FormatTestJS, JSDocAnnotations) {
   verifyFormat("/**\n"
-   " * @exports\n"
-   " * {this.is.a.long.path.to.a.Type}\n"
+   " * @exports {this.is.a.long.path.to.a.Type}\n"
" */",
"/**\n"
" * @exports {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
   verifyFormat("/**\n"
-   " * @mods\n"
-   " * {this.is.a.long.path.to.a.Type}\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   "/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
+   " */",
+   getGoogleJSStyleWithColumns(20));
+  verifyFormat("/**\n"
+   " * @mods {this.is.a.long.path.to.a.Type}\n"
" */",
"/**\n"
" * @mods {this.is.a.long.path.to.a.Type}\n"
" */",
getGoogleJSStyleWithColumns(20));
   verifyFormat("/**\n"
-   " * @param\n"
-   " * {this.is.a.long.path.to.a.Type}\n"
+   " * @param {canWrap\n"
+   " * onSpace}\n"
" */",
"/**\n"
-   " * @param {this.is.a.long.path.to.a.Type}\n"
+   " * @param {canWrap onSpace}\n"
" */",
getGoogleJSStyleWithColumns(20));
   verifyFormat("/**\n"
@@ -2083,8 +2089,7 @@
 "  /**\n"
 "   * long long long\n"
 "   * long\n"
-"   * @param\n"
-"   * {this.is.a.long.path.to.a.Type}\n"
+"   * @param {this.is.a.long.path.to.a.Type}\n"
 "   * a\n"
 "   * long long long\n"
 "   * long long\n"
Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@

[PATCH] D50177: clang-format: fix a crash in comment wraps.

2018-08-02 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Great! Thank you!


Repository:
  rC Clang

https://reviews.llvm.org/D50177



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


r338675 - Test commit access

2018-08-02 Thread Michael Wu via cfe-commits
Author: mwu
Date: Thu Aug  2 00:28:11 2018
New Revision: 338675

URL: http://llvm.org/viewvc/llvm-project?rev=338675&view=rev
Log:
Test commit access

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=338675&r1=338674&r2=338675&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Aug  2 00:28:11 2018
@@ -178,7 +178,6 @@ typedef struct CXVersion {
  * A negative value indicates that the cursor is not a function declaration.
  */
 enum CXCursor_ExceptionSpecificationKind {
-
   /**
* The cursor has no exception specification.
*/


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


[PATCH] D50179: [AArch64][ARM] Context sensitive meaning of option "crypto"

2018-08-02 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: olista01, samparker, john.brawn, ab, 
t.p.northover.
Herald added a reviewer: javed.absar.
Herald added subscribers: chrib, kristof.beyls.

For AArch64:

1. Crypto means sm4 + sha3 + sha2 + aes for Armv8.4-A and up,
2. and sha2 + aes for Armv8.3-A and earlier.

And for AArch32:
Crypto means sha2 + aes, because the Armv8.2-A crypto instructions
were added to AArch64 only.


https://reviews.llvm.org/D50179

Files:
  lib/Driver/ToolChains/Arch/AArch64.cpp
  lib/Driver/ToolChains/Arch/ARM.cpp
  test/Driver/arm-features.c
  test/Preprocessor/aarch64-target-features.c

Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -143,6 +143,101 @@
 // CHECK-MARCH-2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-fp-armv8" "-target-feature" "-neon" "-target-feature" "-crc" "-target-feature" "-crypto"
 // CHECK-MARCH-3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "-neon"
 
+// Check +sm4:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+sm4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SM4 %s
+// CHECK-SM4:  "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+sm4"
+//
+// Check +sha3:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+sha3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SHA3 %s
+// CHECK-SHA3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+sha3"
+//
+// Check +sha2:
+//
+// RUN: %clang -target aarch64 -march=armv8.3a+sha2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-SHA2 %s
+// CHECK-SHA2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.{{.}}a" "-target-feature" "+sha2"
+//
+// Check +aes:
+//
+// RUN: %clang -target aarch64 -march=armv8.3a+aes -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-AES %s
+// CHECK-AES: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.{{.}}a" "-target-feature" "+aes"
+//
+// Check -sm4:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+noSM4 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SM4 %s
+// CHECK-NO-SM4:  "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sm4"
+//
+// Check -sha3:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+noSHA3 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SHA3 %s
+// CHECK-NO-SHA3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sha3"
+//
+// Check -sha2:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+noSHA2 -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-SHA2 %s
+// CHECK-NO-SHA2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-sha2"
+//
+// Check -aes:
+//
+// RUN: %clang -target aarch64 -march=armv8.2a+noAES -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NO-AES %s
+// CHECK-NO-AES: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "-aes"
+//
+//
+// Arch <= ARMv8.3:  crypto = sha2 + aes
+// -
+//
+// Check +crypto:
+//
+// RUN: %clang -target aarch64 -march=armv8a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// RUN: %clang -target aarch64 -march=armv8.1a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// RUN: %clang -target aarch64 -march=armv8.2a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// RUN: %clang -target aarch64 -march=armv8.3a+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// RUN: %clang -target aarch64 -march=armv8a+crypto+nocrypto+crypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-CRYPTO83 %s
+// CHECK-CRYPTO83: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+crypto" "-target-feature" "+sha2" "-target-feature" "+aes"
+//
+// Check -crypto:
+//
+// RUN: %clang -target aarch64 -march=armv8a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO8A %s
+// RUN: %clang -target aarch64 -march=armv8.1a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO81 %s
+// RUN: %clang -target aarch64 -march=armv8.2a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s
+// RUN: %clang -target aarch64 -march=armv8.3a+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s
+// RUN: %clang -target aarch64 -march=armv8.3a+nocrypto+crypto+nocrypto -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-NOCRYPTO82 %s
+
+// CHECK-NOCRYPTO8A: "-target-feature" "+neon" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-abi" "aapcs"
+// CHECK-NOCRYPTO81: "-target-feature" "+neon" "-target-feature" "+v8.1a" "-target-feature" "-crypto" "-target-feature" "-sha2" "-target-feature" "-aes" "-target-abi" "aapcs"
+// CHECK-NOCRYPTO82: "-target-feature" "+neon" "-target-feature" "+v8.{{.}}a" "-target-feature" "-crypto" "-tar

[PATCH] D50154: [clangd] capitalize diagnostic messages if '-capitialize-diagnostic-text' is provided

2018-08-02 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added subscribers: simark, malaperle.
ilya-biryukov added a comment.

Maybe we could simply always capitalize the messages? Any cons to capitalizing 
error messages?
@simark, @malaperle, @ioeric, @hokein, WDYT?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50154



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


[PATCH] D50055: Update the coding standard about NFC changes and whitespace

2018-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 158731.
aaron.ballman added a comment.

Updating based on review feedback.


https://reviews.llvm.org/D50055

Files:
  docs/CodingStandards.rst
  docs/DeveloperPolicy.rst
  docs/Lexicon.rst


Index: docs/Lexicon.rst
===
--- docs/Lexicon.rst
+++ docs/Lexicon.rst
@@ -185,6 +185,7 @@
 
 N
 -
+.. _nfc:
 
 **NFC**
   "No functional change". Used in a commit message to indicate that a patch
Index: docs/DeveloperPolicy.rst
===
--- docs/DeveloperPolicy.rst
+++ docs/DeveloperPolicy.rst
@@ -376,7 +376,13 @@
obvious. This is clearly a subjective decision --- we simply expect you to
use good judgement.  Examples include: fixing build breakage, reverting
obviously broken patches, documentation/comment changes, any other minor
-   changes.
+   changes. Avoid committing formatting- or whitespace-only changes outside of
+   code you plan to make subsequent changes to. Also, try to separate
+   formatting or whitespace changes from functional changes, either by
+   correcting the format first (ideally) or afterward. Such changes should be
+   highly localized and the commit message should clearly state that the commit
+   is not intended to change functionality, usually by stating it is
+   :ref:`NFC `.
 
 #. You are allowed to commit patches without approval to those portions of LLVM
that you have contributed or maintain (i.e., have been assigned
Index: docs/CodingStandards.rst
===
--- docs/CodingStandards.rst
+++ docs/CodingStandards.rst
@@ -494,8 +494,8 @@
 This is one of many contentious issues in coding standards, but it is not up 
for
 debate.
 
-Use Spaces Instead of Tabs
-^^
+Whitespace
+^^
 
 In all cases, prefer spaces to tabs in source files.  People have different
 preferred indentation levels, and different styles of indentation that they
@@ -509,6 +509,12 @@
 of indentation.  Also, do not reindent a whole source file: it makes for
 incredible diffs that are absolutely worthless.
 
+Do not commit changes that include trailing whitespace. If you find trailing
+whitespace in a file, do not remove it unless you're otherwise changing that
+line of code. Some common editors will automatically remove trailing whitespace
+when saving a file which causes unrelated changes to appear in diffs and
+commits.
+
 Indent Code Consistently
 
 


Index: docs/Lexicon.rst
===
--- docs/Lexicon.rst
+++ docs/Lexicon.rst
@@ -185,6 +185,7 @@
 
 N
 -
+.. _nfc:
 
 **NFC**
   "No functional change". Used in a commit message to indicate that a patch
Index: docs/DeveloperPolicy.rst
===
--- docs/DeveloperPolicy.rst
+++ docs/DeveloperPolicy.rst
@@ -376,7 +376,13 @@
obvious. This is clearly a subjective decision --- we simply expect you to
use good judgement.  Examples include: fixing build breakage, reverting
obviously broken patches, documentation/comment changes, any other minor
-   changes.
+   changes. Avoid committing formatting- or whitespace-only changes outside of
+   code you plan to make subsequent changes to. Also, try to separate
+   formatting or whitespace changes from functional changes, either by
+   correcting the format first (ideally) or afterward. Such changes should be
+   highly localized and the commit message should clearly state that the commit
+   is not intended to change functionality, usually by stating it is
+   :ref:`NFC `.
 
 #. You are allowed to commit patches without approval to those portions of LLVM
that you have contributed or maintain (i.e., have been assigned
Index: docs/CodingStandards.rst
===
--- docs/CodingStandards.rst
+++ docs/CodingStandards.rst
@@ -494,8 +494,8 @@
 This is one of many contentious issues in coding standards, but it is not up for
 debate.
 
-Use Spaces Instead of Tabs
-^^
+Whitespace
+^^
 
 In all cases, prefer spaces to tabs in source files.  People have different
 preferred indentation levels, and different styles of indentation that they
@@ -509,6 +509,12 @@
 of indentation.  Also, do not reindent a whole source file: it makes for
 incredible diffs that are absolutely worthless.
 
+Do not commit changes that include trailing whitespace. If you find trailing
+whitespace in a file, do not remove it unless you're otherwise changing that
+line of code. Some common editors will automatically remove trailing whitespace
+when saving a file which causes unrelated changes to appear in diffs and
+commits.
+
 Indent Code Consistently
 
 
___
cfe-commits mailing list
cfe-commits@lists

[PATCH] D50154: [clangd] capitalize diagnostic messages if '-capitialize-diagnostic-text' is provided

2018-08-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D50154#1185545, @ilya-biryukov wrote:

> Maybe we could simply always capitalize the messages? Any cons to 
> capitalizing error messages?
>  @simark, @malaperle, @ioeric, @hokein, WDYT?


Oh sorry, I thought `-capitialize-diagnostic-text` was an existing clang flag, 
in which case we should respect it. I don't think there is any con that I could 
think of, as long as it looks nice in clients :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50154



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


[PATCH] D50177: clang-format: fix a crash in comment wraps.

2018-08-02 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338706: clang-format: fix a crash in comment wraps. 
(authored by mprobst, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D50177

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

Index: cfe/trunk/lib/Format/BreakableToken.cpp
===
--- cfe/trunk/lib/Format/BreakableToken.cpp
+++ cfe/trunk/lib/Format/BreakableToken.cpp
@@ -67,10 +67,11 @@
  unsigned ContentStartColumn,
  unsigned ColumnLimit,
  unsigned TabWidth,
- encoding::Encoding Encoding) {
-  LLVM_DEBUG(llvm::dbgs() << "Comment split: \"" << Text << ", " << ColumnLimit
-  << "\", Content start: " << ContentStartColumn
-  << "\n");
+ encoding::Encoding Encoding,
+ const FormatStyle &Style) {
+  LLVM_DEBUG(llvm::dbgs() << "Comment split: \"" << Text
+  << "\", Column limit: " << ColumnLimit
+  << ", Content start: " << ContentStartColumn << "\n");
   if (ColumnLimit <= ContentStartColumn + 1)
 return BreakableToken::Split(StringRef::npos, 0);
 
@@ -95,6 +96,13 @@
   if (SpaceOffset != StringRef::npos &&
   kNumberedListRegexp->match(Text.substr(SpaceOffset).ltrim(Blanks)))
 SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
+  // In JavaScript, some @tags can be followed by {, and machinery that parses
+  // these comments will fail to understand the comment if followed by a line
+  // break. So avoid ever breaking before a {.
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  SpaceOffset != StringRef::npos && SpaceOffset + 1 < Text.size() &&
+  Text[SpaceOffset + 1] == '{')
+SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
 
   if (SpaceOffset == StringRef::npos ||
   // Don't break at leading whitespace.
@@ -109,6 +117,12 @@
 Blanks, std::max(MaxSplitBytes, FirstNonWhitespace));
   }
   if (SpaceOffset != StringRef::npos && SpaceOffset != 0) {
+// adaptStartOfLine will break after lines starting with /** if the comment
+// is broken anywhere. Avoid emitting this break twice here.
+// Example: in /** longtextcomesherethatbreaks */ (with ColumnLimit 20) will
+// insert a break after /**, so this code must not insert the same break.
+if (SpaceOffset == 1 && Text[SpaceOffset - 1] == '*')
+  return BreakableToken::Split(StringRef::npos, 0);
 StringRef BeforeCut = Text.substr(0, SpaceOffset).rtrim(Blanks);
 StringRef AfterCut = Text.substr(SpaceOffset).ltrim(Blanks);
 return BreakableToken::Split(BeforeCut.size(),
@@ -260,7 +274,7 @@
 return Split(StringRef::npos, 0);
   return getCommentSplit(Content[LineIndex].substr(TailOffset),
  ContentStartColumn, ColumnLimit, Style.TabWidth,
- Encoding);
+ Encoding, Style);
 }
 
 void BreakableComment::compressWhitespace(
@@ -620,6 +634,8 @@
 if (DelimitersOnNewline) {
   // Since we're breaking at index 1 below, the break position and the
   // break length are the same.
+  // Note: this works because getCommentSplit is careful never to split at
+  // the beginning of a line.
   size_t BreakLength = Lines[0].substr(1).find_first_not_of(Blanks);
   if (BreakLength != StringRef::npos)
 insertBreak(LineIndex, 0, Split(1, BreakLength), /*ContentIndent=*/0,
Index: cfe/trunk/unittests/Format/FormatTestComments.cpp
===
--- cfe/trunk/unittests/Format/FormatTestComments.cpp
+++ cfe/trunk/unittests/Format/FormatTestComments.cpp
@@ -1254,6 +1254,12 @@
" */",
getLLVMStyleWithColumns(20)));
 
+  // This reproduces a crashing bug where both adaptStartOfLine and
+  // getCommentSplit were trying to wrap after the "/**".
+  EXPECT_EQ("/** multilineblockcommentwithnowrapopportunity */",
+format("/** multilineblockcommentwithnowrapopportunity */",
+   getLLVMStyleWithColumns(20)));
+
   EXPECT_EQ("/*\n"
 "\n"
 "\n"
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -191,31 +191,32 @@
 
   // Break a single line long jsdoc comment pragma.
   EXPECT_EQ("/**\n"
-" * @returns\n"
-" * {string}\n"
-" * jsdoc line 12\n"
+

r338706 - clang-format: fix a crash in comment wraps.

2018-08-02 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Thu Aug  2 04:52:08 2018
New Revision: 338706

URL: http://llvm.org/viewvc/llvm-project?rev=338706&view=rev
Log:
clang-format: fix a crash in comment wraps.

Summary:
Previously, clang-format would crash if it tried to wrap an overlong
single line comment, because two parts of the code inserted a break in
the same location.

/** heregoesalongcommentwithnospace */

This wasn't previously noticed as it could only trigger for an overlong
single line comment that did have no breaking opportunities except for a
whitespace at the very beginning.

This also introduces a check for JavaScript to not ever wrap a comment
before an opening curly brace:

/** @mods {donotbreakbeforethecurly} */

This is because some machinery parsing these tags sometimes supports
breaks before a possible `{`, but in some other cases does not.
Previously clang-format was careful never to wrap a line with certain
tags on it. The better solution is to specifically disable wrapping
before the problematic token: this allows wrapping and aligning comments
but still avoids the problem.

Reviewers: krasimir

Subscribers: cfe-commits

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

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

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=338706&r1=338705&r2=338706&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Thu Aug  2 04:52:08 2018
@@ -67,10 +67,11 @@ static BreakableToken::Split getCommentS
  unsigned ContentStartColumn,
  unsigned ColumnLimit,
  unsigned TabWidth,
- encoding::Encoding Encoding) {
-  LLVM_DEBUG(llvm::dbgs() << "Comment split: \"" << Text << ", " << ColumnLimit
-  << "\", Content start: " << ContentStartColumn
-  << "\n");
+ encoding::Encoding Encoding,
+ const FormatStyle &Style) {
+  LLVM_DEBUG(llvm::dbgs() << "Comment split: \"" << Text
+  << "\", Column limit: " << ColumnLimit
+  << ", Content start: " << ContentStartColumn << 
"\n");
   if (ColumnLimit <= ContentStartColumn + 1)
 return BreakableToken::Split(StringRef::npos, 0);
 
@@ -95,6 +96,13 @@ static BreakableToken::Split getCommentS
   if (SpaceOffset != StringRef::npos &&
   kNumberedListRegexp->match(Text.substr(SpaceOffset).ltrim(Blanks)))
 SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
+  // In JavaScript, some @tags can be followed by {, and machinery that parses
+  // these comments will fail to understand the comment if followed by a line
+  // break. So avoid ever breaking before a {.
+  if (Style.Language == FormatStyle::LK_JavaScript &&
+  SpaceOffset != StringRef::npos && SpaceOffset + 1 < Text.size() &&
+  Text[SpaceOffset + 1] == '{')
+SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
 
   if (SpaceOffset == StringRef::npos ||
   // Don't break at leading whitespace.
@@ -109,6 +117,12 @@ static BreakableToken::Split getCommentS
 Blanks, std::max(MaxSplitBytes, FirstNonWhitespace));
   }
   if (SpaceOffset != StringRef::npos && SpaceOffset != 0) {
+// adaptStartOfLine will break after lines starting with /** if the comment
+// is broken anywhere. Avoid emitting this break twice here.
+// Example: in /** longtextcomesherethatbreaks */ (with ColumnLimit 20) 
will
+// insert a break after /**, so this code must not insert the same break.
+if (SpaceOffset == 1 && Text[SpaceOffset - 1] == '*')
+  return BreakableToken::Split(StringRef::npos, 0);
 StringRef BeforeCut = Text.substr(0, SpaceOffset).rtrim(Blanks);
 StringRef AfterCut = Text.substr(SpaceOffset).ltrim(Blanks);
 return BreakableToken::Split(BeforeCut.size(),
@@ -260,7 +274,7 @@ BreakableComment::getSplit(unsigned Line
 return Split(StringRef::npos, 0);
   return getCommentSplit(Content[LineIndex].substr(TailOffset),
  ContentStartColumn, ColumnLimit, Style.TabWidth,
- Encoding);
+ Encoding, Style);
 }
 
 void BreakableComment::compressWhitespace(
@@ -620,6 +634,8 @@ void BreakableBlockComment::adaptStartOf
 if (DelimitersOnNewline) {
   // Since we're breaking at index 1 below, the break position and the
   // break length are the same.
+  // Note: this works because getCommentSplit is careful never to split at
+  // the beginning of a line.
   size_t BreakL

[PATCH] D50055: Update the coding standard about NFC changes and whitespace

2018-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 2 inline comments as done.
aaron.ballman added inline comments.



Comment at: docs/CodingStandards.rst:512
 
+Do not commit changes that include trailing whitespace. Some common editors 
will
+automatically remove trailing whitespace when saving a file which causes

hfinkel wrote:
> This statement is confusing (mostly because it has two reasonable 
> interpretations and I think you actually mean both). We should say two 
> separate things:
> 
>  1. As a coding guideline, make sure that lines don't have trailing 
> whitespace.
>  2. If such whitespace exists, don't remove it unless you're otherwise 
> changing that line of code (and here we can caution people about their 
> editors).
> 
Good point; I've made those changes.



Comment at: docs/DeveloperPolicy.rst:395-408
+Commits with No Functional Change
+-
+
+It may be permissible to commit changes without prior review when the changes
+have no semantic impact on the code if the changes being made are obvious and
+not invasive. For instance, removing trailing whitespace from a line, fixing a
+line ending to be consistent with the rest of the file, fixing a typo, code

chandlerc wrote:
> hubert.reinterpretcast wrote:
> > hfinkel wrote:
> > > aaron.ballman wrote:
> > > > chandlerc wrote:
> > > > > I think this is a much broader statement than is warranted to address 
> > > > > the specific problem. And I'm not completely comfortable with it.
> > > > > 
> > > > > I don't think guidance around "no functional change" is the right way 
> > > > > to give guidance about what is or isn't "obvious" and fine to commit 
> > > > > with post-commit review personally.
> > > > > 
> > > > > I'd really suggest just being direct about *formatting* and 
> > > > > whitespace changes, and specifically suggest that they not be made 
> > > > > unless the file or code region in question is an area that the author 
> > > > > is planning subsequent changes to.
> > > > We talk about formatting and whitespace in the CodingStandards 
> > > > document, but we talk about obviousness and post-commit review in 
> > > > DeveloperPolicy. Where would you like these new words to live? To me, 
> > > > they're more about the policy and less about the coding standard -- the 
> > > > coding standard says what the code should look like and the policy says 
> > > > what you should and should not do procedurally, but then I feel the 
> > > > need to tie it back to "obviousness". How about this in the developer 
> > > > policy:
> > > > ```
> > > > The Obviousness of Formatting Changes
> > > > -
> > > > 
> > > > While formatting and whitespace changes may be "obvious", they can also 
> > > > create
> > > > needless churn that causes difficulties for out-of-tree users carrying 
> > > > local
> > > > patches. Do not commit formatting or whitespace changes unless they are 
> > > > related
> > > > to a file or code region that you intend to make subsequent changes to. 
> > > > The
> > > > formatting and whitespace changes should be highly localized, committed 
> > > > before
> > > > you begin functionality-changing work on the code region, and the 
> > > > commit message
> > > > should clearly state that the commit is not intended to change 
> > > > functionality,
> > > > usually by stating it is :ref:`NFC `.
> > > > 
> > > > 
> > > > If you wish to make a change to formatting or whitespace that touches 
> > > > an entire
> > > > library or code base, please seek pre-commit approval first.
> > > > ```
> > > I agree with @chandlerc about the current proposed text, and I think that 
> > > this is better. I wonder if we want to insist on separating the commits, 
> > > of if, combined localized commits are okay?
> > > 
> > It depends on how much noise there is when combining the commits; and when 
> > evaluating for that, we have to remember that people use different diff 
> > tools.
> I like Hal's separation in the other comment.
> 
> Here, I tihnk we can address all of this by making this more of a (strong) 
> suggestion and not a hard rule.
> 
> "Avoid committing formatting or whitespace only changes outside of code you 
> plan to make subsequent changes to." or something similar.
> 
> Then it also becomes natural to suggest:
> 
> "Also, try to separate formatting or whitespace changes from functional 
> changes, either by correcting the format first (ideally) or afterward."
> 
> I think you can also shorten some of the discussion along these lines.
Good suggestions! This made the wording short enough that I rolled it in with 
the "obvious" wording above.


https://reviews.llvm.org/D50055



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


r338707 - Try to make builtin address space declarations not useless

2018-08-02 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Thu Aug  2 05:14:28 2018
New Revision: 338707

URL: http://llvm.org/viewvc/llvm-project?rev=338707&view=rev
Log:
Try to make builtin address space declarations not useless

The way address space declarations for builtins currently work
is nearly useless. The code assumes the address spaces used for
builtins is a confusingly named "target address space" from user
code using __attribute__((address_space(N))) that matches
the builtin declaration. There's no way to use this to declare
a builtin that returns a language specific address space.
The terminology used is highly cofusing since it has nothing
to do with the the address space selected by the target to use
for a language address space.

This feature is essentially unused as-is. AMDGPU and NVPTX
are the only in-tree targets attempting to use this. The AMDGPU
builtins certainly do not behave as intended (i.e. all of the
builtins returning pointers can never compile because the numbered
address space never matches the expected named address space).

The NVPTX builtins are missing tests for some, and the others
seem to rely on an implicit addrspacecast.

Change the used address space for builtins based on a target
hook to allow using a language address space for a builtin.
This allows the same builtin declaration to be used for multiple
languages with similarly purposed address spaces (e.g. the same
AMDGPU builtin can be used in OpenCL and CUDA even though the
constant address spaces are arbitarily different).

This breaks the possibility of using arbitrary numbered
address spaces alongside the named address spaces for builtins.
If this is an issue we probably need to introduce another builtin
declaration character to distinguish language address spaces from
so-called "target address spaces".

Added:
cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
cfe/trunk/test/CodeGenOpenCL/numbered-address-space.cl
cfe/trunk/test/SemaOpenCL/numbered-address-space.cl
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/Targets/AMDGPU.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=338707&r1=338706&r2=338707&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Aug  2 05:14:28 2018
@@ -2488,6 +2488,8 @@ public:
 
   unsigned getTargetAddressSpace(LangAS AS) const;
 
+  LangAS getLangASForBuiltinAddressSpace(unsigned AS) const;
+
   /// Get target-dependent integer value for null pointer which is used for
   /// constant folding.
   uint64_t getTargetNullPointerValue(QualType QT) const;

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=338707&r1=338706&r2=338707&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Thu Aug  2 05:14:28 2018
@@ -21,9 +21,9 @@
 // SI+ only builtins.
 
//===--===//
 
-BUILTIN(__builtin_amdgcn_dispatch_ptr, "Uc*4", "nc")
-BUILTIN(__builtin_amdgcn_kernarg_segment_ptr, "Uc*4", "nc")
-BUILTIN(__builtin_amdgcn_implicitarg_ptr, "Uc*4", "nc")
+BUILTIN(__builtin_amdgcn_dispatch_ptr, "v*4", "nc")
+BUILTIN(__builtin_amdgcn_kernarg_segment_ptr, "v*4", "nc")
+BUILTIN(__builtin_amdgcn_implicitarg_ptr, "v*4", "nc")
 
 BUILTIN(__builtin_amdgcn_workgroup_id_x, "Ui", "nc")
 BUILTIN(__builtin_amdgcn_workgroup_id_y, "Ui", "nc")
@@ -45,6 +45,8 @@ BUILTIN(__builtin_amdgcn_s_barrier, "v",
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_s_dcache_inv, "v", "n")
 BUILTIN(__builtin_amdgcn_buffer_wbinvl1, "v", "n")
+
+// FIXME: Need to disallow constant address space.
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")
 BUILTIN(__builtin_amdgcn_div_scalef, "fffbb*", "n")
 BUILTIN(__builtin_amdgcn_div_fmas, "b", "nc")
@@ -93,9 +95,9 @@ BUILTIN(__builtin_amdgcn_ds_bpermute, "i
 BUILTIN(__builtin_amdgcn_readfirstlane, "ii", "nc")
 BUILTIN(__builtin_amdgcn_readlane, "iii", "nc")
 BUILTIN(__builtin_amdgcn_fmed3f, "", "nc")
-BUILTIN(__builtin_amdgcn_ds_faddf, "ff*fIiIiIb", "n")
-BUILTIN(__builtin_amdgcn_ds_fminf, "ff*fIiIiIb", "n")
-BUILTIN(__builtin_amdgcn_ds_fmaxf, "ff*fIiIiIb", "n")
+BUILTIN(__builtin_amdgcn_ds_faddf, "ff*3fIiIiIb", "n")
+BUILTIN(__builtin_amdgcn_ds_fminf, "ff*3fIiIiIb", "n")
+BUILTIN(__builtin_amdgcn_ds_fmaxf, "ff*3fIiIiIb", "n")
 
 
//===---

[PATCH] D47154: Try to make builtin address space declarations not useless

2018-08-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r338707


https://reviews.llvm.org/D47154



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


[PATCH] D50154: [clangd] capitalize diagnostic messages if '-capitialize-diagnostic-text' is provided

2018-08-02 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment.

That's fine with me.  I'll try it and time will tell if I like it or not :).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50154



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


[PATCH] D45719: [clang-Format] Fix indentation of member call after block

2018-08-02 Thread Anders Karlsson via Phabricator via cfe-commits
ank updated this revision to Diff 158737.
ank added a comment.

fix space in if (


Repository:
  rC Clang

https://reviews.llvm.org/D45719

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4416,6 +4416,40 @@
   verifyFormat(".(\n"
"aa)\n"
".aa();");
+
+  // Dont break if only closing statements before member call
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  }).foo();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  (\n"
+   "  []() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  },\n"
+   "  foo, bar)\n"
+   "  .foo();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  })\n"
+   "  .foo()\n"
+   "  .bar();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  })\n"
+   "  .foo(\"a\"\n"
+   "   \"\");\n"
+   "}",
+   getLLVMStyleWithColumns(30));
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -325,6 +325,14 @@
   }
   template  bool isNot(T Kind) const { return !is(Kind); }
 
+  bool closesScopeAfterBlock() const {
+if (BlockKind == BK_Block)
+  return true;
+if (closesScope())
+  return Previous->closesScopeAfterBlock();
+return false;
+  }
+
   /// \c true if this token starts a sequence with the given tokens in order,
   /// following the ``Next`` pointers, ignoring comments.
   template 
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -403,7 +403,9 @@
   //   }.bind(...));
   // FIXME: We should find a more generic solution to this problem.
   !(State.Column <= NewLineColumn &&
-Style.Language == FormatStyle::LK_JavaScript))
+Style.Language == FormatStyle::LK_JavaScript) &&
+  !(Previous.closesScopeAfterBlock() &&
+State.Column <= NewLineColumn))
 return true;
 
   // If the template declaration spans multiple lines, force wrap before the


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4416,6 +4416,40 @@
   verifyFormat(".(\n"
"aa)\n"
".aa();");
+
+  // Dont break if only closing statements before member call
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  }).foo();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  (\n"
+   "  []() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  },\n"
+   "  foo, bar)\n"
+   "  .foo();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  })\n"
+   "  .foo()\n"
+   "  .bar();\n"
+   "}");
+  verifyFormat("test() {\n"
+   "  ([]() -> {\n"
+   "int b = 32;\n"
+   "return 3;\n"
+   "  })\n"
+   "  .foo(\"a\"\n"
+   "   \"\");\n"
+   "}",
+   getLLVMStyleWithColumns(30));
 }
 
 TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -325,6 +325,14 @@
   }
   template  bool isNot(T Kind) const { return !is(Kind); }
 
+  bool closesScopeAfterBlock() const {
+if (BlockKind == BK_Block)
+  return true;
+if (closesScope())
+   

[PATCH] D50003: Sema: Fix explicit address space cast involving void pointers

2018-08-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Sema/SemaCast.cpp:1050
+ SrcType->getAs()->getPointeeType().getAddressSpace() !=
+ 
DestType->getAs()->getPointeeType().getAddressSpace();
+}

rjmccall wrote:
> yaxunl wrote:
> > rjmccall wrote:
> > > I know the code was like this before, but please rewrite this to just use 
> > > `getAs()` instead of doing the separate `isPointerType()` 
> > > check.
> > IsAddressSpaceConversion is also called in line 2218 of the same file, 
> > where SrcType or DestType may not be pointer type.
> `getAs` is a query; it returns null if the type isn't of the target type.
How about 

```
auto *SrcPtrType = SrcType->getAs();
if (!SrcPtrType )
  return false;
auto *DestPtrType = DestType->getAs();
if (!DestPtrType)
  return false;
return SrcPtrType->getPointeeType().getAddressSpace() !=
 DestPtrType->getPointeeType().getAddressSpace();
```


https://reviews.llvm.org/D50003



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


[PATCH] D50154: [clangd] capitalize diagnostic messages if '-capitialize-diagnostic-text' is provided

2018-08-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Capitalizing sounds nice. +1 to just do it without an option.

My favorite essay on this is
http://neugierig.org/software/blog/2018/07/options.html


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50154



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


[PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute

2018-08-02 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This change made clang to start trigger failed asserts for me (although they 
seem to not be reproducible with all compilers building clang), see 
https://bugs.llvm.org/show_bug.cgi?id=38421 for full description.


Repository:
  rC Clang

https://reviews.llvm.org/D49922



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


[PATCH] D48100: Append new attributes to the end of an AttributeList.

2018-08-02 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D48100#1185189, @hfinkel wrote:

> Assuming that @aaron.ballman is still okay with this, I think that we should 
> move forward. @erichkeane, I suspect that fixing the ordering problems, which 
> were often arbitrary before and are still so, is a larger change that we'd 
> want to split out regardless (not to mention the fact that we'd need to 
> decide how to fix them). Erich, is that alright with you?


That works fine with me.  I'm still concerned about the ordering issues, since 
I think the error-on-the-second made more sense in the past, but after digging 
in for a bit, I think it is perhaps not worth the effort.  I'm OK if 
@aaron.ballman is.


Repository:
  rC Clang

https://reviews.llvm.org/D48100



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


RE: r338641 - [AST][4/4] Move the bit-fields from ObjCMethodDecl and ObjCContainerDecl into DeclContext

2018-08-02 Thread Keane, Erich via cfe-commits
Thanks Vlad for the removal!  This warning didn’t show up in my environment 
when committing this, I really need get a newer GCC :/

I suspect the patch author should extract that assert to the bitfield area with 
the rest.


From: David Jones [mailto:d...@google.com]
Sent: Wednesday, August 1, 2018 3:57 PM
To: Keane, Erich 
Cc: cfe-commits@lists.llvm.org
Subject: Re: r338641 - [AST][4/4] Move the bit-fields from ObjCMethodDecl and 
ObjCContainerDecl into DeclContext

(And it was fixed in r338648)

On Wed, Aug 1, 2018 at 3:24 PM David Jones 
mailto:d...@google.com>> wrote:
FYI, this breaks clang:

.../llvm/tools/clang/lib/AST/DeclObjC.cpp:793:7: error: static_assert 
expression is not an integral constant expression
  static_cast(ObjCMethodDeclBits.ObjCMethodFamilyBitWidth) ==
  ^
.../llvm/tools/clang/lib/AST/DeclObjC.cpp:793:29: note: implicit use of 'this' 
pointer is only allowed within the evaluation of a call to a 'constexpr' member 
function
  static_cast(ObjCMethodDeclBits.ObjCMethodFamilyBitWidth) ==
^
1 error generated.


On Wed, Aug 1, 2018 at 2:31 PM Erich Keane via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: erichkeane
Date: Wed Aug  1 14:31:08 2018
New Revision: 338641

URL: http://llvm.org/viewvc/llvm-project?rev=338641&view=rev
Log:
[AST][4/4] Move the bit-fields from ObjCMethodDecl and ObjCContainerDecl into 
DeclContext

This patch follows https://reviews.llvm.org/D49729,
https://reviews.llvm.org/D49732 and
https://reviews.llvm.org/D49733.

Move the bits from ObjCMethodDecl and ObjCContainerDecl
into DeclContext.

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

Patch By: bricci

Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=338641&r1=338640&r2=338641&view=diff
==
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Aug  1 14:31:08 2018
@@ -141,58 +141,10 @@ public:
   enum ImplementationControl { None, Required, Optional };

 private:
-  // The conventional meaning of this method; an ObjCMethodFamily.
-  // This is not serialized; instead, it is computed on demand and
-  // cached.
-  mutable unsigned Family : ObjCMethodFamilyBitWidth;
-
-  /// instance (true) or class (false) method.
-  unsigned IsInstance : 1;
-  unsigned IsVariadic : 1;
-
-  /// True if this method is the getter or setter for an explicit property.
-  unsigned IsPropertyAccessor : 1;
-
-  // Method has a definition.
-  unsigned IsDefined : 1;
-
-  /// Method redeclaration in the same interface.
-  unsigned IsRedeclaration : 1;
-
-  /// Is redeclared in the same interface.
-  mutable unsigned HasRedeclaration : 1;
-
-  // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
-  /// \@required/\@optional
-  unsigned DeclImplementation : 2;
-
-  // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum
-  /// in, inout, etc.
-  unsigned objcDeclQualifier : 7;
-
-  /// Indicates whether this method has a related result type.
-  unsigned RelatedResultType : 1;
-
-  /// Whether the locations of the selector identifiers are in a
-  /// "standard" position, a enum SelectorLocationsKind.
-  unsigned SelLocsKind : 2;
-
-  /// Whether this method overrides any other in the class hierarchy.
-  ///
-  /// A method is said to override any method in the class's
-  /// base classes, its protocols, or its categories' protocols, that has
-  /// the same selector and is of the same kind (class or instance).
-  /// A method in an implementation is not considered as overriding the same
-  /// method in the interface or its categories.
-  unsigned IsOverriding : 1;
-
-  /// Indicates if the method was a definition but its body was skipped.
-  unsigned HasSkippedBody : 1;
-
-  // Return type of this method.
+  /// Return type of this method.
   QualType MethodDeclType;

-  // Type source information for the return type.
+  /// Type source information for the return type.
   TypeSourceInfo *ReturnTInfo;

   /// Array of ParmVarDecls for the formal parameters of this method
@@ -203,7 +155,7 @@ private:
   /// List of attributes for this method declaration.
   SourceLocation DeclEndLoc; // the location of the ';' or '{'.

-  // The following are only used for method definitions, null otherwise.
+  /// The following are only used for method definitions, null otherwise.
   LazyDeclStmtPtr Body;

   /// SelfDecl - Decl for the implicit self parameter. This is lazily
@@ -220,21 +172,14 @@ private:
  bool isVariadic = false, bool i

[PATCH] D50163: [AST] Remove the static_assert check in ObjCMethodDecl::ObjCMethodDecl

2018-08-02 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

@bricci : This likely needs to be moved into the bitfield section I think.  We 
had a couple of other static-asserts that moved, so this is likely one of them.


Repository:
  rC Clang

https://reviews.llvm.org/D50163



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


[PATCH] D50104: [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

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

In https://reviews.llvm.org/D50104#1184362, @scott.linder wrote:

> Address feedback; I hope I understood correctly what debug info to check for.
>
> I don't see where in CreateMemTemp and friends EmitLifetimeStart gets called, 
> and I don't see any lifetime intrinsics in the IR even at -O1.


Emitting lifetime intrinsic is optional. In this case, since the life time of 
the temp var is just before and after the function call, emitting lifetime 
intrinsics can help optimizers.

It can be done by code like this:

   if (auto *Size = EmitLifetimeStart(
   CGM.getDataLayout().getTypeAllocSize(Alloca.getElementType()),
   Alloca.getPointer())) {
 pushFullExprCleanup(NormalEHLifetimeMarker, Alloca,
Size);
  }

Then the lifetime.start should be emitted before the function call and 
lifetime.end should be emitted just after the function call.


https://reviews.llvm.org/D50104



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


[PATCH] D50154: [clangd] capitalize diagnostic messages if '-capitialize-diagnostic-text' is provided

2018-08-02 Thread Simon Marchi via Phabricator via cfe-commits
simark added a comment.

In https://reviews.llvm.org/D50154#1185605, @sammccall wrote:

> Capitalizing sounds nice. +1 to just do it without an option.
>
> My favorite essay on this is
>  http://neugierig.org/software/blog/2018/07/options.html


Agreed.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50154



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


Re: r338640 - [NFC][CodeGenCXX] Use -emit-llvm-only instead of -emit-llvm and ignoring it.

2018-08-02 Thread Nico Weber via cfe-commits
Can't you omit '-o -' now too?

On Wed, Aug 1, 2018 at 5:21 PM Roman Lebedev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: lebedevri
> Date: Wed Aug  1 14:20:58 2018
> New Revision: 338640
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338640&view=rev
> Log:
> [NFC][CodeGenCXX] Use -emit-llvm-only instead of -emit-llvm and ignoring
> it.
>
> As pointed out by Richard Smith in post-review of r338489.
>
> Modified:
> cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
>
> Modified: cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp?rev=338640&r1=338639&r2=338640&view=diff
>
> ==
> --- cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
> (original)
> +++ cfe/trunk/test/CodeGenCXX/castexpr-basepathsize-threshold.cpp Wed Aug
> 1 14:20:58 2018
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 %s -emit-llvm -o -
> +// RUN: %clang_cc1 %s -emit-llvm-only -o -
>
>  // https://bugs.llvm.org/show_bug.cgi?id=38356
>  // We only check that we do not crash.
>
>
> ___
> 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] D50154: [clangd] capitalize diagnostic messages if '-capitialize-diagnostic-text' is provided

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

Seems we have consensus here.
Let's remove the option and just always capitalize the messages.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50154



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


[PATCH] D50043: [RISCV] RISC-V using -fuse-init-array by default

2018-08-02 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

Could you add a test for this please?


Repository:
  rC Clang

https://reviews.llvm.org/D50043



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


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-02 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 158749.
Szelethus edited the summary of this revision.
Szelethus added a comment.

Dereferencing is disabled by default. I think there's a great value in this 
part of the checker, but I do concede to the fact that it still needs to mature 
even for alpha. I'll probably revisit this once heap regions are better 
supported.


https://reviews.llvm.org/D49438

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
  test/Analysis/cxx-uninitialized-object-inheritance.cpp
  test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
  test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
  test/Analysis/cxx-uninitialized-object.cpp

Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,6 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -DPEDANTIC -verify %s
-
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
 
 //===--===//
 // Default constructor test.
Index: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
===
--- test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -1,6 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -DPEDANTIC -verify %s
-
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
 
 //===--===//
 // Concrete location tests.
Index: test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
===
--- test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
+++ test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:NotesAsWarnings=true -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:NotesAsWarnings=true \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify %s
 
 class NotesAsWarningsTest {
   int a;
Index: test/Analysis/cxx-uninitialized-object-inheritance.cpp
===
--- test/Analysis/cxx-uninitialized-object-inheritance.cpp
+++ test/Analysis/cxx-uninitialized-object-inheritance.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN: -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN: -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN: -std=c++11 -verify  %s
 
 //===--===//
 // Non-polymorphic inheritance tests
Index: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.

[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-02 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:715
 void ento::registerUninitializedObjectChecker(CheckerManager &Mgr) {
   auto Chk = Mgr.registerChecker();
   Chk->IsPedantic = Mgr.getAnalyzerOptions().getBooleanOption(

george.karpenkov wrote:
> `registerChecker` now passes through all arguments to the constructor.
> Could you pass the analyzer options to the constructor,
> and populate the fields from there?
From an earlier conversation (D48285#inline-423489):
>[...]`getBooleanOption(StringRef, /*DefaultVal*/ bool, const ento::CheckerBase 
>*)` depends on the constructed checker, so I don't think I can pull this off.
>
>There actually is a way to get boolean options without having to pass the 
>checker as an argument, but then it wouldn't be a checker specific option:
>`-analyzer-config Pedantic=true`
>instead of
>`-analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true`

I did see your patch D49050, but since `CHECKER::name` is assigned a value 
after the checker's construction, I don't think it solves this particular 
problem.


https://reviews.llvm.org/D49438



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


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-02 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added a comment.

In https://reviews.llvm.org/D49438#1184688, @george.karpenkov wrote:

> @Szelethus Hi, do you plan to finish this patch soon-ish? I would like to 
> evaluate it on a few codebases, but the pointer chasing is currently way too 
> fragile / generates too many FPs.


What do you mean under fragile? It certainly needs some refactoring and 
clarification, but I haven't seen the current version of the checker crash due 
to pointer chasing.

This might be a little nit-picking, but I don't think the finds are false 
positive. From what I've seen after looking through hundreds of reports, I am 
confident that pointer chasing is working as intended. I would however agree 
that some reports hold little value to the developer, as in some cases pointees 
are intentionally left uninitialized, so it's better to hide it behind a flag 
for now.


https://reviews.llvm.org/D49438



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


[PATCH] D50189: Fully qualify the renamed symbol if the shortened name is ambiguous.

2018-08-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
ioeric added reviewers: ilya-biryukov, hokein.
Herald added a subscriber: cfe-commits.

For example, when renaming `a::b::x::foo` to `y::foo` below, replacing
`x::foo()` with `y::foo()` can cause ambiguity. In such cases, we simply fully
qualify the name with leading `::`.
namespace a {
namespace b {
namespace x { void foo() {} }
namespace y { void foo() {} }
}
}

namespace a {
namespace b {
void f() { x::foo(); }
}
})");


Repository:
  rC Clang

https://reviews.llvm.org/D50189

Files:
  lib/Tooling/Core/Lookup.cpp
  unittests/Tooling/LookupTest.cpp

Index: unittests/Tooling/LookupTest.cpp
===
--- unittests/Tooling/LookupTest.cpp
+++ unittests/Tooling/LookupTest.cpp
@@ -68,7 +68,7 @@
   "namespace b { void f() { a::foo(); } }\n");
 
   Visitor.OnCall = [&](CallExpr *Expr) {
-EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+EXPECT_EQ("::a::bar", replaceCallExpr(Expr, "::a::bar"));
   };
   Visitor.runOver("namespace a { void foo(); }\n"
   "namespace b { namespace a { void foo(); }\n"
@@ -127,6 +127,38 @@
   "namespace a { namespace b { namespace c {"
   "void f() { foo(); }"
   "} } }\n");
+
+  // If the shortest name is ambiguous, we need to add more qualifiers.
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("::a::y::bar", replaceCallExpr(Expr, "::a::y::bar"));
+  };
+  Visitor.runOver(R"(
+namespace a {
+namespace b {
+namespace x { void foo() {} }
+namespace y { void foo() {} }
+}
+}
+
+namespace a {
+namespace b {
+void f() { x::foo(); }
+}
+})");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("y::bar", replaceCallExpr(Expr, "::y::bar"));
+  };
+  Visitor.runOver(R"(
+namespace a {
+namespace b {
+namespace x { void foo() {} }
+namespace y { void foo() {} }
+}
+}
+
+void f() { a::b::x::foo(); }
+)");
 }
 
 TEST(LookupTest, replaceNestedClassName) {
Index: lib/Tooling/Core/Lookup.cpp
===
--- lib/Tooling/Core/Lookup.cpp
+++ lib/Tooling/Core/Lookup.cpp
@@ -14,6 +14,7 @@
 #include "clang/Tooling/Core/Lookup.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclarationName.h"
 using namespace clang;
 using namespace clang::tooling;
 
@@ -114,6 +115,37 @@
   return false;
 }
 
+// Returns true if spelling symbol \p QName as \p Spelling in \p UseContext is
+// ambiguous. For example, if QName is "::y::bar" and the spelling is "y::bar"
+// in `UseContext` "a" that contains a nested namespace "a::y", then "y::bar"
+// can be resolved to ::a::y::bar, which can cause compile error.
+static bool isAmbiguousNameInScope(StringRef Spelling, StringRef QName,
+   const DeclContext &UseContext) {
+  assert(QName.startswith("::"));
+  if (Spelling.startswith("::"))
+return false;
+
+  // Lookup the first component of Spelling in all enclosing namespaces and
+  // check if there is any existing symbols with the same name but in different
+  // scope.
+  StringRef Head = Spelling.split("::").first;
+
+  llvm::SmallVector UseNamespaces =
+  getAllNamedNamespaces(&UseContext);
+  auto &AST = UseContext.getParentASTContext();
+  StringRef TrimmedQName = QName.substr(2);
+  for (auto I = UseNamespaces.begin(), E = UseNamespaces.end(); I != E; ++I) {
+const NamespaceDecl *NS = *I;
+auto LookupRes = NS->lookup(DeclarationName(&AST.Idents.get(Head)));
+if (!LookupRes.empty()) {
+  for (const NamedDecl *Res : LookupRes)
+if (!TrimmedQName.startswith(Res->getQualifiedNameAsString()))
+  return true;
+}
+  }
+  return false;
+}
+
 std::string tooling::replaceNestedName(const NestedNameSpecifier *Use,
const DeclContext *UseContext,
const NamedDecl *FromDecl,
@@ -146,6 +178,14 @@
   // figure out how good a namespace match we have with our destination type.
   // We work backwards (from most specific possible namespace to least
   // specific).
-  return getBestNamespaceSubstr(UseContext, ReplacementString,
-isFullyQualified(Use));
+  StringRef Suggested = getBestNamespaceSubstr(UseContext, ReplacementString,
+   isFullyQualified(Use));
+  // Use the fully qualified name if the suggested name is ambiguous.
+  // FIXME: consider re-shortening the name to the length until the name is not
+  // ambiguous. We are not doing this because ambiguity is pretty bad and we
+  // should not try to be clever to handle such cases. Making this noticeable to
+  // users seems to be a better option.
+  return isAmbiguousNameInScope(Suggested, ReplacementString, *UseContext)
+ ? ReplacementString
+ : Suggested;
 }
__

[PATCH] D50189: Fully qualify the renamed symbol if the shortened name is ambiguous.

2018-08-02 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 158761.
ioeric added a comment.

- minor update to comment.


Repository:
  rC Clang

https://reviews.llvm.org/D50189

Files:
  lib/Tooling/Core/Lookup.cpp
  unittests/Tooling/LookupTest.cpp

Index: unittests/Tooling/LookupTest.cpp
===
--- unittests/Tooling/LookupTest.cpp
+++ unittests/Tooling/LookupTest.cpp
@@ -68,7 +68,7 @@
   "namespace b { void f() { a::foo(); } }\n");
 
   Visitor.OnCall = [&](CallExpr *Expr) {
-EXPECT_EQ("a::bar", replaceCallExpr(Expr, "::a::bar"));
+EXPECT_EQ("::a::bar", replaceCallExpr(Expr, "::a::bar"));
   };
   Visitor.runOver("namespace a { void foo(); }\n"
   "namespace b { namespace a { void foo(); }\n"
@@ -127,6 +127,38 @@
   "namespace a { namespace b { namespace c {"
   "void f() { foo(); }"
   "} } }\n");
+
+  // If the shortest name is ambiguous, we need to add more qualifiers.
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("::a::y::bar", replaceCallExpr(Expr, "::a::y::bar"));
+  };
+  Visitor.runOver(R"(
+namespace a {
+namespace b {
+namespace x { void foo() {} }
+namespace y { void foo() {} }
+}
+}
+
+namespace a {
+namespace b {
+void f() { x::foo(); }
+}
+})");
+
+  Visitor.OnCall = [&](CallExpr *Expr) {
+EXPECT_EQ("y::bar", replaceCallExpr(Expr, "::y::bar"));
+  };
+  Visitor.runOver(R"(
+namespace a {
+namespace b {
+namespace x { void foo() {} }
+namespace y { void foo() {} }
+}
+}
+
+void f() { a::b::x::foo(); }
+)");
 }
 
 TEST(LookupTest, replaceNestedClassName) {
Index: lib/Tooling/Core/Lookup.cpp
===
--- lib/Tooling/Core/Lookup.cpp
+++ lib/Tooling/Core/Lookup.cpp
@@ -14,6 +14,7 @@
 #include "clang/Tooling/Core/Lookup.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclarationName.h"
 using namespace clang;
 using namespace clang::tooling;
 
@@ -114,6 +115,37 @@
   return false;
 }
 
+// Returns true if spelling symbol \p QName as \p Spelling in \p UseContext is
+// ambiguous. For example, if QName is "::y::bar" and the spelling is "y::bar"
+// in `UseContext` "a" that contains a nested namespace "a::y", then "y::bar"
+// can be resolved to ::a::y::bar, which can cause compile error.
+static bool isAmbiguousNameInScope(StringRef Spelling, StringRef QName,
+   const DeclContext &UseContext) {
+  assert(QName.startswith("::"));
+  if (Spelling.startswith("::"))
+return false;
+
+  // Lookup the first component of Spelling in all enclosing namespaces and
+  // check if there is any existing symbols with the same name but in different
+  // scope.
+  StringRef Head = Spelling.split("::").first;
+
+  llvm::SmallVector UseNamespaces =
+  getAllNamedNamespaces(&UseContext);
+  auto &AST = UseContext.getParentASTContext();
+  StringRef TrimmedQName = QName.substr(2);
+  for (auto I = UseNamespaces.begin(), E = UseNamespaces.end(); I != E; ++I) {
+const NamespaceDecl *NS = *I;
+auto LookupRes = NS->lookup(DeclarationName(&AST.Idents.get(Head)));
+if (!LookupRes.empty()) {
+  for (const NamedDecl *Res : LookupRes)
+if (!TrimmedQName.startswith(Res->getQualifiedNameAsString()))
+  return true;
+}
+  }
+  return false;
+}
+
 std::string tooling::replaceNestedName(const NestedNameSpecifier *Use,
const DeclContext *UseContext,
const NamedDecl *FromDecl,
@@ -146,6 +178,14 @@
   // figure out how good a namespace match we have with our destination type.
   // We work backwards (from most specific possible namespace to least
   // specific).
-  return getBestNamespaceSubstr(UseContext, ReplacementString,
-isFullyQualified(Use));
+  StringRef Suggested = getBestNamespaceSubstr(UseContext, ReplacementString,
+   isFullyQualified(Use));
+  // Use the fully qualified name if the suggested name is ambiguous.
+  // FIXME: consider re-shortening the name until the name is not ambiguous. We
+  // are not doing this because ambiguity is pretty bad and we should not try to
+  // be clever in handling such cases. Making this noticeable to users seems to
+  // be a better option.
+  return isAmbiguousNameInScope(Suggested, ReplacementString, *UseContext)
+ ? ReplacementString
+ : Suggested;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-02 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 158760.
Szelethus added a comment.

Forgot `git add` and `-U`.


https://reviews.llvm.org/D49438

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp
  test/Analysis/cxx-uninitialized-object-inheritance.cpp
  test/Analysis/cxx-uninitialized-object-no-dereference.cpp
  test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
  test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
  test/Analysis/cxx-uninitialized-object.cpp

Index: test/Analysis/cxx-uninitialized-object.cpp
===
--- test/Analysis/cxx-uninitialized-object.cpp
+++ test/Analysis/cxx-uninitialized-object.cpp
@@ -1,6 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -DPEDANTIC -verify %s
-
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
 
 //===--===//
 // Default constructor test.
Index: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
===
--- test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -1,6 +1,11 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -DPEDANTIC -verify %s
-
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
+
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify  %s
 
 //===--===//
 // Concrete location tests.
Index: test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
===
--- test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
+++ test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:NotesAsWarnings=true -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:NotesAsWarnings=true \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN:   -std=c++11 -verify %s
 
 class NotesAsWarningsTest {
   int a;
Index: test/Analysis/cxx-uninitialized-object-no-dereference.cpp
===
--- /dev/null
+++ test/Analysis/cxx-uninitialized-object-no-dereference.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -std=c++11 -DPEDANTIC -verify %s
+
+class UninitPointerTest {
+  int *ptr; // expected-note{{uninitialized pointer 'this->ptr'}}
+  int dontGetFilteredByNonPedanticMode = 0;
+
+public:
+  UninitPointerTest() {} // expected-warning{{1 uninitialized field}}
+};
+
+void fUninitPointerTest() {
+  UninitPointerTest();
+}
+
+class UninitPointeeTest {
+  int *ptr; // no-note
+  int dontGetFilteredByNonPedanticMode = 0;
+
+public:
+  UninitPointeeTest(int *ptr) : ptr(ptr) {} // no-warning
+};
+
+void fUninitPointeeTest() {
+  int a;
+  UninitPointeeTest t(&a);
+}
Index: test/Analysis/cxx-uninitialized-object-inheritance.cpp
===
--- test/Analysis/cxx-uninitialized-object-inheritance.cpp
+++ test/Analysis/cxx-uninitialized-object-inheritance.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -std=c++11 -veri

[PATCH] D50163: [AST] Remove the static_assert check in ObjCMethodDecl::ObjCMethodDecl

2018-08-02 Thread Bruno Ricci via Phabricator via cfe-commits
bricci added a comment.

The static_assert itself cannot be in the bitfield since the whole point is to 
avoid including Basic/IdentifierTable.h just for this.

I originally put the static_assert in ObjCMethodDecl and everything worked fine 
when tested with GCC but I then saw just
after you committed it that it broke some builds. Therefore for the moment I 
just removed it (and had to beg someone on IRC to commit it )

However  I think that we can simply add it to the definition of the class 
ObjCMethodDecl with a comment both in the bitfield
and in ObjCMethodDecl which explains why we checks this. The problem was not 
the location of the static_assert, but the fact that
even though the member ObjCMethodDeclBits is protected the nested class 
ObjCMethodDeclBitfields is private. However I think tha
we can just use something like

`static_assert(decltype(ObjCMethodDeclBits)::ObjCMethodFamilyBitWidth == 
ObjCMethodFamilyBitWidth, "blablabla")`


Repository:
  rC Clang

https://reviews.llvm.org/D50163



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


[PATCH] D50189: Fully qualify the renamed symbol if the shortened name is ambiguous.

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



Comment at: lib/Tooling/Core/Lookup.cpp:137
+  StringRef TrimmedQName = QName.substr(2);
+  for (auto I = UseNamespaces.begin(), E = UseNamespaces.end(); I != E; ++I) {
+const NamespaceDecl *NS = *I;

maybe use range-based-for here? I.e. `for (const NamespaceDecl* NS  : 
UseNamespaces) { ... }`



Comment at: lib/Tooling/Core/Lookup.cpp:139
+const NamespaceDecl *NS = *I;
+auto LookupRes = NS->lookup(DeclarationName(&AST.Idents.get(Head)));
+if (!LookupRes.empty()) {

This will not take using namespaces into account, right? Do we care about those 
or is this a known limitation of the tools?


Repository:
  rC Clang

https://reviews.llvm.org/D50189



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


[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

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

Address review comments.


Repository:
  rC Clang

https://reviews.llvm.org/D50152

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGBlocks.h
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/blocks-1.c
  test/CodeGen/blocks.c
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  test/CodeGenCXX/block-byref-cxx-objc.cpp
  test/CodeGenCXX/blocks.cpp
  test/CodeGenCXX/cxx-block-objects.cpp
  test/CodeGenObjC/arc-blocks.m
  test/CodeGenObjC/debug-info-block-helper.m
  test/CodeGenObjC/debug-info-blocks.m
  test/CodeGenObjC/mrc-weak.m
  test/CodeGenObjC/strong-in-c-struct.m
  test/CodeGenObjCXX/arc-blocks.mm
  test/CodeGenObjCXX/lambda-to-block.mm
  test/CodeGenObjCXX/mrc-weak.mm

Index: test/CodeGenObjCXX/mrc-weak.mm
===
--- test/CodeGenObjCXX/mrc-weak.mm
+++ test/CodeGenObjCXX/mrc-weak.mm
@@ -119,10 +119,10 @@
 // CHECK:   call void @use_block
 // CHECK:   call void @objc_destroyWeak
 
-// CHECK-LABEL: define internal void @__copy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block
 // CHECK:   @objc_copyWeak
 
-// CHECK-LABEL: define internal void @__destroy_helper_block
+// CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block
 // CHECK:   @objc_destroyWeak
 
 void test8(void) {
@@ -142,8 +142,8 @@
 // CHECK:   call void @objc_destroyWeak
 
 // CHECK-LABEL: define void @_Z14test9_baselinev()
-// CHECK:   define internal void @__copy_helper
-// CHECK:   define internal void @__destroy_helper
+// CHECK:   define linkonce_odr hidden void @__copy_helper
+// CHECK:   define linkonce_odr hidden void @__destroy_helper
 void test9_baseline(void) {
   Foo *p = get_object();
   use_block(^{ [p run]; });
Index: test/CodeGenObjCXX/lambda-to-block.mm
===
--- test/CodeGenObjCXX/lambda-to-block.mm
+++ test/CodeGenObjCXX/lambda-to-block.mm
@@ -12,7 +12,7 @@
 void hasLambda(Copyable x) {
   takesBlock([x] () { });
 }
-// CHECK-LABEL: define internal void @__copy_helper_block_
+// CHECK-LABEL: define linkonce_odr hidden void @"__copy_helper_block_
 // CHECK: call void @"_ZZ9hasLambda8CopyableEN3$_0C1ERKS0_"
 // CHECK-LABEL: define internal void @"_ZZ9hasLambda8CopyableEN3$_0C2ERKS0_"
 // CHECK: call void @_ZN8CopyableC1ERKS_
Index: test/CodeGenObjCXX/arc-blocks.mm
===
--- test/CodeGenObjCXX/arc-blocks.mm
+++ test/CodeGenObjCXX/arc-blocks.mm
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -o - %s | FileCheck -check-prefix CHECK %s
 // RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -fexceptions -fobjc-arc-exceptions -O1 -o - %s | FileCheck -check-prefix CHECK-O1 %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck -check-prefix CHECK-NOEXCP %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 // CHECK: %[[STRUCT_TEST1_S0:.*]] = type { i32 }
@@ -55,10 +56,16 @@
 
 // Check that copy/dispose helper functions are exception safe.
 
-// CHECK-LABEL: define internal void @__copy_helper_block_(
+// CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_ea8_s_32_b8_40_w_48_c20_ZN5test12S0C1ERKS0__56_c20_ZN5test12S0C1ERKS0__60(
 // CHECK: %[[BLOCK_SOURCE:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>*
 // CHECK: %[[BLOCK_DEST:.*]] = bitcast i8* %{{.*}} to <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>*
 
+// CHECK: %[[V9:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>* %[[BLOCK_SOURCE]], i32 0, i32 5
+// CHECK: %[[V10:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>, <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TEST1_S0]], %[[STRUCT_TEST1_S0]] }>* %[[BLOCK_DEST]], i32 0, i32 5
+// CHECK: %[[BLOCKCOPY_SRC2:.*]] = load i8*, i8** %[[V9]], align 8
+// CHECK: store i8* null, i8** %[[V10]], align 8
+// CHECK: call void @objc_storeStrong(i8** %[[V10]], i8* %[[BLOCKCOPY_SRC2]])
+
 // CHECK: %[[V4:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %[[STRUCT_BLOCK_DESCRIPTOR]]*, i8*, i8*, i8*, %[[STRUCT_TE

[PATCH] D50152: [CodeGen] Merge equivalent block copy/helper functions

2018-08-02 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: lib/CodeGen/CGBlocks.cpp:1638
+switch (E.Kind) {
+case BlockCaptureEntityKind::CXXRecord: {
+  Name += "c";

rjmccall wrote:
> I forget whether this case has already filtered out trivial 
> copy-constructors, but if not, you should consider doing that here.
E.Kind is set to CXXRecord only when the copy constructor is non-trivial (or 
the destructor is non-trivial if this is a destroy helper). Both 
computeCopyInfoForBlockCapture and computeDestroyInfoForBlockCapture filter out 
types with trivial copy constructors or destructors.



Comment at: lib/CodeGen/CGBlocks.cpp:1647
+unsigned Qs;
+cast(CE)->getConstructor()->isCopyConstructor(Qs);
+if (Qs & Qualifiers::Volatile)

rjmccall wrote:
> This doesn't always have to be a copy constructor.  I mean, maybe this 
> procedure works anyway, but the constructor used to copy an object isn't 
> always a copy constructor.  Blame constructor templates.
I've made changes to use the name of the constructor function that is used to 
copy the capture instead of using the volatility of the copy constructor's 
argument.

I'm not sure when a function that is not a copy constructor would be used to 
copy a captured object though. The comment in function captureInBlock in 
SemaExpr.cpp says that the the blocks spec requires a const copy constructor.



Comment at: lib/CodeGen/CGBlocks.cpp:1651
+  }
+  std::string Str = CaptureTy->getAsCXXRecordDecl()->getName();
+  Name += llvm::to_string(Str.size()) + Str;

rjmccall wrote:
> The name of a C++ class is not unique; you need to use the mangler.   
> Ideally, you would find a way to mangle all the C++ types in the context of 
> the same mangler instance so that substitutions could be reused across it.
> 
> You also need to check for a type with non-external linkage and make this 
> helper private if you find one.  (You can still unique within the translation 
> unit, for what it's worth.)
Good catch. test/CodeGenCXX/blocks.cpp checks that helper functions for blocks 
that capture non-external types have internal linkage.


Repository:
  rC Clang

https://reviews.llvm.org/D50152



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


r338732 - [analyzer] Make RegionVector use const reference

2018-08-02 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Thu Aug  2 09:29:36 2018
New Revision: 338732

URL: http://llvm.org/viewvc/llvm-project?rev=338732&view=rev
Log:
[analyzer] Make RegionVector use const reference

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=338732&r1=338731&r2=338732&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Thu Aug  2 
09:29:36 2018
@@ -395,7 +395,7 @@ private:
   const Optional
   findRegionOfInterestInRecord(const RecordDecl *RD, ProgramStateRef State,
const MemRegion *R,
-   RegionVector Vec = {},
+   const RegionVector &Vec = {},
int depth = 0) {
 
 if (depth == DEREFERENCE_LIMIT) // Limit the recursion depth.
@@ -548,14 +548,10 @@ private:
 
   /// \return Diagnostics piece for region not modified in the current 
function.
   std::shared_ptr
-  notModifiedDiagnostics(const LocationContext *Ctx,
- CallExitBegin &CallExitLoc,
- CallEventRef<> Call,
- RegionVector FieldChain,
- const MemRegion *MatchedRegion,
- StringRef FirstElement,
- bool FirstIsReferenceType,
- unsigned IndirectionLevel) {
+  notModifiedDiagnostics(const LocationContext *Ctx, CallExitBegin 
&CallExitLoc,
+ CallEventRef<> Call, const RegionVector &FieldChain,
+ const MemRegion *MatchedRegion, StringRef 
FirstElement,
+ bool FirstIsReferenceType, unsigned IndirectionLevel) 
{
 
 PathDiagnosticLocation L;
 if (const ReturnStmt *RS = CallExitLoc.getReturnStmt()) {
@@ -579,7 +575,8 @@ private:
   /// Pretty-print region \p MatchedRegion to \p os.
   void prettyPrintRegionName(StringRef FirstElement, bool FirstIsReferenceType,
  const MemRegion *MatchedRegion,
- RegionVector FieldChain, int IndirectionLevel,
+ const RegionVector &FieldChain,
+ int IndirectionLevel,
  llvm::raw_svector_ostream &os) {
 
 if (FirstIsReferenceType)


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


[PATCH] D50104: [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-08-02 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

I still don't quite see what you describe; with that change all of the 
lifetime.end calls pile up just before the enclosing function returns, not 
after each call to enqueue_kernel. Looking at 
https://clang.llvm.org/doxygen/EHScopeStack_8h_source.html#l00078 I don't see 
any option which isn't based on scope. The lifetime.start calls do occur where 
I would expect, though, so I will update the patch.


https://reviews.llvm.org/D50104



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


[PATCH] D50193: Added functionality to suggest FixIts for conversion of '->' to '.' and vice versa.

2018-08-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, arphaman, jkorous, ioeric.

Added functionality to suggest FixIts for conversion of '->' to '.' and vice 
versa.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50193

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/Diagnostics.cpp
  clangd/Protocol.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -477,7 +477,8 @@
 
 TEST(CompletionTest, ReferencesAffectRanking) {
   auto Results = completions("int main() { abs^ }", {ns("absl"), func("absb")});
-  EXPECT_THAT(Results.Completions, HasSubsequence(Named("absb"), Named("absl")));
+  EXPECT_THAT(Results.Completions,
+  HasSubsequence(Named("absb"), Named("absl")));
   Results = completions("int main() { abs^ }",
 {withReferences(1, ns("absl")), func("absb")});
   EXPECT_THAT(Results.Completions,
@@ -1338,6 +1339,78 @@
   EXPECT_THAT(Results.Context, CodeCompletionContext::CCC_DotMemberAccess);
 }
 
+TEST(CompletionTest, FixItForArrowToDot) {
+  CodeCompleteOptions Opts;
+  Opts.IncludeFixIts = true;
+  auto Results = completions(
+  R"cpp(
+class Auxilary {
+ public:
+  void AuxFunction();
+};
+class ClassWithPtr {
+ public:
+  void MemberFunction();
+  Auxilary* operator->() const { return Aux; }
+ private:
+  Auxilary* Aux;
+};
+namespace ns {
+  void f() {
+ClassWithPtr x;
+x->MemberFunction^;
+  }
+}
+  )cpp",
+  {}, Opts);
+  EXPECT_EQ(Results.Completions.size(), 1u);
+
+  TextEdit ReplacementEdit;
+  ReplacementEdit.range.start.line = 15;
+  ReplacementEdit.range.start.character = 13;
+  ReplacementEdit.range.end.line = 15;
+  ReplacementEdit.range.end.character = 15;
+  ReplacementEdit.newText = ".";
+  const auto &C = Results.Completions.front();
+  EXPECT_THAT(C.FixIts, ElementsAre(ReplacementEdit));
+}
+
+TEST(CompletionTest, FixItForDotToArrow) {
+  CodeCompleteOptions Opts;
+  Opts.IncludeFixIts = true;
+  auto Results = completions(
+  R"cpp(
+class Auxilary {
+ public:
+  void AuxFunction();
+};
+class ClassWithPtr {
+ public:
+  void MemberFunction();
+  Auxilary* operator->() const { return Aux; }
+ private:
+  Auxilary* Aux;
+};
+namespace ns {
+  void f() {
+ClassWithPtr x;
+x.AuxFunction^;
+  }
+}
+  )cpp",
+  {}, Opts);
+  EXPECT_EQ(Results.Completions.size(), 1u);
+
+  TextEdit ReplacementEdit;
+  ReplacementEdit.range.start.line = 15;
+  ReplacementEdit.range.start.character = 13;
+  ReplacementEdit.range.end.line = 15;
+  ReplacementEdit.range.end.character = 14;
+  ReplacementEdit.newText = "->";
+  const auto &C = Results.Completions.front();
+  EXPECT_THAT(C.FixIts, ElementsAre(ReplacementEdit));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/SourceCode.h
===
--- clangd/SourceCode.h
+++ clangd/SourceCode.h
@@ -13,6 +13,7 @@
 //===--===//
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
+#include "Diagnostics.h"
 #include "Protocol.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Core/Replacement.h"
@@ -64,6 +65,10 @@
 /// Get the absolute file path of a given file entry.
 llvm::Optional getAbsoluteFilePath(const FileEntry *F,
 const SourceManager &SourceMgr);
+
+TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,
+const LangOptions &L);
+
 } // namespace clangd
 } // namespace clang
 #endif
Index: clangd/SourceCode.cpp
===
--- clangd/SourceCode.cpp
+++ clangd/SourceCode.cpp
@@ -8,6 +8,7 @@
 //===--===//
 #include "SourceCode.h"
 
+#include "Diagnostics.h"
 #include "Logger.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/SourceManager.h"
@@ -199,5 +200,14 @@
   return FilePath.str().str();
 }
 
+TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,
+const LangOptions &L) {
+  TextEdit Result;
+  Result.range =
+  halfOpenToRange(M, Lexer::makeFileCharRange(FixIt.RemoveRange, M, L));
+  Result.newText = FixIt.CodeToInsert;
+  return Result;
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/Protoc

[PATCH] D50194: LLVM Proto Fuzzer - Run Functions on Suite of Inputs

2018-08-02 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman created this revision.
emmettneyman added reviewers: kcc, morehouse.
Herald added subscribers: cfe-commits, mgorny.

Added corpus of arrays to use as inputs for the functions. Check that the two
functions modify the inputted arrays in the same way.


Repository:
  rC Clang

https://reviews.llvm.org/D50194

Files:
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp
  clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.cpp
  clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.h
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.h
  clang/tools/clang-fuzzer/handle-llvm/input_arrays.cpp
  clang/tools/clang-fuzzer/handle-llvm/input_arrays.h

Index: clang/tools/clang-fuzzer/handle-llvm/input_arrays.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/handle-llvm/input_arrays.h
@@ -0,0 +1,134 @@
+//==-- input_arrays.h - Helper function for LLVM fuzzer inputs -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Declares helper functions for getting the inputs on which to call the
+// compiled functions.
+//
+//===--===//
+
+#include 
+#include 
+
+static const int ArraySize = 64;
+static const int NumArrays = 100;
+
+// Declare the arrays that will be fed to the compiled functions
+static int a1[ArraySize];
+static int b1[ArraySize];
+static int c1[ArraySize];
+static int a2[ArraySize];
+static int b2[ArraySize];
+static int c2[ArraySize];
+
+void UpdateArrays();
+
+std::string ArrayToString(int *arr, int s);
+
+// Define a corpus of possible inputs
+static int InputArrays[100][64] =
+{ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+  {0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
+  {1, 1, 0, 0, 1, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
+  {0, 0, 0, 5, 0, 2, 0, 8, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
+  {1, 1, 2, 1, 6, 0, 3, 1, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
+  {0, 0, 2, 0, 0, 7, 0, 4, 2, 0, 12, 12, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
+  {1, 1, 0, 2, 2, 9, 8, 0, 5, 3, 1, 14, 14, 14, 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14},
+  {0, 0, 0, 4, 0, 1, 10, 9, 0, 6, 4, 2, 0, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+  {1, 1, 2, 3, 2, 3, 0, 11, 10, 0, 7, 5, 3, 1, 18, 18, 18, 18, 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18},
+  {0, 0, 2, 5, 4, 0, 2, 13, 12, 11, 0, 8, 6, 4, 2, 0, 20, 20, 20, 20, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20},
+  {1, 1, 0, 1, 6, 2, 4, 1, 14, 13, 12, 0, 9, 7, 5, 3, 1, 22, 22, 22, 22, 22, 0, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22},
+  {0, 0, 0, 0, 4, 4, 0, 3, 0, 15, 14, 13, 0, 10, 8, 6, 4, 2, 0, 24, 24, 24, 24, 24, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 

[PATCH] D50104: [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

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

In https://reviews.llvm.org/D50104#1185920, @scott.linder wrote:

> I still don't quite see what you describe; with that change all of the 
> lifetime.end calls pile up just before the enclosing function returns, not 
> after each call to enqueue_kernel. Looking at 
> https://clang.llvm.org/doxygen/EHScopeStack_8h_source.html#l00078 I don't see 
> any option which isn't based on scope. The lifetime.start calls do occur 
> where I would expect, though, so I will update the patch.


Sorry my mistake. In this case, the full expressions seems to be the calling 
function, so using pushFullExprCleanup to emit lifetime.end does not work well 
here.

You need to call EmitLifetimeEnd explicitly after emitting the function call.


https://reviews.llvm.org/D50104



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


[PATCH] D48341: [clang-doc] Refactoring mapper to map by scope

2018-08-02 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett marked 2 inline comments as done.
juliehockett added inline comments.



Comment at: clang-tools-extra/test/clang-doc/bc-linkage.cpp:106
+// CHECK-0-NEXT: 
+// CHECK-0-NEXT:   
+// CHECK-0-NEXT:blob data = 'InnerClass'

ioeric wrote:
> juliehockett wrote:
> > ioeric wrote:
> > > I'm still a bit concerned about hardcoding a lot of USRs in tests. They 
> > > are not interpretable and generally not interesting for testing. Also as 
> > > they are auto-generated,   it's hard to tell whether they are actually 
> > > the desired USRs. I'm concerned because the maintenance is getting higher 
> > > as number of tests grows - everyone changing USR semantics in the future 
> > > has to know to regenerate clang-doc tests, this can be annoying and 
> > > potentially unmanageable when a small change in clang USR requires 
> > > changes to many test files in clang-tools-extra :( Comparing to the value 
> > > it brings to test USRs in all tests, I'd still suggest  simply matching 
> > > them with a `{{.*}}`and only test USRs in few tests where you are 
> > > actually interested in them.
> > Okay, I updated it to only check the length -- is that reasonable?
> Thanks! 
> 
> FWIW, I wouldn't check the length either as it seems to add too much 
> overhead; I think checking length/USR in one test should get it well covered. 
Possibly for the YAML tests, but for the bitcode ones I also want to check the 
ops, so it's not just the USR text. It's also autogenerated, so the overhead is 
minimal. 

Also, just to reiterate, you'll still likely have to regenerate these if you 
dramatically change the USR spec. The bitcode tests all rely on USRs to write 
to files, and if those USRs change the name of the file the test needs to read 
will also change.


https://reviews.llvm.org/D48341



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


[PATCH] D50170: [libcxxabi] Fix test_exception_address_alignment test for ARM

2018-08-02 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

That certainly ***looks*** more correct to me.


Repository:
  rCXXA libc++abi

https://reviews.llvm.org/D50170



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


Re: [PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute

2018-08-02 Thread Richard Smith via cfe-commits
On Thu, 2 Aug 2018, 06:10 Martin Storsjö via Phabricator via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> mstorsjo added a comment.
>
> This change made clang to start trigger failed asserts for me (although
> they seem to not be reproducible with all compilers building clang), see
> https://bugs.llvm.org/show_bug.cgi?id=38421 for full description.
>

Are you still seeing problems after r338478? This change is miscompiled by
GCC; that revision contains a workaround.

Repository:
>   rC Clang
>
> https://reviews.llvm.org/D49922
>
>
>
> ___
> 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


r338741 - [c-index-test] Use correct executable path to discover resource directory.

2018-08-02 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Aug  2 10:29:53 2018
New Revision: 338741

URL: http://llvm.org/viewvc/llvm-project?rev=338741&view=rev
Log:
[c-index-test] Use correct executable path to discover resource directory.

Driver builds resource directory path based on provided executable path.
Instead of string "clang" use actual executable path.

rdar://problem/42699514

Reviewers: nathawes, akyrtzi, bob.wilson

Reviewed By: akyrtzi

Subscribers: dexonsmith, cfe-commits

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


Modified:
cfe/trunk/tools/c-index-test/core_main.cpp

Modified: cfe/trunk/tools/c-index-test/core_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/core_main.cpp?rev=338741&r1=338740&r2=338741&view=diff
==
--- cfe/trunk/tools/c-index-test/core_main.cpp (original)
+++ cfe/trunk/tools/c-index-test/core_main.cpp Thu Aug  2 10:29:53 2018
@@ -20,6 +20,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/PrettyStackTrace.h"
@@ -202,11 +203,11 @@ static void dumpModuleFileInputs(seriali
   });
 }
 
-static bool printSourceSymbols(ArrayRef Args,
-   bool dumpModuleImports,
-   bool indexLocals) {
+static bool printSourceSymbols(const char *Executable,
+   ArrayRef Args,
+   bool dumpModuleImports, bool indexLocals) {
   SmallVector ArgsWithProgName;
-  ArgsWithProgName.push_back("clang");
+  ArgsWithProgName.push_back(Executable);
   ArgsWithProgName.append(Args.begin(), Args.end());
   IntrusiveRefCntPtr
 Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
@@ -314,6 +315,8 @@ static void printSymbolNameAndUSR(const
 int indextest_core_main(int argc, const char **argv) {
   sys::PrintStackTraceOnErrorSignal(argv[0]);
   PrettyStackTraceProgram X(argc, argv);
+  void *MainAddr = (void*) (intptr_t) indextest_core_main;
+  std::string Executable = llvm::sys::fs::getMainExecutable(argv[0], MainAddr);
 
   assert(argv[1] == StringRef("core"));
   ++argv;
@@ -343,7 +346,9 @@ int indextest_core_main(int argc, const
   errs() << "error: missing compiler args; pass '-- '\n";
   return 1;
 }
-return printSourceSymbols(CompArgs, options::DumpModuleImports, 
options::IncludeLocals);
+return printSourceSymbols(Executable.c_str(), CompArgs,
+  options::DumpModuleImports,
+  options::IncludeLocals);
   }
 
   return 0;


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


[PATCH] D50160: [c-index-test] Use correct executable path to discover resource directory.

2018-08-02 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
vsapsai marked an inline comment as done.
Closed by commit rL338741: [c-index-test] Use correct executable path to 
discover resource directory. (authored by vsapsai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50160?vs=158658&id=158794#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50160

Files:
  cfe/trunk/tools/c-index-test/core_main.cpp


Index: cfe/trunk/tools/c-index-test/core_main.cpp
===
--- cfe/trunk/tools/c-index-test/core_main.cpp
+++ cfe/trunk/tools/c-index-test/core_main.cpp
@@ -20,6 +20,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/PrettyStackTrace.h"
@@ -202,11 +203,11 @@
   });
 }
 
-static bool printSourceSymbols(ArrayRef Args,
-   bool dumpModuleImports,
-   bool indexLocals) {
+static bool printSourceSymbols(const char *Executable,
+   ArrayRef Args,
+   bool dumpModuleImports, bool indexLocals) {
   SmallVector ArgsWithProgName;
-  ArgsWithProgName.push_back("clang");
+  ArgsWithProgName.push_back(Executable);
   ArgsWithProgName.append(Args.begin(), Args.end());
   IntrusiveRefCntPtr
 Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
@@ -314,6 +315,8 @@
 int indextest_core_main(int argc, const char **argv) {
   sys::PrintStackTraceOnErrorSignal(argv[0]);
   PrettyStackTraceProgram X(argc, argv);
+  void *MainAddr = (void*) (intptr_t) indextest_core_main;
+  std::string Executable = llvm::sys::fs::getMainExecutable(argv[0], MainAddr);
 
   assert(argv[1] == StringRef("core"));
   ++argv;
@@ -343,7 +346,9 @@
   errs() << "error: missing compiler args; pass '-- '\n";
   return 1;
 }
-return printSourceSymbols(CompArgs, options::DumpModuleImports, 
options::IncludeLocals);
+return printSourceSymbols(Executable.c_str(), CompArgs,
+  options::DumpModuleImports,
+  options::IncludeLocals);
   }
 
   return 0;


Index: cfe/trunk/tools/c-index-test/core_main.cpp
===
--- cfe/trunk/tools/c-index-test/core_main.cpp
+++ cfe/trunk/tools/c-index-test/core_main.cpp
@@ -20,6 +20,7 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Serialization/ASTReader.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/PrettyStackTrace.h"
@@ -202,11 +203,11 @@
   });
 }
 
-static bool printSourceSymbols(ArrayRef Args,
-   bool dumpModuleImports,
-   bool indexLocals) {
+static bool printSourceSymbols(const char *Executable,
+   ArrayRef Args,
+   bool dumpModuleImports, bool indexLocals) {
   SmallVector ArgsWithProgName;
-  ArgsWithProgName.push_back("clang");
+  ArgsWithProgName.push_back(Executable);
   ArgsWithProgName.append(Args.begin(), Args.end());
   IntrusiveRefCntPtr
 Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
@@ -314,6 +315,8 @@
 int indextest_core_main(int argc, const char **argv) {
   sys::PrintStackTraceOnErrorSignal(argv[0]);
   PrettyStackTraceProgram X(argc, argv);
+  void *MainAddr = (void*) (intptr_t) indextest_core_main;
+  std::string Executable = llvm::sys::fs::getMainExecutable(argv[0], MainAddr);
 
   assert(argv[1] == StringRef("core"));
   ++argv;
@@ -343,7 +346,9 @@
   errs() << "error: missing compiler args; pass '-- '\n";
   return 1;
 }
-return printSourceSymbols(CompArgs, options::DumpModuleImports, options::IncludeLocals);
+return printSourceSymbols(Executable.c_str(), CompArgs,
+  options::DumpModuleImports,
+  options::IncludeLocals);
   }
 
   return 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50160: [c-index-test] Use correct executable path to discover resource directory.

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

Thanks for the review!


Repository:
  rL LLVM

https://reviews.llvm.org/D50160



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


[PATCH] D50194: LLVM Proto Fuzzer - Run Functions on Suite of Inputs

2018-08-02 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:173
+  int s = getSize((char *) func_ptr);
+  memcpy(mem, func_ptr, s);
+}

Why do we need to copy the function somewhere else?  Looks very error-prone and 
unnecessary.  Also makes this patch larger than it needs to be.



Comment at: clang/tools/clang-fuzzer/handle-llvm/input_arrays.cpp:30
+  memcpy(b2, InputArrays[b_index], ArraySize * sizeof(int));
+  memcpy(c2, InputArrays[c_index], ArraySize * sizeof(int));
+}

Do the generated functions ever modify arrays a and b, or just c?  If just c, 
we can avoid lots of memcpys here.



Comment at: clang/tools/clang-fuzzer/handle-llvm/input_arrays.h:34
+// Define a corpus of possible inputs
+static int InputArrays[100][64] =
+{ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

Use the constants you just defined.


Repository:
  rC Clang

https://reviews.llvm.org/D50194



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


r338743 - __c11_atomic_load's _Atomic can be const

2018-08-02 Thread JF Bastien via cfe-commits
Author: jfb
Date: Thu Aug  2 10:35:46 2018
New Revision: 338743

URL: http://llvm.org/viewvc/llvm-project?rev=338743&view=rev
Log:
__c11_atomic_load's _Atomic can be const

Summary:
C++11 onwards specs the non-member functions atomic_load and 
atomic_load_explicit as taking the atomic by const (potentially volatile) 
pointer. C11, in its infinite wisdom, decided to drop the const, and C17 will 
fix this with DR459 (the current draft forgot to fix B.16, but that’s not the 
normative part).

clang’s lib/Headers/stdatomic.h implements these as #define to the __c11_* 
equivalent, which are builtins with custom typecheck. Fix the typecheck.

D47613 takes care of the libc++ side.

Discussion: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058129.html



Reviewers: rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/atomic-ops.c
cfe/trunk/test/SemaOpenCL/atomic-ops.cl

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=338743&r1=338742&r2=338743&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Aug  2 10:35:46 2018
@@ -4347,7 +4347,7 @@ ExprResult Sema::SemaAtomicOpsOverloaded
 << Ptr->getType() << Ptr->getSourceRange();
   return ExprError();
 }
-if (AtomTy.isConstQualified() ||
+if ((Form != Load && Form != LoadCopy && AtomTy.isConstQualified()) ||
 AtomTy.getAddressSpace() == LangAS::opencl_constant) {
   Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_atomic)
   << (AtomTy.isConstQualified() ? 0 : 1) << Ptr->getType()

Modified: cfe/trunk/test/Sema/atomic-ops.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/atomic-ops.c?rev=338743&r1=338742&r2=338743&view=diff
==
--- cfe/trunk/test/Sema/atomic-ops.c (original)
+++ cfe/trunk/test/Sema/atomic-ops.c Thu Aug  2 10:35:46 2018
@@ -115,7 +115,7 @@ void f(_Atomic(int) *i, const _Atomic(in
   __c11_atomic_load(i, memory_order_seq_cst);
   __c11_atomic_load(p, memory_order_seq_cst);
   __c11_atomic_load(d, memory_order_seq_cst);
-  __c11_atomic_load(ci, memory_order_seq_cst); // expected-error {{address 
argument to atomic operation must be a pointer to non-const _Atomic type 
('const _Atomic(int) *' invalid)}}
+  __c11_atomic_load(ci, memory_order_seq_cst);
 
   int load_n_1 = __atomic_load_n(I, memory_order_relaxed);
   int *load_n_2 = __atomic_load_n(P, memory_order_relaxed);
@@ -222,7 +222,7 @@ void f(_Atomic(int) *i, const _Atomic(in
 
   __c11_atomic_init(ci, 0); // expected-error {{address argument to atomic 
operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' 
invalid)}}
   __c11_atomic_store(ci, 0, memory_order_release); // expected-error {{address 
argument to atomic operation must be a pointer to non-const _Atomic type 
('const _Atomic(int) *' invalid)}}
-  __c11_atomic_load(ci, memory_order_acquire); // expected-error {{address 
argument to atomic operation must be a pointer to non-const _Atomic type 
('const _Atomic(int) *' invalid)}}
+  __c11_atomic_load(ci, memory_order_acquire);
 
   // Ensure the  macros behave appropriately.
   atomic_int n = ATOMIC_VAR_INIT(123);

Modified: cfe/trunk/test/SemaOpenCL/atomic-ops.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/atomic-ops.cl?rev=338743&r1=338742&r2=338743&view=diff
==
--- cfe/trunk/test/SemaOpenCL/atomic-ops.cl (original)
+++ cfe/trunk/test/SemaOpenCL/atomic-ops.cl Thu Aug  2 10:35:46 2018
@@ -58,7 +58,8 @@ void f(atomic_int *i, const atomic_int *
   __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group); // 
expected-error {{address argument to atomic operation must be a pointer to 
non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic 
_Atomic(int) *') invalid)}}
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(i_c, memory_order_seq_cst, memory_scope_work_group); // 
expected-error {{address argument to atomic operation must be a pointer to 
non-constant _Atomic type ('__constant atomic_int *' (aka '__constant 
_Atomic(int) *') invalid)}}
 
   __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
@@ -94,7 +95,7 @@ void f(atomic_int *i, const atomic_int *
 
   __opencl_atomic_init(ci, 0); // expected-err

[PATCH] D47618: __c11_atomic_load's _Atomic can be const

2018-08-02 Thread JF Bastien via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338743: __c11_atomic_load's _Atomic can be const 
(authored by jfb, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47618

Files:
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/atomic-ops.c
  cfe/trunk/test/SemaOpenCL/atomic-ops.cl


Index: cfe/trunk/test/SemaOpenCL/atomic-ops.cl
===
--- cfe/trunk/test/SemaOpenCL/atomic-ops.cl
+++ cfe/trunk/test/SemaOpenCL/atomic-ops.cl
@@ -58,7 +58,8 @@
   __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group); // 
expected-error {{address argument to atomic operation must be a pointer to 
non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic 
_Atomic(int) *') invalid)}}
+  __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(i_c, memory_order_seq_cst, memory_scope_work_group); // 
expected-error {{address argument to atomic operation must be a pointer to 
non-constant _Atomic type ('__constant atomic_int *' (aka '__constant 
_Atomic(int) *') invalid)}}
 
   __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
@@ -94,7 +95,7 @@
 
   __opencl_atomic_init(ci, 0); // expected-error {{address argument to atomic 
operation must be a pointer to non-const _Atomic type ('const __generic 
atomic_int *' (aka 'const __generic _Atomic(int) *') invalid)}}
   __opencl_atomic_store(ci, 0, memory_order_release, memory_scope_work_group); 
// expected-error {{address argument to atomic operation must be a pointer to 
non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic 
_Atomic(int) *') invalid)}}
-  __opencl_atomic_load(ci, memory_order_acquire, memory_scope_work_group); // 
expected-error {{address argument to atomic operation must be a pointer to 
non-const _Atomic type ('const __generic atomic_int *' (aka 'const __generic 
_Atomic(int) *') invalid)}}
+  __opencl_atomic_load(ci, memory_order_acquire, memory_scope_work_group);
 
   __opencl_atomic_init(&gn, 456);
   __opencl_atomic_init(&gn, (void*)0); // expected-warning{{incompatible 
pointer to integer conversion passing '__generic void *' to parameter of type 
'int'}}
Index: cfe/trunk/test/Sema/atomic-ops.c
===
--- cfe/trunk/test/Sema/atomic-ops.c
+++ cfe/trunk/test/Sema/atomic-ops.c
@@ -115,7 +115,7 @@
   __c11_atomic_load(i, memory_order_seq_cst);
   __c11_atomic_load(p, memory_order_seq_cst);
   __c11_atomic_load(d, memory_order_seq_cst);
-  __c11_atomic_load(ci, memory_order_seq_cst); // expected-error {{address 
argument to atomic operation must be a pointer to non-const _Atomic type 
('const _Atomic(int) *' invalid)}}
+  __c11_atomic_load(ci, memory_order_seq_cst);
 
   int load_n_1 = __atomic_load_n(I, memory_order_relaxed);
   int *load_n_2 = __atomic_load_n(P, memory_order_relaxed);
@@ -222,7 +222,7 @@
 
   __c11_atomic_init(ci, 0); // expected-error {{address argument to atomic 
operation must be a pointer to non-const _Atomic type ('const _Atomic(int) *' 
invalid)}}
   __c11_atomic_store(ci, 0, memory_order_release); // expected-error {{address 
argument to atomic operation must be a pointer to non-const _Atomic type 
('const _Atomic(int) *' invalid)}}
-  __c11_atomic_load(ci, memory_order_acquire); // expected-error {{address 
argument to atomic operation must be a pointer to non-const _Atomic type 
('const _Atomic(int) *' invalid)}}
+  __c11_atomic_load(ci, memory_order_acquire);
 
   // Ensure the  macros behave appropriately.
   atomic_int n = ATOMIC_VAR_INIT(123);
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -4347,7 +4347,7 @@
 << Ptr->getType() << Ptr->getSourceRange();
   return ExprError();
 }
-if (AtomTy.isConstQualified() ||
+if ((Form != Load && Form != LoadCopy && AtomTy.isConstQualified()) ||
 AtomTy.getAddressSpace() == LangAS::opencl_constant) {
   Diag(DRE->getLocStart(), diag::err_atomic_op_needs_non_const_atomic)
   << (AtomTy.isConstQualified() ? 0 : 1) << Ptr->getType()


Index: cfe/trunk/test/SemaOpenCL/atomic-ops.cl
===
--- cfe/trunk/test/SemaOpenCL/atomic-ops.cl
+++ cfe/trunk/test/SemaOpenCL/atomic-ops.cl
@@ -58,7 +58,8 @@
   __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(p, memory_orde

[libcxxabi] r338747 - [itanium demangler] Support dot suffixes on block invocation functions

2018-08-02 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Thu Aug  2 10:45:01 2018
New Revision: 338747

URL: http://llvm.org/viewvc/llvm-project?rev=338747&view=rev
Log:
[itanium demangler] Support dot suffixes on block invocation functions

rdar://32378759

Modified:
libcxxabi/trunk/src/cxa_demangle.cpp
libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=338747&r1=338746&r2=338747&view=diff
==
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Thu Aug  2 10:45:01 2018
@@ -4935,6 +4935,8 @@ Node *Db::parse() {
 bool RequireNumber = consumeIf('_');
 if (parseNumber().empty() && RequireNumber)
   return nullptr;
+if (look() == '.')
+  First = Last;
 if (numLeft() != 0)
   return nullptr;
 return make("invocation function for block in ", Encoding);

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=338747&r1=338746&r2=338747&view=diff
==
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Thu Aug  2 10:45:01 2018
@@ -29753,6 +29753,8 @@ const char* cases[][2] =
 // reference collapsing:
 {"_Z1fIR1SEiOT_", "int f(S&)"},
 {"_Z1fIJR1SS0_EEiDpOT_", "int f(S&, S&&)"},
+
+{"___Z3foo_block_invoke.25", "invocation function for block in foo"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);


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


[PATCH] D49811: [analyzer] Obtain a ReturnStmt from a CFGAutomaticObjDtor

2018-08-02 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

We could also print something about the ReturnStmt, like source location or 
pretty print of its expressions so we can check that we picked the right one in 
case we have multiple.
But consider this as an optional task if you have nothing better to do. I am ok 
with committing this as is.


https://reviews.llvm.org/D49811



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


[PATCH] D49361: [analyzer] Detect pointers escaped after return statement execution in MallocChecker

2018-08-02 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

All this stuff looks great! Please commit.


https://reviews.llvm.org/D49361



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


[PATCH] D50194: LLVM Proto Fuzzer - Run Functions on Suite of Inputs

2018-08-02 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added inline comments.



Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:173
+  int s = getSize((char *) func_ptr);
+  memcpy(mem, func_ptr, s);
+}

morehouse wrote:
> Why do we need to copy the function somewhere else?  Looks very error-prone 
> and unnecessary.  Also makes this patch larger than it needs to be.
I'm copying the functions because otherwise, the generated machine code gets 
lost as soon as we exit that function's scope. So I'd have to run the functions 
inside `CreateJITFunction` if I don't copy it.

I thought about doing it this way: moving the code from `RunFuncsOnInputs` to 
the bottom of `CreateJITFunction` and then comparing the arrays after both 
calls to `CreateJITFunction` inside `HandleLLVM`. Do you think that would be 
cleaner?



Comment at: clang/tools/clang-fuzzer/handle-llvm/input_arrays.cpp:30
+  memcpy(b2, InputArrays[b_index], ArraySize * sizeof(int));
+  memcpy(c2, InputArrays[c_index], ArraySize * sizeof(int));
+}

morehouse wrote:
> Do the generated functions ever modify arrays a and b, or just c?  If just c, 
> we can avoid lots of memcpys here.
Right now the generated functions can modify any of the arrays.


Repository:
  rC Clang

https://reviews.llvm.org/D50194



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


[PATCH] D50194: LLVM Proto Fuzzer - Run Functions on Suite of Inputs

2018-08-02 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 158800.
emmettneyman added a comment.

Replaced hardcoded numbers with variables


Repository:
  rC Clang

https://reviews.llvm.org/D50194

Files:
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/ExampleClangLLVMProtoFuzzer.cpp
  clang/tools/clang-fuzzer/handle-llvm/CMakeLists.txt
  clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.cpp
  clang/tools/clang-fuzzer/handle-llvm/fuzzer_initialize.h
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.h
  clang/tools/clang-fuzzer/handle-llvm/input_arrays.cpp
  clang/tools/clang-fuzzer/handle-llvm/input_arrays.h

Index: clang/tools/clang-fuzzer/handle-llvm/input_arrays.h
===
--- /dev/null
+++ clang/tools/clang-fuzzer/handle-llvm/input_arrays.h
@@ -0,0 +1,134 @@
+//==-- input_arrays.h - Helper function for LLVM fuzzer inputs -==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// Declares helper functions for getting the inputs on which to call the
+// compiled functions.
+//
+//===--===//
+
+#include 
+#include 
+
+static const int ArraySize = 64;
+static const int NumArrays = 100;
+
+// Declare the arrays that will be fed to the compiled functions
+static int a1[ArraySize];
+static int b1[ArraySize];
+static int c1[ArraySize];
+static int a2[ArraySize];
+static int b2[ArraySize];
+static int c2[ArraySize];
+
+void UpdateArrays();
+
+std::string ArrayToString(int *arr, int s);
+
+// Define a corpus of possible inputs
+static int InputArrays[NumArrays][ArraySize] =
+{ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+  {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+  {0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
+  {1, 1, 0, 0, 1, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6},
+  {0, 0, 0, 5, 0, 2, 0, 8, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8},
+  {1, 1, 2, 1, 6, 0, 3, 1, 10, 10, 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10},
+  {0, 0, 2, 0, 0, 7, 0, 4, 2, 0, 12, 12, 0, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12},
+  {1, 1, 0, 2, 2, 9, 8, 0, 5, 3, 1, 14, 14, 14, 0, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14},
+  {0, 0, 0, 4, 0, 1, 10, 9, 0, 6, 4, 2, 0, 16, 16, 16, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16},
+  {1, 1, 2, 3, 2, 3, 0, 11, 10, 0, 7, 5, 3, 1, 18, 18, 18, 18, 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18},
+  {0, 0, 2, 5, 4, 0, 2, 13, 12, 11, 0, 8, 6, 4, 2, 0, 20, 20, 20, 20, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20},
+  {1, 1, 0, 1, 6, 2, 4, 1, 14, 13, 12, 0, 9, 7, 5, 3, 1, 22, 22, 22, 22, 22, 0, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22},
+  {0, 0, 0, 0, 4, 4, 0, 3, 0, 15, 14, 13, 0, 10, 8, 6, 4, 2, 0, 24, 24, 24, 24, 24, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24},
+  {1, 1, 2, 2, 6, 6, 2, 5, 2, 17, 16, 15, 14, 0, 11, 9, 7, 5, 3, 1, 26, 26, 26, 26, 26, 26, 0, 26, 26, 26, 

Re: r338259 - [analyzer] Add support for more invalidating functions in InnerPointerChecker.

2018-08-02 Thread Alexander Kornienko via cfe-commits
On Mon, Jul 30, 2018 at 5:44 PM Reka Kovacs via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rkovacs
> Date: Mon Jul 30 08:43:45 2018
> New Revision: 338259
>
> URL: http://llvm.org/viewvc/llvm-project?rev=338259&view=rev
> Log:
> [analyzer] Add support for more invalidating functions in
> InnerPointerChecker.
>
> According to the standard, pointers referring to the elements of a
> `basic_string` may be invalidated if they are used as an argument to
> any standard library function taking a reference to non-const
> `basic_string` as an argument. This patch makes InnerPointerChecker warn
> for these cases.
>
> Differential Revision: https://reviews.llvm.org/D49656
>
> Modified:
> cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
> cfe/trunk/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> cfe/trunk/test/Analysis/inner-pointer.cpp
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp?rev=338259&r1=338258&r2=338259&view=diff
>
> ==
> --- cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp
> (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Checkers/InnerPointerChecker.cpp Mon Jul
> 30 08:43:45 2018
> @@ -91,37 +91,53 @@ public:
>  ReserveFn("reserve"), ResizeFn("resize"),
>  ShrinkToFitFn("shrink_to_fit"), SwapFn("swap") {}
>
> -  /// Check whether the function called on the container object is a
> -  /// member function that potentially invalidates pointers referring
> -  /// to the objects's internal buffer.
> -  bool mayInvalidateBuffer(const CallEvent &Call) const;
> -
> -  /// Record the connection between the symbol returned by c_str() and the
> -  /// corresponding string object region in the ProgramState. Mark the
> symbol
> -  /// released if the string object is destroyed.
> +  /// Check if the object of this member function call is a
> `basic_string`.
> +  bool isCalledOnStringObject(const CXXInstanceCall *ICall) const;
> +
> +  /// Check whether the called member function potentially invalidates
> +  /// pointers referring to the container object's inner buffer.
> +  bool isInvalidatingMemberFunction(const CallEvent &Call) const;
> +
> +  /// Mark pointer symbols associated with the given memory region
> released
> +  /// in the program state.
> +  void markPtrSymbolsReleased(const CallEvent &Call, ProgramStateRef
> State,
> +  const MemRegion *ObjRegion,
> +  CheckerContext &C) const;
> +
> +  /// Standard library functions that take a non-const `basic_string`
> argument by
> +  /// reference may invalidate its inner pointers. Check for these cases
> and
> +  /// mark the pointers released.
> +  void checkFunctionArguments(const CallEvent &Call, ProgramStateRef
> State,
> +  CheckerContext &C) const;
> +
> +  /// Record the connection between raw pointers referring to a container
> +  /// object's inner buffer and the object's memory region in the program
> state.
> +  /// Mark potentially invalidated pointers released.
>void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
>
> -  /// Clean up the ProgramState map.
> +  /// Clean up the program state map.
>void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
>  };
>
>  } // end anonymous namespace
>
> -// [string.require]
> -//
> -// "References, pointers, and iterators referring to the elements of a
> -// basic_string sequence may be invalidated by the following uses of that
> -// basic_string object:
> -//
> -// -- TODO: As an argument to any standard library function taking a
> reference
> -// to non-const basic_string as an argument. For example, as an argument
> to
> -// non-member functions swap(), operator>>(), and getline(), or as an
> argument
> -// to basic_string::swap().
> -//
> -// -- Calling non-const member functions, except operator[], at, front,
> back,
> -// begin, rbegin, end, and rend."
> -//
> -bool InnerPointerChecker::mayInvalidateBuffer(const CallEvent &Call)
> const {
> +bool InnerPointerChecker::isCalledOnStringObject(
> +const CXXInstanceCall *ICall) const {
> +  const auto *ObjRegion =
> +
> dyn_cast_or_null(ICall->getCXXThisVal().getAsRegion());
> +  if (!ObjRegion)
> +return false;
> +
> +  QualType ObjTy = ObjRegion->getValueType();
> +  if (ObjTy.isNull() ||
> +  ObjTy->getAsCXXRecordDecl()->getName() != "basic_string")
>

We observe crashes on this line. I'm working on an isolated repro, but you
could probably try to construct one yourself (I
suppose, getAsCXXRecordDecl() can return null here).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r338749 - Work around more GCC miscompiles exposed by r338464.

2018-08-02 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Thu Aug  2 11:12:08 2018
New Revision: 338749

URL: http://llvm.org/viewvc/llvm-project?rev=338749&view=rev
Log:
Work around more GCC miscompiles exposed by r338464.

This is the same fix as in r338478, for another occurrance of the
same pattern from r338464.

See gcc.gnu.org/PR86769 for details of the bug.

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

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=338749&r1=338748&r2=338749&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Thu Aug  2 11:12:08 2018
@@ -6371,8 +6371,12 @@ static bool implicitObjectParamIsLifetim
   const TypeSourceInfo *TSI = FD->getTypeSourceInfo();
   if (!TSI)
 return false;
+  // Don't declare this variable in the second operand of the for-statement;
+  // GCC miscompiles that by ending its lifetime before evaluating the
+  // third operand. See gcc.gnu.org/PR86769.
+  AttributedTypeLoc ATL;
   for (TypeLoc TL = TSI->getTypeLoc();
-   auto ATL = TL.getAsAdjusted();
+   (ATL = TL.getAsAdjusted());
TL = ATL.getModifiedLoc()) {
 if (ATL.getAttrKind() == AttributedType::attr_lifetimebound)
   return true;


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


r338753 - [analyzer] Forward arguments in registerChecker to avoid accidental copies

2018-08-02 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Aug  2 11:17:01 2018
New Revision: 338753

URL: http://llvm.org/viewvc/llvm-project?rev=338753&view=rev
Log:
[analyzer] Forward arguments in registerChecker to avoid accidental copies

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=338753&r1=338752&r2=338753&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h Thu Aug  2 
11:17:01 2018
@@ -149,13 +149,13 @@ public:
   ///
   /// \returns a pointer to the checker object.
   template 
-  CHECKER *registerChecker(AT... Args) {
+  CHECKER *registerChecker(AT &&... Args) {
 CheckerTag tag = getTag();
 CheckerRef &ref = CheckerTags[tag];
 if (ref)
   return static_cast(ref); // already registered.
 
-CHECKER *checker = new CHECKER(Args...);
+CHECKER *checker = new CHECKER(std::forward(Args)...);
 checker->Name = CurrentCheckName;
 CheckerDtors.push_back(CheckerDtor(checker, destruct));
 CHECKER::_register(checker, *this);


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


[PATCH] D50194: LLVM Proto Fuzzer - Run Functions on Suite of Inputs

2018-08-02 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp:173
+  int s = getSize((char *) func_ptr);
+  memcpy(mem, func_ptr, s);
+}

emmettneyman wrote:
> morehouse wrote:
> > Why do we need to copy the function somewhere else?  Looks very error-prone 
> > and unnecessary.  Also makes this patch larger than it needs to be.
> I'm copying the functions because otherwise, the generated machine code gets 
> lost as soon as we exit that function's scope. So I'd have to run the 
> functions inside `CreateJITFunction` if I don't copy it.
> 
> I thought about doing it this way: moving the code from `RunFuncsOnInputs` to 
> the bottom of `CreateJITFunction` and then comparing the arrays after both 
> calls to `CreateJITFunction` inside `HandleLLVM`. Do you think that would be 
> cleaner?
Or just increase the scope of `EE`.


Repository:
  rC Clang

https://reviews.llvm.org/D50194



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


[PATCH] D50179: [AArch64][ARM] Context sensitive meaning of option "crypto"

2018-08-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Driver/ToolChains/Arch/AArch64.cpp:200
+  //
+  // TODO: implement this logic in TargetParser.
+

Yes, this logic should be in TargetParser, not here.  Trying to rewrite the 
target features afterwards is messy at best.  (Actually, the target feature 
list generated by TargetParser probably shouldn't contain the string "crypto" 
at all.)

Given that this code will go away when TargetParser is fixed, why are you 
proposing this patch?



Comment at: lib/Driver/ToolChains/Arch/AArch64.cpp:219
+
+  if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd) {
+if (HasCrypto && !NoCrypto) {

Does this need to check for 8.5a?



Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:430
+  if (ArchName.find_lower("+noaes") == StringRef::npos)
+Features.push_back("+aes");
+} else if (ArchName.find_lower("-crypto") != StringRef::npos) {

The ARM backend doesn't support features named "sha2" and "aes" at the moment.


https://reviews.llvm.org/D50179



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


r338754 - AMDGPU: Fix missing declaration of queue ptr builtin

2018-08-02 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Thu Aug  2 11:24:55 2018
New Revision: 338754

URL: http://llvm.org/viewvc/llvm-project?rev=338754&view=rev
Log:
AMDGPU: Fix missing declaration of queue ptr builtin

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

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=338754&r1=338753&r2=338754&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Thu Aug  2 11:24:55 2018
@@ -24,6 +24,7 @@
 BUILTIN(__builtin_amdgcn_dispatch_ptr, "v*4", "nc")
 BUILTIN(__builtin_amdgcn_kernarg_segment_ptr, "v*4", "nc")
 BUILTIN(__builtin_amdgcn_implicitarg_ptr, "v*4", "nc")
+BUILTIN(__builtin_amdgcn_queue_ptr, "v*4", "nc")
 
 BUILTIN(__builtin_amdgcn_workgroup_id_x, "Ui", "nc")
 BUILTIN(__builtin_amdgcn_workgroup_id_y, "Ui", "nc")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=338754&r1=338753&r2=338754&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Thu Aug  2 11:24:55 2018
@@ -462,6 +462,13 @@ void test_dispatch_ptr(__constant unsign
   *out = __builtin_amdgcn_dispatch_ptr();
 }
 
+// CHECK-LABEL: @test_queue_ptr
+// CHECK: call i8 addrspace(4)* @llvm.amdgcn.queue.ptr()
+void test_queue_ptr(__constant unsigned char ** out)
+{
+  *out = __builtin_amdgcn_queue_ptr();
+}
+
 // CHECK-LABEL: @test_kernarg_segment_ptr
 // CHECK: call i8 addrspace(4)* @llvm.amdgcn.kernarg.segment.ptr()
 void test_kernarg_segment_ptr(__constant unsigned char ** out)


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


Re: r338749 - Work around more GCC miscompiles exposed by r338464.

2018-08-02 Thread Martin Storsjö via cfe-commits

Hans,

I think this commit should be merged to the 7.0 release branch; the first 
half of the GCC workaround made it in before the branch happened, but 
there was another identical case missing.


// Martin

On Thu, 2 Aug 2018, Martin Storsjo via cfe-commits wrote:


Author: mstorsjo
Date: Thu Aug  2 11:12:08 2018
New Revision: 338749

URL: http://llvm.org/viewvc/llvm-project?rev=338749&view=rev
Log:
Work around more GCC miscompiles exposed by r338464.

This is the same fix as in r338478, for another occurrance of the
same pattern from r338464.

See gcc.gnu.org/PR86769 for details of the bug.


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


r338756 - [analyzer] Fix tests.

2018-08-02 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Aug  2 11:41:25 2018
New Revision: 338756

URL: http://llvm.org/viewvc/llvm-project?rev=338756&view=rev
Log:
[analyzer] Fix tests.

Modified:
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/analyzer-config.cpp

Modified: cfe/trunk/test/Analysis/analyzer-config.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-config.c?rev=338756&r1=338755&r2=338756&view=diff
==
--- cfe/trunk/test/Analysis/analyzer-config.c (original)
+++ cfe/trunk/test/Analysis/analyzer-config.c Thu Aug  2 11:41:25 2018
@@ -25,6 +25,7 @@ void foo() {
 // CHECK-NEXT: inline-lambdas = true
 // CHECK-NEXT: ipa = dynamic-bifurcate
 // CHECK-NEXT: ipa-always-inline-size = 3
+// CHECK-NEXT: leak-diagnostics-reference-allocation = false
 // CHECK-NEXT: max-inlinable-size = 100
 // CHECK-NEXT: max-nodes = 225000
 // CHECK-NEXT: max-times-inline-large = 32
@@ -35,4 +36,4 @@ void foo() {
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 23
+// CHECK-NEXT: num-entries = 24

Modified: cfe/trunk/test/Analysis/analyzer-config.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/analyzer-config.cpp?rev=338756&r1=338755&r2=338756&view=diff
==
--- cfe/trunk/test/Analysis/analyzer-config.cpp (original)
+++ cfe/trunk/test/Analysis/analyzer-config.cpp Thu Aug  2 11:41:25 2018
@@ -40,6 +40,7 @@ public:
 // CHECK-NEXT: inline-lambdas = true
 // CHECK-NEXT: ipa = dynamic-bifurcate
 // CHECK-NEXT: ipa-always-inline-size = 3
+// CHECK-NEXT: leak-diagnostics-reference-allocation = false
 // CHECK-NEXT: max-inlinable-size = 100
 // CHECK-NEXT: max-nodes = 225000
 // CHECK-NEXT: max-times-inline-large = 32
@@ -50,4 +51,4 @@ public:
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 30
+// CHECK-NEXT: num-entries = 31


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


Re: [PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute

2018-08-02 Thread Martin Storsjö via cfe-commits

On Thu, 2 Aug 2018, Richard Smith via cfe-commits wrote:


On Thu, 2 Aug 2018, 06:10 Martin Storsjö via Phabricator via cfe-commits,
 wrote:
  mstorsjo added a comment.

  This change made clang to start trigger failed asserts for me
  (although they seem to not be reproducible with all compilers
  building clang), see https://bugs.llvm.org/show_bug.cgi?id=38421
  for full description.


Are you still seeing problems after r338478? This change is miscompiled by
GCC; that revision contains a workaround.


Sorry, didn't see this mail until now. Yes, I saw problems even after 
r338478; I applied the same fix in a different spot as well, in r338749.


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


[PATCH] D49403: More aggressively complete RecordTypes with Function Pointers

2018-08-02 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added a comment.

I hope I'm not coming across as too argumentative here. I don't really have 
strong feelings about this function pointer type patch and ultimately I see 
that you are right, but the objections you are raising here would equally apply 
to what I'm working on with the IR linker and if I find a way to fix that, I'll 
care a bit more about that case. (If you'd like a preview, here's the bug I'm 
trying to fix: https://bugs.llvm.org/show_bug.cgi?id=38408)

You say "there is no semantic meaning for pointer types in LLVM IR" and that's 
fine, but there is a function PointerType::getElementType() and if I modify 
that function to always return the i8 type it will break a lot of things. So 
while there may be some sense in which the the pointer type cannot be the 
"correct" type, there is most definitely a sense in which it can be "incorrect" 
even if that sense isn't the strict semantic sense. I haven't looked at all the 
uses of  PointerType::getElementType() [or the related 
Type::getPointerElementType()]. I know a lot of them are just tests and 
assertions. Others are trivially walking through something that they know to be 
true by other means. A few seem (at least on first glance) to actually be doing 
something with it. For instance, llvm::getPointerStride() contains this line of 
code: "int64_t Size = DL.getTypeAllocSize(PtrTy->getElementType());"

I'm not arguing against opaque pointer types. I just feel like we're probably 
at least a couple of years away from having that. I'm also not arguing for 
robust and exhaustive correction of all cases where pointer types are not 
currently "working" in the sense that I am describing in my prior comments. I'm 
just saying that if someone runs into a specific case that is causing them 
problems and they submit a fix for that case, maybe we should let it through 
unless we have more of a reason than strict semantics rendering it unimportant.


https://reviews.llvm.org/D49403



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


[PATCH] D50104: [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-08-02 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 158816.
scott.linder added a comment.

Emit lifetime intrinsics for the sizes temp, and update test


https://reviews.llvm.org/D50104

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/cl20-device-side-enqueue.cl
  test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl

Index: test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -emit-llvm -o - -triple amdgcn < %s | FileCheck %s --check-prefixes=COMMON,AMDGPU
+// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -emit-llvm -o - -triple "spir-unknown-unknown" < %s | FileCheck %s --check-prefixes=COMMON,SPIR32
+// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -emit-llvm -o - -triple "spir64-unknown-unknown" < %s | FileCheck %s --check-prefixes=COMMON,SPIR64
+// RUN: %clang_cc1 -cl-std=CL2.0 -O0 -debug-info-kind=limited -emit-llvm -o - -triple amdgcn < %s | FileCheck %s --check-prefixes=CHECK-DEBUG
+
+// Check that the enqueue_kernel array temporary is in the entry block to avoid
+// a dynamic alloca
+
+typedef struct {int a;} ndrange_t;
+
+kernel void test(int i) {
+// COMMON-LABEL: define {{.*}} void @test
+// COMMON-LABEL: entry:
+// AMDGPU: %block_sizes = alloca [1 x i64]
+// SPIR32: %block_sizes = alloca [1 x i32]
+// SPIR64: %block_sizes = alloca [1 x i64]
+// COMMON-LABEL: if.then:
+// COMMON-NOT: alloca
+// CHECK-DEBUG: getelementptr {{.*}} %block_sizes, {{.*}} !dbg !34
+// COMMON-LABEL: if.end
+  queue_t default_queue;
+  unsigned flags = 0;
+  ndrange_t ndrange;
+  if (i)
+enqueue_kernel(default_queue, flags, ndrange, ^(local void *a) { }, 32);
+}
+
+// Check that the temporary is scoped to the `if`
+
+// CHECK-DEBUG: !32 = distinct !DILexicalBlock(scope: !7, file: !1, line: 24)
+// CHECK-DEBUG: !34 = !DILocation(line: 25, scope: !32)
Index: test/CodeGenOpenCL/cl20-device-side-enqueue.cl
===
--- test/CodeGenOpenCL/cl20-device-side-enqueue.cl
+++ test/CodeGenOpenCL/cl20-device-side-enqueue.cl
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -O0 -emit-llvm -o - -triple "spir-unknown-unknown" | FileCheck %s --check-prefix=COMMON --check-prefix=B32
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -O0 -emit-llvm -o - -triple "spir64-unknown-unknown" | FileCheck %s --check-prefix=COMMON --check-prefix=B64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -ffake-address-space-map -O1 -emit-llvm -o - -triple "spir64-unknown-unknown" | FileCheck %s --check-prefix=CHECK-LIFETIMES
 
 #pragma OPENCL EXTENSION cl_khr_subgroups : enable
 
@@ -46,8 +47,31 @@
   // COMMON: %event_wait_list2 = alloca [1 x %opencl.clk_event_t*]
   clk_event_t event_wait_list2[] = {clk_event};
 
-  // Emits block literal on stack and block kernel [[INVLK1]].
   // COMMON: [[NDR:%[a-z0-9]+]] = alloca %struct.ndrange_t, align 4
+
+  // B32: %[[BLOCK_SIZES1:.*]] = alloca [1 x i32]
+  // B64: %[[BLOCK_SIZES1:.*]] = alloca [1 x i64]
+  // CHECK-LIFETIMES: %[[BLOCK_SIZES1:.*]] = alloca [1 x i64]
+  // B32: %[[BLOCK_SIZES2:.*]] = alloca [1 x i32]
+  // B64: %[[BLOCK_SIZES2:.*]] = alloca [1 x i64]
+  // CHECK-LIFETIMES: %[[BLOCK_SIZES2:.*]] = alloca [1 x i64]
+  // B32: %[[BLOCK_SIZES3:.*]] = alloca [1 x i32]
+  // B64: %[[BLOCK_SIZES3:.*]] = alloca [1 x i64]
+  // CHECK-LIFETIMES: %[[BLOCK_SIZES3:.*]] = alloca [1 x i64]
+  // B32: %[[BLOCK_SIZES4:.*]] = alloca [1 x i32]
+  // B64: %[[BLOCK_SIZES4:.*]] = alloca [1 x i64]
+  // CHECK-LIFETIMES: %[[BLOCK_SIZES4:.*]] = alloca [1 x i64]
+  // B32: %[[BLOCK_SIZES5:.*]] = alloca [1 x i32]
+  // B64: %[[BLOCK_SIZES5:.*]] = alloca [1 x i64]
+  // CHECK-LIFETIMES: %[[BLOCK_SIZES5:.*]] = alloca [1 x i64]
+  // B32: %[[BLOCK_SIZES6:.*]] = alloca [3 x i32]
+  // B64: %[[BLOCK_SIZES6:.*]] = alloca [3 x i64]
+  // CHECK-LIFETIMES: %[[BLOCK_SIZES6:.*]] = alloca [3 x i64]
+  // B32: %[[BLOCK_SIZES7:.*]] = alloca [1 x i32]
+  // B64: %[[BLOCK_SIZES7:.*]] = alloca [1 x i64]
+  // CHECK-LIFETIMES: %[[BLOCK_SIZES7:.*]] = alloca [1 x i64]
+
+  // Emits block literal on stack and block kernel [[INVLK1]].
   // COMMON: [[DEF_Q:%[0-9]+]] = load %opencl.queue_t{{.*}}*, %opencl.queue_t{{.*}}** %default_queue
   // COMMON: [[FLAGS:%[0-9]+]] = load i32, i32* %flags
   // B32: [[BL:%[0-9]+]] = bitcast <{ i32, i32, i32 addrspace(1)*, i32, i32 addrspace(1)* }>* %block to void ()*
@@ -73,48 +97,54 @@
   // COMMON-SAME: (%opencl.queue_t{{.*}}* [[DEF_Q]], i32 [[FLAGS]],  %struct.ndrange_t* {{.*}}, i32 2, %opencl.clk_event_t{{.*}}* addrspace(4)* [[WAIT_EVNT]], %opencl.clk_event_t{{.*}}* addrspace(4)* [[EVNT]],
   // COMMON-SAME: i8 addrspace(4)* addrspacecast (i8* bitcast ({{.*}} [[INVLK2:[^ ]+_kernel]] to i8*) to i8 addrspace(4)*),
   // COMMON-SAME: i8 addrspace(4)* [[BL_I8]])
-
   enqueue_kernel(default_queue, flags, ndrange, 2, &event_wait_list, &clk_event,
   

[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-02 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, compnerd, pcc, pirama.

Repository:
  rC Clang

https://reviews.llvm.org/D50199

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Preprocessor/predefined-win-macros.c


Index: test/Preprocessor/predefined-win-macros.c
===
--- test/Preprocessor/predefined-win-macros.c
+++ test/Preprocessor/predefined-win-macros.c
@@ -73,12 +73,17 @@
 // RUN: %clang_cc1 -triple i686-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-MINGW
 
+// CHECK-X86-MINGW-NOT: #define UNICODE 1
 // CHECK-X86-MINGW: #define WIN32 1
 // CHECK-X86-MINGW-NOT: #define WIN64 1
 // CHECK-X86-MINGW: #define WINNT 1
 // CHECK-X86-MINGW: #define _WIN32 1
 // CHECK-X86-MINGW-NOT: #define _WIN64 1
 
+// RUN: %clang_cc1 -triple i686-windows-gnu %s -E -dM -o - -municode \
+// RUN:   | FileCheck -match-full-lines %s 
--check-prefix=CHECK-X86-MINGW-UNICODE
+// CHECK-X86-MINGW-UNICODE: #define UNICODE 1
+
 // RUN: %clang_cc1 -triple thumbv7-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-ARM-MINGW
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2460,6 +2460,7 @@
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.PIE = Args.hasArg(OPT_pic_is_pie);
   Opts.Static = Args.hasArg(OPT_static_define);
+  Opts.Unicode = Args.hasArg(OPT_municode);
   Opts.DumpRecordLayoutsSimple = Args.hasArg(OPT_fdump_record_layouts_simple);
   Opts.DumpRecordLayouts = Opts.DumpRecordLayoutsSimple
 || Args.hasArg(OPT_fdump_record_layouts);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3346,6 +3346,9 @@
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-static-define");
 
+  if (Args.hasArg(options::OPT_municode))
+CmdArgs.push_back("-municode");
+
   if (isa(JA))
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
 
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -109,6 +109,8 @@
   }
   Builder.defineMacro("__MSVCRT__");
   Builder.defineMacro("__MINGW32__");
+  if (Opts.Unicode)
+Builder.defineMacro("UNICODE");
   addCygMingDefines(Opts, Builder);
 }
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1927,7 +1927,7 @@
 def mconsole : Joined<["-"], "mconsole">, Group, 
Flags<[DriverOption]>;
 def mwindows : Joined<["-"], "mwindows">, Group, 
Flags<[DriverOption]>;
 def mdll : Joined<["-"], "mdll">, Group, Flags<[DriverOption]>;
-def municode : Joined<["-"], "municode">, Group, 
Flags<[DriverOption]>;
+def municode : Joined<["-"], "municode">, Group, Flags<[DriverOption, 
CC1Option]>;
 def mthreads : Joined<["-"], "mthreads">, Group, 
Flags<[DriverOption]>;
 def mcpu_EQ : Joined<["-"], "mcpu=">, Group;
 def mmcu_EQ : Joined<["-"], "mmcu=">, Group;
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -164,6 +164,7 @@
 COMPATIBLE_LANGOPT(Optimize  , 1, 0, "__OPTIMIZE__ predefined macro")
 COMPATIBLE_LANGOPT(OptimizeSize  , 1, 0, "__OPTIMIZE_SIZE__ predefined 
macro")
 COMPATIBLE_LANGOPT(Static, 1, 0, "__STATIC__ predefined macro (as 
opposed to __DYNAMIC__)")
+COMPATIBLE_LANGOPT(Unicode   , 1, 0, "UNICODE predefined macro")
 VALUE_LANGOPT(PackStruct  , 32, 0,
   "default struct packing maximum alignment")
 VALUE_LANGOPT(MaxTypeAlign  , 32, 0,


Index: test/Preprocessor/predefined-win-macros.c
===
--- test/Preprocessor/predefined-win-macros.c
+++ test/Preprocessor/predefined-win-macros.c
@@ -73,12 +73,17 @@
 // RUN: %clang_cc1 -triple i686-windows-gnu %s -E -dM -o - \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-MINGW
 
+// CHECK-X86-MINGW-NOT: #define UNICODE 1
 // CHECK-X86-MINGW: #define WIN32 1
 // CHECK-X86-MINGW-NOT: #define WIN64 1
 // CHECK-X86-MINGW: #define WINNT 1
 // CHECK-X86-MINGW: #define _WIN32 1
 // CHECK-X86-MINGW-NOT: #define _WIN64 1
 
+// RUN: %clang_cc1 -triple i686-windows-gnu %s -E -dM -o - -municode \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-X86-MINGW-UNICODE
+// CHECK-X86-MINGW-UNICODE: #define UNICODE 1
+
 // RUN: %clang_cc1

[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

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

Does this do anything other than -DUNICODE? Maybe just translate it at the 
driver level and skip the -cc1 flag?


Repository:
  rC Clang

https://reviews.llvm.org/D50199



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


[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-08-02 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 158822.
Quuxplusone marked 20 inline comments as done.
Quuxplusone added a comment.

Further removal of dead code based on @Rakete's feedback.


Repository:
  rC Clang

https://reviews.llvm.org/D50119

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/DeclCXX.h
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Features.def
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/Type.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/Lexer/has_extension_cxx.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/SemaCXX/trivially-relocatable.cpp

Index: test/SemaCXX/trivially-relocatable.cpp
===
--- /dev/null
+++ test/SemaCXX/trivially-relocatable.cpp
@@ -0,0 +1,495 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// expected-diagnostics
+
+static_assert(__has_extension(trivially_relocatable), "");
+
+// It shall appear at most once in each attribute-list
+// and no attribute-argument-clause shall be present.
+
+struct [[trivially_relocatable, trivially_relocatable]] B1 {};
+// expected-error@-1{{attribute 'trivially_relocatable' cannot appear multiple times in an attribute specifier}}
+
+struct [[trivially_relocatable]] [[trivially_relocatable]] B2 {}; // should really be an error
+
+struct [[trivially_relocatable(42)]] B3 {};
+// expected-error@-1{{attribute 'trivially_relocatable' cannot have an argument list}}
+
+
+//   The first declaration of a type shall specify the
+//   trivially_relocatable attribute if any declaration of that
+//   type specifies the trivially_relocatable attribute.
+
+struct [[trivially_relocatable]] A1 {};  // ok
+struct [[trivially_relocatable]] A1;
+
+struct [[trivially_relocatable]] A2;  // ok
+struct [[trivially_relocatable]] A2 {};
+
+struct [[trivially_relocatable]] A3 {};  // ok
+struct A3;
+
+struct [[trivially_relocatable]] A4;  // ok
+struct A4 {};
+
+struct A5 {};
+struct [[trivially_relocatable]] A5;
+// expected-error@-1{{type A5 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+// expected-warning@-3{{attribute declaration must precede definition}}
+// expected-note@-5{{previous definition is here}}
+
+struct A6;
+struct [[trivially_relocatable]] A6 {};
+// expected-error@-1{{type A6 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+
+
+// If a type T is declared with the trivially_relocatable attribute, and T is either
+// not move-constructible or not destructible, the program is ill-formed.
+
+struct NonDestructible {
+NonDestructible(const NonDestructible&) = default;
+NonDestructible(NonDestructible&&) = default;
+~NonDestructible() = delete;
+};
+struct NonCopyConstructible {
+NonCopyConstructible(const NonCopyConstructible&) = delete;
+};
+struct NonMoveConstructible {
+NonMoveConstructible(const NonMoveConstructible&) = default;
+NonMoveConstructible(NonMoveConstructible&&) = delete;
+};
+static_assert(!__is_trivially_relocatable(NonDestructible), "");
+static_assert(!__is_trivially_relocatable(NonCopyConstructible), "");
+static_assert(!__is_constructible(NonCopyConstructible, NonCopyConstructible&&), "");
+static_assert(!__is_trivially_relocatable(NonMoveConstructible), "");
+static_assert(!__is_constructible(NonMoveConstructible, NonMoveConstructible&&), "");
+
+struct [[trivially_relocatable]] D1 { ~D1() = delete; };
+// expected-error@-1{{cannot be applied to struct 'D1' because it is not destructible}}
+
+struct [[trivially_relocatable]] D2 : private NonDestructible { };
+// expected-error@-1{{cannot be applied to struct 'D2' because it is not destructible}}
+
+struct [[trivially_relocatable]] D3 { D3(const D3&) = delete; };
+// expected-error@-1{{cannot be applied to struct 'D3' because it is not move-constructible}}
+
+struct [[trivially_relocatable]] D4 { D4(const D4&) = default; D4(D4&&) = delete; };
+// expected-error@-1{{cannot be applied to struct 'D4' because it is not move-constructible}}
+
+struct [[trivially_relocatable]] D5 : private NonCopyConstructible { };
+// expected-error@-1{{cannot be applied to struct 'D5' because it is not move-constructible}}
+static_assert(!__is_constructible(D5, D5&&), "");
+
+struct [[trivially_relocatable]] D6 : private NonMoveConstructible { D6(D6&&) = default; };
+// expected-error@-1{{cannot be applied to struct 'D6' because it is not move-constructible}}
+
+template
+struct [[trivially_relocatable]] DT1 : private T { };  // o

[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

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



Comment at: compiler-explorer-llvm-commit.sh:1
+# This is the commit of LLVM that we're currently based on.
+git reset --hard 1fa19f68007cd126a04448093c171f40e556087e

Rakete wrote:
> What's this file? A mistake?
Yeah, it's pipework for the Compiler Explorer integration. I manually deleted 
it from the previously uploaded diff, but forgot to delete it this time. You 
can ignore it.



Comment at: include/clang/Sema/Sema.h:4304
 
+  bool IsTriviallyRelocatableType(QualType QT) const;
+

Rakete wrote:
> Quuxplusone wrote:
> > Rakete wrote:
> > > Any reason why this is a free function? Should be a member function of 
> > > `QualType`.
> > `class QualType` is defined in `AST/`, whereas all the C++-specific 
> > TriviallyRelocatable stuff is currently confined to `Sema/`. My impression 
> > was that I should try to preserve that separation, even if it meant being 
> > ugly right here. I agree that this is a stupid hack, and would love to get 
> > rid of it, but I think I need some guidance as to how much mixing of `AST` 
> > and `Sema` is permitted.
> Nah, it's fine. There are lots of C++ specific things in AST/, because the 
> AST nodes represent C++-y stuff. Trivially copyable is also part of 
> `QualType`, even though it's C++ specific.
Okay, moved!



Comment at: lib/Sema/SemaDeclAttr.cpp:6481
 break;
+  case ParsedAttr::AT_TriviallyRelocatable:
+handleTriviallyRelocatableAttr(S, D, AL);

Rakete wrote:
> Why is this attribute under "Microsoft Attributes"? ;)
I dunno, the random `//comments` seem pretty silly to me. There's nothing 
"Microsoft" about TrivialABI either (and no reason anyone should care, in this 
context, that EmptyBases or LayoutVersion are "Microsoft"). I just put it here 
because it's somewhat related to TrivialABI — and/or, to reduce code churn if 
anyone ever decides to Do The Right Thing and alphabetize these switch cases.



Comment at: lib/Sema/SemaDeclCXX.cpp:6187
+Record->dropAttr();
+  } else if (Record->needsImplicitMoveConstructor() &&
+ Record->defaultedMoveConstructorIsDeleted()) {

Rakete wrote:
> This is dead code. `Record` never needs an implicit move constructor at this 
> point, because either 1) it never did or 2) it was defined above by 
> `LookupSpecialMember`.
Confirmed that this code is never hit; and removed. Just for my own 
information: you're saying that the call to `LookupSpecialMember` on line 6179, 
even though it's looking up the //destructor//, will actually cause all the 
`needsImplicitFootor` flags to get resolved? And so also I guess I should never 
have been looking at those flags directly; I should have handled this case by 
calling `LookupSpecialMember` like I do on line 6196. Is that basically correct?


Repository:
  rC Clang

https://reviews.llvm.org/D50119



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


[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-08-02 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:6187
+Record->dropAttr();
+  } else if (Record->needsImplicitMoveConstructor() &&
+ Record->defaultedMoveConstructorIsDeleted()) {

Quuxplusone wrote:
> Rakete wrote:
> > This is dead code. `Record` never needs an implicit move constructor at 
> > this point, because either 1) it never did or 2) it was defined above by 
> > `LookupSpecialMember`.
> Confirmed that this code is never hit; and removed. Just for my own 
> information: you're saying that the call to `LookupSpecialMember` on line 
> 6179, even though it's looking up the //destructor//, will actually cause all 
> the `needsImplicitFootor` flags to get resolved? And so also I guess I should 
> never have been looking at those flags directly; I should have handled this 
> case by calling `LookupSpecialMember` like I do on line 6196. Is that 
> basically correct?
No, not the 6179 one, but the one before it 6163. Yeah you could have :)


Repository:
  rC Clang

https://reviews.llvm.org/D50119



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


[PATCH] D49403: More aggressively complete RecordTypes with Function Pointers

2018-08-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Hi - sorry about the stalled opaque pointer types effort.

For my money - ideally - if someone comes across a bug caused by incorrect 
pointee types, ideally that would be fixed by adjusting whatever piece of code 
was depending on that pointee type being correct to not depend on that 
information. Though, yes, there are likely cases where a small bug in the type 
information exposes vast swathes of LLVM code - where the argument might 
reasonably made that the cleanup would take too long to leave things broken. 
Worth seeing what that looks like, though, before making the call - hopefully.


https://reviews.llvm.org/D49403



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


[PATCH] D49911: Summary:Add clang::reinitializes attribute

2018-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

The attribute itself is looking reasonable aside from some minor nits, but this 
should not be committed until the clang-tidy functionality is approved (since 
it has no utility beyond clang-tidy).




Comment at: include/clang/Basic/Attr.td:96
+[{!S->isStatic() && !S->isConst()}],
+"non-static non-const member functions">;
+

mboehme wrote:
> aaron.ballman wrote:
> > `non-static, non-const member functions` (with the comma)
> IIUC, Clang then translates the comma into an "and" -- so the actual 
> diagnostic becomes "non-static and non-const member functions" (see the 
> expected-error in the tests). Is this as intended?
Ugh, that's a deficiency in ClangAttrEmitter.cpp. Good thing diagnostics aren't 
grammatically correct anyway, you can roll back to the previous form. Sorry 
about the churn!



Comment at: include/clang/Basic/Attr.td:2945
+def Reinitializes : InheritableAttr {
+  let Spellings = [CXX11<"clang", "reinitializes">];
+  let Subjects = SubjectList<[NonStaticNonConstCXXMethod], ErrorDiag>;

mboehme wrote:
> aaron.ballman wrote:
> > I think it makes sense to use `CXX11` instead of `Clang` as this attribute 
> > doesn't make sense in C2x mode, but should there be a `GNU` spelling as 
> > well?
> I have to admit I'm not sure. What are the usual considerations here? Does 
> this need to be coordinated in any way with GNU, or can Clang simply 
> introduce additional "GNU-style" spellings (i.e. with `__attribute__`) that 
> are Clang-only?
> 
> I understand there's a difference between `GCC` spellings and `GNU` spellings 
> -- but I'm not sure what the rules around the latter are. Let me know if you 
> think this should have a `GNU` spelling, and I'll add it!
We generally want things with both spellings unless there's rationale 
justifying why only one spelling is better. I don't see any reason why this 
shouldn't have a GNU spelling as well.

I'd spell this as `Clang<"reinitializes", 0>` so it gets both the CXX11 and GNU 
spellings but not the C2x spelling.



Comment at: include/clang/Basic/AttrDocs.td:3426
+  let Content = [{
+The ``reinitializes`` attribute can be applied to a non-static, non-const C++
+member function to indicate that this member function reinitializes the entire

mboehme wrote:
> aaron.ballman wrote:
> > While I kind of understand the restriction on a `const` member function, 
> > what about code that has mutable members being reset within a const method?
> I find it hard to envision a method that reinitializes an object by modifying 
> only mutable member variables. Mutable members are, after all, intended to be 
> used for purposes (such as caching and locking) that do not change the 
> "logical state" of the object, whereas reinitialization is an operation that 
> does change the logical state of the object.
> 
> If it really does turn out that there are legitimate use cases for applying 
> the 'reinitializes' attribute to a const member function, we can always relax 
> this requirement later on.
That makes sense to me, thank you for the explanation.


Repository:
  rC Clang

https://reviews.llvm.org/D49911



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


[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-02 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D50199#1186164, @rnk wrote:

> Does this do anything other than -DUNICODE? Maybe just translate it at the 
> driver level and skip the -cc1 flag?


Yes, that also works. Initially I looked at where to place that in 
lib/Driver/ToolChains/MinGW.cpp, but I see that it should be in 
lib/Driver/ToolChains/Clang.cpp (I presume?).


Repository:
  rC Clang

https://reviews.llvm.org/D50199



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


[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-02 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 158827.
mstorsjo added a comment.

Simplified the patch to just handle the flag within the driver, without making 
it a flag to cc1.


https://reviews.llvm.org/D50199

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/mingw.cpp


Index: test/Driver/mingw.cpp
===
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -56,3 +56,8 @@
 // CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: 
"{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+// RUN: %clang -target i686-windows-gnu -E -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_NO_UNICODE %s
+// RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_UNICODE %s
+// CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
+// CHECK_MINGW_UNICODE: "-DUNICODE"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3346,6 +3346,9 @@
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-static-define");
 
+  if (Args.hasArg(options::OPT_municode))
+CmdArgs.push_back("-DUNICODE");
+
   if (isa(JA))
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
 


Index: test/Driver/mingw.cpp
===
--- test/Driver/mingw.cpp
+++ test/Driver/mingw.cpp
@@ -56,3 +56,8 @@
 // CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward"
 // CHECK_MINGW_UBUNTU_POSIX_TREE: "{{.*}}/Inputs/mingw_ubuntu_posix_tree/usr{{/|}}x86_64-w64-mingw32{{/|}}include"
+
+// RUN: %clang -target i686-windows-gnu -E -### %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_NO_UNICODE %s
+// RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck -check-prefix=CHECK_MINGW_UNICODE %s
+// CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
+// CHECK_MINGW_UNICODE: "-DUNICODE"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3346,6 +3346,9 @@
   if (Args.hasArg(options::OPT_static))
 CmdArgs.push_back("-static-define");
 
+  if (Args.hasArg(options::OPT_municode))
+CmdArgs.push_back("-DUNICODE");
+
   if (isa(JA))
 RenderAnalyzerOptions(Args, CmdArgs, Triple, Input);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

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



Comment at: include/clang/Basic/AttrDocs.td:3489
+
+``noderef`` is currently only supported for C style pointers and arrays and 
not usable for
+references or Objective-C pointers.

I would drop the "C style" and just say it's only supported for pointers and 
arrays.



Comment at: include/clang/Basic/AttrDocs.td:3490
+``noderef`` is currently only supported for C style pointers and arrays and 
not usable for
+references or Objective-C pointers.
+

I'd clarify this a little bit to Objective-C object pointers.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9436
+def warn_dereference_of_noderef_type : Warning<
+  "dereferencing %0; was declared with a `noderef` type">, InGroup;
+def warn_dereference_of_noderef_type_no_decl : Warning<

Please use single quotes instead of backticks in the quoting around `noderef` 
in these diagnostics.


Repository:
  rC Clang

https://reviews.llvm.org/D49511



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


[PATCH] D50135: [libunwind] [CMake] Allow building standalone without any llvm-config available

2018-08-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: CMakeLists.txt:363
 
-add_subdirectory(test)
+if (EXISTS ${LLVM_CMAKE_PATH})
+  add_subdirectory(test)

libcxx seems to be using a different condition: `IS_DIRECTORY 
"${CMAKE_CURRENT_SOURCE_DIR}/test"`, should this be unified?


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50135



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


[PATCH] D48100: Append new attributes to the end of an AttributeList.

2018-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

I am still okay with this, and agree that the ordering issues are a separate 
thing to tackle.


Repository:
  rC Clang

https://reviews.llvm.org/D48100



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


r338766 - Fix assertion failure when emitting code for a merged lambda.

2018-08-02 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Aug  2 13:30:52 2018
New Revision: 338766

URL: http://llvm.org/viewvc/llvm-project?rev=338766&view=rev
Log:
Fix assertion failure when emitting code for a merged lambda.

Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/Modules/merge-lambdas.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=338766&r1=338765&r2=338766&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Thu Aug  2 13:30:52 2018
@@ -1327,6 +1327,15 @@ bool CXXRecordDecl::isGenericLambda() co
   return getLambdaData().IsGenericLambda;
 }
 
+#ifndef NDEBUG
+static bool allLookupResultsAreTheSame(const DeclContext::lookup_result &R) {
+  for (auto *D : R)
+if (!declaresSameEntity(D, R.front()))
+  return false;
+  return true;
+}
+#endif
+
 CXXMethodDecl* CXXRecordDecl::getLambdaCallOperator() const {
   if (!isLambda()) return nullptr;
   DeclarationName Name =
@@ -1334,7 +1343,8 @@ CXXMethodDecl* CXXRecordDecl::getLambdaC
   DeclContext::lookup_result Calls = lookup(Name);
 
   assert(!Calls.empty() && "Missing lambda call operator!");
-  assert(Calls.size() == 1 && "More than one lambda call operator!");
+  assert(allLookupResultsAreTheSame(Calls) &&
+ "More than one lambda call operator!");
 
   NamedDecl *CallOp = Calls.front();
   if (const auto *CallOpTmpl = dyn_cast(CallOp))
@@ -1349,7 +1359,8 @@ CXXMethodDecl* CXXRecordDecl::getLambdaS
 &getASTContext().Idents.get(getLambdaStaticInvokerName());
   DeclContext::lookup_result Invoker = lookup(Name);
   if (Invoker.empty()) return nullptr;
-  assert(Invoker.size() == 1 && "More than one static invoker operator!");
+  assert(allLookupResultsAreTheSame(Invoker) &&
+ "More than one static invoker operator!");
   NamedDecl *InvokerFun = Invoker.front();
   if (const auto *InvokerTemplate = dyn_cast(InvokerFun))
 return cast(InvokerTemplate->getTemplatedDecl());

Modified: cfe/trunk/test/Modules/merge-lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/merge-lambdas.cpp?rev=338766&r1=338765&r2=338766&view=diff
==
--- cfe/trunk/test/Modules/merge-lambdas.cpp (original)
+++ cfe/trunk/test/Modules/merge-lambdas.cpp Thu Aug  2 13:30:52 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fmodules -verify %s
+// RUN: %clang_cc1 -fmodules -verify %s -emit-llvm-only
 // expected-no-diagnostics
 
 #pragma clang module build A


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


[PATCH] D50110: Handle shared release attributes correctly

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



Comment at: test/SemaCXX/warn-thread-safety-analysis.cpp:4081-4085
+  void unlockExclusive() EXCLUSIVE_UNLOCK_FUNCTION(mu_) {
+mu_.Unlock();
+  }
+
+  void unlockShared() SHARED_UNLOCK_FUNCTION(mu_) {

Nothing calls either of these functions within the test; is that intended?


Repository:
  rC Clang

https://reviews.llvm.org/D50110



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


[PATCH] D50135: [libunwind] [CMake] Allow building standalone without any llvm-config available

2018-08-02 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: CMakeLists.txt:363
 
-add_subdirectory(test)
+if (EXISTS ${LLVM_CMAKE_PATH})
+  add_subdirectory(test)

phosek wrote:
> libcxx seems to be using a different condition: `IS_DIRECTORY 
> "${CMAKE_CURRENT_SOURCE_DIR}/test"`, should this be unified?
Maybe, but there's more to it than that. libunwind's `test/CMakeLists.txt` will 
unconditionally try to do `include(AddLLVM)`, which fails if `LLVM_CMAKE_PATH` 
isn't set. libcxx's `test/CMakeLists.txt` on the other hand will only try to do 
that if `LIBCXX_INCLUDE_TESTS` is defined, which it isn't by default.

There's lots of the llvm/cmake handling that seems to be quite outdated in 
libunwind compared to libcxxabi/libcxx, but I'm not really volunteering to 
unify that...


Repository:
  rUNW libunwind

https://reviews.llvm.org/D50135



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


Re: r338749 - Work around more GCC miscompiles exposed by r338464.

2018-08-02 Thread Richard Smith via cfe-commits
(+Hans) +1

On Thu, 2 Aug 2018 at 11:37, Martin Storsjö via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hans,
>
> I think this commit should be merged to the 7.0 release branch; the first
> half of the GCC workaround made it in before the branch happened, but
> there was another identical case missing.
>
> // Martin
>
> On Thu, 2 Aug 2018, Martin Storsjo via cfe-commits wrote:
>
> > Author: mstorsjo
> > Date: Thu Aug  2 11:12:08 2018
> > New Revision: 338749
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=338749&view=rev
> > Log:
> > Work around more GCC miscompiles exposed by r338464.
> >
> > This is the same fix as in r338478, for another occurrance of the
> > same pattern from r338464.
> >
> > See gcc.gnu.org/PR86769 for details of the bug.
>
> ___
> 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] D46822: [RISCV] Add driver for riscv32-unknown-elf baremetal target

2018-08-02 Thread Simon Cook via Phabricator via cfe-commits
simoncook added a comment.

It seems the ability to link objects has been broken by this change. As an 
example from our nightly tests:

  Executing on host: riscv32-unknown-elf-clang 
/data/jenkins/workspace/riscv32-llvm-gcc/gcc-tests/gcc/testsuite/gcc.c-torture/execute/20080502-1.c
  -march=rv32gc -mabi=ilp32  -O1  -w  -lm  -o ./20080502-1.exe
(timeout = 600)
  spawn -ignore SIGHUP riscv32-unknown-elf-clang 
/data/jenkins/workspace/riscv32-llvm-gcc/gcc-tests/gcc/testsuite/gcc.c-torture/execute/20080502-1.c
 -march=rv32gc -mabi=ilp32 -O1 -w -lm -o ./20080502-1.exe
  /data/jenkins/workspace/riscv32-llvm-gcc/install/bin/riscv32-unknown-elf-ld: 
cannot find crt0.o: No such file or directory
  clang-8: error: ld command failed with exit code 1 (use -v to see invocation)
  compiler exited with status 1
  FAIL: gcc.c-torture/execute/20080502-1.c   -O1  (test for excess errors)

Running with `-v` shows the link command as:

  "/data/jenkins/workspace/riscv32-llvm-gcc/install/bin/riscv32-unknown-elf-ld" 
crt0.o 
/data/jenkins/workspace/riscv32-llvm-gcc/install/bin/../lib/gcc/riscv32-unknown-elf/8.1.0/crtbegin.o
 -L/lib 
-L/data/jenkins/workspace/riscv32-llvm-gcc/install/bin/../lib/gcc/riscv32-unknown-elf/8.1.0
 /tmp/20080502-1-2b0022.o -lm --start-group -lc -lgloss --end-group -lgcc 
/data/jenkins/workspace/riscv32-llvm-gcc/install/bin/../lib/gcc/riscv32-unknown-elf/8.1.0/crtend.o
 -o ./20080502-1.exe

What's noticeable is `crt0.o` is specified just as a file, and we're trying to 
link in my host `/lib/` (`-L/lib`)? If I manually specify a sysroot (via 
`--sysroot=$INSTALLDIR/riscv32-unknown-elf`), then my link succeeds, adding the 
path to `crt0.o`, and the correct `/lib`:

  "/data/jenkins/workspace/riscv32-llvm-gcc/install/bin/riscv32-unknown-elf-ld" 
--sysroot=/data/jenkins/workspace/riscv32-llvm-gcc/install/riscv32-unknown-elf 
/data/jenkins/workspace/riscv32-llvm-gcc/install/riscv32-unknown-elf/lib/crt0.o 
/data/jenkins/workspace/riscv32-llvm-gcc/install/bin/../lib/gcc/riscv32-unknown-elf/8.1.0/crtbegin.o
 -L/data/jenkins/workspace/riscv32-llvm-gcc/install/riscv32-unknown-elf/lib 
-L/data/jenkins/workspace/riscv32-llvm-gcc/install/bin/../lib/gcc/riscv32-unknown-elf/8.1.0
 /tmp/20080502-1-d53be0.o -lm --start-group -lc -lgloss --end-group -lgcc 
/data/jenkins/workspace/riscv32-llvm-gcc/install/bin/../lib/gcc/riscv32-unknown-elf/8.1.0/crtend.o
 -o ./20080502-1.exe

I think there's some missing calculate the correct sysroot directory logic 
missing, unless linking `clang` to `riscv32-unknown-elf-clang` is no longer 
sufficient for everything to work now?


Repository:
  rC Clang

https://reviews.llvm.org/D46822



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


[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-02 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

In https://reviews.llvm.org/D50199#1186164, @rnk wrote:

> Does this do anything other than -DUNICODE? Maybe just translate it at the 
> driver level and skip the -cc1 flag?


It seems odd to include predefined macros at the driver, which AFAIK is just a 
bridge to the frontend's command-line interface.  OTOH, there is other 
precedence for doing this - during clang-cl's argument processing.  So I don't 
have a strong opinion here.


https://reviews.llvm.org/D50199



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


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-02 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> Dereferencing is disabled by default

Great! Thank you!

> but I haven't seen the current version of the checker crash due to pointer 
> chasing.

@NoQ saw quite a few crashes during evaluation, right?

> This might be a little nit-picking, but I don't think the finds are false 
> positive

Well, yeah, it depends on how do you define things. If we define reports as 
"bugs", then I guess this checker already does not find bugs, but 
best-practices violations.
Then it can be argued whether "best practice" should be extended to include all 
the memory reachable through pointers.


https://reviews.llvm.org/D49438



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


[PATCH] D49438: [analyzer][UninitializedObjectChecker] New flag to turn off dereferencing

2018-08-02 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov requested changes to this revision.
george.karpenkov added a comment.
This revision now requires changes to proceed.

Great! The comment should be updated though.




Comment at: lib/StaticAnalyzer/Checkers/UninitializedObjectChecker.cpp:32
+//  `-analyzer-config \
+// 
alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true`.
+//

The comment is outdated and "true" should be switched to "false", right?


https://reviews.llvm.org/D49438



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


[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-02 Thread Charles Davis via Phabricator via cfe-commits
cdavis5x added a comment.

Are you sure this shouldn't also define `_UNICODE`? //looks// Hmm... GCC 
doesn't define it. I wonder if we should anyway. A user who set `-municode` may 
also be using ``, and thus may want those macros set to their Unicode 
counterparts.

I actually believe this is supposed to have one other effect: it sets the entry 
point to `wmainCRTStartup()`/`wWinMainCRTStartup()`, making the user entry 
point `wmain()`/`wWinMain()`, which take wide arguments:

  int wmain(int argc, wchar_t **argv);
  int WINAPI wWinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPWSTR pwszCmdLine, 
int nCmdShow);

But that's a link-time effect. I believe it has no bearing on @rnk's comment.

...Actually, that suggests that we may want to warn if the user defines 
`main()` or `WinMain()` instead of their Unicode counterparts when `-municode` 
is given--which means we may want to pass it to the frontend after all.


https://reviews.llvm.org/D50199



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


[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-08-02 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:6187
+Record->dropAttr();
+  } else if (Record->needsImplicitMoveConstructor() &&
+ Record->defaultedMoveConstructorIsDeleted()) {

Rakete wrote:
> Quuxplusone wrote:
> > Rakete wrote:
> > > This is dead code. `Record` never needs an implicit move constructor at 
> > > this point, because either 1) it never did or 2) it was defined above by 
> > > `LookupSpecialMember`.
> > Confirmed that this code is never hit; and removed. Just for my own 
> > information: you're saying that the call to `LookupSpecialMember` on line 
> > 6179, even though it's looking up the //destructor//, will actually cause 
> > all the `needsImplicitFootor` flags to get resolved? And so also I guess I 
> > should never have been looking at those flags directly; I should have 
> > handled this case by calling `LookupSpecialMember` like I do on line 6196. 
> > Is that basically correct?
> No, not the 6179 one, but the one before it 6163. Yeah you could have :)
Sorry for the noise, that isn't it because of the if statement right before 
6163 :/. I was wrong...

Every implicit constructor is already defined before the call to 
`CheckCompletedCXXClass` (except if it's a template), so `needsImplicitFootor` 
is always `false`. This means that you can drop the if statement right before 
6163, because it's always true.

I'm 99% sure of the previous paragraph. :)



Comment at: lib/Sema/SemaDeclCXX.cpp:6091
 
+  for (auto *F : Record->fields()) {
+if (F->isMutable()) {

Can you move this in `ActOnFields`? That way we avoid two iterations of the 
fields.


Repository:
  rC Clang

https://reviews.llvm.org/D50119



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


[PATCH] D50199: [MinGW] Predefine UNICODE if -municode is specified during compilation

2018-08-02 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D50199#1186282, @cdavis5x wrote:

> I actually believe this is supposed to have one other effect: it sets the 
> entry point to `wmainCRTStartup()`/`wWinMainCRTStartup()`, making the user 
> entry point `wmain()`/`wWinMain()`, which take wide arguments:


It already does this; lld (and I guess ld.bfd as well) detect the entry point 
based on what symbols are available. But this flag switches between passing 
crt2.o and crt2u.o to the linker, essentially forcing an undefined reference to 
either main or wmain.


https://reviews.llvm.org/D50199



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


  1   2   >