[clang-tools-extra] r329875 - [Documentation] Fix options order for Release Notes in modernize-use-auto.

2018-04-11 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Wed Apr 11 22:45:16 2018
New Revision: 329875

URL: http://llvm.org/viewvc/llvm-project?rev=329875=rev
Log:
[Documentation] Fix options order for Release Notes in modernize-use-auto.


Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst?rev=329875=329874=329875=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst Wed 
Apr 11 22:45:16 2018
@@ -177,24 +177,6 @@ Known Limitations
 Options
 ---
 
-.. option:: RemoveStars
-
-   If the option is set to non-zero (default is `0`), the check will remove
-   stars from the non-typedef pointer types when replacing type names with
-   ``auto``. Otherwise, the check will leave stars. For example:
-
-.. code-block:: c++
-
-  TypeName *my_first_pointer = new TypeName, *my_second_pointer = new TypeName;
-
-  // RemoveStars = 0
-
-  auto *my_first_pointer = new TypeName, *my_second_pointer = new TypeName;
-
-  // RemoveStars = 1
-
-  auto my_first_pointer = new TypeName, my_second_pointer = new TypeName;
-
 .. option:: MinTypeNameLength
 
If the option is set to non-zero (default `5`), the check will ignore type
@@ -214,3 +196,21 @@ Options
   int a = static_cast(foo());// ---> int  a = ...
   bool b = new bool;  // ---> bool b = ...
   unsigned c = static_cast(foo());  // ---> auto c = ...
+
+.. option:: RemoveStars
+
+   If the option is set to non-zero (default is `0`), the check will remove
+   stars from the non-typedef pointer types when replacing type names with
+   ``auto``. Otherwise, the check will leave stars. For example:
+
+.. code-block:: c++
+
+  TypeName *my_first_pointer = new TypeName, *my_second_pointer = new TypeName;
+
+  // RemoveStars = 0
+
+  auto *my_first_pointer = new TypeName, *my_second_pointer = new TypeName;
+
+  // RemoveStars = 1
+
+  auto my_first_pointer = new TypeName, my_second_pointer = new TypeName;


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


[clang-tools-extra] r329873 - [clang-tidy] [modernize-use-auto] Get only a length of token, not the token itself

2018-04-11 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Wed Apr 11 22:41:24 2018
New Revision: 329873

URL: http://llvm.org/viewvc/llvm-project?rev=329873=rev
Log:
[clang-tidy] [modernize-use-auto] Get only a length of token, not the token 
itself


Modified:
clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=329873=329872=329873=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Wed Apr 11 
22:41:24 2018
@@ -11,6 +11,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
 #include "clang/Tooling/FixIt.h"
 
 using namespace clang;
@@ -419,8 +420,8 @@ void UseAutoCheck::replaceExpr(
   SourceRange Range(Loc.getSourceRange());
 
   if (MinTypeNameLength != 0 &&
-  tooling::fixit::getText(Loc.getSourceRange(), FirstDecl->getASTContext())
-  .size() < MinTypeNameLength)
+  Lexer::MeasureTokenLength(Loc.getLocStart(), Context->getSourceManager(),
+getLangOpts()) < MinTypeNameLength)
 return;
 
   auto Diag = diag(Range.getBegin(), Message);


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


[PATCH] D45529: [CMake] Set the default ABI version for Fuchsia in CMake as well

2018-04-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

This LGTM given that Eric accepted your previous change. I'm happy to accept it 
in a day or two if he hasn't gotten the chance to take a look by then.




Comment at: libcxx/CMakeLists.txt:101
+if (FUCHSIA)
+  set(ABI_VERSION_DEFAULT 2)
+else()

I prefer `DEFAULT_ABI_VERSION` to `ABI_VERSION_DEFAULT`


Repository:
  rCXX libc++

https://reviews.llvm.org/D45529



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D44882#1064196, @sammccall wrote:

> (BTW @hokein has https://reviews.llvm.org/D45513 to add row/col to the index, 
> which will allow all the file-reading stuff to be cleaned up, but no need to 
> wait on that since it's all working now).


Looking forward to it!




Comment at: clangd/ClangdLSPServer.cpp:101
+  // All clients should support those.
+  for (SymKindUnderlyingType I = SymbolKindMin;
+   I <= static_cast(SymbolKind::Array); ++I)

sammccall wrote:
> malaperle wrote:
> > I'd like to add some test to exercise the changes in ClangdLSPServer.cpp 
> > and Protocol.cpp but it's not straightforward to do nicely. Using a "lit" 
> > test, I cannot have a header and since symbols in the main file are not 
> > collected then it's not useful. If I make a gtest, I have to feed it the 
> > lsp server with stdin and check the stdout which is a bit messy, but doable.
> Yeah, we don't have a good way to test ClangdLSPServer :-( I would like to 
> fix that, but I don't know of any easy fixes.
> 
> This is kind of gross, but do standard library includes work from our lit 
> tests? You could `#include ` and then test using some symbols you know 
> are there...
> 
It doesn't seem to work unfortunately. I'm not sure why yet. Either way, I 
think I would add this test as a separate patch if we are to add a standard 
library include because I'm a bit nervous it will break and we will have to 
revert it :)



Comment at: clangd/ClangdLSPServer.cpp:103
+   I <= static_cast(SymbolKind::Array); ++I)
+SupportedSymbolKinds.set(I);
+

sammccall wrote:
> I'd like to be slightly less hostile than this to (broken) clients that fail 
> to call initialize.
> As the patch stands they'll get an empty SupportedSymbolKinds, and we'll 
> crash if they call documentSymbols.
> 
> Instead I'd suggest pulling out defaultSymbolKinds() and initializing to that 
> in the constructor, and then overriding with either `SpecifiedSymbolKinds` or 
> `SpecifiedSymbolKinds | defaultSymbolKinds()` here.
Good catch. I initialized SupportedSymbolKinds with defaultSymbolKinds() and 
let this loop add additional symbol kinds.



Comment at: clangd/ClangdServer.h:164
+  void workspaceSymbols(StringRef Query,
+const clangd::WorkspaceSymbolOptions ,
+const DraftStore ,

sammccall wrote:
> I think it would probably be more consistent with other functions to just 
> take `int limit` here. I'm not sure CodeCompletion is an example we want to 
> emulate.
> 
> ClangdLSPServer might even just grab it from the code completion options, 
> since that's the behavior we actually want.
> 
> Up to you, though.
I think it makes sense. We can reintroduce an option struct when there is more 
than one thing in it.



Comment at: clangd/Protocol.cpp:209
+  default:
+llvm_unreachable("Unexpected symbol kind");
+  }

sammccall wrote:
> This doesn't actually seem unreachable (or won't stay that way), maybe log 
> and return `Null` or something like that? (Wow, there's really no catch-all 
> option for this mandatory enum...)
`Null` Is not in LSP 1.0 and 2.0 that's why I had put `Variable` at the 
beginning. Maybe `String` is better. Not sure what you think is best.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 142112.
malaperle marked 2 inline comments as done.
malaperle added a comment.

Address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FindSymbols.cpp
  clangd/FindSymbols.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  clangd/index/SymbolCollector.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -41,6 +41,10 @@
 
 std::string runDumpAST(ClangdServer , PathRef File);
 
+llvm::Expected
+runWorkspaceSymbols(ClangdServer , StringRef Query, int Limit,
+const DraftStore );
+
 } // namespace clangd
 } // namespace clang
 
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -110,5 +110,13 @@
   return std::move(*Result);
 }
 
