[PATCH] D41779: [clang-tidy] Fix DanglingHandleCheck for the correct conversion operation between basic_string and basic_string_view.

2018-01-08 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41779



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


[PATCH] D41039: Add support for attribute "trivial_abi"

2018-01-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 128895.
ahatanak added a comment.

Address review comments.

Also, emit the declaration of the destructor of a trivial-abi override class in 
Sema::ActOnParamDeclarator and mark it as referenced. This is necessary because 
a trivial-abi type that is passed by value needs to be destructed in the callee 
and the destructor has to be declared in the AST when IRGen emits the call to 
the destructor in the callee.


https://reviews.llvm.org/D41039

Files:
  include/clang/AST/Decl.h
  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/Sema/Sema.h
  lib/AST/DeclCXX.cpp
  lib/AST/Type.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGenCXX/trivial_abi.cpp
  test/CodeGenObjCXX/trivial_abi.mm
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/SemaObjCXX/attr-trivial-abi.mm

Index: test/SemaObjCXX/attr-trivial-abi.mm
===
--- /dev/null
+++ test/SemaObjCXX/attr-trivial-abi.mm
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -std=c++11 -fobjc-runtime-has-weak -fobjc-weak -fobjc-arc -fsyntax-only -verify %s
+
+void __attribute__((trivial_abi)) foo(); // expected-warning {{'trivial_abi' attribute only applies to classes}}
+
+struct [[clang::trivial_abi]] S0 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S1 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S2 { // expected-warning {{'trivial_abi' cannot be applied to 'S2'}}
+  __weak id a;
+};
+
+struct __attribute__((trivial_abi)) S3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3'}}
+  virtual void m();
+};
+
+struct S4 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S5 : public virtual S4 { // expected-warning {{'trivial_abi' cannot be applied to 'S5'}}
+};
+
+struct __attribute__((trivial_abi)) S9 : public S4 {
+};
+
+struct S6 {
+  __weak id a;
+};
+
+struct __attribute__((trivial_abi)) S12 { // expected-warning {{'trivial_abi' cannot be applied to 'S12'}}
+  __weak id a;
+};
+
+struct __attribute__((trivial_abi)) S13 { // expected-warning {{'trivial_abi' cannot be applied to 'S13'}}
+  __weak id a[2];
+};
+
+struct __attribute__((trivial_abi)) S7 { // expected-warning {{'trivial_abi' cannot be applied to 'S7'}}
+  S6 a;
+};
+
+struct __attribute__((trivial_abi)) S11 { // expected-warning {{'trivial_abi' cannot be applied to 'S11'}}
+  S6 a[2];
+};
+
+struct __attribute__((trivial_abi(1))) S8 { // expected-error {{'trivial_abi' attribute takes no arguments}}
+  int a;
+};
+
+template
+struct __attribute__((trivial_abi)) S10 {
+  T p;
+};
+
+S10 p1;
+
+// Do not warn when 'trivial_abi' is used to annotate a template class.
+S10<__weak id> p2;
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 66 attributes:
+// CHECK: #pragma clang attribute supports 67 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -66,6 +66,7 @@
 // CHECK-NEXT: TLSModel (SubjectMatchRule_variable_is_thread_local)
 // CHECK-NEXT: Target (SubjectMatchRule_function)
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
+// CHECK-NEXT: TrivialABI (SubjectMatchRule_record)
 // CHECK-NEXT: WarnUnusedResult (SubjectMatchRule_objc_method, SubjectMatchRule_enum, SubjectMatchRule_record, SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: XRayInstrument (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: XRayLogArgs (SubjectMatchRule_function, SubjectMatchRule_objc_method)
Index: test/CodeGenObjCXX/trivial_abi.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/trivial_abi.mm
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fobjc-arc  -fobjc-weak -fobjc-runtime-has-weak -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: %[[STRUCT_STRONGWEAK:.*]] = type { i8*, i8* }
+// CHECK: %[[STRUCT_STRONG:.*]] = type { i8* }
+
+struct __attribute__((trivial_abi)) StrongWeak {
+  id fstrong;
+  __weak id fweak;
+};
+
+struct __attribute__((trivial_abi)) Strong {
+  id fstrong;
+};
+
+// CHECK: define void @_Z19testParamStrongWeak10StrongWeak(%[[STRUCT_STRONGWEAK]]* %{{.*}})
+// CH

[PATCH] D41039: Add support for attribute "trivial_abi"

2018-01-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked 4 inline comments as done.
ahatanak added a comment.

In https://reviews.llvm.org/D41039#969171, @rjmccall wrote:

> I'll trust Richard on the tricky Sema/AST bits.  The functionality of the 
> patch looks basically acceptable to me, although I'm still not thrilled about 
> the idea of actually removing the attribute from the AST rather than just 
> letting it not have effect.  But we could clean that up later if it's 
> significantly simpler to do it this way.


Sure, we can clean up this later.

> Please add a CodeGenObjCXX test case that `__weak` fields in ARC++ do 
> actually override the `trivial_abi` attribute but that `__strong` fields do 
> not.  Also, your test case does not seem to actually test arrays of `__weak` 
> references.

Done. When I was writing a test that tests `__strong` fields, I found out that 
the destructor of the struct wasn't being declared in the AST, which caused an 
assertion to fail in CodeGenFunction::destroyCXXObject when compiling a 
function that takes a trivial_abi type. I fixed it by forcing the declaration 
of the destructor in Sema::ActOnParamDeclarator.




Comment at: include/clang/Basic/Attr.td:1159
+def TrivialABI : InheritableAttr {
+  let Spellings = [Clang<"trivial_abi">];
+  let Subjects = SubjectList<[CXXRecord]>;

aaron.ballman wrote:
> Would this attribute make sense in C, or does it really only make sense in 
> C++? If it doesn't make sense in C++, then you should also set `LangOpts` to 
> be `CPlusPlus`. If it does make sense in C, then the Clang spelling should be 
> `Clang<"trivial_abi", 1>`
I don't think this attribute makes sense in C, so I've set the LangOpts to be 
CPlusPlus.



Comment at: lib/CodeGen/CGDecl.cpp:1825
+HasTrivialABIOverride =
+RD->canPassInRegisters() && RD->hasNonTrivialDestructor();
+

rjmccall wrote:
> You could make a helper function to do this computation and then declare it 
> in some internal-to-IRGen header so that you don't write it out multiple 
> times.
It turns out Sema needs this function too. I defined function 
hasTrivialABIOverride in CXXRecordDecl and moved the code there.


https://reviews.llvm.org/D41039



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


[PATCH] D41815: [clang-tidy] implement check for goto

2018-01-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth created this revision.
JonasToth added reviewers: aaron.ballman, alexfh, hokein.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, mgorny, nemanjai, 
klimek.

The usage of `goto` is discourage in C++ since forever. This check implements
a warning for every `goto`. Even though there are (rare) valid use cases for
`goto`, better high level constructs should be used.

`goto` is used sometimes in C programs to free resources at the end of 
functions in the case of errors. This pattern is better implemented with
RAII in C++.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815

Files:
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-avoid-goto.cpp

Index: test/clang-tidy/cppcoreguidelines-avoid-goto.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-avoid-goto.cpp
@@ -0,0 +1,7 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-avoid-goto %t
+
+void main() {
+jump_to_me:
+  goto jump_to_me;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: goto is considered harmful; use high level programming constructs instead
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -52,6 +52,7 @@
cert-msc30-c (redirects to cert-msc50-cpp) 
cert-msc50-cpp
cert-oop11-cpp (redirects to performance-move-constructor-init) 
+   cppcoreguidelines-avoid-goto
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-interfaces-global-init
cppcoreguidelines-no-malloc
Index: docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
@@ -0,0 +1,11 @@
+.. title:: clang-tidy - cppcoreguidelines-avoid-goto
+
+cppcoreguidelines-avoid-goto
+
+
+The usage of ``goto`` has been discouraged for a long time and is diagnosed
+with this check.
+
+This check implements `ES.76 `_ 
+from the CppCoreGuidelines. For more information on why to avoid programming 
+with ``goto`` you can read the famous paper `A Case against the GO TO Statement. `_.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,12 @@
 Improvements to clang-tidy
 --
 
+- New `cppcoreguidelines-avoid-goto
+  `_ check
+
+  The usage of ``goto`` has been discouraged for a long time and is diagnosed
+  with this check.
+
 - ...
 
 Improvements to include-fixer
Index: clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
===
--- clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/UnconventionalAssignOperatorCheck.h"
+#include "AvoidGotoCheck.h"
 #include "InterfacesGlobalInitCheck.h"
 #include "NoMallocCheck.h"
 #include "OwningMemoryCheck.h"
@@ -35,6 +36,8 @@
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-avoid-goto");
 CheckFactories.registerCheck(
 "cppcoreguidelines-interfaces-global-init");
 CheckFactories.registerCheck("cppcoreguidelines-no-malloc");
Index: clang-tidy/cppcoreguidelines/CMakeLists.txt
===
--- clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCppCoreGuidelinesModule
+  AvoidGotoCheck.cpp
   CppCoreGuidelinesTidyModule.cpp
   InterfacesGlobalInitCheck.cpp
   NoMallocCheck.cpp
Index: clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidGotoCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This 

[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.

2018-01-08 Thread Peter Siket via Phabricator via cfe-commits
MontyKutyi added a comment.

In https://reviews.llvm.org/D34030#967749, @bruno wrote:

> The change seems good to me in general. I wonder if this will hit any broken 
> assumption in the code. Did you run other tests beside unittests?


I run the tests available by building the `clang-test` only.


https://reviews.llvm.org/D34030



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


[PATCH] D41815: [clang-tidy] implement check for goto

2018-01-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 128898.
JonasToth added a comment.

- fix typos and return type of main in test


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815

Files:
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-avoid-goto.cpp

Index: test/clang-tidy/cppcoreguidelines-avoid-goto.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-avoid-goto.cpp
@@ -0,0 +1,7 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-avoid-goto %t
+
+int main() {
+jump_to_me:
+  goto jump_to_me;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: goto is considered harmful; use high level programming constructs instead
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -52,6 +52,7 @@
cert-msc30-c (redirects to cert-msc50-cpp) 
cert-msc50-cpp
cert-oop11-cpp (redirects to performance-move-constructor-init) 
+   cppcoreguidelines-avoid-goto
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-interfaces-global-init
cppcoreguidelines-no-malloc
Index: docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
@@ -0,0 +1,11 @@
+.. title:: clang-tidy - cppcoreguidelines-avoid-goto
+
+cppcoreguidelines-avoid-goto
+
+
+The usage of ``goto`` has been discouraged for a long time and is diagnosed
+with this check.
+
+This check implements `ES.76 `_ 
+from the CppCoreGuidelines. For more information on why to avoid programming 
+with ``goto`` you can read the famous paper `A Case against the GO TO Statement. `_.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,12 @@
 Improvements to clang-tidy
 --
 
+- New `cppcoreguidelines-avoid-goto
+  `_ check
+
+  The usage of ``goto`` has been discouraged for a long time and is diagnosed
+  with this check.
+
 - ...
 
 Improvements to include-fixer
Index: clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
===
--- clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/UnconventionalAssignOperatorCheck.h"
+#include "AvoidGotoCheck.h"
 #include "InterfacesGlobalInitCheck.h"
 #include "NoMallocCheck.h"
 #include "OwningMemoryCheck.h"
@@ -35,6 +36,8 @@
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-avoid-goto");
 CheckFactories.registerCheck(
 "cppcoreguidelines-interfaces-global-init");
 CheckFactories.registerCheck("cppcoreguidelines-no-malloc");
Index: clang-tidy/cppcoreguidelines/CMakeLists.txt
===
--- clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCppCoreGuidelinesModule
+  AvoidGotoCheck.cpp
   CppCoreGuidelinesTidyModule.cpp
   InterfacesGlobalInitCheck.cpp
   NoMallocCheck.cpp
Index: clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidGotoCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDGOTOCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDGOTOCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namesp

[PATCH] D41815: [clang-tidy] implement check for goto

2018-01-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 128899.
JonasToth added a comment.

- [Misc] emphasize goto in warning message


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815

Files:
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-avoid-goto.cpp

Index: test/clang-tidy/cppcoreguidelines-avoid-goto.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-avoid-goto.cpp
@@ -0,0 +1,7 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-avoid-goto %t
+
+int main() {
+jump_to_me:
+  goto jump_to_me;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'goto' is considered harmful; use high level programming constructs instead
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -52,6 +52,7 @@
cert-msc30-c (redirects to cert-msc50-cpp) 
cert-msc50-cpp
cert-oop11-cpp (redirects to performance-move-constructor-init) 
+   cppcoreguidelines-avoid-goto
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-interfaces-global-init
cppcoreguidelines-no-malloc
Index: docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
@@ -0,0 +1,11 @@
+.. title:: clang-tidy - cppcoreguidelines-avoid-goto
+
+cppcoreguidelines-avoid-goto
+
+
+The usage of ``goto`` has been discouraged for a long time and is diagnosed
+with this check.
+
+This check implements `ES.76 `_ 
+from the CppCoreGuidelines. For more information on why to avoid programming 
+with ``goto`` you can read the famous paper `A Case against the GO TO Statement. `_.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,12 @@
 Improvements to clang-tidy
 --
 
+- New `cppcoreguidelines-avoid-goto
+  `_ check
+
+  The usage of ``goto`` has been discouraged for a long time and is diagnosed
+  with this check.
+
 - ...
 
 Improvements to include-fixer
Index: clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
===
--- clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/UnconventionalAssignOperatorCheck.h"
+#include "AvoidGotoCheck.h"
 #include "InterfacesGlobalInitCheck.h"
 #include "NoMallocCheck.h"
 #include "OwningMemoryCheck.h"
@@ -35,6 +36,8 @@
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-avoid-goto");
 CheckFactories.registerCheck(
 "cppcoreguidelines-interfaces-global-init");
 CheckFactories.registerCheck("cppcoreguidelines-no-malloc");
Index: clang-tidy/cppcoreguidelines/CMakeLists.txt
===
--- clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCppCoreGuidelinesModule
+  AvoidGotoCheck.cpp
   CppCoreGuidelinesTidyModule.cpp
   InterfacesGlobalInitCheck.cpp
   NoMallocCheck.cpp
Index: clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidGotoCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDGOTOCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDGOTOCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+names

[PATCH] D41815: [clang-tidy] implement check for goto

2018-01-08 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

A high level comment: while it is very easy to get all the gotos using grep, it 
is not so easy to get all the labels. So for this check to be complete, I think 
it would be useful to also find labels (possibly having a configuration option 
for that).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815



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


[PATCH] D41815: [clang-tidy] implement check for goto

2018-01-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 128902.
JonasToth added a comment.

- [Misc] reformat


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815

Files:
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp
  clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-avoid-goto.cpp

Index: test/clang-tidy/cppcoreguidelines-avoid-goto.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-avoid-goto.cpp
@@ -0,0 +1,7 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-avoid-goto %t
+
+int main() {
+jump_to_me:
+  goto jump_to_me;
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'goto' is considered harmful; use high level programming constructs instead
+}
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -52,6 +52,7 @@
cert-msc30-c (redirects to cert-msc50-cpp) 
cert-msc50-cpp
cert-oop11-cpp (redirects to performance-move-constructor-init) 
+   cppcoreguidelines-avoid-goto
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-interfaces-global-init
cppcoreguidelines-no-malloc
Index: docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst
@@ -0,0 +1,11 @@
+.. title:: clang-tidy - cppcoreguidelines-avoid-goto
+
+cppcoreguidelines-avoid-goto
+
+
+The usage of ``goto`` has been discouraged for a long time and is diagnosed
+with this check.
+
+This check implements `ES.76 `_ 
+from the CppCoreGuidelines. For more information on why to avoid programming 
+with ``goto`` you can read the famous paper `A Case against the GO TO Statement. `_.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,12 @@
 Improvements to clang-tidy
 --
 
+- New `cppcoreguidelines-avoid-goto
+  `_ check
+
+  The usage of ``goto`` has been discouraged for a long time and is diagnosed
+  with this check.
+
 - ...
 
 Improvements to include-fixer
Index: clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
===
--- clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../misc/UnconventionalAssignOperatorCheck.h"
+#include "AvoidGotoCheck.h"
 #include "InterfacesGlobalInitCheck.h"
 #include "NoMallocCheck.h"
 #include "OwningMemoryCheck.h"
@@ -35,6 +36,8 @@
 class CppCoreGuidelinesModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"cppcoreguidelines-avoid-goto");
 CheckFactories.registerCheck(
 "cppcoreguidelines-interfaces-global-init");
 CheckFactories.registerCheck("cppcoreguidelines-no-malloc");
Index: clang-tidy/cppcoreguidelines/CMakeLists.txt
===
--- clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyCppCoreGuidelinesModule
+  AvoidGotoCheck.cpp
   CppCoreGuidelinesTidyModule.cpp
   InterfacesGlobalInitCheck.cpp
   NoMallocCheck.cpp
Index: clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
===
--- /dev/null
+++ clang-tidy/cppcoreguidelines/AvoidGotoCheck.h
@@ -0,0 +1,36 @@
+//===--- AvoidGotoCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDGOTOCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDGOTOCHECK_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {

[PATCH] D41792: [AArch64] Add ARMv8.2-A FP16 scalar intrinsics

2018-01-08 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Thanks for working on this! 
Some comments inline.




Comment at: clang/include/clang/Basic/arm_fp16.td:19
+// The operations are subclasses of Operation providing a list of DAGs, the
+// last of which is the return value. 
+//

nit: trailing whitespace.



Comment at: clang/include/clang/Basic/arm_fp16.td:58
+class IInst : Inst {}
+
+// ARMv8.2-A FP16 intrinsics.

There's a little bit of duplication here: the definitions above are the same as 
in arm_neon.td. Would it be easy to share this, with e.g. an include?



Comment at: clang/include/clang/Basic/arm_fp16.td:79
+
+  // Rounding 
+  def FRINTZ_S64H : SInst<"vrnd", "ss", "Sh">;

trailing whitespace



Comment at: clang/include/clang/Basic/arm_fp16.td:88
+
+  // Conversion 
+  def SCALAR_SCVTFSH   :  SInst<"vcvth_f16", "Ys", "silUsUiUl">;

trailing whitespace



Comment at: clang/include/clang/Basic/arm_fp16.td:89
+  // Conversion 
+  def SCALAR_SCVTFSH   :  SInst<"vcvth_f16", "Ys", "silUsUiUl">;
+  def SCALAR_FCVTZSH   :  SInst<"vcvt_s16", "$s", "Sh">;

Nit: for the definitions below, indentation is sometimes a bit off. I.e. some 
defs have 1 space after the semicolon others have 2.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:4102
   NEONMAP1(vuqadds_s32, aarch64_neon_suqadd, Add1ArgType),
+  // FP16 scalar intrinisics go here.
+  NEONMAP1(vabdh_f16, aarch64_sisd_fabd, Add1ArgType),

Looks like  a few intrinsic descriptions are missing here. For example, the 
first 2-operand intrinsic vaddh_f16 is missing, but there are also more. Is 
this intentional, or might they have slipped through the cracks (or am I 
missing something)?



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:149
 [IntrNoMem]>;
+
+  class AdvSIMD_1Arg_Intrinsic

This and the other changes in this file are changes to LLVM. Do we need these 
changes for this patch? It doesn't look like it.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:360
   // Vector Absolute Value
-  def int_aarch64_neon_abs : AdvSIMD_1IntArg_Intrinsic;
+  //def int_aarch64_neon_abs : AdvSIMD_1IntArg_Intrinsic;
+  def int_aarch64_neon_abs : AdvSIMD_1Arg_Intrinsic;

Forgot to remove this?


https://reviews.llvm.org/D41792



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


[PATCH] D41179: [Sema] Diagnose template specializations with C linkage

2018-01-08 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

ping


https://reviews.llvm.org/D41179



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


[PATCH] D41815: [clang-tidy] implement check for goto

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

In https://reviews.llvm.org/D41815#969626, @xazax.hun wrote:

> A high level comment: while it is very easy to get all the gotos using grep, 
> it is not so easy to get all the labels. So for this check to be complete, I 
> think it would be useful to also find labels (possibly having a configuration 
> option for that).


Agreed. I will add warnings for jump labels too. Do you think a note where a 
goto jumps to would be helpful too?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815



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


[PATCH] D41759: [clangd] Catch more symbols in SymbolCollector.

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



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

Why don't we include symbols from anonymous namespaces too?
They are very similar to static symbols.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41759



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


[PATCH] D41816: [analyzer] Model and check unrepresentable left shifts

2018-01-08 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs created this revision.
rnkovacs added reviewers: NoQ, dcoughlin, xazax.hun.
Herald added subscribers: a.sidorin, szepet, baloghadamsoftware, whisperity.

Left shifting a signed positive value is undefined if the result is not 
representable in the unsigned version of the return type.

The analyzer now returns an UndefVal in this case and UndefResultChecker is 
updated to warn about it.


https://reviews.llvm.org/D41816

Files:
  lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  test/Analysis/bitwise-ops.c


Index: test/Analysis/bitwise-ops.c
===
--- test/Analysis/bitwise-ops.c
+++ test/Analysis/bitwise-ops.c
@@ -51,3 +51,9 @@
   }
   return 0;
 }
+
+int testUnrepresentableLeftShift(int a) {
+  if (a == 8)
+return a << 30; // expected-warning{{The result of the left shift is 
undefined because it is not representable in the return type}}
+  return 0;
+}
Index: lib/StaticAnalyzer/Core/BasicValueFactory.cpp
===
--- lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+++ lib/StaticAnalyzer/Core/BasicValueFactory.cpp
@@ -224,7 +224,6 @@
   // FIXME: This logic should probably go higher up, where we can
   // test these conditions symbolically.
 
-  // FIXME: Expand these checks to include all undefined behavior.
   if (V1.isSigned() && V1.isNegative())
 return nullptr;
 
@@ -236,16 +235,17 @@
   if (Amt >= V1.getBitWidth())
 return nullptr;
 
+  if (V1.isSigned() && (unsigned) Amt > V1.countLeadingZeros())
+  return nullptr;
+
   return &getValue( V1.operator<<( (unsigned) Amt ));
 }
 
 case BO_Shr: {
 
   // FIXME: This logic should probably go higher up, where we can
   // test these conditions symbolically.
 
-  // FIXME: Expand these checks to include all undefined behavior.
-
   if (V2.isSigned() && V2.isNegative())
 return nullptr;
 
Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -141,6 +141,15 @@
  C.isNegative(B->getLHS())) {
 OS << "The result of the left shift is undefined because the left "
   "operand is negative";
+  } else if (B->getOpcode() == BinaryOperatorKind::BO_Shl) {
+SValBuilder &SB = C.getSValBuilder();
+const llvm::APSInt *LHS =
+SB.getKnownValue(state, C.getSVal(B->getLHS()));
+const llvm::APSInt *RHS =
+SB.getKnownValue(state, C.getSVal(B->getRHS()));
+if ((unsigned) RHS->getZExtValue() > LHS->countLeadingZeros())
+  OS << "The result of the left shift is undefined because it is not "
+"representable in the return type";
   } else {
 OS << "The result of the '"
<< BinaryOperator::getOpcodeStr(B->getOpcode())


Index: test/Analysis/bitwise-ops.c
===
--- test/Analysis/bitwise-ops.c
+++ test/Analysis/bitwise-ops.c
@@ -51,3 +51,9 @@
   }
   return 0;
 }
+
+int testUnrepresentableLeftShift(int a) {
+  if (a == 8)
+return a << 30; // expected-warning{{The result of the left shift is undefined because it is not representable in the return type}}
+  return 0;
+}
Index: lib/StaticAnalyzer/Core/BasicValueFactory.cpp
===
--- lib/StaticAnalyzer/Core/BasicValueFactory.cpp
+++ lib/StaticAnalyzer/Core/BasicValueFactory.cpp
@@ -224,7 +224,6 @@
   // FIXME: This logic should probably go higher up, where we can
   // test these conditions symbolically.
 
-  // FIXME: Expand these checks to include all undefined behavior.
   if (V1.isSigned() && V1.isNegative())
 return nullptr;
 
@@ -236,16 +235,17 @@
   if (Amt >= V1.getBitWidth())
 return nullptr;
 
+  if (V1.isSigned() && (unsigned) Amt > V1.countLeadingZeros())
+  return nullptr;
+
   return &getValue( V1.operator<<( (unsigned) Amt ));
 }
 
 case BO_Shr: {
 
   // FIXME: This logic should probably go higher up, where we can
   // test these conditions symbolically.
 
-  // FIXME: Expand these checks to include all undefined behavior.
-
   if (V2.isSigned() && V2.isNegative())
 return nullptr;
 
Index: lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -141,6 +141,15 @@
  C.isNegative(B->getLHS())) {
 OS << "The result of the left shift is undefined because the left "
   "operand is negative";
+  } else if (B->getOpcode() == Bi

[PATCH] D41759: [clangd] Catch more symbols in SymbolCollector.

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



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

ilya-biryukov wrote:
> Why don't we include symbols from anonymous namespaces too?
> They are very similar to static symbols.
Yeah, these symbols need a special handling (the qualified name is like 
`foobar`), we don't support them well enough. I think it is fine 
to ignore them at the moment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41759



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


[PATCH] D41815: [clang-tidy] implement check for goto

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

In https://reviews.llvm.org/D41815#969673, @JonasToth wrote:

> In https://reviews.llvm.org/D41815#969626, @xazax.hun wrote:
>
> > A high level comment: while it is very easy to get all the gotos using 
> > grep, it is not so easy to get all the labels. So for this check to be 
> > complete, I think it would be useful to also find labels (possibly having a 
> > configuration option for that).
>
>
> Agreed. I will add warnings for jump labels too. Do you think a note where a 
> goto jumps to would be helpful too?


Rather than add a warning for the labels, I would just add a note for the label 
when diagnosing the goto (since the goto has a single target).




Comment at: clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp:22
+  if (getLangOpts().CPlusPlus)
+Finder->addMatcher(gotoStmt().bind("goto"), this);
+}

Are you planning to add the exception listed in the C++ Core Guideline? It 
makes an explicit exception allowing you to jump forward out of a loop 
construct.



Comment at: clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp:22
+  if (getLangOpts().CPlusPlus)
+Finder->addMatcher(gotoStmt().bind("goto"), this);
+}

aaron.ballman wrote:
> Are you planning to add the exception listed in the C++ Core Guideline? It 
> makes an explicit exception allowing you to jump forward out of a loop 
> construct.
What should this check do with indirect goto statements (it's a GCC extension 
we support where you can jump to an expression)?

Regardless, there should be a test for indirect gotos and jump forward out of 
loop constructs.



Comment at: clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp:27-28
+  const auto *Match = Result.Nodes.getNodeAs("goto");
+  diag(Match->getGotoLoc(), "'goto' is considered harmful; use high level "
+"programming constructs instead")
+  << Match->getSourceRange();

I don't think this diagnostic really helps the user all that much. It doesn't 
say what's harmful about the goto, nor what high level programming construct to 
use to make it not harmful.



Comment at: docs/clang-tidy/checks/cppcoreguidelines-avoid-goto.rst:6-7
+
+The usage of ``goto`` has been discouraged for a long time and is diagnosed
+with this check.
+

This doesn't really help the user understand what's bad about goto or why it 
should be diagnosed. You should expound a bit here.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815



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


[PATCH] D40712: [Driver] Add flag enabling the function stack size section that was added in r319430

2018-01-08 Thread Sean Eveson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
seaneveson marked an inline comment as done.
Closed by commit rL321992: [Driver] Add flag enabling the function stack size 
section that was added in… (authored by seaneveson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D40712?vs=128745&id=128911#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40712

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/include/clang/Frontend/CodeGenOptions.def
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/stack-size-section.c
  cfe/trunk/test/Driver/stack-size-section.c


Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -682,6 +682,8 @@
OPT_fno_function_sections, false);
   Opts.DataSections = Args.hasFlag(OPT_fdata_sections,
OPT_fno_data_sections, false);
+  Opts.StackSizeSection =
+  Args.hasFlag(OPT_fstack_size_section, OPT_fno_stack_size_section, false);
   Opts.UniqueSectionNames = Args.hasFlag(OPT_funique_section_names,
  OPT_fno_unique_section_names, true);
 
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -448,6 +448,7 @@
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
+  Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
 
   if (CodeGenOpts.EnableSplitDwarf)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3798,6 +3798,10 @@
 CmdArgs.push_back(A->getValue());
   }
 
+  if (Args.hasFlag(options::OPT_fstack_size_section,
+   options::OPT_fno_stack_size_section, RawTriple.isPS4()))
+CmdArgs.push_back("-fstack-size-section");
+
   CmdArgs.push_back("-ferror-limit");
   if (Arg *A = Args.getLastArg(options::OPT_ferror_limit_EQ))
 CmdArgs.push_back(A->getValue());
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1574,6 +1574,10 @@
  Flags<[CC1Option]>, HelpText<"Place each data in its own section (ELF Only)">;
 def fno_data_sections : Flag <["-"], "fno-data-sections">, Group,
   Flags<[CC1Option]>;