+llvm::Expected
+runWorkspaceSymbols(ClangdServer , StringRef Query, int Limit,
+const DraftStore ) {
+  llvm::Optional> Result;
+  Server.workspaceSymbols(Query, Limit, DS, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- /dev/null
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -0,0 +1,249 @@
+//===-- FindSymbolsTests.cpp -*- C++ -*===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "Annotations.h"
+#include "ClangdServer.h"
+#include "DraftStore.h"
+#include "FindSymbols.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+
+namespace {
+
+using ::testing::AllOf;
+using ::testing::AnyOf;
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAre;
+
+class IgnoreDiagnostics : public DiagnosticsConsumer {
+  void onDiagnosticsReady(PathRef File,
+  std::vector Diagnostics) override {}
+};
+
+// GMock helpers for matching SymbolInfos items.
+MATCHER_P(Named, Name, "") { return arg.name == Name; }
+MATCHER_P(InContainer, ContainerName, "") {
+  return arg.containerName == ContainerName;
+}
+MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
+
+ClangdServer::Options optsForTests() {
+  auto ServerOpts = ClangdServer::optsForTest();
+  ServerOpts.BuildDynamicSymbolIndex = true;
+  return ServerOpts;
+}
+
+class WorkspaceSymbolsTest : public ::testing::Test {
+public:
+  WorkspaceSymbolsTest()
+  : Server(CDB, FSProvider, DiagConsumer, optsForTests()) {}
+
+protected:
+  MockFSProvider FSProvider;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server;
+  int Limit;
+  DraftStore DS;
+
+  std::vector getSymbols(StringRef Query) {
+EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for preamble";
+auto SymbolInfos = runWorkspaceSymbols(Server, Query, Limit, DS);
+EXPECT_TRUE(bool(SymbolInfos)) << "workspaceSymbols returned an error";
+return *SymbolInfos;
+  }
+
+  void addFile(StringRef FileName, StringRef Contents) {
+auto Path = testPath(FileName);
+FSProvider.Files[Path] = Contents;
+Server.addDocument(Path, Contents);
+  }
+};
+
+} // namespace
+
+TEST_F(WorkspaceSymbolsTest, NoMacro) {
+  addFile("foo.cpp", R"cpp(
+  #define MACRO X
+  )cpp");
+
+  // Macros are not in the index.
+  EXPECT_THAT(getSymbols("macro"), IsEmpty());
+}
+
+TEST_F(WorkspaceSymbolsTest, NoLocals) {
+  addFile("foo.cpp", R"cpp(
+  void test(int FirstParam, int SecondParam) {
+struct LocalClass {};
+int local_var;
+  })cpp");
+  EXPECT_THAT(getSymbols("l"), IsEmpty());
+  EXPECT_THAT(getSymbols("p"), IsEmpty());
+}
+
+TEST_F(WorkspaceSymbolsTest, Globals) {
+  addFile("foo.h", R"cpp(
+  int global_var;
+
+  int global_func();
+
+  struct GlobalStruct {};)cpp");
+  addFile("foo.cpp", R"cpp(
+  #include "foo.h"
+  )cpp");
+  EXPECT_THAT(getSymbols("global"),
+  

[PATCH] D45305: ObjCGNU: Fix empty v3 protocols being emitted two fields short

2018-04-11 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT added a comment.

Hi! Is there anything else holding up this patch? Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D45305



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


r329869 - [ODRHash] Skip more types hashing TypedefType

2018-04-11 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Apr 11 19:26:49 2018
New Revision: 329869

URL: http://llvm.org/viewvc/llvm-project?rev=329869=rev
Log:
[ODRHash] Skip more types hashing TypedefType

To get the underlying type for TypedefType's, also skip ElaboratedType's.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=329869=329868=329869=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Wed Apr 11 19:26:49 2018
@@ -646,9 +646,19 @@ public:
 AddDecl(T->getDecl());
 QualType UnderlyingType = T->getDecl()->getUnderlyingType();
 VisitQualifiers(UnderlyingType.getQualifiers());
-while (const TypedefType *Underlying =
-   dyn_cast(UnderlyingType.getTypePtr())) {
-  UnderlyingType = Underlying->getDecl()->getUnderlyingType();
+while (true) {
+  if (const TypedefType *Underlying =
+  dyn_cast(UnderlyingType.getTypePtr())) {
+UnderlyingType = Underlying->getDecl()->getUnderlyingType();
+continue;
+  }
+  if (const ElaboratedType *Underlying =
+  dyn_cast(UnderlyingType.getTypePtr())) {
+UnderlyingType = Underlying->getNamedType();
+continue;
+  }
+
+  break;
 }
 AddType(UnderlyingType.getTypePtr());
 VisitType(T);

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=329869=329868=329869=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Wed Apr 11 19:26:49 2018
@@ -2744,6 +2744,38 @@ struct S3 {
 #else
 S3 s3;
 #endif
+
+#if defined(FIRST)
+using A4 = int;
+using B4 = A4;
+struct S4 {
+  B4 x;
+};
+#elif defined(SECOND)
+using A4 = int;
+using B4 = ::MultipleTypedefs::A4;
+struct S4 {
+  B4 x;
+};
+#else
+S4 s4;
+#endif
+
+#if defined(FIRST)
+using A5 = int;
+using B5 = MultipleTypedefs::A5;
+struct S5 {
+  B5 x;
+};
+#elif defined(SECOND)
+using A5 = int;
+using B5 = ::MultipleTypedefs::A5;
+struct S5 {
+  B5 x;
+};
+#else
+S5 s5;
+#endif
 }  // MultipleTypedefs
 
 namespace DefaultArguments {


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


[PATCH] D45529: [CMake] Set the default ABI version for Fuchsia in CMake as well

2018-04-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

ping?


Repository:
  rCXX libc++

https://reviews.llvm.org/D45529



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


r329866 - Lex: make `clang::Preprocessor::macros` work on MSVC

2018-04-11 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Apr 11 16:47:25 2018
New Revision: 329866

URL: http://llvm.org/viewvc/llvm-project?rev=329866=rev
Log:
Lex: make `clang::Preprocessor::macros` work on MSVC

The order of argument construction is reversed on MS ABI on Windows.
When `macros` was invoked, the `end` call is made prior to `begin`.  In
such a case, the DenseMap (`ModuleMap`) is populated after the `end`
iterator is constructed.  This reversal results in the invalidation of
the end iterator, resulting in a failure at runtime (assertion failure
in `DenseMap::operator!=` that "handles are not in sync!").  Ensure
that the end iterator is constructed after the begin iterator.  This
fixes the use of `macros(bool)`, which symptomized as an assertion
failure in the swift compiler in the clang importer.

Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=329866=329865=329866=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Apr 11 16:47:25 2018
@@ -1041,12 +1041,14 @@ public:
 
   macro_iterator macro_begin(bool IncludeExternalMacros = true) const;
   macro_iterator macro_end(bool IncludeExternalMacros = true) const;
-  llvm::iterator_range
 
+  llvm::iterator_range
   macros(bool IncludeExternalMacros = true) const {
-return llvm::make_range(macro_begin(IncludeExternalMacros),
-macro_end(IncludeExternalMacros));
+macro_iterator begin = macro_begin(IncludeExternalMacros);
+macro_iterator end = macro_end(IncludeExternalMacros);
+return llvm::make_range(begin, end);
   }
+
   /// \}
 
   /// \brief Return the name of the macro defined before \p Loc that has


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


[PATCH] D45544: [AAch64] Add the __ARM_FEATURE_DOTPROD macro definition

2018-04-11 Thread Junmo Park via Phabricator via cfe-commits
flyingforyou created this revision.
flyingforyou added a reviewer: SjoerdMeijer.
Herald added subscribers: kristof.beyls, javed.absar.

This matches what GCC does.
https://github.com/gcc-mirror/gcc/blob/master/gcc/config/aarch64/aarch64-c.c


https://reviews.llvm.org/D45544

Files:
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/AArch64.h
  test/Preprocessor/aarch64-target-features.c


Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -89,6 +89,10 @@
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE %s
 // CHECK-SVE: __ARM_FEATURE_SVE 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.2a+dotprod -x c -E
+// -dM %s -o - | FileCheck --check-prefix=CHECK-DOTPROD %s
+// CHECK-DOTPROD: __ARM_FEATURE_DOTPROD 1
+
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2a+fp16 -x c -E 
-dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
Index: lib/Basic/Targets/AArch64.h
===
--- lib/Basic/Targets/AArch64.h
+++ lib/Basic/Targets/AArch64.h
@@ -33,6 +33,7 @@
   unsigned Crypto;
   unsigned Unaligned;
   unsigned HasFullFP16;
+  unsigned HasDotProd;
   llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -193,6 +193,9 @@
   if (HasFullFP16)
Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1");
 
+  if (HasDotProd)
+Builder.defineMacro("__ARM_FEATURE_DOTPROD", "1");
+
   switch (ArchKind) {
   default:
 break;
@@ -248,6 +251,8 @@
   ArchKind = llvm::AArch64::ArchKind::ARMV8_2A;
 if (Feature == "+fullfp16")
   HasFullFP16 = 1;
+if (Feature == "+dotprod")
+  HasDotProd = 1;
   }
 
   setDataLayout();


Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -89,6 +89,10 @@
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE %s
 // CHECK-SVE: __ARM_FEATURE_SVE 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.2a+dotprod -x c -E
+// -dM %s -o - | FileCheck --check-prefix=CHECK-DOTPROD %s
+// CHECK-DOTPROD: __ARM_FEATURE_DOTPROD 1
+
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2a+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
Index: lib/Basic/Targets/AArch64.h
===
--- lib/Basic/Targets/AArch64.h
+++ lib/Basic/Targets/AArch64.h
@@ -33,6 +33,7 @@
   unsigned Crypto;
   unsigned Unaligned;
   unsigned HasFullFP16;
+  unsigned HasDotProd;
   llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -193,6 +193,9 @@
   if (HasFullFP16)
Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1");
 
+  if (HasDotProd)
+Builder.defineMacro("__ARM_FEATURE_DOTPROD", "1");
+
   switch (ArchKind) {
   default:
 break;
@@ -248,6 +251,8 @@
   ArchKind = llvm::AArch64::ArchKind::ARMV8_2A;
 if (Feature == "+fullfp16")
   HasFullFP16 = 1;
+if (Feature == "+dotprod")
+  HasDotProd = 1;
   }
 
   setDataLayout();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

2018-04-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D45015#1064922, @vsapsai wrote:

> Another approach is `__has_feature` but I don't think it is applicable in 
> this case.
>
> Is there a way right now to detect that aligned allocation is supported by 
> clang, regardless of link time? Asking to make sure we are consistent.


There is a C++ feature test macro, as specified by the standard, 
`__cpp_aligned_new`.  But I'm not sure how to be consistent with that.


Repository:
  rC Clang

https://reviews.llvm.org/D45015



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


[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

2018-04-11 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Another approach is `__has_feature` but I don't think it is applicable in this 
case.

Is there a way right now to detect that aligned allocation is supported by 
clang, regardless of link time? Asking to make sure we are consistent.


Repository:
  rC Clang

https://reviews.llvm.org/D45015



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


[PATCH] D44130: Driver: Add gcc search path for RHEL devtoolset-7

2018-04-11 Thread Tom Stellard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329854: Driver:  Add gcc search path for RHEL devtoolset-7 
(authored by tstellar, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44130

Files:
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -1785,6 +1785,7 @@
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL devtoolsets.
+Prefixes.push_back("/opt/rh/devtoolset-7/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -1785,6 +1785,7 @@
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL devtoolsets.
+Prefixes.push_back("/opt/rh/devtoolset-7/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41938: [Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

2018-04-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

We've found a crash on our internal buildbot, would you like to have a look?:

**`$ cat repro.c`**

  int foo(int x, int y) {
short a = x - 1U;
return a - y;
  }

**`$ clang -cc1 -analyze -analyzer-checker=core repro.c`**

  Assertion failed: (APSIntType(LInt) == BV.getAPSIntType(SymTy) && "Integers 
are not of the same type as symbols!"), function doRearrangeUnchecked, file 
/Users/adergachev/llvm/tools/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp,
 line 383.

`1U` can be replaced with `1L` or `1UL`.


Repository:
  rL LLVM

https://reviews.llvm.org/D41938



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


r329854 - Driver: Add gcc search path for RHEL devtoolset-7

2018-04-11 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Apr 11 15:29:35 2018
New Revision: 329854

URL: http://llvm.org/viewvc/llvm-project?rev=329854=rev
Log:
Driver:  Add gcc search path for RHEL devtoolset-7

Reviewers: bruno

Reviewed By: bruno

Subscribers: bruno, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=329854=329853=329854=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Apr 11 15:29:35 2018
@@ -1785,6 +1785,7 @@ void Generic_GCC::GCCInstallationDetecto
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL devtoolsets.
+Prefixes.push_back("/opt/rh/devtoolset-7/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");


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


Re: [PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-04-11 Thread Chih-hung Hsieh via cfe-commits
Should we have two versions of `__gcov_flush`?

One version is visible outside a .so file,
we use dlsym to find and call it to dump
profile data of .so files, like Android.

One version is hidden and must be called from another
wrapper function in a .so file. An application that
wants to flush .so file profile data will need to call
those wrapper functions.


On Wed, Apr 11, 2018 at 12:31 PM, Xinliang David Li 
wrote:

>
>
> On Wed, Apr 11, 2018 at 11:31 AM, Chih-Hung Hsieh via Phabricator via
> llvm-commits  wrote:
>
>> chh added a comment.
>>
>> Yes, calling `__gcov_flush` within .so files are different,
>> but it's a revert of https://reviews.llvm.org/D38124.
>> I think  https://bugs.llvm.org/show_bug.cgi?id=27224
>> can be fixed by hiding only llvm_gcda_* functions,
>> without any change to `__gcov_flush`.
>>
>>
> The coverage dumping behavior for shared libraries (not dlopened) was also
> wrong before D38124. D38124 fixed the crash as well as the dumping bug.
>
> David
>
>
>
>
>
>> (1) Before https://reviews.llvm.org/D38124:
>>
>> - Calling `__gcov_flush` within .so or main function dumps to main gcda
>> file.
>> - Android's dlsym() lookup/call of `__gcov_flush` dumps to .so file
>> specific gcda files.
>>
>> (2) After https://reviews.llvm.org/D38124:
>>
>> - Android's dlsym() cannot find/call `__gcov_flush`.
>> - Calling `__gcov_flush` from main works as in (1).
>> - Calling `__gcov_flush` from .so works differently; it will dump to .so
>> specific gcda file, not the main one.
>>
>> (3) With this change, we revert `__gcov_flush` behavior back to (1).
>>
>> Is there any application that needs to call `__gcov_flush` within .so
>> and expects the output to .so specific gcda file like in (2)?
>> I think the behavior of (1) is more desirable.
>> If a main program wants to dump to .so specific gcda file, like Android,
>> it can use dlsym() to look up .so specific `__gcov_flush`.
>>
>>
>> https://reviews.llvm.org/D45454
>>
>>
>>
>> ___
>> llvm-commits mailing list
>> llvm-comm...@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2018-04-11 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Apr 11 13:57:28 2018
New Revision: 329851

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

Modified:
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/Module.cpp

Modified: cfe/trunk/include/clang/Serialization/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=329851=329850=329851=diff
==
--- cfe/trunk/include/clang/Serialization/Module.h (original)
+++ cfe/trunk/include/clang/Serialization/Module.h Wed Apr 11 13:57:28 2018
@@ -1,4 +1,4 @@
-//===--- Module.h - Module description --*- C++ 
-*-===//
+//===- Module.h - Module description *- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -15,42 +15,49 @@
 #ifndef LLVM_CLANG_SERIALIZATION_MODULE_H
 #define LLVM_CLANG_SERIALIZATION_MODULE_H
 
-#include "clang/Basic/FileManager.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ContinuousRangeMap.h"
 #include "clang/Serialization/ModuleFileExtension.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Bitcode/BitstreamReader.h"
 #include "llvm/Support/Endian.h"
+#include 
+#include 
 #include 
 #include 
-
-namespace llvm {
-template  class OnDiskChainedHashTable;
-template  class OnDiskIterableChainedHashTable;
-}
+#include 
 
 namespace clang {
 
-class DeclContext;
-class Module;
+class FileEntry;
 
 namespace serialization {
 
-namespace reader {
-  class ASTDeclContextNameLookupTrait;
-}
-
 /// \brief Specifies the kind of module that has been loaded.
 enum ModuleKind {
-  MK_ImplicitModule, ///< File is an implicitly-loaded module.
-  MK_ExplicitModule, ///< File is an explicitly-loaded module.
-  MK_PCH,///< File is a PCH file treated as such.
-  MK_Preamble,   ///< File is a PCH file treated as the preamble.
-  MK_MainFile,   ///< File is a PCH file treated as the actual main file.
-  MK_PrebuiltModule  ///< File is from a prebuilt module path.
+  /// File is an implicitly-loaded module.
+  MK_ImplicitModule,
+
+  /// File is an explicitly-loaded module.
+  MK_ExplicitModule,
+
+  /// File is a PCH file treated as such.
+  MK_PCH,
+
+  /// File is a PCH file treated as the preamble.
+  MK_Preamble,
+
+  /// File is a PCH file treated as the actual main file.
+  MK_MainFile,
+
+  /// File is from a prebuilt module path.
+  MK_PrebuiltModule
 };
 
 /// \brief The input file that has been loaded from this AST file, along with
@@ -65,7 +72,8 @@ class InputFile {
   llvm::PointerIntPair Val;
 
 public:
-  InputFile() {}
+  InputFile() = default;
+
   InputFile(const FileEntry *File,
 bool isOverridden = false, bool isOutOfDate = false) {
 assert(!(isOverridden && isOutOfDate) &&
@@ -205,6 +213,7 @@ public:
   StringRef ModuleOffsetMap;
 
   // === Input Files ===
+
   /// \brief The cursor to the start of the input-files block.
   llvm::BitstreamCursor InputFilesCursor;
 
@@ -347,6 +356,7 @@ public:
   void *HeaderFileInfoTable = nullptr;
 
   // === Submodule information ===  
+
   /// \brief The number of submodules in this module.
   unsigned LocalNumSubmodules = 0;
   
@@ -470,8 +480,8 @@ public:
   void dump();
 };
 
-} // end namespace serialization
+} // namespace serialization
 
-} // end namespace clang
+} // namespace clang
 
-#endif
+#endif // LLVM_CLANG_SERIALIZATION_MODULE_H

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=329851=329850=329851=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Apr 11 13:57:28 2018
@@ -1,4 +1,4 @@
-//===--- ASTReaderDecl.cpp - Decl Deserialization ---*- C++ 
-*-===//
+//===- ASTReaderDecl.cpp - Decl Deserialization 
---===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -15,42 +15,89 @@
 #include "ASTCommon.h"
 #include "ASTReaderInternals.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/AttrIterator.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclGroup.h"
+#include "clang/AST/DeclFriend.h"
+#include "clang/AST/DeclObjC.h"
+#include "clang/AST/DeclOpenMP.h"
 #include 

[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2018-04-11 Thread Erik Nyquist via Phabricator via cfe-commits
enyquist added a comment.

As far as I know, there are no updates required from me for this pull request-- 
I rebased on the main trunk recently, and will do it again tonight to be sure. 
So it should be compiling/working just fine.
I believe it is just awaiting final approval from somebody.


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



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


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D45532#1064685, @Szelethus wrote:

> In https://reviews.llvm.org/D45532#1064670, @Szelethus wrote:
>
> > I wasn't too clear on this one: unknown fields are regarded as 
> > uninitialized, what I wrote was a temporary change in the code so I could 
> > check whether it would work.
>
>
> Woops, I meant that unknown fields are regarded az initialized.


Aha, yep, that makes a lot more sense =)


https://reviews.llvm.org/D45532



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


[PATCH] D43817: [x86] wbnoinvd intrinsic

2018-04-11 Thread Gabor Buella via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329848: [x86] wbnoinvd intrinsic (authored by GBuella, 
committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D43817

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/Headers/CMakeLists.txt
  lib/Headers/cpuid.h
  lib/Headers/wbnoinvdintrin.h
  lib/Headers/x86intrin.h
  test/CodeGen/builtin-wbnoinvd.c
  test/CodeGen/builtins-x86.c
  test/Driver/x86-target-features.c
  test/Preprocessor/predefined-arch-macros.c

Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -2484,6 +2484,8 @@
 
 .. option:: -mvpclmulqdq, -mno-vpclmulqdq
 
+.. option:: -mwbnoinvd, -mno-wbnoinvd
+
 .. option:: -mx87, -m80387, -mno-x87
 
 .. option:: -mxop, -mno-xop
Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -679,6 +679,9 @@
 //CLWB
 TARGET_BUILTIN(__builtin_ia32_clwb, "vvC*", "", "clwb")
 
+//WBNOINVD
+TARGET_BUILTIN(__builtin_ia32_wbnoinvd, "v", "", "wbnoinvd")
+
 // ADX
 TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
 TARGET_BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "", "")
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2598,6 +2598,8 @@
 def mno_clflushopt : Flag<["-"], "mno-clflushopt">, Group;
 def mclwb : Flag<["-"], "mclwb">, Group;
 def mno_clwb : Flag<["-"], "mno-clwb">, Group;
+def mwbnoinvd : Flag<["-"], "mwbnoinvd">, Group;
+def mno_wbnoinvd : Flag<["-"], "mno-wbnoinvd">, Group;
 def mclzero : Flag<["-"], "mclzero">, Group;
 def mno_clzero : Flag<["-"], "mno-clzero">, Group;
 def mcx16 : Flag<["-"], "mcx16">, Group;
Index: test/CodeGen/builtin-wbnoinvd.c
===
--- test/CodeGen/builtin-wbnoinvd.c
+++ test/CodeGen/builtin-wbnoinvd.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +wbnoinvd -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+void test_wbnoinvd(void) {
+  //CHECK-LABEL: @test_wbnoinvd
+  //CHECK: call void @llvm.x86.wbnoinvd()
+  _wbnoinvd();
+}
Index: test/CodeGen/builtins-x86.c
===
--- test/CodeGen/builtins-x86.c
+++ test/CodeGen/builtins-x86.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +clzero -target-feature +ibt -target-feature +shstk -emit-llvm -o %t %s
-// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +ibt -target-feature +shstk -target-feature +clzero -fsyntax-only -o %t %s
+// RUN: %clang_cc1 -DUSE_64 -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +clzero -target-feature +ibt -target-feature +shstk -target-feature +wbnoinvd -emit-llvm -o %t %s
+// RUN: %clang_cc1 -DUSE_ALL -triple x86_64-unknown-unknown -target-feature +fxsr -target-feature +avx -target-feature +xsaveopt -target-feature +xsaves -target-feature +xsavec -target-feature +mwaitx -target-feature +ibt -target-feature +shstk -target-feature +clzero -target-feature +wbnoinvd -fsyntax-only -o %t %s
 
 #ifdef USE_ALL
 #define USE_3DNOW
@@ -305,6 +305,7 @@
   tmp_i = __rdtsc();
   tmp_i = __builtin_ia32_rdtscp(_Ui);
   tmp_LLi = __builtin_ia32_rdpmc(tmp_i);
+  __builtin_ia32_wbnoinvd();
 #ifdef USE_64
   tmp_LLi = __builtin_ia32_cvtss2si64(tmp_V4f);
   tmp_LLi = __builtin_ia32_cvttss2si64(tmp_V4f);
Index: test/Driver/x86-target-features.c
===
--- test/Driver/x86-target-features.c
+++ test/Driver/x86-target-features.c
@@ -60,6 +60,11 @@
 // CLWB: "-target-feature" "+clwb"
 // NO-CLWB: "-target-feature" "-clwb"
 
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mwbnoinvd %s -### -o %t.o 2>&1 | FileCheck -check-prefix=WBNOINVD %s
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-wbnoinvd %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-WBNOINVD %s
+// WBNOINVD: "-target-feature" "+wbnoinvd"
+// NO-WBNOINVD: "-target-feature" "-wbnoinvd"
+
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mmovbe %s 

Re: [PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-04-11 Thread Xinliang David Li via cfe-commits
On Wed, Apr 11, 2018 at 11:31 AM, Chih-Hung Hsieh via Phabricator via
llvm-commits  wrote:

> chh added a comment.
>
> Yes, calling `__gcov_flush` within .so files are different,
> but it's a revert of https://reviews.llvm.org/D38124.
> I think  https://bugs.llvm.org/show_bug.cgi?id=27224
> can be fixed by hiding only llvm_gcda_* functions,
> without any change to `__gcov_flush`.
>
>
The coverage dumping behavior for shared libraries (not dlopened) was also
wrong before D38124. D38124 fixed the crash as well as the dumping bug.

David





> (1) Before https://reviews.llvm.org/D38124:
>
> - Calling `__gcov_flush` within .so or main function dumps to main gcda
> file.
> - Android's dlsym() lookup/call of `__gcov_flush` dumps to .so file
> specific gcda files.
>
> (2) After https://reviews.llvm.org/D38124:
>
> - Android's dlsym() cannot find/call `__gcov_flush`.
> - Calling `__gcov_flush` from main works as in (1).
> - Calling `__gcov_flush` from .so works differently; it will dump to .so
> specific gcda file, not the main one.
>
> (3) With this change, we revert `__gcov_flush` behavior back to (1).
>
> Is there any application that needs to call `__gcov_flush` within .so
> and expects the output to .so specific gcda file like in (2)?
> I think the behavior of (1) is more desirable.
> If a main program wants to dump to .so specific gcda file, like Android,
> it can use dlsym() to look up .so specific `__gcov_flush`.
>
>
> https://reviews.llvm.org/D45454
>
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329843 - [OPENMP] Code cleanup, NFC.

2018-04-11 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr 11 12:21:00 2018
New Revision: 329843

URL: http://llvm.org/viewvc/llvm-project?rev=329843=rev
Log:
[OPENMP] Code cleanup, NFC.

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

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=329843=329842=329843=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Apr 11 12:21:00 2018
@@ -161,12 +161,12 @@ private:
   bool ForceCapturing = false;
   CriticalsWithHintsTy Criticals;
 
-  typedef SmallVector::reverse_iterator reverse_iterator;
+  typedef StackTy::reverse_iterator reverse_iterator;
 
-  DSAVarData getDSA(StackTy::reverse_iterator , ValueDecl *D);
+  DSAVarData getDSA(reverse_iterator , ValueDecl *D);
 
   /// \brief Checks if the variable is a local for OpenMP region.
-  bool isOpenMPLocal(VarDecl *D, StackTy::reverse_iterator Iter);
+  bool isOpenMPLocal(VarDecl *D, reverse_iterator Iter);
 
   bool isStackEmpty() const {
 return Stack.empty() ||
@@ -300,35 +300,36 @@ public:
   /// match specified \a CPred predicate in any directive which matches \a 
DPred
   /// predicate.
   DSAVarData hasDSA(ValueDecl *D,
-const llvm::function_ref ,
-const llvm::function_ref ,
+const llvm::function_ref CPred,
+const llvm::function_ref DPred,
 bool FromParent);
   /// \brief Checks if the specified variables has data-sharing attributes 
which
   /// match specified \a CPred predicate in any innermost directive which
   /// matches \a DPred predicate.
   DSAVarData
   hasInnermostDSA(ValueDecl *D,
-  const llvm::function_ref ,
-  const llvm::function_ref ,
+  const llvm::function_ref CPred,
+  const llvm::function_ref DPred,
   bool FromParent);
   /// \brief Checks if the specified variables has explicit data-sharing
   /// attributes which match specified \a CPred predicate at the specified
   /// OpenMP region.
   bool hasExplicitDSA(ValueDecl *D,
-  const llvm::function_ref ,
+  const llvm::function_ref CPred,
   unsigned Level, bool NotLastprivate = false);
 
   /// \brief Returns true if the directive at level \Level matches in the
   /// specified \a DPred predicate.
   bool hasExplicitDirective(
-  const llvm::function_ref ,
+  const llvm::function_ref DPred,
   unsigned Level);
 
   /// \brief Finds a directive which matches specified \a DPred predicate.
-  bool hasDirective(const llvm::function_ref ,
-bool FromParent);
+  bool hasDirective(
+  const llvm::function_ref
+  DPred,
+  bool FromParent);
 
   /// \brief Returns currently analyzed directive.
   OpenMPDirectiveKind getCurrentDirective() const {
@@ -479,7 +480,8 @@ public:
   ValueDecl *VD, bool CurrentRegionOnly,
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
-   OpenMPClauseKind)> ) {
+   OpenMPClauseKind)>
+  Check) {
 if (isStackEmpty())
   return false;
 auto SI = Stack.back().first.rbegin();
@@ -510,7 +512,8 @@ public:
   ValueDecl *VD, unsigned Level,
   const llvm::function_ref<
   bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
-   OpenMPClauseKind)> ) {
+   OpenMPClauseKind)>
+  Check) {
 if (isStackEmpty())
   return false;
 
@@ -603,7 +606,7 @@ static ValueDecl *getCanonicalDecl(Value
   return D;
 }
 
-DSAStackTy::DSAVarData DSAStackTy::getDSA(StackTy::reverse_iterator ,
+DSAStackTy::DSAVarData DSAStackTy::getDSA(reverse_iterator ,
   ValueDecl *D) {
   D = getCanonicalDecl(D);
   auto *VD = dyn_cast(D);
@@ -939,7 +942,7 @@ DSAStackTy::getTopMostTaskgroupReduction
   return DSAVarData();
 }
 
-bool DSAStackTy::isOpenMPLocal(VarDecl *D, StackTy::reverse_iterator Iter) {
+bool DSAStackTy::isOpenMPLocal(VarDecl *D, reverse_iterator Iter) {
   D = D->getCanonicalDecl();
   if (!isStackEmpty()) {
 reverse_iterator I = Iter, E = Stack.back().first.rend();
@@ -1100,7 +1103,7 @@ 

[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

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

In https://reviews.llvm.org/D45532#1064670, @Szelethus wrote:

> I wasn't too clear on this one: unknown fields are regarded as uninitialized, 
> what I wrote was a temporary change in the code so I could check whether it 
> would work.


Woops, I meant that unknown fields are regarded az initialized.


https://reviews.llvm.org/D45532



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


[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-11 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added inline comments.



Comment at: test/clang-tidy/readability-identifier-naming-objc.m:8-9
+// RUN:   ]}' -- -fno-delayed-template-parsing \
+// RUN:   -I%S/Inputs/readability-identifier-naming \
+// RUN:   -isystem %S/Inputs/readability-identifier-naming/system
+

alexfh wrote:
> It looks like these flags are not needed, since there are no #include 
> directives in this test.
So we won't worry about those flags when using this check in google codebase 
right?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-11 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 142057.
Wizard added a comment.

remove unnecessary flags


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming-objc.m


Index: test/clang-tidy/readability-identifier-naming-objc.m
===
--- /dev/null
+++ test/clang-tidy/readability-identifier-naming-objc.m
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s readability-identifier-naming %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}]}' \
+// RUN: --
+
+@interface Foo
+@end 
+
+@interface Foo () {
+int _bar;
+int barWithoutPrefix;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc 
ivar 'barWithoutPrefix' [readability-identifier-naming]
+// CHECK-FIXES: int _barWithoutPrefix;
+}
+@end
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -109,6 +109,7 @@
 m(TemplateParameter) \
 m(TypeAlias) \
 m(MacroDefinition) \
+m(ObjcIvar) \
 
 enum StyleKind {
 #define ENUMERATE(v) SK_ ## v,
@@ -384,6 +385,9 @@
 const NamedDecl *D,
 const std::vector
 ) {
+  if (isa(D) && NamingStyles[SK_ObjcIvar])
+return SK_ObjcIvar;
+
   if (isa(D) && NamingStyles[SK_Typedef])
 return SK_Typedef;
 


Index: test/clang-tidy/readability-identifier-naming-objc.m
===
--- /dev/null
+++ test/clang-tidy/readability-identifier-naming-objc.m
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s readability-identifier-naming %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}]}' \
+// RUN: --
+
+@interface Foo
+@end 
+
+@interface Foo () {
+int _bar;
+int barWithoutPrefix;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for objc ivar 'barWithoutPrefix' [readability-identifier-naming]
+// CHECK-FIXES: int _barWithoutPrefix;
+}
+@end
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -109,6 +109,7 @@
 m(TemplateParameter) \
 m(TypeAlias) \
 m(MacroDefinition) \
+m(ObjcIvar) \
 
 enum StyleKind {
 #define ENUMERATE(v) SK_ ## v,
@@ -384,6 +385,9 @@
 const NamedDecl *D,
 const std::vector
 ) {
+  if (isa(D) && NamingStyles[SK_ObjcIvar])
+return SK_ObjcIvar;
+
   if (isa(D) && NamingStyles[SK_Typedef])
 return SK_Typedef;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Ok, thanks, looking forward to it!




Comment at: test/Analysis/ctor-uninitialized-member.cpp:869
+void f44() {
+  ContainsUnionWithSimpleUnionTest2(); // xpected-warning{{1 uninitialized 
field}}
+}

Szelethus wrote:
> NoQ wrote:
> > Hmm, shouldn't it say "expected"? Do these tests actually work?
> Since unions are not yet supported by the CSA, this is only what would be 
> expected from this checker to find in the future. I purposely wrote 'xpected' 
> so tests wouldn't break.
Aha, okay, got it. The tradition is to say "// no-warning" and then put a FIXME 
nearby saying that it should warn, how it should warn, probably why it should 
warn, if it's non-obvious.


https://reviews.llvm.org/D45532



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


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

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

In https://reviews.llvm.org/D45532#1064652, @NoQ wrote:

> > In most cases, all fields of a union is regarded as unknown. I checked 
> > these cases by regarding unknown fields as uninitialized.
>
> The whole point of making them unknown, as far as i understand, was to 
> suppress uninitialized field warnings. So i feel what we're doing here is a 
> bit upside down.


I wasn't too clear on this one: unknown fields are regarded as uninitialized, 
what I wrote was a temporary change in the code so I could check whether it 
would work.

I agree with you regarding unions, and will remove the code that relies on non 
existing implementation.


https://reviews.llvm.org/D45532



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


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-11 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: test/Analysis/ctor-uninitialized-member.cpp:869
+void f44() {
+  ContainsUnionWithSimpleUnionTest2(); // xpected-warning{{1 uninitialized 
field}}
+}

NoQ wrote:
> Hmm, shouldn't it say "expected"? Do these tests actually work?
Since unions are not yet supported by the CSA, this is only what would be 
expected from this checker to find in the future. I purposely wrote 'xpected' 
so tests wouldn't break.


https://reviews.llvm.org/D45532



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


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

That's a lot of code, so it'll take me some time to understand what's going on 
here. You might be able to help me by the large patch in smaller logical chunks.

The idea looks reasonable. We're having specific warnings for, eg., assigning 
an uninitialized value, which fire much more often now that we have proper 
constructor support (eg. they'll fire in the copy constructor when the value 
was not initialized in the "actual" constructor). While some bugs can be found 
this way, i agree that it's not the best way to find them.

That said, your checker finds non-bugs, which is always risky. Sometimes the 
user should be allowed to initialize the field after construction but before 
the first use as a potentially important performance optimization. Did you find 
any such intentionally uninitialized fields with your checker? Were there many 
of those? If a user wants to have his codebase "analyzer-clean", would he be 
able to suppress the warning without changing the behavior of the program?

If union support is causing problems and you have a lot of workaround in the 
checker for these problems, i'll definitely suggest removing these workarounds 
from the initial commit and replacing them with FIXME comments (even if it 
assumes completely suppressing all warnings on classes that mention unions 
anywhere in the chain) because i'd much rather move towards better modeling in 
RegionStore than having checkers work around that. You might also be interested 
in https://reviews.llvm.org/D45241.

> In most cases, all fields of a union is regarded as unknown. I checked these 
> cases by regarding unknown fields as uninitialized.

The whole point of making them unknown, as far as i understand, was to suppress 
uninitialized field warnings. So i feel what we're doing here is a bit upside 
down.




Comment at: test/Analysis/ctor-uninitialized-member.cpp:683
+// Note that the rules for unions are different in C++ and C.
+// http://lists.llvm.org/pipermail/cfe-dev/242017-March/42052912.html
+

I managed to find the thread, but this link doesn't work for me.



Comment at: test/Analysis/ctor-uninitialized-member.cpp:869
+void f44() {
+  ContainsUnionWithSimpleUnionTest2(); // xpected-warning{{1 uninitialized 
field}}
+}

Hmm, shouldn't it say "expected"? Do these tests actually work?


https://reviews.llvm.org/D45532



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


[PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-04-11 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh added a comment.

Yes, calling `__gcov_flush` within .so files are different,
but it's a revert of https://reviews.llvm.org/D38124.
I think  https://bugs.llvm.org/show_bug.cgi?id=27224
can be fixed by hiding only llvm_gcda_* functions,
without any change to `__gcov_flush`.

(1) Before https://reviews.llvm.org/D38124:

- Calling `__gcov_flush` within .so or main function dumps to main gcda file.
- Android's dlsym() lookup/call of `__gcov_flush` dumps to .so file specific 
gcda files.

(2) After https://reviews.llvm.org/D38124:

- Android's dlsym() cannot find/call `__gcov_flush`.
- Calling `__gcov_flush` from main works as in (1).
- Calling `__gcov_flush` from .so works differently; it will dump to .so 
specific gcda file, not the main one.

(3) With this change, we revert `__gcov_flush` behavior back to (1).

Is there any application that needs to call `__gcov_flush` within .so
and expects the output to .so specific gcda file like in (2)?
I think the behavior of (1) is more desirable.
If a main program wants to dump to .so specific gcda file, like Android,
it can use dlsym() to look up .so specific `__gcov_flush`.


https://reviews.llvm.org/D45454



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


[PATCH] D45523: [CodeGen] Handle __func__ inside __finally

2018-04-11 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329836: [CodeGen] Handle __func__ inside __finally (authored 
by smeenai, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45523

Files:
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/test/CodeGen/exceptions-seh-finally.c


Index: cfe/trunk/test/CodeGen/exceptions-seh-finally.c
===
--- cfe/trunk/test/CodeGen/exceptions-seh-finally.c
+++ cfe/trunk/test/CodeGen/exceptions-seh-finally.c
@@ -268,6 +268,18 @@
 // CHECK-LABEL: define internal void 
@"?fin$1@0@finally_within_finally@@"({{[^)]*}})
 // CHECK-SAME: [[finally_attrs]]
 
+void cleanup_with_func(const char *);
+void finally_with_func() {
+  __try {
+might_crash();
+  } __finally {
+cleanup_with_func(__func__);
+  }
+}
+
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+
 // Look for the absence of noinline. Enum attributes come first, so check that
 // a string attribute is the first to verify that no enum attributes are
 // present.
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -2611,7 +2611,7 @@
   StringRef NameItems[] = {
   PredefinedExpr::getIdentTypeName(E->getIdentType()), FnName};
   std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
-  if (auto *BD = dyn_cast(CurCodeDecl)) {
+  if (auto *BD = dyn_cast_or_null(CurCodeDecl)) {
 std::string Name = SL->getString();
 if (!Name.empty()) {
   unsigned Discriminator =


Index: cfe/trunk/test/CodeGen/exceptions-seh-finally.c
===
--- cfe/trunk/test/CodeGen/exceptions-seh-finally.c
+++ cfe/trunk/test/CodeGen/exceptions-seh-finally.c
@@ -268,6 +268,18 @@
 // CHECK-LABEL: define internal void @"?fin$1@0@finally_within_finally@@"({{[^)]*}})
 // CHECK-SAME: [[finally_attrs]]
 
+void cleanup_with_func(const char *);
+void finally_with_func() {
+  __try {
+might_crash();
+  } __finally {
+cleanup_with_func(__func__);
+  }
+}
+
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+
 // Look for the absence of noinline. Enum attributes come first, so check that
 // a string attribute is the first to verify that no enum attributes are
 // present.
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -2611,7 +2611,7 @@
   StringRef NameItems[] = {
   PredefinedExpr::getIdentTypeName(E->getIdentType()), FnName};
   std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
-  if (auto *BD = dyn_cast(CurCodeDecl)) {
+  if (auto *BD = dyn_cast_or_null(CurCodeDecl)) {
 std::string Name = SL->getString();
 if (!Name.empty()) {
   unsigned Discriminator =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329836 - [CodeGen] Handle __func__ inside __finally

2018-04-11 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Wed Apr 11 11:17:35 2018
New Revision: 329836

URL: http://llvm.org/viewvc/llvm-project?rev=329836=rev
Log:
[CodeGen] Handle __func__ inside __finally

When we enter a __finally block, the CGF's CurCodeDecl will be null
(because CodeGenFunction::StartFunction is given an empty GlobalDecl for
a __finally block), and so the dyn_cast here will result in an assertion
failure. Change it to dyn_cast_or_null to handle this case.

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

Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGen/exceptions-seh-finally.c

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=329836=329835=329836=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Apr 11 11:17:35 2018
@@ -2611,7 +2611,7 @@ LValue CodeGenFunction::EmitPredefinedLV
   StringRef NameItems[] = {
   PredefinedExpr::getIdentTypeName(E->getIdentType()), FnName};
   std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
-  if (auto *BD = dyn_cast(CurCodeDecl)) {
+  if (auto *BD = dyn_cast_or_null(CurCodeDecl)) {
 std::string Name = SL->getString();
 if (!Name.empty()) {
   unsigned Discriminator =

Modified: cfe/trunk/test/CodeGen/exceptions-seh-finally.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh-finally.c?rev=329836=329835=329836=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh-finally.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh-finally.c Wed Apr 11 11:17:35 2018
@@ -268,6 +268,18 @@ void finally_within_finally() {
 // CHECK-LABEL: define internal void 
@"?fin$1@0@finally_within_finally@@"({{[^)]*}})
 // CHECK-SAME: [[finally_attrs]]
 
+void cleanup_with_func(const char *);
+void finally_with_func() {
+  __try {
+might_crash();
+  } __finally {
+cleanup_with_func(__func__);
+  }
+}
+
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+
 // Look for the absence of noinline. Enum attributes come first, so check that
 // a string attribute is the first to verify that no enum attributes are
 // present.


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


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-11 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 142053.
Szelethus added a comment.

Reuploaded the diff with full context.


https://reviews.llvm.org/D45532

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp
  test/Analysis/ctor-uninitialized-member-inheritance.cpp
  test/Analysis/ctor-uninitialized-member.cpp

Index: test/Analysis/ctor-uninitialized-member.cpp
===
--- /dev/null
+++ test/Analysis/ctor-uninitialized-member.cpp
@@ -0,0 +1,870 @@
+//RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.CtorUninitializedMember -std=c++11 -verify %s
+
+//===--===//
+// Default constructor test.
+//===--===//
+
+class DefaultConstructorTest {
+  int a, b, c, d, e, f, g, h, i, j;
+
+public:
+  DefaultConstructorTest() = default;
+};
+
+void f00() {
+  DefaultConstructorTest();
+}
+
+//===--===//
+// Initializer list test.
+//===--===//
+
+class InitListTest1 {
+  int a;
+  int b;
+
+public:
+  InitListTest1()
+  : a(420),
+b(420) {
+// All good!
+  }
+};
+
+void f01() {
+  InitListTest1();
+}
+
+class InitListTest2 {
+  int a;
+  int b; // expected-note{{uninitialized field 'this->b'}}
+
+public:
+  InitListTest2()
+  : a(420) {} // expected-warning{{1 uninitialized field}}
+};
+
+void f02() {
+  InitListTest2();
+}
+
+class InitListTest3 {
+  int a; // expected-note{{uninitialized field 'this->a'}}
+  int b;
+
+public:
+  InitListTest3()
+  : b(420) {} // expected-warning{{1 uninitialized field}}
+};
+
+void f03() {
+  InitListTest3();
+}
+
+//===--===//
+// Constructor body test.
+//===--===//
+
+class CtorBodyTest1 {
+  int a, b;
+
+public:
+  CtorBodyTest1() {
+a = 420;
+b = 420;
+// All good!
+  }
+};
+
+void f04() {
+  CtorBodyTest1();
+}
+
+class CtorBodyTest2 {
+  int a;
+  int b; // expected-note{{uninitialized field 'this->b'}}
+
+public:
+  CtorBodyTest2() {
+a = 420; // expected-warning{{1 uninitialized field}}
+  }
+};
+
+void f05() {
+  CtorBodyTest2();
+}
+
+class CtorBodyTest3 {
+  int a; // expected-note{{uninitialized field 'this->a'}}
+  int b;
+
+public:
+  CtorBodyTest3() {
+b = 420; // expected-warning{{1 uninitialized field}}
+  }
+};
+
+void f06() {
+  CtorBodyTest3();
+}
+
+class CtorBodyTest4 {
+  int a; // expected-note{{uninitialized field 'this->a'}}
+  int b; // expected-note{{uninitialized field 'this->b'}}
+
+public:
+  CtorBodyTest4() {}
+};
+
+void f07() {
+  CtorBodyTest4(); // expected-warning{{2 uninitialized fields}}
+}
+
+//===--===//
+// Constructor delegation test.
+//===--===//
+
+class CtorDelegationTest1 {
+  int a;
+  int b;
+
+public:
+  CtorDelegationTest1(int)
+  : a(420) {
+// leaves 'b' unintialized, but we'll never check this function
+  }
+
+  CtorDelegationTest1()
+  : CtorDelegationTest1(int{}) { // Initializing 'a'
+b = 420;
+// All good!
+  }
+};
+
+void f08() {
+  CtorDelegationTest1();
+}
+
+class CtorDelegationTest2 {
+  int a; // expected-note{{uninitialized field 'this->a'}}
+  int b;
+
+public:
+  CtorDelegationTest2(int)
+  : b(420) {
+// leaves 'a' unintialized, but we'll never check this function
+  }
+
+  CtorDelegationTest2()
+  : CtorDelegationTest2(int{}) { // expected-warning{{1 uninitialized field}}
+  }
+};
+
+void f09() {
+  CtorDelegationTest2();
+}
+
+//===--===//
+// Tests for classes containing records.
+//===--===//
+
+class ContainsRecordTest1 {
+  struct RecordType {
+int x;
+int y;
+  } rec;
+  int c, d;
+
+public:
+  ContainsRecordTest1()
+  : rec({420, 420}),
+c(420),
+d(420) {
+// All good!
+  }
+};
+
+void f10() {
+  ContainsRecordTest1();
+}
+
+class ContainsRecordTest2 {
+  struct RecordType {
+int x;
+int y; // expected-note{{uninitialized field 'this->rec.y'}}
+  } rec;
+  int c, d;
+
+public:
+  ContainsRecordTest2()
+  : c(420),
+d(420) {
+rec.x = 420; // expected-warning{{1 uninitialized field}}
+  }
+};
+
+void f11() {
+  ContainsRecordTest2();
+}
+
+class ContainsRecordTest3 {
+  struct RecordType {
+int x; // expected-note{{uninitialized field 'this->rec.x'}}
+int y; // expected-note{{uninitialized field 'this->rec.y'}}
+  } rec;
+  

[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17

2018-04-11 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

In https://reviews.llvm.org/D45179#1064589, @lebedev.ri wrote:

> I'm waiting for @mclow.lists to have the final say re this differential.


Ack. :)

> So roughly:
> 
>   // NOTE: Do not use [[nodiscard]] in pre-C++17 mode
>   //   to avoid -Wc++17-extensions warning.
>   // And we can't use GCC's [[gnu::warn_unused_result]] and
>   // __attribute__((warn_unused_result)),
>   // because GCC does not silence them via (void) cast.
>   #if !defined(_LIBCPP_NODISCARD)
>   #  if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17
>   #define _LIBCPP_NODISCARD [[nodiscard]]
>   #  elif __has_cpp_attribute(clang::warn_unused_result)
>   #define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
>   #  else
>   #define _LIBCPP_NODISCARD
>   #  endif
>   #endif
> 
> 
> ?

Yes, that correctly expresses my intent. Personally I would write it like this 
to reduce the nesting and linecount:

  // NOTE: Do not use [[nodiscard]] in pre-C++17 mode
  //   to avoid -Wc++17-extensions warning.
  // And we can't use GCC's [[gnu::warn_unused_result]] and
  // __attribute__((warn_unused_result)),
  // because GCC does not silence them via (void) cast.
  #if defined(_LIBCPP_NODISCARD)
  #elif __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17
  #  define _LIBCPP_NODISCARD [[nodiscard]]
  #elif __has_cpp_attribute(clang::warn_unused_result)
  #  define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
  #else
  #  define _LIBCPP_NODISCARD
  #endif


Repository:
  rCXX libc++

https://reviews.llvm.org/D45179



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


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Please always upload all patches with full context (`-U9`)


Repository:
  rC Clang

https://reviews.llvm.org/D45532



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


[clang-tools-extra] r329833 - [Documentation] Fix formatting and order in Release Notes for recent changes in modernize-use-auto.

2018-04-11 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Wed Apr 11 11:03:57 2018
New Revision: 329833

URL: http://llvm.org/viewvc/llvm-project?rev=329833=rev
Log:
[Documentation] Fix formatting and order in Release Notes for recent changes in 
modernize-use-auto.

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=329833=329832=329833=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Apr 11 11:03:57 2018
@@ -57,11 +57,6 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- New option `MinTypeNameLength` for `modernize-use-auto` to limit the minimal
-  length of type names to be replaced with 'auto'. Use to skip replacing
-  short type names like 'int'/'bool' -> 'auto'. Default value is 5 which means
-  replace types with the name length >= 5 letters only (ex. double, unsigned).
-
 - New module `abseil` for checks related to the `Abseil `_
   library.
 
@@ -151,6 +146,13 @@ Improvements to clang-tidy
 
   Warns on construction of specific temporary objects in the Zircon kernel.
 
+- New option `MinTypeNameLength` for :doc:`modernize-use-auto
+  ` check to limit the minimal length of
+  type names to be replaced with ``auto``. Use to skip replacing short type
+  names like ``int``/``bool`` with ``auto``. Default value is 5 which means
+  replace types with the name length >= 5 letters only (ex. ``double``,
+  ``unsigned``).
+
 - New alias :doc:`hicpp-avoid-goto
   ` to :doc:`cppcoreguidelines-avoid-goto
   `

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst?rev=329833=329832=329833=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst Wed 
Apr 11 11:03:57 2018
@@ -197,9 +197,9 @@ Options
 
 .. option:: MinTypeNameLength
 
-   If the option is set to non-zero (default '5'), the check will ignore
-   type names having a length less than the option value.
-   The option affects expressions only, not iterators.
+   If the option is set to non-zero (default `5`), the check will ignore type
+   names having a length less than the option value. The option affects
+   expressions only, not iterators.
 
 .. code-block:: c++
 


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


[PATCH] D45532: [StaticAnalyzer] Checker to find uninitialized fields after a constructor call

2018-04-11 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, dkrupp, whisperity.
Herald added subscribers: cfe-commits, a.sidorin, rnkovacs, szepet, mgorny.
Herald added a reviewer: george.karpenkov.

This checker checks at the end of a constructor call whether all fields of the 
object were initialized.

Note that a significant portion of the code is for handling unions, for which 
there is very little support in the CSA. In most cases, all fields of a union 
is regarded as unknown. I checked these cases by regarding unknown fields as 
uninitialized.

The test files also contain checks for heap allocated objects, and heap regions 
are mostly conjured in the CSA, so the tests for them and unions should work 
theoretically, but its not 100%.


Repository:
  rC Clang

https://reviews.llvm.org/D45532

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CtorUninitializedMemberChecker.cpp
  test/Analysis/ctor-uninitialized-member-inheritance.cpp
  test/Analysis/ctor-uninitialized-member.cpp

Index: test/Analysis/ctor-uninitialized-member.cpp
===
--- /dev/null
+++ test/Analysis/ctor-uninitialized-member.cpp
@@ -0,0 +1,870 @@
+//RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.CtorUninitializedMember -std=c++11 -verify %s
+
+//===--===//
+// Default constructor test.
+//===--===//
+
+class DefaultConstructorTest {
+  int a, b, c, d, e, f, g, h, i, j;
+
+public:
+  DefaultConstructorTest() = default;
+};
+
+void f00() {
+  DefaultConstructorTest();
+}
+
+//===--===//
+// Initializer list test.
+//===--===//
+
+class InitListTest1 {
+  int a;
+  int b;
+
+public:
+  InitListTest1()
+  : a(420),
+b(420) {
+// All good!
+  }
+};
+
+void f01() {
+  InitListTest1();
+}
+
+class InitListTest2 {
+  int a;
+  int b; // expected-note{{uninitialized field 'this->b'}}
+
+public:
+  InitListTest2()
+  : a(420) {} // expected-warning{{1 uninitialized field}}
+};
+
+void f02() {
+  InitListTest2();
+}
+
+class InitListTest3 {
+  int a; // expected-note{{uninitialized field 'this->a'}}
+  int b;
+
+public:
+  InitListTest3()
+  : b(420) {} // expected-warning{{1 uninitialized field}}
+};
+
+void f03() {
+  InitListTest3();
+}
+
+//===--===//
+// Constructor body test.
+//===--===//
+
+class CtorBodyTest1 {
+  int a, b;
+
+public:
+  CtorBodyTest1() {
+a = 420;
+b = 420;
+// All good!
+  }
+};
+
+void f04() {
+  CtorBodyTest1();
+}
+
+class CtorBodyTest2 {
+  int a;
+  int b; // expected-note{{uninitialized field 'this->b'}}
+
+public:
+  CtorBodyTest2() {
+a = 420; // expected-warning{{1 uninitialized field}}
+  }
+};
+
+void f05() {
+  CtorBodyTest2();
+}
+
+class CtorBodyTest3 {
+  int a; // expected-note{{uninitialized field 'this->a'}}
+  int b;
+
+public:
+  CtorBodyTest3() {
+b = 420; // expected-warning{{1 uninitialized field}}
+  }
+};
+
+void f06() {
+  CtorBodyTest3();
+}
+
+class CtorBodyTest4 {
+  int a; // expected-note{{uninitialized field 'this->a'}}
+  int b; // expected-note{{uninitialized field 'this->b'}}
+
+public:
+  CtorBodyTest4() {}
+};
+
+void f07() {
+  CtorBodyTest4(); // expected-warning{{2 uninitialized fields}}
+}
+
+//===--===//
+// Constructor delegation test.
+//===--===//
+
+class CtorDelegationTest1 {
+  int a;
+  int b;
+
+public:
+  CtorDelegationTest1(int)
+  : a(420) {
+// leaves 'b' unintialized, but we'll never check this function
+  }
+
+  CtorDelegationTest1()
+  : CtorDelegationTest1(int{}) { // Initializing 'a'
+b = 420;
+// All good!
+  }
+};
+
+void f08() {
+  CtorDelegationTest1();
+}
+
+class CtorDelegationTest2 {
+  int a; // expected-note{{uninitialized field 'this->a'}}
+  int b;
+
+public:
+  CtorDelegationTest2(int)
+  : b(420) {
+// leaves 'a' unintialized, but we'll never check this function
+  }
+
+  CtorDelegationTest2()
+  : CtorDelegationTest2(int{}) { // expected-warning{{1 uninitialized field}}
+  }
+};
+
+void f09() {
+  CtorDelegationTest2();
+}
+
+//===--===//
+// Tests for classes containing records.
+//===--===//
+
+class ContainsRecordTest1 {
+  struct RecordType {
+int x;
+int y;
+  } rec;
+  int c, d;
+
+public:
+  ContainsRecordTest1()
+ 

[PATCH] D45061: [NVPTX, CUDA] Improved feature constraints on NVPTX target builtins.

2018-04-11 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329829: [NVPTX, CUDA] Improved feature constraints on NVPTX 
target builtins. (authored by tra, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45061?vs=141932=142047#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45061

Files:
  include/clang/Basic/BuiltinsNVPTX.def
  lib/Basic/Targets/NVPTX.cpp
  lib/Basic/Targets/NVPTX.h
  test/CodeGen/builtins-nvptx-ptx50.cu
  test/CodeGen/builtins-nvptx.c

Index: test/CodeGen/builtins-nvptx.c
===
--- test/CodeGen/builtins-nvptx.c
+++ test/CodeGen/builtins-nvptx.c
@@ -5,6 +5,9 @@
 // RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_60 \
 // RUN:-fcuda-is-device -S -emit-llvm -o - -x cuda %s \
 // RUN:   | FileCheck -check-prefix=CHECK -check-prefix=LP64 %s
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_61 \
+// RUN:-fcuda-is-device -S -emit-llvm -o - -x cuda %s \
+// RUN:   | FileCheck -check-prefix=CHECK -check-prefix=LP64 %s
 // RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_53 \
 // RUN:   -DERROR_CHECK -fcuda-is-device -S -o /dev/null -x cuda -verify %s
 
@@ -292,245 +295,245 @@
 #if ERROR_CHECK || __CUDA_ARCH__ >= 600
 
   // CHECK: call i32 @llvm.nvvm.atomic.add.gen.i.cta.i32.p0i32
-  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_i' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_i' needs target feature sm_60}}
   __nvvm_atom_cta_add_gen_i(ip, i);
   // LP32: call i32 @llvm.nvvm.atomic.add.gen.i.cta.i32.p0i32
   // LP64: call i64 @llvm.nvvm.atomic.add.gen.i.cta.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_l' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_l' needs target feature sm_60}}
   __nvvm_atom_cta_add_gen_l(, l);
   // CHECK: call i64 @llvm.nvvm.atomic.add.gen.i.cta.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_ll' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_ll' needs target feature sm_60}}
   __nvvm_atom_cta_add_gen_ll(, ll);
   // CHECK: call i32 @llvm.nvvm.atomic.add.gen.i.sys.i32.p0i32
-  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_i' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_i' needs target feature sm_60}}
   __nvvm_atom_sys_add_gen_i(ip, i);
   // LP32: call i32 @llvm.nvvm.atomic.add.gen.i.sys.i32.p0i32
   // LP64: call i64 @llvm.nvvm.atomic.add.gen.i.sys.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_l' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_l' needs target feature sm_60}}
   __nvvm_atom_sys_add_gen_l(, l);
   // CHECK: call i64 @llvm.nvvm.atomic.add.gen.i.sys.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_ll' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_ll' needs target feature sm_60}}
   __nvvm_atom_sys_add_gen_ll(, ll);
 
   // CHECK: call float @llvm.nvvm.atomic.add.gen.f.cta.f32.p0f32
-  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_f' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_f' needs target feature sm_60}}
   __nvvm_atom_cta_add_gen_f(fp, f);
   // CHECK: call double @llvm.nvvm.atomic.add.gen.f.cta.f64.p0f64
-  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_d' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_add_gen_d' needs target feature sm_60}}
   __nvvm_atom_cta_add_gen_d(dfp, df);
   // CHECK: call float @llvm.nvvm.atomic.add.gen.f.sys.f32.p0f32
-  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_f' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_f' needs target feature sm_60}}
   __nvvm_atom_sys_add_gen_f(fp, f);
   // CHECK: call double @llvm.nvvm.atomic.add.gen.f.sys.f64.p0f64
-  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_d' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_sys_add_gen_d' needs target feature sm_60}}
   __nvvm_atom_sys_add_gen_d(dfp, df);
 
   // CHECK: call i32 @llvm.nvvm.atomic.exch.gen.i.cta.i32.p0i32
-  // expected-error@+1 {{'__nvvm_atom_cta_xchg_gen_i' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_xchg_gen_i' needs target feature sm_60}}
   __nvvm_atom_cta_xchg_gen_i(ip, i);
   // LP32: call i32 @llvm.nvvm.atomic.exch.gen.i.cta.i32.p0i32
   // LP64: call i64 @llvm.nvvm.atomic.exch.gen.i.cta.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_cta_xchg_gen_l' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_xchg_gen_l' needs target feature sm_60}}
   __nvvm_atom_cta_xchg_gen_l(, l);
   // CHECK: call i64 @llvm.nvvm.atomic.exch.gen.i.cta.i64.p0i64
-  // expected-error@+1 {{'__nvvm_atom_cta_xchg_gen_ll' needs target feature satom}}
+  // expected-error@+1 {{'__nvvm_atom_cta_xchg_gen_ll' needs target feature sm_60}}
   

r329830 - [NVPTX] Removed 'satom' feature which is no longer used.

2018-04-11 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Apr 11 10:51:33 2018
New Revision: 329830

URL: http://llvm.org/viewvc/llvm-project?rev=329830=rev
Log:
[NVPTX] Removed 'satom' feature which is no longer used.

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

Modified:
cfe/trunk/lib/Basic/Targets/NVPTX.cpp
cfe/trunk/lib/Basic/Targets/NVPTX.h

Modified: cfe/trunk/lib/Basic/Targets/NVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/NVPTX.cpp?rev=329830=329829=329830=diff
==
--- cfe/trunk/lib/Basic/Targets/NVPTX.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/NVPTX.cpp Wed Apr 11 10:51:33 2018
@@ -161,7 +161,6 @@ ArrayRef NVPTXTargetInfo::
 bool NVPTXTargetInfo::hasFeature(StringRef Feature) const {
   return llvm::StringSwitch(Feature)
   .Cases("ptx", "nvptx", true)
-  .Case("satom", GPU >= CudaArch::SM_60) // Atomics w/ scope.
   .Default(false);
 }
 

Modified: cfe/trunk/lib/Basic/Targets/NVPTX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/NVPTX.h?rev=329830=329829=329830=diff
==
--- cfe/trunk/lib/Basic/Targets/NVPTX.h (original)
+++ cfe/trunk/lib/Basic/Targets/NVPTX.h Wed Apr 11 10:51:33 2018
@@ -57,7 +57,6 @@ public:
  StringRef CPU,
  const std::vector ) const override {
 Features[CudaArchToString(GPU)] = true;
-Features["satom"] = GPU >= CudaArch::SM_60;
 Features["ptx" + std::to_string(PTXVersion)] = true;
 return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
   }


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


r329829 - [NVPTX, CUDA] Improved feature constraints on NVPTX target builtins.

2018-04-11 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Apr 11 10:51:19 2018
New Revision: 329829

URL: http://llvm.org/viewvc/llvm-project?rev=329829=rev
Log:
[NVPTX, CUDA] Improved feature constraints on NVPTX target builtins.

When NVPTX TARGET_BUILTIN specifies sm_XX or ptxYY as required feature,
consider those features available if we're compiling for GPU >= sm_XX or have
enabled PTX version >= ptxYY.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/Basic/Targets/NVPTX.cpp
cfe/trunk/lib/Basic/Targets/NVPTX.h
cfe/trunk/test/CodeGen/builtins-nvptx-ptx50.cu
cfe/trunk/test/CodeGen/builtins-nvptx.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=329829=329828=329829=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Wed Apr 11 10:51:19 2018
@@ -18,6 +18,12 @@
 #   define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS)
 #endif
 
+#pragma push_macro("SM_60")
+#define SM_60 "sm_60|sm_61|sm_62|sm_70|sm_71"
+
+#pragma push_macro("PTX60")
+#define PTX60 "ptx60|ptx61"
+
 // Special Registers
 
 BUILTIN(__nvvm_read_ptx_sreg_tid_x, "i", "nc")
@@ -372,7 +378,7 @@ BUILTIN(__nvvm_bitcast_ll2d, "dLLi", "")
 BUILTIN(__nvvm_bitcast_d2ll, "LLid", "")
 
 // FNS
-TARGET_BUILTIN(__nvvm_fns, "UiUiUii", "n", "ptx60")
+TARGET_BUILTIN(__nvvm_fns, "UiUiUii", "n", PTX60)
 
 // Sync
 
@@ -381,9 +387,9 @@ BUILTIN(__nvvm_bar0_popc, "ii", "")
 BUILTIN(__nvvm_bar0_and, "ii", "")
 BUILTIN(__nvvm_bar0_or, "ii", "")
 BUILTIN(__nvvm_bar_sync, "vi", "n")
-TARGET_BUILTIN(__nvvm_bar_warp_sync, "vUi", "n", "ptx60")
-TARGET_BUILTIN(__nvvm_barrier_sync, "vUi", "n", "ptx60")
-TARGET_BUILTIN(__nvvm_barrier_sync_cnt, "vUiUi", "n", "ptx60")
+TARGET_BUILTIN(__nvvm_bar_warp_sync, "vUi", "n", PTX60)
+TARGET_BUILTIN(__nvvm_barrier_sync, "vUi", "n", PTX60)
+TARGET_BUILTIN(__nvvm_barrier_sync_cnt, "vUiUi", "n", PTX60)
 
 // Shuffle
 
@@ -396,14 +402,14 @@ BUILTIN(__nvvm_shfl_bfly_f32, "ffii", ""
 BUILTIN(__nvvm_shfl_idx_i32, "", "")
 BUILTIN(__nvvm_shfl_idx_f32, "ffii", "")
 
-TARGET_BUILTIN(__nvvm_shfl_sync_down_i32, "iU", "", "ptx60")
-TARGET_BUILTIN(__nvvm_shfl_sync_down_f32, "fUifii", "", "ptx60")
-TARGET_BUILTIN(__nvvm_shfl_sync_up_i32, "iU", "", "ptx60")
-TARGET_BUILTIN(__nvvm_shfl_sync_up_f32, "fUifii", "", "ptx60")
-TARGET_BUILTIN(__nvvm_shfl_sync_bfly_i32, "iU", "", "ptx60")
-TARGET_BUILTIN(__nvvm_shfl_sync_bfly_f32, "fUifii", "", "ptx60")
-TARGET_BUILTIN(__nvvm_shfl_sync_idx_i32, "iU", "", "ptx60")
-TARGET_BUILTIN(__nvvm_shfl_sync_idx_f32, "fUifii", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_down_i32, "iU", "", PTX60)
+TARGET_BUILTIN(__nvvm_shfl_sync_down_f32, "fUifii", "", PTX60)
+TARGET_BUILTIN(__nvvm_shfl_sync_up_i32, "iU", "", PTX60)
+TARGET_BUILTIN(__nvvm_shfl_sync_up_f32, "fUifii", "", PTX60)
+TARGET_BUILTIN(__nvvm_shfl_sync_bfly_i32, "iU", "", PTX60)
+TARGET_BUILTIN(__nvvm_shfl_sync_bfly_f32, "fUifii", "", PTX60)
+TARGET_BUILTIN(__nvvm_shfl_sync_idx_i32, "iU", "", PTX60)
+TARGET_BUILTIN(__nvvm_shfl_sync_idx_f32, "fUifii", "", PTX60)
 
 // Vote
 BUILTIN(__nvvm_vote_all, "bb", "")
@@ -411,17 +417,17 @@ BUILTIN(__nvvm_vote_any, "bb", "")
 BUILTIN(__nvvm_vote_uni, "bb", "")
 BUILTIN(__nvvm_vote_ballot, "Uib", "")
 
-TARGET_BUILTIN(__nvvm_vote_all_sync, "bUib", "", "ptx60")
-TARGET_BUILTIN(__nvvm_vote_any_sync, "bUib", "", "ptx60")
-TARGET_BUILTIN(__nvvm_vote_uni_sync, "bUib", "", "ptx60")
-TARGET_BUILTIN(__nvvm_vote_ballot_sync, "UiUib", "", "ptx60")
+TARGET_BUILTIN(__nvvm_vote_all_sync, "bUib", "", PTX60)
+TARGET_BUILTIN(__nvvm_vote_any_sync, "bUib", "", PTX60)
+TARGET_BUILTIN(__nvvm_vote_uni_sync, "bUib", "", PTX60)
+TARGET_BUILTIN(__nvvm_vote_ballot_sync, "UiUib", "", PTX60)
 
 // Match
-TARGET_BUILTIN(__nvvm_match_any_sync_i32, "UiUiUi", "", "ptx60")
-TARGET_BUILTIN(__nvvm_match_any_sync_i64, "WiUiWi", "", "ptx60")
+TARGET_BUILTIN(__nvvm_match_any_sync_i32, "UiUiUi", "", PTX60)
+TARGET_BUILTIN(__nvvm_match_any_sync_i64, "WiUiWi", "", PTX60)
 // These return a pair {value, predicate}, which requires custom lowering.
-TARGET_BUILTIN(__nvvm_match_all_sync_i32p, "UiUiUii*", "", "ptx60")
-TARGET_BUILTIN(__nvvm_match_all_sync_i64p, "WiUiWii*", "", "ptx60")
+TARGET_BUILTIN(__nvvm_match_all_sync_i32p, "UiUiUii*", "", PTX60)
+TARGET_BUILTIN(__nvvm_match_all_sync_i64p, "WiUiWii*", "", PTX60)
 
 // Membar
 
@@ -465,28 +471,28 @@ BUILTIN(__builtin_ptx_get_image_channel_
 BUILTIN(__nvvm_atom_add_g_i, "iiD*1i", "n")
 BUILTIN(__nvvm_atom_add_s_i, "iiD*3i", "n")
 BUILTIN(__nvvm_atom_add_gen_i, "iiD*i", "n")
-TARGET_BUILTIN(__nvvm_atom_cta_add_gen_i, "iiD*i", "n", "satom")
-TARGET_BUILTIN(__nvvm_atom_sys_add_gen_i, "iiD*i", "n", "satom")
+TARGET_BUILTIN(__nvvm_atom_cta_add_gen_i, 

[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17

2018-04-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I'm waiting for @mclow.lists to have the final say re this differential.

In https://reviews.llvm.org/D45179#1057187, @Quuxplusone wrote:

> In https://reviews.llvm.org/D45179#1056706, @lebedev.ri wrote:
>
> > gcc does not silence the warning produced by
> >  these attributes via `(void)` cast, unless it's `[[nodiscard]]` attribute 
> > :/
> >  [...] So until they fix that (they will fix that right? :)),
> >  we can only support `_LIBCPP_FORCE_NODISCARD` for clang compilers.
>
>
> The GCC warn_unused_result issue is 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509 and also 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 . I would certainly love 
> for them to fix it, but the sentiment expressed in those bug reports is "no! 
> never! we love being broken!". :/
>  I re-suggest my idea that perhaps libc++ should respect the user's choice to 
> pass `-D_LIBCPP_NODISCARD=__attribute__((warn_unused_result))` on the GCC 
> command line. This would make your patch only one line longer than it is 
> right now...


So roughly:

  // NOTE: Do not use [[nodiscard]] in pre-C++17 mode
  //   to avoid -Wc++17-extensions warning.
  // And we can't use GCC's [[gnu::warn_unused_result]] and
  // __attribute__((warn_unused_result)),
  // because GCC does not silence them via (void) cast.
  #if !defined(_LIBCPP_NODISCARD)
  #  if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17
  #define _LIBCPP_NODISCARD [[nodiscard]]
  #  elif __has_cpp_attribute(clang::warn_unused_result)
  #define _LIBCPP_NODISCARD [[clang::warn_unused_result]]
  #  else
  #define _LIBCPP_NODISCARD
  #  endif
  #endif

?


Repository:
  rCXX libc++

https://reviews.llvm.org/D45179



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


[PATCH] D43817: [x86] wbnoinvd intrinsic

2018-04-11 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.

LGTM


https://reviews.llvm.org/D43817



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


[PATCH] D45061: [NVPTX, CUDA] Improved feature constraints on NVPTX target builtins.

2018-04-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D45061#1063791, @echristo wrote:

> Guessing that SM_60 (etc) are defines?
>
> Anyhow LGTM. I'm not sure you can split up the satom part of the patch, but 
> if you can that'd be great.
>
> -eric


I'll split out removal of satom feature into a separate commit.


https://reviews.llvm.org/D45061



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


[PATCH] D45406: Document -std= values for different languages

2018-04-11 Thread Dimitry Andric via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329827: Document -std= values for different languages 
(authored by dim, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45406?vs=141529=142042#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45406

Files:
  cfe/trunk/docs/CommandGuide/clang.rst

Index: cfe/trunk/docs/CommandGuide/clang.rst
===
--- cfe/trunk/docs/CommandGuide/clang.rst
+++ cfe/trunk/docs/CommandGuide/clang.rst
@@ -98,10 +98,129 @@
 
  Treat subsequent input files as having type language.
 
-.. option:: -std=
+.. option:: -std=
 
  Specify the language standard to compile for.
 
+ Supported values for the C language are:
+
+  | ``c89``
+  | ``c90``
+  | ``iso9899:1990``
+
+   ISO C 1990
+
+  | ``iso9899:199409``
+
+   ISO C 1990 with amendment 1
+
+  | ``gnu89``
+  | ``gnu90``
+
+   ISO C 1990 with GNU extensions
+
+  | ``c99``
+  | ``iso9899:1999``
+
+   ISO C 1999
+
+  | ``gnu99``
+
+   ISO C 1999 with GNU extensions
+
+  | ``c11``
+  | ``iso9899:2011``
+
+   ISO C 2011
+
+  | ``gnu11``
+
+   ISO C 2011 with GNU extensions
+
+  | ``c17``
+  | ``iso9899:2017``
+
+   ISO C 2017
+
+  | ``gnu17``
+
+   ISO C 2017 with GNU extensions
+
+ The default C language standard is ``gnu11``, except on PS4, where it is
+ ``gnu99``.
+
+ Supported values for the C++ language are:
+
+  | ``c++98``
+  | ``c++03``
+
+   ISO C++ 1998 with amendments
+
+  | ``gnu++98``
+  | ``gnu++03``
+
+   ISO C++ 1998 with amendments and GNU extensions
+
+  | ``c++11``
+
+   ISO C++ 2011 with amendments
+
+  | ``gnu++11``
+
+ISO C++ 2011 with amendments and GNU extensions
+
+  | ``c++14``
+
+   ISO C++ 2014 with amendments
+
+  | ``gnu++14``
+
+   ISO C++ 2014 with amendments and GNU extensions
+
+  | ``c++17``
+
+   ISO C++ 2017 with amendments
+
+  | ``gnu++17``
+
+   ISO C++ 2017 with amendments and GNU extensions
+
+  | ``c++2a``
+
+   Working draft for ISO C++ 2020
+
+  | ``gnu++2a``
+
+   Working draft for ISO C++ 2020 with GNU extensions
+
+ The default C++ language standard is ``gnu++14``.
+
+ Supported values for the OpenCL language are:
+
+  | ``cl1.0``
+
+   OpenCL 1.0
+
+  | ``cl1.1``
+
+   OpenCL 1.1
+
+  | ``cl1.2``
+
+   OpenCL 1.2
+
+  | ``cl2.0``
+
+   OpenCL 2.0
+
+ The default OpenCL language standard is ``cl1.0``.
+
+ Supported values for the CUDA language are:
+
+  | ``cuda``
+
+   NVIDIA CUDA(tm)
+
 .. option:: -stdlib=
 
  Specify the C++ standard library to use; supported options are libstdc++ and
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45529: [CMake] Set the default ABI version for Fuchsia in CMake as well

2018-04-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: EricWF, beanz.
Herald added subscribers: cfe-commits, christof, mgorny.

This is neeeded since the CMake value is used for the SOVERSION.


Repository:
  rCXX libc++

https://reviews.llvm.org/D45529

Files:
  libcxx/CMakeLists.txt


Index: libcxx/CMakeLists.txt
===
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -97,7 +97,12 @@
 cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
 "Install libc++experimental.a" ON
 "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
-set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
+if (FUCHSIA)
+  set(ABI_VERSION_DEFAULT 2)
+else()
+  set(ABI_VERSION_DEFAULT 1)
+endif()
+set(LIBCXX_ABI_VERSION ${ABI_VERSION_DEFAULT} CACHE STRING "ABI version of 
libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the 
Itanium ABI.")
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the 
Microsoft ABI.")
@@ -619,7 +624,7 @@
 endif()
 
 # Configuration file flags 
=
-if (NOT LIBCXX_ABI_VERSION EQUAL "1")
+if (NOT LIBCXX_ABI_VERSION EQUAL ABI_VERSION_DEFAULT)
   config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
 endif()
 config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)


Index: libcxx/CMakeLists.txt
===
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -97,7 +97,12 @@
 cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
 "Install libc++experimental.a" ON
 "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
-set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
+if (FUCHSIA)
+  set(ABI_VERSION_DEFAULT 2)
+else()
+  set(ABI_VERSION_DEFAULT 1)
+endif()
+set(LIBCXX_ABI_VERSION ${ABI_VERSION_DEFAULT} CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.")
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
@@ -619,7 +624,7 @@
 endif()
 
 # Configuration file flags =
-if (NOT LIBCXX_ABI_VERSION EQUAL "1")
+if (NOT LIBCXX_ABI_VERSION EQUAL ABI_VERSION_DEFAULT)
   config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
 endif()
 config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329827 - Document -std= values for different languages

2018-04-11 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Wed Apr 11 10:21:52 2018
New Revision: 329827

URL: http://llvm.org/viewvc/llvm-project?rev=329827=rev
Log:
Document -std= values for different languages

Summary:
After a remark on a FreeBSD mailing list that the clang man page did
not have any list of possible values for the `-std=` flag, I have now
attempted to exhaustively list those, for each available language.

I also documented the default standard for each language, if there was
more than one choice.

Reviewers: rsmith, dexonsmith, sylvestre.ledru, mgorny

Reviewed By: rsmith

Subscribers: fhahn, emaste, cfe-commits, krytarowski

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

Modified:
cfe/trunk/docs/CommandGuide/clang.rst

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=329827=329826=329827=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Wed Apr 11 10:21:52 2018
@@ -98,10 +98,129 @@ Language Selection and Mode Options
 
  Treat subsequent input files as having type language.
 
-.. option:: -std=
+.. option:: -std=
 
  Specify the language standard to compile for.
 
+ Supported values for the C language are:
+
+  | ``c89``
+  | ``c90``
+  | ``iso9899:1990``
+
+   ISO C 1990
+
+  | ``iso9899:199409``
+
+   ISO C 1990 with amendment 1
+
+  | ``gnu89``
+  | ``gnu90``
+
+   ISO C 1990 with GNU extensions
+
+  | ``c99``
+  | ``iso9899:1999``
+
+   ISO C 1999
+
+  | ``gnu99``
+
+   ISO C 1999 with GNU extensions
+
+  | ``c11``
+  | ``iso9899:2011``
+
+   ISO C 2011
+
+  | ``gnu11``
+
+   ISO C 2011 with GNU extensions
+
+  | ``c17``
+  | ``iso9899:2017``
+
+   ISO C 2017
+
+  | ``gnu17``
+
+   ISO C 2017 with GNU extensions
+
+ The default C language standard is ``gnu11``, except on PS4, where it is
+ ``gnu99``.
+
+ Supported values for the C++ language are:
+
+  | ``c++98``
+  | ``c++03``
+
+   ISO C++ 1998 with amendments
+
+  | ``gnu++98``
+  | ``gnu++03``
+
+   ISO C++ 1998 with amendments and GNU extensions
+
+  | ``c++11``
+
+   ISO C++ 2011 with amendments
+
+  | ``gnu++11``
+
+ISO C++ 2011 with amendments and GNU extensions
+
+  | ``c++14``
+
+   ISO C++ 2014 with amendments
+
+  | ``gnu++14``
+
+   ISO C++ 2014 with amendments and GNU extensions
+
+  | ``c++17``
+
+   ISO C++ 2017 with amendments
+
+  | ``gnu++17``
+
+   ISO C++ 2017 with amendments and GNU extensions
+
+  | ``c++2a``
+
+   Working draft for ISO C++ 2020
+
+  | ``gnu++2a``
+
+   Working draft for ISO C++ 2020 with GNU extensions
+
+ The default C++ language standard is ``gnu++14``.
+
+ Supported values for the OpenCL language are:
+
+  | ``cl1.0``
+
+   OpenCL 1.0
+
+  | ``cl1.1``
+
+   OpenCL 1.1
+
+  | ``cl1.2``
+
+   OpenCL 1.2
+
+  | ``cl2.0``
+
+   OpenCL 2.0
+
+ The default OpenCL language standard is ``cl1.0``.
+
+ Supported values for the CUDA language are:
+
+  | ``cuda``
+
+   NVIDIA CUDA(tm)
+
 .. option:: -stdlib=
 
  Specify the C++ standard library to use; supported options are libstdc++ and


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


[PATCH] D45526: [clang-format] Prefer breaking after ObjC category close paren

2018-04-11 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: djasper, jolesiak.
Herald added subscribers: cfe-commits, klimek.

Previously, `clang-format` would break Objective-C
category extensions after the opening parenthesis to avoid
breaking the protocol list:

  % echo "@interface c (ccc)  { }" | \
clang-format -assume-filename=foo.h -style="{BasedOnStyle: llvm, \
ColumnLimit: 40}"
  @interface c (
  ccc)  {
  }

This looks fairly odd, as we could have kept the category extension
on the previous line.

Category extensions are a single item, so they are generally very
short compared to protocol lists. We should prefer breaking after the
opening `<` of the protocol list over breaking after the opening `(`
of the category extension.

With this diff, we now prefer breaking after the category extension's
closing paren:

  % echo "@interface c (ccc)  { }" | \
./bin/clang-format -assume-filename=foo.h -style="{BasedOnStyle: llvm, \
ColumnLimit: 40}"
  @interface c (ccc) <
  c> {
  }

Test Plan: New test added. Confirmed test failed before diff and

  passed after diff by running:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D45526

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -334,6 +334,9 @@
"c, c,\n"
"c, c> {\n"
"}");
+  verifyFormat("@interface c (ccc) <\n"
+   "c> {\n"
+   "}");
   Style.ObjCBinPackProtocolList = FormatStyle::BPS_Never;
   verifyFormat("@interface d () <\n"
"d,\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2272,6 +2272,12 @@
   if (Left.is(tok::colon) && Left.is(TT_ObjCMethodExpr))
 return Line.MightBeFunctionDecl ? 50 : 500;
 
+  // In Objective-C type declarations, prefer breaking after the category's
+  // close paren instead of after the open paren.
+  if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous &&
+  Left.Previous->isOneOf(tok::identifier, tok::greater))
+return 500;
+
   if (Left.is(tok::l_paren) && InFunctionDecl &&
   Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign)
 return 100;


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -334,6 +334,9 @@
"c, c,\n"
"c, c> {\n"
"}");
+  verifyFormat("@interface c (ccc) <\n"
+   "c> {\n"
+   "}");
   Style.ObjCBinPackProtocolList = FormatStyle::BPS_Never;
   verifyFormat("@interface d () <\n"
"d,\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2272,6 +2272,12 @@
   if (Left.is(tok::colon) && Left.is(TT_ObjCMethodExpr))
 return Line.MightBeFunctionDecl ? 50 : 500;
 
+  // In Objective-C type declarations, prefer breaking after the category's
+  // close paren instead of after the open paren.
+  if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous &&
+  Left.Previous->isOneOf(tok::identifier, tok::greater))
+return 500;
+
   if (Left.is(tok::l_paren) && InFunctionDecl &&
   Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign)
 return 100;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45523: [CodeGen] Handle __func__ inside __finally

2018-04-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!




Comment at: test/CodeGen/exceptions-seh-finally.c:281
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+

smeenai wrote:
> How stable is the mangling here? I included the complete `call` instruction 
> because I wanted to ensure that the value of `__func__` inside a `__finally` 
> block reflects the parent function, not the outlined funclet, and both the 
> `[18 x i8]` and the mangled string name are pretty good proxies for that. I 
> can generalize it more if it'll make the test more reliable though.
It's pretty stable.


Repository:
  rC Clang

https://reviews.llvm.org/D45523



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


[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident

2018-04-11 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

What's your use-case for this?




Comment at: test/CodeGen/no-ident-version.c:4
+// CHECK-NOT: llvm.ident
+// CHECK-NOT: producer:
+int main(void) {}

You'll also want to check for something positive, otherwise this test will 
succeed even if clang is symlinked to /bin/true :-)


https://reviews.llvm.org/D45255



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


[PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-04-11 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

The behavior will change if the shared libraries are not 'dlopen'ed but loaded 
at program startup time.


https://reviews.llvm.org/D45454



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


[PATCH] D45491: [analyzer] Do not invalidate the `this` pointer.

2018-04-11 Thread Henry Wong via Phabricator via cfe-commits
MTC updated this revision to Diff 142026.
MTC marked 2 inline comments as done.
MTC added a comment.

- Move the `CXXThisRegion`'s check to `LoopWidening.cpp`
- Use `isa(R)` instead of `CXXThisRegion::classof(R)`.


Repository:
  rC Clang

https://reviews.llvm.org/D45491

Files:
  lib/StaticAnalyzer/Core/LoopWidening.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/this-pointer.cpp

Index: test/Analysis/this-pointer.cpp
===
--- /dev/null
+++ test/Analysis/this-pointer.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config widen-loops=true -analyzer-disable-retry-exhausted -verify %s
+
+void clang_analyzer_eval(bool);
+void clang_analyzer_dump(int);
+
+// 'this' pointer is not an lvalue, we should not invalidate it.
+namespace this_pointer_after_loop_widen {
+class A {
+public:
+  A() {
+int count = 10;
+do {
+} while (count--);
+  }
+};
+
+void goo(A a);
+void test_temporary_object() {
+  goo(A()); // no-crash
+}
+
+struct B {
+  int mem;
+  B() : mem(0) {
+for (int i = 0; i < 10; ++i) {
+}
+mem = 0;
+  }
+};
+
+void test_ctor() {
+  B b;
+  clang_analyzer_eval(b.mem == 0); // expected-warning{{TRUE}}
+}
+
+struct C {
+  int mem;
+  C() : mem(0) {}
+  void set() {
+for (int i = 0; i < 10; ++i) {
+}
+mem = 10;
+  }
+};
+
+void test_method() {
+  C c;
+  clang_analyzer_eval(c.mem == 0); // expected-warning{{TRUE}}
+  c.set();
+  clang_analyzer_eval(c.mem == 10); // expected-warning{{TRUE}}
+}
+
+struct D {
+  int mem;
+  D() : mem(0) {}
+  void set() {
+for (int i = 0; i < 10; ++i) {
+}
+mem = 10;
+  }
+};
+
+void test_new() {
+  D *d = new D;
+  clang_analyzer_eval(d->mem == 0); // expected-warning{{TRUE}}
+  d->set();
+  clang_analyzer_eval(d->mem == 10); // expected-warning{{TRUE}}
+}
+
+struct E {
+  int mem;
+  E() : mem(0) {}
+  void set() {
+for (int i = 0; i < 10; ++i) {
+}
+setAux();
+  }
+  void setAux() {
+this->mem = 10;
+  }
+};
+
+void test_chained_method_call() {
+  E e;
+  e.set();
+  clang_analyzer_eval(e.mem == 10); // expected-warning{{TRUE}}
+}
+} // namespace this_pointer_after_loop_widen
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2050,6 +2050,9 @@
 R = GetElementZeroRegion(SR, T);
   }
 
+  assert((!isa(R) || !B.lookup(R)) &&
+ "'this' pointer is not an l-value and is not assignable");
+
   // Clear out bindings that may overlap with this binding.
   RegionBindingsRef NewB = removeSubRegionBindings(B, cast(R));
   return NewB.addBinding(BindingKey::Make(R, BindingKey::Direct), V);
Index: lib/StaticAnalyzer/Core/LoopWidening.cpp
===
--- lib/StaticAnalyzer/Core/LoopWidening.cpp
+++ lib/StaticAnalyzer/Core/LoopWidening.cpp
@@ -59,6 +59,18 @@
 ITraits.setTrait(Region,
  RegionAndSymbolInvalidationTraits::TK_EntireMemSpace);
   }
+
+  // 'this' pointer is not an lvalue, we should not invalidate it. If the loop
+  // is located in a method, constructor or destructor, the value of 'this'
+  // pointer shoule remain unchanged.
+  if (const CXXMethodDecl *CXXMD = dyn_cast(STC->getDecl())) {
+const CXXThisRegion *ThisR = MRMgr.getCXXThisRegion(
+CXXMD->getThisType(STC->getAnalysisDeclContext()->getASTContext()),
+STC);
+ITraits.setTrait(ThisR,
+ RegionAndSymbolInvalidationTraits::TK_PreserveContents);
+  }
+
   return PrevState->invalidateRegions(Regions, getLoopCondition(LoopStmt),
   BlockCount, LCtx, true, nullptr, nullptr,
   );
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45523: [CodeGen] Handle __func__ inside __finally

2018-04-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: test/CodeGen/exceptions-seh-finally.c:281
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+

How stable is the mangling here? I included the complete `call` instruction 
because I wanted to ensure that the value of `__func__` inside a `__finally` 
block reflects the parent function, not the outlined funclet, and both the `[18 
x i8]` and the mangled string name are pretty good proxies for that. I can 
generalize it more if it'll make the test more reliable though.


Repository:
  rC Clang

https://reviews.llvm.org/D45523



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


[PATCH] D45523: [CodeGen] Handle __func__ inside __finally

2018-04-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: compnerd, majnemer, rnk.

When we enter a __finally block, the CGF's CurCodeDecl will be null
(because CodeGenFunction::StartFunction is given an empty GlobalDecl for
a __finally block), and so the dyn_cast here will result in an assertion
failure. Change it to dyn_cast_or_null to handle this case.


Repository:
  rC Clang

https://reviews.llvm.org/D45523

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/exceptions-seh-finally.c


Index: test/CodeGen/exceptions-seh-finally.c
===
--- test/CodeGen/exceptions-seh-finally.c
+++ test/CodeGen/exceptions-seh-finally.c
@@ -268,6 +268,18 @@
 // CHECK-LABEL: define internal void 
@"?fin$1@0@finally_within_finally@@"({{[^)]*}})
 // CHECK-SAME: [[finally_attrs]]
 
+void cleanup_with_func(const char *);
+void finally_with_func() {
+  __try {
+might_crash();
+  } __finally {
+cleanup_with_func(__func__);
+  }
+}
+
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+
 // Look for the absence of noinline. Enum attributes come first, so check that
 // a string attribute is the first to verify that no enum attributes are
 // present.
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2611,7 +2611,7 @@
   StringRef NameItems[] = {
   PredefinedExpr::getIdentTypeName(E->getIdentType()), FnName};
   std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
-  if (auto *BD = dyn_cast(CurCodeDecl)) {
+  if (auto *BD = dyn_cast_or_null(CurCodeDecl)) {
 std::string Name = SL->getString();
 if (!Name.empty()) {
   unsigned Discriminator =


Index: test/CodeGen/exceptions-seh-finally.c
===
--- test/CodeGen/exceptions-seh-finally.c
+++ test/CodeGen/exceptions-seh-finally.c
@@ -268,6 +268,18 @@
 // CHECK-LABEL: define internal void @"?fin$1@0@finally_within_finally@@"({{[^)]*}})
 // CHECK-SAME: [[finally_attrs]]
 
+void cleanup_with_func(const char *);
+void finally_with_func() {
+  __try {
+might_crash();
+  } __finally {
+cleanup_with_func(__func__);
+  }
+}
+
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+
 // Look for the absence of noinline. Enum attributes come first, so check that
 // a string attribute is the first to verify that no enum attributes are
 // present.
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2611,7 +2611,7 @@
   StringRef NameItems[] = {
   PredefinedExpr::getIdentTypeName(E->getIdentType()), FnName};
   std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
-  if (auto *BD = dyn_cast(CurCodeDecl)) {
+  if (auto *BD = dyn_cast_or_null(CurCodeDecl)) {
 std::string Name = SL->getString();
 if (!Name.empty()) {
   unsigned Discriminator =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45521: [clang-format] Improve ObjC guessing heuristic by supporting all @keywords

2018-04-11 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: djasper, jolesiak.
Herald added subscribers: cfe-commits, klimek.

This diff improves the Objective-C guessing heuristic by
replacing the hard-coded list of a subset of Objective-C @keywords
with a general check which supports all @keywords.

I also added a few more Foundation keywords which were missing from
the heuristic.

Test Plan: Unit tests updated. Ran tests with:

  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D45521

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12101,6 +12101,12 @@
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.mm", ""));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@interface 
Foo\n@end\n"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define TRY(x, y) @try { x; } @finally { y; }"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#define AVAIL(x) @available(x, *))"));
+  EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@class Foo;"));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface 
Foo\n@end\n"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1465,6 +1465,7 @@
 "NSAffineTransform",
 "NSArray",
 "NSAttributedString",
+"NSBlockOperation",
 "NSBundle",
 "NSCache",
 "NSCalendar",
@@ -1480,6 +1481,7 @@
 "NSIndexPath",
 "NSIndexSet",
 "NSInteger",
+"NSInvocationOperation",
 "NSLocale",
 "NSMapTable",
 "NSMutableArray",
@@ -1494,9 +1496,13 @@
 "NSNumber",
 "NSNumberFormatter",
 "NSObject",
+"NSOperation",
+"NSOperationQueue",
+"NSOperationQueuePriority",
 "NSOrderedSet",
 "NSPoint",
 "NSPointerArray",
+"NSQualityOfService",
 "NSRange",
 "NSRect",
 "NSRegularExpression",
@@ -1518,10 +1524,7 @@
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
- (FormatTok->isObjCAtKeyword(tok::objc_interface) ||
-  FormatTok->isObjCAtKeyword(tok::objc_implementation) ||
-  FormatTok->isObjCAtKeyword(tok::objc_protocol) ||
-  FormatTok->isObjCAtKeyword(tok::objc_end) ||
+ (FormatTok->Tok.getObjCKeywordID() != tok::objc_not_keyword ||
   FormatTok->isOneOf(tok::numeric_constant, tok::l_square,
  tok::l_brace))) ||
 (FormatTok->Tok.isAnyIdentifier() &&


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12101,6 +12101,12 @@
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.mm", ""));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@interface Foo\n@end\n"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define TRY(x, y) @try { x; } @finally { y; }"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#define AVAIL(x) @available(x, *))"));
+  EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@class Foo;"));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface Foo\n@end\n"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1465,6 +1465,7 @@
 "NSAffineTransform",
 "NSArray",
 "NSAttributedString",
+"NSBlockOperation",
 "NSBundle",
 "NSCache",
 "NSCalendar",
@@ -1480,6 +1481,7 @@
 "NSIndexPath",
 "NSIndexSet",
 "NSInteger",
+"NSInvocationOperation",
 "NSLocale",
 "NSMapTable",
 "NSMutableArray",
@@ -1494,9 +1496,13 @@
 "NSNumber",
 "NSNumberFormatter",
 "NSObject",
+"NSOperation",
+"NSOperationQueue",
+"NSOperationQueuePriority",
 "NSOrderedSet",
 "NSPoint",
 "NSPointerArray",
+"NSQualityOfService",
 "NSRange",
 "NSRect",
 "NSRegularExpression",
@@ -1518,10 +1524,7 

r329816 - Fix bugs around handling C++11 attributes.

2018-04-11 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Wed Apr 11 07:51:54 2018
New Revision: 329816

URL: http://llvm.org/viewvc/llvm-project?rev=329816=rev
Log:
Fix bugs around handling C++11 attributes.

Previously, we would format:
  int a() { ... }
  [[unused]] int b() { ... }
as...
  int a() {} [[unused] int b() {}
Now we correctly format each on its own line.

Similarly, we would detect:
  [[unused]] int b() { return 42; }
As a lambda and leave it on a single line, even if that was disallowed
by the format style.

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=329816=329815=329816=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Apr 11 07:51:54 2018
@@ -449,12 +449,19 @@ void UnwrappedLineParser::calculateBrace
   (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
tok::r_paren, tok::r_square, tok::l_brace,
-   tok::l_square, tok::ellipsis) ||
+   tok::ellipsis) ||
   (NextTok->is(tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
   (NextTok->isBinaryOperator() && !NextIsObjCMethod);
+  if (NextTok->is(tok::l_square)) {
+// We can have an array subscript after a braced init
+// list, but C++11 attributes are expected after blocks.
+NextTok = Tokens->getNextToken();
+++ReadTokens;
+ProbablyBracedList = NextTok->isNot(tok::l_square);
+  }
 }
 if (ProbablyBracedList) {
   Tok->BlockKind = BK_BracedInit;
@@ -1406,13 +1413,16 @@ bool UnwrappedLineParser::tryToParseLamb
   const FormatToken *Previous = FormatTok->Previous;
   if (Previous &&
   (Previous->isOneOf(tok::identifier, tok::kw_operator, tok::kw_new,
- tok::kw_delete) ||
+ tok::kw_delete, tok::l_square) ||
FormatTok->isCppStructuredBinding(Style) || Previous->closesScope() ||
Previous->isSimpleTypeSpecifier())) {
 nextToken();
 return false;
   }
   nextToken();
+  if (FormatTok->is(tok::l_square)) {
+return false;
+  }
   parseSquare(/*LambdaIntroducer=*/true);
   return true;
 }

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=329816=329815=329816=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Apr 11 07:51:54 2018
@@ -6078,6 +6078,21 @@ TEST_F(FormatTest, UnderstandsSquareAttr
   verifyFormat("void f() [[deprecated(\"so sorry\")]];");
   verifyFormat("aa\n"
"[[unused]] aaa(int i);");
+
+  // Make sure we do not mistake attributes for array subscripts.
+  verifyFormat("int a() {}\n"
+   "[[unused]] int b() {}\n");
+
+  // On the other hand, we still need to correctly find array subscripts.
+  verifyFormat("int a = std::vector{1, 2, 3}[0];");
+
+  // Make sure we do not parse attributes as lambda introducers.
+  FormatStyle MultiLineFunctions = getLLVMStyle();
+  MultiLineFunctions.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+  verifyFormat("[[unused]] int b() {\n"
+   "  return 42;\n"
+   "}\n",
+   MultiLineFunctions);
 }
 
 TEST_F(FormatTest, UnderstandsEllipsis) {


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


[PATCH] D45483: [NEON] Support vfma_n and vfms_n intrinsics

2018-04-11 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329814: [NEON] Support vfma_n and vfms_n intrinsics 
(authored by kosarev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45483?vs=141828=142008#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45483

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td
  cfe/trunk/test/CodeGen/aarch64-neon-2velem.c


Index: cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
@@ -3083,6 +3083,17 @@
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, 
<1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], 
float %n, i32 1
@@ -3110,6 +3121,18 @@
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> [[SUB_I]] to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> 
[[SUB_I]], <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfms_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfms_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmsq_n_f32(
 // CHECK:   [[SUB_I:%.*]] = fsub <4 x float> , %b
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -621,8 +621,8 @@
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fQfQd", OP_FMLA_N>;
-def FMLS_N : SOpInst<"vfms_n", "ddds", "fQfQd", OP_FMLS_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
 def MLS_N : SOpInst<"vmls_n", "ddds", "Qd", OP_MLS_N>;


Index: cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
@@ -3083,6 +3083,17 @@
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], float %n, i32 1
@@ -3110,6 +3121,18 @@
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> [[SUB_I]] to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> [[SUB_I]], <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfms_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfms_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmsq_n_f32(
 // 

[PATCH] D45483: [NEON] Support vfma_n and vfms_n intrinsics

2018-04-11 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329814: [NEON] Support vfma_n and vfms_n intrinsics 
(authored by kosarev, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D45483

Files:
  include/clang/Basic/arm_neon.td
  test/CodeGen/aarch64-neon-2velem.c


Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -621,8 +621,8 @@
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fQfQd", OP_FMLA_N>;
-def FMLS_N : SOpInst<"vfms_n", "ddds", "fQfQd", OP_FMLS_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
 def MLS_N : SOpInst<"vmls_n", "ddds", "Qd", OP_MLS_N>;
Index: test/CodeGen/aarch64-neon-2velem.c
===
--- test/CodeGen/aarch64-neon-2velem.c
+++ test/CodeGen/aarch64-neon-2velem.c
@@ -3083,6 +3083,17 @@
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, 
<1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], 
float %n, i32 1
@@ -3110,6 +3121,18 @@
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> [[SUB_I]] to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> 
[[SUB_I]], <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfms_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfms_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmsq_n_f32(
 // CHECK:   [[SUB_I:%.*]] = fsub <4 x float> , %b
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0


Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -621,8 +621,8 @@
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fQfQd", OP_FMLA_N>;
-def FMLS_N : SOpInst<"vfms_n", "ddds", "fQfQd", OP_FMLS_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
 def MLS_N : SOpInst<"vmls_n", "ddds", "Qd", OP_MLS_N>;
Index: test/CodeGen/aarch64-neon-2velem.c
===
--- test/CodeGen/aarch64-neon-2velem.c
+++ test/CodeGen/aarch64-neon-2velem.c
@@ -3083,6 +3083,17 @@
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], float %n, i32 1
@@ -3110,6 +3121,18 @@
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   

r329814 - [NEON] Support vfma_n and vfms_n intrinsics

2018-04-11 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Wed Apr 11 07:43:11 2018
New Revision: 329814

URL: http://llvm.org/viewvc/llvm-project?rev=329814=rev
Log:
[NEON] Support vfma_n and vfms_n intrinsics

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

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/aarch64-neon-2velem.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=329814=329813=329814=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Wed Apr 11 07:43:11 2018
@@ -621,8 +621,8 @@ def FMLS : SOpInst<"vfms", "", "dQd"
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fQfQd", OP_FMLA_N>;
-def FMLS_N : SOpInst<"vfms_n", "ddds", "fQfQd", OP_FMLS_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
 def MLS_N : SOpInst<"vmls_n", "ddds", "Qd", OP_MLS_N>;

Modified: cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-2velem.c?rev=329814=329813=329814=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-2velem.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-2velem.c Wed Apr 11 07:43:11 2018
@@ -3083,6 +3083,17 @@ float32x2_t test_vfma_n_f32(float32x2_t
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, 
<1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], 
float %n, i32 1
@@ -3110,6 +3121,18 @@ float32x2_t test_vfms_n_f32(float32x2_t
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> [[SUB_I]] to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> 
[[SUB_I]], <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfms_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfms_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmsq_n_f32(
 // CHECK:   [[SUB_I:%.*]] = fsub <4 x float> , %b
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0


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


[clang-tools-extra] r329813 - [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.

2018-04-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Apr 11 07:39:17 2018
New Revision: 329813

URL: http://llvm.org/viewvc/llvm-project?rev=329813=rev
Log:
[clang-apply-replacements] Convert tooling::Replacements to 
tooling::AtomicChange for conflict resolving of changes, code cleanup, and code 
formatting.

Summary:
By converting Replacements by AtomicChange, clang-apply-replacements is able 
like clang-tidy to automatically cleanup and format changes.
This should permits to close this ticket: 
https://bugs.llvm.org/show_bug.cgi?id=35051 and attempt to follow hints from 
https://reviews.llvm.org/D43500 comments.

Reviewers: klimek, ioeric

Reviewed By: ioeric

Subscribers: malcolm.parsons, mgorny, cfe-commits

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

Patch by Jeremy Demeule.

Added:
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/file1.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/identical.cpp

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/expected.txt

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file1.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file2.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/order-dependent.cpp
clang-tools-extra/trunk/test/clang-apply-replacements/identical.cpp
clang-tools-extra/trunk/test/clang-apply-replacements/order-dependent.cpp
Removed:

clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp
Modified:

clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h

clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt

clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt

clang-tools-extra/trunk/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h?rev=329813=329812=329813=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
 Wed Apr 11 07:39:17 2018
@@ -18,6 +18,7 @@
 
 #include "clang/Tooling/Core/Diagnostic.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -29,15 +30,8 @@ namespace clang {
 class DiagnosticsEngine;
 class Rewriter;
 
-namespace format {
-struct FormatStyle;
-} // end namespace format
-
 namespace replace {
 
-/// \brief Collection of source ranges.
-typedef std::vector RangeVector;
-
 /// \brief Collection of TranslationUnitReplacements.
 typedef std::vector 
TUReplacements;
 
@@ -47,10 +41,10 @@ typedef std::vector TURepla
 /// \brief Collection of TranslationUniDiagnostics.
 typedef std::vector TUDiagnostics;
 
-/// \brief Map mapping file name to Replacements targeting that file.
+/// \brief Map mapping file name to a set of AtomicChange targeting that file.
 typedef llvm::DenseMap>
-FileToReplacementsMap;
+   std::vector>
+FileToChangesMap;
 
 /// \brief Recursively descends through a directory structure rooted at \p
 /// Directory and attempts to deserialize *.yaml files as
@@ -77,65 +71,39 @@ std::error_code collectReplacementsFromD
 const llvm::StringRef Directory, TUDiagnostics ,
 TUReplacementFiles , clang::DiagnosticsEngine );
 
-/// \brief Deduplicate, check for conflicts, and apply all Replacements stored
-/// in \c TUs. If conflicts occur, no Replacements are applied.
+/// \brief Deduplicate, check for conflicts, and extract all Replacements 
stored
+/// in \c TUs. Conflicting replacements are skipped.
 ///
-/// \post For all (key,value) in GroupedReplacements, value[i].getOffset() <=
+/// \post For all (key,value) in FileChanges, value[i].getOffset() <=
 /// value[i+1].getOffset().
 ///
 /// \param[in] TUs Collection of TranslationUnitReplacements or
-/// TranslationUnitDiagnostics to merge,
-/// 

[PATCH] D43764: [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.

2018-04-11 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329813: [clang-apply-replacements] Convert 
tooling::Replacements to tooling… (authored by malcolm.parsons, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43764?vs=141969=142006#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43764

Files:
  
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
  
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/file1.yaml
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/identical.cpp
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/expected.txt
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file1.yaml
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file2.yaml
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/order-dependent.cpp
  clang-tools-extra/trunk/test/clang-apply-replacements/identical.cpp
  clang-tools-extra/trunk/test/clang-apply-replacements/order-dependent.cpp
  
clang-tools-extra/trunk/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
  clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt
  
clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp

Index: clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
===
--- clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
+++ clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
@@ -18,6 +18,7 @@
 
 #include "clang/Tooling/Core/Diagnostic.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -29,15 +30,8 @@
 class DiagnosticsEngine;
 class Rewriter;
 
-namespace format {
-struct FormatStyle;
-} // end namespace format
-
 namespace replace {
 
-/// \brief Collection of source ranges.
-typedef std::vector RangeVector;
-
 /// \brief Collection of TranslationUnitReplacements.
 typedef std::vector TUReplacements;
 
@@ -47,10 +41,10 @@
 /// \brief Collection of TranslationUniDiagnostics.
 typedef std::vector TUDiagnostics;
 
-/// \brief Map mapping file name to Replacements targeting that file.
+/// \brief Map mapping file name to a set of AtomicChange targeting that file.
 typedef llvm::DenseMap>
-FileToReplacementsMap;
+   std::vector>
+FileToChangesMap;
 
 /// \brief Recursively descends through a directory structure rooted at \p
 /// Directory and attempts to deserialize *.yaml files as
@@ -77,65 +71,39 @@
 const llvm::StringRef Directory, TUDiagnostics ,
 TUReplacementFiles , clang::DiagnosticsEngine );
 
-/// \brief Deduplicate, check for conflicts, and apply all Replacements stored
-/// in \c TUs. If conflicts occur, no Replacements are applied.
+/// \brief Deduplicate, check for conflicts, and extract all Replacements stored
+/// in \c TUs. Conflicting replacements are skipped.
 ///
-/// \post For all (key,value) in GroupedReplacements, value[i].getOffset() <=
+/// \post For all (key,value) in FileChanges, value[i].getOffset() <=
 /// value[i+1].getOffset().
 ///
 /// \param[in] TUs Collection of TranslationUnitReplacements or
-/// TranslationUnitDiagnostics to merge,
-/// deduplicate, and test for conflicts.
-/// \param[out] GroupedReplacements Container grouping all Replacements by the
-/// file they target.
+/// TranslationUnitDiagnostics to merge, deduplicate, and test for conflicts.
+/// \param[out] FileChanges Container grouping all changes by the
+/// file they target. Only non conflicting replacements are kept into
+/// FileChanges.
 /// \param[in] SM SourceManager required for conflict reporting.
 ///
 /// \returns \parblock
-///  \li true If all changes were applied successfully.
+///  \li true If all changes were converted successfully.
 ///  \li false If there were conflicts.
-bool mergeAndDeduplicate(const TUReplacements ,
- FileToReplacementsMap ,
- clang::SourceManager );
-
-bool mergeAndDeduplicate(const TUDiagnostics ,
- FileToReplacementsMap ,
+bool 

[PATCH] D43578: -ftime-report switch support in Clang

2018-04-11 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D43578#1064113, @russell.gallop wrote:

> We also see an assertion failure prior to the revert. At r329738:


Yes, you're right - thaks again for this test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D45092: [Driver] Don't forward -m[no-]unaligned-access options to GCC when assembling/linking

2018-04-11 Thread Chad Rosier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329810: [Driver] Dont forward -m[no-]unaligned-access 
options to GCC when… (authored by mcrosier, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D45092

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/gcc_forward.c


Index: test/Driver/gcc_forward.c
===
--- test/Driver/gcc_forward.c
+++ test/Driver/gcc_forward.c
@@ -34,3 +34,9 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 // CHECK-ASM: as
 // CHECK-ASM-NOT: "-g"
+
+// Check that we're not forwarding -mno-unaligned-access.
+// RUN: %clang -target aarch64-none-elf -mno-unaligned-access %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM %s
+// CHECK-ARM: gcc{{[^"]*}}"
+// CHECK-ARM-NOT: -mno-unaligned-access
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -85,6 +85,13 @@
   A->getOption().matches(options::OPT_W_Group))
 continue;
 
+  // Don't forward -mno-unaligned-access since GCC doesn't understand
+  // it and because it doesn't affect the assembly or link steps.
+  if ((isa(JA) || isa(JA)) &&
+  (A->getOption().matches(options::OPT_munaligned_access) ||
+   A->getOption().matches(options::OPT_mno_unaligned_access)))
+continue;
+
   A->render(Args, CmdArgs);
 }
   }


Index: test/Driver/gcc_forward.c
===
--- test/Driver/gcc_forward.c
+++ test/Driver/gcc_forward.c
@@ -34,3 +34,9 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 // CHECK-ASM: as
 // CHECK-ASM-NOT: "-g"
+
+// Check that we're not forwarding -mno-unaligned-access.
+// RUN: %clang -target aarch64-none-elf -mno-unaligned-access %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM %s
+// CHECK-ARM: gcc{{[^"]*}}"
+// CHECK-ARM-NOT: -mno-unaligned-access
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -85,6 +85,13 @@
   A->getOption().matches(options::OPT_W_Group))
 continue;
 
+  // Don't forward -mno-unaligned-access since GCC doesn't understand
+  // it and because it doesn't affect the assembly or link steps.
+  if ((isa(JA) || isa(JA)) &&
+  (A->getOption().matches(options::OPT_munaligned_access) ||
+   A->getOption().matches(options::OPT_mno_unaligned_access)))
+continue;
+
   A->render(Args, CmdArgs);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329810 - [Driver] Don't forward -m[no-]unaligned-access options to GCC when assembling/linking

2018-04-11 Thread Chad Rosier via cfe-commits
Author: mcrosier
Date: Wed Apr 11 07:20:37 2018
New Revision: 329810

URL: http://llvm.org/viewvc/llvm-project?rev=329810=rev
Log:
[Driver] Don't forward -m[no-]unaligned-access options to GCC when 
assembling/linking

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/gcc_forward.c

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=329810=329809=329810=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Apr 11 07:20:37 2018
@@ -85,6 +85,13 @@ void tools::gcc::Common::ConstructJob(Co
   A->getOption().matches(options::OPT_W_Group))
 continue;
 
+  // Don't forward -mno-unaligned-access since GCC doesn't understand
+  // it and because it doesn't affect the assembly or link steps.
+  if ((isa(JA) || isa(JA)) &&
+  (A->getOption().matches(options::OPT_munaligned_access) ||
+   A->getOption().matches(options::OPT_mno_unaligned_access)))
+continue;
+
   A->render(Args, CmdArgs);
 }
   }

Modified: cfe/trunk/test/Driver/gcc_forward.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gcc_forward.c?rev=329810=329809=329810=diff
==
--- cfe/trunk/test/Driver/gcc_forward.c (original)
+++ cfe/trunk/test/Driver/gcc_forward.c Wed Apr 11 07:20:37 2018
@@ -34,3 +34,9 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 // CHECK-ASM: as
 // CHECK-ASM-NOT: "-g"
+
+// Check that we're not forwarding -mno-unaligned-access.
+// RUN: %clang -target aarch64-none-elf -mno-unaligned-access %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM %s
+// CHECK-ARM: gcc{{[^"]*}}"
+// CHECK-ARM-NOT: -mno-unaligned-access


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


Re: r329804 - [Sema] Fix built-in decrement operator overload resolution

2018-04-11 Thread Richard Smith via cfe-commits
While you're here... ++ should not be available for bool in C++17 onwards.
:)

On Wed, 11 Apr 2018, 14:39 Jan Korous via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> Author: jkorous
> Date: Wed Apr 11 06:36:29 2018
> New Revision: 329804
>
> URL: http://llvm.org/viewvc/llvm-project?rev=329804=rev
> Log:
> [Sema] Fix built-in decrement operator overload resolution
>
> C++ [over.built] p4:
>
> "For every pair (T, VQ), where T is an arithmetic type other than bool,
> and VQ is either volatile or empty, there exist candidate operator
> functions of the form
>
>   VQ T&  operator--(VQ T&);
>   T  operator--(VQ T&, int);
> "
> The bool type is in position LastPromotedIntegralType in
> BuiltinOperatorOverloadBuilder::getArithmeticType::ArithmeticTypes, but
> addPlusPlusMinusMinusArithmeticOverloads() was expecting it at position 0.
>
> Differential Revision: https://reviews.llvm.org/D44988
>
> rdar://problem/34255516
>
> Modified:
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=329804=329803=329804=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 11 06:36:29 2018
> @@ -7796,10 +7796,12 @@ public:
>  if (!HasArithmeticOrEnumeralCandidateType)
>return;
>
> -for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
> - Arith < NumArithmeticTypes; ++Arith) {
> +for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
> +  const auto TypeOfT = ArithmeticTypes[Arith];
> +  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
> +continue;
>addPlusPlusMinusMinusStyleOverloads(
> -ArithmeticTypes[Arith],
> +TypeOfT,
>  VisibleTypeConversionsQuals.hasVolatile(),
>  VisibleTypeConversionsQuals.hasRestrict());
>  }
>
> Modified: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp?rev=329804=329803=329804=diff
>
> ==
> --- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp (original)
> +++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp Wed Apr 11
> 06:36:29 2018
> @@ -62,6 +62,10 @@ void f(Short s, Long l, Enum1 e1, Enum2
>// FIXME: should pass (void)static_cast(islong(e1 % e2));
>  }
>
> +struct BoolRef {
> +  operator bool&();
> +};
> +
>  struct ShortRef { // expected-note{{candidate function (the implicit copy
> assignment operator) not viable}}
>  #if __cplusplus >= 201103L // C++11 or later
>  // expected-note@-2 {{candidate function (the implicit move assignment
> operator) not viable}}
> @@ -73,6 +77,10 @@ struct LongRef {
>operator volatile long&();
>  };
>
> +struct FloatRef {
> +  operator float&();
> +};
> +
>  struct XpmfRef { // expected-note{{candidate function (the implicit copy
> assignment operator) not viable}}
>  #if __cplusplus >= 201103L // C++11 or later
>  // expected-note@-2 {{candidate function (the implicit move assignment
> operator) not viable}}
> @@ -84,13 +92,19 @@ struct E2Ref {
>operator E2&();
>  };
>
> -void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
> +void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref,
> XpmfRef pmf_ref) {
>// C++ [over.built]p3
>short s1 = sr++;
>
> -  // C++ [over.built]p3
> +  // C++ [over.built]p4
>long l1 = lr--;
>
> +  // C++ [over.built]p4
> +  float f1 = fr--;
> +
> +  // C++ [over.built]p4
> +  bool b2 = br--; // expected-error{{cannot decrement value of type
> 'BoolRef'}}
> +
>// C++ [over.built]p18
>short& sr1 = (sr *= lr);
>volatile long& lr1 = (lr *= sr);
>
>
> ___
> 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] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

2018-04-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 142003.
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.

- Drop stale comment
- Switch to pre{in,de}crement


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-function-size.rst
  test/clang-tidy/readability-function-size-variables-c++17.cpp
  test/clang-tidy/readability-function-size.cpp

Index: test/clang-tidy/readability-function-size.cpp
===
--- test/clang-tidy/readability-function-size.cpp
+++ test/clang-tidy/readability-function-size.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}]}' -- -std=c++11
+// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}, {key: readability-function-size.VariableThreshold, value: 1}]}' -- -std=c++11
 
 // Bad formatting is intentional, don't run clang-format over the whole file!
 