+def fstack_size_section : Flag<["-"], "fstack-size-section">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Emit section containing metadata on function stack sizes">;
+def fno_stack_size_section : Flag<["-"], "fno-stack-size-section">, 
Group, Flags<[CC1Option]>,
+  HelpText<"Don't emit section containing metadata on function stack sizes">;
 
 def funique_section_names : Flag <["-"], "funique-section-names">,
   Group, Flags<[CC1Option]>,
Index: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
===
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def
@@ -83,6 +83,7 @@
 
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
+CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
 
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
Index: cfe/trunk/test/CodeGen/stack-size-section.c
===
--- cfe/trunk/test/CodeGen/stack-size-section.c
+++ cfe/trunk/test/CodeGen/stack-size-section.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-unknown %s -S -o - | FileCheck %s 
--check-prefix=CHECK-ABSENT
+// CHECK-ABSENT-NOT: section .stack_sizes
+
+// RUN: %clang_cc1 -triple x86_64-unknown -fstack-size-section %s -S -o - | 
FileCheck %s --check-prefix=CHECK-PRESENT
+// CHECK-PRESENT: section .stack_sizes
+
+int foo() { return 42; }
Index: cfe/trunk/test/Driver/stack-size-section.c
===
--- cfe/trunk/test/Driver/stack-size-section.c
+++ cfe/trunk/test/Driver/stack-size-section.c
@@ -0,0 +1,9 @@
+// RUN: %clang -target x86_64-unknown %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ABSENT
+// RUN: %clang -target x86_64-scei-ps4 -fno-stack-size-section %s -### 2>&1 | 
Fil

r321992 - [Driver] Add flag enabling the function stack size section that was added in r319430

2018-01-08 Thread Sean Eveson via cfe-commits
Author: seaneveson
Date: Mon Jan  8 05:42:26 2018
New Revision: 321992

URL: http://llvm.org/viewvc/llvm-project?rev=321992&view=rev
Log:
[Driver] Add flag enabling the function stack size section that was added in 
r319430

Adds the -fstack-size-section flag to enable the .stack_sizes section. The flag 
defaults to on for the PS4 triple.

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

Added:
cfe/trunk/test/CodeGen/stack-size-section.c
cfe/trunk/test/Driver/stack-size-section.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=321992&r1=321991&r2=321992&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jan  8 05:42:26 2018
@@ -1574,6 +1574,10 @@ def fdata_sections : Flag <["-"], "fdata
  Flags<[CC1Option]>, HelpText<"Place each data in its own section (ELF Only)">;
 def fno_data_sections : Flag <["-"], "fno-data-sections">, Group,
   Flags<[CC1Option]>;
+def fstack_size_section : Flag<["-"], "fstack-size-section">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Emit section containing metadata on function stack sizes">;
+def fno_stack_size_section : Flag<["-"], "fno-stack-size-section">, 
Group, Flags<[CC1Option]>,
+  HelpText<"Don't emit section containing metadata on function stack sizes">;
 
 def funique_section_names : Flag <["-"], "funique-section-names">,
   Group, Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=321992&r1=321991&r2=321992&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Jan  8 05:42:26 2018
@@ -83,6 +83,7 @@ CODEGENOPT(InstrumentFunctionEntryBare ,
 
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
+CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
 
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=321992&r1=321991&r2=321992&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Jan  8 05:42:26 2018
@@ -448,6 +448,7 @@ static void initTargetOptions(llvm::Targ
   Options.UniqueSectionNames = CodeGenOpts.UniqueSectionNames;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
+  Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
 
   if (CodeGenOpts.EnableSplitDwarf)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=321992&r1=321991&r2=321992&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Jan  8 05:42:26 2018
@@ -3798,6 +3798,10 @@ void Clang::ConstructJob(Compilation &C,
 CmdArgs.push_back(A->getValue());
   }
 
+  if (Args.hasFlag(options::OPT_fstack_size_section,
+   options::OPT_fno_stack_size_section, RawTriple.isPS4()))
+CmdArgs.push_back("-fstack-size-section");
+
   CmdArgs.push_back("-ferror-limit");
   if (Arg *A = Args.getLastArg(options::OPT_ferror_limit_EQ))
 CmdArgs.push_back(A->getValue());

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=321992&r1=321991&r2=321992&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Jan  8 05:42:26 2018
@@ -682,6 +682,8 @@ static bool ParseCodeGenArgs(CodeGenOpti
OPT_fno_function_sections, false);
   Opts.DataSections = Args.hasFlag(OPT_fdata_sections,
OPT_fno_data_sections, false);
+  Opts.StackSizeSection =
+  Args.hasFlag(OPT_fstack_size_section, OPT_fno_stack_size_section, false);
   Opts.Uni

[PATCH] D41815: [clang-tidy] implement check for goto

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

> Rather than add a warning for the labels, I would just add a note for the 
> label when diagnosing the goto (since the goto has a single target).

That might lead to existing labels without any gotos for them, does it? Maybe 
the check could also diagnose labels without corresponding gotos, or does the 
frontend already have something like this?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815



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


[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

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



Comment at: test/clang-tidy/bugprone-unused-return-value.cpp:163
+
+void noWarning() {
+  auto AsyncRetval1 = std::async(increment, 42);

khuttun wrote:
> aaron.ballman wrote:
> > Sorry, I just realized that we're missing a test case for a common 
> > situation -- where the result is used as part of another call expression. 
> > Can you add a test to `noWarning()` to make sure this does not warn:
> > ```
> > std::vector v;
> > extern void f(bool);
> > 
> > f(v.empty()); // Should not warn
> > ```
> See line 199 in this file.
Ah, my eyes missed that, thank you!

Hmm, I *think* this test should also be okay, but I want to be sure:
```
std::vector v;
bool b = ({v.empty()}); // Should not warn
({v.empty()}); // ???
```
I kind of thing that, as an extension to the spirit of this check, any GNU 
expression statement whose result is unused should probably be diagnosed; what 
do you think?

You should add tests for the above so we document the expected behavior here.


https://reviews.llvm.org/D41655



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


[PATCH] D35109: [Analyzer] SValBuilder Comparison Rearrangement

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

In https://reviews.llvm.org/D35109#969109, @NoQ wrote:

> I guess it'd be an `-analyzer-config` flag. You can add it to the 
> `AnalyzerOptions` object, which has access to these flags and can be accessed 
> from `AnalysisManager`.


OK, I can do that. BUt how should I call it? The name should be something the 
user also understands, not referring to some internal stuff. Any ideas?


https://reviews.llvm.org/D35109



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


[PATCH] D41815: [clang-tidy] implement check for goto

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

In https://reviews.llvm.org/D41815#969708, @JonasToth wrote:

> > Rather than add a warning for the labels, I would just add a note for the 
> > label when diagnosing the goto (since the goto has a single target).
>
> That might lead to existing labels without any gotos for them, does it? Maybe 
> the check could also diagnose labels without corresponding gotos, or does the 
> frontend already have something like this?


`-Wunused-label` already covers this scenario.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815



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


[PATCH] D41815: [clang-tidy] implement check for goto

2018-01-08 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp:22
+  if (getLangOpts().CPlusPlus)
+Finder->addMatcher(gotoStmt().bind("goto"), this);
+}

aaron.ballman wrote:
> aaron.ballman wrote:
> > Are you planning to add the exception listed in the C++ Core Guideline? It 
> > makes an explicit exception allowing you to jump forward out of a loop 
> > construct.
> What should this check do with indirect goto statements (it's a GCC extension 
> we support where you can jump to an expression)?
> 
> Regardless, there should be a test for indirect gotos and jump forward out of 
> loop constructs.
> Are you planning to add the exception listed in the C++ Core Guideline? It 
> makes an explicit exception allowing you to jump forward out of a loop 
> construct.

I do plan for this. Because I dont have any experience with gotos I wanted to 
do it in small steps.

> What should this check do with indirect goto statements (it's a GCC extension 
> we support where you can jump to an expression)?
Iam not aware of these :) 



Comment at: clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp:27-28
+  const auto *Match = Result.Nodes.getNodeAs("goto");
+  diag(Match->getGotoLoc(), "'goto' is considered harmful; use high level "
+"programming constructs instead")
+  << Match->getSourceRange();

aaron.ballman wrote:
> I don't think this diagnostic really helps the user all that much. It doesn't 
> say what's harmful about the goto, nor what high level programming construct 
> to use to make it not harmful.
I dont like the diagnostic too. But i dont know how to give a sensefull short 
message.

Here Andrei Alexandrescu introduced some high level rules, maybe i the Rule of 
Minimum Power could be a starting point?
https://github.com/isocpp/CppCoreGuidelines/issues/19

> Good example for Rule of Minimum Power: goto is the most powerful looping 
> construct (it can do everything while does, and a lot more such as jumping in 
> the middle of a loop etc.) and the most unrecommended.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815



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


[PATCH] D41815: [clang-tidy] implement check for goto

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



Comment at: clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp:22
+  if (getLangOpts().CPlusPlus)
+Finder->addMatcher(gotoStmt().bind("goto"), this);
+}

JonasToth wrote:
> aaron.ballman wrote:
> > aaron.ballman wrote:
> > > Are you planning to add the exception listed in the C++ Core Guideline? 
> > > It makes an explicit exception allowing you to jump forward out of a loop 
> > > construct.
> > What should this check do with indirect goto statements (it's a GCC 
> > extension we support where you can jump to an expression)?
> > 
> > Regardless, there should be a test for indirect gotos and jump forward out 
> > of loop constructs.
> > Are you planning to add the exception listed in the C++ Core Guideline? It 
> > makes an explicit exception allowing you to jump forward out of a loop 
> > construct.
> 
> I do plan for this. Because I dont have any experience with gotos I wanted to 
> do it in small steps.
> 
> > What should this check do with indirect goto statements (it's a GCC 
> > extension we support where you can jump to an expression)?
> Iam not aware of these :) 
>> What should this check do with indirect goto statements (it's a GCC 
>> extension we support where you can jump to an expression)?
>
> Iam not aware of these :)

https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
(and a good reference on why these are interesting: 
https://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables)



Comment at: clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp:27-28
+  const auto *Match = Result.Nodes.getNodeAs("goto");
+  diag(Match->getGotoLoc(), "'goto' is considered harmful; use high level "
+"programming constructs instead")
+  << Match->getSourceRange();

JonasToth wrote:
> aaron.ballman wrote:
> > I don't think this diagnostic really helps the user all that much. It 
> > doesn't say what's harmful about the goto, nor what high level programming 
> > construct to use to make it not harmful.
> I dont like the diagnostic too. But i dont know how to give a sensefull short 
> message.
> 
> Here Andrei Alexandrescu introduced some high level rules, maybe i the Rule 
> of Minimum Power could be a starting point?
> https://github.com/isocpp/CppCoreGuidelines/issues/19
> 
> > Good example for Rule of Minimum Power: goto is the most powerful looping 
> > construct (it can do everything while does, and a lot more such as jumping 
> > in the middle of a loop etc.) and the most unrecommended.
I think part of the issue here is that goto isn't harmful in all circumstances, 
but this check is going to tell users to remove the goto regardless of whether 
it's dangerous or not. That kind of broad prohibition suggests the diagnostic 
wording should be more along the lines of "avoid using 'goto' for flow control" 
or something along those lines. When you add the exception case(s) to the rule, 
you could reword to "this use of 'goto' for flow control is prohibited" (or 
similar).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41815



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


[PATCH] D41820: [coroutines] Pass coro func args to promise ctor

2018-01-08 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
modocache added reviewers: rsmith, GorNishanov, eric_niebler.
Herald added a subscriber: EricWF.

Use corutine function arguments to initialize a promise type, but only
if the promise type defines a constructor that takes those arguments.
Otherwise, fall back to the default constructor.

Test Plan: check-clang


Repository:
  rC Clang

https://reviews.llvm.org/D41820

Files:
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/Sema/CoroutineStmtBuilder.h
  lib/Sema/ScopeInfo.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/CodeGenCoroutines/coro-alloc.cpp

Index: test/CodeGenCoroutines/coro-alloc.cpp
===
--- test/CodeGenCoroutines/coro-alloc.cpp
+++ test/CodeGenCoroutines/coro-alloc.cpp
@@ -193,3 +193,26 @@
   // CHECK:   ret i32 %[[LoadRet]]
   co_return;
 }
+
+struct promise_matching_constructor {};
+
+template<>
+struct std::experimental::coroutine_traits {
+  struct promise_type {
+promise_type(promise_matching_constructor, int, float, double) {}
+promise_type() = delete;
+void get_return_object() {}
+suspend_always initial_suspend() { return {}; }
+suspend_always final_suspend() { return {}; }
+void return_void() {}
+  };
+};
+
+// CHECK-LABEL: f5(
+extern "C" void f5(promise_matching_constructor, int, float, double) {
+  // CHECK: %[[INT:.+]] = load i32, i32* %.addr, align 4
+  // CHECK: %[[FLOAT:.+]] = load float, float* %.addr1, align 4
+  // CHECK: %[[DOUBLE:.+]] = load double, double* %.addr2, align 8
+  // CHECK: call void @_ZNSt12experimental16coroutine_traitsIJv28promise_matching_constructorifdEE12promise_typeC1ES1_ifd(%"struct.std::experimental::coroutine_traits::promise_type"* %__promise, i32 %[[INT]], float %[[FLOAT]], double %[[DOUBLE]])
+  co_return;
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -6956,6 +6956,8 @@
 
   // The new CoroutinePromise object needs to be built and put into the current
   // FunctionScopeInfo before any transformations or rebuilding occurs.
+  if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
+return StmtError();
   auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
   if (!Promise)
 return StmtError();
@@ -7046,8 +7048,6 @@
   Builder.ReturnStmt = Res.get();
 }
   }
-  if (!Builder.buildParameterMoves())
-return StmtError();
 
   return getDerived().RebuildCoroutineBodyStmt(Builder);
 }
Index: lib/Sema/SemaCoroutine.cpp
===
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -472,6 +472,69 @@
   return buildMemberCall(S, PromiseRef.get(), Loc, Name, Args);
 }
 
+// Create a static_cast\(expr).
+static Expr *castForMoving(Sema &S, Expr *E, QualType T = QualType()) {
+  if (T.isNull())
+T = E->getType();
+  QualType TargetType = S.BuildReferenceType(
+  T, /*SpelledAsLValue*/ false, SourceLocation(), DeclarationName());
+  SourceLocation ExprLoc = E->getLocStart();
+  TypeSourceInfo *TargetLoc =
+  S.Context.getTrivialTypeSourceInfo(TargetType, ExprLoc);
+
+  return S
+  .BuildCXXNamedCast(ExprLoc, tok::kw_static_cast, TargetLoc, E,
+ SourceRange(ExprLoc, ExprLoc), E->getSourceRange())
+  .get();
+}
+
+/// \brief Build a variable declaration for move parameter.
+static VarDecl *buildVarDecl(Sema &S, SourceLocation Loc, QualType Type,
+ IdentifierInfo *II) {
+  TypeSourceInfo *TInfo = S.Context.getTrivialTypeSourceInfo(Type, Loc);
+  VarDecl *Decl = VarDecl::Create(S.Context, S.CurContext, Loc, Loc, II, Type,
+  TInfo, SC_None);
+  Decl->setImplicit();
+  return Decl;
+}
+
+// Build statements that move coroutine function parameters to the coroutine
+// frame, and store them on the function scope info.
+bool Sema::buildCoroutineParameterMoves(SourceLocation Loc) {
+  assert(isa(CurContext) && "not in a function scope");
+  auto *FD = cast(CurContext);
+
+  auto *ScopeInfo = getCurFunction();
+  assert(ScopeInfo->CoroutineParameterMoves.empty() &&
+ "Should not build parameter moves twice");
+
+  for (auto *PD : FD->parameters()) {
+if (PD->getType()->isDependentType())
+  continue;
+
+// No need to copy scalars, LLVM will take care of them.
+if (PD->getType()->getAsCXXRecordDecl()) {
+  ExprResult PDRefExpr = BuildDeclRefExpr(
+  PD, PD->getType(), ExprValueKind::VK_LValue, Loc); // FIXME: scope?
+  if (PDRefExpr.isInvalid())
+return false;
+
+  Expr *CExpr = castForMoving(*this, PDRefExpr.get());
+
+  auto D = buildVarDecl(*this, Loc, PD->getType(), PD->getIdentifier());
+  AddInitializerToDecl(D, CExpr, /*DirectInit=*/true);
+
+  // Convert decl to a statement.
+  StmtResult Stmt = ActOnDeclStmt(ConvertDec

[PATCH] D41487: [clang-format] Adds a FormatStyleSet

2018-01-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 128921.
krasimir added a comment.

- Address review comments


Repository:
  rC Clang

https://reviews.llvm.org/D41487

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp

Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -859,7 +859,7 @@
   assert(Language != FormatStyle::LK_None);
   if (Text.trim().empty())
 return make_error_code(ParseError::Error);
-
+  Style->StyleSet.Clear();
   std::vector Styles;
   llvm::yaml::Input Input(Text);
   // DocumentListTraits> uses the context to get default
@@ -888,15 +888,23 @@
   // Look for a suitable configuration starting from the end, so we can
   // find the configuration for the specific language first, and the default
   // configuration (which can only be at slot 0) after it.
+  FormatStyle::FormatStyleSet StyleSet;
+  bool LanguageFound = false;
   for (int i = Styles.size() - 1; i >= 0; --i) {
-if (Styles[i].Language == Language ||
-Styles[i].Language == FormatStyle::LK_None) {
-  *Style = Styles[i];
-  Style->Language = Language;
-  return make_error_code(ParseError::Success);
-}
-  }
-  return make_error_code(ParseError::Unsuitable);
+if (Styles[i].Language != FormatStyle::LK_None)
+  StyleSet.Add(Styles[i]);
+if (Styles[i].Language == Language)
+  LanguageFound = true;
+  }
+  if (!LanguageFound) {
+if (Styles.empty() || Styles[0].Language != FormatStyle::LK_None)
+  return make_error_code(ParseError::Unsuitable);
+FormatStyle DefaultStyle = Styles[0];
+DefaultStyle.Language = Language;
+StyleSet.Add(DefaultStyle);
+  }
+  *Style = *StyleSet.Get(Language);
+  return make_error_code(ParseError::Success);
 }
 
 std::string configurationAsText(const FormatStyle &Style) {
@@ -910,6 +918,36 @@
   return Stream.str();
 }
 
+llvm::Optional
+FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
+  if (!Styles)
+return None;
+  auto It = Styles->find(Language);
+  if (It == Styles->end())
+return None;
+  FormatStyle Style = *It->second;
+  Style.StyleSet = *this;
+  return Style;
+}
+
+void FormatStyle::FormatStyleSet::Add(FormatStyle Style) {
+  assert(
+  !Style.StyleSet.Styles &&
+  "Cannot add a style associated with an existing StyleSet to a StyleSet");
+  if (!Styles)
+Styles = std::make_shared();
+  (*Styles)[Style.Language].reset(new FormatStyle(Style));
+}
+
+void FormatStyle::FormatStyleSet::Clear() {
+  Styles.reset();
+}
+
+llvm::Optional
+FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {
+  return StyleSet.Get(Language);
+}
+
 namespace {
 
 class JavaScriptRequoter : public TokenAnalyzer {
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1685,6 +1685,40 @@
Standard == R.Standard && TabWidth == R.TabWidth &&
UseTab == R.UseTab;
   }
+
+  llvm::Optional GetLanguageStyle(LanguageKind Language) const;
+
+  // Stores per-language styles. A FormatStyle instance inside has an empty
+  // StyleSet. A FormatStyle instance returned by the Get method has its
+  // StyleSet set to a copy of the originating StyleSet, effectively keeping the
+  // internal representation of that StyleSet alive.
+  //
+  // The memory management and ownership reminds of a birds nest: chicks
+  // leaving the nest take photos of the nest with them.
+  struct FormatStyleSet {
+typedef std::map>
+MapType;
+
+llvm::Optional Get(FormatStyle::LanguageKind Language) const;
+// Adds \p Style to this FormatStyleSet. Style must not have an associated
+// FormatStyleSet.
+void Add(FormatStyle Style);
+// Clears this FormatStyleSet.
+void Clear();
+
+  private:
+std::shared_ptr Styles;
+  };
+
+  static FormatStyleSet BuildStyleSetFromConfiguration(
+  const FormatStyle &MainStyle,
+  const std::vector &ConfigurationStyles);
+
+private:
+  FormatStyleSet StyleSet;
+
+  friend std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
 };
 
 /// \brief Returns a format style complying with the LLVM coding standards:
@@ -1730,6 +1764,8 @@
 /// Style->Language is used to get the base style, if the ``BasedOnStyle``
 /// option is present.
 ///
+/// The FormatStyleSet of Style is reset.
+///
 /// When ``BasedOnStyle`` is not present, options not present in the YAML
 /// document, are retained in \p Style.
 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41539: [CodeGen] Decorate aggregate accesses with TBAA tags

2018-01-08 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Sure, but since it is not a trivial change we could first replace 'tbaa.struct' 
with 'tbaa' and then decide how to attach multiple TBAA tags to an instruction. 
I didn't think enough about it, but one way to do that is to have different 
kinds of TBAA tags for read and write accesses, in which case we could 
re-purpose the 'tbaa.struct' tag slot.


https://reviews.llvm.org/D41539



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


r321995 - Fix test added in r321992 failing on some buildbots.

2018-01-08 Thread Sean Eveson via cfe-commits
Author: seaneveson
Date: Mon Jan  8 06:43:28 2018
New Revision: 321995

URL: http://llvm.org/viewvc/llvm-project?rev=321995&view=rev
Log:
Fix test added in r321992 failing on some buildbots.

Modified:
cfe/trunk/test/CodeGen/stack-size-section.c

Modified: cfe/trunk/test/CodeGen/stack-size-section.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/stack-size-section.c?rev=321995&r1=321994&r2=321995&view=diff
==
--- cfe/trunk/test/CodeGen/stack-size-section.c (original)
+++ cfe/trunk/test/CodeGen/stack-size-section.c Mon Jan  8 06:43:28 2018
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple x86_64-unknown %s -S -o - | FileCheck %s 
--check-prefix=CHECK-ABSENT
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -S -o - | FileCheck %s 
--check-prefix=CHECK-ABSENT
 // CHECK-ABSENT-NOT: section .stack_sizes
 
-// RUN: %clang_cc1 -triple x86_64-unknown -fstack-size-section %s -S -o - | 
FileCheck %s --check-prefix=CHECK-PRESENT
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fstack-size-section %s -S 
-o - | FileCheck %s --check-prefix=CHECK-PRESENT
 // CHECK-PRESENT: section .stack_sizes
 
 int foo() { return 42; }


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


[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference

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

Strange, but modifying the tests from `m  n` to `m - n  0`  
does not help. The statement `if (m - n  0)` does not store a range 
for `m - n` in the constraint manager. With the other patch which automatically 
changes `m  n` to `m - n  0` the range is stored 
automatically.


https://reviews.llvm.org/D35110



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


r321997 - Avoid assumption that lit tests are writable. NFC

2018-01-08 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jan  8 07:05:01 2018
New Revision: 321997

URL: http://llvm.org/viewvc/llvm-project?rev=321997&view=rev
Log:
Avoid assumption that lit tests are writable. NFC

Modified:
cfe/trunk/test/ARCMT/releases-driver.m
cfe/trunk/test/ARCMT/releases-driver.m.result
cfe/trunk/test/ARCMT/with-arc-mode-modify.m
cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result
cfe/trunk/test/PCH/verify_pch.m
cfe/trunk/test/VFS/real-path-found-first.m

Modified: cfe/trunk/test/ARCMT/releases-driver.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/releases-driver.m?rev=321997&r1=321996&r2=321997&view=diff
==
--- cfe/trunk/test/ARCMT/releases-driver.m (original)
+++ cfe/trunk/test/ARCMT/releases-driver.m Mon Jan  8 07:05:01 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: cp %s %t
+// RUN: cat %s > %t
 // RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x 
objective-c %t
 // RUN: diff %t %s.result
 // RUN: rm %t

Modified: cfe/trunk/test/ARCMT/releases-driver.m.result
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/releases-driver.m.result?rev=321997&r1=321996&r2=321997&view=diff
==
--- cfe/trunk/test/ARCMT/releases-driver.m.result (original)
+++ cfe/trunk/test/ARCMT/releases-driver.m.result Mon Jan  8 07:05:01 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: cp %s %t
+// RUN: cat %s > %t
 // RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x 
objective-c %t
 // RUN: diff %t %s.result
 // RUN: rm %t

Modified: cfe/trunk/test/ARCMT/with-arc-mode-modify.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/with-arc-mode-modify.m?rev=321997&r1=321996&r2=321997&view=diff
==
--- cfe/trunk/test/ARCMT/with-arc-mode-modify.m (original)
+++ cfe/trunk/test/ARCMT/with-arc-mode-modify.m Mon Jan  8 07:05:01 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: cp %s %t
+// RUN: cat %s > %t
 // RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c %t
 // RUN: diff %t %s.result
 // RUN: rm %t

Modified: cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result?rev=321997&r1=321996&r2=321997&view=diff
==
--- cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result (original)
+++ cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result Mon Jan  8 07:05:01 2018
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
-// RUN: cp %s %t
+// RUN: cat %s > %t
 // RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c %t
 // RUN: diff %t %s.result
 // RUN: rm %t

Modified: cfe/trunk/test/PCH/verify_pch.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/verify_pch.m?rev=321997&r1=321996&r2=321997&view=diff
==
--- cfe/trunk/test/PCH/verify_pch.m (original)
+++ cfe/trunk/test/PCH/verify_pch.m Mon Jan  8 07:05:01 2018
@@ -2,7 +2,7 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/usr/include
 // RUN: echo '// empty' > %t/usr/include/sys_header.h
-// RUN: cp %s %t.h
+// RUN: cat %s > %t.h
 //
 // Precompile
 // RUN: %clang_cc1 -isystem %t/usr/include -x objective-c-header -emit-pch -o 
%t.pch %t.h

Modified: cfe/trunk/test/VFS/real-path-found-first.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/real-path-found-first.m?rev=321997&r1=321996&r2=321997&view=diff
==
--- cfe/trunk/test/VFS/real-path-found-first.m (original)
+++ cfe/trunk/test/VFS/real-path-found-first.m Mon Jan  8 07:05:01 2018
@@ -7,7 +7,7 @@
 // REQUIRES: shell
 // RUN: rm -rf %t %t-cache %t.pch
 // RUN: mkdir -p %t/SomeFramework.framework/Modules
-// RUN: cp %S/Inputs/some_frame_module.map 
%t/SomeFramework.framework/Modules/module.modulemap
+// RUN: cat %S/Inputs/some_frame_module.map > 
%t/SomeFramework.framework/Modules/module.modulemap
 // RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%t:g" 
%S/Inputs/vfsoverlay.yaml > %t.yaml
 
 // Build


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


r321999 - [CodeGen] Fix TBAA info for accesses to members of base classes

2018-01-08 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Mon Jan  8 07:36:06 2018
New Revision: 321999

URL: http://llvm.org/viewvc/llvm-project?rev=321999&view=rev
Log:
[CodeGen] Fix TBAA info for accesses to members of base classes

Resolves:
Bug 35724 - regression (r315984): fatal error: error in backend:
Broken function found (Did not see access type in access path!)
https://bugs.llvm.org/show_bug.cgi?id=35724

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

Added:
cfe/trunk/test/CodeGen/tbaa-base.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=321999&r1=321998&r2=321999&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Jan  8 07:36:06 2018
@@ -1034,8 +1034,12 @@ Address CodeGenFunction::EmitPointerWith
 // Derived-to-base conversions.
 case CK_UncheckedDerivedToBase:
 case CK_DerivedToBase: {
-  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo,
-  TBAAInfo);
+  // TODO: Support accesses to members of base classes in TBAA. For now, we
+  // conservatively pretend that the complete object is of the base class
+  // type.
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(E->getType());
+  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo);
   auto Derived = CE->getSubExpr()->getType()->getPointeeCXXRecordDecl();
   return GetAddressOfBaseClass(Addr, Derived,
CE->path_begin(), CE->path_end(),

Added: cfe/trunk/test/CodeGen/tbaa-base.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-base.cpp?rev=321999&view=auto
==
--- cfe/trunk/test/CodeGen/tbaa-base.cpp (added)
+++ cfe/trunk/test/CodeGen/tbaa-base.cpp Mon Jan  8 07:36:06 2018
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 %s -emit-llvm -o - | FileCheck 
%s
+//
+// Test generating of TBAA metadata for accesses to members of base classes.
+
+struct A {
+  int x, y, z;
+};
+
+struct B : A {
+  int i;
+};
+
+struct C {
+  int i;
+  B b;
+  int j;
+};
+
+int f1(B *b) {
+// CHECK-LABEL: _Z2f1P1B
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y:!.*]]
+  return b->y;
+}
+
+int f2(C *c) {
+// CHECK-LABEL: _Z2f2P1C
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]]
+  return (&(c->b))->y;
+}
+
+struct D : virtual A
+{};
+
+struct E {
+  D d;
+};
+
+int f3(D *d) {
+// CHECK-LABEL: _Z2f3P1D
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]]
+  return d->y;
+}
+
+int f4(E *e) {
+// CHECK-LABEL: _Z2f4P1E
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]]
+  return (&(e->d))->y;
+}
+
+// CHECK-DAG: [[TYPE_char:!.*]] = !{!"omnipotent char", {{.*}}, i64 0}
+// CHECK-DAG: [[TYPE_int:!.*]] = !{!"int", [[TYPE_char]], i64 0}
+// CHECK-DAG: [[TYPE_A:!.*]] = !{!"_ZTS1A", [[TYPE_int]], i64 0, [[TYPE_int]], 
i64 4, [[TYPE_int]], i64 8}
+// CHECK-DAG: [[TAG_A_y]] = !{[[TYPE_A]], [[TYPE_int]], i64 4}


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