@@ -64,7 +64,7 @@
 
 void baz0() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 27 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 28 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
   int a;
   { // 2
@@ -87,14 +87,15 @@
 }
   }
   macro()
-// CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
-// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
+  // CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-27]]:6: note: 9 variables (threshold 1)
 }
 
 // check that nested if's are not reported. this was broken initially
 void nesting_if() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
   if (true) { // 2
@@ -114,12 +115,13 @@
   } else if (true) { // 2
  int j;
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 6 variables (threshold 1)
 }
 
 // however this should warn
 void bad_if_nesting() { // 1
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_if_nesting' exceeds recommended size/complexity
-// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 12 statements (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 4 branches (threshold 0)
   if (true) {// 2
@@ -139,4 +141,161 @@
   }
 }
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 4 variables (threshold 1)
 }
+
+void variables_0() {
+  int i;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_0' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_1(int i) {
+  int j;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_1' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_2(int i, int j) {
+  ;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_2' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 

[PATCH] D45517: [analyzer] WIP: False positive refutation with Z3

2018-04-11 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs created this revision.
rnkovacs added reviewers: george.karpenkov, NoQ, dcoughlin.
Herald added subscribers: a.sidorin, szepet, baloghadamsoftware, whisperity, 
fhahn.

This is a prototype of a bug reporter visitor that invalidates bug reports by 
re-checking constraints of certain states on the bug path using the Z3 
constraint manager backend. The functionality is available under the 
`postprocess-reports` analyzer config flag.

Results of analysis runs on a few open-source projects with this option turned 
on can be explored here .

This work is preliminary and any comments are appreciated. A few remarks:

- In order to work with constraints generated by the range-based constraint 
manager outside its own file, much of the `Range`, `RangeTrait` and `RangeSet` 
classes have been moved to the corresponding header file.

- The visitor currently checks states appearing as block edges in the exploded 
graph. The first idea was to filter states based on the shape of the exploded 
graph, by checking the number of successors of the parent node, but 
surprisingly, both `succ_size()` and `pred_size()` seemed to return 1 for each 
node in the graph (except for the root), even if there clearly were branchings 
in the code (and on the `.dot` picture). To my understanding, the exploded 
graph is fully constructed at the stage where visitors are run, so I must be 
missing something.

- 1-bit APSInts obtained from ranged constraints crashed when 
`isSignedIntegerOrEnumerationType()` was called on them inside 
`Z3ConstraintManager`'s methods. This issue is currently sidestepped, but they 
might be converted to a valid built-in type at some point.


Repository:
  rC Clang

https://reviews.llvm.org/D45517

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.h
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "RangedConstraintManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -915,6 +916,8 @@
   void print(ProgramStateRef St, raw_ostream , const char *nl,
  const char *sep) override;
 
+  bool checkRangedStateConstraints(ProgramStateRef State) override;
+
   //===--===//
   // Implementation for interface from SimpleConstraintManager.
   //===--===//
@@ -1235,6 +1238,47 @@
   return State->set(CZ);
 }
 