[PATCH] D41547: [CodeGen] Fix TBAA info for accesses to members of base classes

2018-01-08 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321999: [CodeGen] Fix TBAA info for accesses to members of 
base classes (authored by kosarev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D41547

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/tbaa-base.cpp


Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1034,8 +1034,12 @@
 // Derived-to-base conversions.
 case CK_UncheckedDerivedToBase:
 case CK_DerivedToBase: {
-  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo,
-  TBAAInfo);
+  // TODO: Support accesses to members of base classes in TBAA. For now, we
+  // conservatively pretend that the complete object is of the base class
+  // type.
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(E->getType());
+  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo);
   auto Derived = CE->getSubExpr()->getType()->getPointeeCXXRecordDecl();
   return GetAddressOfBaseClass(Addr, Derived,
CE->path_begin(), CE->path_end(),
Index: test/CodeGen/tbaa-base.cpp
===
--- test/CodeGen/tbaa-base.cpp
+++ test/CodeGen/tbaa-base.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 %s -emit-llvm -o - | FileCheck 
%s
+//
+// Test generating of TBAA metadata for accesses to members of base classes.
+
+struct A {
+  int x, y, z;
+};
+
+struct B : A {
+  int i;
+};
+
+struct C {
+  int i;
+  B b;
+  int j;
+};
+
+int f1(B *b) {
+// CHECK-LABEL: _Z2f1P1B
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y:!.*]]
+  return b->y;
+}
+
+int f2(C *c) {
+// CHECK-LABEL: _Z2f2P1C
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]]
+  return (&(c->b))->y;
+}
+
+struct D : virtual A
+{};
+
+struct E {
+  D d;
+};
+
+int f3(D *d) {
+// CHECK-LABEL: _Z2f3P1D
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]]
+  return d->y;
+}
+
+int f4(E *e) {
+// CHECK-LABEL: _Z2f4P1E
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]]
+  return (&(e->d))->y;
+}
+
+// CHECK-DAG: [[TYPE_char:!.*]] = !{!"omnipotent char", {{.*}}, i64 0}
+// CHECK-DAG: [[TYPE_int:!.*]] = !{!"int", [[TYPE_char]], i64 0}
+// CHECK-DAG: [[TYPE_A:!.*]] = !{!"_ZTS1A", [[TYPE_int]], i64 0, [[TYPE_int]], 
i64 4, [[TYPE_int]], i64 8}
+// CHECK-DAG: [[TAG_A_y]] = !{[[TYPE_A]], [[TYPE_int]], i64 4}


Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1034,8 +1034,12 @@
 // Derived-to-base conversions.
 case CK_UncheckedDerivedToBase:
 case CK_DerivedToBase: {
-  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo,
-  TBAAInfo);
+  // TODO: Support accesses to members of base classes in TBAA. For now, we
+  // conservatively pretend that the complete object is of the base class
+  // type.
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(E->getType());
+  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo);
   auto Derived = CE->getSubExpr()->getType()->getPointeeCXXRecordDecl();
   return GetAddressOfBaseClass(Addr, Derived,
CE->path_begin(), CE->path_end(),
Index: test/CodeGen/tbaa-base.cpp
===
--- test/CodeGen/tbaa-base.cpp
+++ test/CodeGen/tbaa-base.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 %s -emit-llvm -o - | FileCheck %s
+//
+// Test generating of TBAA metadata for accesses to members of base classes.
+
+struct A {
+  int x, y, z;
+};
+
+struct B : A {
+  int i;
+};
+
+struct C {
+  int i;
+  B b;
+  int j;
+};
+
+int f1(B *b) {
+// CHECK-LABEL: _Z2f1P1B
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y:!.*]]
+  return b->y;
+}
+
+int f2(C *c) {
+// CHECK-LABEL: _Z2f2P1C
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]]
+  return (&(c->b))->y;
+}
+
+struct D : virtual A
+{};
+
+struct E {
+  D d;
+};
+
+int f3(D *d) {
+// CHECK-LABEL: _Z2f3P1D
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]]
+  return d->y;
+}
+
+int f4(E *e) {
+// CHECK-LABEL: _Z2f4P1E
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_A_y]]
+  return (&(e->d))->y;
+}
+
+// CHECK-DAG: [[TYPE_char:!.*]] = !{!"omnipotent char", {{.*}}, i64 0}
+// CHECK-DAG: [[TYPE_int:!.*]] = !{!"int", [[TYPE_char]], i64 0}
+// CHECK-DAG: [[TYPE_A:!.*]] = !{!"_ZTS1A", [[TYPE_int]], i64 0, [[TYPE_int]], i64 4, [[TYPE_int]], i64 8}
+// CHECK-DAG: [[TAG_A_y]] = !{[[TYPE_A]], [[TYPE_int]], i64 4}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41487: [clang-format] Adds a FormatStyleSet

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



Comment at: include/clang/Format/Format.h:1700
+typedef std::map>
+MapType;

Why unique_ptr?



Comment at: include/clang/Format/Format.h:1706
+// FormatStyleSet.
+void Add(FormatStyle Style);
+// Clears this FormatStyleSet.

Document what happens if the Style for this language is in the set already.



Comment at: lib/Format/Format.cpp:904
+DefaultStyle.Language = Language;
+StyleSet.Add(DefaultStyle);
+  }

std::move



Comment at: lib/Format/Format.cpp:939
+Styles = std::make_shared();
+  (*Styles)[Style.Language].reset(new FormatStyle(Style));
+}

You can std::move `Style` here, it's passed by value.



Comment at: lib/Format/Format.cpp:939
+Styles = std::make_shared();
+  (*Styles)[Style.Language].reset(new FormatStyle(Style));
+}

bkramer wrote:
> You can std::move `Style` here, it's passed by value.
Can Style.Language ever be LK_None? Does that even make sense?


Repository:
  rC Clang

https://reviews.llvm.org/D41487



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


r322000 - Fix test added in r321992 failing on some buildbots (again), test requires x86.

2018-01-08 Thread Sean Eveson via cfe-commits
Author: seaneveson
Date: Mon Jan  8 07:46:18 2018
New Revision: 322000

URL: http://llvm.org/viewvc/llvm-project?rev=322000&view=rev
Log:
Fix test added in r321992 failing on some buildbots (again), test requires x86.

Modified:
cfe/trunk/test/CodeGen/stack-size-section.c

Modified: cfe/trunk/test/CodeGen/stack-size-section.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/stack-size-section.c?rev=322000&r1=321999&r2=322000&view=diff
==
--- cfe/trunk/test/CodeGen/stack-size-section.c (original)
+++ cfe/trunk/test/CodeGen/stack-size-section.c Mon Jan  8 07:46:18 2018
@@ -1,3 +1,5 @@
+// REQUIRES: x86-registered-target
+
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -S -o - | FileCheck %s 
--check-prefix=CHECK-ABSENT
 // CHECK-ABSENT-NOT: section .stack_sizes
 


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


[clang-tools-extra] r322001 - Avoid assumption that lit tests are writable. NFC

2018-01-08 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon Jan  8 07:49:40 2018
New Revision: 322001

URL: http://llvm.org/viewvc/llvm-project?rev=322001&view=rev
Log:
Avoid assumption that lit tests are writable. NFC

Modified:
clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp
clang-tools-extra/trunk/test/clang-move/move-function.cpp
clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp

Modified: clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp?rev=322001&r1=322000&r2=322001&view=diff
==
--- clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp (original)
+++ clang-tools-extra/trunk/test/clang-apply-replacements/crlf.cpp Mon Jan  8 
07:49:40 2018
@@ -1,5 +1,5 @@
 // RUN: mkdir -p %T/Inputs/crlf
-// RUN: cp %S/Inputs/crlf/crlf.cpp %T/Inputs/crlf/crlf.cpp
+// RUN: cat %S/Inputs/crlf/crlf.cpp > %T/Inputs/crlf/crlf.cpp
 // RUN: sed "s#\$(path)#%/T/Inputs/crlf#" %S/Inputs/crlf/file1.yaml > 
%T/Inputs/crlf/file1.yaml
 // RUN: clang-apply-replacements %T/Inputs/crlf
 // RUN: diff %T/Inputs/crlf/crlf.cpp %S/Inputs/crlf/crlf.cpp.expected

Modified: clang-tools-extra/trunk/test/clang-move/move-function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-function.cpp?rev=322001&r1=322000&r2=322001&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-function.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/move-function.cpp Mon Jan  8 
07:49:40 2018
@@ -1,5 +1,6 @@
 // RUN: mkdir -p %T/move-function
-// RUN: cp %S/Inputs/function_test*  %T/move-function
+// RUN: cat %S/Inputs/function_test.h > %T/move-function/function_test.h
+// RUN: cat %S/Inputs/function_test.cpp > %T/move-function/function_test.cpp
 // RUN: cd %T/move-function
 // RUN: clang-move -names="g" -new_header=%T/move-function/new_function_test.h 
-old_header=../move-function/function_test.h %T/move-function/function_test.cpp 
--
 // RUN: FileCheck -input-file=%T/move-function/new_function_test.h 
-check-prefix=CHECK-NEW-TEST-H-CASE1 %s
@@ -39,12 +40,14 @@
 // CHECK-NEW-TEST-CPP-CASE3: {{[[:space:]]+}}
 // CHECK-NEW-TEST-CPP-CASE3: void f() {}
 //
-// RUN: cp %S/Inputs/function_test*  %T/move-function
+// RUN: cat %S/Inputs/function_test.h > %T/move-function/function_test.h
+// RUN: cat %S/Inputs/function_test.cpp > %T/move-function/function_test.cpp
 // RUN: clang-move -names="A::f" 
-new_header=%T/move-function/new_function_test.h 
-new_cc=%T/move-function/new_function_test.cpp 
-old_header=../move-function/function_test.h 
-old_cc=../move-function/function_test.cpp %T/move-function/function_test.cpp 
-dump_result -- | FileCheck %s -check-prefix=CHECK-EMPTY
 //
 // CHECK-EMPTY: [{{[[:space:]]*}}]
 //
-// RUN: cp %S/Inputs/function_test*  %T/move-function
+// RUN: cat %S/Inputs/function_test.h > %T/move-function/function_test.h
+// RUN: cat %S/Inputs/function_test.cpp > %T/move-function/function_test.cpp
 // RUN: clang-move -names="f,A" 
-new_header=%T/move-function/new_function_test.h 
-new_cc=%T/move-function/new_function_test.cpp 
-old_header=../move-function/function_test.h 
-old_cc=../move-function/function_test.cpp %T/move-function/function_test.cpp --
 // RUN: FileCheck -input-file=%T/move-function/new_function_test.h 
-check-prefix=CHECK-NEW-TEST-H-CASE4 %s
 // RUN: FileCheck -input-file=%T/move-function/new_function_test.cpp 
-check-prefix=CHECK-NEW-TEST-CPP-CASE4 %s

Modified: clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp?rev=322001&r1=322000&r2=322001&view=diff
==
--- clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/no-move-macro-helpers.cpp Mon Jan  
8 07:49:40 2018
@@ -1,6 +1,6 @@
 // RUN: mkdir -p %T/no-move-macro-helper
-// RUN: cp %S/Inputs/macro_helper_test.h  
%T/no-move-macro-helper/macro_helper_test.h
-// RUN: cp %S/Inputs/macro_helper_test.cpp 
%T/no-move-macro-helper/macro_helper_test.cpp
+// RUN: cat %S/Inputs/macro_helper_test.h > 
%T/no-move-macro-helper/macro_helper_test.h
+// RUN: cat %S/Inputs/macro_helper_test.cpp > 
%T/no-move-macro-helper/macro_helper_test.cpp
 // RUN: cd %T/no-move-macro-helper
 //
 // 
-
@@ -24,8 +24,8 @@
 // 
-
 // Test moving all.
 // 
-
-// RUN: cp %S/Inputs/macro_helper_test.h  
%T/no-move-macro-helper/macro_helper_test.h
-// RUN: cp %S/Inputs/macro_helper_test.cpp 

Re: trivial_abi

2018-01-08 Thread David Blaikie via cfe-commits
(just a side note: perhaps this conversation would've been more suited to
cfe-dev? I sort of missed it because I only check commits once a week,
unless I'm specifically cc'd on something. All good though :))

On Wed, Jan 3, 2018 at 4:06 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On 3 January 2018 at 15:24, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Jan 3, 2018, at 5:53 PM, Richard Smith  wrote:
>> On 3 January 2018 at 14:29, John McCall via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> On Jan 3, 2018, at 5:12 PM, Richard Smith  wrote:
>>>
>>> On 2 January 2018 at 20:55, John McCall via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 On Jan 2, 2018, at 10:43 PM, Richard Smith 
 wrote:

 On 2 January 2018 at 19:02, John McCall via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

>
> On Jan 2, 2018, at 9:15 PM, Akira Hatanaka 
> wrote:
>
>
>
> On Jan 2, 2018, at 4:56 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> On 2 January 2018 at 15:33, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Hey, Richard et al.  Akira and I were talking about the right ABI
>> rule for deciding can-pass-in-registers-ness for structs in the presence 
>> of
>> trivial_abi, and I think I like Akira's approach but wanted to get your
>> input.
>>
>> The current definition in Itanium is:
>>
>>   *non-trivial for the purposes of calls*
>>
>> A type is considered non-trivial for the purposes of calls if:
>>
>>- it has a non-trivial copy constructor, move constructor, or
>>destructor, or
>>
>> I'm assuming we're implicitly excluding deleted functions here. (I'd
> prefer to make that explicit; this has been the source of a number of ABI
> mismatches.)
>
>>
>>- all of its copy and move constructors are deleted.
>>
>>
>> I'd suggest modifying this to:
>>
>> A type is considered non-trivial for the purposes of calls if:
>> - if has a copy constructor, move constructor, or destructor which is
>> non-trivial for the purposes of calls, or
>> - all of its copy and move constructors are deleted and it does not
>> have the trivial_abi attribute.
>>
>> A copy/move constructor is considered trivial for the purposes of
>> calls if:
>> - it is user-provided and
>> - the class has the trivial_abi attribute and
>> - a defaulted definition of the constructor would be trivial for the
>> purposes of calls; or
>>
>
> We'd need to say what happens if the function in question cannot
> validly be defaulted for any of the reasons in [dcl.fct.def.default]. Do 
> we
> try to infer whether it's a copy or move constructor, and use the rules 
> for
> a defaulted copy or move constructor? Or do we just say that's never
> trivial for the purposes of calls? Or something else? Eg:
>
> struct [[clang::trivial_abi]] A {
>   A(A && = make());
> };
>
> Here, A::A(A&&) cannot validly be defaulted. Is A trivial for the
> purpose of calls? Likewise:
>
> struct [[clang::trivial_abi]] B {
>   B(...);
> };
> struct C {
>   volatile B b;
> };
>
> Here, C's copy constructor calls B::B(...). Is C trivial for the
> purpose of calls? (OK, Clang crashes on that example today. But still...)
>
> I'd be uncomfortable making the rules in [dcl.fct.def.default] part of
> the ABI; they seem to be changing relatively frequently. Perhaps we could
> say "if the function is a copy constructor ([class.copy.ctor]/1), then
> consider what an implicitly-declared defaulted copy constructor would do;
> if it's a move constructor ([class.copy.ctor]/2), then consider what an
> implicitly-declared defaulted move constructor would do; otherwise, it's
> not trivial for the purpose of calls". That'd mean A is trivial for the
> purpose of calls and C is not, which I think is probably the right answer.
>
> - it is not user-provided and
>> - the class has no virtual functions and no virtual base classes, and
>> - the constructor used to copy/move each direct base class subobject
>> is trivial for the purposes of calls, and
>> - for each non-static data member that is of class type (or array
>> thereof), the constructor selected to copy/move that member is trivial 
>> for
>> the purposes of calls.
>>
>> A destructor is considered trivial for the purposes of calls if:
>> - it is not user-provided or the class has the trivial_abi attribute,
>> and
>> - the destructor is not virtual, and
>> - all of the direct base classes of its class have destructors that
>> are trivial for the purposes of calls, and
>> - for all of the non-static data membe

[PATCH] D41779: [clang-tidy] Fix DanglingHandleCheck for the correct conversion operation between basic_string and basic_string_view.

2018-01-08 Thread Samuel Benzaquen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322002: [clang-tidy] Fix DanglingHandleCheck for the correct 
conversion operation… (authored by sbenza, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D41779

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp


Index: clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
@@ -25,8 +25,12 @@
 ast_matchers::internal::BindableMatcher
 handleFrom(const ast_matchers::internal::Matcher &IsAHandle,
const ast_matchers::internal::Matcher &Arg) {
-  return cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
-  hasArgument(0, Arg));
+  return expr(
+  anyOf(cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
+ hasArgument(0, Arg)),
+cxxMemberCallExpr(hasType(cxxRecordDecl(IsAHandle)),
+  callee(memberExpr(member(cxxConversionDecl(,
+  on(Arg;
 }
 
 ast_matchers::internal::Matcher handleFromTemporaryValue(
Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp
@@ -45,19 +45,23 @@
   value_type& operator[](Key&& key);
 };
 
+class basic_string_view;
+
 class basic_string {
  public:
   basic_string();
   basic_string(const char*);
+
+  operator basic_string_view() const noexcept;
+
   ~basic_string();
 };
 
 typedef basic_string string;
 
 class basic_string_view {
  public:
   basic_string_view(const char*);
-  basic_string_view(const basic_string&);
 };
 
 typedef basic_string_view string_view;


Index: clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
@@ -25,8 +25,12 @@
 ast_matchers::internal::BindableMatcher
 handleFrom(const ast_matchers::internal::Matcher &IsAHandle,
const ast_matchers::internal::Matcher &Arg) {
-  return cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
-  hasArgument(0, Arg));
+  return expr(
+  anyOf(cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
+ hasArgument(0, Arg)),
+cxxMemberCallExpr(hasType(cxxRecordDecl(IsAHandle)),
+  callee(memberExpr(member(cxxConversionDecl(,
+  on(Arg;
 }
 
 ast_matchers::internal::Matcher handleFromTemporaryValue(
Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp
@@ -45,19 +45,23 @@
   value_type& operator[](Key&& key);
 };
 
+class basic_string_view;
+
 class basic_string {
  public:
   basic_string();
   basic_string(const char*);
+
+  operator basic_string_view() const noexcept;
+
   ~basic_string();
 };
 
 typedef basic_string string;
 
 class basic_string_view {
  public:
   basic_string_view(const char*);
-  basic_string_view(const basic_string&);
 };
 
 typedef basic_string_view string_view;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r322002 - [clang-tidy] Fix DanglingHandleCheck for the correct conversion operation between basic_string and basic_string_view.

2018-01-08 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Mon Jan  8 07:59:08 2018
New Revision: 322002

URL: http://llvm.org/viewvc/llvm-project?rev=322002&view=rev
Log:
[clang-tidy] Fix DanglingHandleCheck for the correct conversion operation 
between basic_string and basic_string_view.

Summary:
Fix DanglingHandleCheck to handle the final implementation of std::string and 
std::string_view.
These use a conversion operator instead of a conversion constructor.

Reviewers: hokein

Subscribers: klimek, xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp?rev=322002&r1=322001&r2=322002&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp Mon Jan 
 8 07:59:08 2018
@@ -25,8 +25,12 @@ namespace {
 ast_matchers::internal::BindableMatcher
 handleFrom(const ast_matchers::internal::Matcher &IsAHandle,
const ast_matchers::internal::Matcher &Arg) {
-  return cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
-  hasArgument(0, Arg));
+  return expr(
+  anyOf(cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))),
+ hasArgument(0, Arg)),
+cxxMemberCallExpr(hasType(cxxRecordDecl(IsAHandle)),
+  callee(memberExpr(member(cxxConversionDecl(,
+  on(Arg;
 }
 
 ast_matchers::internal::Matcher handleFromTemporaryValue(

Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp?rev=322002&r1=322001&r2=322002&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp Mon 
Jan  8 07:59:08 2018
@@ -45,10 +45,15 @@ class map {
   value_type& operator[](Key&& key);
 };
 
+class basic_string_view;
+
 class basic_string {
  public:
   basic_string();
   basic_string(const char*);
+
+  operator basic_string_view() const noexcept;
+
   ~basic_string();
 };
 
@@ -57,7 +62,6 @@ typedef basic_string string;
 class basic_string_view {
  public:
   basic_string_view(const char*);
-  basic_string_view(const basic_string&);
 };
 
 typedef basic_string_view string_view;


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


[PATCH] D41487: [clang-format] Adds a FormatStyleSet

2018-01-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 128932.
krasimir marked 5 inline comments as done.
krasimir added a comment.

- Address review comments


Repository:
  rC Clang

https://reviews.llvm.org/D41487

Files:
  2
  include/clang/Format/Format.h
  lib/Format/Format.cpp

Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -859,7 +859,7 @@
   assert(Language != FormatStyle::LK_None);
   if (Text.trim().empty())
 return make_error_code(ParseError::Error);
-
+  Style->StyleSet.Clear();
   std::vector Styles;
   llvm::yaml::Input Input(Text);
   // DocumentListTraits> uses the context to get default
@@ -888,15 +888,23 @@
   // Look for a suitable configuration starting from the end, so we can
   // find the configuration for the specific language first, and the default
   // configuration (which can only be at slot 0) after it.
+  FormatStyle::FormatStyleSet StyleSet;
+  bool LanguageFound = false;
   for (int i = Styles.size() - 1; i >= 0; --i) {
-if (Styles[i].Language == Language ||
-Styles[i].Language == FormatStyle::LK_None) {
-  *Style = Styles[i];
-  Style->Language = Language;
-  return make_error_code(ParseError::Success);
-}
-  }
-  return make_error_code(ParseError::Unsuitable);
+if (Styles[i].Language != FormatStyle::LK_None)
+  StyleSet.Add(Styles[i]);
+if (Styles[i].Language == Language)
+  LanguageFound = true;
+  }
+  if (!LanguageFound) {
+if (Styles.empty() || Styles[0].Language != FormatStyle::LK_None)
+  return make_error_code(ParseError::Unsuitable);
+FormatStyle DefaultStyle = Styles[0];
+DefaultStyle.Language = Language;
+StyleSet.Add(std::move(DefaultStyle));
+  }
+  *Style = *StyleSet.Get(Language);
+  return make_error_code(ParseError::Success);
 }
 
 std::string configurationAsText(const FormatStyle &Style) {
@@ -910,6 +918,38 @@
   return Stream.str();
 }
 
+llvm::Optional
+FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
+  if (!Styles)
+return None;
+  auto It = Styles->find(Language);
+  if (It == Styles->end())
+return None;
+  FormatStyle Style = It->second;
+  Style.StyleSet = *this;
+  return Style;
+}
+
+void FormatStyle::FormatStyleSet::Add(FormatStyle Style) {
+  assert(Style.Language != LK_None &&
+ "Cannot add a style for LK_None to a StyleSet");
+  assert(
+  !Style.StyleSet.Styles &&
+  "Cannot add a style associated with an existing StyleSet to a StyleSet");
+  if (!Styles)
+Styles = std::make_shared();
+  (*Styles)[Style.Language] = std::move(Style);
+}
+
+void FormatStyle::FormatStyleSet::Clear() {
+  Styles.reset();
+}
+
+llvm::Optional
+FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {
+  return StyleSet.Get(Language);
+}
+
 namespace {
 
 class JavaScriptRequoter : public TokenAnalyzer {
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1685,6 +1685,43 @@
Standard == R.Standard && TabWidth == R.TabWidth &&
UseTab == R.UseTab;
   }
+
+  llvm::Optional GetLanguageStyle(LanguageKind Language) const;
+
+  // Stores per-language styles. A FormatStyle instance inside has an empty
+  // StyleSet. A FormatStyle instance returned by the Get method has its
+  // StyleSet set to a copy of the originating StyleSet, effectively keeping the
+  // internal representation of that StyleSet alive.
+  //
+  // The memory management and ownership reminds of a birds nest: chicks
+  // leaving the nest take photos of the nest with them.
+  struct FormatStyleSet {
+typedef std::map MapType;
+
+llvm::Optional Get(FormatStyle::LanguageKind Language) const;
+
+// Adds \p Style to this FormatStyleSet. Style must not have an associated
+// FormatStyleSet.
+// Style.Language should be different than LK_None. If this FormatStyleSet
+// already contains an entry for Style.Language, that gets replaced with the
+// passed Style.
+void Add(FormatStyle Style);
+
+// Clears this FormatStyleSet.
+void Clear();
+
+  private:
+std::shared_ptr Styles;
+  };
+
+  static FormatStyleSet BuildStyleSetFromConfiguration(
+  const FormatStyle &MainStyle,
+  const std::vector &ConfigurationStyles);
+
+private:
+  FormatStyleSet StyleSet;
+
+  friend std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
 };
 
 /// \brief Returns a format style complying with the LLVM coding standards:
@@ -1730,6 +1767,8 @@
 /// Style->Language is used to get the base style, if the ``BasedOnStyle``
 /// option is present.
 ///
+/// The FormatStyleSet of Style is reset.
+///
 /// When ``BasedOnStyle`` is not present, options not present in the YAML
 /// document, are retained in \p Style.
 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
Index: 2
==

[PATCH] D41487: [clang-format] Adds a FormatStyleSet

2018-01-08 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 128933.
krasimir added a comment.

- Remove accidentally added file


Repository:
  rC Clang

https://reviews.llvm.org/D41487

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp

Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -859,7 +859,7 @@
   assert(Language != FormatStyle::LK_None);
   if (Text.trim().empty())
 return make_error_code(ParseError::Error);
-
+  Style->StyleSet.Clear();
   std::vector Styles;
   llvm::yaml::Input Input(Text);
   // DocumentListTraits> uses the context to get default
@@ -888,15 +888,23 @@
   // Look for a suitable configuration starting from the end, so we can
   // find the configuration for the specific language first, and the default
   // configuration (which can only be at slot 0) after it.
+  FormatStyle::FormatStyleSet StyleSet;
+  bool LanguageFound = false;
   for (int i = Styles.size() - 1; i >= 0; --i) {
-if (Styles[i].Language == Language ||
-Styles[i].Language == FormatStyle::LK_None) {
-  *Style = Styles[i];
-  Style->Language = Language;
-  return make_error_code(ParseError::Success);
-}
-  }
-  return make_error_code(ParseError::Unsuitable);
+if (Styles[i].Language != FormatStyle::LK_None)
+  StyleSet.Add(Styles[i]);
+if (Styles[i].Language == Language)
+  LanguageFound = true;
+  }
+  if (!LanguageFound) {
+if (Styles.empty() || Styles[0].Language != FormatStyle::LK_None)
+  return make_error_code(ParseError::Unsuitable);
+FormatStyle DefaultStyle = Styles[0];
+DefaultStyle.Language = Language;
+StyleSet.Add(std::move(DefaultStyle));
+  }
+  *Style = *StyleSet.Get(Language);
+  return make_error_code(ParseError::Success);
 }
 
 std::string configurationAsText(const FormatStyle &Style) {
@@ -910,6 +918,38 @@
   return Stream.str();
 }
 
+llvm::Optional
+FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
+  if (!Styles)
+return None;
+  auto It = Styles->find(Language);
+  if (It == Styles->end())
+return None;
+  FormatStyle Style = It->second;
+  Style.StyleSet = *this;
+  return Style;
+}
+
+void FormatStyle::FormatStyleSet::Add(FormatStyle Style) {
+  assert(Style.Language != LK_None &&
+ "Cannot add a style for LK_None to a StyleSet");
+  assert(
+  !Style.StyleSet.Styles &&
+  "Cannot add a style associated with an existing StyleSet to a StyleSet");
+  if (!Styles)
+Styles = std::make_shared();
+  (*Styles)[Style.Language] = std::move(Style);
+}
+
+void FormatStyle::FormatStyleSet::Clear() {
+  Styles.reset();
+}
+
+llvm::Optional
+FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {
+  return StyleSet.Get(Language);
+}
+
 namespace {
 
 class JavaScriptRequoter : public TokenAnalyzer {
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1685,6 +1685,43 @@
Standard == R.Standard && TabWidth == R.TabWidth &&
UseTab == R.UseTab;
   }
+
+  llvm::Optional GetLanguageStyle(LanguageKind Language) const;
+
+  // Stores per-language styles. A FormatStyle instance inside has an empty
+  // StyleSet. A FormatStyle instance returned by the Get method has its
+  // StyleSet set to a copy of the originating StyleSet, effectively keeping the
+  // internal representation of that StyleSet alive.
+  //
+  // The memory management and ownership reminds of a birds nest: chicks
+  // leaving the nest take photos of the nest with them.
+  struct FormatStyleSet {
+typedef std::map MapType;
+
+llvm::Optional Get(FormatStyle::LanguageKind Language) const;
+
+// Adds \p Style to this FormatStyleSet. Style must not have an associated
+// FormatStyleSet.
+// Style.Language should be different than LK_None. If this FormatStyleSet
+// already contains an entry for Style.Language, that gets replaced with the
+// passed Style.
+void Add(FormatStyle Style);
+
+// Clears this FormatStyleSet.
+void Clear();
+
+  private:
+std::shared_ptr Styles;
+  };
+
+  static FormatStyleSet BuildStyleSetFromConfiguration(
+  const FormatStyle &MainStyle,
+  const std::vector &ConfigurationStyles);
+
+private:
+  FormatStyleSet StyleSet;
+
+  friend std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
 };
 
 /// \brief Returns a format style complying with the LLVM coding standards:
@@ -1730,6 +1767,8 @@
 /// Style->Language is used to get the base style, if the ``BasedOnStyle``
 /// option is present.
 ///
+/// The FormatStyleSet of Style is reset.
+///
 /// When ``BasedOnStyle`` is not present, options not present in the YAML
 /// document, are retained in \p Style.
 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
___
cfe

Re: trivial_abi

2018-01-08 Thread John McCall via cfe-commits
> On Jan 8, 2018, at 10:57 AM, David Blaikie  wrote:
> (just a side note: perhaps this conversation would've been more suited to 
> cfe-dev? I sort of missed it because I only check commits once a week, unless 
> I'm specifically cc'd on something. All good though :))

I suppose it's more design-and-development than just code review, so yes, 
perhaps cfe-dev would have been more appropriate.  Regardless I should've made 
a point of CC'ing you, since you'd been part of the ongoing conversation.  
Apologies.

John.

> 
> On Wed, Jan 3, 2018 at 4:06 PM Richard Smith via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> On 3 January 2018 at 15:24, John McCall via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
>> On Jan 3, 2018, at 5:53 PM, Richard Smith > > wrote:
>> On 3 January 2018 at 14:29, John McCall via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>>> On Jan 3, 2018, at 5:12 PM, Richard Smith >> > wrote:
>>> 
>>> On 2 January 2018 at 20:55, John McCall via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
 On Jan 2, 2018, at 10:43 PM, Richard Smith >>> > wrote:
 
 On 2 January 2018 at 19:02, John McCall via cfe-commits 
 mailto:cfe-commits@lists.llvm.org>> wrote:
 
> On Jan 2, 2018, at 9:15 PM, Akira Hatanaka  > wrote:
> 
> 
> 
>> On Jan 2, 2018, at 4:56 PM, Richard Smith via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>> On 2 January 2018 at 15:33, John McCall via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Hey, Richard et al.  Akira and I were talking about the right ABI rule 
>> for deciding can-pass-in-registers-ness for structs in the presence of 
>> trivial_abi, and I think I like Akira's approach but wanted to get your 
>> input.
>> 
>> The current definition in Itanium is:
>> 
>>   non-trivial for the purposes of calls <>
>>  <>
>> A type is considered non-trivial for the purposes of calls if:
>> 
>> it has a non-trivial copy constructor, move constructor, or destructor, 
>> or
>>  <>
>> I'm assuming we're implicitly excluding deleted functions here. (I'd 
>> prefer to make that explicit; this has been the source of a number of 
>> ABI mismatches.)
>> all of its copy and move constructors are deleted.
>>  <>
>> 
>> I'd suggest modifying this to:
>> 
>>  A type is considered non-trivial for the purposes of calls if:
>>  - if has a copy constructor, move constructor, or destructor 
>> which is non-trivial for the purposes of calls, or
>>  - all of its copy and move constructors are deleted and it does 
>> not have the trivial_abi attribute.
>> 
>>  A copy/move constructor is considered trivial for the purposes of calls 
>> if:
>>  - it is user-provided and
>>  - the class has the trivial_abi attribute and
>>  - a defaulted definition of the constructor would be 
>> trivial for the purposes of calls; or
>> 
>> We'd need to say what happens if the function in question cannot validly 
>> be defaulted for any of the reasons in [dcl.fct.def.default]. Do we try 
>> to infer whether it's a copy or move constructor, and use the rules for 
>> a defaulted copy or move constructor? Or do we just say that's never 
>> trivial for the purposes of calls? Or something else? Eg:
>> 
>> struct [[clang::trivial_abi]] A {
>>   A(A && = make());
>> };
>> 
>> Here, A::A(A&&) cannot validly be defaulted. Is A trivial for the 
>> purpose of calls? Likewise:
>> 
>> struct [[clang::trivial_abi]] B {
>>   B(...);
>> };
>> struct C {
>>   volatile B b;
>> };
>> 
>> Here, C's copy constructor calls B::B(...). Is C trivial for the purpose 
>> of calls? (OK, Clang crashes on that example today. But still...)
>> 
>> I'd be uncomfortable making the rules in [dcl.fct.def.default] part of 
>> the ABI; they seem to be changing relatively frequently. Perhaps we 
>> could say "if the function is a copy constructor ([class.copy.ctor]/1), 
>> then consider what an implicitly-declared defaulted copy constructor 
>> would do; if it's a move constructor ([class.copy.ctor]/2), then 
>> consider what an implicitly-declared defaulted move constructor would 
>> do; otherwise, it's not trivial for the purpose of calls". That'd mean A 
>> is trivial for the purpose of calls and C is not, which I think is 
>> probably the right answer.
>> 
>>  - it is not user-provided and
>>  - the class has no virtual functions and no virtual 
>> base classes, and
>>  - the constructor used to copy/move each direct base 

Re: r321997 - Avoid assumption that lit tests are writable. NFC

2018-01-08 Thread David Blaikie via cfe-commits
I'm sure it's something obvious I don't understand here, but maybe someone
else doesn't either & could benefit from it:

What exactly does this change do? In what important way is "cp X Y"
different from "cat X > Y"?

On Mon, Jan 8, 2018 at 7:06 AM Sam McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sammccall
> Date: Mon Jan  8 07:05:01 2018
> New Revision: 321997
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321997&view=rev
> Log:
> Avoid assumption that lit tests are writable. NFC
>
> Modified:
> cfe/trunk/test/ARCMT/releases-driver.m
> cfe/trunk/test/ARCMT/releases-driver.m.result
> cfe/trunk/test/ARCMT/with-arc-mode-modify.m
> cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result
> cfe/trunk/test/PCH/verify_pch.m
> cfe/trunk/test/VFS/real-path-found-first.m
>
> Modified: cfe/trunk/test/ARCMT/releases-driver.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/releases-driver.m?rev=321997&r1=321996&r2=321997&view=diff
>
> ==
> --- cfe/trunk/test/ARCMT/releases-driver.m (original)
> +++ cfe/trunk/test/ARCMT/releases-driver.m Mon Jan  8 07:05:01 2018
> @@ -1,5 +1,5 @@
>  // RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c
> %s.result
> -// RUN: cp %s %t
> +// RUN: cat %s > %t
>  // RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x
> objective-c %t
>  // RUN: diff %t %s.result
>  // RUN: rm %t
>
> Modified: cfe/trunk/test/ARCMT/releases-driver.m.result
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/releases-driver.m.result?rev=321997&r1=321996&r2=321997&view=diff
>
> ==
> --- cfe/trunk/test/ARCMT/releases-driver.m.result (original)
> +++ cfe/trunk/test/ARCMT/releases-driver.m.result Mon Jan  8 07:05:01 2018
> @@ -1,5 +1,5 @@
>  // RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c
> %s.result
> -// RUN: cp %s %t
> +// RUN: cat %s > %t
>  // RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x
> objective-c %t
>  // RUN: diff %t %s.result
>  // RUN: rm %t
>
> Modified: cfe/trunk/test/ARCMT/with-arc-mode-modify.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/with-arc-mode-modify.m?rev=321997&r1=321996&r2=321997&view=diff
>
> ==
> --- cfe/trunk/test/ARCMT/with-arc-mode-modify.m (original)
> +++ cfe/trunk/test/ARCMT/with-arc-mode-modify.m Mon Jan  8 07:05:01 2018
> @@ -1,5 +1,5 @@
>  // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
> -// RUN: cp %s %t
> +// RUN: cat %s > %t
>  // RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c
> %t
>  // RUN: diff %t %s.result
>  // RUN: rm %t
>
> Modified: cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result?rev=321997&r1=321996&r2=321997&view=diff
>
> ==
> --- cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result (original)
> +++ cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result Mon Jan  8 07:05:01
> 2018
> @@ -1,5 +1,5 @@
>  // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
> -// RUN: cp %s %t
> +// RUN: cat %s > %t
>  // RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c
> %t
>  // RUN: diff %t %s.result
>  // RUN: rm %t
>
> Modified: cfe/trunk/test/PCH/verify_pch.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/verify_pch.m?rev=321997&r1=321996&r2=321997&view=diff
>
> ==
> --- cfe/trunk/test/PCH/verify_pch.m (original)
> +++ cfe/trunk/test/PCH/verify_pch.m Mon Jan  8 07:05:01 2018
> @@ -2,7 +2,7 @@
>  // RUN: rm -rf %t
>  // RUN: mkdir -p %t/usr/include
>  // RUN: echo '// empty' > %t/usr/include/sys_header.h
> -// RUN: cp %s %t.h
> +// RUN: cat %s > %t.h
>  //
>  // Precompile
>  // RUN: %clang_cc1 -isystem %t/usr/include -x objective-c-header
> -emit-pch -o %t.pch %t.h
>
> Modified: cfe/trunk/test/VFS/real-path-found-first.m
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/real-path-found-first.m?rev=321997&r1=321996&r2=321997&view=diff
>
> ==
> --- cfe/trunk/test/VFS/real-path-found-first.m (original)
> +++ cfe/trunk/test/VFS/real-path-found-first.m Mon Jan  8 07:05:01 2018
> @@ -7,7 +7,7 @@
>  // REQUIRES: shell
>  // RUN: rm -rf %t %t-cache %t.pch
>  // RUN: mkdir -p %t/SomeFramework.framework/Modules
> -// RUN: cp %S/Inputs/some_frame_module.map
> %t/SomeFramework.framework/Modules/module.modulemap
> +// RUN: cat %S/Inputs/some_frame_module.map >
> %t/SomeFramework.framework/Modules/module.modulemap
>  // RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%t:g"
>

Re: r321854 - NFC.

2018-01-08 Thread David Blaikie via cfe-commits
It helps to have the first line of the commit message be roughly
descriptive, since it forms the brief commit summary in version tools and
the subject line in commit email - just "NFC" is a bit unclear. Usually
these sort of commits are described as, say "Suppress -Asserts
unused-variable warning for variable only used in an assert".

On Fri, Jan 5, 2018 at 4:52 AM Evgeny Stupachenko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: evstupac
> Date: Thu Jan  4 18:22:52 2018
> New Revision: 321854
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321854&view=rev
> Log:
> NFC.
> The patch fixes r321395, that cuased
>  -Werror=unused-but-set-variable issue for
>  Diagnosed var on prod build.
>
> From: Evgeny Stupachenko 
>
> Modified:
> cfe/trunk/lib/Serialization/ASTReader.cpp
>
> Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=321854&r1=321853&r2=321854&view=diff
>
> ==
> --- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
> +++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Jan  4 18:22:52 2018
> @@ -10660,6 +10660,7 @@ void ASTReader::diagnoseOdrViolations()
>Diagnosed = true;
>break;
>  }
> +(void)Diagnosed;
>  assert(Diagnosed && "Unable to emit ODR diagnostic.");
>}
>  }
>
>
> ___
> 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: r321816 - [OPENMP] Add debug info for generated functions.

2018-01-08 Thread David Blaikie via cfe-commits
Rough guess: That seems like a lot of code changes for relatively little
test changes - are all parts of this change tested? (Might well be - just
lots of layers to plumb things through - but if there's lots of places that
get locations and only a few of those are tested, maybe this could use more
coverage?)

On Thu, Jan 4, 2018 at 11:46 AM Alexey Bataev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: abataev
> Date: Thu Jan  4 11:45:16 2018
> New Revision: 321816
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321816&view=rev
> Log:
> [OPENMP] Add debug info for generated functions.
>
> Most of the generated functions for the OpenMP were generated with
> disabled debug info. Patch fixes this for better user experience.
>
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
> cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
> cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=321816&r1=321815&r2=321816&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jan  4 11:45:16 2018
> @@ -1216,7 +1216,8 @@ emitCombinerOrInitializer(CodeGenModule
>CodeGenFunction CGF(CGM);
>// Map "T omp_in;" variable to "*omp_in_parm" value in all expressions.
>// Map "T omp_out;" variable to "*omp_out_parm" value in all
> expressions.
> -  CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args);
> +  CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args,
> In->getLocation(),
> +Out->getLocation());
>CodeGenFunction::OMPPrivateScope Scope(CGF);
>Address AddrIn = CGF.GetAddrOfLocalVar(&OmpInParm);
>Scope.addPrivate(In, [&CGF, AddrIn, PtrTy]() -> Address {
> @@ -2383,7 +2384,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
>// threadprivate copy of the variable VD
>CodeGenFunction CtorCGF(CGM);
>FunctionArgList Args;
> -  ImplicitParamDecl Dst(CGM.getContext(), CGM.getContext().VoidPtrTy,
> +  ImplicitParamDecl Dst(CGM.getContext(), /*DC=*/nullptr, Loc,
> +/*Id=*/nullptr, CGM.getContext().VoidPtrTy,
>  ImplicitParamDecl::Other);
>Args.push_back(&Dst);
>
> @@ -2393,13 +2395,13 @@ llvm::Function *CGOpenMPRuntime::emitThr
>auto Fn = CGM.CreateGlobalInitOrDestructFunction(
>FTy, ".__kmpc_global_ctor_.", FI, Loc);
>CtorCGF.StartFunction(GlobalDecl(), CGM.getContext().VoidPtrTy, Fn,
> FI,
> -Args, SourceLocation());
> +Args, Loc, Loc);
>auto ArgVal = CtorCGF.EmitLoadOfScalar(
>CtorCGF.GetAddrOfLocalVar(&Dst), /*Volatile=*/false,
>CGM.getContext().VoidPtrTy, Dst.getLocation());
>Address Arg = Address(ArgVal, VDAddr.getAlignment());
> -  Arg = CtorCGF.Builder.CreateElementBitCast(Arg,
> -
>  CtorCGF.ConvertTypeForMem(ASTTy));
> +  Arg = CtorCGF.Builder.CreateElementBitCast(
> +  Arg, CtorCGF.ConvertTypeForMem(ASTTy));
>CtorCGF.EmitAnyExprToMem(Init, Arg, Init->getType().getQualifiers(),
> /*IsInitializer=*/true);
>ArgVal = CtorCGF.EmitLoadOfScalar(
> @@ -2414,7 +2416,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
>// of the variable VD
>CodeGenFunction DtorCGF(CGM);
>FunctionArgList Args;
> -  ImplicitParamDecl Dst(CGM.getContext(), CGM.getContext().VoidPtrTy,
> +  ImplicitParamDecl Dst(CGM.getContext(), /*DC=*/nullptr, Loc,
> +/*Id=*/nullptr, CGM.getContext().VoidPtrTy,
>  ImplicitParamDecl::Other);
>Args.push_back(&Dst);
>
> @@ -2425,7 +2428,7 @@ llvm::Function *CGOpenMPRuntime::emitThr
>FTy, ".__kmpc_global_dtor_.", FI, Loc);
>auto NL = ApplyDebugLocation::CreateEmpty(DtorCGF);
>DtorCGF.StartFunction(GlobalDecl(), CGM.getContext().VoidTy, Fn,
> FI, Args,
> -SourceLocation());
> +Loc, Loc);
>// Create a scope with an artificial location for the body of this
> function.
>auto AL = ApplyDebugLocation::CreateArtificial(DtorCGF);
>auto ArgVal = DtorCGF.EmitLoadOfScalar(
> @@ -2469,7 +2472,7 @@ llvm::Function *CGOpenMPRuntime::emitThr
>FunctionArgList ArgList;
>InitCGF.StartFunction(GlobalDecl(), CGM.getContext().VoidTy,
> InitFunction,
>  CGM.getTypes().arrangeNullaryFunction(),
> ArgList,
> -Loc);
> +Loc, Loc);
>emitThreadPrivateVarInit(InitCGF, VDAddr, Ctor, CopyCtor, Dtor,
> Loc);
>   

Re: r321845 - Debug Info: Support DW_AT_calling_convention on composite types.

2018-01-08 Thread David Blaikie via cfe-commits
Great - are you tracking/planning to implement this for trivial_abi once
it's in? (was mentioned in the code review, but not sure if it's on your
plate/plan or not (no worries if it isn't, just keeping these things in
mind))

On Thu, Jan 4, 2018 at 5:14 PM Adrian Prantl via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: adrian
> Date: Thu Jan  4 17:13:52 2018
> New Revision: 321845
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321845&view=rev
> Log:
> Debug Info: Support DW_AT_calling_convention on composite types.
> This implements the DWARF 5 feature described at
> http://www.dwarfstd.org/ShowIssue.php?issue=141215.1
>
> This allows a consumer to understand whether a composite data type is
> trivially copyable and thus should be passed by value instead of by
> reference. The canonical example is being able to distinguish the
> following two types:
>
>   // S is not trivially copyable because of the explicit destructor.
>   struct S {
>  ~S() {}
>   };
>
>   // T is a POD type.
>   struct T {
> ~T() = default;
>   };
>
> 
> Differential Revision: https://reviews.llvm.org/D41039
>
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan  4 17:13:52 2018
> @@ -2803,9 +2803,18 @@ llvm::DICompositeType *CGDebugInfo::Crea
>
>SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
>
> +  // Explicitly record the calling convention for C++ records.
> +  auto Flags = llvm::DINode::FlagZero;
> +  if (auto CXXRD = dyn_cast(RD)) {
> +if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)
> +  Flags |= llvm::DINode::FlagTypePassByReference;
> +else
> +  Flags |= llvm::DINode::FlagTypePassByValue;
> +  }
> +
>llvm::DICompositeType *RealDecl =
> DBuilder.createReplaceableCompositeType(
>getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size,
> Align,
> -  llvm::DINode::FlagZero, FullName);
> +  Flags, FullName);
>
>// Elements of composite types usually have back to the type, creating
>// uniquing cycles.  Distinct nodes are more efficient.
>
> Added: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto
>
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Jan  4
> 17:13:52 2018
> @@ -0,0 +1,48 @@
> +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple
> %itanium_abi_triple %s -o - | FileCheck %s
> +
> +// Not trivially copyable because of the explicit destructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefDtor",{{.*}}flags:
> DIFlagTypePassByReference
> +struct RefDtor {
> +  int i;
> +  ~RefDtor() {}
> +} refDtor;
> +
> +// Not trivially copyable because of the explicit copy constructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefCopy",{{.*}}flags:
> DIFlagTypePassByReference
> +struct RefCopy {
> +  int i;
> +  RefCopy() = default;
> +  RefCopy(RefCopy &Copy) {}
> +} refCopy;
> +
> +// Not trivially copyable because of the explicit move constructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefMove",{{.*}}flags:
> DIFlagTypePassByReference
> +struct RefMove {
> +  int i;
> +  RefMove() = default;
> +  RefMove(RefMove &&Move) {}
> +} refMove;
> +
> +// POD-like type even though it defines a destructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Podlike", {{.*}}flags:
> DIFlagTypePassByValue
> +struct Podlike {
> +  int i;
> +  Podlike() = default;
> +  Podlike(Podlike &&Move) = default;
> +  ~Podlike() = default;
> +} podlike;
> +
> +
> +// This is a POD type.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Pod",{{.*}}flags:
> DIFlagTypePassByValue
> +struct Pod {
> +  int i;
> +} pod;
> +
> +// This is definitely not a POD type.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Complex",{{.*}}flags:
> DIFlagTypePassByReference
> +struct Complex {
> +  Complex() {}
> +  Complex(Complex &Copy) : i(Copy.i) {};
> +  int i;
> +} complex;
>
>
> ___
> 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] D41039: Add support for attribute "trivial_abi"

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



Comment at: include/clang/AST/Type.h:811
 
+  bool hasTrivialABIOverride() const;
+

This should get a comment, even if it's just to refer to the CXXRecordDecl 
method.



Comment at: lib/CodeGen/CGCall.cpp:3498
   bool HasAggregateEvalKind = hasAggregateEvaluationKind(type);
+  bool HasTrivialABIOverride = type.hasTrivialABIOverride();
 

Please sink this call to the points where you use it; it should be possible to 
avoid computing it in most cases.



Comment at: lib/CodeGen/CGCall.cpp:3505
+   CGM.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee()) ||
+  HasTrivialABIOverride) {
 // If we're using inalloca, use the argument memory.  Otherwise, use a

e.g. here you can conditionalize it on HasAggregateEvalKind, which is both 
slightly faster and clearer to the reader.



Comment at: lib/CodeGen/CGCall.cpp:3518
+ CGM.getCXXABI().getRecordArgABI(RD) != CGCXXABI::RAA_Default) ||
+HasTrivialABIOverride;
 if (DestroyedInCallee)

And here you can guard it by RD && RD->hasNonTrivialDestructor(), and you can 
just call hasNonTrivialABIOverride() directly on RD.



Comment at: lib/Sema/SemaDecl.cpp:11700
+}
+  }
+

I think it's correct not to call CheckDestructorAccess and DiagnoseUseOfDecl 
here, since according to the standard destructor access is always supposed to 
be checked at the call-site, but please leave a comment explaining that.


https://reviews.llvm.org/D41039



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


[PATCH] D41539: [CodeGen] Decorate aggregate accesses with TBAA tags

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

Yes, I think that's fine.

I think unconditionally attaching the tag is probably wrong; you need suppress 
it in the may_alias cases.  I'll grant that the existing code doesn't honor 
that, but that seems like a bug we should go ahead and fix.  You'll need to 
either propagate more information into this function or propagate out the 
memcpy instruction so that callers can decide how to apply TBAA.


https://reviews.llvm.org/D41539



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


r322005 - Emit Function IDs table for Control Flow Guard

2018-01-08 Thread Adrian McCarthy via cfe-commits
Author: amccarth
Date: Mon Jan  8 08:33:42 2018
New Revision: 322005

URL: http://llvm.org/viewvc/llvm-project?rev=322005&view=rev
Log:
Emit Function IDs table for Control Flow Guard

Adds option /guard:cf to clang-cl and -cfguard to cc1 to emit function IDs
of functions that have their address taken into a section named .gfids$y for
compatibility with Microsoft's Control Flow Guard feature.

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

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=322005&r1=322004&r2=322005&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Mon Jan  8 08:33:42 2018
@@ -235,6 +235,8 @@ def _SLASH_Fi : CLCompileJoined<"Fi">,
 def _SLASH_Fo : CLCompileJoined<"Fo">,
   HelpText<"Set output object file, or directory (ends in / or \\) (with /c)">,
   MetaVarName<"">;
+def _SLASH_Guard : CLJoined<"guard:">,
+  HelpText<"Enable Control Flow Guard with /guard:cf">;
 def _SLASH_GX : CLFlag<"GX">,
   HelpText<"Enable exception handling">;
 def _SLASH_GX_ : CLFlag<"GX-">,
@@ -364,7 +366,6 @@ def _SLASH_GL_ : CLFlag<"GL-">;
 def _SLASH_Gm : CLFlag<"Gm">;
 def _SLASH_Gm_ : CLFlag<"Gm-">;
 def _SLASH_GT : CLFlag<"GT">;
-def _SLASH_Guard : CLJoined<"guard:">;
 def _SLASH_GZ : CLFlag<"GZ">;
 def _SLASH_H : CLFlag<"H">;
 def _SLASH_homeparams : CLFlag<"homeparams">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=322005&r1=322004&r2=322005&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jan  8 08:33:42 2018
@@ -492,6 +492,8 @@ def bind__at__load : Flag<["-"], "bind_a
 def bundle__loader : Separate<["-"], "bundle_loader">;
 def bundle : Flag<["-"], "bundle">;
 def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>;
+def cfguard : Flag<["-"], "cfguard">, Flags<[CC1Option]>,
+  HelpText<"Emit tables required for Windows Control Flow Guard.">;
 def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. This option disables all optimizations. By default 
optimizations are enabled.">;
 def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, 
Group, Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=322005&r1=322004&r2=322005&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Jan  8 08:33:42 2018
@@ -38,6 +38,7 @@ CODEGENOPT(AssumeSaneOperatorNew , 1, 1)
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.
 CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
+CODEGENOPT(ControlFlowGuard  , 1, 0) ///< -cfguard
 CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum 
for functions in GCNO files.
 CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function 
names in GCDA files.
 CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit 
block before the body blocks in GCNO files.

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=322005&r1=322004&r2=322005&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jan  8 08:33:42 2018
@@ -456,6 +456,10 @@ void CodeGenModule::Release() {
 // Indicate that we want CodeView in the metadata.
 getModule().addModuleFlag(llvm::Module::Warning, "CodeView", 1);
   }
+  if (CodeGenOpts.ControlFlowGuard) {
+// We want function ID tables for Control Flow Guard.
+getModule().addModuleFlag(llvm::Module::Warning, "cfguard", 1);
+  }
   if (CodeGenOpts.OptimizationLevel > 0 && CodeGenOpts.StrictVTablePointers) {
 // We don't support LTO with 2 with different StrictVTablePointers
 // FIXME: we could support it by stripping all the information introduced

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-projec

[PATCH] D41823: [clangd] Add more filters for collected symbols.

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

o We only collect symbols in namespace or translation unit scopes.
o Add an option to only collect symbols in included headers.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41823

Files:
  clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
  clangd/index/FileIndex.cpp
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -50,20 +50,22 @@
 namespace {
 class SymbolIndexActionFactory : public tooling::FrontendActionFactory {
 public:
-  SymbolIndexActionFactory() = default;
+  SymbolIndexActionFactory(SymbolCollector::Options COpts)
+  : COpts(std::move(COpts)) {}
 
   clang::FrontendAction *create() override {
 index::IndexingOptions IndexOpts;
 IndexOpts.SystemSymbolFilter =
 index::IndexingOptions::SystemSymbolFilterKind::All;
 IndexOpts.IndexFunctionLocals = false;
-Collector = std::make_shared();
+Collector = std::make_shared(COpts);
 FrontendAction *Action =
 index::createIndexingAction(Collector, IndexOpts, nullptr).release();
 return Action;
   }
 
   std::shared_ptr Collector;
+  SymbolCollector::Options COpts;
 };
 
 class SymbolCollectorTest : public ::testing::Test {
@@ -76,7 +78,7 @@
 
 const std::string FileName = "symbol.cc";
 const std::string HeaderName = "symbols.h";
-auto Factory = llvm::make_unique();
+auto Factory = llvm::make_unique(CollectorOpts);
 
 tooling::ToolInvocation Invocation(
 {"symbol_collector", "-fsyntax-only", "-std=c++11", FileName},
@@ -97,50 +99,87 @@
 
 protected:
   SymbolSlab Symbols;
+  SymbolCollector::Options CollectorOpts;
 };
 
-TEST_F(SymbolCollectorTest, CollectSymbol) {
+TEST_F(SymbolCollectorTest, IgnoreSymbolsInMainFile) {
   const std::string Header = R"(
-class Foo {
-  void f();
-};
+class Foo {};
 void f1();
 inline void f2() {}
   )";
   const std::string Main = R"(
 namespace {
 void ff() {} // ignore
 }
+void main_f() {} // ignore
 void f1() {}
   )";
   runSymbolCollector(Header, Main);
-  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo"), QName("Foo::f"),
-QName("f1"), QName("f2")));
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("Foo"), QName("f1"), QName("f2")));
 }
 
-TEST_F(SymbolCollectorTest, SymbolWithDocumentation) {
+TEST_F(SymbolCollectorTest, IncludeSymbolsInMainFile) {
+  CollectorOpts.IndexMainFiles = true;
+  const std::string Header = R"(
+class Foo {};
+void f1();
+inline void f2() {}
+  )";
   const std::string Main = R"(
+namespace {
+void ff() {} // ignore
+}
+void main_f() {}
+void f1() {}
+  )";
+  runSymbolCollector(Header, Main);
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo"), QName("f1"),
+QName("f2"), QName("main_f")));
+}
+
+TEST_F(SymbolCollectorTest, IgnoreClassMembers) {
+  const std::string Header = R"(
+class Foo {
+  void f() {}
+  void g();
+  static void sf() {}
+  static void ssf();
+  static int x;
+};
+  )";
+  const std::string Main = R"(
+void Foo::g() {}
+void Foo::ssf() {}
+  )";
+  runSymbolCollector(Header, Main);
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo")));
+}
+
+TEST_F(SymbolCollectorTest, SymbolWithDocumentation) {
+  const std::string Header = R"(
 namespace nx {
 /// Foo comment.
 int ff(int x, double y) { return 0; }
 }
   )";