+bool Z3ConstraintManager::checkRangedStateConstraints(ProgramStateRef State) {
+  Solver.reset();
+  ConstraintRangeTy CR = State->get();
+
+  for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
+SymbolRef Sym = I.getKey();
+
+for (const auto  : I.getData()) {
+  const llvm::APSInt  = Range.From();
+  const llvm::APSInt  = Range.To();
+
+  assert((getAPSIntType(From) == getAPSIntType(To)) &&
+ "Range values have different types!");
+  QualType RangeTy = getAPSIntType(From);
+  // Skip ranges whose endpoints cannot be converted to APSInts with
+  // a valid APSIntType.
+  if (RangeTy.isNull())
+continue;
+
+  QualType SymTy;
+  Z3Expr Exp = getZ3Expr(Sym, );
+  bool isSignedTy = SymTy->isSignedIntegerOrEnumerationType();
+
+  Z3Expr FromExp = Z3Expr::fromAPSInt(From);
+  Z3Expr ToExp = Z3Expr::fromAPSInt(To);
+
+  if (From == To) {
+Z3Expr Eq = getZ3BinExpr(Exp, SymTy, BO_EQ, FromExp, RangeTy, nullptr);
+Solver.addConstraint(Eq);
+  } else {
+Z3Expr LHS = getZ3BinExpr(Exp, SymTy, BO_GE, FromExp, RangeTy, nullptr);
+Z3Expr RHS = getZ3BinExpr(Exp, SymTy, BO_LE, ToExp, RangeTy, nullptr);
+Solver.addConstraint(Z3Expr::fromBinOp(LHS, BO_LAnd, RHS, isSignedTy));
+  }
+}
+  }
+  // If Z3 timeouts, Z3_L_UNDEF is returned, and we assume that the state
+  // is feasible.
+  return Solver.check() != Z3_L_FALSE;
+}
+
 //===--===//
 // Internal implementation.
 

[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

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

Aside from some minor nits, LGTM!




Comment at: clang-tidy/readability/FunctionSizeCheck.cpp:28
+// Do not count decomposition declarations (C++17's structured bindings).
+// Do not count variables declared in macros.
+if (StructNesting == 0 &&

Comment is now stale.



Comment at: clang-tidy/readability/FunctionSizeCheck.cpp:31
+!(isa(VD) || isa(VD)))
+  Info.Variables++;
+return true;

Do you mind switching these to preincrement (and predecrement, below) since the 
value is not subsequently used?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602



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


[PATCH] D45405: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'

2018-04-11 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

The build was broken by someone else's commit then. From my side there was
a warning only I fixed immediately.

ср, 11 апр. 2018 г. в 16:26, Alexander Kornienko via Phabricator <
revi...@reviews.llvm.org>:

> alexfh added a comment.
> 
> In https://reviews.llvm.org/D45405#1063890, @zinovy.nis wrote:
> 
>> Roman, I see you've fixed them. Thanks a lot!
>  >  I did not face with these errors on MSVS'201 so  had no chance to fix
>  early.
> 
> No stress, but as Roman said, please watch the bots after committing a
>  patch: http://lab.llvm.org:8011/console.
> 
>> ср, 11 апр. 2018 г. в 0:02, Roman Lebedev via Phabricator <
>  >  revi...@reviews.llvm.org>:
>  >
>  >> lebedev.ri added a comment.
>  >>
>  >> This change had two different problems.
>  >>  Please watch the bots?
> 
> Repository:
> 
>   rL LLVM
> 
> https://reviews.llvm.org/D45405


Repository:
  rL LLVM

https://reviews.llvm.org/D45405



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


[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

2018-04-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 141997.
lebedev.ri added a reviewer: alexfh.
lebedev.ri added a comment.

After a quick IRC chat with @aaron.ballman, it was discovered that there has 
been a big misunderstanding:

  we don't need to ignore/exempt *all* the variables declared in macros, we 
just need to ignore *all* GNU Statement Expressions.

Yay!

I think this is ready now, please review.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-function-size.rst
  test/clang-tidy/readability-function-size-variables-c++17.cpp
  test/clang-tidy/readability-function-size.cpp

Index: test/clang-tidy/readability-function-size.cpp
===
--- test/clang-tidy/readability-function-size.cpp
+++ test/clang-tidy/readability-function-size.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}]}' -- -std=c++11
+// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}, {key: readability-function-size.VariableThreshold, value: 1}]}' -- -std=c++11
 
 // Bad formatting is intentional, don't run clang-format over the whole file!
 