-  runSymbolCollector(/*Header=*/"", Main);
+  runSymbolCollector(Header, /*Main=*/"");
   EXPECT_THAT(Symbols,
   UnorderedElementsAre(QName("nx"),
AllOf(QName("nx::ff"),
  Labeled("ff(int x, double y)"),
  Detail("int"), Doc("Foo comment.";
 }
 
 TEST_F(SymbolCollectorTest, PlainAndSnippet) {
-  const std::string Main = R"(
+  const std::string Header = R"(
 namespace nx {
 void f() {}
 int ff(int x, double y) { return 0; }
 }
   )";
-  runSymbolCollector(/*Header=*/"", Main);
+  runSymbolCollector(Header, /*Main=*/"");
   EXPECT_THAT(
   Symbols,
   UnorderedElementsAre(
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -166,15 +166,15 @@
   EXPECT_THAT(match(M, FuzzyFindRequest()), UnorderedElementsAre());
 }
 
-TEST(FileIndexTest, ClassMembers) {
+TEST(FileIndexTest, IgnoreClassMembers) {

Re: r321845 - Debug Info: Support DW_AT_calling_convention on composite types.

2018-01-08 Thread Adrian Prantl via cfe-commits


> On Jan 8, 2018, at 8:14 AM, David Blaikie  wrote:
> 
> Great - are you tracking/planning to implement this for trivial_abi once it's 
> in? (was mentioned in the code review, but not sure if it's on your 
> plate/plan or not (no worries if it isn't, just keeping these things in mind))

Yes, this was in fact my primary motivation for the feature. Since the code is 
asking the ABI object, it looks like this might work out of the box with the 
trivial_abi attribute, but I will definitely at least add a testcase once it's 
in.

-- adrian

> 
> On Thu, Jan 4, 2018 at 5:14 PM Adrian Prantl via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: adrian
> Date: Thu Jan  4 17:13:52 2018
> New Revision: 321845
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=321845&view=rev 
> 
> Log:
> Debug Info: Support DW_AT_calling_convention on composite types.
> This implements the DWARF 5 feature described at
> http://www.dwarfstd.org/ShowIssue.php?issue=141215.1 
> 
> 
> This allows a consumer to understand whether a composite data type is
> trivially copyable and thus should be passed by value instead of by
> reference. The canonical example is being able to distinguish the
> following two types:
> 
>   // S is not trivially copyable because of the explicit destructor.
>   struct S {
>  ~S() {}
>   };
> 
>   // T is a POD type.
>   struct T {
> ~T() = default;
>   };
> 
> 
> Differential Revision: https://reviews.llvm.org/D41039 
> 
> 
> Added:
> cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan  4 17:13:52 2018
> @@ -2803,9 +2803,18 @@ llvm::DICompositeType *CGDebugInfo::Crea
> 
>SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
> 
> +  // Explicitly record the calling convention for C++ records.
> +  auto Flags = llvm::DINode::FlagZero;
> +  if (auto CXXRD = dyn_cast(RD)) {
> +if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)
> +  Flags |= llvm::DINode::FlagTypePassByReference;
> +else
> +  Flags |= llvm::DINode::FlagTypePassByValue;
> +  }
> +
>llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(
>getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size, Align,
> -  llvm::DINode::FlagZero, FullName);
> +  Flags, FullName);
> 
>// Elements of composite types usually have back to the type, creating
>// uniquing cycles.  Distinct nodes are more efficient.
> 
> Added: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto
>  
> 
> ==
> --- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (added)
> +++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Jan  4 17:13:52 
> 2018
> @@ -0,0 +1,48 @@
> +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple 
> %itanium_abi_triple %s -o - | FileCheck %s
> +
> +// Not trivially copyable because of the explicit destructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefDtor",{{.*}}flags: 
> DIFlagTypePassByReference
> +struct RefDtor {
> +  int i;
> +  ~RefDtor() {}
> +} refDtor;
> +
> +// Not trivially copyable because of the explicit copy constructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefCopy",{{.*}}flags: 
> DIFlagTypePassByReference
> +struct RefCopy {
> +  int i;
> +  RefCopy() = default;
> +  RefCopy(RefCopy &Copy) {}
> +} refCopy;
> +
> +// Not trivially copyable because of the explicit move constructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefMove",{{.*}}flags: 
> DIFlagTypePassByReference
> +struct RefMove {
> +  int i;
> +  RefMove() = default;
> +  RefMove(RefMove &&Move) {}
> +} refMove;
> +
> +// POD-like type even though it defines a destructor.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Podlike", {{.*}}flags: 
> DIFlagTypePassByValue
> +struct Podlike {
> +  int i;
> +  Podlike() = default;
> +  Podlike(Podlike &&Move) = default;
> +  ~Podlike() = default;
> +} podlike;
> +
> +
> +// This is a POD type.
> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Pod",{{.*}}flags: 
> DIFlagTypePas

Re: r321845 - Debug Info: Support DW_AT_calling_convention on composite types.

2018-01-08 Thread David Blaikie via cfe-commits
Excellent :)

On Mon, Jan 8, 2018 at 8:39 AM Adrian Prantl  wrote:

>
> On Jan 8, 2018, at 8:14 AM, David Blaikie  wrote:
>
> Great - are you tracking/planning to implement this for trivial_abi once
> it's in? (was mentioned in the code review, but not sure if it's on your
> plate/plan or not (no worries if it isn't, just keeping these things in
> mind))
>
>
> Yes, this was in fact my primary motivation for the feature. Since the
> code is asking the ABI object, it looks like this might work out of the box
> with the trivial_abi attribute, but I will definitely at least add a
> testcase once it's in.
>
> -- adrian
>
>
> On Thu, Jan 4, 2018 at 5:14 PM Adrian Prantl via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: adrian
>> Date: Thu Jan  4 17:13:52 2018
>> New Revision: 321845
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=321845&view=rev
>> Log:
>> Debug Info: Support DW_AT_calling_convention on composite types.
>> This implements the DWARF 5 feature described at
>> http://www.dwarfstd.org/ShowIssue.php?issue=141215.1
>>
>> This allows a consumer to understand whether a composite data type is
>> trivially copyable and thus should be passed by value instead of by
>> reference. The canonical example is being able to distinguish the
>> following two types:
>>
>>   // S is not trivially copyable because of the explicit destructor.
>>   struct S {
>>  ~S() {}
>>   };
>>
>>   // T is a POD type.
>>   struct T {
>> ~T() = default;
>>   };
>>
>> 
>> Differential Revision: https://reviews.llvm.org/D41039
>>
>> Added:
>> cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=321845&r1=321844&r2=321845&view=diff
>>
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Jan  4 17:13:52 2018
>> @@ -2803,9 +2803,18 @@ llvm::DICompositeType *CGDebugInfo::Crea
>>
>>SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
>>
>> +  // Explicitly record the calling convention for C++ records.
>> +  auto Flags = llvm::DINode::FlagZero;
>> +  if (auto CXXRD = dyn_cast(RD)) {
>> +if (CGM.getCXXABI().getRecordArgABI(CXXRD) == CGCXXABI::RAA_Indirect)
>> +  Flags |= llvm::DINode::FlagTypePassByReference;
>> +else
>> +  Flags |= llvm::DINode::FlagTypePassByValue;
>> +  }
>> +
>>llvm::DICompositeType *RealDecl =
>> DBuilder.createReplaceableCompositeType(
>>getTagForRecord(RD), RDName, RDContext, DefUnit, Line, 0, Size,
>> Align,
>> -  llvm::DINode::FlagZero, FullName);
>> +  Flags, FullName);
>>
>>// Elements of composite types usually have back to the type, creating
>>// uniquing cycles.  Distinct nodes are more efficient.
>>
>> Added: cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp?rev=321845&view=auto
>>
>> ==
>> --- cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp (added)
>> +++ cfe/trunk/test/CodeGenCXX/debug-info-composite-cc.cpp Thu Jan  4
>> 17:13:52 2018
>> @@ -0,0 +1,48 @@
>> +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone -triple
>> %itanium_abi_triple %s -o - | FileCheck %s
>> +
>> +// Not trivially copyable because of the explicit destructor.
>> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefDtor",{{.*}}flags:
>> DIFlagTypePassByReference
>> +struct RefDtor {
>> +  int i;
>> +  ~RefDtor() {}
>> +} refDtor;
>> +
>> +// Not trivially copyable because of the explicit copy constructor.
>> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefCopy",{{.*}}flags:
>> DIFlagTypePassByReference
>> +struct RefCopy {
>> +  int i;
>> +  RefCopy() = default;
>> +  RefCopy(RefCopy &Copy) {}
>> +} refCopy;
>> +
>> +// Not trivially copyable because of the explicit move constructor.
>> +// CHECK-DAG: !DICompositeType({{.*}}, name: "RefMove",{{.*}}flags:
>> DIFlagTypePassByReference
>> +struct RefMove {
>> +  int i;
>> +  RefMove() = default;
>> +  RefMove(RefMove &&Move) {}
>> +} refMove;
>> +
>> +// POD-like type even though it defines a destructor.
>> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Podlike", {{.*}}flags:
>> DIFlagTypePassByValue
>> +struct Podlike {
>> +  int i;
>> +  Podlike() = default;
>> +  Podlike(Podlike &&Move) = default;
>> +  ~Podlike() = default;
>> +} podlike;
>> +
>> +
>> +// This is a POD type.
>> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Pod",{{.*}}flags:
>> DIFlagTypePassByValue
>> +struct Pod {
>> +  int i;
>> +} pod;
>> +
>> +// This is definitely not a POD type.
>> +// CHECK-DAG: !DICompositeType({{.*}}, name: "Complex",{{.*}}flags:
>> DIFlagTypePassByReference
>> +struct Complex {
>> 

[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

2018-01-08 Thread Kalle Huttunen via Phabricator via cfe-commits
khuttun added inline comments.



Comment at: test/clang-tidy/bugprone-unused-return-value.cpp:163
+
+void noWarning() {
+  auto AsyncRetval1 = std::async(increment, 42);

aaron.ballman wrote:
> khuttun wrote:
> > aaron.ballman wrote:
> > > Sorry, I just realized that we're missing a test case for a common 
> > > situation -- where the result is used as part of another call expression. 
> > > Can you add a test to `noWarning()` to make sure this does not warn:
> > > ```
> > > std::vector v;
> > > extern void f(bool);
> > > 
> > > f(v.empty()); // Should not warn
> > > ```
> > See line 199 in this file.
> Ah, my eyes missed that, thank you!
> 
> Hmm, I *think* this test should also be okay, but I want to be sure:
> ```
> std::vector v;
> bool b = ({v.empty()}); // Should not warn
> ({v.empty()}); // ???
> ```
> I kind of thing that, as an extension to the spirit of this check, any GNU 
> expression statement whose result is unused should probably be diagnosed; 
> what do you think?
> 
> You should add tests for the above so we document the expected behavior here.
Getting a warning when just surrounding the call expression with parenthesis is 
tested in bugprone-unused-return-value-custom.cpp.

Would your example be parsed as creating an initializer_list? In that case it 
should not warn. I can add test cases for that.

What do you mean by "GNU expression"?


https://reviews.llvm.org/D41655



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


r322008 - Revert "Emit Function IDs table for Control Flow Guard"

2018-01-08 Thread Adrian McCarthy via cfe-commits
Author: amccarth
Date: Mon Jan  8 09:12:01 2018
New Revision: 322008

URL: http://llvm.org/viewvc/llvm-project?rev=322008&view=rev
Log:
Revert "Emit Function IDs table for Control Flow Guard"

The new test fails on the Hexagon bot.  Reverting while I investigate.

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

This reverts commit b7e0026b4385180c378edc658ec91a39566f2942.

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=322008&r1=322007&r2=322008&view=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Mon Jan  8 09:12:01 2018
@@ -235,8 +235,6 @@ def _SLASH_Fi : CLCompileJoined<"Fi">,
 def _SLASH_Fo : CLCompileJoined<"Fo">,
   HelpText<"Set output object file, or directory (ends in / or \\) (with /c)">,
   MetaVarName<"">;
-def _SLASH_Guard : CLJoined<"guard:">,
-  HelpText<"Enable Control Flow Guard with /guard:cf">;
 def _SLASH_GX : CLFlag<"GX">,
   HelpText<"Enable exception handling">;
 def _SLASH_GX_ : CLFlag<"GX-">,
@@ -366,6 +364,7 @@ def _SLASH_GL_ : CLFlag<"GL-">;
 def _SLASH_Gm : CLFlag<"Gm">;
 def _SLASH_Gm_ : CLFlag<"Gm-">;
 def _SLASH_GT : CLFlag<"GT">;
+def _SLASH_Guard : CLJoined<"guard:">;
 def _SLASH_GZ : CLFlag<"GZ">;
 def _SLASH_H : CLFlag<"H">;
 def _SLASH_homeparams : CLFlag<"homeparams">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=322008&r1=322007&r2=322008&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jan  8 09:12:01 2018
@@ -492,8 +492,6 @@ def bind__at__load : Flag<["-"], "bind_a
 def bundle__loader : Separate<["-"], "bundle_loader">;
 def bundle : Flag<["-"], "bundle">;
 def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>;
-def cfguard : Flag<["-"], "cfguard">, Flags<[CC1Option]>,
-  HelpText<"Emit tables required for Windows Control Flow Guard.">;
 def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. This option disables all optimizations. By default 
optimizations are enabled.">;
 def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, 
Group, Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=322008&r1=322007&r2=322008&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Mon Jan  8 09:12:01 2018
@@ -38,7 +38,6 @@ CODEGENOPT(AssumeSaneOperatorNew , 1, 1)
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be 
EH-safe.
 CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
-CODEGENOPT(ControlFlowGuard  , 1, 0) ///< -cfguard
 CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum 
for functions in GCNO files.
 CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function 
names in GCDA files.
 CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit 
block before the body blocks in GCNO files.

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=322008&r1=322007&r2=322008&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jan  8 09:12:01 2018
@@ -456,10 +456,6 @@ void CodeGenModule::Release() {
 // Indicate that we want CodeView in the metadata.
 getModule().addModuleFlag(llvm::Module::Warning, "CodeView", 1);
   }
-  if (CodeGenOpts.ControlFlowGuard) {
-// We want function ID tables for Control Flow Guard.
-getModule().addModuleFlag(llvm::Module::Warning, "cfguard", 1);
-  }
   if (CodeGenOpts.OptimizationLevel > 0 && CodeGenOpts.StrictVTablePointers) {
 // We don't support LTO with 2 with different StrictVTablePointers
 // FIXME: we could support it by stripping all the information introduced

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=322008&r1=322007&r2=322008&v

[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

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



Comment at: test/clang-tidy/bugprone-unused-return-value.cpp:163
+
+void noWarning() {
+  auto AsyncRetval1 = std::async(increment, 42);

khuttun wrote:
> aaron.ballman wrote:
> > khuttun wrote:
> > > aaron.ballman wrote:
> > > > Sorry, I just realized that we're missing a test case for a common 
> > > > situation -- where the result is used as part of another call 
> > > > expression. Can you add a test to `noWarning()` to make sure this does 
> > > > not warn:
> > > > ```
> > > > std::vector v;
> > > > extern void f(bool);
> > > > 
> > > > f(v.empty()); // Should not warn
> > > > ```
> > > See line 199 in this file.
> > Ah, my eyes missed that, thank you!
> > 
> > Hmm, I *think* this test should also be okay, but I want to be sure:
> > ```
> > std::vector v;
> > bool b = ({v.empty()}); // Should not warn
> > ({v.empty()}); // ???
> > ```
> > I kind of thing that, as an extension to the spirit of this check, any GNU 
> > expression statement whose result is unused should probably be diagnosed; 
> > what do you think?
> > 
> > You should add tests for the above so we document the expected behavior 
> > here.
> Getting a warning when just surrounding the call expression with parenthesis 
> is tested in bugprone-unused-return-value-custom.cpp.
> 
> Would your example be parsed as creating an initializer_list? In that case it 
> should not warn. I can add test cases for that.
> 
> What do you mean by "GNU expression"?
> Getting a warning when just surrounding the call expression with parenthesis 
> is tested in bugprone-unused-return-value-custom.cpp.

Yup, this is something entirely different, however.

> Would your example be parsed as creating an initializer_list? In that case it 
> should not warn. I can add test cases for that.
>
> What do you mean by "GNU expression"?

Those examples are GNU expression statements, which is a GCC extension that 
Clang also supports. See 
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html for more information.

Effectively, the last statement in the GNU expression statement is the "return 
value" of the expression statement. We should make sure the warnings are 
sensible with this construct.


https://reviews.llvm.org/D41655



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


Re: r321816 - [OPENMP] Add debug info for generated functions.

2018-01-08 Thread Alexey Bataev via cfe-commits
Will add some more tests later today
-
Best regards,
Alexey Bataev

08.01.2018 11:13, David Blaikie пишет:
> Rough guess: That seems like a lot of code changes for relatively
> little test changes - are all parts of this change tested? (Might well
> be - just lots of layers to plumb things through - but if there's lots
> of places that get locations and only a few of those are tested, maybe
> this could use more coverage?)
>
> On Thu, Jan 4, 2018 at 11:46 AM Alexey Bataev via cfe-commits
> mailto:cfe-commits@lists.llvm.org>> wrote:
>
> Author: abataev
> Date: Thu Jan  4 11:45:16 2018
> New Revision: 321816
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321816&view=rev
> 
> 
> Log:
> [OPENMP] Add debug info for generated functions.
>
> Most of the generated functions for the OpenMP were generated with
> disabled debug info. Patch fixes this for better user experience.
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
>     cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
>     cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
>     cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
>     cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> URL:
> 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=321816&r1=321815&r2=321816&view=diff
> 
> 
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Jan  4 11:45:16 2018
> @@ -1216,7 +1216,8 @@ emitCombinerOrInitializer(CodeGenModule
>    CodeGenFunction CGF(CGM);
>    // Map "T omp_in;" variable to "*omp_in_parm" value in all
> expressions.
>    // Map "T omp_out;" variable to "*omp_out_parm" value in all
> expressions.
> -  CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args);
> +  CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args,
> In->getLocation(),
> +                    Out->getLocation());
>    CodeGenFunction::OMPPrivateScope Scope(CGF);
>    Address AddrIn = CGF.GetAddrOfLocalVar(&OmpInParm);
>    Scope.addPrivate(In, [&CGF, AddrIn, PtrTy]() -> Address {
> @@ -2383,7 +2384,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
>        // threadprivate copy of the variable VD
>        CodeGenFunction CtorCGF(CGM);
>        FunctionArgList Args;
> -      ImplicitParamDecl Dst(CGM.getContext(),
> CGM.getContext().VoidPtrTy,
> +      ImplicitParamDecl Dst(CGM.getContext(), /*DC=*/nullptr, Loc,
> +                            /*Id=*/nullptr,
> CGM.getContext().VoidPtrTy,
>                              ImplicitParamDecl::Other);
>        Args.push_back(&Dst);
>
> @@ -2393,13 +2395,13 @@ llvm::Function *CGOpenMPRuntime::emitThr
>        auto Fn = CGM.CreateGlobalInitOrDestructFunction(
>            FTy, ".__kmpc_global_ctor_.", FI, Loc);
>        CtorCGF.StartFunction(GlobalDecl(),
> CGM.getContext().VoidPtrTy, Fn, FI,
> -                            Args, SourceLocation());
> +                            Args, Loc, Loc);
>        auto ArgVal = CtorCGF.EmitLoadOfScalar(
>            CtorCGF.GetAddrOfLocalVar(&Dst), /*Volatile=*/false,
>            CGM.getContext().VoidPtrTy, Dst.getLocation());
>        Address Arg = Address(ArgVal, VDAddr.getAlignment());
> -      Arg = CtorCGF.Builder.CreateElementBitCast(Arg,
> -                                           
>  CtorCGF.ConvertTypeForMem(ASTTy));
> +      Arg = CtorCGF.Builder.CreateElementBitCast(
> +          Arg, CtorCGF.ConvertTypeForMem(ASTTy));
>        CtorCGF.EmitAnyExprToMem(Init, Arg,
> Init->getType().getQualifiers(),
>                                 /*IsInitializer=*/true);
>        ArgVal = CtorCGF.EmitLoadOfScalar(
> @@ -2414,7 +2416,8 @@ llvm::Function *CGOpenMPRuntime::emitThr
>        // of the variable VD
>        CodeGenFunction DtorCGF(CGM);
>        FunctionArgList Args;
> -      ImplicitParamDecl Dst(CGM.getContext(),
> CGM.getContext().VoidPtrTy,
> +      ImplicitParamDecl 

Re: r321997 - Avoid assumption that lit tests are writable. NFC

2018-01-08 Thread Sam McCall via cfe-commits
Hi David (and the list this time!),

If X is readonly, then after `cp X Y`, Y is also readonly. The `cat`
version doesn't propagate permissions.

The environment for lit tests isn't really spelled out, but relying on the
input files being +w doesn't seem obviously reasonable.
Google's internal runner puts them on a readonly filesystem, and has hacks
to deal with tests like this.
These hacks are causing me some pain, so I'm experimenting with removing
them. (Can give more details internally).

I don't have a great plan for keeping this from regressing - obviously only
the stuff that llvm-lit enforces can govern what gets checked in upstream.
That said, there are other cases (like writing outside of %T) where
google's runner is stricter, and fixing these upstream seems to be mostly
working.

Cheers, Sam

On Mon, Jan 8, 2018 at 5:05 PM, David Blaikie  wrote:

> I'm sure it's something obvious I don't understand here, but maybe someone
> else doesn't either & could benefit from it:
>
> What exactly does this change do? In what important way is "cp X Y"
> different from "cat X > Y"?
>
> On Mon, Jan 8, 2018 at 7:06 AM Sam McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: sammccall
>> Date: Mon Jan  8 07:05:01 2018
>> New Revision: 321997
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=321997&view=rev
>> Log:
>> Avoid assumption that lit tests are writable. NFC
>>
>> Modified:
>> cfe/trunk/test/ARCMT/releases-driver.m
>> cfe/trunk/test/ARCMT/releases-driver.m.result
>> cfe/trunk/test/ARCMT/with-arc-mode-modify.m
>> cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result
>> cfe/trunk/test/PCH/verify_pch.m
>> cfe/trunk/test/VFS/real-path-found-first.m
>>
>> Modified: cfe/trunk/test/ARCMT/releases-driver.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/rel
>> eases-driver.m?rev=321997&r1=321996&r2=321997&view=diff
>> 
>> ==
>> --- cfe/trunk/test/ARCMT/releases-driver.m (original)
>> +++ cfe/trunk/test/ARCMT/releases-driver.m Mon Jan  8 07:05:01 2018
>> @@ -1,5 +1,5 @@
>>  // RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c
>> %s.result
>> -// RUN: cp %s %t
>> +// RUN: cat %s > %t
>>  // RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x
>> objective-c %t
>>  // RUN: diff %t %s.result
>>  // RUN: rm %t
>>
>> Modified: cfe/trunk/test/ARCMT/releases-driver.m.result
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/rel
>> eases-driver.m.result?rev=321997&r1=321996&r2=321997&view=diff
>> 
>> ==
>> --- cfe/trunk/test/ARCMT/releases-driver.m.result (original)
>> +++ cfe/trunk/test/ARCMT/releases-driver.m.result Mon Jan  8 07:05:01
>> 2018
>> @@ -1,5 +1,5 @@
>>  // RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c
>> %s.result
>> -// RUN: cp %s %t
>> +// RUN: cat %s > %t
>>  // RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x
>> objective-c %t
>>  // RUN: diff %t %s.result
>>  // RUN: rm %t
>>
>> Modified: cfe/trunk/test/ARCMT/with-arc-mode-modify.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/wit
>> h-arc-mode-modify.m?rev=321997&r1=321996&r2=321997&view=diff
>> 
>> ==
>> --- cfe/trunk/test/ARCMT/with-arc-mode-modify.m (original)
>> +++ cfe/trunk/test/ARCMT/with-arc-mode-modify.m Mon Jan  8 07:05:01 2018
>> @@ -1,5 +1,5 @@
>>  // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
>> -// RUN: cp %s %t
>> +// RUN: cat %s > %t
>>  // RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c
>> %t
>>  // RUN: diff %t %s.result
>>  // RUN: rm %t
>>
>> Modified: cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/wit
>> h-arc-mode-modify.m.result?rev=321997&r1=321996&r2=321997&view=diff
>> 
>> ==
>> --- cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result (original)
>> +++ cfe/trunk/test/ARCMT/with-arc-mode-modify.m.result Mon Jan  8
>> 07:05:01 2018
>> @@ -1,5 +1,5 @@
>>  // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
>> -// RUN: cp %s %t
>> +// RUN: cat %s > %t
>>  // RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c
>> %t
>>  // RUN: diff %t %s.result
>>  // RUN: rm %t
>>
>> Modified: cfe/trunk/test/PCH/verify_pch.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/verif
>> y_pch.m?rev=321997&r1=321996&r2=321997&view=diff
>> 
>> ==
>> --- cfe/trunk/test/PCH/verify_pch.m (original)
>> +++ cfe/trunk/test/PCH/verify_pch.m Mon Jan  8 07:05:01 2018
>> @@ -2,7 +2,7 @@
>>  // RUN: rm -rf %t
>>  // RUN: mkdir -p %t/usr/include
>>  // RUN: echo '// empty' > %t/us

[libcxx] r322011 - Document upcoming TS feature removal

2018-01-08 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan  8 09:43:46 2018
New Revision: 322011

URL: http://llvm.org/viewvc/llvm-project?rev=322011&view=rev
Log:
Document upcoming TS feature removal

Added:
libcxx/trunk/www/TS_deprecation.html

Added: libcxx/trunk/www/TS_deprecation.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/TS_deprecation.html?rev=322011&view=auto
==
--- libcxx/trunk/www/TS_deprecation.html (added)
+++ libcxx/trunk/www/TS_deprecation.html Mon Jan  8 09:43:46 2018
@@ -0,0 +1,138 @@
+http://www.w3.org/TR/html4/strict.dtd";>
+
+
+
+  
+  libc++ Technical Specification Status
+  
+  
+
+
+
+
+  
+https://llvm.org/";>LLVM Home
+  
+
+  
+libc++ Info
+About
+  
+
+  
+Quick Links
+https://lists.llvm.org/mailman/listinfo/cfe-dev";>cfe-dev
+https://lists.llvm.org/mailman/listinfo/cfe-commits";>cfe-commits
+https://bugs.llvm.org/";>Bug Reports
+https://llvm.org/svn/llvm-project/libcxx/trunk/";>Browse SVN
+https://llvm.org/viewvc/llvm-project/libcxx/trunk/";>Browse 
ViewVC
+  
+
+
+
+The "end game" of a Technical Specification (TS) is to have the features in 
there added to a future version of the C++ standard. When this happens, the TS 
can be retired. Sometimes, only part of at TS is added to the standard, and the 
rest of the features may be incorporated into the next version of the TS.
+
+Adoption leaves library implementors with two implementations of a feature, 
one in namespace std, and the other in namespace 
std::experimental. The first one will continue to evolve (via issues 
and papers), while the other will not. Gradually they will diverge. It's not 
good for users to have two (subtly) different implementations of the same 
functionality in the same library.
+
+As features are adopted into the main standard, we will implement them in 
namespace std, and then remove the versions in 
std::experimental. The removal will not happen immediately, because 
that would be unhelpful for users - giving them no chance to update their 
code.
+
+The rule of thumb that libc++ will follow is: one year. One 
year after we ship an implementation of a feature in std, we will 
remove it from std::experimental.
+
+A specific example: The first release of clang/libc++ that officially 
supported C++17 was 5.0. For the 7.0 release (one year after 5.0), we will 
remove the features that were adopted into C++17 from the TSes, and that 
were present in namespace std in the 5.0 release.
+
+Library Fundamentals TS https://wg21.link/N4480";>V1 and https://wg21.link/N4617";>V2
+
+Most (but not all) of the features of the LFTS were accepted into C++17.
+
+
+SectionFeatureshipped instdTo 
be removed fromstd::experimentalNotes
+2.1uses_allocator 
construction5.07.0
+3.1.2erased_typen/aNot
 part of C++17
+3.2.1tuple_size_v5.07.0
+3.2.2apply5.07.0
+3.3.1All of the '_v' traits in 
5.07.0
+3.3.2invocation_type and 
raw_invocation_typen/aNot
 part of C++17
+3.3.3Logical operator 
traits5.07.0
+3.3.3Detection 
Idiom5.0Only partially in 
C++17
+3.4.1All of the '_v' traits in 
5.07.0
+3.5.1All of the '_v' traits in 
5.07.0
+3.6.1All of the '_v' traits in 
5.07.0
+3.7propagate_constn/aNot
 part of C++17
+4.2Enhancements to functionNot 
yet
+4.3searchers7.09.0
+5optional5.07.0
+6any5.07.0
+7string_view5.07.0
+8.2.1shared_ptr enhancementsNot 
yetNever added
+8.2.2weak_ptr enhancementsNot 
yetNever added
+8.5memory_resourceNot 
yet
+8.6polymorphic_allocatorNot 
yet
+8.7resource_adaptorn/aNot
 part of C++17
+8.8Access to program-wide memory_resource 
objectsNot yet
+8.9Pool resource classesNot 
yet
+8.10monotonic_buffer_resourceNot 
yet
+8.11Alias templates using polymorphic memory 
resourcesNot yet
+8.12Non-owning 
pointersn/aNot part of 
C++17
+11.2promisen/aNot
 part of C++17
+11.3packaged_taskn/aNot
 part of C++17
+12.2search7.09.0
+12.3sample5.07.0
+12.4shuffleNot part of 
C++17
+13.1gcd and 
lcm5.07.0
+13.2Random number generationNot part 
of C++17
+14Reflection LibraryNot part of 
C++17
+
+
+https://wg21.link/N4100";>FileSystem TS
+The FileSystem TS was accepted (in toto) for C++17.
+The FileSystem TS implementation is still (as of v6.0) in namespace 
std::experimental.
+
+Parallelism TS https://wg21.link/N4507";>V1 and https://wg21.link/N4706";>V2
+Some (most) of the Parallelism TS was accepted for C++17.
+We have not yet shipped an implementation of the Parallelism TS.
+
+https://wg21.link/N4680";>Coroutines TS
+The Coroutines TS is not yet part of a shipping standard.
+We are shipping (as of v5.0) an implementation of the Coroutines TS in 
namespace std::experimental.
+
+https://wg21.link/N4656";>Networking TS
+The Networking TS is not yet part of a shipping standard.
+We have not yet shipped an implementation of the Networking TS.
+
+https://wg21.link/N4685";>Ranges TS
+The Ranges TS is not yet part of a shipping standard.
+We have not yet shipped an implementation of the

[PATCH] D41575: [index] Return when DC is null in handleReference

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

Sorry, I was hoping @akyrtzi would see this.
I don't know enough about the code to know whether DC==null is an indicator of 
some other problem, but if this is crashing today then let's not block on that.


Repository:
  rC Clang

https://reviews.llvm.org/D41575



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


[PATCH] D41575: [index] Return when DC is null in handleReference

2018-01-08 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added a comment.

Could you add a test case for this change ? See examples in `test/Index/Core`.
Also for the test case code: `template  class Actor = 
actor>`, is the `actor` reference in this code reported ?
See the test examples on how to print out and test how the source symbols are 
indexed.


Repository:
  rC Clang

https://reviews.llvm.org/D41575



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


[PATCH] D40819: Implement Attribute Target MultiVersioning (Improved edition!)

2018-01-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 7 inline comments as done.
erichkeane added a comment.

patch incoming!




Comment at: include/clang/AST/ASTContext.h:2643-2648
+for (auto *CurDecl :
+ FD->getDeclContext()->getRedeclContext()->lookup(FD->getDeclName())) {
+  FunctionDecl *CurFD = CurDecl->getAsFunction()->getCanonicalDecl();
+  if (CurFD && hasSameType(CurFD->getType(), FD->getType()))
+P(CurFD);
+}

rsmith wrote:
> This should deal with the case where `lookup` finds multiple declarations of 
> the same version (which can happen in particular when serializing to AST 
> files; we keep around a handle to the version from each AST file). Also, 
> consider moving this to the .cpp file (use `llvm::function_ref FunctionDecl*)>` to pass in the callback).
Ah, right, this part got dropped when I was moving it around...  

There is only 2 ways I could think of to do this properly, first is to actually 
check the 'target' strings, second is to check the address of the canonical 
decl.  Checking target strings seems expensive, but I don't know if the pointer 
values are sufficient?

I'll implement the 2nd for this patch, but if you could give me a hint as the 
proper way (if this isn't sufficient), I'd be grateful.



Comment at: lib/Sema/SemaDecl.cpp:9228-9229
+S.Diag(NewFD->getLocation(), diag::err_multiversion_no_other_attrs);
+if (CausesMV)
+  S.Diag(NewFD->getLocation(), diag::note_multiversioning_caused_here);
+return true;

rsmith wrote:
> It seems strange to have a "caused here" note pointing at the same location 
> that you just produced an error on. Is this note really adding value? 
> (Likewise on all later diagnostics that add this note at the same place as 
> the error.)
I think that makes sense.  I'll remove all of those diagnostics where the error 
and the 'caused by' are different lines.


https://reviews.llvm.org/D40819



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


[PATCH] D40819: Implement Attribute Target MultiVersioning (Improved edition!)

2018-01-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 128950.
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

All of @rsmith 's comments on the last patch.  1 "open" item on the duplicate 
discover in the resolver generation, but hopefully this otherwise acceptable.


https://reviews.llvm.org/D40819

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/X86Target.def
  include/clang/Sema/Overload.h
  lib/AST/ASTContext.cpp
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaOverload.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/attr-target-mv-func-ptrs.c
  test/CodeGen/attr-target-mv-va-args.c
  test/CodeGen/attr-target-mv.c
  test/CodeGenCXX/attr-target-mv-diff-ns.cpp
  test/CodeGenCXX/attr-target-mv-func-ptrs.cpp
  test/CodeGenCXX/attr-target-mv-member-funcs.cpp
  test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
  test/CodeGenCXX/attr-target-mv-overloads.cpp
  test/Sema/attr-target-mv-bad-target.c
  test/Sema/attr-target-mv.c
  test/SemaCXX/attr-target-mv.cpp

Index: test/SemaCXX/attr-target-mv.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-target-mv.cpp
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14
+void __attribute__((target("sse4.2"))) no_default(void);
+void __attribute__((target("arch=sandybridge")))  no_default(void);
+
+void use1(void){
+  // expected-error@+1 {{no matching function for call to 'no_default'}}
+  no_default();
+}
+constexpr int __attribute__((target("sse4.2"))) foo(void) { return 0; }
+constexpr int __attribute__((target("arch=sandybridge"))) foo(void);
+//expected-error@+1 {{multiversioned function declaration has a different constexpr specification}}
+int __attribute__((target("arch=ivybridge"))) foo(void) {return 1;}
+constexpr int __attribute__((target("default"))) foo(void) { return 2; }
+
+int __attribute__((target("sse4.2"))) foo2(void) { return 0; }
+//expected-error@+1 {{multiversioned function declaration has a different constexpr specification}}
+constexpr int __attribute__((target("arch=sandybridge"))) foo2(void);
+int __attribute__((target("arch=ivybridge"))) foo2(void) {return 1;}
+int __attribute__((target("default"))) foo2(void) { return 2; }
+
+static int __attribute__((target("sse4.2"))) bar(void) { return 0; }
+static int __attribute__((target("arch=sandybridge"))) bar(void);
+//expected-error@+1 {{multiversioned function declaration has a different storage class}}
+int __attribute__((target("arch=ivybridge"))) bar(void) {return 1;}
+static int __attribute__((target("default"))) bar(void) { return 2; }
+
+int __attribute__((target("sse4.2"))) bar2(void) { return 0; }
+//expected-error@+1 {{multiversioned function declaration has a different storage class}}
+static int __attribute__((target("arch=sandybridge"))) bar2(void);
+int __attribute__((target("arch=ivybridge"))) bar2(void) {return 1;}
+int __attribute__((target("default"))) bar2(void) { return 2; }
+
+
+inline int __attribute__((target("sse4.2"))) baz(void) { return 0; }
+inline int __attribute__((target("arch=sandybridge"))) baz(void);
+//expected-error@+1 {{multiversioned function declaration has a different inline specification}}
+int __attribute__((target("arch=ivybridge"))) baz(void) {return 1;}
+inline int __attribute__((target("default"))) baz(void) { return 2; }
+
+int __attribute__((target("sse4.2"))) baz2(void) { return 0; }
+//expected-error@+1 {{multiversioned function declaration has a different inline specification}}
+inline int __attribute__((target("arch=sandybridge"))) baz2(void);
+int __attribute__((target("arch=ivybridge"))) baz2(void) {return 1;}
+int __attribute__((target("default"))) baz2(void) { return 2; }
+
+float __attribute__((target("sse4.2"))) bock(void) { return 0; }
+//expected-error@+1 {{multiversioned function declaration has a different return type}}
+int __attribute__((target("arch=sandybridge"))) bock(void);
+//expected-error@+1 {{multiversioned function declaration has a different return type}}
+int __attribute__((target("arch=ivybridge"))) bock(void) {return 1;}
+//expected-error@+1 {{multiversioned function declaration has a different return type}}
+int __attribute__((target("default"))) bock(void) { return 2; }
+
+int __attribute__((target("sse4.2"))) bock2(void) { return 0; }
+//expected-error@+1 {{multiversioned function declaration has a different return type}}
+float __attribute__((target("arch=sandybridge"))) bock2(void);
+int __attribute__((target("arch=ivybridge"))) bock2(void) {return 1;}
+int __attribute__((target("default")

[PATCH] D41539: [CodeGen] Decorate aggregate accesses with TBAA tags

2018-01-08 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev added a comment.

OK, I'm reading your response so that this patch may significantly increase the 
number of cases where we propagate TBAA tags from memory-transfer intrinsic 
calls, which means potentially more cases where ignoring may_alias would lead 
to problems. If so, then I tend to agree. Will prepare another version. Thanks.


https://reviews.llvm.org/D41539



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


[PATCH] D41575: [index] Return when DC is null in handleReference

2018-01-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

@akyrtzi When I run `c-index-test core -print-source-symbols -- a.cc` on

  template 
  struct actor;
  
  template  class Actor = actor>
  struct terminal;

the issue disappears. It emerges only when `clang_indexTranslationUnit` is 
called with interactions of other things.


Repository:
  rC Clang

https://reviews.llvm.org/D41575



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


[PATCH] D41575: [index] Return when DC is null in handleReference

2018-01-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 128953.
MaskRay added a comment.

rebase


Repository:
  rC Clang

https://reviews.llvm.org/D41575

Files:
  tools/libclang/CXIndexDataConsumer.cpp


Index: tools/libclang/CXIndexDataConsumer.cpp
===
--- tools/libclang/CXIndexDataConsumer.cpp
+++ tools/libclang/CXIndexDataConsumer.cpp
@@ -890,7 +890,7 @@
   const DeclContext *DC,
   const Expr *E,
   CXIdxEntityRefKind Kind) {
-  if (!D)
+  if (!D || !DC)
 return false;
 
   CXCursor Cursor = E ? MakeCXCursor(E, cast(DC), CXTU)
@@ -907,7 +907,7 @@
   if (!CB.indexEntityReference)
 return false;
 
-  if (!D)
+  if (!D || !DC)
 return false;
   if (Loc.isInvalid())
 return false;


Index: tools/libclang/CXIndexDataConsumer.cpp
===
--- tools/libclang/CXIndexDataConsumer.cpp
+++ tools/libclang/CXIndexDataConsumer.cpp
@@ -890,7 +890,7 @@
   const DeclContext *DC,
   const Expr *E,
   CXIdxEntityRefKind Kind) {
-  if (!D)
+  if (!D || !DC)
 return false;
 
   CXCursor Cursor = E ? MakeCXCursor(E, cast(DC), CXTU)
@@ -907,7 +907,7 @@
   if (!CB.indexEntityReference)
 return false;
 
-  if (!D)
+  if (!D || !DC)
 return false;
   if (Loc.isInvalid())
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41655: [clang-tidy] New check bugprone-unused-return-value

2018-01-08 Thread Kalle Huttunen via Phabricator via cfe-commits
khuttun added inline comments.



Comment at: test/clang-tidy/bugprone-unused-return-value.cpp:163
+
+void noWarning() {
+  auto AsyncRetval1 = std::async(increment, 42);

aaron.ballman wrote:
> khuttun wrote:
> > aaron.ballman wrote:
> > > khuttun wrote:
> > > > aaron.ballman wrote:
> > > > > Sorry, I just realized that we're missing a test case for a common 
> > > > > situation -- where the result is used as part of another call 
> > > > > expression. Can you add a test to `noWarning()` to make sure this 
> > > > > does not warn:
> > > > > ```
> > > > > std::vector v;
> > > > > extern void f(bool);
> > > > > 
> > > > > f(v.empty()); // Should not warn
> > > > > ```
> > > > See line 199 in this file.
> > > Ah, my eyes missed that, thank you!
> > > 
> > > Hmm, I *think* this test should also be okay, but I want to be sure:
> > > ```
> > > std::vector v;
> > > bool b = ({v.empty()}); // Should not warn
> > > ({v.empty()}); // ???
> > > ```
> > > I kind of thing that, as an extension to the spirit of this check, any 
> > > GNU expression statement whose result is unused should probably be 
> > > diagnosed; what do you think?
> > > 
> > > You should add tests for the above so we document the expected behavior 
> > > here.
> > Getting a warning when just surrounding the call expression with 
> > parenthesis is tested in bugprone-unused-return-value-custom.cpp.
> > 
> > Would your example be parsed as creating an initializer_list? In that case 
> > it should not warn. I can add test cases for that.
> > 
> > What do you mean by "GNU expression"?
> > Getting a warning when just surrounding the call expression with 
> > parenthesis is tested in bugprone-unused-return-value-custom.cpp.
> 
> Yup, this is something entirely different, however.
> 
> > Would your example be parsed as creating an initializer_list? In that case 
> > it should not warn. I can add test cases for that.
> >
> > What do you mean by "GNU expression"?
> 
> Those examples are GNU expression statements, which is a GCC extension that 
> Clang also supports. See 
> https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html for more information.
> 
> Effectively, the last statement in the GNU expression statement is the 
> "return value" of the expression statement. We should make sure the warnings 
> are sensible with this construct.
This was a good catch. Code like this

```
auto Gnu = ({ fun(); });
```

is currently causing a warning.


https://reviews.llvm.org/D41655



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


[PATCH] D41575: [index] Return when DC is null in handleReference

2018-01-08 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL322017: [index] Return when DC is null in handleReference 
(authored by MaskRay, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D41575

Files:
  cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp


Index: cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
===
--- cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
+++ cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
@@ -890,7 +890,7 @@
   const DeclContext *DC,
   const Expr *E,
   CXIdxEntityRefKind Kind) {
-  if (!D)
+  if (!D || !DC)
 return false;
 
   CXCursor Cursor = E ? MakeCXCursor(E, cast(DC), CXTU)
@@ -907,7 +907,7 @@
   if (!CB.indexEntityReference)
 return false;
 
-  if (!D)
+  if (!D || !DC)
 return false;
   if (Loc.isInvalid())
 return false;


Index: cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
===
--- cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
+++ cfe/trunk/tools/libclang/CXIndexDataConsumer.cpp
@@ -890,7 +890,7 @@
   const DeclContext *DC,
   const Expr *E,
   CXIdxEntityRefKind Kind) {
-  if (!D)
+  if (!D || !DC)
 return false;
 
   CXCursor Cursor = E ? MakeCXCursor(E, cast(DC), CXTU)
@@ -907,7 +907,7 @@
   if (!CB.indexEntityReference)
 return false;
 
-  if (!D)
+  if (!D || !DC)
 return false;
   if (Loc.isInvalid())
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r322018 - [OPENMP] Current status of OpenMP support.

2018-01-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jan  8 11:02:51 2018
New Revision: 322018

URL: http://llvm.org/viewvc/llvm-project?rev=322018&view=rev
Log:
[OPENMP] Current status of OpenMP support.

Summary: Some info about supported features of OpenMP 4.5-5.0.

Reviewers: hfinkel, rsmith

Subscribers: kkwli0, Hahnfeld, cfe-commits

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

Added:
cfe/trunk/docs/OpenMPSupport.rst
Modified:
cfe/trunk/docs/index.rst

Added: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=322018&view=auto
==
--- cfe/trunk/docs/OpenMPSupport.rst (added)
+++ cfe/trunk/docs/OpenMPSupport.rst Mon Jan  8 11:02:51 2018
@@ -0,0 +1,68 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports 
offloading to X86_64, AArch64 and PPC64[LE] devices.
+Support for Cuda devices is not ready yet.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Complete`.
+
+* #pragma omp target update: :good:`Complete`.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :good:`Complete`.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :partial:`Partial`.  No support for the 
`depend` clauses.
+
+* #pragma omp target parallel for [simd]: :partial:`Partial`.  No support for 
the `depend` clauses.
+
+* #pragma omp target simd: :partial:`Partial`.  No support for the `depend` 
clauses.
+
+* #pragma omp target teams: :partial:`Partial`.  No support for the `depend` 
clauses.
+
+* #pragma omp teams distribute [simd]: :good:`Complete`.
+
+* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No support 
for the and `depend` clauses.
+
+* #pragma omp teams distribute parallel for [simd]: :good:`Complete`.
+
+* #pragma omp target teams distribute parallel for [simd]: :partial:`Partial`. 
 No full codegen support.
+
+Clang does not support any constructs/updates from upcoming OpenMP 5.0 except 
for `reduction`-based clauses in the `task` and `target`-based directives.
+

Modified: cfe/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/index.rst?rev=322018&r1=322017&r2=322018&view=diff
==
--- cfe/trunk/docs/index.rst (original)
+++ cfe/trunk/docs/index.rst Mon Jan  8 11:02:51 2018
@@ -39,6 +39,7 @@ Using Clang as a Compiler
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ


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


[PATCH] D39457: [OPENMP] Current status of OpenMP support.

2018-01-08 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC322018: [OPENMP] Current status of OpenMP support. (authored 
by ABataev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D39457?vs=128238&id=128957#toc

Repository:
  rC Clang

https://reviews.llvm.org/D39457

Files:
  docs/OpenMPSupport.rst
  docs/index.rst


Index: docs/OpenMPSupport.rst
===
--- docs/OpenMPSupport.rst
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,68 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports 
offloading to X86_64, AArch64 and PPC64[LE] devices.
+Support for Cuda devices is not ready yet.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Complete`.
+
+* #pragma omp target update: :good:`Complete`.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :good:`Complete`.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :partial:`Partial`.  No support for the 
`depend` clauses.
+
+* #pragma omp target parallel for [simd]: :partial:`Partial`.  No support for 
the `depend` clauses.
+
+* #pragma omp target simd: :partial:`Partial`.  No support for the `depend` 
clauses.
+
+* #pragma omp target teams: :partial:`Partial`.  No support for the `depend` 
clauses.
+
+* #pragma omp teams distribute [simd]: :good:`Complete`.
+
+* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No support 
for the and `depend` clauses.
+
+* #pragma omp teams distribute parallel for [simd]: :good:`Complete`.
+
+* #pragma omp target teams distribute parallel for [simd]: :partial:`Partial`. 
 No full codegen support.
+
+Clang does not support any constructs/updates from upcoming OpenMP 5.0 except 
for `reduction`-based clauses in the `task` and `target`-based directives.
+
Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ


Index: docs/OpenMPSupport.rst
===
--- docs/OpenMPSupport.rst
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,68 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports offloading to X86_64, AArch64 and PPC64[LE] devices.
+Support for Cuda devices is not ready yet.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Complete`.
+
+* #pragma omp target update: :good:`Complete`.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :good:`Complete`.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :partial:`Partial`.  No support for the `depend` clauses.
+
+* #pragma omp target parallel for [simd]: :partial:`Partial`.  No support for the `depend` clauses.
+
+* #pragma omp target simd: :partial:`Partial`.  No support for the `depend` clauses.
+
+*

Re: r322018 - [OPENMP] Current status of OpenMP support.

2018-01-08 Thread Jonas Hahnfeld via cfe-commits
Can we backport this page to release_60? I think the documented support 
is also valid for 6.0 or did I miss recent commits that added support 
for new directives / clauses?


Am 2018-01-08 20:02, schrieb Alexey Bataev via cfe-commits:

Author: abataev
Date: Mon Jan  8 11:02:51 2018
New Revision: 322018

URL: http://llvm.org/viewvc/llvm-project?rev=322018&view=rev
Log:
[OPENMP] Current status of OpenMP support.

Summary: Some info about supported features of OpenMP 4.5-5.0.

Reviewers: hfinkel, rsmith

Subscribers: kkwli0, Hahnfeld, cfe-commits

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

Added:
cfe/trunk/docs/OpenMPSupport.rst
Modified:
cfe/trunk/docs/index.rst

Added: cfe/trunk/docs/OpenMPSupport.rst
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=322018&view=auto
==
--- cfe/trunk/docs/OpenMPSupport.rst (added)
+++ cfe/trunk/docs/OpenMPSupport.rst Mon Jan  8 11:02:51 2018
@@ -0,0 +1,68 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang
supports offloading to X86_64, AArch64 and PPC64[LE] devices.
+Support for Cuda devices is not ready yet.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support 
parsing/semantic
+  analysis + generation of special attributes for X86 target, but 
still

+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Complete`.
+
+* #pragma omp target update: :good:`Complete`.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `depend` 
clauses.

+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen 
support.

+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :good:`Complete`.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :partial:`Partial`.  No support for
the `depend` clauses.
+
+* #pragma omp target parallel for [simd]: :partial:`Partial`.  No
support for the `depend` clauses.
+
+* #pragma omp target simd: :partial:`Partial`.  No support for the
`depend` clauses.
+
+* #pragma omp target teams: :partial:`Partial`.  No support for the
`depend` clauses.
+
+* #pragma omp teams distribute [simd]: :good:`Complete`.
+
+* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No
support for the and `depend` clauses.
+
+* #pragma omp teams distribute parallel for [simd]: :good:`Complete`.
+
+* #pragma omp target teams distribute parallel for [simd]:
:partial:`Partial`.  No full codegen support.
+
+Clang does not support any constructs/updates from upcoming OpenMP
5.0 except for `reduction`-based clauses in the `task` and
`target`-based directives.
+

Modified: cfe/trunk/docs/index.rst
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/index.rst?rev=322018&r1=322017&r2=322018&view=diff
==
--- cfe/trunk/docs/index.rst (original)
+++ cfe/trunk/docs/index.rst Mon Jan  8 11:02:51 2018
@@ -39,6 +39,7 @@ Using Clang as a Compiler
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ


___
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


[libcxx] r322019 - Add the C++17 extensions to std::search. Include the default searcher, but not the Boyer-Moore or Boyer-Moore-Horspool searcher (yet). BUT put the BM and BMH tests in place, marked

2018-01-08 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan  8 11:18:00 2018
New Revision: 322019

URL: http://llvm.org/viewvc/llvm-project?rev=322019&view=rev
Log:
Add the C++17 extensions to std::search. Include the default searcher, but not 
the Boyer-Moore or Boyer-Moore-Horspool searcher (yet). BUT put the BM and BMH 
tests in place, marked to XFAIL. The other searchers will follow soon

Added:
libcxx/trunk/test/std/utilities/function.objects/func.search/
libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/default.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/hash.pred.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/pred.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bmh/

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bmh/default.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bmh/hash.pred.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bmh/pred.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.default/

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.default/default.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.default/default.pred.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/func.search/nothing_to_do.pass.cpp
Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/functional
libcxx/trunk/test/std/algorithms/alg.nonmodifying/alg.search/search.pass.cpp

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=322019&r1=322018&r2=322019&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Jan  8 11:18:00 2018
@@ -641,6 +641,7 @@ template 
 #include  // needed to provide swap_ranges.
 #include 
+#include 
 #include 
 #include 
 
@@ -1545,88 +1546,7 @@ is_permutation(_ForwardIterator1 __first
 #endif
 
 // search
-
-template 
-pair<_ForwardIterator1, _ForwardIterator1>
-__search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2, 
_BinaryPredicate __pred,
- forward_iterator_tag, forward_iterator_tag)
-{
-if (__first2 == __last2)
-return make_pair(__first1, __first1);  // Everything matches an empty 
sequence
-while (true)
-{
-// Find first element in sequence 1 that matchs *__first2, with a 
mininum of loop checks
-while (true)
-{
-if (__first1 == __last1)  // return __last1 if no element matches 
*__first2
-return make_pair(__last1, __last1);
-if (__pred(*__first1, *__first2))
-break;
-++__first1;
-}
-// *__first1 matches *__first2, now match elements after here
-_ForwardIterator1 __m1 = __first1;
-_ForwardIterator2 __m2 = __first2;
-while (true)
-{
-if (++__m2 == __last2)  // If pattern exhausted, __first1 is the 
answer (works for 1 element pattern)
-return make_pair(__first1, __m1);
-if (++__m1 == __last1)  // Otherwise if source exhaused, pattern 
not found
-return make_pair(__last1, __last1);
-if (!__pred(*__m1, *__m2))  // if there is a mismatch, restart 
with a new __first1
-{
-++__first1;
-break;
-}  // else there is a match, check next elements
-}
-}
-}
-
-template 
-_LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_RandomAccessIterator1, _RandomAccessIterator1>
-__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
- _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, 
_BinaryPredicate __pred,
-   random_access_iterator_tag, random_access_iterator_tag)
-{
-typedef typename iterator_traits<_RandomAccessIterator1>::difference_type 
_D1;
-typedef typename iterator_traits<_RandomAccessIterator2>::difference_type 
_D2;
-// Take advantage of knowing source and pattern lengths.  Stop short when 
source is smaller than pattern
-const _D2 __len2 = __last2 - __first2;
-if (__len2 == 0)
-return make_pair(__first1, __first1);
-const _D1 __len1 = __last1 - __first1;
-if (__len1 < __len2)
-return make_pair(__last1, __last1);
-const _RandomAccessIterator1 __s = __last1 - (__len2 - 1);  // Start of 
pattern match can't go beyond here
-
-

[PATCH] D40819: Implement Attribute Target MultiVersioning (Improved edition!)

2018-01-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

Looks good to me with just a few more tweaks (assuming these comments don't 
uncover any new issues). Thank you!




Comment at: lib/AST/ASTContext.cpp:9490
+  assert(FD->isMultiVersion() && "Only valid for multiversioned functions");
+  llvm::SmallVector SeenDecls;
+  FD = FD->getCanonicalDecl();

Consider using `SmallDenseSet` here. (In the modules case, we could potentially 
have hundreds or even thousands of lookup results, and the better asymptotics 
in the bad cases seems on balance worth the higher constant factor.)

Also, you'll need to add declarations to this set :)

A testcase for this would look something like:

```
#pragma clang module build A
module A {}
#pragma clang module contents
#pragma clang module begin A
__attribute__((target("default"))) void f();
__attribute__((target("foo"))) void f();
#pragma clang module end
#pragma clang module endbuild

#pragma clang module build B
module B {}
#pragma clang module contents
#pragma clang module begin B
__attribute__((target("default"))) void f();
__attribute__((target("foo"))) void f();
#pragma clang module end
#pragma clang module endbuild

#pragma clang module import A
#pragma clang module import B
void g() { f(); }
```

... with a check that the resolver ifunc only includes each case once.



Comment at: lib/Serialization/ASTReaderDecl.cpp:2832
+
+  if (!TAY || TAX->getFeaturesStr() != TAY->getFeaturesStr())
+return false;

The `!TAY` check here is now redundant and can be moved into the assertion.



Comment at: test/CodeGen/attr-target-mv.c:20-26
+inline __attribute__((target("default"))) void foo_decls(void);
+inline __attribute__((target("sse4.2"))) void foo_decls(void);
+void bar3() {
+  foo_decls();
+}
+__attribute__((target("default"))) void foo_decls(void) {}
+__attribute__((target("sse4.2"))) void foo_decls(void) {}

This will either need to be a C++ test or will need `inline` on the definitions 
to have the intended effect of creating a discardable function definition.



Comment at: test/CodeGenCXX/attr-target-mv-member-funcs.cpp:3-8
+struct S {
+  int __attribute__((target("sse4.2"))) foo(int) { return 0; }
+  int __attribute__((target("arch=sandybridge"))) foo(int);
+  int __attribute__((target("arch=ivybridge"))) foo(int) { return 1; }
+  int __attribute__((target("default"))) foo(int) { return 2; }
+};

erichkeane wrote:
> rsmith wrote:
> > OK, multiversioned member functions! Let's look at some nasty corner cases!
> > 
> > Do you allow multiversioning of special member functions (copy constructor, 
> > destructor, ...)? Some tests for that would be interesting. Note in 
> > particular that `CXXRecordDecl::getDestructor` assumes that there is only 
> > one destructor for a class, and I expect we make that assumption in a bunch 
> > of other places too. Might be best to disallow multiversioning destructors 
> > for now.
> > 
> > Do you allow a multiversioned function to have one defaulted version and 
> > one non-defaulted version? What does that mean for the properties of the 
> > class that depend on whether special member functions are trivial? Might be 
> > a good idea to disallow defaulting a multiversioned function. Oh, and we 
> > should probably not permit versions of a multiversioned function to be 
> > deleted either.
> > 
> > If you allow multiversioning of constructors, I'd like to see a test for 
> > multiversioning of inherited constructors. Likewise, if you allow 
> > multiversioning of conversion functions, I'd like to see a test for that. 
> > (I actually think there's a very good chance both of those will just work 
> > fine.)
> > 
> > You don't allow multiversioning of function templates right now, but what 
> > about multiversioning of member functions of a class template? Does that 
> > work? If so, does class template argument deduction using multiversioned 
> > constructors work?
> > 
> > Does befriending multiversioned functions work? Is the target attribute 
> > taken into account?
> I gave CTORs a try, and found that there are a few subtle issues that need to 
> be dealt with in code-gen.  For the moment (and since GCC simply terminates 
> if you try to use them), I'd like to disallow them.  
> 
> Definitely going to disallow dtors/default/deleted functions.  
Can you also test that out-of-line definitions of multiversioned member 
functions are properly matched with the in-class declaration, and that you 
can't add new versions not present in the class definition that way? (Again, 
I'm not expecting any problems here, but it seems like something we should have 
coverage for.)


https://reviews.llvm.org/D40819



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


[PATCH] D41039: Add support for attribute "trivial_abi"

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

Address review comments.


https://reviews.llvm.org/D41039

Files:
  include/clang/AST/Decl.h
  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/Sema/Sema.h
  lib/AST/DeclCXX.cpp
  lib/AST/Type.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGenCXX/trivial_abi.cpp
  test/CodeGenObjCXX/trivial_abi.mm
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/SemaObjCXX/attr-trivial-abi.mm

Index: test/SemaObjCXX/attr-trivial-abi.mm
===
--- /dev/null
+++ test/SemaObjCXX/attr-trivial-abi.mm
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -std=c++11 -fobjc-runtime-has-weak -fobjc-weak -fobjc-arc -fsyntax-only -verify %s
+
+void __attribute__((trivial_abi)) foo(); // expected-warning {{'trivial_abi' attribute only applies to classes}}
+
+struct [[clang::trivial_abi]] S0 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S1 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S2 { // expected-warning {{'trivial_abi' cannot be applied to 'S2'}}
+  __weak id a;
+};
+
+struct __attribute__((trivial_abi)) S3 { // expected-warning {{'trivial_abi' cannot be applied to 'S3'}}
+  virtual void m();
+};
+
+struct S4 {
+  int a;
+};
+
+struct __attribute__((trivial_abi)) S5 : public virtual S4 { // expected-warning {{'trivial_abi' cannot be applied to 'S5'}}
+};
+
+struct __attribute__((trivial_abi)) S9 : public S4 {
+};
+
+struct S6 {
+  __weak id a;
+};
+
+struct __attribute__((trivial_abi)) S12 { // expected-warning {{'trivial_abi' cannot be applied to 'S12'}}
+  __weak id a;
+};
+
+struct __attribute__((trivial_abi)) S13 { // expected-warning {{'trivial_abi' cannot be applied to 'S13'}}
+  __weak id a[2];
+};
+
+struct __attribute__((trivial_abi)) S7 { // expected-warning {{'trivial_abi' cannot be applied to 'S7'}}
+  S6 a;
+};
+
+struct __attribute__((trivial_abi)) S11 { // expected-warning {{'trivial_abi' cannot be applied to 'S11'}}
+  S6 a[2];
+};
+
+struct __attribute__((trivial_abi(1))) S8 { // expected-error {{'trivial_abi' attribute takes no arguments}}
+  int a;
+};
+
+template
+struct __attribute__((trivial_abi)) S10 {
+  T p;
+};
+
+S10 p1;
+
+// Do not warn when 'trivial_abi' is used to annotate a template class.
+S10<__weak id> p2;
Index: test/Misc/pragma-attribute-supported-attributes-list.test
===
--- test/Misc/pragma-attribute-supported-attributes-list.test
+++ test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 66 attributes:
+// CHECK: #pragma clang attribute supports 67 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -66,6 +66,7 @@
 // CHECK-NEXT: TLSModel (SubjectMatchRule_variable_is_thread_local)
 // CHECK-NEXT: Target (SubjectMatchRule_function)
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
+// CHECK-NEXT: TrivialABI (SubjectMatchRule_record)
 // CHECK-NEXT: WarnUnusedResult (SubjectMatchRule_objc_method, SubjectMatchRule_enum, SubjectMatchRule_record, SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: XRayInstrument (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: XRayLogArgs (SubjectMatchRule_function, SubjectMatchRule_objc_method)
Index: test/CodeGenObjCXX/trivial_abi.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/trivial_abi.mm
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fobjc-arc  -fobjc-weak -fobjc-runtime-has-weak -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: %[[STRUCT_STRONGWEAK:.*]] = type { i8*, i8* }
+// CHECK: %[[STRUCT_STRONG:.*]] = type { i8* }
+
+struct __attribute__((trivial_abi)) StrongWeak {
+  id fstrong;
+  __weak id fweak;
+};
+
+struct __attribute__((trivial_abi)) Strong {
+  id fstrong;
+};
+
+// CHECK: define void @_Z19testParamStrongWeak10StrongWeak(%[[STRUCT_STRONGWEAK]]* %{{.*}})
+// CHECK-NOT: call
+// CHECK: ret void
+
+void testParamStrongWeak(StrongWeak a) {
+}
+
+// CHECK: define void @_Z18testCallStrongWeakP10StrongWeak(%[[STRUCT_STRONGWEAK]]* %[[A:.*]])
+// CHECK: %[[A_ADDR:.*]] = alloca %[[STRUCT_STRONGWEAK]]*, align 8
+// CHECK: %[[AGG_TMP:.*]] = alloca %[[STRUCT_STRONGWEAK]], alig

[PATCH] D41829: [cmake] Add cache file to bootstrap 2-stage linux cross compile on Darwin.

2018-01-08 Thread Don Hinton via Phabricator via cfe-commits
hintonda created this revision.
hintonda added reviewers: beanz, compnerd, phosek, smeenai.
Herald added a subscriber: mgorny.

Add cache file to bootstrap 2-stage linux cross compile on
Darwin.


Repository:
  rC Clang

https://reviews.llvm.org/D41829

Files:
  cmake/caches/Linux.cmake


Index: cmake/caches/Linux.cmake
===
--- /dev/null
+++ cmake/caches/Linux.cmake
@@ -0,0 +1,59 @@
+# This file is primarily for cross compiling clang+llvm, et al, for
+# Linux on Darwin, and can be invoked like this:
+#
+#  cmake -GNinja -DBOOTSTRAP_CMAKE_SYSROOT= [OPTIONS] \
+#-DBOOTSTRAP_CMAKE_TOOLCHAIN_FILE=/cmake/platforms/Linux.cmake \
+#-C /cmake/caches/Linux.cmake ../llvm
+
+if(NOT DEFINED BOOTSTRAP_CMAKE_SYSROOT)
+  message(SEND_ERROR "Missing required argument 
-DBOOTSTRAP_CMAKE_SYSROOT=.")
+endif()
+if(NOT DEFINED BOOTSTRAP_CMAKE_TOOLCHAIN_FILE)
+  message(SEND_ERROR "Missing required argument 
-DBOOTSTRAP_CMAKE_TOOLCHAIN_FILE=.")
+endif()
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+
+if(NOT DEFINED BOOTSTRAP_LLVM_DEFAULT_TARGET_TRIPLE)
+  set(BOOTSTRAP_LLVM_DEFAULT_TARGET_TRIPLE "x86_64-unknown-linux-gnu")
+endif()
+
+# Since LLVM_ENABLE_PROJECTS gets passed automatically to the next
+# stage, use another variable to pass the desired projects to stage2.
+if(DEFINED BOOTSTRAP_LLVM_ENABLE_PROJECTS)
+  set(BOOTSTRAP_LLVM_ENABLE_PROJECTS_OVERRIDE 
${BOOTSTRAP_LLVM_ENABLE_PROJECTS} CACHE STRING "" FORCE)
+  unset(BOOTSTRAP_LLVM_ENABLE_PROJECTS CACHE)
+else()
+  set(BOOTSTRAP_LLVM_ENABLE_PROJECTS_OVERRIDE 
"clang;libcxx;libcxxabi;libunwind" CACHE STRING "" FORCE)
+endif()
+
+if(CMAKE_HOST_APPLE)
+  # Make sure at least clang and lld are included.
+  list(APPEND LLVM_ENABLE_PROJECTS clang lld)
+  set(LLVM_ENABLE_PROJECTS ${LLVM_ENABLE_PROJECTS} CACHE STRING "")
+
+  # Passing -fuse-ld=lld is hard for cmake to handle correctly, so
+  # make lld the default linker.
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "" FORCE)
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+
+  set(BOOTSTRAP_CMAKE_AR ${CMAKE_BINARY_DIR}/bin/llvm-ar CACHE STRING "")
+  set(BOOTSTRAP_CMAKE_RANLIB ${CMAKE_BINARY_DIR}/bin/llvm-ranlib CACHE STRING 
"")
+  set(BOOTSTRAP_CLANG_TABLEGEN ${CMAKE_BINARY_DIR}/bin/clang-tblgen CACHE 
STRING "")
+  set(BOOTSTRAP_LLVM_TABLEGEN ${CMAKE_BINARY_DIR}/bin/llvm-tblgen CACHE STRING 
"")
+endif()
+
+# Since we just want to build a bootstrap compiler, turn off as much
+# as possible.
+set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_RUNTIMES OFF CACHE BOOL "")
+set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
+set(LLVM_INCLUDE_UTILS OFF CACHE BOOL "")
+set(CLANG_BUILD_TOOLS OFF CACHE BOOL "")
+set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
+set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")


Index: cmake/caches/Linux.cmake
===
--- /dev/null
+++ cmake/caches/Linux.cmake
@@ -0,0 +1,59 @@
+# This file is primarily for cross compiling clang+llvm, et al, for
+# Linux on Darwin, and can be invoked like this:
+#
+#  cmake -GNinja -DBOOTSTRAP_CMAKE_SYSROOT= [OPTIONS] \
+#-DBOOTSTRAP_CMAKE_TOOLCHAIN_FILE=/cmake/platforms/Linux.cmake \
+#-C /cmake/caches/Linux.cmake ../llvm
+
+if(NOT DEFINED BOOTSTRAP_CMAKE_SYSROOT)
+  message(SEND_ERROR "Missing required argument -DBOOTSTRAP_CMAKE_SYSROOT=.")
+endif()
+if(NOT DEFINED BOOTSTRAP_CMAKE_TOOLCHAIN_FILE)
+  message(SEND_ERROR "Missing required argument -DBOOTSTRAP_CMAKE_TOOLCHAIN_FILE=.")
+endif()
+
+set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+
+set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
+
+if(NOT DEFINED BOOTSTRAP_LLVM_DEFAULT_TARGET_TRIPLE)
+  set(BOOTSTRAP_LLVM_DEFAULT_TARGET_TRIPLE "x86_64-unknown-linux-gnu")
+endif()
+
+# Since LLVM_ENABLE_PROJECTS gets passed automatically to the next
+# stage, use another variable to pass the desired projects to stage2.
+if(DEFINED BOOTSTRAP_LLVM_ENABLE_PROJECTS)
+  set(BOOTSTRAP_LLVM_ENABLE_PROJECTS_OVERRIDE ${BOOTSTRAP_LLVM_ENABLE_PROJECTS} CACHE STRING "" FORCE)
+  unset(BOOTSTRAP_LLVM_ENABLE_PROJECTS CACHE)
+else()
+  set(BOOTSTRAP_LLVM_ENABLE_PROJECTS_OVERRIDE "clang;libcxx;libcxxabi;libunwind" CACHE STRING "" FORCE)
+endif()
+
+if(CMAKE_HOST_APPLE)
+  # Make sure at least clang and lld are included.
+  list(APPEND LLVM_ENABLE_PROJECTS clang lld)
+  set(LLVM_ENABLE_PROJECTS ${LLVM_ENABLE_PROJECTS} CACHE STRING "")
+
+  # Passing -fuse-ld=lld is hard for cmake to handle correctly, so
+  # make lld the default linker.
+  set(CLANG_DEFAULT_LINKER lld CACHE STRING "" FORCE)
+  set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
+
+  set(BOOTSTRAP_CMAKE_AR ${CMAKE_BINARY_DIR}/bin/llvm-ar CACHE STRING "")
+  s

[libcxx] r322021 - Change add_ten to add_one to avoid triggering ubsan integer overflow.

2018-01-08 Thread Billy Robert O'Neal III via cfe-commits
Author: bion
Date: Mon Jan  8 11:45:16 2018
New Revision: 322021

URL: http://llvm.org/viewvc/llvm-project?rev=322021&view=rev
Log:
Change add_ten to add_one to avoid triggering ubsan integer overflow.

Modified:

libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp

libcxx/trunk/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp

Modified: 
libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp?rev=322021&r1=322020&r2=322021&view=diff
==
--- 
libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
 Mon Jan  8 11:45:16 2018
@@ -28,10 +28,10 @@
 
 #include "test_iterators.h"
 
-struct add_ten {
+struct add_one {
 template 
 constexpr auto operator()(T x) const noexcept {
-return static_cast(x + 10);
+return static_cast(x + 1);
 }
 };
 
@@ -56,15 +56,15 @@ template 
 void
 test()
 {
-  int ia[] = { 1,  3,  5,   7,   9};
-const int pResI0[] = { 0, 11, 24,  39,  56};// with add_ten
-const int mResI0[] = { 0,  0,  0,   0,   0};
-const int pResN0[] = { 0, -1, -4,  -9, -16};// with negate
-const int mResN0[] = { 0,  0,  0,   0,   0};
-const int pResI2[] = { 2, 13, 26,  41,  58};// with add_ten
-const int mResI2[] = { 2, 22, 286, 4290, 72930};
-const int pResN2[] = { 2,  1,  -2,  -7, -14};   // with negate
-const int mResN2[] = { 2, -2,   6, -30, 210};
+  int ia[] = { 1,  3,  5,7,   9 };
+const int pResI0[] = { 0,  2,  6,   12,  20 };// with add_one
+const int mResI0[] = { 0,  0,  0,0,   0 };
+const int pResN0[] = { 0, -1, -4,   -9, -16 };// with negate
+const int mResN0[] = { 0,  0,  0,0,   0 };
+const int pResI2[] = { 2,  4,  8,   14,  22 };// with add_one
+const int mResI2[] = { 2,  4, 16,   96, 768 };
+const int pResN2[] = { 2,  1,  -2,  -7, -14 };// with negate
+const int mResN2[] = { 2, -2,   6, -30, 210 };
 const unsigned sa = sizeof(ia) / sizeof(ia[0]);
 static_assert(sa == sizeof(pResI0) / sizeof(pResI0[0]));   // just to 
be sure
 static_assert(sa == sizeof(mResI0) / sizeof(mResI0[0]));   // just to 
be sure
@@ -76,12 +76,12 @@ test()
 static_assert(sa == sizeof(mResN2) / sizeof(mResN2[0]));   // just to 
be sure
 
 for (unsigned int i = 0; i < sa; ++i ) {
-test(Iter(ia), Iter(ia + i), std::plus<>(),   add_ten{},   0, 
pResI0, pResI0 + i);
-test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_ten{},   0, 
mResI0, mResI0 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   add_one{},   0, 
pResI0, pResI0 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_one{},   0, 
mResI0, mResI0 + i);
 test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 0, 
pResN0, pResN0 + i);
 test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 0, 
mResN0, mResN0 + i);
-test(Iter(ia), Iter(ia + i), std::plus<>(),   add_ten{},   2, 
pResI2, pResI2 + i);
-test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_ten{},   2, 
mResI2, mResI2 + i);
+test(Iter(ia), Iter(ia + i), std::plus<>(),   add_one{},   2, 
pResI2, pResI2 + i);
+test(Iter(ia), Iter(ia + i), std::multiplies<>(), add_one{},   2, 
mResI2, mResI2 + i);
 test(Iter(ia), Iter(ia + i), std::plus<>(),   std::negate<>(), 2, 
pResN2, pResN2 + i);
 test(Iter(ia), Iter(ia + i), std::multiplies<>(), std::negate<>(), 2, 
mResN2, mResN2 + i);
 }
@@ -95,30 +95,30 @@ void basic_tests()
 {
 std::vector v(10);
 std::fill(v.begin(), v.end(), 3);
-std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 50, 
std::plus<>(), add_ten{});
+std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 50, 
std::plus<>(), add_one{});
 for (size_t i = 0; i < v.size(); ++i)
-assert(v[i] == 50 + (int) i * 13);
+assert(v[i] == 50 + (int) i * 4);
 }
 
 {
 std::vector v(10);
 std::iota(v.begin(), v.end(), 0);
-std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 30, 
std::plus<>(), add_ten{});
+std::transform_exclusive_scan(v.begin(), v.end(), v.begin(), 30, 
std::plus<>(), add_one{});
 for (size_t i = 0; i < v.s

[PATCH] D41830: [libc++] Fix PR#35780 - make std::experimental::filesystem::remove return false if the file doesn't exist

2018-01-08 Thread Ekaterina Vaartis via Phabricator via cfe-commits
TyanNN created this revision.
TyanNN added a reviewer: EricWF.
Herald added a subscriber: cfe-commits.

Previously it thrown an error if the file didn't exist.

PR#35780


Repository:
  rCXX libc++

https://reviews.llvm.org/D41830

Files:
  src/experimental/filesystem/operations.cpp
  
test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp


Index: 
test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp
===
--- 
test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp
+++ 
test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp
@@ -0,0 +1,42 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class path
+
+#define _LIBCPP_DEBUG 0
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)
+int AssertCount = 0;
+
+#include 
+#include 
+#include 
+
+namespace fs = std::experimental::filesystem;
+
+int main()
+{
+using namespace fs;
+
+path nFile("nonexistant.file");
+assert(remove(nFile) == false);
+
+path tempFilePath = temp_directory_path();
+tempFilePath += path("existingFile");
+
+std::ofstream theTempFile(tempFilePath);
+theTempFile.close();
+
+assert(remove(tempFilePath) == true);
+
+return 0;
+}
Index: src/experimental/filesystem/operations.cpp
===
--- src/experimental/filesystem/operations.cpp
+++ src/experimental/filesystem/operations.cpp
@@ -661,8 +661,9 @@
 
 bool __remove(const path& p, std::error_code *ec) {
 if (ec) ec->clear();
+
 if (::remove(p.c_str()) == -1) {
-set_or_throw(ec, "remove", p);
+if (errno != ENOENT) set_or_throw(ec, "remove", p);
 return false;
 }
 return true;


Index: test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp
===
--- test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp
+++ test/libcxx/experimental/filesystem/class.path/path.remove/remove_should_not_throw.pass.cpp
@@ -0,0 +1,42 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class path
+
+#define _LIBCPP_DEBUG 0
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (void)::AssertCount++)
+int AssertCount = 0;
+
+#include 
+#include 
+#include 
+
+namespace fs = std::experimental::filesystem;
+
+int main()
+{
+using namespace fs;
+
+path nFile("nonexistant.file");
+assert(remove(nFile) == false);
+
+path tempFilePath = temp_directory_path();
+tempFilePath += path("existingFile");
+
+std::ofstream theTempFile(tempFilePath);
+theTempFile.close();
+
+assert(remove(tempFilePath) == true);
+
+return 0;
+}
Index: src/experimental/filesystem/operations.cpp
===
--- src/experimental/filesystem/operations.cpp
+++ src/experimental/filesystem/operations.cpp
@@ -661,8 +661,9 @@
 
 bool __remove(const path& p, std::error_code *ec) {
 if (ec) ec->clear();
+
 if (::remove(p.c_str()) == -1) {
-set_or_throw(ec, "remove", p);
+if (errno != ENOENT) set_or_throw(ec, "remove", p);
 return false;
 }
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33563: Track whether a unary operation can overflow

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



Comment at: test/Misc/ast-dump-stmt.c:66
+  // CHECK:ImplicitCastExpr
+  // CHECK:  DeclRefExpr{{.*}}'T2' 'int'
+}

aaron.ballman wrote:
> efriedma wrote:
> > What does it mean for bitwise complement to "overflow"?
> When the sign bit flips on a signed value, e.g., `~0`.
Bitwise complement always flips the sign bit; calling that an "overflow" 
doesn't seem useful.


https://reviews.llvm.org/D33563



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


r322022 - [OPENMP] Fix debug info for outlined functions in NVPTX + add more tests.

2018-01-08 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jan  8 12:09:47 2018
New Revision: 322022

URL: http://llvm.org/viewvc/llvm-project?rev=322022&view=rev
Log:
[OPENMP] Fix debug info for outlined functions in NVPTX  + add more tests.

Fixed name of emitted outlined functions in NVPTX target + extra tests
for the debug info.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_debug_codegen.cpp
cfe/trunk/test/OpenMP/taskgroup_task_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=322022&r1=322021&r2=322022&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Jan  8 12:09:47 2018
@@ -262,7 +262,7 @@ void CGOpenMPRuntimeNVPTX::WorkerFunctio
 
   WorkerFn = llvm::Function::Create(
   CGM.getTypes().GetFunctionType(*CGFI), 
llvm::GlobalValue::InternalLinkage,
-  /* placeholder */ "_worker", &CGM.getModule());
+  /*placeholder=*/"_worker", &CGM.getModule());
   CGM.SetInternalFunctionAttributes(/*D=*/nullptr, WorkerFn, *CGFI);
 }
 
@@ -323,12 +323,12 @@ void CGOpenMPRuntimeNVPTX::emitGenericKe
   emitTargetOutlinedFunctionHelper(D, ParentName, OutlinedFn, OutlinedFnID,
IsOffloadEntry, CodeGen);
 
-  // Create the worker function
-  emitWorkerFunction(WST);
-
   // Now change the name of the worker function to correspond to this target
   // region's entry function.
   WST.WorkerFn->setName(OutlinedFn->getName() + "_worker");
+
+  // Create the worker function
+  emitWorkerFunction(WST);
 }
 
 // Setup NVPTX threads for master-worker OpenMP scheme.

Modified: cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp?rev=322022&r1=322021&r2=322022&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp Mon Jan  8 
12:09:47 2018
@@ -219,3 +219,9 @@ int bar(int n, double *ptr) {
 // TCHECK: ret void
 
 #endif
+
+// TCHECK-DAG: distinct !DISubprogram(linkageName: 
"__omp_offloading_{{.+}}_worker",
+// TCHECK-DAG: distinct !DISubprogram(linkageName: 
"__omp_offloading_{{.+}}_worker",
+// TCHECK-DAG: distinct !DISubprogram(linkageName: 
"__omp_offloading_{{.+}}_worker",
+// TCHECK-DAG: distinct !DISubprogram(linkageName: 
"__omp_offloading_{{.+}}_worker",
+// TCHECK-DAG: distinct !DISubprogram(linkageName: 
"__omp_offloading_{{.+}}_worker",

Modified: cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp?rev=322022&r1=322021&r2=322022&view=diff
==
--- cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_parallel_debug_codegen.cpp Mon Jan  8 12:09:47 
2018
@@ -92,18 +92,18 @@ int main() {
 // CHECK: addrspacecast [10 x [10 x [10 x i32]]] addrspace(1)* %{{.+}} to [10 
x [10 x [10 x i32]]]*
 // CHECK: addrspacecast i32 addrspace(1)* %{{.+}} to i32*
 // CHECK: addrspacecast [10 x [10 x i32]] addrspace(1)* %{{.+}} to [10 x [10 x 
i32]]*
-// CHECK: call void [[NONDEBUG_WRAPPER:@.+]](i32* {{[^,]+}}, i32* {{[^,]+}}, 
[10 x [10 x [10 x i32]]]* {{[^,]+}}, i32* {{[^,]+}}, [10 x [10 x i32]]* 
{{[^,]+}}, i8* {{[^)]+}})
+// CHECK: call void @[[NONDEBUG_WRAPPER:.+]](i32* {{[^,]+}}, i32* {{[^,]+}}, 
[10 x [10 x [10 x i32]]]* {{[^,]+}}, i32* {{[^,]+}}, [10 x [10 x i32]]* 
{{[^,]+}}, i8* {{[^)]+}})
 
-// CHECK: define internal void [[DEBUG_PARALLEL:@.+]](i32* {{[^,]+}}, i32* 
{{[^,]+}}, [10 x [10 x [10 x i32]]] addrspace(1)* noalias{{[^,]+}}, i32 
addrspace(1)* noalias{{[^,]+}}, [10 x [10 x i32]] addrspace(1)* 
noalias{{[^,]+}}, i8 addrspace(1)* noalias{{[^)]+}})
+// CHECK: define internal void @[[DEBUG_PARALLEL:.+]](i32* {{[^,]+}}, i32* 
{{[^,]+}}, [10 x [10 x [10 x i32]]] addrspace(1)* noalias{{[^,]+}}, i32 
addrspace(1)* noalias{{[^,]+}}, [10 x [10 x i32]] addrspace(1)* 
noalias{{[^,]+}}, i8 addrspace(1)* noalias{{[^)]+}})
 // CHECK: addrspacecast [10 x [10 x [10 x i32]]] addrspace(1)* %{{.+}} to [10 