@@ -64,7 +64,7 @@
 
 void baz0() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 27 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 28 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
   int a;
   { // 2
@@ -87,14 +87,15 @@
 }
   }
   macro()
-// CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
-// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
+  // CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-27]]:6: note: 9 variables (threshold 1)
 }
 
 // check that nested if's are not reported. this was broken initially
 void nesting_if() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
   if (true) { // 2
@@ -114,12 +115,13 @@
   } else if (true) { // 2
  int j;
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 6 variables (threshold 1)
 }
 
 // however this should warn
 void bad_if_nesting() { // 1
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_if_nesting' exceeds recommended size/complexity
-// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 12 statements (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 4 branches (threshold 0)
   if (true) {// 2
@@ -139,4 +141,161 @@
   }
 }
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 4 variables (threshold 1)
 }
+
+void variables_0() {
+  int i;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_0' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_1(int i) {
+  int j;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_1' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_2(int i, int j) {
+  ;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_2' exceeds 

[PATCH] D45491: [analyzer] Do not invalidate the `this` pointer.

2018-04-11 Thread Henry Wong via Phabricator via cfe-commits
MTC marked 2 inline comments as done.
MTC added inline comments.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1024-1027
+  // 'this' pointer is not an lvalue, we should not invalidate it.
+  if (CXXThisRegion::classof(baseR))
+return;
+

NoQ wrote:
> I don't think this run-time check belongs here. The fix should be isolated in 
> loop widening because everything else is already known to work correctly. The 
> invalidation worker is not to be blamed for other entities throwing incorrect 
> stuff into it.
Make sense, will do.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2057-2060
+  assert((!CXXThisRegion::classof(R) ||
+  CXXThisRegion::classof(R) && !B.lookup(R)) &&
+ "'this' pointer is not an l-value and is not assignable");
+

NoQ wrote:
> This assertion is great to have.
> 
> Please use `!isa(R)` instead of `CXXThisRegion::classof(R)`. 
> The left argument of `&&` is always true, so you can omit it.
Excellent advice, thank you! Will do.


Repository:
  rC Clang

https://reviews.llvm.org/D45491



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


[PATCH] D44988: [Sema] Fix decrement availability for built-in types

2018-04-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329804: [Sema] Fix built-in decrement operator overload 
resolution (authored by jkorous, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44988?vs=141865=141995#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44988

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp


Index: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
===
--- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
+++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -62,6 +62,10 @@
   // FIXME: should pass (void)static_cast(islong(e1 % e2));
 }
 
+struct BoolRef {
+  operator bool&();
+};
+
 struct ShortRef { // expected-note{{candidate function (the implicit copy 
assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment 
operator) not viable}}
@@ -73,6 +77,10 @@
   operator volatile long&();
 };
 
+struct FloatRef {
+  operator float&();
+};
+
 struct XpmfRef { // expected-note{{candidate function (the implicit copy 
assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment 
operator) not viable}}
@@ -84,13 +92,19 @@
   operator E2&();
 };
 
-void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
+void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref, XpmfRef 
pmf_ref) {
   // C++ [over.built]p3
   short s1 = sr++;
 
-  // C++ [over.built]p3
+  // C++ [over.built]p4
   long l1 = lr--;
 
+  // C++ [over.built]p4
+  float f1 = fr--;
+
+  // C++ [over.built]p4
+  bool b2 = br--; // expected-error{{cannot decrement value of type 'BoolRef'}}
+
   // C++ [over.built]p18
   short& sr1 = (sr *= lr);
   volatile long& lr1 = (lr *= sr);
Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -7796,10 +7796,12 @@
 if (!HasArithmeticOrEnumeralCandidateType)
   return;
 
-for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
- Arith < NumArithmeticTypes; ++Arith) {
+for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
+  const auto TypeOfT = ArithmeticTypes[Arith];
+  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
+continue;
   addPlusPlusMinusMinusStyleOverloads(
-ArithmeticTypes[Arith],
+TypeOfT,
 VisibleTypeConversionsQuals.hasVolatile(),
 VisibleTypeConversionsQuals.hasRestrict());
 }


Index: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
===
--- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
+++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -62,6 +62,10 @@
   // FIXME: should pass (void)static_cast(islong(e1 % e2));
 }
 
+struct BoolRef {
+  operator bool&();
+};
+
 struct ShortRef { // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
@@ -73,6 +77,10 @@
   operator volatile long&();
 };
 
+struct FloatRef {
+  operator float&();
+};
+
 struct XpmfRef { // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
@@ -84,13 +92,19 @@
   operator E2&();
 };
 
-void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
+void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref, XpmfRef pmf_ref) {
   // C++ [over.built]p3
   short s1 = sr++;
 
-  // C++ [over.built]p3
+  // C++ [over.built]p4
   long l1 = lr--;
 
+  // C++ [over.built]p4
+  float f1 = fr--;
+
+  // C++ [over.built]p4
+  bool b2 = br--; // expected-error{{cannot decrement value of type 'BoolRef'}}
+
   // C++ [over.built]p18
   short& sr1 = (sr *= lr);
   volatile long& lr1 = (lr *= sr);
Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -7796,10 +7796,12 @@
 if (!HasArithmeticOrEnumeralCandidateType)
   return;
 
-for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
- Arith < NumArithmeticTypes; ++Arith) {
+for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
+  const auto TypeOfT = ArithmeticTypes[Arith];
+  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
+continue;
   

r329804 - [Sema] Fix built-in decrement operator overload resolution

2018-04-11 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Apr 11 06:36:29 2018
New Revision: 329804

URL: http://llvm.org/viewvc/llvm-project?rev=329804=rev
Log:
[Sema] Fix built-in decrement operator overload resolution

C++ [over.built] p4:

"For every pair (T, VQ), where T is an arithmetic type other than bool, and VQ 
is either volatile or empty, there exist candidate operator functions of the 
form

  VQ T&  operator--(VQ T&);
  T  operator--(VQ T&, int);
"
The bool type is in position LastPromotedIntegralType in 
BuiltinOperatorOverloadBuilder::getArithmeticType::ArithmeticTypes, but 
addPlusPlusMinusMinusArithmeticOverloads() was expecting it at position 0.

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

rdar://problem/34255516

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=329804=329803=329804=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 11 06:36:29 2018
@@ -7796,10 +7796,12 @@ public:
 if (!HasArithmeticOrEnumeralCandidateType)
   return;
 
-for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
- Arith < NumArithmeticTypes; ++Arith) {
+for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
+  const auto TypeOfT = ArithmeticTypes[Arith];
+  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
+continue;
   addPlusPlusMinusMinusStyleOverloads(
-ArithmeticTypes[Arith],
+TypeOfT,
 VisibleTypeConversionsQuals.hasVolatile(),
 VisibleTypeConversionsQuals.hasRestrict());
 }

Modified: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp?rev=329804=329803=329804=diff
==
--- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp Wed Apr 11 06:36:29 
2018
@@ -62,6 +62,10 @@ void f(Short s, Long l, Enum1 e1, Enum2
   // FIXME: should pass (void)static_cast(islong(e1 % e2));
 }
 
+struct BoolRef {
+  operator bool&();
+};
+
 struct ShortRef { // expected-note{{candidate function (the implicit copy 
assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment 
operator) not viable}}
@@ -73,6 +77,10 @@ struct LongRef {
   operator volatile long&();
 };
 
+struct FloatRef {
+  operator float&();
+};
+
 struct XpmfRef { // expected-note{{candidate function (the implicit copy 
assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment 
operator) not viable}}
@@ -84,13 +92,19 @@ struct E2Ref {
   operator E2&();
 };
 
-void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
+void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref, XpmfRef 
pmf_ref) {
   // C++ [over.built]p3
   short s1 = sr++;
 
-  // C++ [over.built]p3
+  // C++ [over.built]p4
   long l1 = lr--;
 
+  // C++ [over.built]p4
+  float f1 = fr--;
+
+  // C++ [over.built]p4
+  bool b2 = br--; // expected-error{{cannot decrement value of type 'BoolRef'}}
+
   // C++ [over.built]p18
   short& sr1 = (sr *= lr);
   volatile long& lr1 = (lr *= sr);


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


[PATCH] D45515: [NEON] Support vrndns_f32 intrinsic

2018-04-11 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Looks good to me.


https://reviews.llvm.org/D45515



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


[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

2018-04-11 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Thank you, that's much better!

I'd also appreciate, if you could document the options this check supports in 
its .rst document (separately from this patch).

A few more comments inline.




Comment at: test/clang-tidy/readability-identifier-naming-objc.m:1-3
+// Remove UNSUPPORTED for powerpc64le when the problem introduced by
+// r288563 is resolved.
+// UNSUPPORTED: powerpc64le

I'd try committing the patch without disabling the test for powerpc64le and see 
whether the relevant buildbot complains. Looking at the description of r288563, 
I don't see anything that could be relevant to this test.



Comment at: test/clang-tidy/readability-identifier-naming-objc.m:7
+// RUN: {key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}, \
+// RUN:   ]}' -- -fno-delayed-template-parsing \
+// RUN:   -I%S/Inputs/readability-identifier-naming \

I suspect the -fno-delayed-template-parsing is not needed, since no templates 
are used in this test.



Comment at: test/clang-tidy/readability-identifier-naming-objc.m:8-9
+// RUN:   ]}' -- -fno-delayed-template-parsing \
+// RUN:   -I%S/Inputs/readability-identifier-naming \
+// RUN:   -isystem %S/Inputs/readability-identifier-naming/system
+

It looks like these flags are not needed, since there are no #include 
directives in this test.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


[PATCH] D45491: [analyzer] Do not invalidate the `this` pointer.

2018-04-11 Thread Henry Wong via Phabricator via cfe-commits
MTC added a comment.

In https://reviews.llvm.org/D45491#1063364, @george.karpenkov wrote:

> @MTC what happens for
>
>   this.j = 0;
>   for (int i=0; i<100; i++)
>  this.j++;
>
>
> ?


@george.karpenkov  `this`'s value will remain unchanged, `j` will be 
invalidated.

   1   void clang_analyzer_printState();
   2   struct A {
   3   int j;
   4   void foo() {
   5   this->j = 0;
   6   clang_analyzer_printState();
   7   for (int i = 0; i < 100; ++i)
   8   this->j++;
   9   clang_analyzer_printState();
  10 }
  11   };
  12
  13   void func() {
  14   A a;
  15   a.foo();
  16   }

For the above code, given the command `clang -cc1 -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config widen-loops=true 
test.cpp`. The output about `Store` is as follows.

  Store (direct and default bindings), 0x7fb7d008c068 :
   (a,0,direct) : 0 S32b
  
   (this,0,direct) : 
  
  
  Store (direct and default bindings), 0x7fb7d080a618 :
   (a,0,default) : conj_$1{int}
  
   (this,0,direct) : 


Repository:
  rC Clang

https://reviews.llvm.org/D45491



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


[PATCH] D45405: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'

2018-04-11 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D45405#1063890, @zinovy.nis wrote:

> Roman, I see you've fixed them. Thanks a lot!
>  I did not face with these errors on MSVS'201 so  had no chance to fix early.


No stress, but as Roman said, please watch the bots after committing a patch: 
http://lab.llvm.org:8011/console.

> ср, 11 апр. 2018 г. в 0:02, Roman Lebedev via Phabricator <
>  revi...@reviews.llvm.org>:
> 
>> lebedev.ri added a comment.
>> 
>> This change had two different problems.
>>  Please watch the bots?




Repository:
  rL LLVM

https://reviews.llvm.org/D45405



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


[PATCH] D45045: [DebugInfo] Generate debug information for labels.

2018-04-11 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 141989.
HsiangKai added a comment.

Update the test case for inlined functions. The inlined label will attach to 
DISubprogram(..., labels: !n)


Repository:
  rC Clang

https://reviews.llvm.org/D45045

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGStmt.cpp
  test/CodeGen/debug-label-inline.c
  test/CodeGen/debug-label.c

Index: test/CodeGen/debug-label.c
===
--- /dev/null
+++ test/CodeGen/debug-label.c
@@ -0,0 +1,16 @@
+// This test will test the correstness of generating DILabel and
+// llvm.dbg.label for labels.
+//
+// RUN: %clang_cc1 -emit-llvm %s -o - -emit-llvm -debug-info-kind=limited | FileCheck %s
+
+int f1(int a, int b) {
+  int sum;
+
+top:
+  // CHECK: call void @llvm.dbg.label(metadata [[LABEL_METADATA:!.*]]), !dbg [[LABEL_LOCATION:!.*]]
+  sum = a + b;
+  return sum;
+}
+
+// CHECK: [[LABEL_METADATA]] = !DILabel({{.*}}, name: "top", {{.*}}, line: 9)
+// CHECK: [[LABEL_LOCATION]] = !DILocation(line: 9,
Index: test/CodeGen/debug-label-inline.c
===
--- /dev/null
+++ test/CodeGen/debug-label-inline.c
@@ -0,0 +1,28 @@
+// This test will test the correctness of generating DILabel and
+// llvm.dbg.label when the label is in inlined functions.
+//
+// RUN: %clang_cc1 -O2 %s -o - -emit-llvm -debug-info-kind=limited | FileCheck %s
+inline int f1(int a, int b) {
+  int sum;
+
+top:
+  sum = a + b;
+  return sum;
+}
+
+extern int ga, gb;
+
+int f2(void) {
+  int result;
+
+  result = f1(ga, gb);
+  // CHECK: call void @llvm.dbg.label(metadata [[LABEL_METADATA:!.*]]), !dbg [[LABEL_LOCATION:!.*]]
+
+  return result;
+}
+
+// CHECK: distinct !DISubprogram(name: "f1", {{.*}}, labels: [[LABELS:!.*]])
+// CHECK: [[LABELS]] = !{[[LABEL_METADATA]]}
+// CHECK: [[LABEL_METADATA]] = !DILabel({{.*}}, name: "top", {{.*}}, line: 8)
+// CHECK: [[INLINEDAT:!.*]] = distinct !DILocation(line: 18,
+// CHECK: [[LABEL_LOCATION]] = !DILocation(line: 8, {{.*}}, inlinedAt: [[INLINEDAT]])
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -531,6 +531,18 @@
   }
 
   EmitBlock(Dest.getBlock());
+
+  // Emit debug info for the label only if it's reachable.
+  if (HaveInsertPoint()) {
+if (CGDebugInfo *DI = getDebugInfo()) {
+  if (CGM.getCodeGenOpts().getDebugInfo() >=
+  codegenoptions::LimitedDebugInfo) {
+DI->setLocation(D->getLocation());
+DI->EmitLabel(D, Builder);
+  }
+}
+  }
+
   incrementProfileCounter(D->getStmt());
 }
 
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -395,6 +395,9 @@
llvm::Value *AI,
CGBuilderTy );
 
+  /// Emit call to \c llvm.dbg.label for an label.
+  void EmitLabel(const LabelDecl *D, CGBuilderTy );
+
   /// Emit call to \c llvm.dbg.declare for an imported variable
   /// declaration in a block.
   void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3640,6 +3640,33 @@
   return EmitDeclare(VD, Storage, llvm::None, Builder);
 }
 
+void CGDebugInfo::EmitLabel(const LabelDecl *D,
+CGBuilderTy ) {
+  assert(DebugKind >= codegenoptions::LimitedDebugInfo);
+  assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
+
+  if (D->hasAttr())
+return;
+
+  auto *Scope = cast(LexicalBlockStack.back());
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+
+  // Get location information.
+  unsigned Line = getLineNumber(D->getLocation());
+  unsigned Column = getColumnNumber(D->getLocation());
+
+  StringRef Name = D->getName();
+
+  // Create the descriptor for the label.
+  auto *L = DBuilder.createLabel(Scope, Name, Unit, Line,
+ CGM.getLangOpts().Optimize);
+
+  // Insert an llvm.dbg.label into the current block.
+  DBuilder.insertLabel(L,
+   llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
+   Builder.GetInsertBlock());
+}
+
 llvm::DIType *CGDebugInfo::CreateSelfType(const QualType ,
   llvm::DIType *Ty) {
   llvm::DIType *CachedTy = getTypeOrNull(QualTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(BTW @hokein has https://reviews.llvm.org/D45513 to add row/col to the index, 
which will allow all the file-reading stuff to be cleaned up, but no need to 
wait on that since it's all working now).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-11 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 about the delay Marc-André - I got stuck on "how to test ClangdLSPServer" 
and then distracted!
But this looks great.




Comment at: clangd/ClangdLSPServer.cpp:101
+  // All clients should support those.
+  for (SymKindUnderlyingType I = SymbolKindMin;
+   I <= static_cast(SymbolKind::Array); ++I)

malaperle wrote:
> I'd like to add some test to exercise the changes in ClangdLSPServer.cpp and 
> Protocol.cpp but it's not straightforward to do nicely. Using a "lit" test, I 
> cannot have a header and since symbols in the main file are not collected 
> then it's not useful. If I make a gtest, I have to feed it the lsp server 
> with stdin and check the stdout which is a bit messy, but doable.
Yeah, we don't have a good way to test ClangdLSPServer :-( I would like to fix 
that, but I don't know of any easy fixes.

This is kind of gross, but do standard library includes work from our lit 
tests? You could `#include ` and then test using some symbols you know are 
there...




Comment at: clangd/ClangdLSPServer.cpp:103
+   I <= static_cast(SymbolKind::Array); ++I)
+SupportedSymbolKinds.set(I);
+

I'd like to be slightly less hostile than this to (broken) clients that fail to 
call initialize.
As the patch stands they'll get an empty SupportedSymbolKinds, and we'll crash 
if they call documentSymbols.

Instead I'd suggest pulling out defaultSymbolKinds() and initializing to that 
in the constructor, and then overriding with either `SpecifiedSymbolKinds` or 
`SpecifiedSymbolKinds | defaultSymbolKinds()` here.



Comment at: clangd/ClangdServer.h:164
+  void workspaceSymbols(StringRef Query,
+const clangd::WorkspaceSymbolOptions ,
+const DraftStore ,

I think it would probably be more consistent with other functions to just take 
`int limit` here. I'm not sure CodeCompletion is an example we want to emulate.

ClangdLSPServer might even just grab it from the code completion options, since 
that's the behavior we actually want.

Up to you, though.



Comment at: clangd/ClangdServer.h:165
+const clangd::WorkspaceSymbolOptions ,
+const DraftStore ,
+Callback CB);

maybe a short FIXME here too e.g. "remove param when the index has line/col"



Comment at: clangd/FindSymbols.cpp:42
+
+  if (!supportedSymbolKinds) {
+// Provide some sensible default when all fails.

malaperle wrote:
> sammccall wrote:
> > This code shouldn't need to handle this case. The LSP specifies the default 
> > set of supported types if it's not provided, so ClangdLSPServer should 
> > enure we always have a valid set
> My thought is that if we start dealing with one of those:
> ```
>   Object = 19,
>   Key = 20,
>   Null = 21,
>   Event = 24,
>   Operator = 25,
>   TypeParameter = 26
> ```
> and it's an older client that only supports up to "Array = 18", then we can 
> provide a fallback, otherwise the client my not handle the unknown kind 
> gracefully. But we can add this later if necessary I guess.
Ah yes I agree, fallbacks are good. I just meant that ClangdLSPServer should 
ensure that we actually have the bitset populated with the right values. I 
think it looks good now.



Comment at: clangd/Protocol.cpp:209
+  default:
+llvm_unreachable("Unexpected symbol kind");
+  }

This doesn't actually seem unreachable (or won't stay that way), maybe log and 
return `Null` or something like that? (Wow, there's really no catch-all option 
for this mandatory enum...)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-04-11 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 141983.
aheejin added a comment.

- Rebase


Repository:
  rC Clang

https://reviews.llvm.org/D44931

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGCleanup.h
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp

Index: test/CodeGenCXX/wasm-eh.cpp
===
--- /dev/null
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -0,0 +1,392 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+
+void may_throw();
+void dont_throw() noexcept;
+
+struct Cleanup {
+  ~Cleanup() { dont_throw(); }
+};
+
+// Multiple catch clauses w/o catch-all
+void test0() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (double) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*)
+
+// CHECK:   %[[INT_ALLOCA:.*]] = alloca i32
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label %[[NORMAL_BB:.*]] unwind label %[[CATCHDISPATCH_BB:.*]]
+
+// CHECK: [[CATCHDISPATCH_BB]]:
+// CHECK-NEXT:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception()
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot
+// CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector()
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label %[[CATCH_FALLTHROUGH_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK-NEXT:   %[[EXN:.*]] = load i8*, i8** %exn.slot
+// CHECK-NEXT:   %[[ADDR:.*]] = call i8* @__cxa_begin_catch(i8* %[[EXN]]) {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   %[[ADDR_CAST:.*]] = bitcast i8* %[[ADDR]] to i32*
+// CHECK-NEXT:   %[[INT_VAL:.*]] = load i32, i32* %[[ADDR_CAST]]
+// CHECK-NEXT:   store i32 %[[INT_VAL]], i32* %[[INT_ALLOCA]]
+// CHECK-NEXT:   call void @_Z10dont_throwv() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   call void @__cxa_end_catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB0:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB0]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
+
+// CHECK: [[CATCH_FALLTHROUGH_BB]]
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label %[[RETHROW_BB:.*]]
+
+// CHECK: [[CATCH_FLOAT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB1:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB1]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB]]
+
+// CHECK: [[RETHROW_BB]]:
+// CHECK-NEXT:   call void @__cxa_rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   unreachable
+
+
+// Single catch-all
+void test1() {
+  try {
+may_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CATCH-LABEL: @_Z5test1v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* null]
+// CHECK:   br label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Multiple catch clauses w/ catch-all
+void test2() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: @_Z5test2v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* null]
+// CHECK:   br i1 %{{.*}}, label %[[CATCH_INT_BB:.*]], label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Cleanup
+void test3() {
+  Cleanup c;
+  may_throw();
+}
+
+// CHECK-LABEL: @_Z5test3v()
+
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label {{.*}} unwind label %[[EHCLEANUP_BB:.*]]
+
+// CHECK: 

[PATCH] D45363: [OpenCL] Added -std/-cl-std=CL2.2/CLC++

2018-04-11 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D45363



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


Re: [PATCH] D43578: -ftime-report switch support in Clang

2018-04-11 Thread Nico Weber via cfe-commits
On Wed, Apr 11, 2018 at 6:18 AM, Andrew V. Tischenko via Phabricator via
cfe-commits  wrote:

> avt77 added a comment.
>
> In https://reviews.llvm.org/D43578#1062950, @thakis wrote:
>
> > @davezarzycki remarks in https://reviews.llvm.org/D45485 that this
> breaks the shared build. The proposed fix there is to make several of
> clang's modules depend on LLVM's IR library ("Core"). This seems weird to
> me for two reasons, one architectural, one form a build point of view:
> >
> > 1. The modules growing the dep don't really depend on IR, they just need
> that one bool that happens to be defined there. That bool is called
> `TimePassesIsEnabled` which is a reasonable bool to live in IR, but this
> patch starts using that bool for meanings other than "should we time
> passes?". It instead uses the same bool to decide if clang should print a
> bunch of timing info. We probably should have a separate bool in clang and
> key this off that and make -ftime-report set both.
> > 2. From a build PoV, depending on Core means explicitly depending on
> TableGen processing the Attributes.td and Intrinsics.td files in
> include/llvm/IR, which needlessly (explicitly) serializes the build.
>
>
> In fact the current trunk already depends on TimePassesIsEnabled (w/o this
> patch applied):
>
> //$ find clang -name \*.cpp | xargs grep TimePassesIsEnabled
> clang/lib/CodeGen/CodeGenAction.cpp:  llvm::TimePassesIsEnabled =
> TimePasses;
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled) {
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled) {
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
> clang/lib/CodeGen/CodeGenAction.cpp:if
> (llvm::TimePassesIsEnabled) {
> clang/lib/CodeGen/CodeGenAction.cpp:if
> (llvm::TimePassesIsEnabled) {
> clang/lib/CodeGen/BackendUtil.cpp:  TimeRegion 
> Region(llvm::TimePassesIsEnabled
> ?  : nullptr);
> clang/lib/CodeGen/BackendUtil.cpp:  TimeRegion 
> Region(llvm::TimePassesIsEnabled
> ?  : nullptr);
>

Note that these are all in CodeGen, which needs to depend on LLVM's IR
library anyway for code generation. It's still possible that CodeGen is
misusing TimePassesIsEnabled for a meaning which isn't "should we time
passes", in which case I agree we should change that, but at least it
doesn't add an unnecessary dependency there.


> //
> But I agree that such dependence is not OK. I'll create a separate bool
> instead of TimePassesIsEnabled but the question is should I remove the
> above usage of TimePassesIsEnabled as well? Or maybe it should be a
> separate pre-patch? Or it could be left as it is?
>

It could be a separate patch after your main change made it in.


>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D43578
>
>
>
> ___
> 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] D45515: [NEON] Support vrndns_f32 intrinsic

2018-04-11 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added reviewers: t.p.northover, rengolin, SjoerdMeijer.
kosarev added a project: clang.
Herald added a subscriber: javed.absar.

https://reviews.llvm.org/D45515

Files:
  include/clang/Basic/arm_neon.td
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/arm-neon-directed-rounding.c


Index: test/CodeGen/arm-neon-directed-rounding.c
===
--- test/CodeGen/arm-neon-directed-rounding.c
+++ test/CodeGen/arm-neon-directed-rounding.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 
-ffreestanding -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | 
FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \
+// RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \
+// RUN: opt -S -mem2reg | FileCheck %s
 
 #include 
 
@@ -85,3 +87,10 @@
 float32x4_t test_vrndq_f32(float32x4_t a) {
   return vrndq_f32(a);
 }
+
+// CHECK-LABEL: define float @test_vrndns_f32(float %a) #0 {
+// CHECK:   [[VRNDN_I:%.*]] = call float @llvm.arm.neon.vrintn.f32(float %a) #2
+// CHECK:   ret float [[VRNDN_I]]
+float32_t test_vrndns_f32(float32_t a) {
+  return vrndns_f32(a);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -5485,6 +5485,12 @@
   case NEON::BI__builtin_neon_vgetq_lane_f32:
 return Builder.CreateExtractElement(Ops[0], Ops[1], "vget_lane");
 
+  case NEON::BI__builtin_neon_vrndns_f32: {
+Value *Arg = EmitScalarExpr(E->getArg(0));
+llvm::Type *Tys[] = {Arg->getType()};
+Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vrintn, Tys);
+return Builder.CreateCall(F, {Arg}, "vrndn"); }
+
   case NEON::BI__builtin_neon_vset_lane_i8:
   case NEON::BI__builtin_neon_vset_lane_i16:
   case NEON::BI__builtin_neon_vset_lane_i32:
Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -1116,6 +1116,12 @@
 }
 
 

+// Scalar Floating-point Round to Integral
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING)" 
in {
+def SCALAR_FRINTN_S32 : SInst<"vrndn", "ss", "Sf">;
+}
+
+
 // Scalar Reduce Pairwise Addition (Scalar and Floating Point)
 def SCALAR_ADDP  : SInst<"vpadd", "sd", "SfSHlSHdSHUl">;
 


Index: test/CodeGen/arm-neon-directed-rounding.c
===
--- test/CodeGen/arm-neon-directed-rounding.c
+++ test/CodeGen/arm-neon-directed-rounding.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \
+// RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \
+// RUN: opt -S -mem2reg | FileCheck %s
 
 #include 
 
@@ -85,3 +87,10 @@
 float32x4_t test_vrndq_f32(float32x4_t a) {
   return vrndq_f32(a);
 }
+
+// CHECK-LABEL: define float @test_vrndns_f32(float %a) #0 {
+// CHECK:   [[VRNDN_I:%.*]] = call float @llvm.arm.neon.vrintn.f32(float %a) #2
+// CHECK:   ret float [[VRNDN_I]]
+float32_t test_vrndns_f32(float32_t a) {
+  return vrndns_f32(a);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -5485,6 +5485,12 @@
   case NEON::BI__builtin_neon_vgetq_lane_f32:
 return Builder.CreateExtractElement(Ops[0], Ops[1], "vget_lane");
 
+  case NEON::BI__builtin_neon_vrndns_f32: {
+Value *Arg = EmitScalarExpr(E->getArg(0));
+llvm::Type *Tys[] = {Arg->getType()};
+Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vrintn, Tys);
+return Builder.CreateCall(F, {Arg}, "vrndn"); }
+
   case NEON::BI__builtin_neon_vset_lane_i8:
   case NEON::BI__builtin_neon_vset_lane_i16:
   case NEON::BI__builtin_neon_vset_lane_i32:
Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -1116,6 +1116,12 @@
 }
 
 
+// Scalar Floating-point Round to Integral
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING)" in {
+def SCALAR_FRINTN_S32 : SInst<"vrndn", "ss", "Sf">;
+}
+
+
 // Scalar Reduce Pairwise Addition (Scalar and Floating Point)
 def SCALAR_ADDP  : SInst<"vpadd", "sd", "SfSHlSHdSHUl">;
 