x [10 x [10 x i32]]]*
 // CHECK: addrspacecast i32 addrspace(1)* %{{.+}} to i32*
 // CHECK: addrspacecast [10 x [10 x i32]] addrspace(1)* %{{.+}} to [10 x [10 x 
i32]]*
 
-// CHECK: define internal void [[NONDEBUG_WRAPPER]](i32* {{[^,]+}}, i32* 
{{[^,]+}}, 

[PATCH] D41507: avxintrin.h documentation fixes and updates

2018-01-08 Thread Katya Romanova via Phabricator via cfe-commits
kromanova accepted this revision.
kromanova added a comment.

LGTM too.


https://reviews.llvm.org/D41507



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


[PATCH] D39963: [RISCV] Add initial RISC-V target and driver support

2018-01-08 Thread Ana Pazos via Phabricator via cfe-commits
apazos accepted this revision.
apazos added a comment.
This revision is now accepted and ready to land.

Please merge this patch, it looks in good shape. This patch is required for any 
RISCV build.


https://reviews.llvm.org/D39963



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


r322023 - [Myriad] Remove invalidated -elf flag for MoviAsm

2018-01-08 Thread Walter Lee via cfe-commits
Author: waltl
Date: Mon Jan  8 12:36:08 2018
New Revision: 322023

URL: http://llvm.org/viewvc/llvm-project?rev=322023&view=rev
Log:
[Myriad] Remove invalidated -elf flag for MoviAsm

Summary:
The flag has been deprecated, and is becoming invalid in the latest
MDK.

Reviewers: jyknight

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Myriad.cpp
cfe/trunk/test/Driver/myriad-toolchain.c

Modified: cfe/trunk/lib/Driver/ToolChains/Myriad.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Myriad.cpp?rev=322023&r1=322022&r2=322023&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Myriad.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Myriad.cpp Mon Jan  8 12:36:08 2018
@@ -107,7 +107,6 @@ void tools::SHAVE::Assembler::ConstructJ
 CmdArgs.push_back(
 Args.MakeArgString(std::string("-i:") + A->getValue(0)));
   }
-  CmdArgs.push_back("-elf"); // Output format.
   CmdArgs.push_back(II.getFilename());
   CmdArgs.push_back(
   Args.MakeArgString(std::string("-o:") + Output.getFilename()));

Modified: cfe/trunk/test/Driver/myriad-toolchain.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/myriad-toolchain.c?rev=322023&r1=322022&r2=322023&view=diff
==
--- cfe/trunk/test/Driver/myriad-toolchain.c (original)
+++ cfe/trunk/test/Driver/myriad-toolchain.c Mon Jan  8 12:36:08 2018
@@ -41,7 +41,7 @@
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
 // MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" 
"-mcpu=myriad2.2" "-isystem" "somewhere" "-I" "common"
 // MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2.2" 
"-noSPrefixing" "-a"
-// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
+// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common"
 
 // RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFINES


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


[PATCH] D41713: [Myriad] Remove invalidated -elf flag for MoviAsm

2018-01-08 Thread Walter Lee via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC322023: [Myriad] Remove invalidated -elf flag for MoviAsm 
(authored by waltl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41713?vs=128557&id=128970#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41713

Files:
  lib/Driver/ToolChains/Myriad.cpp
  test/Driver/myriad-toolchain.c


Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -41,7 +41,7 @@
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
 // MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" 
"-mcpu=myriad2.2" "-isystem" "somewhere" "-I" "common"
 // MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2.2" 
"-noSPrefixing" "-a"
-// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
+// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common"
 
 // RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFINES
Index: lib/Driver/ToolChains/Myriad.cpp
===
--- lib/Driver/ToolChains/Myriad.cpp
+++ lib/Driver/ToolChains/Myriad.cpp
@@ -107,7 +107,6 @@
 CmdArgs.push_back(
 Args.MakeArgString(std::string("-i:") + A->getValue(0)));
   }
-  CmdArgs.push_back("-elf"); // Output format.
   CmdArgs.push_back(II.getFilename());
   CmdArgs.push_back(
   Args.MakeArgString(std::string("-o:") + Output.getFilename()));


Index: test/Driver/myriad-toolchain.c
===
--- test/Driver/myriad-toolchain.c
+++ test/Driver/myriad-toolchain.c
@@ -41,7 +41,7 @@
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
 // MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" "-mcpu=myriad2.2" "-isystem" "somewhere" "-I" "common"
 // MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2.2" "-noSPrefixing" "-a"
-// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
+// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common"
 
 // RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFINES
Index: lib/Driver/ToolChains/Myriad.cpp
===
--- lib/Driver/ToolChains/Myriad.cpp
+++ lib/Driver/ToolChains/Myriad.cpp
@@ -107,7 +107,6 @@
 CmdArgs.push_back(
 Args.MakeArgString(std::string("-i:") + A->getValue(0)));
   }