[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-04-11 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 141979.
aheejin added a comment.

- Change personality function name to a unique one


Repository:
  rC Clang

https://reviews.llvm.org/D44931

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGCleanup.h
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp

Index: test/CodeGenCXX/wasm-eh.cpp
===
--- /dev/null
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -0,0 +1,392 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+
+void may_throw();
+void dont_throw() noexcept;
+
+struct Cleanup {
+  ~Cleanup() { dont_throw(); }
+};
+
+// Multiple catch clauses w/o catch-all
+void test0() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (double) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*)
+
+// CHECK:   %[[INT_ALLOCA:.*]] = alloca i32
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label %[[NORMAL_BB:.*]] unwind label %[[CATCHDISPATCH_BB:.*]]
+
+// CHECK: [[CATCHDISPATCH_BB]]:
+// CHECK-NEXT:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception()
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot
+// CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector()
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label %[[CATCH_FALLTHROUGH_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK-NEXT:   %[[EXN:.*]] = load i8*, i8** %exn.slot
+// CHECK-NEXT:   %[[ADDR:.*]] = call i8* @__cxa_begin_catch(i8* %[[EXN]]) {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   %[[ADDR_CAST:.*]] = bitcast i8* %[[ADDR]] to i32*
+// CHECK-NEXT:   %[[INT_VAL:.*]] = load i32, i32* %[[ADDR_CAST]]
+// CHECK-NEXT:   store i32 %[[INT_VAL]], i32* %[[INT_ALLOCA]]
+// CHECK-NEXT:   call void @_Z10dont_throwv() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   call void @__cxa_end_catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB0:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB0]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
+
+// CHECK: [[CATCH_FALLTHROUGH_BB]]
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label %[[RETHROW_BB:.*]]
+
+// CHECK: [[CATCH_FLOAT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB1:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB1]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB]]
+
+// CHECK: [[RETHROW_BB]]:
+// CHECK-NEXT:   call void @__cxa_rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   unreachable
+
+
+// Single catch-all
+void test1() {
+  try {
+may_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CATCH-LABEL: @_Z5test1v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* null]
+// CHECK:   br label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Multiple catch clauses w/ catch-all
+void test2() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: @_Z5test2v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* null]
+// CHECK:   br i1 %{{.*}}, label %[[CATCH_INT_BB:.*]], label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Cleanup
+void test3() {
+  Cleanup c;
+  may_throw();
+}
+
+// CHECK-LABEL: @_Z5test3v()
+
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label {{.*}} unwind label 

[clang-tools-extra] r329789 - [clang-tidy] add missing assignment operations in hicpp-signed-bitwise

2018-04-11 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Apr 11 02:53:08 2018
New Revision: 329789

URL: http://llvm.org/viewvc/llvm-project?rev=329789=rev
Log:
[clang-tidy] add missing assignment operations in hicpp-signed-bitwise

This patch resolves the bug https://bugs.llvm.org/show_bug.cgi?id=36963.

- implement missing assignment operators for hicpp-signed-bitwise
- mention fix in release notes

Reviewers:
aaron.ballman, hokein, alexfh

Differential: https://reviews.llvm.org/D45414


Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp?rev=329789=329788=329789=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp Wed Apr 11 
02:53:08 2018
@@ -36,7 +36,8 @@ void SignedBitwiseCheck::registerMatcher
   Finder->addMatcher(
   binaryOperator(
   allOf(anyOf(hasOperatorName("^"), hasOperatorName("|"),
-  hasOperatorName("&")),
+  hasOperatorName("&"), hasOperatorName("^="),
+  hasOperatorName("|="), hasOperatorName("&=")),
 
 unless(allOf(hasLHS(IsStdBitmask), hasRHS(IsStdBitmask))),
 
@@ -48,10 +49,11 @@ void SignedBitwiseCheck::registerMatcher
   // Shifting and complement is not allowed for any signed integer type because
   // the sign bit may corrupt the result.
   Finder->addMatcher(
-  binaryOperator(allOf(anyOf(hasOperatorName("<<"), hasOperatorName(">>")),
-   hasEitherOperand(SignedIntegerOperand),
-   hasLHS(hasType(isInteger())),
-   hasRHS(hasType(isInteger()
+  binaryOperator(
+  allOf(anyOf(hasOperatorName("<<"), hasOperatorName(">>"),
+  hasOperatorName("<<="), hasOperatorName(">>=")),
+hasEitherOperand(SignedIntegerOperand),
+hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger()
   .bind("binary-sign-interference"),
   this);
 
@@ -84,10 +86,8 @@ void SignedBitwiseCheck::check(const Mat
 else
   llvm_unreachable("unexpected matcher result");
   }
-
-  diag(Location,
-   "use of a signed integer operand with a %select{binary|unary}0 bitwise "
-   "operator")
+  diag(Location, "use of a signed integer operand with a "
+ "%select{binary|unary}0 bitwise operator")
   << IsUnary << SignedOperand->getSourceRange();
 }
 

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=329789=329788=329789=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Apr 11 02:53:08 2018
@@ -156,6 +156,9 @@ Improvements to clang-tidy
   `
   added.
 
+- Adding the missing bitwise assignment operations to 
+  :doc:`hicpp-signed-bitwise `.
+
 - The 'misc-forwarding-reference-overload' check was renamed to 
:doc:`bugprone-forwarding-reference-overload
   `
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp?rev=329789=329788=329789=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp 
Wed Apr 11 02:53:08 2018
@@ -8,13 +8,19 @@ void pure_bitmask_types() {
   std::locale::category C = std::locale::category::ctype;
 
   SResult = std::locale::category::none | std::locale::category::collate;
+  SResult|= std::locale::category::collate;
   SResult = std::locale::category::ctype & std::locale::category::monetary;
+  SResult&= std::locale::category::monetary;
   SResult = std::locale::category::numeric ^ std::locale::category::time;
+  SResult^= std::locale::category::time;
   SResult = std::locale::category::messages | std::locale::category::all;
 
   SResult = std::locale::category::all & C;
+  SResult&= std::locale::category::all;
   SResult = std::locale::category::all | C;
+  SResult|= std::locale::category::all;
   SResult = std::locale::category::all ^ C;
+  SResult^= std::locale::category::all;
 
   // std::ctype_base::mask
   std::ctype_base::mask M = std::ctype_base::mask::punct;

[clang-tools-extra] r329790 - [clang-tidy] fix buildbots from hicpp-signed-bitwise

2018-04-11 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Apr 11 03:22:25 2018
New Revision: 329790

URL: http://llvm.org/viewvc/llvm-project?rev=329790=rev
Log:
[clang-tidy] fix buildbots from hicpp-signed-bitwise

The applied patch to diagnose assignment operators introduced
breakage on some architectures. This patch tries to rectify that.


Modified:

clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp?rev=329790=329789=329790=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp 
Wed Apr 11 03:22:25 2018
@@ -93,11 +93,16 @@ void still_forbidden() {
   // Staying within the allowed standard types is ok for bitwise assignment
   // operations.
   std::ctype_base::mask var = std::ctype_base::mask::print;
-  var<<= std::ctype_base::mask::upper;
-  var>>= std::ctype_base::mask::upper;
-  var &= std::ctype_base::mask::upper;
-  var |= std::ctype_base::mask::upper;
-  var ^= std::ctype_base::mask::upper;
+  SResult<<= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
+  SResult>>= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
+  SResult &= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
+  SResult |= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
+  SResult ^= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
 
   UResult = std::locale::category::collate << 1u;
   UResult = std::locale::category::ctype << 1;


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


[PATCH] D44921: [PowerPC] Option for secure plt mode

2018-04-11 Thread Strahinja Petrovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329795: [PowerPC] Option for secure plt mode (authored by 
spetrovic, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44921?vs=140060=141976#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44921

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
  cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
  cfe/trunk/test/Driver/ppc-features.cpp


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1957,6 +1957,7 @@
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
+def msecure_plt : Flag<["-"], "msecure-plt">, Group;
 def mpower8_vector : Flag<["-"], "mpower8-vector">,
 Group;
 def mno_power8_vector : Flag<["-"], "mno-power8-vector">,
Index: cfe/trunk/test/Driver/ppc-features.cpp
===
--- cfe/trunk/test/Driver/ppc-features.cpp
+++ cfe/trunk/test/Driver/ppc-features.cpp
@@ -22,6 +22,10 @@
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -mhard-float 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTHARD %s
 // CHECK-SOFTHARD-NOT: "-target-feature" "-hard-float"
 
+// check -msecure-plt option for ppc32
+// RUN: %clang -target powerpc-unknown-linux-gnu -msecure-plt %s  -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-SECUREPLT %s
+// CHECK-SECUREPLT: "-target-feature" "+secure-plt"
+
 // check -mfloat-abi=x option
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s
 // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
Index: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -106,6 +106,16 @@
   ppc::FloatABI FloatABI = ppc::getPPCFloatABI(D, Args);
   if (FloatABI == ppc::FloatABI::Soft)
 Features.push_back("-hard-float");
+
+  ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Args);
+  if (ReadGOT == ppc::ReadGOTPtrMode::SecurePlt)
+Features.push_back("+secure-plt");
+}
+
+ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver , const ArgList 
) {
+  if (Args.getLastArg(options::OPT_msecure_plt))
+return ppc::ReadGOTPtrMode::SecurePlt;
+  return ppc::ReadGOTPtrMode::Bss;
 }
 
 ppc::FloatABI ppc::getPPCFloatABI(const Driver , const ArgList ) {
Index: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
@@ -29,10 +29,17 @@
   Hard,
 };
 
+enum class ReadGOTPtrMode {
+  Bss,
+  SecurePlt,
+};
+
 FloatABI getPPCFloatABI(const Driver , const llvm::opt::ArgList );
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList );
 const char *getPPCAsmModeForCPU(StringRef Name);
+ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver ,
+   const llvm::opt::ArgList );
 
 void getPPCTargetFeatures(const Driver , const llvm::Triple ,
   const llvm::opt::ArgList ,


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1957,6 +1957,7 @@
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
+def msecure_plt : Flag<["-"], "msecure-plt">, Group;
 def mpower8_vector : Flag<["-"], "mpower8-vector">,
 Group;
 def mno_power8_vector : Flag<["-"], "mno-power8-vector">,
Index: cfe/trunk/test/Driver/ppc-features.cpp
===
--- cfe/trunk/test/Driver/ppc-features.cpp
+++ cfe/trunk/test/Driver/ppc-features.cpp
@@ -22,6 +22,10 @@
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -mhard-float -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTHARD %s
 // CHECK-SOFTHARD-NOT: "-target-feature" "-hard-float"
 
+// check -msecure-plt option for ppc32
+// RUN: %clang -target powerpc-unknown-linux-gnu -msecure-plt %s  -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SECUREPLT %s
+// CHECK-SECUREPLT: "-target-feature" "+secure-plt"
+
 // check -mfloat-abi=x option
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s
 // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
Index: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp

r329795 - [PowerPC] Option for secure plt mode

2018-04-11 Thread Strahinja Petrovic via cfe-commits
Author: spetrovic
Date: Wed Apr 11 05:24:44 2018
New Revision: 329795

URL: http://llvm.org/viewvc/llvm-project?rev=329795=rev
Log:
[PowerPC] Option for secure plt mode

This patch enables option for secure plt mode in
clang (-msecure-plt).

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
cfe/trunk/test/Driver/ppc-features.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329795=329794=329795=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 11 05:24:44 2018
@@ -1957,6 +1957,7 @@ def maltivec : Flag<["-"], "maltivec">,
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
+def msecure_plt : Flag<["-"], "msecure-plt">, Group;
 def mpower8_vector : Flag<["-"], "mpower8-vector">,
 Group;
 def mno_power8_vector : Flag<["-"], "mno-power8-vector">,

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp?rev=329795=329794=329795=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp Wed Apr 11 05:24:44 2018
@@ -106,6 +106,16 @@ void ppc::getPPCTargetFeatures(const Dri
   ppc::FloatABI FloatABI = ppc::getPPCFloatABI(D, Args);
   if (FloatABI == ppc::FloatABI::Soft)
 Features.push_back("-hard-float");
+
+  ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Args);
+  if (ReadGOT == ppc::ReadGOTPtrMode::SecurePlt)
+Features.push_back("+secure-plt");
+}
+
+ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver , const ArgList 
) {
+  if (Args.getLastArg(options::OPT_msecure_plt))
+return ppc::ReadGOTPtrMode::SecurePlt;
+  return ppc::ReadGOTPtrMode::Bss;
 }
 
 ppc::FloatABI ppc::getPPCFloatABI(const Driver , const ArgList ) {

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h?rev=329795=329794=329795=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h Wed Apr 11 05:24:44 2018
@@ -29,10 +29,17 @@ enum class FloatABI {
   Hard,
 };
 
+enum class ReadGOTPtrMode {
+  Bss,
+  SecurePlt,
+};
+
 FloatABI getPPCFloatABI(const Driver , const llvm::opt::ArgList );
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList );
 const char *getPPCAsmModeForCPU(StringRef Name);
+ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver ,
+   const llvm::opt::ArgList );
 
 void getPPCTargetFeatures(const Driver , const llvm::Triple ,
   const llvm::opt::ArgList ,

Modified: cfe/trunk/test/Driver/ppc-features.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ppc-features.cpp?rev=329795=329794=329795=diff
==
--- cfe/trunk/test/Driver/ppc-features.cpp (original)
+++ cfe/trunk/test/Driver/ppc-features.cpp Wed Apr 11 05:24:44 2018
@@ -22,6 +22,10 @@
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -mhard-float 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTHARD %s
 // CHECK-SOFTHARD-NOT: "-target-feature" "-hard-float"
 
+// check -msecure-plt option for ppc32
+// RUN: %clang -target powerpc-unknown-linux-gnu -msecure-plt %s  -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-SECUREPLT %s
+// CHECK-SECUREPLT: "-target-feature" "+secure-plt"
+
 // check -mfloat-abi=x option
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s
 // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'


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


[PATCH] D45482: [clangd] Match AST and Index label for template Symbols

2018-04-11 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.

Nice, I'd been wondering about that...




Comment at: clangd/index/SymbolCollector.cpp:36
+  return *T;
+return ND;
+  }

uber-nit: these three return statements are a bit confusing to me. Maybe omit 
them and if/elseif, so the default case falls through to the bottom.



Comment at: clangd/index/SymbolCollector.cpp:331
+  // We call getTemplateOrThis, since this is what clang's code completion gets
+  // from the lookup in an actual run.
+  CodeCompletionResult SymbolCompletion((ND), 0);

"an actual run" confused me here. Maybe "We use the primary template, as clang 
does during code completion"?



Comment at: unittests/clangd/FileIndexTests.cpp:218
+  EXPECT_EQ(Sym.CompletionLabel, "vector");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText, "vector<${1:class Ty}>");
+  SeenVector = true;

If snippets are off, we'll get "vector", not "vector<>", right?

(Probably no need to test this explicitly, but I just want to be sure)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45482



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


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-11 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

We also see an assertion failure prior to the revert. At r329738:

  $ cat test.cpp
  template  struct A {
template  using rebind_alloc = _Other;
  };
  template  struct _Wrap_alloc {
template 
using rebind_alloc = typename A<_Alloc>::template rebind_alloc<_Other>;
template  using rebind = _Wrap_alloc;
  };
  _Wrap_alloc::rebind w;
  
  $ clang++ -c test.cpp
  
  $ clang++ -c test.cpp -ftime-report
  clang-7: llvm/lib/Support/Timer.cpp:133: void llvm::Timer::startTimer(): 
Assertion `!Running && "Cannot start a running timer"' failed.


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D45363: [OpenCL] Added -std/-cl-std=CL2.2/CLC++

2018-04-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Frontend/InitPreprocessor.cpp:434
+llvm_unreachable("Unsupported OpenCL C++ version");
+  Builder.defineMacro("__CL_CPP_VERSION_1_0__", "100");
+} else {

There is no such macro in the spec it seems, but I am adding it because it's 
probably useful. Also endian and fast math macros (bfrom below) are not in the 
spec it seems. Not sure it was on purpose.


https://reviews.llvm.org/D45363



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


[PATCH] D45363: [OpenCL] Added -std/-cl-std=CL2.2/CLC++

2018-04-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 141975.
Anastasia edited the summary of this revision.
Anastasia added a comment.

Changed to `-cl-std=c++` since it's explicitly defined in spec. We could reuse 
`OpenCLVersion` in `LangOpts` but I think it might be cleaner to add separate 
`OpenCLCPlusPlusVersion`.


https://reviews.llvm.org/D45363

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/autocomplete.c
  test/Driver/opencl.cl
  test/Driver/unknown-std.cl
  test/Frontend/opencl.cl
  test/Frontend/stdlang.c
  test/Preprocessor/predefined-macros.c

Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -159,6 +159,8 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=c++ \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -184,6 +186,10 @@
 // CHECK-CL20: #define __OPENCL_C_VERSION__ 200
 // CHECK-CL20-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
+// CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE
Index: test/Frontend/stdlang.c
===
--- test/Frontend/stdlang.c
+++ test/Frontend/stdlang.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -x cl -cl-std=cl1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=c++ -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
Index: test/Frontend/opencl.cl
===
--- test/Frontend/opencl.cl
+++ test/Frontend/opencl.cl
@@ -1,24 +1,33 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0
-// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=c++ -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS -DSYNTAX
+// RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only -DSYNTAX
 // RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
 
+#ifdef SYNTAX
+class test{
+int member;
+};
+#ifndef __OPENCL_CPP_VERSION__
+//expected-error@-4{{unknown type name 'class'}}
+//expected-error@-5{{expected ';' after top level declarator}}
+#endif
+#endif
+
 void f(void (^g)(void)) {
-#ifdef __OPENCL_C_VERSION__
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 && !defined(BLOCKS)
-  // expected-error@-3{{blocks support disabled - compile with -fblocks or for OpenCL 2.0 or above}}
-#else
-  // expected-no-diagnostics
+#if defined(__OPENCL_C_VERSION__) || defined(__OPENCL_CPP_VERSION__)
+#if !defined(BLOCKS) && (defined(__OPENCL_CPP_VERSION__)  || __OPENCL_C_VERSION__ != CL_VERSION_2_0)
+  // expected-error@-3{{blocks support disabled - compile with -fblocks or for OpenCL 2.0}}
 #endif
 #else
-  // expected-error@-8{{blocks support disabled - compile with 

Re: r329784 - [Tooling] Optimize memory usage in InMemoryToolResults.

2018-04-11 Thread Alexander Kornienko via cfe-commits
On Wed, Apr 11, 2018 at 10:16 AM Haojian Wu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hokein
> Date: Wed Apr 11 01:13:07 2018
> New Revision: 329784
> ...
>
> ==
> --- cfe/trunk/include/clang/Tooling/Execution.h (original)
> +++ cfe/trunk/include/clang/Tooling/Execution.h Wed Apr 11 01:13:07 2018
>
> @@ -45,20 +46,30 @@ class ToolResults {
>  public:
>virtual ~ToolResults() = default;
>virtual void addResult(StringRef Key, StringRef Value) = 0;
> -  virtual std::vector> AllKVResults()
> = 0;
> +  virtual std::vector>
> +  AllKVResults() = 0;
>

I would add a comment re: lifetime of the strings pointed by the return
value.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43817: [x86] wbnoinvd intrinsic

2018-04-11 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:188
 setFeatureEnabledImpl(Features, "mpx", true);
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);

craig.topper wrote:
> Not related to this patch, but does IcelakeServer have SGX? The adding 
> icelake-server patch and removing sgx from skylakeserver intersected here.
As far as I know both icelake-client & icelake-server has it.
https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf
says:
"ENCLV - Ice Lake Server and later ; Future Tremont and later"
enclv is an SGX leaf.


https://reviews.llvm.org/D43817



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


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-04-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/ComparisonCategories.h:68
+  /// \brief A map containing the comparison category values built from the
+  /// standard library. The key is a value of ComparisonCategoryValue.
+  llvm::DenseMap Objects;

What is ComparisonCategoryValue? Do you mean ComparisonCategoryResult?



Comment at: include/clang/AST/ComparisonCategories.h:77-78
+  ///   comparison category. For example 'std::strong_equality::equal'
+  const DeclRefExpr *getResultValue(ComparisonCategoryResult ValueKind) const {
+const DeclRefExpr *DR = getResultValueUnsafe(ValueKind);
+assert(DR &&

This should deal in `DeclRefExpr*`s, not `NamedDecl*`s. We don't have an 
expression naming the comparison result value, and we shouldn't pretend we do.



Comment at: include/clang/AST/ComparisonCategories.h:175-177
+  /// \brief returns true if the comparison category data has already been
+  /// built, and false otherwise.
+  bool hasData() const { return HasData; }

I don't think this should be exposed. (I think we should only be building the 
CCK that we need when we request them, rather than building all five, and if we 
do that, then this function is meaningless.)



Comment at: include/clang/AST/ComparisonCategories.h:180
+public:
+  // implementation details which should only be used by the function creating
+  // and setting the data.

Comments should start with a capital letter.



Comment at: include/clang/AST/Expr.h:3097-3106
+  bool isRelationalOp() const {
+return isRelationalOp(getOpcode()) ||
+   (getOpcode() == BO_Cmp && IsCmpOrdered);
+  }
 
   static bool isEqualityOp(Opcode Opc) { return Opc == BO_EQ || Opc == BO_NE; }
+  bool isEqualityOp() const {

These seem wrong to me. Relational operators are `<`, `<=`, `>`, and `>=`. 
`<=>` is not a relational operator even if it's an ordered comparison. 
Likewise, `<=>` is not an equality operator even if we don't have an ordered 
comparison.

If you undo this, you can also drop the `IsCmpOrdered` member entirely.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9377-9378
+def err_implied_comparison_category_type_not_found : Error<
+  "%0 type was not found; include  before defining "
+  "or using 'operator<=>'">;
+def err_spaceship_argument_narrowing : Error<

This doesn't sound quite right. You can define your own `operator<=>` without 
including `` so long as you don't try to default it or use one of the 
standard comparison category kinds. Also, instead of saying "before doing X or 
Y", say which one the user actually did.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9384-9385
+def err_spaceship_comparison_of_void_ptr : Error<
+  "three-way comparison with void pointer %select{operand type|operand types}0 
"
+  "(%1 and %2)">;
+def err_spaceship_comparison_of_invalid_comp_type : Error<

Why are you diagnosing this case as an error?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9386-9387
+  "(%1 and %2)">;
+def err_spaceship_comparison_of_invalid_comp_type : Error<
+  "three-way comparison of operands has composite type %0 (%1 and %2)">;
+def err_std_compare_type_missing_member : Error<

It's unclear to me what this diagnostic is supposed to mean. What actionable 
feedback is this supposed to be giving a user?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9389
+def err_std_compare_type_missing_member : Error<
+  "%0 missing a member named '%1'">;
+def err_std_compare_type_invalid_member : Error<

"%0 *is* missing [...]"?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9391
+def err_std_compare_type_invalid_member : Error<
+  "member '%1' of %0 is ill-formed">;
+def note_spaceship_operand_not_cce : Note<

What do you mean by "ill-formed" here?

I think what you really mean is "we don't understand how to deal with this 
definition of that member", so maybe we should just fold this and the prior 
diagnostic into something like "sorry, this standard library implementation of 
std::whatever is not supported"?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9393
+def note_spaceship_operand_not_cce : Note<
+  "argument is not a constant expression">;
 } // end of sema component.

Is this really useful? I would think almost all the cases where you'd hit the 
"cannot be narrowed" error, this diagnostic and the explanation of why the 
operand is not constant would be meaningless noise, because it was never meant 
to be constant, and the problem is simply that you are trying to three-way 
compare integers of mixed signedness.



Comment at: 

[PATCH] D33537: [clang-tidy] Exception Escape Checker

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

Thank you for your thorough review, I will do the fixes next week, after the 
Euro LLVM.


https://reviews.llvm.org/D33537



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


[PATCH] D38845: [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, DependentScopeDeclRefExpr

2018-04-11 Thread Peter Szecsi via Phabricator via cfe-commits
szepet marked an inline comment as done.
szepet added a comment.

Hello Aleksei,

Thanks for carrying the ASTImporter improvements (in general)! I will rebase it 
and upload for sure, but probably just next week. (After EuroLLVM.)


https://reviews.llvm.org/D38845



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


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-11 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D43578#1062950, @thakis wrote:

> @davezarzycki remarks in https://reviews.llvm.org/D45485 that this breaks the 
> shared build. The proposed fix there is to make several of clang's modules 
> depend on LLVM's IR library ("Core"). This seems weird to me for two reasons, 
> one architectural, one form a build point of view:
>
> 1. The modules growing the dep don't really depend on IR, they just need that 
> one bool that happens to be defined there. That bool is called 
> `TimePassesIsEnabled` which is a reasonable bool to live in IR, but this 
> patch starts using that bool for meanings other than "should we time 
> passes?". It instead uses the same bool to decide if clang should print a 
> bunch of timing info. We probably should have a separate bool in clang and 
> key this off that and make -ftime-report set both.
> 2. From a build PoV, depending on Core means explicitly depending on TableGen 
> processing the Attributes.td and Intrinsics.td files in include/llvm/IR, 
> which needlessly (explicitly) serializes the build.


In fact the current trunk already depends on TimePassesIsEnabled (w/o this 
patch applied):

//$ find clang -name \*.cpp | xargs grep TimePassesIsEnabled
clang/lib/CodeGen/CodeGenAction.cpp:  llvm::TimePassesIsEnabled = 
TimePasses;
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled) {
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled) {
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
clang/lib/CodeGen/CodeGenAction.cpp:if (llvm::TimePassesIsEnabled) {
clang/lib/CodeGen/CodeGenAction.cpp:if (llvm::TimePassesIsEnabled) {
clang/lib/CodeGen/BackendUtil.cpp:  TimeRegion Region(llvm::TimePassesIsEnabled 
?  : nullptr);
clang/lib/CodeGen/BackendUtil.cpp:  TimeRegion Region(llvm::TimePassesIsEnabled 
?  : nullptr);
//
But I agree that such dependence is not OK. I'll create a separate bool instead 
of TimePassesIsEnabled but the question is should I remove the above usage of 
TimePassesIsEnabled as well? Or maybe it should be a separate pre-patch? Or it 
could be left as it is?


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D45406: Document -std= values for different languages

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

Looks good to me, thank you


Repository:
  rC Clang

https://reviews.llvm.org/D45406



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


[PATCH] D45414: [clang-tidy] add missing assignment operations in hicpp-signed-bitwise

2018-04-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth closed this revision.
JonasToth added a comment.

Commit in https://reviews.llvm.org/rCTE329789


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45414



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


  1   2   >