-  CmdArgs.push_back("-elf"); // Output format.
   CmdArgs.push_back(II.getFilename());
   CmdArgs.push_back(
   Args.MakeArgString(std::string("-o:") + Output.getFilename()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40023: [RISCV] Implement ABI lowering

2018-01-08 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Hi Alex, just a reminder, it looks like Eli's and David's comments have not 
been addressed yet.


https://reviews.llvm.org/D40023



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


[PATCH] D41271: [RISCV] Propagate -mabi and -march values to GNU assembler.

2018-01-08 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

This is ready to merge, just waiting for the dependence 
https://reviews.llvm.org/D39963 to be merged first.


https://reviews.llvm.org/D41271



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


[PATCH] D41039: Add support for attribute "trivial_abi"

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

Thanks, looks good to me.


https://reviews.llvm.org/D41039



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


[PATCH] D41834: [Lex] Fix handling numerical literals ending with ' and signed exponent.

2018-01-08 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: rsmith, t.p.northover.

For input `0'e+1` lexer tokenized as numeric constant only `0'e`. Later
NumericLiteralParser skipped 0 and ' as digits and parsed `e+1` as valid
exponent going past the end of the token. Because it didn't mark numeric
literal as having an error, it continued parsing and tried to expandUCNs
with StringRef of length -2.

The fix is to update error state when digit separator is encountered
after digits, so that we don't try to keep parsing invalid input.

Discovered by OSS-Fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=4588

rdar://problem/36076719


https://reviews.llvm.org/D41834

Files:
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/Lexer/cxx1y_digit_separators.cpp


Index: clang/test/Lexer/cxx1y_digit_separators.cpp
===
--- clang/test/Lexer/cxx1y_digit_separators.cpp
+++ clang/test/Lexer/cxx1y_digit_separators.cpp
@@ -51,6 +51,7 @@
   float u = 0x.'p1f; // expected-error {{hexadecimal floating literal requires 
a significand}}
   float v = 0e'f; // expected-error {{exponent has no digits}}
   float w = 0x0p'f; // expected-error {{exponent has no digits}}
+  float x = 0'e+1; // expected-error {{digit separator cannot appear at end of 
digit sequence}}
 }
 
 #line 123'456
Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -787,10 +787,12 @@
   } else if (Pos == ThisTokEnd)
 return;
 
-  if (isDigitSeparator(*Pos))
+  if (isDigitSeparator(*Pos)) {
 PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Pos - ThisTokBegin),
 diag::err_digit_separator_not_between_digits)
   << IsAfterDigits;
+hadError = true;
+  }
 }
 
 /// ParseNumberStartingWithZero - This method is called when the first 
character


Index: clang/test/Lexer/cxx1y_digit_separators.cpp
===
--- clang/test/Lexer/cxx1y_digit_separators.cpp
+++ clang/test/Lexer/cxx1y_digit_separators.cpp
@@ -51,6 +51,7 @@
   float u = 0x.'p1f; // expected-error {{hexadecimal floating literal requires a significand}}
   float v = 0e'f; // expected-error {{exponent has no digits}}
   float w = 0x0p'f; // expected-error {{exponent has no digits}}
+  float x = 0'e+1; // expected-error {{digit separator cannot appear at end of digit sequence}}
 }
 
 #line 123'456
Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -787,10 +787,12 @@
   } else if (Pos == ThisTokEnd)
 return;
 
-  if (isDigitSeparator(*Pos))
+  if (isDigitSeparator(*Pos)) {
 PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, Pos - ThisTokBegin),
 diag::err_digit_separator_not_between_digits)
   << IsAfterDigits;
+hadError = true;
+  }
 }
 
 /// ParseNumberStartingWithZero - This method is called when the first character
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41834: [Lex] Fix handling numerical literals ending with ' and signed exponent.

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

This fixes the OSS-Fuzz bug but I don't know if it is sufficient. Should I also 
make `Lexer::LexNumericConstant` to include `+1` part as tok::numeric_constant?


https://reviews.llvm.org/D41834



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


r322024 - Factor out comparison handling for arithmetic types.

2018-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jan  8 13:12:04 2018
New Revision: 322024

URL: http://llvm.org/viewvc/llvm-project?rev=322024&view=rev
Log:
Factor out comparison handling for arithmetic types.

This is not quite NFC: we don't perform the usual arithmetic conversions unless
we have an operand of arithmetic or enumeration type any more. This matches the
standard rule, but actually has no effect other than to marginally improve our
diagnostics for the non-arithmetic, non-enumeration cases (by not performing
integral promotions on one operand if the other is a pointer).

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Parser/pointer_promotion.c

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=322024&r1=322023&r2=322024&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Jan  8 13:12:04 2018
@@ -10405,7 +10405,10 @@ private:
   const AttrVec *Attrs = nullptr,
   const FunctionDecl *FD = nullptr);
 
-  void CheckFloatComparison(SourceLocation Loc, Expr* LHS, Expr* RHS);
+public:
+  void CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS);
+
+private:
   void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
   void CheckBoolLikeConversion(Expr *E, SourceLocation CC);
   void CheckForIntOverflow(Expr *E);

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=322024&r1=322023&r2=322024&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jan  8 13:12:04 2018
@@ -9598,7 +9598,6 @@ static void diagnoseTautologicalComparis
   Expr *RHSStripped = RHS->IgnoreParenImpCasts();
 
   QualType LHSType = LHS->getType();
-  QualType RHSType = RHS->getType();
   if (LHSType->hasFloatingRepresentation() ||
   (LHSType->isBlockPointerType() && !BinaryOperator::isEqualityOp(Opc)) ||
   LHS->getLocStart().isMacroID() || RHS->getLocStart().isMacroID() ||
@@ -9636,9 +9635,8 @@ static void diagnoseTautologicalComparis
   S.PDiag(diag::warn_comparison_always)
   << 0 /*self-comparison*/ << !Result.empty()
   << Result);
-  } else if (DL && DR && LHSType->isArrayType() && RHSType->isArrayType() &&
- !DL->getType()->isReferenceType() &&
- !DR->getType()->isReferenceType() &&
+  } else if (DL && DR &&
+ DL->getType()->isArrayType() && DR->getType()->isArrayType() &&
  !DL->isWeak() && !DR->isWeak()) {
 // What is it always going to evaluate to?
 StringRef Result;
@@ -9689,10 +9687,53 @@ static void diagnoseTautologicalComparis
   }
 }
 
+static QualType checkArithmeticOrEnumeralCompare(Sema &S, ExprResult &LHS,
+ ExprResult &RHS,
+ SourceLocation Loc,
+ BinaryOperatorKind Opc) {
+  // C99 6.5.8p3 / C99 6.5.9p4
+  QualType Type = S.UsualArithmeticConversions(LHS, RHS);
+  if (LHS.isInvalid() || RHS.isInvalid())
+return QualType();
+  if (Type.isNull())
+return S.InvalidOperands(Loc, LHS, RHS);
+  assert(Type->isArithmeticType() || Type->isEnumeralType());
+
+  checkEnumComparison(S, Loc, LHS.get(), RHS.get());
+
+  enum { StrongEquality, PartialOrdering, StrongOrdering } Ordering;
+  if (Type->isAnyComplexType())
+Ordering = StrongEquality;
+  else if (Type->isFloatingType())
+Ordering = PartialOrdering;
+  else
+Ordering = StrongOrdering;
+
+  if (Ordering == StrongEquality && BinaryOperator::isRelationalOp(Opc))
+return S.InvalidOperands(Loc, LHS, RHS);
+
+  // Check for comparisons of floating point operands using != and ==.
+  if (Type->hasFloatingRepresentation() && BinaryOperator::isEqualityOp(Opc))
+S.CheckFloatComparison(Loc, LHS.get(), RHS.get());
+
+  // The result of comparisons is 'bool' in C++, 'int' in C.
+  // FIXME: For BO_Cmp, return the relevant comparison category type.
+  return S.Context.getLogicalOperationType();
+}
+
 // C99 6.5.8, C++ [expr.rel]
 QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
 SourceLocation Loc, BinaryOperatorKind Opc,
 bool IsRelational) {
+  // Comparisons expect an rvalue, so convert to rvalue before any
+  // type-related checks.
+  LHS = DefaultFunctionArrayLvalueConversion(LHS.get());
+  if (LHS.isInvalid())
+return QualType();
+  RHS = DefaultFunctionArrayLvalueConversion(RHS.get());
+  if (RHS.isInvalid())
+return QualType();
+
   checkArithmeticNull(*th

r322027 - [DOXYGEN] Fix doxygen and content issues in avxintrin.h

2018-01-08 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Mon Jan  8 13:21:17 2018
New Revision: 322027

URL: http://llvm.org/viewvc/llvm-project?rev=322027&view=rev
Log:
[DOXYGEN] Fix doxygen and content issues in avxintrin.h

- Fix incorrect wording in various intrinsic descriptions. Previously the 
descriptions used "low-order" and "high-order" when the intended meaning was 
"even-indexed" and "odd-indexed".
- Fix a few typos and errors found during review.
- Restore new line endings.

This patch was made by Craig Flores


Modified:
cfe/trunk/lib/Headers/avxintrin.h

Modified: cfe/trunk/lib/Headers/avxintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avxintrin.h?rev=322027&r1=322026&r2=322027&view=diff
==
--- cfe/trunk/lib/Headers/avxintrin.h (original)
+++ cfe/trunk/lib/Headers/avxintrin.h Mon Jan  8 13:21:17 2018
@@ -1120,7 +1120,7 @@ _mm256_permutevar_ps(__m256 __a, __m256i
 /// \param A
 ///A 256-bit vector of [8 x float].
 /// \param C
-///An immediate integer operand specifying how the values are to be \n
+///An immediate integer operand specifying how the values are to be
 ///copied. \n
 ///Bits [1:0]: \n
 ///  00: Bits [31:0] of the source are copied to bits [31:0] of the
@@ -1150,7 +1150,7 @@ _mm256_permutevar_ps(__m256 __a, __m256i
 ///  11: Bits [127:96] of the source are copied to bits [95:64] of the
 ///  returned vector. \n
 ///Bits [7:6]: \n
-///  00: Bits [31:qq0] of the source are copied to bits [127:96] of the
+///  00: Bits [31:0] of the source are copied to bits [127:96] of the
 ///  returned vector. \n
 ///  01: Bits [63:32] of the source are copied to bits [127:96] of the
 ///  returned vector. \n
@@ -1665,38 +1665,38 @@ _mm256_blendv_ps(__m256 __a, __m256 __b,
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which 
comparison
 ///operation to use: \n
-///0x00 : Equal (ordered, non-signaling)
-///0x01 : Less-than (ordered, signaling)
-///0x02 : Less-than-or-equal (ordered, signaling)
-///0x03 : Unordered (non-signaling)
-///0x04 : Not-equal (unordered, non-signaling)
-///0x05 : Not-less-than (unordered, signaling)
-///0x06 : Not-less-than-or-equal (unordered, signaling)
-///0x07 : Ordered (non-signaling)
-///0x08 : Equal (unordered, non-signaling)
-///0x09 : Not-greater-than-or-equal (unordered, signaling)
-///0x0a : Not-greater-than (unordered, signaling)
-///0x0b : False (ordered, non-signaling)
-///0x0c : Not-equal (ordered, non-signaling)
-///0x0d : Greater-than-or-equal (ordered, signaling)
-///0x0e : Greater-than (ordered, signaling)
-///0x0f : True (unordered, non-signaling)
-///0x10 : Equal (ordered, signaling)
-///0x11 : Less-than (ordered, non-signaling)
-///0x12 : Less-than-or-equal (ordered, non-signaling)
-///0x13 : Unordered (signaling)
-///0x14 : Not-equal (unordered, signaling)
-///0x15 : Not-less-than (unordered, non-signaling)
-///0x16 : Not-less-than-or-equal (unordered, non-signaling)
-///0x17 : Ordered (signaling)
-///0x18 : Equal (unordered, signaling)
-///0x19 : Not-greater-than-or-equal (unordered, non-signaling)
-///0x1a : Not-greater-than (unordered, non-signaling)
-///0x1b : False (ordered, signaling)
-///0x1c : Not-equal (ordered, signaling)
-///0x1d : Greater-than-or-equal (ordered, non-signaling)
-///0x1e : Greater-than (ordered, non-signaling)
-///0x1f : True (unordered, signaling)
+///0x00: Equal (ordered, non-signaling) \n
+///0x01: Less-than (ordered, signaling) \n
+///0x02: Less-than-or-equal (ordered, signaling) \n
+///0x03: Unordered (non-signaling) \n
+///0x04: Not-equal (unordered, non-signaling) \n
+///0x05: Not-less-than (unordered, signaling) \n
+///0x06: Not-less-than-or-equal (unordered, signaling) \n
+///0x07: Ordered (non-signaling) \n
+///0x08: Equal (unordered, non-signaling) \n
+///0x09: Not-greater-than-or-equal (unordered, signaling) \n
+///0x0A: Not-greater-than (unordered, signaling) \n
+///0x0B: False (ordered, non-signaling) \n
+///0x0C: Not-equal (ordered, non-signaling) \n
+///0x0D: Greater-than-or-equal (ordered, signaling) \n
+///0x0E: Greater-than (ordered, signaling) \n
+///0x0F: True (unordered, non-signaling) \n
+///0x10: Equal (ordered, signaling) \n
+///0x11: Less-than (ordered, non-signaling) \n
+///0x12: Less-than-or-equal (ordered, non-signaling) \n
+///0x13: Unordered (signaling) \n
+///0x14: Not-equal (unordered, signaling) \n
+///0x15: Not-less-than (unordered, non-signaling) \n
+///0x16: Not-less-than-or-equal (unordered, non-signaling) \n
+///0x17: Ordered (signaling) \n
+///0x18: Equal (unordered, signaling) \n
+///0x19: Not-greater-than-or-equal (unordered, non-signaling) \n
+///0x1A: Not-greater-than (unordered,

r322028 - Implement Attribute Target MultiVersioning

2018-01-08 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Jan  8 13:34:17 2018
New Revision: 322028

URL: http://llvm.org/viewvc/llvm-project?rev=322028&view=rev
Log:
Implement Attribute Target MultiVersioning

GCC's attribute 'target', in addition to being an optimization hint,
also allows function multiversioning. We currently have the former
implemented, this is the latter's implementation.

This works by enabling functions with the same name/signature to coexist,
so that they can all be emitted. Multiversion state is stored in the
FunctionDecl itself, and SemaDecl manages the definitions.
Note that it ends up having to permit redefinition of functions so
that they can all be emitted. Additionally, all versions of the function
must be emitted, so this also manages that.

Note that this includes some additional rules that GCC does not, since
defining something as a MultiVersion function after a usage has been made 
illegal.

The only 'history rewriting' that happens is if a function is emitted before
it has been converted to a multiversion'ed function, at which point its name
needs to be changed.

Function templates and virtual functions are NOT yet supported (not supported
in GCC either).

Additionally, constructors/destructors are disallowed, but the former is 
planned.

Added:
cfe/trunk/test/CodeGen/attr-target-mv-func-ptrs.c
cfe/trunk/test/CodeGen/attr-target-mv-va-args.c
cfe/trunk/test/CodeGen/attr-target-mv.c
cfe/trunk/test/CodeGenCXX/attr-target-mv-diff-ns.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-func-ptrs.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-member-funcs.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-modules.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp
cfe/trunk/test/CodeGenCXX/attr-target-mv-overloads.cpp
cfe/trunk/test/Sema/attr-target-mv-bad-target.c
cfe/trunk/test/Sema/attr-target-mv.c
cfe/trunk/test/SemaCXX/attr-target-mv.cpp
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Basic/X86Target.def
cfe/trunk/include/clang/Sema/Overload.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=322028&r1=322027&r2=322028&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Jan  8 13:34:17 2018
@@ -2640,6 +2640,12 @@ public:
   /// it is not used.
   bool DeclMustBeEmitted(const Decl *D);
 
+  /// \brief Visits all versions of a multiversioned function with the passed
+  /// predicate.
+  void forEachMultiversionedFunctionVersion(
+  const FunctionDecl *FD,
+  llvm::function_ref Pred) const;
+
   const CXXConstructorDecl *
   getCopyConstructorForExceptionObject(CXXRecordDecl *RD);
 

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=322028&r1=322027&r2=322028&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Jan  8 13:34:17 2018
@@ -1750,6 +1750,10 @@ private:
   /// parsing it.
   unsigned WillHaveBody : 1;
 
+  /// Indicates that this function is a multiversioned function using attribute
+  /// 'target'.
+  unsigned IsMultiVersion : 1;
+
 protected:
   /// [C++17] Only used by CXXDeductionGuideDecl. Declared here to avoid
   /// increasing the size of CXXDeductionGuideDecl by the size of an unsigned
@@ -1846,9 +1850,9 @@ protected:
 IsExplicitlyDefaulted(false), HasImplicitReturnZero(false),
 IsLateTemplateParsed(false), IsConstexpr(isConstexprSpecified),
 InstantiationIsPending(false), UsesSEHTry(false), 
HasSkippedBody(false),
-WillHaveBody(false), IsCopyDeductionCandidate(false), 
HasODRHash(false),
-ODRHash(0), EndRangeLoc(NameInfo.getEndLoc()),
-DNLoc(NameInfo.getInfo()) {}
+WillHaveBody(false), IsMultiVersion(false),
+IsCopyDeductionCandidate(false), HasODRHash(false), ODRHash(0),
+EndRangeLoc(NameInfo.getEndLoc()), DNLoc(NameInfo.getInfo()) {}
 
   using redeclarable_base = Redeclarable;
 
@@ -2154,6 +2158,15 @@ public:
   bool wi

[PATCH] D40819: Implement Attribute Target MultiVersioning (Improved edition!)

2018-01-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane closed this revision.
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

Closed with revision 322028


https://reviews.llvm.org/D40819



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


[PATCH] D41039: Add support for attribute "trivial_abi"

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

I'd like to see more testing for the template instantiation case. I don't see 
any test coverage for the "attribute only affects instantiations whose members 
are trivial-for-calls" part.




Comment at: include/clang/Sema/Sema.h:2239
   bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM,
-  bool Diagnose = false);
+  bool ForCall = false, bool Diagnose = false);
   CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD);

Please use an enum here; two bool parameters in a row is too error-prone, 
especially if both have default arguments.



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:863-864
+  return RAA_Default;
+// Otherwise, if the copy ctor is trivial and the object is small, pass
+// direct.
+if (CopyCtorIsTrivial &&

Please retain the two pre-existing "Note"s pointing out how the ABI rule here 
is intentionally non-conforming.



Comment at: lib/Sema/SemaDecl.cpp:11700
+}
+  }
+

rjmccall wrote:
> I think it's correct not to call CheckDestructorAccess and DiagnoseUseOfDecl 
> here, since according to the standard destructor access is always supposed to 
> be checked at the call-site, but please leave a comment explaining that.
The corresponding code for `areArgsDestroyedLeftToRightInCallee` is in 
`SemaChecking`. This should be done in the same place.

More generally, we have at least three different places where we check 
`CXXABI::areArgsDestroyedLeftToRightInCallee() || 
Type->hasTrivialABIOverride()`. It would make sense to factor that out into a 
`isParamDestroyedInCallee` function (probably on `ASTContext`, since we don't 
have anywhere better for ABI-specific checks at a layering level that can talk 
about types).



Comment at: lib/Sema/SemaDeclCXX.cpp:7580
 
+static void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD, Sema &S) {
+  auto PrintDiagAndRemoveAttr = [&]() {

Either "ill-formed" is the wrong word here, or this needs to produce `ext_` 
diagnostics that `-pedantic-errors` turns into hard errors.



Comment at: lib/Sema/SemaDeclCXX.cpp:7582-7583
+  auto PrintDiagAndRemoveAttr = [&]() {
+S.Diag(RD.getAttr()->getLocation(),
+   diag::warn_cannot_use_trivial_abi) << &RD;
+RD.dropAttr();

Suppress the diagnostic in the case where this happens during template 
instantiation.



Comment at: lib/Sema/SemaDeclCXX.cpp:7595
+const auto *BaseClassDecl
+= cast(B.getType()->getAs()->getDecl());
+// Ill-formed if the base class is non-trivial for the purpose of calls or 
a

This can be simplified to `B.getType()->getAsCXXRecordDecl()`.



Comment at: lib/Sema/SemaDeclCXX.cpp:7598
+// virtual base.
+if (!BaseClassDecl->canPassInRegisters() || B.isVirtual()) {
+  PrintDiagAndRemoveAttr();

It isn't correct to check `canPassInRegisters` on a dependent type here; you 
need to skip this check in that case.


https://reviews.llvm.org/D41039



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


[PATCH] D41706: [Driver] Update default sanitizer blacklist location

2018-01-08 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd accepted this revision.
compnerd added a comment.
This revision is now accepted and ready to land.

This seems fine, but will need https://reviews.llvm.org/D41673 to go in at the 
same time.  The sanitizers are pretty tightly coupled with the compiler, so I 
don't think that it is too big of a deal, but it may be nice to have a more 
robust upgrade path.


Repository:
  rC Clang

https://reviews.llvm.org/D41706



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


r322030 - PR35862: Suppress -Wmissing-variable-declarations warning on inline variables,

2018-01-08 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Jan  8 13:46:42 2018
New Revision: 322030

URL: http://llvm.org/viewvc/llvm-project?rev=322030&view=rev
Log:
PR35862: Suppress -Wmissing-variable-declarations warning on inline variables,
variable templates, and instantiations thereof.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/warn-missing-variable-declarations.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=322030&r1=322029&r2=322030&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Jan  8 13:46:42 2018
@@ -11348,6 +11348,8 @@ void Sema::CheckCompleteVariableDeclarat
   if (var->isThisDeclarationADefinition() &&
   var->getDeclContext()->getRedeclContext()->isFileContext() &&
   var->isExternallyVisible() && var->hasLinkage() &&
+  !var->isInline() && !var->getDescribedVarTemplate() &&
+  !isTemplateInstantiation(var->getTemplateSpecializationKind()) &&
   !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
   var->getLocation())) {
 // Find a previous declaration that's not a definition.

Modified: cfe/trunk/test/SemaCXX/warn-missing-variable-declarations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-missing-variable-declarations.cpp?rev=322030&r1=322029&r2=322030&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-missing-variable-declarations.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-missing-variable-declarations.cpp Mon Jan  8 
13:46:42 2018
@@ -1,4 +1,4 @@
-// RUN: %clang -Wmissing-variable-declarations -fsyntax-only -Xclang -verify %s
+// RUN: %clang -Wmissing-variable-declarations -fsyntax-only -Xclang -verify 
-std=c++17 %s
 
 // Variable declarations that should trigger a warning.
 int vbad1; // expected-warning{{no previous extern declaration for non-static 
variable 'vbad1'}}
@@ -52,3 +52,24 @@ class C {
 namespace {
   int vgood4;
 }
+
+inline int inline_var = 0;
+const int const_var = 0;
+constexpr int constexpr_var = 0;
+inline constexpr int inline_constexpr_var = 0;
+extern const int extern_const_var = 0; // expected-warning {{no previous 
extern declaration}}
+extern constexpr int extern_constexpr_var = 0; // expected-warning {{no 
previous extern declaration}}
+
+template int var_template = 0;
+template constexpr int const_var_template = 0;
+template static int static_var_template = 0;
+
+template int var_template;
+int use_var_template() { return var_template; }
+template int var_template;
+extern template int var_template;
+template<> int var_template; // expected-warning {{no previous extern 
declaration}}
+
+// FIXME: We give this specialization internal linkage rather than inheriting
+// the linkage from the template! We should not warn here.
+template<> int static_var_template; // expected-warning {{no previous 
extern declaration}}


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


[libcxx] r322031 - Make rehash(0) work with ubsan's unsigned-integer-overflow.

2018-01-08 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Mon Jan  8 13:49:12 2018
New Revision: 322031

URL: http://llvm.org/viewvc/llvm-project?rev=322031&view=rev
Log:
Make rehash(0) work with ubsan's unsigned-integer-overflow.

Reviewers: mclow.lists, EricWF

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/include/__hash_table

Modified: libcxx/trunk/include/__hash_table
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__hash_table?rev=322031&r1=322030&r2=322031&view=diff
==
--- libcxx/trunk/include/__hash_table (original)
+++ libcxx/trunk/include/__hash_table Mon Jan  8 13:49:12 2018
@@ -2136,7 +2136,7 @@ template ::rehash(size_type __n)
 {
-if (__n == 1)
+if (__n < 2)
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);


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


[PATCH] D40743: Make rehash(0) work with ubsan's unsigned-integer-overflow.

2018-01-08 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX322031: Make rehash(0) work with ubsan's 
unsigned-integer-overflow. (authored by danalbert, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D40743?vs=125193&id=128979#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D40743

Files:
  include/__hash_table


Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2136,7 +2136,7 @@
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
 {
-if (__n == 1)
+if (__n < 2)
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);


Index: include/__hash_table
===
--- include/__hash_table
+++ include/__hash_table
@@ -2136,7 +2136,7 @@
 void
 __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
 {
-if (__n == 1)
+if (__n < 2)
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40743: Make rehash(0) work with ubsan's unsigned-integer-overflow.

2018-01-08 Thread Dan Albert via Phabricator via cfe-commits
danalbert added inline comments.



Comment at: include/__hash_table:2141
 __n = 2;
 else if (__n & (__n - 1))
 __n = __next_prime(__n);

mclow.lists wrote:
> danalbert wrote:
> > With `rehash(0)` this is `0 & (0 - 1)`, which triggers 
> > unsigned-integer-overflow.
> Grumble, grumble. That's not UB, that's just UBSan whining.
> On the other hand, this doesn't appear to change any behavior, and shuts 
> UBSan up.
FWIW, this check isn't enabled in ubsan by default. Android uses it for testing 
and mititgation in a handful of projects because it does catch errors 
(stagefright was an unsigned overflow issue). It's good to keep the libc++ 
headers clean of these issues so we're not dictating the compile flags of 
libc++ users.


Repository:
  rCXX libc++

https://reviews.llvm.org/D40743



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


[PATCH] D41837: Add Function multiversion to the release notes.

2018-01-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rsmith, hans, aaron.ballman, echristo.

Richard suggested that I add this feature to the release notes,
so I was hoping someone (anyone willing:) ) could do a quick read
through for me.

Thanks!
-Erich


Repository:
  rC Clang

https://reviews.llvm.org/D41837

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -80,6 +80,11 @@
 Attribute Changes in Clang
 --
 
+- Clang now supports function multiversioning with attribute 'target' on ELF
+  based environments by using indirect functions. This implementation has a few
+  minor limitations over the GCC implementation for the sake of AST sanity,
+  however it is otherwise compatible with existing code using this feature for
+  GCC.
 - ...
 
 Windows Support


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -80,6 +80,11 @@
 Attribute Changes in Clang
 --
 
+- Clang now supports function multiversioning with attribute 'target' on ELF
+  based environments by using indirect functions. This implementation has a few
+  minor limitations over the GCC implementation for the sake of AST sanity,
+  however it is otherwise compatible with existing code using this feature for
+  GCC.
 - ...
 
 Windows Support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41837: Add Function multiversion to the release notes.

2018-01-08 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

I think you're missing that right now it's x86 only yes? :)

-eric


Repository:
  rC Clang

https://reviews.llvm.org/D41837



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


[PATCH] D41837: Add Function multiversion to the release notes.

2018-01-08 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 128982.
erichkeane added a comment.

Ah, right :)  Slipped my mind that ELF != x86-linux.


https://reviews.llvm.org/D41837

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -80,6 +80,11 @@
 Attribute Changes in Clang
 --
 
+- Clang now supports function multiversioning with attribute 'target' on ELF
+  based x86/x86-64 environments by using indirect functions. This 
implementation
+  has a few minor limitations over the GCC implementation for the sake of AST
+  sanity, however it is otherwise compatible with existing code using this
+  feature for GCC.
 - ...
 
 Windows Support


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -80,6 +80,11 @@
 Attribute Changes in Clang
 --
 
+- Clang now supports function multiversioning with attribute 'target' on ELF
+  based x86/x86-64 environments by using indirect functions. This implementation
+  has a few minor limitations over the GCC implementation for the sake of AST
+  sanity, however it is otherwise compatible with existing code using this
+  feature for GCC.
 - ...
 
 Windows Support
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r322034 - Apparently 'C++14' is different than 'c++14'

2018-01-08 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Jan  8 14:16:30 2018
New Revision: 322034

URL: http://llvm.org/viewvc/llvm-project?rev=322034&view=rev
Log:
Apparently 'C++14' is different than 'c++14'

Modified:

libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp?rev=322034&r1=322033&r2=322034&view=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/func.search/func.search.bm/hash.pass.cpp
 Mon Jan  8 14:16:30 2018
@@ -7,7 +7,7 @@
 //
 
//===--===//
 
-// UNSUPPORTED: c++98, c++03, c++11, C++14
+// UNSUPPORTED: c++98, c++03, c++11, c++14
 // XFAIL: c++17, c++2a
 
 // 


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


  1   2   >