[PATCH] D29758: [OpenMP] Parallel reduction on the NVPTX device.

2017-02-13 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D29758



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


[PATCH] D29879: [OpenMP] Teams reduction on the NVPTX device.

2017-02-13 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

General note:
Be more strict with the types. For indeces it's better to use `SizeTy` or 
`UintPtrTy`, if `Int32Ty` is specified as type of parameter, use `Int32y`, not 
`IntTy`




Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:725
+/*isVarArg=*/false);
+llvm::Type *InterWarpCopyTypeParams[] = {CGM.VoidPtrTy, CGM.Int32Ty};
+auto *InterWarpCopyFnTy =

You should use `CGM.IntTy` instead of `CGM.Int32Ty` if 
`(*kmp_InterWarpCopyFctPtr)` really uses `int` type as the second type.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1121
+  auto *CurrentOffset =
+  Bld.CreateMul(Bld.getInt64(ElementSizeInChars), ScratchpadIndex);
+  auto *ScratchPadElemAbsolutePtrVal =

Maybe it's better to use `SizeTy` rather than to rely on the support of 
`Int64Ty`?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1140
+  auto *CurrentOffset =
+  Bld.CreateMul(Bld.getInt64(ElementSizeInChars), ScratchpadIndex);
+  auto *ScratchPadElemAbsolutePtrVal =

Again, `SizeTy` instead of `Int64Ty`? Or `Intptr`?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1201-1209
+  Bld.CreateMul(ScratchpadWidth, Bld.getInt64(ElementSizeInChars)));
+
+  // Take care of global memory alignment for performance
+  ScratchpadBasePtr = Bld.CreateSub(ScratchpadBasePtr, Bld.getInt64(1));
+  ScratchpadBasePtr = Bld.CreateSDiv(ScratchpadBasePtr,
+ Bld.getInt64(GlobalMemoryAlignment));
+  ScratchpadBasePtr = Bld.CreateAdd(ScratchpadBasePtr, Bld.getInt64(1));

It is better to deduce type from `ScratchpadBasePtr` rather than to rely on 
support of `Int64Ty`.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1247-1256
+ /*Id=*/nullptr, C.IntTy);
+  // Row width of an element in the scratchpad array, typically
+  // the number of teams.
+  ImplicitParamDecl WidthArg(C, /*DC=*/nullptr, SourceLocation(),
+ /*Id=*/nullptr, C.IntTy);
+  // If should_reduce == 1, then it's load AND reduce,
+  // If should_reduce == 0 (or otherwise), then it only loads (+ copy).

I don't think you should use `IntTy` here, you should use `Int32Ty`



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1295-1301
+ CGF.Int64Ty);
+
+  Address AddrWidthArg = CGF.GetAddrOfLocalVar(&WidthArg);
+  llvm::Value *WidthVal =
+  Bld.CreateSExt(CGF.EmitLoadOfScalar(AddrWidthArg, /*Volatile=*/false,
+  C.IntTy, SourceLocation()),
+ CGF.Int64Ty);

Again, better to use `SizeTy`



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1309
+  llvm::Value *CumulativeElemBasePtr =
+  Bld.CreatePtrToInt(ScratchPadBase, CGM.Int64Ty);
+  Address SrcDataAddr(CumulativeElemBasePtr, CGF.getPointerAlign());

`IntPtr`



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1374-1378
+ /*Id=*/nullptr, C.IntTy);
+  // Row width of an element in the scratchpad array, typically
+  // the number of teams.
+  ImplicitParamDecl WidthArg(C, /*DC=*/nullptr, SourceLocation(),
+ /*Id=*/nullptr, C.IntTy);

`IntTy` or `Int32Ty`?


https://reviews.llvm.org/D29879



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


[PATCH] D29884: [analyzer] Proper caching in CallDescription objects.

2017-02-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.

During the review of https://reviews.llvm.org/D29567 it turned out the caching 
in CallDescription is not implemented properly. In case an identifier does not 
exist in a translation unit, repeated identifier lookups will be done which 
might have bad impact on the performance. This patch guarantees that the lookup 
is only executed once. Moreover this patch fixes a corner case when the 
identifier of CallDescription does not exist in the translation unit and the 
called function does not have an identifier (e.g.: overloaded operator in C++).


https://reviews.llvm.org/D29884

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  lib/StaticAnalyzer/Core/CallEvent.cpp


Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -212,9 +212,12 @@
 
 bool CallEvent::isCalled(const CallDescription &CD) const {
   assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
-  if (!CD.II)
+  if (!CD.IsLookupDone) {
+CD.IsLookupDone = true;
 CD.II = 
&getState()->getStateManager().getContext().Idents.get(CD.FuncName);
-  if (getCalleeIdentifier() != CD.II)
+  }
+  const IdentifierInfo *II = getCalleeIdentifier();
+  if (!II || II != CD.II)
 return false;
   return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
   CD.RequiredArgs == getNumArgs());
Index: include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -55,6 +55,7 @@
 class CallDescription {
   friend CallEvent;
   mutable IdentifierInfo *II;
+  mutable bool IsLookupDone;
   StringRef FuncName;
   unsigned RequiredArgs;
 
@@ -68,7 +69,8 @@
   /// call. Omit this parameter to match every occurance of call with a given
   /// name regardless the number of arguments.
   CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
-  : II(nullptr), FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+  : II(nullptr), IsLookupDone(false), FuncName(FuncName),
+RequiredArgs(RequiredArgs) {}
 
   /// \brief Get the name of the function that this object matches.
   StringRef getFunctionName() const { return FuncName; }


Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -212,9 +212,12 @@
 
 bool CallEvent::isCalled(const CallDescription &CD) const {
   assert(getKind() != CE_ObjCMessage && "Obj-C methods are not supported");
-  if (!CD.II)
+  if (!CD.IsLookupDone) {
+CD.IsLookupDone = true;
 CD.II = &getState()->getStateManager().getContext().Idents.get(CD.FuncName);
-  if (getCalleeIdentifier() != CD.II)
+  }
+  const IdentifierInfo *II = getCalleeIdentifier();
+  if (!II || II != CD.II)
 return false;
   return (CD.RequiredArgs == CallDescription::NoArgRequirement ||
   CD.RequiredArgs == getNumArgs());
Index: include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -55,6 +55,7 @@
 class CallDescription {
   friend CallEvent;
   mutable IdentifierInfo *II;
+  mutable bool IsLookupDone;
   StringRef FuncName;
   unsigned RequiredArgs;
 
@@ -68,7 +69,8 @@
   /// call. Omit this parameter to match every occurance of call with a given
   /// name regardless the number of arguments.
   CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
-  : II(nullptr), FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+  : II(nullptr), IsLookupDone(false), FuncName(FuncName),
+RequiredArgs(RequiredArgs) {}
 
   /// \brief Get the name of the function that this object matches.
   StringRef getFunctionName() const { return FuncName; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19105: Changes in clang after running http://reviews.llvm.org/D18821

2017-02-13 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek abandoned this revision.
Prazek added inline comments.



Comment at: lib/CodeGen/SplitKit.h:298
 
-  typedef PointerIntPair ValueForcePair;
+  typedef PointerIntPair ValueForcePair;
   typedef DenseMap, ValueForcePair> ValueMap;

alexfh wrote:
> Is it an automated fix?
No, this is the only one that I'have made by hand, so it won't change some 
calls on this type


https://reviews.llvm.org/D19105



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


[PATCH] D28365: [Driver] Updated for Visual Studio 2017

2017-02-13 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added a comment.

In https://reviews.llvm.org/D28365#665408, @rnk wrote:

> Doesn't your fix mean that the tests will fail on a Windows machine that 
> doesn't have VS because LLVM was built with mingw? Usually in these 
> situations we provide some way to provide a fake toolchain.


I'm not sure. It should be the same behaviour as before, which is that it'll 
keep going regardless of whether it can find an MSVC instance. Was there some 
fake toolchain providing that I missed in the old code?


https://reviews.llvm.org/D28365



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


[PATCH] D29886: [clangd] Wire up ASTUnit and publish diagnostics with it.

2017-02-13 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer created this revision.
Herald added a subscriber: mgorny.

This requires an accessible compilation database. The parsing is done
asynchronously on a separate thread.


https://reviews.llvm.org/D29886

Files:
  clangd/ASTManager.cpp
  clangd/ASTManager.h
  clangd/CMakeLists.txt
  clangd/ClangDMain.cpp
  clangd/DocumentStore.h
  test/clangd/diagnostics.test

Index: test/clangd/diagnostics.test
===
--- /dev/null
+++ test/clangd/diagnostics.test
@@ -0,0 +1,17 @@
+# RUN: clangd < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+#
+Content-Length: 152
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///foo.c","languageId":"c","version":1,"text":"void main() {}"}}}
+#
+# CHECK: {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///foo.c","diagnostics":[{"range":{"start": {"line": 0, "character": 1}, "end": {"line": 0, "character": 1}},"severity":2,"message":"return type of 'main' is not 'int'"},{"range":{"start": {"line": 0, "character": 1}, "end": {"line": 0, "character": 1}},"severity":3,"message":"change return type to 'int'"}]}}
+#
+#
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
Index: clangd/DocumentStore.h
===
--- clangd/DocumentStore.h
+++ clangd/DocumentStore.h
@@ -12,27 +12,62 @@
 
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include 
 #include 
 
 namespace clang {
 namespace clangd {
+class DocumentStore;
+
+struct DocumentStoreListener {
+  virtual ~DocumentStoreListener() = default;
+  virtual void onDocumentAdd(StringRef Uri, const DocumentStore &Docs) {}
+  virtual void onDocumentRemove(StringRef Uri, const DocumentStore &Docs) {}
+};
 
 /// A container for files opened in a workspace, addressed by URI. The contents
 /// are owned by the DocumentStore.
 class DocumentStore {
 public:
   /// Add a document to the store. Overwrites existing contents.
-  void addDocument(StringRef Uri, StringRef Text) { Docs[Uri] = Text; }
+  void addDocument(StringRef Uri, StringRef Text) {
+{
+  std::lock_guard Guard(DocsMutex);
+  Docs[Uri] = Text;
+}
+for (const auto &Listener : Listeners)
+  Listener->onDocumentAdd(Uri, *this);
+  }
   /// Delete a document from the store.
-  void removeDocument(StringRef Uri) { Docs.erase(Uri); }
+  void removeDocument(StringRef Uri) { Docs.erase(Uri);
+for (const auto &Listener : Listeners)
+  Listener->onDocumentRemove(Uri, *this);
+  }
   /// Retrieve a document from the store. Empty string if it's unknown.
   StringRef getDocument(StringRef Uri) const {
+// FIXME: This could be a reader lock.
+std::lock_guard Guard(DocsMutex);
 auto I = Docs.find(Uri);
 return I == Docs.end() ? StringRef("") : StringRef(I->second);
   }
 
+  void addListener(std::unique_ptr DSL) {
+Listeners.push_back(std::move(DSL));
+  }
+
+  std::vector> getAllDocuments() const {
+std::vector> AllDocs;
+std::lock_guard Guard(DocsMutex);
+for (const auto &P : Docs)
+  AllDocs.emplace_back(P.first(), P.second);
+return AllDocs;
+  }
+
 private:
   llvm::StringMap Docs;
+  std::vector> Listeners;
+
+  mutable std::mutex DocsMutex;
 };
 
 } // namespace clangd
Index: clangd/ClangDMain.cpp
===
--- clangd/ClangDMain.cpp
+++ clangd/ClangDMain.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "ASTManager.h"
 #include "DocumentStore.h"
 #include "JSONRPCDispatcher.h"
 #include "ProtocolHandlers.h"
@@ -27,6 +28,8 @@
   // Set up a document store and intialize all the method handlers for JSONRPC
   // dispatching.
   DocumentStore Store;
+  auto *AST = new ASTManager(Out, Store);
+  Store.addListener(std::unique_ptr(AST));
   JSONRPCDispatcher Dispatcher(llvm::make_unique(Out));
   Dispatcher.registerHandler("initialize",
  llvm::make_unique(Out));
Index: clangd/CMakeLists.txt
===
--- clangd/CMakeLists.txt
+++ clangd/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_clang_executable(clangd
+  ASTManager.cpp
   ClangDMain.cpp
   JSONRPCDispatcher.cpp
   Protocol.cpp
@@ -8,5 +9,7 @@
 target_link_libraries(clangd
   clangBasic
   clangFormat
+  clangFrontend
+  clangTooling
   LLVMSupport
   )
Index: clangd/ASTManager.h
===
--- /dev/null
+++ clangd/ASTManager.h
@@ -0,0 +1,73 @@
+//===--- ASTManager.h - Clang AST manager ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distribute

[PATCH] D23427: [Clang-tidy] Comparison Misuse

2017-02-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun abandoned this revision.
xazax.hun added a comment.

For the first case ToT clang compiler gives a warning (-Wstring-compare), for 
the second case, it generates a compiler error (error: ordered comparison 
between pointer and zero). Note that, older versions of clang did not even give 
a warning for that case.

It looks like this check no longer makes sense considering the current warnings 
and errors of clang top of tree.


Repository:
  rL LLVM

https://reviews.llvm.org/D23427



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


[PATCH] D23423: [Clang-tidy] Comparison Function Address

2017-02-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun abandoned this revision.
xazax.hun added a comment.

-Wtautological-pointer-compare already covers this case.


Repository:
  rL LLVM

https://reviews.llvm.org/D23423



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


[PATCH] D19586: Misleading Indentation check

2017-02-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun commandeered this revision.
xazax.hun edited reviewers, added: Pajesz; removed: xazax.hun.
xazax.hun added a comment.
Herald added a subscriber: mgorny.

The original author is no longer available.


https://reviews.llvm.org/D19586



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


[PATCH] D19586: Misleading Indentation check

2017-02-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 88182.
xazax.hun added a comment.

- Updated to latest trunk.
- Mentioned check in the release notes.
- Documented the limitation that tabs and spaces need to be consistent for this 
check to work.
- Fixed (hopefully all) review comments.
- Fixed the test cases.
- Minor code cleanups.


https://reviews.llvm.org/D19586

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/MisleadingIndentationCheck.cpp
  clang-tidy/readability/MisleadingIndentationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-misleading-indentation.rst
  test/clang-tidy/readability-misleading-indentation.cpp

Index: test/clang-tidy/readability-misleading-indentation.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-misleading-indentation.cpp
@@ -0,0 +1,79 @@
+// RUN: %check_clang_tidy %s readability-misleading-indentation %t
+
+void foo1();
+void foo2();
+
+#define BLOCK \
+  if (cond1)  \
+foo1();   \
+foo2();
+
+int main()
+{
+  bool cond1 = true;
+  bool cond2 = true;
+
+  if (cond1)
+if (cond2)
+  foo1();
+  else
+foo2();
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: potential dangling 'else' [readability-misleading-indentation]
+
+  if (cond1) {
+if (cond2)
+  foo1();
+  }
+  else
+foo2();
+
+  if (cond1)
+if (cond2)
+  foo1();
+else
+  foo2();
+
+  if (cond2)
+foo1();
+foo2();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: misleading indentation: statement is indented too deeply [readability-misleading-indentation]
+foo2(); // No redundant warning.
+
+  if (cond1)
+  {
+foo1();
+  }
+foo2();
+
+  if (cond1)
+foo1();
+  foo2();
+
+  if (cond2)
+if (cond1) foo1(); else foo2();
+
+  if (cond1) {
+  } else {
+  }
+
+  if (cond1) {
+  }
+  else {
+  }
+
+  if (cond1)
+  {
+  }
+  else
+  {
+  }
+
+  if (cond1)
+{
+}
+  else
+{
+}
+
+  BLOCK
+}
Index: docs/clang-tidy/checks/readability-misleading-indentation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-misleading-indentation.rst
@@ -0,0 +1,38 @@
+.. title:: clang-tidy - readability-misleading-indentation
+
+readability-misleading-indentation
+==
+
+Correct indentation helps to understand code. Mismatch of the syntactical
+structure and the indentation of the code may hide serious problems.
+Missing braces can also make it significantly harder to read the code,
+therefore it is important to use braces. 
+
+The way to avoid dangling else is to always check that an ``else`` belongs
+to the ``if`` that begins in the same column.
+
+You can omit braces when your inner part of e.g. an ``if`` statement has only
+one statement in it. Although in that case you should begin the next statement
+in the same column with the ``if``.
+
+Examples:
+
+.. code-block:: c++
+
+  // Dangling else:
+  if (cond1)
+if (cond2)
+  foo1();
+  else
+foo2();  // Wrong indentation: else belongs to if(cond2) statement.
+
+  // Missing braces:
+  if (cond1)
+foo1();
+foo2();  // Not guarded by if(cond1).
+
+Limitations
+===
+
+Note that this check only works as expected when the tabs or spaces are used
+consistently and not mixed.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -139,6 +139,7 @@
readability-identifier-naming
readability-implicit-bool-cast
readability-inconsistent-declaration-parameter-name
+   readability-misleading-indentation
readability-misplaced-array-index
readability-named-parameter
readability-non-const-parameter
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `readability-misleading-indentation
+  `_ check
+
+  Finds misleading indentation where braces should be introduced or the code should be reformatted.
+
 - New `safety-no-assembler
   `_ check
 
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -20,6 +20,7 @@
 #include "IdentifierNamingCheck.h"
 #include "ImplicitBoolCastCheck.h"
 #include "InconsistentDeclarationParameterNameCheck.h"
+#include "MisleadingIndentationCheck.h"
 #include "MisplacedArrayIndexCheck.h"
 #include "NamedParameterCheck.h"
 #include "Non

[PATCH] D19586: Misleading Indentation check

2017-02-13 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 13 inline comments as done.
xazax.hun added inline comments.



Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:20
+
+void MisleadingIndentationCheck::danglingElseCheck(
+const MatchFinder::MatchResult &Result) {

danielmarjamaki wrote:
> There is no handling of tabs and spaces by danglingElseCheck as far as I see.
> 
> The "if" might for example be indented with spaces. And then the 
> corresponding "else" is indented with a tab. Then I guess there is false 
> positive.
> 
> If the "if" is indented with 2 spaces and the "else" is indented with 2 tabs. 
> then I assume there is false negative.
> 
> It's unfortunate. Is it ok?
Documented this limitation.


https://reviews.llvm.org/D19586



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


[PATCH] D29770: [Assembler] Inline assembly diagnostics test.

2017-02-13 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 updated this revision to Diff 88188.
sanwou01 added a comment.

Use clang_cc1 -verify for testing as suggested by @rnk.

@echristo, llc does use the same diags interfaces as clang, however, it is
lacking the infrastructure to make use of LocCookies.

In any case, I think this test is useful to prevent regressions in inline
assembly diagnostics in clang.


https://reviews.llvm.org/D29770

Files:
  test/Misc/inline-asm-diags.c


Index: test/Misc/inline-asm-diags.c
===
--- /dev/null
+++ test/Misc/inline-asm-diags.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -S -emit-obj -triple armv7a-arm-none-eabi %s -o /dev/null 
-verify
+
+void foo2() {
+   asm(" wibble"); // expected-error{{invalid instruction}}
+}
+
+void foo() {
+   asm(" .word -bar");  // expected-error {{expected relocatable 
expression}}
+   asm(" .word -foo");  // expected-error {{expected relocatable 
expression}}
+}
+
+// expected-note@1 {{instantiated into assembly here}}
+// expected-note@1 {{instantiated into assembly here}}
+// expected-note@1 {{instantiated into assembly here}}


Index: test/Misc/inline-asm-diags.c
===
--- /dev/null
+++ test/Misc/inline-asm-diags.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -S -emit-obj -triple armv7a-arm-none-eabi %s -o /dev/null -verify
+
+void foo2() {
+	asm(" wibble"); // expected-error{{invalid instruction}}
+}
+
+void foo() {
+	asm(" .word -bar");  // expected-error {{expected relocatable expression}}
+	asm(" .word -foo");  // expected-error {{expected relocatable expression}}
+}
+
+// expected-note@1 {{instantiated into assembly here}}
+// expected-note@1 {{instantiated into assembly here}}
+// expected-note@1 {{instantiated into assembly here}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29757: [libcxx] Threading support: Externalize hardware_concurrency()

2017-02-13 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 88189.
rmaprath retitled this revision from "Threading support: Externalize 
hardware_concurrency()" to "[libcxx] Threading support: Externalize 
hardware_concurrency()".
rmaprath added a comment.

Re-based on trunk.


https://reviews.llvm.org/D29757

Files:
  include/__threading_support
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -15,26 +15,6 @@
 #include "vector"
 #include "future"
 #include "limits"
-#include 
-
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
-# include 
-# if defined(BSD)
-#   include 
-# endif // defined(BSD)
-#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
-
-#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__)
-# include 
-#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__)
-
-#if defined(__NetBSD__)
-#pragma weak pthread_create // Do not create libpthread dependency
-#endif
-
-#if defined(_LIBCPP_WIN32API)
-#include 
-#endif // defined(_LIBCPP_WIN32API)
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -77,35 +57,13 @@
 unsigned
 thread::hardware_concurrency() _NOEXCEPT
 {
-#if defined(CTL_HW) && defined(HW_NCPU)
-unsigned n;
-int mib[2] = {CTL_HW, HW_NCPU};
-std::size_t s = sizeof(n);
-sysctl(mib, 2, &n, &s, 0, 0);
-return n;
-#elif defined(_SC_NPROCESSORS_ONLN)
-long result = sysconf(_SC_NPROCESSORS_ONLN);
-// sysconf returns -1 if the name is invalid, the option does not exist or
-// does not have a definite limit.
-// if sysconf returns some other negative number, we have no idea
-// what is going on. Default to something safe.
+int result = __libcpp_thread_hw_concurrency();
+
+// Treat negative values as errors. Use a safe default value.
 if (result < 0)
 return 0;
-return static_cast(result);
-#elif defined(_LIBCPP_WIN32API)
-SYSTEM_INFO info;
-GetSystemInfo(&info);
-return info.dwNumberOfProcessors;
-#else  // defined(CTL_HW) && defined(HW_NCPU)
-// TODO: grovel through /proc or check cpuid on x86 and similar
-// instructions on other architectures.
-#   if defined(_LIBCPP_MSVC)
-_LIBCPP_WARNING("hardware_concurrency not yet implemented")
-#   else
-#   warning hardware_concurrency not yet implemented
-#   endif
-return 0;  // Means not computable [thread.thread.static]
-#endif  // defined(CTL_HW) && defined(HW_NCPU)
+
+return result;
 }
 
 namespace this_thread
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -26,6 +26,22 @@
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
 # include 
 # include 
+
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+# include 
+# if defined(BSD)
+#   include 
+# endif // defined(BSD)
+#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
+
+#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__)
+# include 
+#endif // defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__CloudABI__)
+
+#if defined(__NetBSD__)
+#pragma weak pthread_create // Do not create libpthread dependency
+#endif
+
 #elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
 #include 
 #include 
@@ -186,6 +202,9 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns);
 
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_thread_hw_concurrency();
+
 // Thread local storage
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_tls_create(__libcpp_tls_key* __key,
@@ -370,6 +389,28 @@
while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR);
 }
 
+int __libcpp_thread_hw_concurrency()
+{
+#if defined(CTL_HW) && defined(HW_NCPU)
+  int __n;
+  int __mib[2] = {CTL_HW, HW_NCPU};
+  std::size_t __sz = sizeof(__n);
+  sysctl(__mib, 2, &__n, &__sz, 0, 0);
+  return __n;
+#elif defined(_SC_NPROCESSORS_ONLN)
+  return sysconf(_SC_NPROCESSORS_ONLN);
+#else  // !(defined(CTL_HW) && defined(HW_NCPU))
+  // TODO: grovel through /proc or check cpuid on x86 and similar
+  // instructions on other architectures.
+# if defined(_LIBCPP_MSVC)
+_LIBCPP_WARNING("hardware_concurrency not yet implemented")
+# else
+#   warning hardware_concurrency not yet implemented
+# endif
+  return 0;  // Means not computable [thread.thread.static]
+#endif  // defined(CTL_HW) && defined(HW_NCPU
+}
+
 // Thread local storage
 int __libcpp_tls_create(__libcpp_tls_key *__key, void (*__at_exit)(void *))
 {
@@ -596,6 +637,13 @@
   Sleep(__ms.count());
 }
 
+int __libcpp_thread_hw_concurrency()
+{
+  SYSTEM_INFO __info;
+  GetSystemInfo(&__info);
+  return __info.dwNumberOfProcessors;
+}
+
 // Thread Local Storage
 int __libcpp_tls_create(__libcpp_tls_key* __key,
 void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(vo

[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations

2017-02-13 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath updated this revision to Diff 88190.
rmaprath added a comment.

Re-based.


https://reviews.llvm.org/D29818

Files:
  include/__threading_support
  src/chrono.cpp

Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -10,50 +10,7 @@
 #include "chrono"
 #include "cerrno"// errno
 #include "system_error"  // __throw_system_error
-#include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
-
-#if (__APPLE__)
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 10
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 10
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 3
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
-#else
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif // __APPLE__
-
-#if defined(_LIBCPP_WIN32API)
-#define WIN32_LEAN_AND_MEAN
-#define VC_EXTRA_LEAN
-#include 
-#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
-#include 
-#endif
-#else
-#if !defined(CLOCK_REALTIME) || !defined(_LIBCXX_USE_CLOCK_GETTIME)
-#include // for gettimeofday and timeval
-#endif // !defined(CLOCK_REALTIME)
-#endif // defined(_LIBCPP_WIN32API)
-
-#if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
-#if __APPLE__
-#include   // mach_absolute_time, mach_timebase_info_data_t
-#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
-#error "Monotonic clock not implemented"
-#endif
-#endif
+#include "__threading_support"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -67,42 +24,7 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
-  // FILETIME is in 100ns units
-  using filetime_duration =
-  _VSTD::chrono::duration<__int64,
-  _VSTD::ratio_multiply<_VSTD::ratio<100, 1>,
-nanoseconds::period>>;
-
-  // The Windows epoch is Jan 1 1601, the Unix epoch Jan 1 1970.
-  static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600};
-
-  FILETIME ft;
-#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-  GetSystemTimePreciseAsFileTime(&ft);
-#else
-  GetSystemTimeAsFileTime(&ft);
-#endif
-#else
-  GetSystemTimeAsFileTime(&ft);
-#endif
-
-  filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
-   static_cast<__int64>(ft.dwLowDateTime)};
-  return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
-struct timespec tp;
-if (0 != clock_gettime(CLOCK_REALTIME, &tp))
-__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
-return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
-#else
-timeval tv;
-gettimeofday(&tv, 0);
-return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
-#endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
+return __libcpp_clock_system_now();
 }
 
 time_t
@@ -193,42 +115,15 @@
 }
 #endif // defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
 
-#elif defined(_LIBCPP_WIN32API)
-
-steady_clock::time_point
-steady_clock::now() _NOEXCEPT
-{
-  static LARGE_INTEGER freq;
-  static BOOL initialized = FALSE;
-  if (!initialized)
-initialized = QueryPerformanceFrequency(&freq); // always succceeds
-
-  LARGE_INTEGER counter;
-  QueryPerformanceCounter(&counter);
-  return time_point(duration(counter.QuadPart * nano::den / freq.QuadPart));
-}
-
-#elif defined(CLOCK_MONOTONIC)
-
-// On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able to
-// time functions in the nanosecond range. Thus, they are the only acceptable
-// implementations of steady_clock.
-#ifdef __APPLE__
-#error "Never use CLOCK_MONOTONIC for steady_clock::now on Apple platforms"
-#endif
+#else
 
 steady_clock::time_point
 steady_clock::now() _NOEXCEPT
 {
-struct timespec tp;
-if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
-__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
-return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+return __libcpp_clock_steady_now();
 }
 
-#else
-#error "Monotonic clock not implemented"
-#endif
+#endif // __APPLE__
 
 #endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK
 
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -13,7 +13,9 @@
 
 #include <__config>
 #include 
-#include 
+#include 
+#include 
+

[PATCH] D29839: [clang-tidy] New misc-istream-overflow check

2017-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D29839#674714, @cryptoad wrote:

> So if I understand correctly, the consensus is to abandon this and rewrite it 
> to be part of the clang static analyzer?


That's correct.


https://reviews.llvm.org/D29839



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


[PATCH] D29830: [OpenCL][Doc] Relase 4.0 notes for OpenCL

2017-02-13 Thread Pekka Jääskeläinen via Phabricator via cfe-commits
pekka.jaaskelainen accepted this revision.
pekka.jaaskelainen added a comment.

LGTM.


https://reviews.llvm.org/D29830



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


[PATCH] D29868: Recover more gracefully when __declspec is not supported as a keyword

2017-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 88198.
aaron.ballman added a comment.

Fixed review feedback


https://reviews.llvm.org/D29868

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  lib/Parse/ParseDecl.cpp
  test/Parser/declspec-recovery.c
  test/Parser/declspec-supported.c


Index: test/Parser/declspec-supported.c
===
--- test/Parser/declspec-supported.c
+++ test/Parser/declspec-supported.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -fms-extensions 
-verify %s
+// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -fdeclspec -verify %s
+// expected-no-diagnostics
+
+__declspec(naked) void f(void) {}
+
+struct S {
+  __declspec(property(get=Getter, put=Setter)) int X;
+  int Y;
+};
Index: test/Parser/declspec-recovery.c
===
--- test/Parser/declspec-recovery.c
+++ test/Parser/declspec-recovery.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -verify %s
+
+__declspec(naked) void f(void) {} // expected-error{{'__declspec' attributes 
are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for 
__declspec attributes}}
+
+struct S {
+  __declspec(property(get=Getter, put=Setter)) int X; // 
expected-error{{'__declspec' attributes are not enabled; use '-fdeclspec' or 
'-fms-extensions' to enable support for __declspec attributes}}
+  int Y;
+};
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -2966,6 +2966,31 @@
   if (DS.hasTypeSpecifier())
 goto DoneWithDeclSpec;
 
+  // If the token is an identifier named "__declspec" and Microsoft
+  // extensions are not enabled, it is likely that there will be cascading
+  // parse errors if this really is a __declspec attribute. Attempt to
+  // recognize that scenario and recover gracefully.
+  if (!getLangOpts().DeclSpecKeyword && Tok.is(tok::identifier) &&
+  Tok.getIdentifierInfo()->getName().equals("__declspec")) {
+Diag(Loc, diag::err_ms_attributes_not_enabled);
+
+// The next token should be an open paren. If it is, eat the entire
+// attribute declaration and continue.
+if (NextToken().is(tok::l_paren)) {
+  // Consume the __declspec identifier.
+  SourceLocation Loc = ConsumeToken();
+
+  // Eat the parens and everything between them.
+  BalancedDelimiterTracker T(*this, tok::l_paren);
+  if (T.consumeOpen()) {
+assert(false && "Not a left paren?");
+return;
+  }
+  T.skipToEnd();
+  continue;
+}
+  }
+
   // In C++, check to see if this is a scope specifier like foo::bar::, if
   // so handle it as such.  This is important for ctor parsing.
   if (getLangOpts().CPlusPlus) {
Index: include/clang/Basic/DiagnosticParseKinds.td
===
--- include/clang/Basic/DiagnosticParseKinds.td
+++ include/clang/Basic/DiagnosticParseKinds.td
@@ -176,6 +176,9 @@
 def warn_attribute_no_decl : Warning<
   "attribute %0 ignored, because it is not attached to a declaration">, 
   InGroup;
+def err_ms_attributes_not_enabled : Error<
+  "'__declspec' attributes are not enabled; use '-fdeclspec' or "
+  "'-fms-extensions' to enable support for __declspec attributes">;
 def err_expected_method_body : Error<"expected method body">;
 def err_declspec_after_virtspec : Error<
   "'%0' qualifier may not appear after the virtual specifier '%1'">;


Index: test/Parser/declspec-supported.c
===
--- test/Parser/declspec-supported.c
+++ test/Parser/declspec-supported.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -fms-extensions -verify %s
+// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -fdeclspec -verify %s
+// expected-no-diagnostics
+
+__declspec(naked) void f(void) {}
+
+struct S {
+  __declspec(property(get=Getter, put=Setter)) int X;
+  int Y;
+};
Index: test/Parser/declspec-recovery.c
===
--- test/Parser/declspec-recovery.c
+++ test/Parser/declspec-recovery.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple i386-pc-unknown -fsyntax-only -verify %s
+
+__declspec(naked) void f(void) {} // expected-error{{'__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes}}
+
+struct S {
+  __declspec(property(get=Getter, put=Setter)) int X; // expected-error{{'__declspec' attributes are not enabled; use '-fdeclspec' or '-fms-extensions' to enable support for __declspec attributes}}
+  int Y;
+};
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.

[PATCH] D29868: Recover more gracefully when __declspec is not supported as a keyword

2017-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 3 inline comments as done.
aaron.ballman added inline comments.



Comment at: lib/Parse/ParseDecl.cpp:2989
+
+  Diag(Loc, diag::err_ms_attributes_not_enabled);
+  continue;

compnerd wrote:
> aaron.ballman wrote:
> > compnerd wrote:
> > > I think that we want to emit the diagnostic even if there is no 
> > > parenthesis as `__declspec` is a reserved identifier, and we would 
> > > normally diagnose the bad `__declspec` (expected '(' after '__declspec').
> > Yes, but it could also lead to a rejecting code that we used to accept and 
> > properly handle when __declspec is an identifier rather than a keyword. 
> > e.g.,
> > ```
> > struct __declspec {};
> > 
> > __declspec some_func(void);
> > ```
> > By looking for the paren, we run less risk of breaking working code, even 
> > if that code abuses the implementation namespace (after all, __declspec it 
> > not a keyword in this scenario).
> But we would reject that code under `-fdeclspec` anyways.  I think having the 
> code be more portable is a bit nicer.
After discussing in IRC, I decided that I agree with @compnerd on this and have 
changed the patch accordingly.


https://reviews.llvm.org/D29868



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


r294954 - Fix r291495 -- Normalize LLVM_CMAKE_PATH in clang standalone build.

2017-02-13 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Mon Feb 13 08:59:53 2017
New Revision: 294954

URL: http://llvm.org/viewvc/llvm-project?rev=294954&view=rev
Log:
Fix r291495 -- Normalize LLVM_CMAKE_PATH in clang standalone build.

CMake handles paths with slashes. It caused cmake/install failure on 
msbuild.exe.

Note, Other llvm-config-oriented variables have been normalized since they are 
stored in the cache attributed with PATH.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=294954&r1=294953&r2=294954&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Mon Feb 13 08:59:53 2017
@@ -42,7 +42,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
   list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
   list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
-  list(GET CONFIG_OUTPUT 6 LLVM_CMAKE_PATH)
+  list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH)
 
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
@@ -57,6 +57,10 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
   set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
+  # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
+  # CMake assumes slashes as PATH.
+  get_filename_component(LLVM_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} ABSOLUTE)
+
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
 


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


[PATCH] D29886: [clangd] Wire up ASTUnit and publish diagnostics with it.

2017-02-13 Thread Wojciech Cierpucha via Phabricator via cfe-commits
cierpuchaw added inline comments.



Comment at: clangd/DocumentStore.h:42
   /// Delete a document from the store.
-  void removeDocument(StringRef Uri) { Docs.erase(Uri); }
+  void removeDocument(StringRef Uri) { Docs.erase(Uri);
+for (const auto &Listener : Listeners)

Shouldn't this be called under a lock_guard?


https://reviews.llvm.org/D29886



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


[PATCH] D29886: [clangd] Wire up ASTUnit and publish diagnostics with it.

2017-02-13 Thread Wojciech Cierpucha via Phabricator via cfe-commits
cierpuchaw added inline comments.



Comment at: clangd/DocumentStore.h:42
   /// Delete a document from the store.
-  void removeDocument(StringRef Uri) { Docs.erase(Uri); }
+  void removeDocument(StringRef Uri) { Docs.erase(Uri);
+for (const auto &Listener : Listeners)

cierpuchaw wrote:
> Shouldn't this be called under a lock_guard?
I should've reworded my comment before submitting it. By 'this' I'm referring 
to the 'Docs.erase()' part, not the whole function.



https://reviews.llvm.org/D29886



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


[libcxx] r294956 - test: mark another test as requiring pthreads

2017-02-13 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Feb 13 09:26:47 2017
New Revision: 294956

URL: http://llvm.org/viewvc/llvm-project?rev=294956&view=rev
Log:
test: mark another test as requiring pthreads

This is checking pthread specific behaviour.  Add a requirement on
pthreads.

Modified:

libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp

Modified: 
libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp?rev=294956&r1=294955&r2=294956&view=diff
==
--- 
libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
 (original)
+++ 
libcxx/trunk/test/libcxx/thread/thread.threads/thread.thread.class/types.pass.cpp
 Mon Feb 13 09:26:47 2017
@@ -8,6 +8,7 @@
 
//===--===//
 //
 // UNSUPPORTED: libcpp-has-no-threads, libcpp-has-thread-api-external
+// REQUIRES: libcpp-has-thread-api-pthread
 
 // 
 


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


[libcxx] r294957 - math: actually pull the declarations/overloads into std

2017-02-13 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Feb 13 09:26:50 2017
New Revision: 294957

URL: http://llvm.org/viewvc/llvm-project?rev=294957&view=rev
Log:
math: actually pull the declarations/overloads into std

The previous changes missed the change to include/cmath.  These changes
allow some of the rand.distribution tests to pass on Windows.

Modified:
libcxx/trunk/include/cmath
libcxx/trunk/include/math.h

Modified: libcxx/trunk/include/cmath
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cmath?rev=294957&r1=294956&r2=294957&view=diff
==
--- libcxx/trunk/include/cmath (original)
+++ libcxx/trunk/include/cmath Mon Feb 13 09:26:50 2017
@@ -398,7 +398,7 @@ using ::cbrtf;
 using ::copysign;
 using ::copysignf;
 
-#ifndef _LIBCPP_MSVCRT
+#if !defined(_LIBCPP_MSVCRT) || ((_VC_CRT_NAJOR_VERSION-0) >= 14)
 using ::erf;
 using ::erff;
 using ::erfc;

Modified: libcxx/trunk/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=294957&r1=294956&r2=294957&view=diff
==
--- libcxx/trunk/include/math.h (original)
+++ libcxx/trunk/include/math.h Mon Feb 13 09:26:50 2017
@@ -293,6 +293,9 @@ long doubletruncl(long double x);
 */
 
 #include <__config>
+#if defined(_LIBCPP_MSVCRT)
+#include 
+#endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header


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


[libcxx] r294958 - config: disable thread safety analysis on COFF

2017-02-13 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Mon Feb 13 09:26:51 2017
New Revision: 294958

URL: http://llvm.org/viewvc/llvm-project?rev=294958&view=rev
Log:
config: disable thread safety analysis on COFF

clang cannot properly handle __declspec and __attribute__ on classes
right now.  This prevents the shared_mutex tests from working.  Disable
the use of the annotation on COFF targets.

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=294958&r1=294957&r2=294958&view=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Feb 13 09:26:51 2017
@@ -1012,10 +1012,16 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
 #endif
 
-#if (defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) \
-  && __has_attribute(acquire_capability))
+#if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS)
+#if defined(__clang__) && __has_attribute(acquire_capability)
+// Work around the attribute handling in clang.  When both __declspec and
+// __attribute__ are present, the processing goes awry preventing the 
definition
+// of the types.
+#if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
 #define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
 #endif
+#endif
+#endif
 
 #if __has_attribute(require_constant_initialization)
 #define _LIBCPP_SAFE_STATIC 
__attribute__((__require_constant_initialization__))


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


Re: r294954 - Fix r291495 -- Normalize LLVM_CMAKE_PATH in clang standalone build.

2017-02-13 Thread Michał Górny via cfe-commits
W dniu 13.02.2017, pon o godzinie 14∶59 +, użytkownik NAKAMURA
Takumi via cfe-commits napisał:
> Author: chapuni
> Date: Mon Feb 13 08:59:53 2017
> New Revision: 294954
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=294954&view=rev
> Log:
> Fix r291495 -- Normalize LLVM_CMAKE_PATH in clang standalone build.
> 
> CMake handles paths with slashes. It caused cmake/install failure on 
> msbuild.exe.
> 
> Note, Other llvm-config-oriented variables have been normalized since they 
> are stored in the cache attributed with PATH.
> 
> Modified:
> cfe/trunk/CMakeLists.txt
> 
> Modified: cfe/trunk/CMakeLists.txt
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=294954&r1=294953&r2=294954&view=diff
> ==
> --- cfe/trunk/CMakeLists.txt (original)
> +++ cfe/trunk/CMakeLists.txt Mon Feb 13 08:59:53 2017
> @@ -42,7 +42,7 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
>list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
>list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
>list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
> -  list(GET CONFIG_OUTPUT 6 LLVM_CMAKE_PATH)
> +  list(GET CONFIG_OUTPUT 6 LLVM_CONFIG_CMAKE_PATH)
>  
>if(NOT MSVC_IDE)
>  set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
> @@ -57,6 +57,10 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
>set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
>set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source 
> tree")
>  
> +  # Normalize LLVM_CMAKE_PATH. --cmakedir might contain backslashes.
> +  # CMake assumes slashes as PATH.
> +  get_filename_component(LLVM_CMAKE_PATH ${LLVM_CONFIG_CMAKE_PATH} ABSOLUTE)

Are you sure this is the best way of doing it? I'm not a Windows expert
but I've seen others using file(TO_CMAKE_PATH ...) for what I suppose
was the same goal.

> +
>find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
>  NO_DEFAULT_PATH)
>  
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

-- 
Best regards,
Michał Górny


signature.asc
Description: This is a digitally signed message part
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29542: [TargetInfo] Adjust x86-32 atomic support to the CPU used

2017-02-13 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Le gentle ping.


https://reviews.llvm.org/D29542



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


[PATCH] D29858: [clang-tidy] Catch trivially true statements like a != 1 || a != 3

2017-02-13 Thread Etienne Bergeron via Phabricator via cfe-commits
etienneb added a comment.

Could you add some tests with enums (like the one in your description)?
This is missing and it's a nice to have.




Comment at: clang-tidy/misc/RedundantExpressionCheck.cpp:244
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+return true;

The good news is that this code will be catch by this check!
```
  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)   <<-- redundant expression
```
Should be:
```
  if (OpcodeLHS == BO_NE || OpcodeRHS == BO_NE) 
```





https://reviews.llvm.org/D29858



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


Re: r293199 - Turn on -Wblock-capture-autoreleasing by default.

2017-02-13 Thread Nico Weber via cfe-commits
If I'm understanding you correctly, you're saying that clang implicitly
marks the indirect NSError** parameter with __autoreleasing, so there's no
bug here. Is that correct? If so, should Wblock-capture-autoreleasing just
not fire on parameters that are already implicitly marked as
__autoreleasing?

On Mon, Feb 13, 2017 at 1:54 AM, Akira Hatanaka  wrote:

> Hi Nico,
>
> The documentation might confuse people now that the warning is on by
> default, but it’s correct as clang still qualifies indirect parameters with
> __autoreleasing. We had to add this warning and turn it on by default
> because a lot of people capture indirect parameters in their code not
> realizing the object assigned might get released by an autorelease pool.
>
> Perhaps we can change the warning message or the documentation to make it
> clear that the parameter has been implicitly marked __autoreleasing
> regardless.
>
> On Feb 11, 2017, at 11:54 AM, Nico Weber  wrote:
>
> Hi Akira,
>
> this fires in internal chrome/ios code like so:
>
> somefile.m: error: block captures an autoreleasing out-parameter, which
> may result in use-after-free bugs [-Werror,-Wblock-capture-autoreleasing]
>   if (error) {
>   ^
> somefile.m: note: declare the parameter __autoreleasing explicitly to
> suppress this warning
> - (NSDictionary *)fooWithError:(NSError **)error {
>   ^
>   __autoreleasing
> somefile.m: note: declare the parameter __strong or capture a __block
> __strong variable to keep values alive across autorelease pools
>
>
> A colleague points out that http://clang.llvm.org/docs/
> AutomaticReferenceCounting.html#indirect-parameters suggests NSError **
> should "be implicitly qualified with __autoreleasing." Is that a bug in the
> implementation of the warning, is AutomaticReferenceCounting.html
> incorrect, or are we just misunderstanding that document?
>
> Thanks,
> Nico
>
> On Thu, Jan 26, 2017 at 1:51 PM, Akira Hatanaka via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ahatanak
>> Date: Thu Jan 26 12:51:10 2017
>> New Revision: 293199
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=293199&view=rev
>> Log:
>> Turn on -Wblock-capture-autoreleasing by default.
>>
>> Turning on the warning by default helps the users as it's a common
>> mistake to capture out-parameters in a block without ensuring the object
>> assigned doesn't get released.
>>
>> rdar://problem/30200058
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/test/SemaObjC/arc.m
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticSemaKinds.td?rev=293199&r1=293198&r2=293199&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 26
>> 12:51:10 2017
>> @@ -5185,7 +5185,7 @@ def err_arc_inconsistent_property_owners
>>  def warn_block_capture_autoreleasing : Warning<
>>"block captures an autoreleasing out-parameter, which may result in "
>>"use-after-free bugs">,
>> -  InGroup, DefaultIgnore;
>> +  InGroup;
>>  def note_declare_parameter_autoreleasing : Note<
>>"declare the parameter __autoreleasing explicitly to suppress this
>> warning">;
>>  def note_declare_parameter_strong : Note<
>>
>> Modified: cfe/trunk/test/SemaObjC/arc.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/
>> arc.m?rev=293199&r1=293198&r2=293199&view=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaObjC/arc.m (original)
>> +++ cfe/trunk/test/SemaObjC/arc.m Thu Jan 26 12:51:10 2017
>> @@ -1,4 +1,4 @@
>> -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak
>> -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class
>> -Wblock-capture-autoreleasing %s
>> +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak
>> -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s
>>
>>  typedef unsigned long NSUInteger;
>>  typedef const void * CFTypeRef;
>>
>>
>> ___
>> 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] D29886: [clangd] Wire up ASTUnit and publish diagnostics with it.

2017-02-13 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/ASTManager.cpp:21
+using namespace clang;
+using namespace clangd;
+

Any reason not to wrap code in namespaces instead?


https://reviews.llvm.org/D29886



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


[PATCH] D19586: Misleading Indentation check

2017-02-13 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:72
+SM.getExpansionColumnNumber(NextLoc))
+  diag(NextLoc, "misleading indentation: statement is indented too 
deeply");
+  }

Will it be useful to add a note pointing to the control statement and saying 
"did you mean this line to be inside this if/while/for/..."?



Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:79
+  Finder->addMatcher(
+  compoundStmt(anyOf(has(ifStmt()), has(forStmt()), has(whileStmt(
+  .bind("compound"),

`has(anyOf(ifStmt(), forStmt(), whileStmt()))` would read better.


https://reviews.llvm.org/D19586



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


r294961 - [PM] Add support for instrumented PGO in the new pass manager (clang-side)

2017-02-13 Thread Davide Italiano via cfe-commits
Author: davide
Date: Mon Feb 13 10:07:05 2017
New Revision: 294961

URL: http://llvm.org/viewvc/llvm-project?rev=294961&view=rev
Log:
[PM] Add support for instrumented PGO in the new pass manager (clang-side)

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

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=294961&r1=294960&r2=294961&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon Feb 13 10:07:05 2017
@@ -61,6 +61,9 @@ using namespace llvm;
 
 namespace {
 
+// Default filename used for profile generation.
+static constexpr StringLiteral DefaultProfileGenName = "default_%m.profraw";
+
 class EmitAssemblyHelper {
   DiagnosticsEngine &Diags;
   const HeaderSearchOptions &HSOpts;
@@ -448,7 +451,7 @@ void EmitAssemblyHelper::CreatePasses(le
 if (!CodeGenOpts.InstrProfileOutput.empty())
   PMBuilder.PGOInstrGen = CodeGenOpts.InstrProfileOutput;
 else
-  PMBuilder.PGOInstrGen = "default_%m.profraw";
+  PMBuilder.PGOInstrGen = DefaultProfileGenName;
   }
   if (CodeGenOpts.hasProfileIRUse())
 PMBuilder.PGOInstrUse = CodeGenOpts.ProfileInstrumentUsePath;
@@ -775,7 +778,24 @@ void EmitAssemblyHelper::EmitAssemblyWit
 return;
   TheModule->setDataLayout(TM->createDataLayout());
 
-  PassBuilder PB(TM.get());
+  PGOOptions PGOOpt;
+
+  // -fprofile-generate.
+  PGOOpt.RunProfileGen = CodeGenOpts.hasProfileIRInstr();
+  if (PGOOpt.RunProfileGen)
+PGOOpt.ProfileGenFile = CodeGenOpts.InstrProfileOutput.empty() ?
+  DefaultProfileGenName : CodeGenOpts.InstrProfileOutput;
+
+  // -fprofile-use.
+  if (CodeGenOpts.hasProfileIRUse())
+PGOOpt.ProfileUseFile = CodeGenOpts.ProfileInstrumentUsePath;
+
+  // Only pass a PGO options struct if -fprofile-generate or
+  // -fprofile-use were passed on the cmdline.
+  PassBuilder PB(TM.get(),
+(PGOOpt.RunProfileGen ||
+  !PGOOpt.ProfileUseFile.empty()) ?
+Optional(PGOOpt) : None);
 
   LoopAnalysisManager LAM;
   FunctionAnalysisManager FAM;


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


[PATCH] D29857: Catch trivially true statements of the form a != 1 || a != 3. Statements likethese are likely errors. They are particularly easy to miss when handling enums:enum State {RUNNING, STOPPE

2017-02-13 Thread Etienne Bergeron via Phabricator via cfe-commits
etienneb added a comment.

which one is the final version?

https://reviews.llvm.org/D25946

Please close one of them.


https://reviews.llvm.org/D29857



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


r294963 - [ASTUnit] Clear out diagnostic state after creating the preamble.

2017-02-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Feb 13 10:16:43 2017
New Revision: 294963

URL: http://llvm.org/viewvc/llvm-project?rev=294963&view=rev
Log:
[ASTUnit] Clear out diagnostic state after creating the preamble.

If the preamble had diagnostic state this would leave behind invalid
state in the DiagnosticsEngine and crash later. The test case runs into
an assertion in DiagnosticsEngine::setSourceManager.

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/test/Index/complete-preamble.h

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=294963&r1=294962&r2=294963&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Feb 13 10:16:43 2017
@@ -1891,6 +1891,8 @@ bool ASTUnit::LoadFromCompilerInvocation
 PreambleRebuildCounter = PrecompilePreambleAfterNParses;
 OverrideMainBuffer =
 getMainBufferWithPrecompiledPreamble(PCHContainerOps, *Invocation);
+getDiagnostics().Reset();
+ProcessWarningOptions(getDiagnostics(), Invocation->getDiagnosticOpts());
   }
   
   SimpleTimer ParsingTimer(WantTiming);

Modified: cfe/trunk/test/Index/complete-preamble.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-preamble.h?rev=294963&r1=294962&r2=294963&view=diff
==
--- cfe/trunk/test/Index/complete-preamble.h (original)
+++ cfe/trunk/test/Index/complete-preamble.h Mon Feb 13 10:16:43 2017
@@ -1,6 +1,11 @@
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Weverything"
+
 namespace std {
   void wibble();
 }
 
+#pragma clang diagnostic pop
+
 namespace std {
 }


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


[PATCH] D29893: [change-namespace] add an option to dump changed files in YAML.

2017-02-13 Thread Eric Liu via Phabricator via cfe-commits
ioeric created this revision.
Herald added a subscriber: fhahn.

https://reviews.llvm.org/D29893

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/tool/ClangChangeNamespace.cpp


Index: change-namespace/tool/ClangChangeNamespace.cpp
===
--- change-namespace/tool/ClangChangeNamespace.cpp
+++ change-namespace/tool/ClangChangeNamespace.cpp
@@ -39,6 +39,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
@@ -63,6 +64,11 @@
 cl::opt Inplace("i", cl::desc("Inplace edit s, if specified."),
   cl::cat(ChangeNamespaceCategory));
 
+cl::opt
+DumpYAML("dump_yaml",
+ cl::desc("Dump new file content in YAML, if specified."),
+ cl::cat(ChangeNamespaceCategory));
+
 cl::opt Style("style",
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
@@ -101,14 +107,41 @@
   if (Inplace)
 return Rewrite.overwriteChangedFiles();
 
-  for (const auto &File : Files) {
+  std::set ChangedFiles;
+  for (const auto &it : Tool.getReplacements())
+ChangedFiles.insert(it.first);
+
+  if (DumpYAML) {
+auto WriteToYAML = [&](llvm::raw_ostream &OS) {
+  OS << "[\n";
+  for (auto I = ChangedFiles.begin(), E = ChangedFiles.end(); I != E; ++I) 
{
+OS << "  {\n";
+OS << "\"FilePath\": \"" << *I << "\",\n";
+const auto *Entry = FileMgr.getFile(*I);
+auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
+std::string Content;
+llvm::raw_string_ostream ContentStream(Content);
+Rewrite.getEditBuffer(ID).write(ContentStream);
+OS << "\"SourceText\": \""
+   << llvm::yaml::escape(ContentStream.str()) << "\"\n";
+OS << "  }";
+if (I != std::prev(E))
+  OS << ",\n";
+  }
+  OS << "\n]\n";
+};
+WriteToYAML(llvm::outs());
+return 0;
+  }
+
+  for (const auto &File : ChangedFiles) {
 const auto *Entry = FileMgr.getFile(File);
 
 auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
-// FIXME: print results in parsable format, e.g. JSON.
 outs() << "== " << File << " ==\n";
 Rewrite.getEditBuffer(ID).write(llvm::outs());
 outs() << "\n\n";
   }
+
   return 0;
 }
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -275,7 +275,7 @@
 // Returns true if \p D is visible at \p Loc with DeclContext \p DeclCtx.
 bool isDeclVisibleAtLocation(const SourceManager &SM, const Decl *D,
  const DeclContext *DeclCtx, SourceLocation Loc) {
-  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocation());
+  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocStart());
   Loc = SM.getSpellingLoc(Loc);
   return SM.isBeforeInTranslationUnit(DeclLoc, Loc) &&
  (SM.getFileID(DeclLoc) == SM.getFileID(Loc) &&


Index: change-namespace/tool/ClangChangeNamespace.cpp
===
--- change-namespace/tool/ClangChangeNamespace.cpp
+++ change-namespace/tool/ClangChangeNamespace.cpp
@@ -39,6 +39,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
@@ -63,6 +64,11 @@
 cl::opt Inplace("i", cl::desc("Inplace edit s, if specified."),
   cl::cat(ChangeNamespaceCategory));
 
+cl::opt
+DumpYAML("dump_yaml",
+ cl::desc("Dump new file content in YAML, if specified."),
+ cl::cat(ChangeNamespaceCategory));
+
 cl::opt Style("style",
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
@@ -101,14 +107,41 @@
   if (Inplace)
 return Rewrite.overwriteChangedFiles();
 
-  for (const auto &File : Files) {
+  std::set ChangedFiles;
+  for (const auto &it : Tool.getReplacements())
+ChangedFiles.insert(it.first);
+
+  if (DumpYAML) {
+auto WriteToYAML = [&](llvm::raw_ostream &OS) {
+  OS << "[\n";
+  for (auto I = ChangedFiles.begin(), E = ChangedFiles.end(); I != E; ++I) {
+OS << "  {\n";
+OS << "\"FilePath\": \"" << *I << "\",\n";
+const auto *Entry = FileMgr.getFile(*I);
+auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
+std::string Content;
+llvm::raw_string_ostream ContentStream(Content);
+Rewrite.getEditBuffer(ID).write(ContentStream);
+OS << "\"SourceText\": \""
+   

[PATCH] D29886: [clangd] Wire up ASTUnit and publish diagnostics with it.

2017-02-13 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clangd/DocumentStore.h:42
   /// Delete a document from the store.
-  void removeDocument(StringRef Uri) { Docs.erase(Uri); }
+  void removeDocument(StringRef Uri) { Docs.erase(Uri);
+for (const auto &Listener : Listeners)

cierpuchaw wrote:
> cierpuchaw wrote:
> > Shouldn't this be called under a lock_guard?
> I should've reworded my comment before submitting it. By 'this' I'm referring 
> to the 'Docs.erase()' part, not the whole function.
> 
Even under a guard, it may potentially still be unsafe since workers may 
operate on erased/modified StringRef-s.



Comment at: clangd/DocumentStore.h:51
 auto I = Docs.find(Uri);
 return I == Docs.end() ? StringRef("") : StringRef(I->second);
   }

StringRef doesn't own the underlying data, right? What if I erase it in the 
meantime?



Comment at: clangd/DocumentStore.h:63
+  AllDocs.emplace_back(P.first(), P.second);
+return AllDocs;
+  }

Same thing, shouldn't these be strings?


https://reviews.llvm.org/D29886



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


[PATCH] D29599: Clang Changes for alloc_align

2017-02-13 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In https://reviews.llvm.org/D29599#674772, @ahatanak wrote:

> Can this attribute be used on c++ template methods? Is the following code 
> valid?
>
>   template
>   struct S {
> T foo(int a)  __attribute__((alloc_align(1)));
>   };
>


Yes it can, however that example will NOT compile.  First, on member functions 
you cannot use alloc_align to refer to the 'this' function.  Second, the return 
value must be a pointer, so if remove_pointer == T, this will fail.


https://reviews.llvm.org/D29599



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


[PATCH] D29770: [Assembler] Inline assembly diagnostics test.

2017-02-13 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D29770#674961, @sanwou01 wrote:

> Use clang_cc1 -verify for testing as suggested by @rnk.
>
> @echristo, llc does use the same diags interfaces as clang, however, it is
>  lacking the infrastructure to make use of LocCookies.
>
> In any case, I think this test is useful to prevent regressions in inline
>  assembly diagnostics in clang.


The point is that we typically do not want end to end tests (of which this is 
one) in clang if there's any way to avoid it. In this case we could test the 
same interfaces by adding support to llc for them (and it would arguably be 
useful in llc mode anyhow).


https://reviews.llvm.org/D29770



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


[PATCH] D29893: [change-namespace] add an option to dump changed files in YAML.

2017-02-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: change-namespace/tool/ClangChangeNamespace.cpp:68
+cl::opt
+DumpYAML("dump_yaml",
+ cl::desc("Dump new file content in YAML, if specified."),

`dump_result` maybe a clearer name, which also is consistent with clang-move's.



Comment at: change-namespace/tool/ClangChangeNamespace.cpp:137
+
+  for (const auto &File : ChangedFiles) {
 const auto *Entry = FileMgr.getFile(File);

Is this duplicated as we already have "dump_results" option now?


https://reviews.llvm.org/D29893



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


[PATCH] D29893: [change-namespace] add an option to dump changed files in YAML.

2017-02-13 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: change-namespace/tool/ClangChangeNamespace.cpp:137
+
+  for (const auto &File : ChangedFiles) {
 const auto *Entry = FileMgr.getFile(File);

hokein wrote:
> Is this duplicated as we already have "dump_results" option now?
I'd like this to be default since this produces readable results.


https://reviews.llvm.org/D29893



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


[PATCH] D29770: [Assembler] Inline assembly diagnostics test.

2017-02-13 Thread Jim Grosbach via Phabricator via cfe-commits
grosbach added a comment.

Eric is correct. These tests would be more suitable in llc. The clang tests 
should check that the inline asm is inserted into the IR in the correct form if 
there's any difference pre and post patch (I don't think there is?).


https://reviews.llvm.org/D29770



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


[PATCH] D29893: [change-namespace] add an option to dump changed files in YAML.

2017-02-13 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 88208.
ioeric marked 2 inline comments as done.
ioeric added a comment.

- Addressed review comments.


https://reviews.llvm.org/D29893

Files:
  change-namespace/ChangeNamespace.cpp
  change-namespace/tool/ClangChangeNamespace.cpp


Index: change-namespace/tool/ClangChangeNamespace.cpp
===
--- change-namespace/tool/ClangChangeNamespace.cpp
+++ change-namespace/tool/ClangChangeNamespace.cpp
@@ -39,6 +39,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
@@ -63,6 +64,11 @@
 cl::opt Inplace("i", cl::desc("Inplace edit s, if specified."),
   cl::cat(ChangeNamespaceCategory));
 
+cl::opt
+DumpYAML("dump_result",
+ cl::desc("Dump new file contents in YAML, if specified."),
+ cl::cat(ChangeNamespaceCategory));
+
 cl::opt Style("style",
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
@@ -101,14 +107,41 @@
   if (Inplace)
 return Rewrite.overwriteChangedFiles();
 
-  for (const auto &File : Files) {
+  std::set ChangedFiles;
+  for (const auto &it : Tool.getReplacements())
+ChangedFiles.insert(it.first);
+
+  if (DumpYAML) {
+auto WriteToYAML = [&](llvm::raw_ostream &OS) {
+  OS << "[\n";
+  for (auto I = ChangedFiles.begin(), E = ChangedFiles.end(); I != E; ++I) 
{
+OS << "  {\n";
+OS << "\"FilePath\": \"" << *I << "\",\n";
+const auto *Entry = FileMgr.getFile(*I);
+auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
+std::string Content;
+llvm::raw_string_ostream ContentStream(Content);
+Rewrite.getEditBuffer(ID).write(ContentStream);
+OS << "\"SourceText\": \""
+   << llvm::yaml::escape(ContentStream.str()) << "\"\n";
+OS << "  }";
+if (I != std::prev(E))
+  OS << ",\n";
+  }
+  OS << "\n]\n";
+};
+WriteToYAML(llvm::outs());
+return 0;
+  }
+
+  for (const auto &File : ChangedFiles) {
 const auto *Entry = FileMgr.getFile(File);
 
 auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
-// FIXME: print results in parsable format, e.g. JSON.
 outs() << "== " << File << " ==\n";
 Rewrite.getEditBuffer(ID).write(llvm::outs());
 outs() << "\n\n";
   }
+
   return 0;
 }
Index: change-namespace/ChangeNamespace.cpp
===
--- change-namespace/ChangeNamespace.cpp
+++ change-namespace/ChangeNamespace.cpp
@@ -275,7 +275,7 @@
 // Returns true if \p D is visible at \p Loc with DeclContext \p DeclCtx.
 bool isDeclVisibleAtLocation(const SourceManager &SM, const Decl *D,
  const DeclContext *DeclCtx, SourceLocation Loc) {
-  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocation());
+  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocStart());
   Loc = SM.getSpellingLoc(Loc);
   return SM.isBeforeInTranslationUnit(DeclLoc, Loc) &&
  (SM.getFileID(DeclLoc) == SM.getFileID(Loc) &&


Index: change-namespace/tool/ClangChangeNamespace.cpp
===
--- change-namespace/tool/ClangChangeNamespace.cpp
+++ change-namespace/tool/ClangChangeNamespace.cpp
@@ -39,6 +39,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
@@ -63,6 +64,11 @@
 cl::opt Inplace("i", cl::desc("Inplace edit s, if specified."),
   cl::cat(ChangeNamespaceCategory));
 
+cl::opt
+DumpYAML("dump_result",
+ cl::desc("Dump new file contents in YAML, if specified."),
+ cl::cat(ChangeNamespaceCategory));
+
 cl::opt Style("style",
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
@@ -101,14 +107,41 @@
   if (Inplace)
 return Rewrite.overwriteChangedFiles();
 
-  for (const auto &File : Files) {
+  std::set ChangedFiles;
+  for (const auto &it : Tool.getReplacements())
+ChangedFiles.insert(it.first);
+
+  if (DumpYAML) {
+auto WriteToYAML = [&](llvm::raw_ostream &OS) {
+  OS << "[\n";
+  for (auto I = ChangedFiles.begin(), E = ChangedFiles.end(); I != E; ++I) {
+OS << "  {\n";
+OS << "\"FilePath\": \"" << *I << "\",\n";
+const auto *Entry = FileMgr.getFile(*I);
+auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
+std::string Content;
+llvm::raw_string_ostream ContentStream(Content);
+Rewrite.ge

[PATCH] D29893: [change-namespace] add an option to dump changed files in YAML.

2017-02-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: change-namespace/tool/ClangChangeNamespace.cpp:68
+cl::opt
+DumpYAML("dump_yaml",
+ cl::desc("Dump new file content in YAML, if specified."),

hokein wrote:
> `dump_result` maybe a clearer name, which also is consistent with 
> clang-move's.
Nit: Also change the variable name to `DumpResult`.



Comment at: change-namespace/tool/ClangChangeNamespace.cpp:137
+
+  for (const auto &File : ChangedFiles) {
 const auto *Entry = FileMgr.getFile(File);

ioeric wrote:
> hokein wrote:
> > Is this duplicated as we already have "dump_results" option now?
> I'd like this to be default since this produces readable results.
OK, it is up to you.


https://reviews.llvm.org/D29893



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


[PATCH] D29893: [change-namespace] add an option to dump changed files in YAML.

2017-02-13 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: change-namespace/tool/ClangChangeNamespace.cpp:68
+cl::opt
+DumpYAML("dump_yaml",
+ cl::desc("Dump new file content in YAML, if specified."),

hokein wrote:
> hokein wrote:
> > `dump_result` maybe a clearer name, which also is consistent with 
> > clang-move's.
> Nit: Also change the variable name to `DumpResult`.
Since I am also dumping output as plain text, I named this `DumpYAML` for 
clarity.


https://reviews.llvm.org/D29893



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


[clang-tools-extra] r294969 - [change-namespace] add an option to dump changed files in YAML.

2017-02-13 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Feb 13 11:24:14 2017
New Revision: 294969

URL: http://llvm.org/viewvc/llvm-project?rev=294969&view=rev
Log:
[change-namespace] add an option to dump changed files in YAML.

Reviewers: hokein

Reviewed By: hokein

Subscribers: fhahn, cfe-commits

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

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

Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp?rev=294969&r1=294968&r2=294969&view=diff
==
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp (original)
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Mon Feb 13 
11:24:14 2017
@@ -275,7 +275,7 @@ bool isNestedDeclContext(const DeclConte
 // Returns true if \p D is visible at \p Loc with DeclContext \p DeclCtx.
 bool isDeclVisibleAtLocation(const SourceManager &SM, const Decl *D,
  const DeclContext *DeclCtx, SourceLocation Loc) {
-  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocation());
+  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocStart());
   Loc = SM.getSpellingLoc(Loc);
   return SM.isBeforeInTranslationUnit(DeclLoc, Loc) &&
  (SM.getFileID(DeclLoc) == SM.getFileID(Loc) &&

Modified: clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp?rev=294969&r1=294968&r2=294969&view=diff
==
--- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp 
(original)
+++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp Mon 
Feb 13 11:24:14 2017
@@ -39,6 +39,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
@@ -63,6 +64,11 @@ cl::opt FilePattern(
 cl::opt Inplace("i", cl::desc("Inplace edit s, if specified."),
   cl::cat(ChangeNamespaceCategory));
 
+cl::opt
+DumpYAML("dump_result",
+ cl::desc("Dump new file contents in YAML, if specified."),
+ cl::cat(ChangeNamespaceCategory));
+
 cl::opt Style("style",
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
@@ -101,14 +107,41 @@ int main(int argc, const char **argv) {
   if (Inplace)
 return Rewrite.overwriteChangedFiles();
 
-  for (const auto &File : Files) {
+  std::set ChangedFiles;
+  for (const auto &it : Tool.getReplacements())
+ChangedFiles.insert(it.first);
+
+  if (DumpYAML) {
+auto WriteToYAML = [&](llvm::raw_ostream &OS) {
+  OS << "[\n";
+  for (auto I = ChangedFiles.begin(), E = ChangedFiles.end(); I != E; ++I) 
{
+OS << "  {\n";
+OS << "\"FilePath\": \"" << *I << "\",\n";
+const auto *Entry = FileMgr.getFile(*I);
+auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
+std::string Content;
+llvm::raw_string_ostream ContentStream(Content);
+Rewrite.getEditBuffer(ID).write(ContentStream);
+OS << "\"SourceText\": \""
+   << llvm::yaml::escape(ContentStream.str()) << "\"\n";
+OS << "  }";
+if (I != std::prev(E))
+  OS << ",\n";
+  }
+  OS << "\n]\n";
+};
+WriteToYAML(llvm::outs());
+return 0;
+  }
+
+  for (const auto &File : ChangedFiles) {
 const auto *Entry = FileMgr.getFile(File);
 
 auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
-// FIXME: print results in parsable format, e.g. JSON.
 outs() << "== " << File << " ==\n";
 Rewrite.getEditBuffer(ID).write(llvm::outs());
 outs() << "\n\n";
   }
+
   return 0;
 }


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


[PATCH] D29893: [change-namespace] add an option to dump changed files in YAML.

2017-02-13 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294969: [change-namespace] add an option to dump changed 
files in YAML. (authored by ioeric).

Changed prior to commit:
  https://reviews.llvm.org/D29893?vs=88208&id=88211#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29893

Files:
  clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
  clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp


Index: clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
@@ -39,6 +39,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
@@ -63,6 +64,11 @@
 cl::opt Inplace("i", cl::desc("Inplace edit s, if specified."),
   cl::cat(ChangeNamespaceCategory));
 
+cl::opt
+DumpYAML("dump_result",
+ cl::desc("Dump new file contents in YAML, if specified."),
+ cl::cat(ChangeNamespaceCategory));
+
 cl::opt Style("style",
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
@@ -101,14 +107,41 @@
   if (Inplace)
 return Rewrite.overwriteChangedFiles();
 
-  for (const auto &File : Files) {
+  std::set ChangedFiles;
+  for (const auto &it : Tool.getReplacements())
+ChangedFiles.insert(it.first);
+
+  if (DumpYAML) {
+auto WriteToYAML = [&](llvm::raw_ostream &OS) {
+  OS << "[\n";
+  for (auto I = ChangedFiles.begin(), E = ChangedFiles.end(); I != E; ++I) 
{
+OS << "  {\n";
+OS << "\"FilePath\": \"" << *I << "\",\n";
+const auto *Entry = FileMgr.getFile(*I);
+auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
+std::string Content;
+llvm::raw_string_ostream ContentStream(Content);
+Rewrite.getEditBuffer(ID).write(ContentStream);
+OS << "\"SourceText\": \""
+   << llvm::yaml::escape(ContentStream.str()) << "\"\n";
+OS << "  }";
+if (I != std::prev(E))
+  OS << ",\n";
+  }
+  OS << "\n]\n";
+};
+WriteToYAML(llvm::outs());
+return 0;
+  }
+
+  for (const auto &File : ChangedFiles) {
 const auto *Entry = FileMgr.getFile(File);
 
 auto ID = Sources.getOrCreateFileID(Entry, SrcMgr::C_User);
-// FIXME: print results in parsable format, e.g. JSON.
 outs() << "== " << File << " ==\n";
 Rewrite.getEditBuffer(ID).write(llvm::outs());
 outs() << "\n\n";
   }
+
   return 0;
 }
Index: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
@@ -275,7 +275,7 @@
 // Returns true if \p D is visible at \p Loc with DeclContext \p DeclCtx.
 bool isDeclVisibleAtLocation(const SourceManager &SM, const Decl *D,
  const DeclContext *DeclCtx, SourceLocation Loc) {
-  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocation());
+  SourceLocation DeclLoc = SM.getSpellingLoc(D->getLocStart());
   Loc = SM.getSpellingLoc(Loc);
   return SM.isBeforeInTranslationUnit(DeclLoc, Loc) &&
  (SM.getFileID(DeclLoc) == SM.getFileID(Loc) &&


Index: clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
===
--- clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
+++ clang-tools-extra/trunk/change-namespace/tool/ClangChangeNamespace.cpp
@@ -39,6 +39,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/YAMLTraits.h"
 
 using namespace clang;
 using namespace llvm;
@@ -63,6 +64,11 @@
 cl::opt Inplace("i", cl::desc("Inplace edit s, if specified."),
   cl::cat(ChangeNamespaceCategory));
 
+cl::opt
+DumpYAML("dump_result",
+ cl::desc("Dump new file contents in YAML, if specified."),
+ cl::cat(ChangeNamespaceCategory));
+
 cl::opt Style("style",
cl::desc("The style name used for reformatting."),
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
@@ -101,14 +107,41 @@
   if (Inplace)
 return Rewrite.overwriteChangedFiles();
 
-  for (const auto &File : Files) {
+  std::set ChangedFiles;
+  for (const auto &it : Tool.getReplacements())
+ChangedFiles.insert(it.first);
+
+  if (DumpYAML) {
+auto WriteToYAML = [&](llvm::raw_ostrea

[PATCH] D19586: Misleading Indentation check

2017-02-13 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added inline comments.



Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:42
+const Stmt *Inside = nullptr;
+
+if (const auto *CurrentIf = dyn_cast(CurrentStmt)) {

I would rename Inside to Inner. That would make InnerLoc more "consistent".



Comment at: clang-tidy/readability/MisleadingIndentationCheck.cpp:48
+  Inside = CurrentFor->getBody();
+} else if (const auto CurrentWhile = dyn_cast(CurrentStmt)) {
+  Inside = CurrentWhile->getBody();

nit: write "const auto *CurrentWhile...". missing "*"?




Comment at: test/clang-tidy/readability-misleading-indentation.cpp:21
+foo2();
+  // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: potential dangling 'else' 
[readability-misleading-indentation]
+

I am skeptic about this warning message.

Why does it say "potential". I would say that in this test case the indentation 
_is_ "dangling".

The message is not very clear to me. I personally don't intuitively understand 
what is wrong without looking at the code.

I don't know what it should say. Maybe:
```
different indentation for 'if' and 'else'
```



https://reviews.llvm.org/D19586



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


[PATCH] D29859: Make Lit tests C++11 compatible - nounwind noexcept

2017-02-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294972: [Test] Make Lit tests C++11 compatible - nounwind 
noexcept (authored by lcharles).

Changed prior to commit:
  https://reviews.llvm.org/D29859?vs=88074&id=88220#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29859

Files:
  cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
  cfe/trunk/test/CodeGenCXX/lpad-linetable.cpp
  cfe/trunk/test/Index/comment-cplus-decls.cpp


Index: cfe/trunk/test/Index/comment-cplus-decls.cpp
===
--- cfe/trunk/test/Index/comment-cplus-decls.cpp
+++ cfe/trunk/test/Index/comment-cplus-decls.cpp
@@ -2,9 +2,15 @@
 // RUN: mkdir %t
 // RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target 
x86_64-apple-darwin10 %s > %t/out
 // RUN: FileCheck %s < %t/out
+// RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target 
x86_64-apple-darwin10 -std=c++98 %s > %t/98
+// RUN: FileCheck %s < %t/98
+// RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target 
x86_64-apple-darwin10 -std=c++11 %s > %t/11
+// RUN: FileCheck %s < %t/11
 
 // Ensure that XML we generate is not invalid.
 // RUN: FileCheck %s -check-prefix=WRONG < %t/out
+// RUN: FileCheck %s -check-prefix=WRONG < %t/98
+// RUN: FileCheck %s -check-prefix=WRONG < %t/11
 // WRONG-NOT: CommentXMLInvalid
 // rdar://12378714
 
@@ -42,7 +48,7 @@
 // CHECK: class Test {}
 // CHECK: Test() : reserved(new Test::data()) {}
 // CHECK: unsigned int getID() const
-// CHECK: ~Test()
+// CHECK: ~Test(){{( noexcept)?}}
 // CHECK: Test::data *reserved
 
 
Index: cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
===
--- cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
+++ cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
@@ -1,10 +1,12 @@
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin10 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin10 -std=c++98 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin10 -std=c++11 %s -o - | FileCheck %s
 
 // Check the line numbers for cleanup code with EH in combination with
 // simple return expressions.
 
 // CHECK: define {{.*}}foo
-// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[RET:[0-9]+]]
+// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}){{( #[0-9])?}}, !dbg 
![[RET:[0-9]+]]
 // CHECK: ret i32 0, !dbg ![[RET]]
 
 // CHECK: define {{.*}}bar
Index: cfe/trunk/test/CodeGenCXX/lpad-linetable.cpp
===
--- cfe/trunk/test/CodeGenCXX/lpad-linetable.cpp
+++ cfe/trunk/test/CodeGenCXX/lpad-linetable.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fcxx-exceptions -fexceptions -emit-llvm 
-debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+// RUN: %clang_cc1  -fcxx-exceptions -fexceptions -emit-llvm 
-debug-info-kind=limited -triple x86_64-apple-darwin10 -std=c++98 %s -o - | 
FileCheck %s
 // The landing pad should have the line number of the closing brace of the 
function.
 // rdar://problem/13888152
 // CHECK: ret i32


Index: cfe/trunk/test/Index/comment-cplus-decls.cpp
===
--- cfe/trunk/test/Index/comment-cplus-decls.cpp
+++ cfe/trunk/test/Index/comment-cplus-decls.cpp
@@ -2,9 +2,15 @@
 // RUN: mkdir %t
 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 %s > %t/out
 // RUN: FileCheck %s < %t/out
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 -std=c++98 %s > %t/98
+// RUN: FileCheck %s < %t/98
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 -std=c++11 %s > %t/11
+// RUN: FileCheck %s < %t/11
 
 // Ensure that XML we generate is not invalid.
 // RUN: FileCheck %s -check-prefix=WRONG < %t/out
+// RUN: FileCheck %s -check-prefix=WRONG < %t/98
+// RUN: FileCheck %s -check-prefix=WRONG < %t/11
 // WRONG-NOT: CommentXMLInvalid
 // rdar://12378714
 
@@ -42,7 +48,7 @@
 // CHECK: class Test {}
 // CHECK: Test() : reserved(new Test::data()) {}
 // CHECK: unsigned int getID() const
-// CHECK: ~Test()
+// CHECK: ~Test(){{( noexcept)?}}
 // CHECK: Test::data *reserved
 
 
Index: cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
===
--- cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
+++ cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
@@ -1,10 +1,12 @@
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited 

r294972 - [Test] Make Lit tests C++11 compatible - nounwind noexcept

2017-02-13 Thread Charles Li via cfe-commits
Author: lcharles
Date: Mon Feb 13 11:56:30 2017
New Revision: 294972

URL: http://llvm.org/viewvc/llvm-project?rev=294972&view=rev
Log:
[Test] Make Lit tests C++11 compatible - nounwind noexcept

C++11 destructors are nothrow by default.

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

Modified:
cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
cfe/trunk/test/CodeGenCXX/lpad-linetable.cpp
cfe/trunk/test/Index/comment-cplus-decls.cpp

Modified: cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp?rev=294972&r1=294971&r2=294972&view=diff
==
--- cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/linetable-cleanup.cpp Mon Feb 13 11:56:30 2017
@@ -1,10 +1,12 @@
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin10 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin10 -std=c++98 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin10 -std=c++11 %s -o - | FileCheck %s
 
 // Check the line numbers for cleanup code with EH in combination with
 // simple return expressions.
 
 // CHECK: define {{.*}}foo
-// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[RET:[0-9]+]]
+// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}){{( #[0-9])?}}, !dbg 
![[RET:[0-9]+]]
 // CHECK: ret i32 0, !dbg ![[RET]]
 
 // CHECK: define {{.*}}bar

Modified: cfe/trunk/test/CodeGenCXX/lpad-linetable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/lpad-linetable.cpp?rev=294972&r1=294971&r2=294972&view=diff
==
--- cfe/trunk/test/CodeGenCXX/lpad-linetable.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/lpad-linetable.cpp Mon Feb 13 11:56:30 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fcxx-exceptions -fexceptions -emit-llvm 
-debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+// RUN: %clang_cc1  -fcxx-exceptions -fexceptions -emit-llvm 
-debug-info-kind=limited -triple x86_64-apple-darwin10 -std=c++98 %s -o - | 
FileCheck %s
 // The landing pad should have the line number of the closing brace of the 
function.
 // rdar://problem/13888152
 // CHECK: ret i32

Modified: cfe/trunk/test/Index/comment-cplus-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/comment-cplus-decls.cpp?rev=294972&r1=294971&r2=294972&view=diff
==
--- cfe/trunk/test/Index/comment-cplus-decls.cpp (original)
+++ cfe/trunk/test/Index/comment-cplus-decls.cpp Mon Feb 13 11:56:30 2017
@@ -2,9 +2,15 @@
 // RUN: mkdir %t
 // RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target 
x86_64-apple-darwin10 %s > %t/out
 // RUN: FileCheck %s < %t/out
+// RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target 
x86_64-apple-darwin10 -std=c++98 %s > %t/98
+// RUN: FileCheck %s < %t/98
+// RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target 
x86_64-apple-darwin10 -std=c++11 %s > %t/11
+// RUN: FileCheck %s < %t/11
 
 // Ensure that XML we generate is not invalid.
 // RUN: FileCheck %s -check-prefix=WRONG < %t/out
+// RUN: FileCheck %s -check-prefix=WRONG < %t/98
+// RUN: FileCheck %s -check-prefix=WRONG < %t/11
 // WRONG-NOT: CommentXMLInvalid
 // rdar://12378714
 
@@ -42,7 +48,7 @@ protected:
 // CHECK: class Test {}
 // CHECK: Test() : reserved(new Test::data()) {}
 // CHECK: unsigned int getID() const
-// CHECK: ~Test()
+// CHECK: ~Test(){{( noexcept)?}}
 // CHECK: Test::data *reserved
 
 


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


[clang-tools-extra] r294974 - [clang-tidy] Reduce indentation. NFC.

2017-02-13 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Mon Feb 13 12:03:10 2017
New Revision: 294974

URL: http://llvm.org/viewvc/llvm-project?rev=294974&view=rev
Log:
[clang-tidy] Reduce indentation. NFC.

Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp?rev=294974&r1=294973&r2=294974&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidyDiagnosticConsumer.cpp Mon Feb 
13 12:03:10 2017
@@ -269,16 +269,16 @@ void ClangTidyDiagnosticConsumer::finali
 static bool LineIsMarkedWithNOLINT(SourceManager &SM, SourceLocation Loc) {
   bool Invalid;
   const char *CharacterData = SM.getCharacterData(Loc, &Invalid);
-  if (!Invalid) {
-const char *P = CharacterData;
-while (*P != '\0' && *P != '\r' && *P != '\n')
-  ++P;
-StringRef RestOfLine(CharacterData, P - CharacterData + 1);
-// FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
-if (RestOfLine.find("NOLINT") != StringRef::npos) {
-  return true;
-}
-  }
+  if (Invalid)
+return false;
+
+  const char *P = CharacterData;
+  while (*P != '\0' && *P != '\r' && *P != '\n')
+++P;
+  StringRef RestOfLine(CharacterData, P - CharacterData + 1);
+  // FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
+  if (RestOfLine.find("NOLINT") != StringRef::npos)
+return true;
   return false;
 }
 


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


[PATCH] D29899: [clang-tidy] Add support for NOLINTNEXTLINE.

2017-02-13 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer created this revision.
Herald added a subscriber: JDevlieghere.

https://reviews.llvm.org/D29899

Files:
  clang-tidy/ClangTidyDiagnosticConsumer.cpp
  test/clang-tidy/nolintnextline.cpp


Index: test/clang-tidy/nolintnextline.cpp
===
--- /dev/null
+++ test/clang-tidy/nolintnextline.cpp
@@ -0,0 +1,33 @@
+class A { A(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must 
be marked explicit
+
+// NOLINTNEXTLINE
+class B { B(int i); };
+
+// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+class C { C(int i); };
+
+
+// NOLINTNEXTLINE
+
+
+class D { D(int i); };
+
+// NOLINTNEXTLINE
+//
+class E { E(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must 
be marked explicit
+
+#define MACRO(X) class X { X(int i); };
+MACRO(F)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must 
be marked explicit
+// NOLINTNEXTLINE
+MACRO(G)
+
+#define MACRO_NOARG class H { H(int i); };
+// NOLINTNEXTLINE
+MACRO_NOARG
+
+// CHECK-MESSAGES: Suppressed 5 warnings (5 NOLINT)
+
+// RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -272,13 +272,45 @@
   if (Invalid)
 return false;
 
+  // Check if there's a NOLINT on this line.
   const char *P = CharacterData;
   while (*P != '\0' && *P != '\r' && *P != '\n')
 ++P;
   StringRef RestOfLine(CharacterData, P - CharacterData + 1);
   // FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
   if (RestOfLine.find("NOLINT") != StringRef::npos)
 return true;
+
+  // Check if there's a NOLINTNEXTLINE on the previous line.
+  const char *BufBegin =
+  SM.getCharacterData(SM.getLocForStartOfFile(SM.getFileID(Loc)), 
&Invalid);
+  if (Invalid || P == BufBegin)
+return false;
+
+  // Scan backwards over the current line.
+  P = CharacterData;
+  while (P != BufBegin && *P != '\r' && *P != '\n')
+--P;
+
+  // If we reached the begin of the file there is no line before it.
+  if (P == BufBegin)
+return false;
+
+  // Now skip any newlines.
+  // FIXME: We want to skip over exactly one line, not an arbitrary number.
+  while (P != BufBegin && (*P == '\r' || *P == '\n'))
+--P;
+
+  const char *LineEnd = P;
+
+  // Now we're on the previous line. Skip to the beginning of it.
+  while (P != BufBegin && *P != '\r' && *P != '\n')
+--P;
+
+  RestOfLine = StringRef(P, LineEnd - P + 1);
+  if (RestOfLine.find("NOLINTNEXTLINE") != StringRef::npos)
+return true;
+
   return false;
 }
 


Index: test/clang-tidy/nolintnextline.cpp
===
--- /dev/null
+++ test/clang-tidy/nolintnextline.cpp
@@ -0,0 +1,33 @@
+class A { A(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE
+class B { B(int i); };
+
+// NOLINTNEXTLINE(we-dont-care-about-categories-yet)
+class C { C(int i); };
+
+
+// NOLINTNEXTLINE
+
+
+class D { D(int i); };
+
+// NOLINTNEXTLINE
+//
+class E { E(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+#define MACRO(X) class X { X(int i); };
+MACRO(F)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
+// NOLINTNEXTLINE
+MACRO(G)
+
+#define MACRO_NOARG class H { H(int i); };
+// NOLINTNEXTLINE
+MACRO_NOARG
+
+// CHECK-MESSAGES: Suppressed 5 warnings (5 NOLINT)
+
+// RUN: %check_clang_tidy %s google-explicit-constructor %t --
Index: clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -272,13 +272,45 @@
   if (Invalid)
 return false;
 
+  // Check if there's a NOLINT on this line.
   const char *P = CharacterData;
   while (*P != '\0' && *P != '\r' && *P != '\n')
 ++P;
   StringRef RestOfLine(CharacterData, P - CharacterData + 1);
   // FIXME: Handle /\bNOLINT\b(\([^)]*\))?/ as cpplint.py does.
   if (RestOfLine.find("NOLINT") != StringRef::npos)
 return true;
+
+  // Check if there's a NOLINTNEXTLINE on the previous line.
+  const char *BufBegin =
+  SM.getCharacterData(SM.getLocForStartOfFile(SM.getFileID(Loc)), &Invalid);
+  if (Invalid || P == BufBegin)
+return false;
+
+  // Scan backwards over the current line.
+  P = CharacterData;
+  while (P != BufBegin && *P != '\r' && *P != '\n')
+--P;
+
+  // If we reached the begin of the file there is no line before it.
+  if (P == BufBegin)
+return false;
+
+  // Now skip any newlines.
+  // FIXME: We want to skip over exactly one line, not an arbitrary number.
+  while (P != BufBegin && (*P ==

[PATCH] D29685: Lit C++11 Compatibility - Function Attributes

2017-02-13 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley added a comment.

I agree with Aaron here.  Those thread safety errors are supposed to fire; 
simply disabling the unit tests because they no longer fire is not acceptable.  
I also don't understand how this could be a bug with the thread safety 
analysis, since these particular errors are issued when the attributes are 
parsed, not when the analysis is run.   I haven't looked at the relevant code 
in a long time; have there been significant changes to the attribute-parsing 
mechanism?  There's no member initialization going on here, so why would 
changes to member initialization have this side effect?  I'm confused.

  DeLesley


https://reviews.llvm.org/D29685



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


[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 88222.
arphaman marked 9 inline comments as done.
arphaman added a comment.

Thanks for the feedback! I've addressed the majority of your comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Parse/Parser.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Misc/ast-dump-attr.cpp
  test/Parser/attr-external-source-symbol-cxx11.cpp
  test/Parser/attr-external-source-symbol.m
  test/Sema/attr-external-source-symbol.c

Index: test/Sema/attr-external-source-symbol.c
===
--- /dev/null
+++ test/Sema/attr-external-source-symbol.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+void threeClauses() __attribute__((external_source_symbol(language=Swift, defined_in="module", generated_declaration)));
+
+void twoClauses() __attribute__((external_source_symbol(language=Swift, defined_in="module")));
+
+void fourClauses() __attribute__((external_source_symbol(language=Swift, defined_in="module", generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+
+void oneClause() __attribute__((external_source_symbol(generated_declaration)));
+
+void noArguments()
+__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
+
+void namedDeclsOnly() {
+  int (^block)(void) = ^ (void)
+__attribute__((external_source_symbol(language=Swift))) { // expected-warning {{'external_source_symbol' attribute only applies to named declarations}}
+  return 1;
+  };
+}
Index: test/Parser/attr-external-source-symbol.m
===
--- /dev/null
+++ test/Parser/attr-external-source-symbol.m
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void function() __attribute__((external_source_symbol(language=Swift, defined_in="module", generated_declaration)));
+
+__attribute__((external_source_symbol(language=Swift, defined_in="module")))
+@interface I
+
+- (void)method __attribute__((external_source_symbol(defined_in= "module")));
+
+@end
+
+enum E {
+  CaseA __attribute__((external_source_symbol(generated_declaration))),
+  CaseB __attribute__((external_source_symbol(generated_declaration, language=Swift)))
+} __attribute__((external_source_symbol(language = Swift)));
+
+void f2()
+__attribute__((external_source_symbol())); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f3()
+__attribute__((external_source_symbol(invalid))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f4()
+__attribute__((external_source_symbol(language))); // expected-error {{expected '=' after language}}
+void f5()
+__attribute__((external_source_symbol(language=))); // expected-error {{expected an identifier that corresponds to the original source language}}
+void f6()
+__attribute__((external_source_symbol(defined_in=20))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
+
+void f7()
+__attribute__((external_source_symbol(generated_declaration, generated_declaration))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
+void f8()
+__attribute__((external_source_symbol(language=Swift, language=Swift))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}}
+void f9()
+__attribute__((external_source_symbol(defined_in="module", language=Swift, defined_in="foo"))); // expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}}
+
+void f10()
+__attribute__((external_source_symbol(generated_declaration, language=Swift, defined_in="foo", generated_declaration, generated_declaration, language=Swift))); // expected-error {{duplicate 'generated_declaration' clause in an 'external_source_symbol' attribute}}
Index: test/Parser/attr-external-source-symbol-cxx11.cpp
===
--- /dev/null
+++ test/Parser/attr-external-source-symbol-cxx11.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// expected-no-diagnostics
+
+[[clang::external_source_symbol(language=Swift, defined_in="module")]]
+void function() { }
Index: test/Misc/ast-dump-attr.cpp
===
--- test/Misc/ast-dump-attr.cpp
+++ test/Misc/ast-dump-attr.cpp
@@ -154,3 +154,28 @@
 struct __attribute__((objc_bridge_related(NSParagraphStyle,,))) TestBridgedRef;
 // CHECK: CXXRec

[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: include/clang/Basic/AttrDocs.td:1007
+
+defined_in=\ *string-literal*
+  The name of the source container in which the declaration was defined. The

aaron.ballman wrote:
> Would this hold something like a file name? If so, I worry about conflicts 
> between the comma separator and a file name -- you might want to pick a 
> separator that can't be used in a file name (like | or :).
It could potentially include a filename, yes.
I don't quite follow your concerns though.. If a comma is in a string literal 
then it's wrapped in quotes. Wouldn't that be enough to distinguish the comma 
separator token from the comma in a filename?



Comment at: lib/Sema/SemaDeclAttr.cpp:2414
+   const AttributeList &Attr) {
+  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+return;

aaron.ballman wrote:
> You should also diagnose if there's more than 3 arguments, no?
I think an assert would be more appropriate since I only use up to 3 arguments 
when creating the attribute, so I wouldn't be able to test the diagnostic.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819



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


[PATCH] D29764: [OpenCL] Blocks cannot capture/reference another block

2017-02-13 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D29764#673679, @yaxunl wrote:

> In https://reviews.llvm.org/D29764#673548, @Nicola wrote:
>
> > Looking at "Example 4" in the standard it looks like this should also be 
> > illegal.
> >
> >   int (^block1)(void) = ^int {return 1;};
> >   int foo() { return block1(); }
> >  
> >   __kernel void k(global int *z)
> >   {
> >int (^block2)(void) = ^int {
> > return foo(); // expected-error {{cannot refer to a block inside block}}
> >}; 
> >   }
> >  
> >
> >
> > Unless I missed something it's not erroring in this case.
>
>
> To diagnose this needs to traverse the AST tree. I think it is too much to do 
> it during parsing.
>
> It may be done through static analysis though.




In https://reviews.llvm.org/D29764#673679, @yaxunl wrote:

> In https://reviews.llvm.org/D29764#673548, @Nicola wrote:
>
> > Looking at "Example 4" in the standard it looks like this should also be 
> > illegal.
> >
> >   int (^block1)(void) = ^int {return 1;};
> >   int foo() { return block1(); }
> >  
> >   __kernel void k(global int *z)
> >   {
> >int (^block2)(void) = ^int {
> > return foo(); // expected-error {{cannot refer to a block inside block}}
> >}; 
> >   }
> >  
> >
> >
> > Unless I missed something it's not erroring in this case.
>
>
> To diagnose this needs to traverse the AST tree. I think it is too much to do 
> it during parsing.
>
> It may be done through static analysis though.


Yes, it will require quite some expensive checks to implement visiting the AST 
to trace back the block variables declared in other functions. Additionally 
this example doesn't seem to cause any issues really. It is mainly in the case 
with blocks captured from the stack:

  kernel void foo() {
bl2_t bl1 = ^(int i) {
  return 1;
};
void (^bl2)(void) = ^{
  int i = bl1(1); // expected-error {{cannot refer to a block inside block}}
};
  }

}
for which ObjC implementation creates copy/destroy helpers that use some 
symbols that are supposed to be defined elsewhere (presumably in the ObjC 
runtime) which causes issue in OpenCL because we suddenly end up with undefined 
symbols. I am guessing this is needed in order to promote stack allocated 
blocks into heap. Although the copy itself doesn't happen in our cases.




Comment at: test/SemaOpenCL/invalid-block.cl:71
+kernel void foobars() {
+  int v0;
+  bl2_t bl1 = ^(int i) {

v0 is not used!


https://reviews.llvm.org/D29764



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


[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++

2017-02-13 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In https://reviews.llvm.org/D29739#674297, @rjmccall wrote:

> In https://reviews.llvm.org/D29739#674288, @probinson wrote:
>
> > I really think Apple would need to step up here if the default 
> > Objective-C++ dialect is going to change.
>
>
> I don't mind stepping up and doing this work.  I just thought you'd already 
> done it.  This patch updates some tests; is that enough, or are there further 
> changes required in order to change the default ObjC++ dialect?
>
> John.


Charles tells me this is the last group of Objective-C++ tests that failed, so 
maybe there isn't anything else to do after all.  I had thought there were 
more.  He'll go ahead with this set.
We have another couple dozen C++ tests to straighten out, then we'll be ready 
to have the dev-list discussion about upgrading the default for 5.0, and 
whether it's the narrow case (just C++ and just for PS4, which was our original 
plan) or the big bang (both languages and for everybody).


https://reviews.llvm.org/D29739



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


[PATCH] D24812: Lit C++11 Compatibility Patch #11

2017-02-13 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 88224.
tigerleapgorge edited the summary of this revision.
tigerleapgorge added a comment.

Remove another 3 tests reviewed in https://reviews.llvm.org/D29859


https://reviews.llvm.org/D24812

Files:
  test/CodeGenCXX/mangle-unnamed.cpp
  test/CodeGenCXX/static-init.cpp
  test/CodeGenCXX/volatile-1.cpp
  test/CodeGenCXX/volatile.cpp
  test/PCH/macro-undef.cpp

Index: test/PCH/macro-undef.cpp
===
--- test/PCH/macro-undef.cpp
+++ test/PCH/macro-undef.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fsyntax-only -include-pch %t %s -Wuninitialized -verify
-// RUN: %clang_cc1 -fsyntax-only -include-pch %t %s -Wuninitialized -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -std=c++98 -emit-pch -o %t %s
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -include-pch %t %s -Wuninitialized -verify
+// RUN: %clang_cc1 -std=c++98 -fsyntax-only -include-pch %t %s -Wuninitialized -fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
 
 #ifndef HEADER
 #define HEADER
Index: test/CodeGenCXX/volatile.cpp
===
--- test/CodeGenCXX/volatile.cpp
+++ test/CodeGenCXX/volatile.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -std=c++98 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
 
 // Check that IR gen doesn't try to do an lvalue-to-rvalue conversion
 // on a volatile reference result.  rdar://problem/8338198
@@ -27,6 +28,7 @@
   // CHECK-LABEL: define void @_ZN5test14testEv()
   void test() {
 // CHECK:  [[TMP:%.*]] = load i32*, i32** @_ZN5test11xE, align 8
+// CHECK11:{{%.*}} = load volatile i32, i32* [[TMP]], align 4
 // CHECK-NEXT: ret void
 *x;
   }
Index: test/CodeGenCXX/volatile-1.cpp
===
--- test/CodeGenCXX/volatile-1.cpp
+++ test/CodeGenCXX/volatile-1.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -std=c++98 -o - | FileCheck %s
+// RUN: %clang_cc1 -Wno-unused-value -triple %itanium_abi_triple -emit-llvm %s -std=c++11 -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s
 
 // CHECK: @i = global [[INT:i[0-9]+]] 0
 volatile int i, j, k;
@@ -22,18 +23,22 @@
 
   asm("nop"); // CHECK: call void asm
 
-  // should not load
+  // should not load in C++98
   i;
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @i
 
   (float)(ci);
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 0)
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 1)
   // CHECK-NEXT: sitofp [[INT]]
 
-  // These are not uses in C++:
+  // These are not uses in C++98:
   //   [expr.static.cast]p6:
   // The lvalue-to-rvalue . . . conversions are not applied to the expression.
   (void)ci;
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 0)
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* getelementptr inbounds ([[CINT]], [[CINT]]* @ci, i32 0, i32 1)
+
   (void)a;
 
   (void)(ci=ci);
@@ -126,7 +131,8 @@
   // CHECK-NEXT: load volatile
   // CHECK-NEXT: sitofp
 
-  (void)i;
+  (void)i; // This is now a load in C++11
+  // CHECK11-NEXT: load volatile
 
   i=i;
   // CHECK-NEXT: load volatile
@@ -155,25 +161,30 @@
   // CHECK-NEXT: br label
   // CHECK:  phi
 
-  (void)(i,(i=i));
+  (void)(i,(i=i)); // first i is also a load in C++11
+  // CHECK11-NEXT: load volatile
   // CHECK-NEXT: load volatile
   // CHECK-NEXT: store volatile
 
-  i=i,k;
+  i=i,k; // k is also a load in C++11
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* @i
   // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @k
 
   (i=j,k=j);
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* @j
   // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* @j
   // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @k
 
-  (i=j,k);
+  (i=j,k); // k is also a load in C++11
   // CHECK-NEXT: load volatile [[INT]], [[INT]]* @j
   // CHECK-NEXT: store volatile {{.*}}, [[INT]]* @i
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @k
 
-  (i,j);
+  (i,j); // i and j both are loads in C++11
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @i
+  // CHECK11-NEXT: load volatile [[INT]], [[INT]]* @j
 
   // Extra load in C++.
   i=c=k;
@@ -190,7 +201,9 @@
   // CHECK-NEXT: add nsw [[INT]]
   // CHECK-NEXT: store volatile
 
-  ci;
+  ci; // ci is a 

[PATCH] D29886: [clangd] Wire up ASTUnit and publish diagnostics with it.

2017-02-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clangd/ASTManager.cpp:69
+  // our one-element queue is empty.
+  if (!RequestIsPending && !Done)
+ClangRequestCV.wait(Lock);

This is just a suggestion based on personal opinion: `RequestIsPending` and 
`Done` can be merged into one enum value that uses an enum like this:

```
enum ASTManagerState {
  Waiting, ReceivedRequest, Done
}
```

Then this condition could be rewritten as `if (state == Waiting)`.



Comment at: clangd/ASTManager.cpp:70
+  if (!RequestIsPending && !Done)
+ClangRequestCV.wait(Lock);
+

 I believe `std::condition_variable` may also be unblocked spuriously when 
`wait` is called without a predicate, which would lead to an empty `File` down 
below.



Comment at: clangd/ASTManager.h:67
+  /// Setting Done to true will make the worker thread terminate.
+  std::atomic Done;
+};

It looks like `Done` is always accessed in a scope where `RequestLock` is 
locked, so `atomic` doesn't seem needed here.


https://reviews.llvm.org/D29886



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


[PATCH] D28768: [clang-tidy] Add check 'modernize-return-braced-init-list'

2017-02-13 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere updated this revision to Diff 88226.
JDevlieghere marked 5 inline comments as done.
JDevlieghere added a comment.

Thanks for reviewing @aaron.ballman and @alexfh. I have updated the diff to 
address your issues. While looking at the logic that checked for matching 
argument types I discovered that I was looking at the wrong declaration, which 
has also been fixed.


Repository:
  rL LLVM

https://reviews.llvm.org/D28768

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.cpp
  clang-tidy/modernize/ReturnBracedInitListCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-return-braced-init-list.rst
  test/clang-tidy/modernize-return-braced-init-list.cpp

Index: test/clang-tidy/modernize-return-braced-init-list.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-return-braced-init-list.cpp
@@ -0,0 +1,201 @@
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t -- --
+// -std=c++14
+
+namespace std {
+typedef decltype(sizeof(int)) size_t;
+
+// libc++'s implementation
+template 
+class initializer_list {
+  const _E *__begin_;
+  size_t __size_;
+
+  initializer_list(const _E *__b, size_t __s)
+  : __begin_(__b),
+__size_(__s) {}
+
+public:
+  typedef _E value_type;
+  typedef const _E &reference;
+  typedef const _E &const_reference;
+  typedef size_t size_type;
+
+  typedef const _E *iterator;
+  typedef const _E *const_iterator;
+
+  initializer_list() : __begin_(nullptr), __size_(0) {}
+
+  size_t size() const { return __size_; }
+  const _E *begin() const { return __begin_; }
+  const _E *end() const { return __begin_ + __size_; }
+};
+
+template 
+class vector {
+public:
+  vector(T){};
+  vector(std::initializer_list) {}
+};
+}
+
+class Bar {};
+
+Bar b;
+
+class Foo {
+public:
+  Foo(Bar);
+  explicit Foo(Bar, unsigned int);
+  Foo(unsigned int);
+};
+
+class Baz {
+public:
+  Foo m() {
+Bar b;
+return Foo(b);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+// CHECK-FIXES: return {b};
+  }
+};
+
+class Quux : public Foo {
+public:
+  Quux(Bar bar) : Foo(bar){};
+  Quux(unsigned, unsigned, unsigned k = 0) : Foo(k) {};
+};
+
+Foo f() {
+  Bar b;
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f2() {
+  Bar b;
+  return {b};
+}
+
+auto f3() {
+  Bar b;
+  return Foo(b);
+}
+
+#define A(b) Foo(b)
+
+Foo f4() {
+  Bar b;
+  return A(b);
+}
+
+Foo f5() {
+  Bar b;
+  return Quux(b);
+}
+
+Foo f6() {
+  Bar b;
+  return Foo(b, 1);
+}
+
+std::vector f7() {
+  int i = 1;
+  return std::vector(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {i};
+}
+
+Bar f8() {
+  return {};
+}
+
+Bar f9() {
+  return Bar();
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {};
+}
+
+Bar f10() {
+  return Bar{};
+}
+
+Foo f11(Bar b) {
+  return Foo(b);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {b};
+}
+
+Foo f12() {
+  return f11(Bar());
+}
+
+Foo f13() {
+  return Foo(Bar());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {Bar()};
+}
+
+Foo f14() {
+  // FIXME: Type narrowing should not occur!
+  return Foo(-1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {-1};
+}
+
+Foo f15() {
+  return Foo(f10());
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {f10()};
+}
+
+Quux f16() {
+  return Quux(1, 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return type from the declaration, use a braced initializer list instead [modernize-return-braced-init-list]
+  // CHECK-FIXES: return {1, 2};
+}
+
+Quux f17() {
+  return Quux(1, 2, 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: to avoid repeating the return

[PATCH] D29685: Lit C++11 Compatibility - Function Attributes

2017-02-13 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge added a comment.

@aaron.ballman Thank you for the code review. I take it I can commit the first 
2 tests?

@delesley Thank you for the analysis. Should I open a bugzilla to track this 
issue?


https://reviews.llvm.org/D29685



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


[PATCH] D29685: Lit C++11 Compatibility - Function Attributes

2017-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D29685#675306, @tigerleapgorge wrote:

> @aaron.ballman Thank you for the code review. I take it I can commit the 
> first 2 tests?


Yes, the first two tests are good to commit.


https://reviews.llvm.org/D29685



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


[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/CodeGenCXX/ubsan-suppress-null-checks.cpp:8
+  int load_member() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch

I think this kind of check would've passed even when this patch is not applied. 
I understand that you need the first check for the single 'this' check, but it 
should be rewritten to ensure that it couldn't be the check for the `return 
foo`. Maybe you could use a C label before return and then check that the 
'this' check is performed before the label?


https://reviews.llvm.org/D29530



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


r294978 - [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-13 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Feb 13 12:49:21 2017
New Revision: 294978

URL: http://llvm.org/viewvc/llvm-project?rev=294978&view=rev
Log:
[CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

Fixes https://bugs.llvm.org/show_bug.cgi?id=31932

Based on a patch by Roland McGrath

Reviewed By: phosek

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

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/global-init.cpp
cfe/trunk/test/OpenMP/threadprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=294978&r1=294977&r2=294978&view=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Feb 13 12:49:21 2017
@@ -2162,7 +2162,9 @@ static void emitGlobalDtorWithCXAAtExit(
 
   // Create a variable that binds the atexit to this shared object.
   llvm::Constant *handle =
-CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+  CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+  auto *GV = cast(handle->stripPointerCasts());
+  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
   llvm::Value *args[] = {
 llvm::ConstantExpr::getBitCast(dtor, dtorTy),

Modified: cfe/trunk/test/CodeGenCXX/global-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/global-init.cpp?rev=294978&r1=294977&r2=294978&view=diff
==
--- cfe/trunk/test/CodeGenCXX/global-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/global-init.cpp Mon Feb 13 12:49:21 2017
@@ -15,7 +15,7 @@ struct C { void *field; };
 
 struct D { ~D(); };
 
-// CHECK: @__dso_handle = external global i8
+// CHECK: @__dso_handle = external hidden global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
 // PR6205: The casts should not require global initializers

Modified: cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/threadprivate_codegen.cpp?rev=294978&r1=294977&r2=294978&view=diff
==
--- cfe/trunk/test/OpenMP/threadprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/threadprivate_codegen.cpp Mon Feb 13 12:49:21 2017
@@ -176,7 +176,7 @@ struct S5 {
 // CHECK-TLS-DAG:  [[ST_S4_ST:@.+]] = linkonce_odr thread_local global 
%struct.S4 zeroinitializer
 // CHECK-TLS-DAG:  [[ST_S4_ST_GUARD:@_ZGVN2STI2S4E2stE]] = linkonce_odr 
thread_local global i64 0
 // CHECK-TLS-DAG:  @__tls_guard = internal thread_local global i8 0
-// CHECK-TLS-DAG:  @__dso_handle = external global i8
+// CHECK-TLS-DAG:  @__dso_handle = external hidden global i8
 // CHECK-TLS-DAG:  [[GS1_TLS_INIT:@_ZTHL3gs1]] = internal alias void (), void 
()* @__tls_init
 // CHECK-TLS-DAG:  [[ARR_X_TLS_INIT:@_ZTH5arr_x]] = alias void (), void ()* 
@__tls_init
 


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


[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-13 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294978: [CodeGen] Treat auto-generated __dso_handle symbol 
as HiddenVisibility (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D29843?vs=88068&id=88229#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29843

Files:
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/global-init.cpp
  cfe/trunk/test/OpenMP/threadprivate_codegen.cpp


Index: cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
===
--- cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
+++ cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
@@ -176,7 +176,7 @@
 // CHECK-TLS-DAG:  [[ST_S4_ST:@.+]] = linkonce_odr thread_local global 
%struct.S4 zeroinitializer
 // CHECK-TLS-DAG:  [[ST_S4_ST_GUARD:@_ZGVN2STI2S4E2stE]] = linkonce_odr 
thread_local global i64 0
 // CHECK-TLS-DAG:  @__tls_guard = internal thread_local global i8 0
-// CHECK-TLS-DAG:  @__dso_handle = external global i8
+// CHECK-TLS-DAG:  @__dso_handle = external hidden global i8
 // CHECK-TLS-DAG:  [[GS1_TLS_INIT:@_ZTHL3gs1]] = internal alias void (), void 
()* @__tls_init
 // CHECK-TLS-DAG:  [[ARR_X_TLS_INIT:@_ZTH5arr_x]] = alias void (), void ()* 
@__tls_init
 
Index: cfe/trunk/test/CodeGenCXX/global-init.cpp
===
--- cfe/trunk/test/CodeGenCXX/global-init.cpp
+++ cfe/trunk/test/CodeGenCXX/global-init.cpp
@@ -15,7 +15,7 @@
 
 struct D { ~D(); };
 
-// CHECK: @__dso_handle = external global i8
+// CHECK: @__dso_handle = external hidden global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
 // PR6205: The casts should not require global initializers
Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2162,7 +2162,9 @@
 
   // Create a variable that binds the atexit to this shared object.
   llvm::Constant *handle =
-CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+  CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+  auto *GV = cast(handle->stripPointerCasts());
+  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
   llvm::Value *args[] = {
 llvm::ConstantExpr::getBitCast(dtor, dtorTy),


Index: cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
===
--- cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
+++ cfe/trunk/test/OpenMP/threadprivate_codegen.cpp
@@ -176,7 +176,7 @@
 // CHECK-TLS-DAG:  [[ST_S4_ST:@.+]] = linkonce_odr thread_local global %struct.S4 zeroinitializer
 // CHECK-TLS-DAG:  [[ST_S4_ST_GUARD:@_ZGVN2STI2S4E2stE]] = linkonce_odr thread_local global i64 0
 // CHECK-TLS-DAG:  @__tls_guard = internal thread_local global i8 0
-// CHECK-TLS-DAG:  @__dso_handle = external global i8
+// CHECK-TLS-DAG:  @__dso_handle = external hidden global i8
 // CHECK-TLS-DAG:  [[GS1_TLS_INIT:@_ZTHL3gs1]] = internal alias void (), void ()* @__tls_init
 // CHECK-TLS-DAG:  [[ARR_X_TLS_INIT:@_ZTH5arr_x]] = alias void (), void ()* @__tls_init
 
Index: cfe/trunk/test/CodeGenCXX/global-init.cpp
===
--- cfe/trunk/test/CodeGenCXX/global-init.cpp
+++ cfe/trunk/test/CodeGenCXX/global-init.cpp
@@ -15,7 +15,7 @@
 
 struct D { ~D(); };
 
-// CHECK: @__dso_handle = external global i8
+// CHECK: @__dso_handle = external hidden global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
 // PR6205: The casts should not require global initializers
Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2162,7 +2162,9 @@
 
   // Create a variable that binds the atexit to this shared object.
   llvm::Constant *handle =
-CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+  CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+  auto *GV = cast(handle->stripPointerCasts());
+  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
 
   llvm::Value *args[] = {
 llvm::ConstantExpr::getBitCast(dtor, dtorTy),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29764: [OpenCL] Blocks cannot capture/reference another block

2017-02-13 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

Please fix the test. Otherwise LGTM. Thanks!


https://reviews.llvm.org/D29764



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


r294979 - [Test] Make Lit tests C++11 compatible - printf format string

2017-02-13 Thread Charles Li via cfe-commits
Author: lcharles
Date: Mon Feb 13 12:57:06 2017
New Revision: 294979

URL: http://llvm.org/viewvc/llvm-project?rev=294979&view=rev
Log:
[Test] Make Lit tests C++11 compatible - printf format string

Different diagnostics when format string does not match 
actual arg type.

This commit contains the first 2 of 3 tests reviewed in D29685

Modified:
cfe/trunk/test/SemaCXX/format-strings.cpp
cfe/trunk/test/SemaCXX/printf-cstr.cpp

Modified: cfe/trunk/test/SemaCXX/format-strings.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/format-strings.cpp?rev=294979&r1=294978&r2=294979&view=diff
==
--- cfe/trunk/test/SemaCXX/format-strings.cpp (original)
+++ cfe/trunk/test/SemaCXX/format-strings.cpp Mon Feb 13 12:57:06 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso 
-fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso 
-fblocks -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso 
-fblocks -std=c++11 %s
 
 #include 
 
@@ -9,9 +11,13 @@ extern int vprintf(const char *restrict,
 }
 
 void f(char **sp, float *fp) {
-  scanf("%as", sp); // expected-warning{{'a' length modifier is not supported 
by ISO C}}
+  scanf("%as", sp);
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{'a' length modifier is not supported by ISO C}}
+#else
+  // expected-warning@-4 {{format specifies type 'float *' but the argument 
has type 'char **'}}
+#endif
 
-  // TODO: Warn that the 'a' conversion specifier is a C++11 feature.
   printf("%a", 1.0);
   scanf("%afoobar", fp);
 }
@@ -46,11 +52,19 @@ void h(int *i) {
 // Test handling __null for format string literal checking.
 extern "C" {
   int test_null_format(const char *format, ...) __attribute__((__format__ 
(__printf__, 1, 2)));
+#if __cplusplus >= 201103L
+  // expected-note@-2 {{candidate function not viable: no known conversion 
from 'bool' to 'const char *' for 1st argument}}
+#endif
 }
 
 void rdar8269537(const char *f)
 {
-  test_null_format(false); // expected-warning {{null from a constant boolean}}
+  test_null_format(false);
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{null from a constant boolean}}
+#else
+  // expected-error@-4 {{no matching function for call to 'test_null_format'}}
+#endif
   test_null_format(0); // no-warning
   test_null_format(__null); // no-warning
   test_null_format(f); // expected-warning {{not a string literal}}

Modified: cfe/trunk/test/SemaCXX/printf-cstr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/printf-cstr.cpp?rev=294979&r1=294978&r2=294979&view=diff
==
--- cfe/trunk/test/SemaCXX/printf-cstr.cpp (original)
+++ cfe/trunk/test/SemaCXX/printf-cstr.cpp Mon Feb 13 12:57:06 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -Wformat -verify %s -Wno-error=non-pod-varargs
+// RUN: %clang_cc1 -fsyntax-only -Wformat -verify -std=c++98 %s 
-Wno-error=non-pod-varargs
+// RUN: %clang_cc1 -fsyntax-only -Wformat -verify -std=c++11 %s 
-Wno-error=non-pod-varargs
 
 #include 
 
@@ -31,12 +33,39 @@ void pod_test() {
   int n = 10;
 
   printf("%d: %s\n", n, hcs.c_str());
-  printf("%d: %s\n", n, hcs); // expected-warning{{cannot pass non-POD object 
of type 'HasCStr' to variadic function; expected type from format string was 
'char *'}} expected-note{{did you mean to call the c_str() method?}}
-  printf("%d: %s\n", n, hncs); // expected-warning{{cannot pass non-POD object 
of type 'HasNoCStr' to variadic function; expected type from format string was 
'char *'}}
-  sprintf(str, "%d: %s", n, hcs); // expected-warning{{cannot pass non-POD 
object of type 'HasCStr' to variadic function; expected type from format string 
was 'char *'}} expected-note{{did you mean to call the c_str() method?}}
-
-  printf(formatString, hcs, hncs); // expected-warning{{cannot pass object of 
non-POD type 'HasCStr' through variadic function}} expected-warning{{cannot 
pass object of non-POD type 'HasNoCStr' through variadic function}}
-  printf(extstr, hcs, n); // expected-warning{{cannot pass object of non-POD 
type 'HasCStr' through variadic function}}
+  printf("%d: %s\n", n, hcs);
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{cannot pass non-POD object of type 'HasCStr' to 
variadic function; expected type from format string was 'char *'}}
+  // expected-note@-3 {{did you mean to call the c_str() method?}}
+#else
+  // expected-warning@-5 {{format specifies type 'char *' but the argument has 
type 'HasCStr'}}
+#endif
+
+  printf("%d: %s\n", n, hncs);
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{cannot pass non-POD object of type 'HasNoCStr' to 
variadic function; expected type from format string was 'char *'}}
+#else
+  // expected-warning@-4 {{format specifies type 'char *' but the argument has 
type 'HasNoCStr'}}
+#

[PATCH] D21626: Lit C++11 Compatibility Patch #10

2017-02-13 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge updated this revision to Diff 88232.
tigerleapgorge edited the summary of this revision.
tigerleapgorge added a comment.

Remove 2 tests reviewed in https://reviews.llvm.org/D29685


https://reviews.llvm.org/D21626

Files:
  test/Modules/Inputs/merge-using-decls/a.h
  test/Modules/Inputs/merge-using-decls/b.h
  test/Modules/merge-using-decls.cpp
  test/SemaCXX/PR9572.cpp
  test/SemaCXX/default-assignment-operator.cpp
  test/SemaCXX/default-constructor-initializers.cpp
  test/SemaCXX/warn-thread-safety-parsing.cpp

Index: test/SemaCXX/warn-thread-safety-parsing.cpp
===
--- test/SemaCXX/warn-thread-safety-parsing.cpp
+++ test/SemaCXX/warn-thread-safety-parsing.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s
 
 #define LOCKABLE__attribute__ ((lockable))
 #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable))
@@ -1266,8 +1268,10 @@
   void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { }
   void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu);
 
-  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo5()EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif
 
   template 
   void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { }
@@ -1461,15 +1465,21 @@
   mutable Mutex mu;
   int a GUARDED_BY(mu);
 
-  static int si GUARDED_BY(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+  static int si GUARDED_BY(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of non-static data member 'mu'}}
+#endif
 
-  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of member 'mu' in static member function}}
+  static void foo() EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{invalid use of member 'mu' in static member function}}
+#endif
 
   friend FooStream& operator<<(FooStream& s, const Foo& f)
-EXCLUSIVE_LOCKS_REQUIRED(mu); // \
-// expected-error {{invalid use of non-static data member 'mu'}}
+EXCLUSIVE_LOCKS_REQUIRED(mu);
+#if __cplusplus <= 199711L
+// expected-error@-2 {{invalid use of non-static data member 'mu'}}
+#endif
 };
 
 
Index: test/SemaCXX/default-constructor-initializers.cpp
===
--- test/SemaCXX/default-constructor-initializers.cpp
+++ test/SemaCXX/default-constructor-initializers.cpp
@@ -1,26 +1,59 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct X1 { // has no implicit default constructor
X1(int);
 };
 
-struct X2  : X1 {  // expected-note 2 {{'X2' declared here}}
-   X2(int);
-};
-
-struct X3 : public X2 { // expected-error {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
-};
-X3 x3; // expected-note {{first required here}}
+struct X2  : X1 {
+#if __cplusplus <= 199711L
+// expected-note@-2 2 {{'X2' declared here}}
+#endif
 
-
-struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \
-// expected-error {{must explicitly initialize the reference member 'rx2'}}
-  X2 x2; 	// expected-note {{member is declared here}}
-  X2 & rx2; // expected-note {{declared here}}
+   X2(int);
 };
 
-X4 x4; // expected-note {{first required here}}
-
+struct X3 : public X2 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{implicit default constructor for 'X3' must explicitly initialize the base class 'X2' which does not have a default constructor}}
+#else
+// expected-note@-4 {{default constructor of 'X3' is implicitly deleted because base class 'X2' has no default constructor}}
+#endif
+};
+
+X3 x3;
+#if __cplusplus <= 199711L
+// expected-note@-2 {{first required here}}
+#else
+// expected-error@-4 {{call to implicitly-deleted default constructor of 'X3'}}
+#endif
+
+struct X4 {
+#if __cplusplus <= 199711L
+// expected-error@-2 {{must explicitly initialize the member 'x2'}}
+// expected-error@-3 {{must explicitly initialize the reference member 'rx2'}}
+#endif
+
+  X2 x2;
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{member is declared here}}
+#else
+  // expected-note@-4 {{default constructor of 'X4' is implicitly deleted because field 'x2' has no default constructor}}
+#endif
+
+  X2 & rx2;
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{declared here}}
+#endif
+};
+
+X4 x4;
+#if __cplusplus <= 199711L
+// expected-note@-2 {{first required here}}
+#else
+// expected-error@-4 {{call to implicitly-delete

[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-13 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I committed a modified patch that set the visibility on the global after 
creating it to avoid adding an optional boolean parameter. Thanks for the 
report and patch!


Repository:
  rL LLVM

https://reviews.llvm.org/D29843



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


[PATCH] D29901: Modular Codegen: Add/use a bit in serialized function definitions to track whether they are the subject of modular codegen

2017-02-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie created this revision.

Some decls are created not where they are written, but in other module
files/users (implicit special members and function template implicit
specializations). To correctly identify them, use a bit next to the definition
to track the modular codegen property.

Possible improvement would be to store this bit on the Decl itself, rather than
a sidemap - happy to give that a whirl if it seems better. (actually it'd be
two bits, since 3 states are required - currently reflected by "not in the
map", "in the map with Always", "in the map with Never")

Discussed whether the module file bit could be omitted in favor of
reconstituting from the modular codegen decls list - best guess today is that
the efficiency improvement of not having to deserialize the whole list whenever
any function is queried by a module user is worth it for the small size
increase of this redundant (list + bit-on-def) representation.


https://reviews.llvm.org/D29901

Files:
  include/clang/AST/ExternalASTSource.h
  include/clang/Sema/MultiplexExternalSemaSource.h
  include/clang/Serialization/ASTReader.h
  lib/AST/ASTContext.cpp
  lib/AST/ExternalASTSource.cpp
  lib/Sema/MultiplexExternalSemaSource.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/Modules/Inputs/codegen/foo.h
  test/Modules/Inputs/codegen/use.cpp
  test/Modules/codegen.test

Index: test/Modules/codegen.test
===
--- test/Modules/codegen.test
+++ test/Modules/codegen.test
@@ -3,8 +3,23 @@
 
 RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
 
-RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s
+RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s
 
-CHECK: $_Z2f1PKcz = comdat any
-CHECK: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat
-CHECK:   call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}})
+FOO: $_Z2f1PKcz = comdat any
+FOO: $_ZN13implicit_dtorD1Ev = comdat any
+USE: $_Z4instIiEvv = comdat any
+FOO: $_ZN13implicit_dtorD2Ev = comdat any
+FOO: define weak_odr void @_Z2f1PKcz(i8* %fmt, ...) #{{[0-9]+}} comdat
+FOO:   call void @llvm.va_start(i8* %{{[a-zA-Z0-9]*}})
+
+Test that implicit special members (like this dtor) are emitted into both module (if they're used there) and user.
+FIXME: Proactively instantiate any valid implicit special members to emit them into the module object.
+
+FOO: define weak_odr void @_ZN13implicit_dtorD1Ev(%struct.implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+FOO: define weak_odr void @_Z4instIfEvv() #0 comdat {
+FOO: define weak_odr void @_ZN13implicit_dtorD2Ev(%struct.implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+
+USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD1Ev(%struct.uninst_implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
+USE: define linkonce_odr void @_Z4instIiEvv() #0 comdat {
+USE: define linkonce_odr void @_ZN20uninst_implicit_dtorD2Ev(%struct.uninst_implicit_dtor* %this) unnamed_addr #0 comdat align 2 {
Index: test/Modules/Inputs/codegen/use.cpp
===
--- /dev/null
+++ test/Modules/Inputs/codegen/use.cpp
@@ -0,0 +1,8 @@
+#include "foo.h"
+void non_modular_use_of_implicit_dtor() {
+  implicit_dtor d1;
+  uninst_implicit_dtor d2;
+}
+void use_of_instantiated_declaration_without_definition() {
+  inst();
+}
Index: test/Modules/Inputs/codegen/foo.h
===
--- test/Modules/Inputs/codegen/foo.h
+++ test/Modules/Inputs/codegen/foo.h
@@ -2,3 +2,29 @@
   __builtin_va_list args;
   __builtin_va_start(args, fmt);
 }
+
+struct non_trivial_dtor {
+  ~non_trivial_dtor();
+};
+
+struct implicit_dtor {
+  non_trivial_dtor d;
+};
+
+struct uninst_implicit_dtor {
+  non_trivial_dtor d;
+};
+
+inline void use_implicit_dtor() {
+  implicit_dtor d;
+}
+
+template
+void inst() {
+}
+
+inline void inst_decl() {
+  // cause inst's declaration to be instantiated, without a definition.
+  (void)sizeof(&inst);
+  inst();
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -2224,6 +2224,8 @@
   Writer->ClearSwitchCaseIDs();
 
   assert(FD->doesThisDeclarationHaveABody());
+  Record->push_back(Writer->Context->getLangOpts().ModularCodegen &&
+Writer->WritingModule);
   if (auto *CD = dyn_cast(FD)) {
 Record->push_back(CD->getNumCtorInitializers());
 if (CD->getNumCtorInitializers())
Index:

[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++

2017-02-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D29739#675277, @probinson wrote:

> In https://reviews.llvm.org/D29739#674297, @rjmccall wrote:
>
> > In https://reviews.llvm.org/D29739#674288, @probinson wrote:
> >
> > > I really think Apple would need to step up here if the default 
> > > Objective-C++ dialect is going to change.
> >
> >
> > I don't mind stepping up and doing this work.  I just thought you'd already 
> > done it.  This patch updates some tests; is that enough, or are there 
> > further changes required in order to change the default ObjC++ dialect?
> >
> > John.
>
>
> Charles tells me this is the last group of Objective-C++ tests that failed, 
> so maybe there isn't anything else to do after all.  I had thought there were 
> more.  He'll go ahead with this set.
>  We have another couple dozen C++ tests to straighten out, then we'll be 
> ready to have the dev-list discussion about upgrading the default for 5.0, 
> and whether it's the narrow case (just C++ and just for PS4, which was our 
> original plan) or the big bang (both languages and for everybody).


Okay, thanks, sounds good.


https://reviews.llvm.org/D29739



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


[PATCH] D24812: Lit C++11 Compatibility Patch #11

2017-02-13 Thread John McCall via Phabricator via cfe-commits
rjmccall added a reviewer: rnk.
rjmccall added a comment.

Generally looks good to me, thanks.  One question for Reid.




Comment at: test/CodeGenCXX/static-init.cpp:14
+// CHECK98: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global 
%"struct.test4::HasVTable" zeroinitializer, comdat, align 8
+// CHECK11: @_ZZN5test414useStaticLocalEvE3obj = linkonce_odr global { i8** } 
{ i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* 
@_ZTVN5test49HasVTableE, i32 0, inrange i32 0, i32 2) }, comdat, align 8
 

Interesting.  It looks to me like the C++11 IR pattern is actually the only one 
that would've exposed the bug that Reid was fixing in r242704.  Reid, do you 
agree?



Comment at: test/CodeGenCXX/volatile.cpp:31
 // CHECK:  [[TMP:%.*]] = load i32*, i32** @_ZN5test11xE, align 8
+// CHECK11:{{%.*}} = load volatile i32, i32* [[TMP]], align 4
 // CHECK-NEXT: ret void

CHECK11-NEXT, please.


https://reviews.llvm.org/D24812



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


[PATCH] D29904: [OpenMP] Prevent emission of exception handling code when using OpenMP to offload to NVIDIA devices.

2017-02-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.

For the OpenMP toolchain which offloads to NVIDIA GPUs make sure that no 
exception handling code is emitted.


Repository:
  rL LLVM

https://reviews.llvm.org/D29904

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/OpenMP/target_parallel_no_exceptions.cpp


Index: test/OpenMP/target_parallel_no_exceptions.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_no_exceptions.cpp
@@ -0,0 +1,29 @@
+/// Make sure no exception messages are inclided in the llvm output.
+// RUN: %clang -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CHK-EXCEPTION %s
+
+#include 
+
+#define SIZE 100
+#define EPS 1e-10
+
+void test_increment(){
+  #pragma omp target
+  {
+#pragma omp parallel
+{
+  int a = 10;
+  printf("a = %d\n", a);
+}
+  }
+}
+
+int main(){
+  test_increment();
+  return 0;
+}
+
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLESTART__ openmp-nvptx64-nvidia-cuda
+//CHK-EXCEPTION-NOT: __cxa_begin_catch
+//CHK-EXCEPTION-NOT: terminate.lpad
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLEEND__ openmp-nvptx64-nvidia-cuda
+
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2163,6 +2163,13 @@
 break;
   }
 }
+
+// Set the flag to prevent the implementation from emitting device 
exception
+// handling code for those requiring so.
+if (Opts.OpenMPIsDevice && T.isNVPTX()) {
+  Opts.Exceptions = 0;
+  Opts.CXXExceptions = 0;
+}
   }
 
   // Get the OpenMP target triples if any.


Index: test/OpenMP/target_parallel_no_exceptions.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_no_exceptions.cpp
@@ -0,0 +1,29 @@
+/// Make sure no exception messages are inclided in the llvm output.
+// RUN: %clang -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CHK-EXCEPTION %s
+
+#include 
+
+#define SIZE 100
+#define EPS 1e-10
+
+void test_increment(){
+  #pragma omp target
+  {
+#pragma omp parallel
+{
+  int a = 10;
+  printf("a = %d\n", a);
+}
+  }
+}
+
+int main(){
+  test_increment();
+  return 0;
+}
+
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLESTART__ openmp-nvptx64-nvidia-cuda
+//CHK-EXCEPTION-NOT: __cxa_begin_catch
+//CHK-EXCEPTION-NOT: terminate.lpad
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLEEND__ openmp-nvptx64-nvidia-cuda
+
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2163,6 +2163,13 @@
 break;
   }
 }
+
+// Set the flag to prevent the implementation from emitting device exception
+// handling code for those requiring so.
+if (Opts.OpenMPIsDevice && T.isNVPTX()) {
+  Opts.Exceptions = 0;
+  Opts.CXXExceptions = 0;
+}
   }
 
   // Get the OpenMP target triples if any.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29905: [OpenMP] Pass argument to device kernel by reference when map is used.

2017-02-13 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.

When a scalar argument is explicitly mapped, the device kernel needs to be 
passed that argument by reference.

This is a partial fix to this bug 
.

The full fix requires data sharing support which will land in future patches.


Repository:
  rL LLVM

https://reviews.llvm.org/D29905

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_map_codegen.cpp


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,24 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang -DCK30 -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CK30 %s
+#ifdef CK30
+#include 
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+  #pragma omp target map(tofrom:ParamToKernel)
+  {
+printf("Print ParamToKernel = %d\n", ParamToKernel);
+#pragma omp parallel
+{
+  printf("Do nothing\n");
+}
+  }
+}
+
+// CK30: define void 
@__omp_offloading_802_{{.*}}target_maps_parallel_integer{{.*}}l{{.*}}(i32* 
dereferenceable(4) %ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -355,6 +355,27 @@
 return false;
   }
 
+  /// Do the check specified in \a Check to all component lists at a given 
level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> &Check) {
+auto StartI = std::next(Stack.begin());
+auto EndI = Stack.end();
+if (std::distance(StartI, EndI) <= (int)Level)
+  return false;
+std::advance(StartI, Level);
+
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto &L : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
+return false;
+  }
+
   /// Create a new mappable expression component list associated with a given
   /// declaration and initialize it with the provided list of components.
   void addMappableExpressionComponents(
@@ -912,9 +933,8 @@
 bool IsVariableUsedInMapClause = false;
 bool IsVariableAssociatedWithSection = false;
 
-DSAStack->checkMappableExprComponentListsForDecl(
-D, /*CurrentRegionOnly=*/true,
-[&](OMPClauseMappableExprCommon::MappableExprComponentListRef
+DSAStack->checkMappableExprComponentListsForDeclAtLevel(
+D, Level, [&](OMPClauseMappableExprCommon::MappableExprComponentListRef
 MapExprComponents,
 OpenMPClauseKind WhereFoundClauseKind) {
   // Only the map clause information influences how a variable is


Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4756,3 +4756,24 @@
 }
 #endif
 #endif
+
+///==///
+// RUN: %clang -DCK30 -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CK30 %s
+#ifdef CK30
+#include 
+
+void target_maps_parallel_integer(int a){
+  int ParamToKernel = a;
+  #pragma omp target map(tofrom:ParamToKernel)
+  {
+printf("Print ParamToKernel = %d\n", ParamToKernel);
+#pragma omp parallel
+{
+  printf("Do nothing\n");
+}
+  }
+}
+
+// CK30: define void @__omp_offloading_802_{{.*}}target_maps_parallel_integer{{.*}}l{{.*}}(i32* dereferenceable(4) %ParamToKernel) #0 {
+
+#endif
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -355,6 +355,27 @@
 return false;
   }
 
+  /// Do the check specified in \a Check to all component lists at a given level
+  /// and return true if any issue is found.
+  bool checkMappableExprComponentListsForDeclAtLevel(
+  ValueDecl *VD, unsigned Level,
+  const llvm::function_ref<
+  bool(OMPClauseMappableExprCommon::MappableExprComponentListRef,
+   OpenMPClauseKind)> &Check) {
+auto StartI = std::next(Stack.begin());
+auto EndI = Stack.end();
+if (std::distance(StartI, EndI) <= (int)Level)
+  return false;
+std::advance(StartI, Level);
+
+auto MI = StartI->MappedExprComponents.find(VD);
+if (MI != StartI->MappedExprComponents.end())
+  for (auto &L : MI->second.Components)
+if (Check(L, MI->second.Kind))
+  return true;
+return false;
+

[PATCH] D28933: Revert the return type for `emplace_(back|front)` to `void` in C++14 and before

2017-02-13 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Landed as r292990.


https://reviews.llvm.org/D28933



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


[PATCH] D29432: Modular Codegen: Emit inline asm into users, not modular objects

2017-02-13 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

+rsmith we chatted about a bit of this offline & some things came out of it, 
not entirely resolved:

1. Is this the right thing for inline asm or similar things (static functions? 
static variables?) - I was mirroring the choice already made for static 
variables (motivated by the iostreams initializer) sort of broadening that idea 
to "you can put internal linkage things in headers so long as you don't 
actually violate the ODR by referring to them in linkage-having entities in the 
header". But that may be impractically aggressive. Practically speaking maybe 
static locals get a special exemption and everything else goes everywhere it's 
used, modular object or not?

2. The refactoring of DeclMustBeEmitted to take an (in)out parameter seemed 
good, but there was some discussion around whether it should instead return a 
more complex value rather than an optional inout parameter. Did you have any 
further thoughts on that? I think we talked about it possibly being a bit 
complicated for existing callers because they want to treat two different 
states as "false" (both Never and Always map to "it doesn't /have/ to be 
emitted").


https://reviews.llvm.org/D29432



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


[PATCH] D20660: Remove `auto_ptr` in C++17.

2017-02-13 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

Landed as r292986


https://reviews.llvm.org/D20660



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


[PATCH] D29464: [MinGWToolChain] Don't use GCC headers on Win32

2017-02-13 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 added a comment.

My GPU has died in the meantime but openmp project doesn't seem buildable with 
mingw-w64 based compilers.
So the case is still open.


https://reviews.llvm.org/D29464



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


[PATCH] D28473: Implement http://wg21.link/P0426 Constexpr for std::char_traits

2017-02-13 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists closed this revision.
mclow.lists added a comment.

Landed as r291741, r291742 and r293154.


https://reviews.llvm.org/D28473



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


[PATCH] D29908: Disallow returning a __block variable via a move

2017-02-13 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.

This patch disables moving a __block variable to return it from a function, 
which was causing a crash that occurred when compiling and executing the 
following code:

  #include 
  #include 
  #include 
  
  class A {
  public:
A(int x) : internal(x) {}
int internal;
  };
  
  dispatch_semaphore_t sema;
  dispatch_queue_t q;
  
  std::shared_ptr dispatch_function(int x) {
__block std::shared_ptr ret = std::shared_ptr(new A(x));
dispatch_async(q, ^{
  printf("%d\n", ret->internal); // segfaults here
  dispatch_semaphore_signal(sema);
});
return ret;
  }
  
  int main() {
q = dispatch_queue_create("com.example.MyCustomQueue", NULL);
sema = dispatch_semaphore_create(0);
dispatch_function(100);
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
dispatch_release(sema);
return 0;
  }

This is how the crash occurs:

1. When dispatch_async is called, the block passed to it is copied to the heap, 
and when that happens the shared_ptr is moved to the heap. Note that the 
shared_ptr is moved, not copied, in @__Block_byref_object_copy_ because 
Sema::CheckCompleteVariableDeclaration passes " /*AllowNRVO=*/true" to the call 
to PerformMoveOrCopyInitialization. I'm not sure whether this is correct or 
not, but even after changing it to pass AllowNRVO=false, the code still crashes.

2. "ret" is moved to the return aggregate. Since "ret" is a __block variable, 
it refers to the shared_ptr on the heap, not on the stack, so the one on the 
heap is moved.

3. The destructor for the shared_ptr on the stack is called when 
dispatch_function exits.

4. When dispatch_function returns in "main", the returned shared_ptr is 
immediately destructed, and the object it points to is destructed too when the 
reference count drops to zero.

5. The code crashes when the block passed to dispatch_async is executed since 
the object ret  used to point to has been destructed.

An alternate solution that fixes the crash is to somehow pass 
followForward=false to CodeGenFunction::emitBlockByrefAddress so that it emits 
the address of the shared_ptr on the stack, not on the heap, but I guess that 
is not always correct and can break some other code.

rdar://problem/28181080


https://reviews.llvm.org/D29908

Files:
  lib/Sema/SemaStmt.cpp
  test/SemaObjCXX/blocks.mm


Index: test/SemaObjCXX/blocks.mm
===
--- test/SemaObjCXX/blocks.mm
+++ test/SemaObjCXX/blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class 
-std=c++11 %s
 @protocol NSObject;
 
 void bar(id(^)(void));
@@ -144,3 +144,17 @@
 
   template void f(X);
 }
+
+namespace MoveBlockVariable {
+struct B0 {
+};
+
+struct B1 { // expected-note 2 {{candidate constructor (the implicit}}
+  B1(B0&&); // expected-note {{candidate constructor not viable}}
+};
+
+B1 test_move() {
+  __block B0 b;
+  return b; // expected-error {{no viable conversion from returned value of 
type 'MoveBlockVariable::B0' to function return type 'MoveBlockVariable::B1'}}
+}
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2743,15 +2743,15 @@
   // ...automatic...
   if (!VD->hasLocalStorage()) return false;
 
+  // __block variables can't be allocated in a way that permits NRVO.
+  if (VD->hasAttr()) return false;
+
   if (AllowParamOrMoveConstructible)
 return true;
 
   // ...non-volatile...
   if (VD->getType().isVolatileQualified()) return false;
 
-  // __block variables can't be allocated in a way that permits NRVO.
-  if (VD->hasAttr()) return false;
-
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
   if (!VD->getType()->isDependentType() && VD->hasAttr() &&


Index: test/SemaObjCXX/blocks.mm
===
--- test/SemaObjCXX/blocks.mm
+++ test/SemaObjCXX/blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class -std=c++11 %s
 @protocol NSObject;
 
 void bar(id(^)(void));
@@ -144,3 +144,17 @@
 
   template void f(X);
 }
+
+namespace MoveBlockVariable {
+struct B0 {
+};
+
+struct B1 { // expected-note 2 {{candidate constructor (the implicit}}
+  B1(B0&&); // expected-note {{candidate constructor not viable}}
+};
+
+B1 test_move() {
+  __block B0 b;
+  return b; // expected-error {{no viable conversion from returned value of type 'MoveBlockVariable::B0' to function return type 'MoveBlockVariable::B1'}}
+}
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -2743,15 +2743,15 @@
   // ...automatic...
   if (!VD->hasL

[PATCH] D29910: [OpenMP] Specialize default schedule on a worksharing loop on the NVPTX device.

2017-02-13 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob created this revision.

The default schedule type on a worksharing loop is implementation
defined according to the OpenMP specifications.  Currently, the
compiler codegens a doubly nested loop that effectively implements
a schedule of type (static).  This is ideal for threads on CPUs.

On the NVPTX and other SIMT GPUs, this schedule provides very poor
performance because consecutive threads in a warp access loop arrays
in a non-coalesced manner.  That is, to achieve coalescing, and good
performance, the best schedule is static with a chunk size of 1.

This patch adds support for target devices to select the best default
schedule depending on their architecture.  It modifies loop codegen
to generate optimized code for (static,1) on the NVPTX device, i.e.,
by using a single loop instead of a doubly nested loop as is
currently the case.


https://reviews.llvm.org/D29910

Files:
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/OpenMPKinds.h
  lib/AST/StmtOpenMP.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nvptx_coalesced_scheduling_codegen.cpp

Index: test/OpenMP/nvptx_coalesced_scheduling_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_coalesced_scheduling_codegen.cpp
@@ -0,0 +1,322 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fexceptions -fcxx-exceptions -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// Check that the execution mode of the target regions on the gpu is set to the right mode.
+// CHECK-DAG: {{@__omp_offloading_.+l19}}_exec_mode = weak constant i8 0
+
+template
+tx ftemplate() {
+  tx a[100];
+  tx b[10][10];
+
+  #pragma omp target parallel
+  {
+#pragma omp for
+for (int i = 0; i < 99; i++) {
+  a[i] = 1;
+}
+
+#pragma omp for schedule(auto)
+for (int i = 0; i < 98; i++) {
+  a[i] = 2;
+}
+
+#pragma omp for schedule(static,1)
+for (int i = 0; i < 97; i++) {
+  a[i] = 3;
+}
+
+#pragma omp for schedule(static,2)
+for (int i = 0; i < 96; i++) {
+  a[i] = 1;
+}
+
+#pragma omp for schedule(static)
+for (int i = 0; i < 95; i++) {
+  a[i] = 1;
+}
+
+#pragma omp for schedule(auto) ordered
+for (int i = 0; i < 94; i++) {
+  a[i] = 1;
+}
+
+#pragma omp for schedule(runtime)
+for (int i = 0; i < 93; i++) {
+  a[i] = 1;
+}
+
+#pragma omp for schedule(dynamic)
+for (int i = 0; i < 92; i++) {
+  a[i] = 1;
+}
+
+#pragma omp for schedule(guided)
+for (int i = 0; i < 91; i++) {
+  a[i] = 1;
+}
+  }
+
+  return a[0] + b[9][9];
+}
+
+int bar(){
+  int a = 0;
+
+  a += ftemplate();
+
+  return a;
+}
+
+  // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+template.+l19}}(
+  // CHECK: call void @__kmpc_spmd_kernel_init(
+  // CHECK: br label {{%?}}[[EXEC:.+]]
+  //
+  // CHECK: [[EXEC]]
+  // CHECK: {{call|invoke}} void [[OP1:@.+]](i32*
+  // CHECK: br label {{%?}}[[DONE:.+]]
+  //
+  // CHECK: [[DONE]]
+  // CHECK: call void @__kmpc_spmd_kernel_deinit()
+  // CHECK: br label {{%?}}[[EXIT:.+]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK: ret void
+  // CHECK: }
+
+  // CHECK: define internal void [[OP1]](
+
+  // No schedule clause.
+  //
+  // CHECK: store i32 0, i32* [[LB_PTR:%.+]], align
+  // CHECK: store i32 98, i32* [[UB_PTR:%.+]], align
+  // CHECK: store i32 1, i32* [[ST_PTR:%.+]], align
+  // CHECK: call void @__kmpc_for_static_init_4(%ident_t* {{@.+}}, i32 {{%.+}}, i32 33, i32* {{%.+}}, i32* [[LB_PTR]], i32* [[UB_PTR]], i32* [[ST_PTR]], i32 1, i32 1)
+  // CHECK: [[LB:%.+]] = load i32, i32* [[LB_PTR]], align
+  // CHECK: store i32 [[LB]], i32* [[IV_PTR:%.+]], align
+  // CHECK: br label {{%?}}[[FOR_COND:.+]]
+  //
+  // CHECK: [[FOR_COND]]
+  // CHECK: [[IV

[PATCH] D29912: [MS ABI] Correctly mangling vbase destructors

2017-02-13 Thread David Majnemer via Phabricator via cfe-commits
majnemer created this revision.

They are a little bit of a special case in the mangling. They are always
mangled without taking into account their virtual-ness of the
destructor. They are also mangled to return void, unlike the actual
destructor.

This fixes PR31931.


https://reviews.llvm.org/D29912

Files:
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenCXX/debug-info-ms-dtor-thunks.cpp
  test/CodeGenCXX/exceptions-cxx-new.cpp
  test/CodeGenCXX/inheriting-constructor.cpp
  test/CodeGenCXX/microsoft-abi-dynamic-cast.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp
  test/CodeGenCXX/microsoft-abi-throw.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
  test/CodeGenCXX/regcall.cpp

Index: test/CodeGenCXX/regcall.cpp
===
--- test/CodeGenCXX/regcall.cpp
+++ test/CodeGenCXX/regcall.cpp
@@ -47,8 +47,8 @@
   // CHECK-LIN-DAG: define linkonce_odr x86_regcallcc void @_ZN10test_classD2Ev
   // CHECK-LIN-DAG: define linkonce_odr x86_regcallcc void @_ZN10test_classD1Ev
   // Windows ignores calling convention on constructor/destructors.
-  // CHECK-WIN64-DAG: define linkonce_odr void @"\01??_Dtest_class@@QEAA@XZ"
-  // CHECK-WIN32-DAG: define linkonce_odr x86_thiscallcc void @"\01??_Dtest_class@@QAE@XZ"
+  // CHECK-WIN64-DAG: define linkonce_odr void @"\01??_Dtest_class@@QEAAXXZ"
+  // CHECK-WIN32-DAG: define linkonce_odr x86_thiscallcc void @"\01??_Dtest_class@@QAEXXZ"
   
   test_class& __regcall operator+=(const test_class&){
 return *this;
Index: test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
===
--- test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -84,7 +84,7 @@
 
   // CHECK: ret
 
-  // CHECK2-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_DB@@UAE@XZ"(%struct.B*
+  // CHECK2-LABEL: define linkonce_odr x86_thiscallcc void @"\01??_DB@@QAEXXZ"(%struct.B*
   // CHECK2: %[[THIS:.*]] = load %struct.B*, %struct.B** {{.*}}
   // CHECK2: %[[THIS_i8:.*]] = bitcast %struct.B* %[[THIS]] to i8*
   // CHECK2: %[[B_i8:.*]] = getelementptr i8, i8* %[[THIS_i8]], i32 8
@@ -102,7 +102,7 @@
   // CHECK2:   %[[THIS:.*]] = bitcast i8* %[[THIS_i8]] to %struct.B*
   // CHECK2:   store %struct.B* %[[THIS]], %struct.B** %[[THIS_ADDR:.*]], align 4
   // CHECK2:   %[[THIS:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
-  // CHECK2:   call x86_thiscallcc void @"\01??_DB@@UAE@XZ"(%struct.B* %[[THIS]])
+  // CHECK2:   call x86_thiscallcc void @"\01??_DB@@QAEXXZ"(%struct.B* %[[THIS]])
   // ...
   // CHECK2: ret
 }
@@ -208,7 +208,7 @@
   B b;
   // CHECK: call x86_thiscallcc %struct.B* @"\01??0B@@QAE@XZ"(%struct.B* %[[B:.*]], i32 1)
   // CHECK-NOT: getelementptr
-  // CHECK: call x86_thiscallcc void @"\01??_DB@@UAE@XZ"(%struct.B* %[[B]])
+  // CHECK: call x86_thiscallcc void @"\01??_DB@@QAEXXZ"(%struct.B* %[[B]])
   // CHECK: ret
 }
 
Index: test/CodeGenCXX/microsoft-abi-throw.cpp
===
--- test/CodeGenCXX/microsoft-abi-throw.cpp
+++ test/CodeGenCXX/microsoft-abi-throw.cpp
@@ -12,7 +12,7 @@
 // CHECK-DAG: @"\01??_R0?AUV@@@8" = linkonce_odr global %rtti.TypeDescriptor7 { i8** @"\01??_7type_info@@6B@", i8* null, [8 x i8] c".?AUV@@\00" }, comdat
 // CHECK-DAG: @"_CT??_R0?AUV@@@81044" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor7* @"\01??_R0?AUV@@@8" to i8*), i32 0, i32 4, i32 4, i32 1, i8* null }, section ".xdata", comdat
 // CHECK-DAG: @"_CTA5?AUY@@" = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.5 { i32 5, [5 x %eh.CatchableType*] [%eh.CatchableType* @"_CT??_R0?AUY@@@8??0Y@@QAE@ABU0@@Z8", %eh.CatchableType* @"_CT??_R0?AUZ@@@81", %eh.CatchableType* @"_CT??_R0?AUW@@@8??0W@@QAE@ABU0@@Z44", %eh.CatchableType* @"_CT??_R0?AUM@@@818", %eh.CatchableType* @"_CT??_R0?AUV@@@81044"] }, section ".xdata", comdat
-// CHECK-DAG: @"_TI5?AUY@@" = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* bitcast (void (%struct.Y*)* @"\01??_DY@@QAE@XZ" to i8*), i8* null, i8* bitcast (%eh.CatchableTypeArray.5* @"_CTA5?AUY@@" to i8*) }, section ".xdata", comdat
+// CHECK-DAG: @"_TI5?AUY@@" = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i8* bitcast (void (%struct.Y*)* @"\01??_DY@@QAEXXZ" to i8*), i8* null, i8* bitcast (%eh.CatchableTypeArray.5* @"_CTA5?AUY@@" to i8*) }, section ".xdata", comdat
 // CHECK-DAG: @"_CT??_R0?AUDefault@@@8??_ODefault@@QAEXAAU0@@Z1" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescriptor13* @"\01??_R0?AUDefault@@@8" to i8*), i32 0, i32 -1, i32 0, i32 1, i8* bitcast (void (%struct.Default*, %struct.Default*)* @"\01??_ODefault@@QAEXAAU0@@Z" to i8*) }, section ".xdata", comdat
 // CHECK-DAG: @"_CT??_R0?AUVariadic@@@8??_OVariadic@@QAEXAAU0@@Z1" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i8* bitcast (%rtti.TypeDescri

[PATCH] D29868: Recover more gracefully when __declspec is not supported as a keyword

2017-02-13 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/Parse/ParseDecl.cpp:2989
+
+  Diag(Loc, diag::err_ms_attributes_not_enabled);
+  continue;

aaron.ballman wrote:
> compnerd wrote:
> > aaron.ballman wrote:
> > > compnerd wrote:
> > > > I think that we want to emit the diagnostic even if there is no 
> > > > parenthesis as `__declspec` is a reserved identifier, and we would 
> > > > normally diagnose the bad `__declspec` (expected '(' after 
> > > > '__declspec').
> > > Yes, but it could also lead to a rejecting code that we used to accept 
> > > and properly handle when __declspec is an identifier rather than a 
> > > keyword. e.g.,
> > > ```
> > > struct __declspec {};
> > > 
> > > __declspec some_func(void);
> > > ```
> > > By looking for the paren, we run less risk of breaking working code, even 
> > > if that code abuses the implementation namespace (after all, __declspec 
> > > it not a keyword in this scenario).
> > But we would reject that code under `-fdeclspec` anyways.  I think having 
> > the code be more portable is a bit nicer.
> After discussing in IRC, I decided that I agree with @compnerd on this and 
> have changed the patch accordingly.
What if somebody wants to use __declspec and are using the compiler in a 
freestanding mode? Also, we aren't the only member of the implementor's 
namespace.


https://reviews.llvm.org/D29868



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


[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk marked 2 inline comments as done.
vsk added inline comments.



Comment at: test/CodeGenCXX/ubsan-suppress-null-checks.cpp:8
+  int load_member() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch

arphaman wrote:
> I think this kind of check would've passed even when this patch is not 
> applied. I understand that you need the first check for the single 'this' 
> check, but it should be rewritten to ensure that it couldn't be the check for 
> the `return foo`. Maybe you could use a C label before return and then check 
> that the 'this' check is performed before the label?
Yes, this check should be tighter. This just checks that the number of checks 
in the method goes from 2 to 1. The label idea is great.


https://reviews.llvm.org/D29530



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


[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-13 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 88259.
vsk marked an inline comment as done.
vsk added a comment.

- Tighten up the tests per Alex's suggestion.


https://reviews.llvm.org/D29530

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/catch-undef-behavior.c
  test/CodeGen/sanitize-recover.c
  test/CodeGenCXX/ubsan-suppress-null-checks.cpp

Index: test/CodeGenCXX/ubsan-suppress-null-checks.cpp
===
--- /dev/null
+++ test/CodeGenCXX/ubsan-suppress-null-checks.cpp
@@ -0,0 +1,161 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null | FileCheck %s
+
+struct A {
+  int foo;
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A10do_nothingEv
+  void do_nothing() {
+// CHECK: icmp ne %struct.A* %[[THIS1:[a-z0-9]+]], null, !nosanitize
+// CHECK: ptrtoint %struct.A* %[[THIS1]] to i64, !nosanitize
+// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11load_memberEv
+  int load_member() {
+// CHECK: icmp ne %struct.A* %[[THIS2:[a-z0-9]+]], null, !nosanitize
+// CHECK: ptrtoint %struct.A* %[[THIS2]] to i64, !nosanitize
+// CHECK-NEXT: call void @__ubsan_handle_type_mismatch
+// CHECK: L1
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L1:
+return foo;
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11call_methodEv
+  int call_method() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L2
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L2:
+return load_member();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_1Ev
+  void assign_member_1() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L3
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L3:
+foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_2Ev
+  void assign_member_2() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L4
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L4:
+(__extension__ (this))->foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZNK1A15assign_member_3Ev
+  void assign_member_3() const {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L5
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L5:
+const_cast(this)->foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A22call_through_referenceERS_
+  static int call_through_reference(A &a) {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return a.load_member();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A20call_through_pointerEPS_
+  static int call_through_pointer(A *a) {
+// CHECK: call void @__ubsan_handle_type_mismatch
+return a->load_member();
+// CHECK: ret i32
+  }
+};
+
+struct B {
+  operator A*() const { return nullptr; }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1B11load_memberEv
+  static int load_member() {
+// Null-check &b before converting it to an A*.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// Null-check the result of the conversion before using it.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+B b;
+return static_cast(b)->load_member();
+// CHECK: ret i32
+  }
+};
+
+struct Base {
+  int foo;
+
+  virtual int load_member_1() = 0;
+};
+
+struct Derived : public Base {
+  int bar;
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_2Ev
+  int load_member_2() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L6
+L6:
+// Null-check the result of the cast before using it.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return dynamic_cast(this)->load_member_1();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_3Ev
+  int load_member_3() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L7
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L7:
+return reinterpret_cast(static_cast(this))->foo;
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_1Ev
+  int load_member_1() override {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK: L8
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+L8:
+return foo + bar;
+// CHECK: ret i32
+  }
+};
+
+void force_irgen() {
+  A *a;
+  a->do_nothing();
+  a->load_member();
+  a->call_method

[libcxx] r294995 - Add tests for noexcept functions

2017-02-13 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Feb 13 16:44:39 2017
New Revision: 294995

URL: http://llvm.org/viewvc/llvm-project?rev=294995&view=rev
Log:
Add tests for noexcept functions

Modified:

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp

libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp?rev=294995&r1=294994&r2=294995&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp
 Mon Feb 13 16:44:39 2017
@@ -13,6 +13,7 @@
 
 #include 
 #include // for std::nullptr_t
+
 #include "test_macros.h"
 
 template 
@@ -79,22 +80,27 @@ int main()
test_is_function();
test_is_function();
 
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function(); // function pointer is not a function
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
-test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function(); // function pointer is not a function
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+  test_is_not_function();
+
+#if TEST_STD_VER >= 11
+  test_is_function();
+  test_is_function();
+#endif
 }

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp?rev=294995&r1=294994&r2=294995&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp
 Mon Feb 13 16:44:39 2017
@@ -97,4 +97,10 @@ int main()
 test_is_not_member_pointer();
 test_is_not_member_pointer();
 test_is_not_member_pointer();
+
+#if TEST_STD_VER >= 11
+  test_is_member_pointer();
+  test_is_member_pointer();
+  test_is_member_pointer();
+#endif
 }

Modified: 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp?rev=294995&r1=294994&r2=294995&view=diff
==
--- 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/meta/meta.unary/meta.unary.cat/member_function_pointer.pass.cpp
 Mon Feb 13 16:44:39 2017
@@ -52,90 +52,175 @@ struct incomplete_type;
 
 int main()
 {
-test_member_function_pointer();
-test_member_function_pointer();
-test_member_function_pointer();
-
-test_member_function_pointer();
-test_member_function_pointer();
-test_member_function_pointer();
-
-test_member_function_pointer();
-test_member_function_pointer();
-test_member_function_pointer();
-
-test_member_function_pointer();
-test_member_function_pointer();
-test_member_function_pointer();
-
-test_member_function_pointer();
-test_member_function_pointer();
-test_member_function_pointer();
-
-test_member_function_pointer();
-test_member_function_pointer();
-test_member_function_pointer();
+  test_member_function_pointer();
+  test_member_function_pointer();
+  test_member_function_pointer();
+
+  test_member_function_pointer();
+  test_member_function_pointer();
+  test_member_function_pointer();
+
+  test_member_function_pointer();
+  test_member_function_pointer();
+  test_member_function_pointer();
+
+  test_member_function_pointer();
+  test_member_function_pointer();
+  test_member_function_pointer();

[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-02-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Also note that @chandlerc in r290398 made clang adding "noinline" on every 
function at O0 by default, which seems very similar to what I'm doing here.

We're still waiting for @rsmith to comment whether it'd be better to `have a 
LangOpts flag that basically means "pragma clang optimize off is always in 
effect."` and `Have Sema pretend the pragma is in effect at all times, at -O0`.


https://reviews.llvm.org/D28404



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


[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++

2017-02-13 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge reclaimed this revision.
tigerleapgorge added a comment.

@rjmccall - Hi John, I have reopened this patch.


https://reviews.llvm.org/D29739



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


[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++

2017-02-13 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D29739



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


[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++

2017-02-13 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294997: [test] Make Lit tests C++11 Compatible - 
Objective-C++ (authored by lcharles).

Changed prior to commit:
  https://reviews.llvm.org/D29739?vs=87735&id=88267#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29739

Files:
  cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
  cfe/trunk/test/CodeGenObjCXX/encode.mm
  cfe/trunk/test/CodeGenObjCXX/literals.mm
  cfe/trunk/test/SemaObjCXX/arc-system-header.mm
  cfe/trunk/test/SemaObjCXX/ivar-construct.mm


Index: cfe/trunk/test/SemaObjCXX/arc-system-header.mm
===
--- cfe/trunk/test/SemaObjCXX/arc-system-header.mm
+++ cfe/trunk/test/SemaObjCXX/arc-system-header.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-arc -isystem %S/Inputs %s -verify
+// RUN: %clang_cc1 -std=gnu++98 -fobjc-arc -isystem %S/Inputs %s -verify
 
 #include 
 
Index: cfe/trunk/test/SemaObjCXX/ivar-construct.mm
===
--- cfe/trunk/test/SemaObjCXX/ivar-construct.mm
+++ cfe/trunk/test/SemaObjCXX/ivar-construct.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -std=gnu++98 -fsyntax-only -verify -Wno-objc-root-class %s
 struct Y { 
   Y(); 
 
Index: cfe/trunk/test/CodeGenObjCXX/literals.mm
===
--- cfe/trunk/test/CodeGenObjCXX/literals.mm
+++ cfe/trunk/test/CodeGenObjCXX/literals.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm 
-fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions -fobjc-exceptions 
-fcxx-exceptions -fobjc-arc-exceptions -O2 -disable-llvm-passes -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -std=gnu++98 -I %S/Inputs -triple x86_64-apple-darwin10 
-emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions 
-fobjc-exceptions -fcxx-exceptions -fobjc-arc-exceptions -O2 
-disable-llvm-passes -o - %s | FileCheck %s
 
 #include "literal-support.h"
 
Index: cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
===
--- cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
+++ cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm 
-fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm 
-fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 
Index: cfe/trunk/test/CodeGenObjCXX/encode.mm
===
--- cfe/trunk/test/CodeGenObjCXX/encode.mm
+++ cfe/trunk/test/CodeGenObjCXX/encode.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o 
- | FileCheck %s
 
 // CHECK: v17@0:8{vector=}16
 // CHECK: {vector=}


Index: cfe/trunk/test/SemaObjCXX/arc-system-header.mm
===
--- cfe/trunk/test/SemaObjCXX/arc-system-header.mm
+++ cfe/trunk/test/SemaObjCXX/arc-system-header.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-arc -isystem %S/Inputs %s -verify
+// RUN: %clang_cc1 -std=gnu++98 -fobjc-arc -isystem %S/Inputs %s -verify
 
 #include 
 
Index: cfe/trunk/test/SemaObjCXX/ivar-construct.mm
===
--- cfe/trunk/test/SemaObjCXX/ivar-construct.mm
+++ cfe/trunk/test/SemaObjCXX/ivar-construct.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -std=gnu++98 -fsyntax-only -verify -Wno-objc-root-class %s
 struct Y { 
   Y(); 
 
Index: cfe/trunk/test/CodeGenObjCXX/literals.mm
===
--- cfe/trunk/test/CodeGenObjCXX/literals.mm
+++ cfe/trunk/test/CodeGenObjCXX/literals.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-arc-exceptions -O2 -disable-llvm-passes -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=gnu++98 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions -fobjc-exceptions -fcxx-exceptions -fobjc-arc-exceptions -O2 -disable-llvm-passes -o - %s | FileCheck %s
 
 #include "literal-support.h"
 
Index: cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
===
--- cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
+++ cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
+// RUN: %clang_cc

r294997 - [test] Make Lit tests C++11 Compatible - Objective-C++

2017-02-13 Thread Charles Li via cfe-commits
Author: lcharles
Date: Mon Feb 13 17:09:56 2017
New Revision: 294997

URL: http://llvm.org/viewvc/llvm-project?rev=294997&view=rev
Log:
[test] Make Lit tests C++11 Compatible - Objective-C++

Set 5 Objective-C++ tests to run at gnu++98

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

Modified:
cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
cfe/trunk/test/CodeGenObjCXX/encode.mm
cfe/trunk/test/CodeGenObjCXX/literals.mm
cfe/trunk/test/SemaObjCXX/arc-system-header.mm
cfe/trunk/test/SemaObjCXX/ivar-construct.mm

Modified: cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm?rev=294997&r1=294996&r2=294997&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/arc-blocks.mm Mon Feb 13 17:09:56 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm 
-fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=gnu++98 -triple x86_64-apple-darwin10 -emit-llvm 
-fobjc-runtime-has-weak -fblocks -fobjc-arc -o - %s | FileCheck %s
 
 // CHECK: [[A:.*]] = type { i64, [10 x i8*] }
 

Modified: cfe/trunk/test/CodeGenObjCXX/encode.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/encode.mm?rev=294997&r1=294996&r2=294997&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/encode.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/encode.mm Mon Feb 13 17:09:56 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -std=gnu++98 %s -triple=x86_64-apple-darwin10 -emit-llvm -o 
- | FileCheck %s
 
 // CHECK: v17@0:8{vector=}16
 // CHECK: {vector=}

Modified: cfe/trunk/test/CodeGenObjCXX/literals.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/literals.mm?rev=294997&r1=294996&r2=294997&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/literals.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/literals.mm Mon Feb 13 17:09:56 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-darwin10 -emit-llvm 
-fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions -fobjc-exceptions 
-fcxx-exceptions -fobjc-arc-exceptions -O2 -disable-llvm-passes -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -std=gnu++98 -I %S/Inputs -triple x86_64-apple-darwin10 
-emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -fexceptions 
-fobjc-exceptions -fcxx-exceptions -fobjc-arc-exceptions -O2 
-disable-llvm-passes -o - %s | FileCheck %s
 
 #include "literal-support.h"
 

Modified: cfe/trunk/test/SemaObjCXX/arc-system-header.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-system-header.mm?rev=294997&r1=294996&r2=294997&view=diff
==
--- cfe/trunk/test/SemaObjCXX/arc-system-header.mm (original)
+++ cfe/trunk/test/SemaObjCXX/arc-system-header.mm Mon Feb 13 17:09:56 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fobjc-arc -isystem %S/Inputs %s -verify
+// RUN: %clang_cc1 -std=gnu++98 -fobjc-arc -isystem %S/Inputs %s -verify
 
 #include 
 

Modified: cfe/trunk/test/SemaObjCXX/ivar-construct.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/ivar-construct.mm?rev=294997&r1=294996&r2=294997&view=diff
==
--- cfe/trunk/test/SemaObjCXX/ivar-construct.mm (original)
+++ cfe/trunk/test/SemaObjCXX/ivar-construct.mm Mon Feb 13 17:09:56 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+// RUN: %clang_cc1 -std=gnu++98 -fsyntax-only -verify -Wno-objc-root-class %s
 struct Y { 
   Y(); 
 


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


[PATCH] D29915: emit constant expression for new expression array size if it is one

2017-02-13 Thread Nick Lewycky via Phabricator via cfe-commits
nlewycky created this revision.

When the new expr's array size is an ICE, emit it as a constant expression.

This bypasses integer sanitization checks which are redundant on the expression 
since it's been checked by Sema. Fixes a clang codegen assertion on "void 
test() { new int[0+1]{0}; }" when building with 
-fsanitize=signed-integer-overflow.


https://reviews.llvm.org/D29915

Files:
  lib/CodeGen/CGExprCXX.cpp
  test/CodeGenCXX/new-array-init.cpp


Index: test/CodeGenCXX/new-array-init.cpp
===
--- test/CodeGenCXX/new-array-init.cpp
+++ test/CodeGenCXX/new-array-init.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm -o - 
| FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm 
-fsanitize=signed-integer-overflow -o - | FileCheck --check-prefix=SIO %s
 
 // CHECK: @[[ABC4:.*]] = {{.*}} constant [4 x i8] c"abc\00"
 // CHECK: @[[ABC15:.*]] = {{.*}} constant [15 x i8] c"abc\00\00\00\00
@@ -116,3 +117,9 @@
   struct Aggr { int a, b; };
   new Aggr[n] { 1, 2, 3 };
 }
+
+// SIO-LABEL: define void @_Z14constexpr_testv
+void constexpr_test() {
+  // SIO: call i8* @_Zna{{.}}(i32 4)
+  new int[0+1]{0};
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -659,7 +659,10 @@
   // Emit the array size expression.
   // We multiply the size of all dimensions for NumElements.
   // e.g for 'int[2][3]', ElemType is 'int' and NumElements is 6.
-  numElements = CGF.EmitScalarExpr(e->getArraySize());
+  numElements = CGF.CGM.EmitConstantExpr(e->getArraySize(),
+ CGF.getContext().getSizeType(), &CGF);
+  if (!numElements)
+numElements = CGF.EmitScalarExpr(e->getArraySize());
   assert(isa(numElements->getType()));
 
   // The number of elements can be have an arbitrary integer type;


Index: test/CodeGenCXX/new-array-init.cpp
===
--- test/CodeGenCXX/new-array-init.cpp
+++ test/CodeGenCXX/new-array-init.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm -fsanitize=signed-integer-overflow -o - | FileCheck --check-prefix=SIO %s
 
 // CHECK: @[[ABC4:.*]] = {{.*}} constant [4 x i8] c"abc\00"
 // CHECK: @[[ABC15:.*]] = {{.*}} constant [15 x i8] c"abc\00\00\00\00
@@ -116,3 +117,9 @@
   struct Aggr { int a, b; };
   new Aggr[n] { 1, 2, 3 };
 }
+
+// SIO-LABEL: define void @_Z14constexpr_testv
+void constexpr_test() {
+  // SIO: call i8* @_Zna{{.}}(i32 4)
+  new int[0+1]{0};
+}
Index: lib/CodeGen/CGExprCXX.cpp
===
--- lib/CodeGen/CGExprCXX.cpp
+++ lib/CodeGen/CGExprCXX.cpp
@@ -659,7 +659,10 @@
   // Emit the array size expression.
   // We multiply the size of all dimensions for NumElements.
   // e.g for 'int[2][3]', ElemType is 'int' and NumElements is 6.
-  numElements = CGF.EmitScalarExpr(e->getArraySize());
+  numElements = CGF.CGM.EmitConstantExpr(e->getArraySize(),
+ CGF.getContext().getSizeType(), &CGF);
+  if (!numElements)
+numElements = CGF.EmitScalarExpr(e->getArraySize());
   assert(isa(numElements->getType()));
 
   // The number of elements can be have an arbitrary integer type;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r295001 - [CodeCompletion] Code complete the missing C++11 keywords

2017-02-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Feb 13 17:19:40 2017
New Revision: 295001

URL: http://llvm.org/viewvc/llvm-project?rev=295001&view=rev
Log:
[CodeCompletion] Code complete the missing C++11 keywords

This commit adds context sensitive code completion support for the C++11
keywords that currently don't have completion results.

The following keywords are supported by this patch:

alignas
constexpr
static_assert
noexcept (as a function/method qualifier)
thread_local

The following special identifiers are also supported:

final (as a method qualifier or class qualifier)
override

rdar://29219185

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

Added:
cfe/trunk/test/CodeCompletion/keywords.cpp
Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=295001&r1=295000&r2=295001&view=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Feb 13 17:19:40 2017
@@ -2385,10 +2385,10 @@ private:
 AR_DeclspecAttributesParsed
   };
 
-  void ParseTypeQualifierListOpt(DeclSpec &DS,
- unsigned AttrReqs = AR_AllAttributesParsed,
- bool AtomicAllowed = true,
- bool IdentifierRequired = false);
+  void ParseTypeQualifierListOpt(
+  DeclSpec &DS, unsigned AttrReqs = AR_AllAttributesParsed,
+  bool AtomicAllowed = true, bool IdentifierRequired = false,
+  Optional> CodeCompletionHandler = None);
   void ParseDirectDeclarator(Declarator &D);
   void ParseDecompositionDeclarator(Declarator &D);
   void ParseParenDeclarator(Declarator &D);

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=295001&r1=295000&r2=295001&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Feb 13 17:19:40 2017
@@ -9820,6 +9820,8 @@ public:
   void CodeCompletePostfixExpression(Scope *S, ExprResult LHS);
   void CodeCompleteTag(Scope *S, unsigned TagSpec);
   void CodeCompleteTypeQualifiers(DeclSpec &DS);
+  void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D,
+  const VirtSpecifiers *VS = nullptr);
   void CodeCompleteBracketDeclarator(Scope *S);
   void CodeCompleteCase(Scope *S);
   void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef Args);

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=295001&r1=295000&r2=295001&view=diff
==
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Feb 13 17:19:40 2017
@@ -4802,9 +4802,10 @@ bool Parser::isConstructorDeclarator(boo
 ///  [ only if AttReqs & AR_CXX11AttributesParsed ]
 /// Note: vendor can be GNU, MS, etc and can be explicitly controlled via
 /// AttrRequirements bitmask values.
-void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, unsigned AttrReqs,
-   bool AtomicAllowed,
-   bool IdentifierRequired) {
+void Parser::ParseTypeQualifierListOpt(
+DeclSpec &DS, unsigned AttrReqs, bool AtomicAllowed,
+bool IdentifierRequired,
+Optional> CodeCompletionHandler) {
   if (getLangOpts().CPlusPlus11 && (AttrReqs & AR_CXX11AttributesParsed) &&
   isCXX11AttributeSpecifier()) {
 ParsedAttributesWithRange attrs(AttrFactory);
@@ -4822,7 +4823,10 @@ void Parser::ParseTypeQualifierListOpt(D
 
 switch (Tok.getKind()) {
 case tok::code_completion:
-  Actions.CodeCompleteTypeQualifiers(DS);
+  if (CodeCompletionHandler)
+(*CodeCompletionHandler)();
+  else
+Actions.CodeCompleteTypeQualifiers(DS);
   return cutOffParsing();
 
 case tok::kw_const:
@@ -5748,7 +5752,11 @@ void Parser::ParseFunctionDeclarator(Dec
 
   // Parse cv-qualifier-seq[opt].
   ParseTypeQualifierListOpt(DS, AR_NoAttributesParsed,
-/*AtomicAllowed*/ false);
+/*AtomicAllowed*/ false,
+/*IdentifierRequired=*/false,
+llvm::function_ref([&]() {
+  Actions.CodeCompleteFunctionQualifiers(DS, 
D);
+}));
   if (!DS.getSourceRange().getEnd().isInvalid()) {

[PATCH] D28286: [CodeCompletion] Code complete the missing C++11 keywords

2017-02-13 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL295001: [CodeCompletion] Code complete the missing C++11 
keywords (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D28286?vs=83030&id=88271#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D28286

Files:
  cfe/trunk/include/clang/Parse/Parser.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseDecl.cpp
  cfe/trunk/lib/Parse/ParseDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/CodeCompletion/keywords.cpp
  cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp

Index: cfe/trunk/lib/Parse/ParseDecl.cpp
===
--- cfe/trunk/lib/Parse/ParseDecl.cpp
+++ cfe/trunk/lib/Parse/ParseDecl.cpp
@@ -4802,9 +4802,10 @@
 ///  [ only if AttReqs & AR_CXX11AttributesParsed ]
 /// Note: vendor can be GNU, MS, etc and can be explicitly controlled via
 /// AttrRequirements bitmask values.
-void Parser::ParseTypeQualifierListOpt(DeclSpec &DS, unsigned AttrReqs,
-   bool AtomicAllowed,
-   bool IdentifierRequired) {
+void Parser::ParseTypeQualifierListOpt(
+DeclSpec &DS, unsigned AttrReqs, bool AtomicAllowed,
+bool IdentifierRequired,
+Optional> CodeCompletionHandler) {
   if (getLangOpts().CPlusPlus11 && (AttrReqs & AR_CXX11AttributesParsed) &&
   isCXX11AttributeSpecifier()) {
 ParsedAttributesWithRange attrs(AttrFactory);
@@ -4822,7 +4823,10 @@
 
 switch (Tok.getKind()) {
 case tok::code_completion:
-  Actions.CodeCompleteTypeQualifiers(DS);
+  if (CodeCompletionHandler)
+(*CodeCompletionHandler)();
+  else
+Actions.CodeCompleteTypeQualifiers(DS);
   return cutOffParsing();
 
 case tok::kw_const:
@@ -5748,7 +5752,11 @@
 
   // Parse cv-qualifier-seq[opt].
   ParseTypeQualifierListOpt(DS, AR_NoAttributesParsed,
-/*AtomicAllowed*/ false);
+/*AtomicAllowed*/ false,
+/*IdentifierRequired=*/false,
+llvm::function_ref([&]() {
+  Actions.CodeCompleteFunctionQualifiers(DS, D);
+}));
   if (!DS.getSourceRange().getEnd().isInvalid()) {
 EndLoc = DS.getSourceRange().getEnd();
 ConstQualifierLoc = DS.getConstSpecLoc();
Index: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -2285,7 +2285,11 @@
 
   // GNU-style and C++11 attributes are not allowed here, but they will be
   // handled by the caller.  Diagnose everything else.
-  ParseTypeQualifierListOpt(DS, AR_NoAttributesParsed, false);
+  ParseTypeQualifierListOpt(
+  DS, AR_NoAttributesParsed, false,
+  /*IdentifierRequired=*/false, llvm::function_ref([&]() {
+Actions.CodeCompleteFunctionQualifiers(DS, D, &VS);
+  }));
   D.ExtendWithDeclSpec(DS);
 
   if (D.isFunctionDeclarator()) {
Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -1370,6 +1370,21 @@
   // in C++0x as a type specifier.
   Results.AddResult(Result("extern"));
   Results.AddResult(Result("static"));
+
+  if (LangOpts.CPlusPlus11) {
+CodeCompletionAllocator &Allocator = Results.getAllocator();
+CodeCompletionBuilder Builder(Allocator, Results.getCodeCompletionTUInfo());
+
+// alignas
+Builder.AddTypedTextChunk("alignas");
+Builder.AddChunk(CodeCompletionString::CK_LeftParen);
+Builder.AddPlaceholderChunk("expression");
+Builder.AddChunk(CodeCompletionString::CK_RightParen);
+Results.AddResult(Result(Builder.TakeString()));
+
+Results.AddResult(Result("constexpr"));
+Results.AddResult(Result("thread_local"));
+  }
 }
 
 static void AddFunctionSpecifiers(Sema::ParserCompletionContext CCC,
@@ -1527,6 +1542,21 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
+static void AddStaticAssertResult(CodeCompletionBuilder &Builder,
+  ResultBuilder &Results,
+  const LangOptions &LangOpts) {
+  if (!LangOpts.CPlusPlus11)
+return;
+
+  Builder.AddTypedTextChunk("static_assert");
+  Builder.AddChunk(CodeCompletionString::CK_LeftParen);
+  Builder.AddPlaceholderChunk("expression");
+  Builder.AddChunk(CodeCompletionString::CK_Comma);
+  Builder.AddPlaceholderChunk("message");
+  Builder.AddChunk(CodeCompletionString::CK_RightParen);
+  Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+}
+
 /// \brief Add language constructs that show up for "ordinary" names.
 static void AddOrdinaryNameResults(Sema:

[PATCH] D29868: Recover more gracefully when __declspec is not supported as a keyword

2017-02-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added inline comments.



Comment at: lib/Parse/ParseDecl.cpp:2989
+
+  Diag(Loc, diag::err_ms_attributes_not_enabled);
+  continue;

majnemer wrote:
> aaron.ballman wrote:
> > compnerd wrote:
> > > aaron.ballman wrote:
> > > > compnerd wrote:
> > > > > I think that we want to emit the diagnostic even if there is no 
> > > > > parenthesis as `__declspec` is a reserved identifier, and we would 
> > > > > normally diagnose the bad `__declspec` (expected '(' after 
> > > > > '__declspec').
> > > > Yes, but it could also lead to a rejecting code that we used to accept 
> > > > and properly handle when __declspec is an identifier rather than a 
> > > > keyword. e.g.,
> > > > ```
> > > > struct __declspec {};
> > > > 
> > > > __declspec some_func(void);
> > > > ```
> > > > By looking for the paren, we run less risk of breaking working code, 
> > > > even if that code abuses the implementation namespace (after all, 
> > > > __declspec it not a keyword in this scenario).
> > > But we would reject that code under `-fdeclspec` anyways.  I think having 
> > > the code be more portable is a bit nicer.
> > After discussing in IRC, I decided that I agree with @compnerd on this and 
> > have changed the patch accordingly.
> What if somebody wants to use __declspec and are using the compiler in a 
> freestanding mode? Also, we aren't the only member of the implementor's 
> namespace.
Users using __declspec in a freestanding mode is a concern that I share. 
However, I imagine there are *far* more users who accidentally forget to pass 
`-fdeclspec` than there are users who are writing code in freestanding mode 
that wish to use `__declspec` as an identifier in a situation that proves 
problematic. That being said, do you think the approach in the patch would work 
with a warning rather than an error? I went with an error because I felt that a 
warning would require tentative parsing to be properly implemented, which felt 
like a heavy solution for a problem I didn't think anyone would run into in 
practice.

I'm not overly sympathetic to others in the implementor's namespace who use 
`__declspec` but not to implement attributes under that name. However, I could 
be convinced to be sympathetic if there was some conflict in practice. Do you 
have a case in mind?


https://reviews.llvm.org/D29868



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


r295003 - [CodeCompletion] Code complete the '__auto_type' keyword

2017-02-13 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Mon Feb 13 17:35:59 2017
New Revision: 295003

URL: http://llvm.org/viewvc/llvm-project?rev=295003&view=rev
Log:
[CodeCompletion] Code complete the '__auto_type' keyword

rdar://29219185

Added:
cfe/trunk/test/CodeCompletion/auto_type.c
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=295003&r1=295002&r2=295003&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon Feb 13 17:35:59 2017
@@ -1334,8 +1334,9 @@ static void AddTypeSpecifierResults(cons
   Builder.AddChunk(CodeCompletionString::CK_RightParen);
   Results.AddResult(Result(Builder.TakeString()));
 }
-  }
-  
+  } else
+Results.AddResult(Result("__auto_type", CCP_Type));
+
   // GNU extensions
   if (LangOpts.GNUMode) {
 // FIXME: Enable when we actually support decimal floating point.

Added: cfe/trunk/test/CodeCompletion/auto_type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/auto_type.c?rev=295003&view=auto
==
--- cfe/trunk/test/CodeCompletion/auto_type.c (added)
+++ cfe/trunk/test/CodeCompletion/auto_type.c Mon Feb 13 17:35:59 2017
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -code-completion-at=%s:3:1 %s | FileCheck %s
+void func() {
+
+}
+// CHECK: COMPLETION: __auto_type


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


[PATCH] D29863: [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.

2017-02-13 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: include/string:782
 _LIBCPP_INLINE_VISIBILITY
 basic_string(const value_type* __s, size_type __n);
 _LIBCPP_INLINE_VISIBILITY

rsmith wrote:
> EricWF wrote:
> > rsmith wrote:
> > > Did you skip this one intentionally?
> > Yes. `size_type`  is a typedef for 
> > `allocator_traits::size_type`, This causes the 
> > `basic_string(CharT*, Allocator const&)` to always be chosen instead, 
> > resulting in a incorrect allocator type.
> I don't think it will always be chosen instead; if the argument is of type 
> `size_t`, the `(const CharT*, size_type)` overload should be chosen.
OK, so it's not that it should always be taken. Instead I think any attempt to 
form the implicit deduction guide overloads for such a call will end up 
attempting to evaluate `std::basic_string, unsigned 
long long>` which is an ill-formed instantiation of `basic_string`.


So if building the overload set were to succeed then yes, the `(const CharT*, 
size_type)` would be callable with an argument of `size_type`. However it seems 
that the overload set is poisoned by `(const CharT*, Allocator)`





https://reviews.llvm.org/D29863



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


[PATCH] D29912: [MS ABI] Correctly mangling vbase destructors

2017-02-13 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!


https://reviews.llvm.org/D29912



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


r295006 - When the new expr's array size is an ICE, emit it as a constant expression.

2017-02-13 Thread Nick Lewycky via cfe-commits
Author: nicholas
Date: Mon Feb 13 17:49:55 2017
New Revision: 295006

URL: http://llvm.org/viewvc/llvm-project?rev=295006&view=rev
Log:
When the new expr's array size is an ICE, emit it as a constant expression.

This bypasses integer sanitization checks which are redundant on the expression 
since it's been checked by Sema. Fixes a clang codegen assertion on "void 
test() { new int[0+1]{0}; }" when building with 
-fsanitize=signed-integer-overflow.

Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/test/CodeGenCXX/new-array-init.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=295006&r1=295005&r2=295006&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Mon Feb 13 17:49:55 2017
@@ -659,7 +659,10 @@ static llvm::Value *EmitCXXNewAllocSize(
   // Emit the array size expression.
   // We multiply the size of all dimensions for NumElements.
   // e.g for 'int[2][3]', ElemType is 'int' and NumElements is 6.
-  numElements = CGF.EmitScalarExpr(e->getArraySize());
+  numElements = CGF.CGM.EmitConstantExpr(e->getArraySize(),
+ CGF.getContext().getSizeType(), &CGF);
+  if (!numElements)
+numElements = CGF.EmitScalarExpr(e->getArraySize());
   assert(isa(numElements->getType()));
 
   // The number of elements can be have an arbitrary integer type;

Modified: cfe/trunk/test/CodeGenCXX/new-array-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/new-array-init.cpp?rev=295006&r1=295005&r2=295006&view=diff
==
--- cfe/trunk/test/CodeGenCXX/new-array-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/new-array-init.cpp Mon Feb 13 17:49:55 2017
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm -o - 
| FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -triple i386-unknown-unknown %s -emit-llvm 
-fsanitize=signed-integer-overflow -o - | FileCheck --check-prefix=SIO %s
 
 // CHECK: @[[ABC4:.*]] = {{.*}} constant [4 x i8] c"abc\00"
 // CHECK: @[[ABC15:.*]] = {{.*}} constant [15 x i8] c"abc\00\00\00\00
@@ -116,3 +117,9 @@ void aggr_sufficient(int n) {
   struct Aggr { int a, b; };
   new Aggr[n] { 1, 2, 3 };
 }
+
+// SIO-LABEL: define void @_Z14constexpr_testv
+void constexpr_test() {
+  // SIO: call i8* @_Zna{{.}}(i32 4)
+  new int[0+1]{0};
+}


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


[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-02-13 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

Just to be explicit, I agree with Hal's summary. This seems like the right 
engineering tradeoff and I don't find anything particularly unsatisfying about 
it.

In https://reviews.llvm.org/D28404#675616, @mehdi_amini wrote:

> Also note that @chandlerc in r290398 made clang adding "noinline" on every 
> function at O0 by default, which seems very similar to what I'm doing here.
>
> We're still waiting for @rsmith to comment whether it'd be better to `have a 
> LangOpts flag that basically means "pragma clang optimize off is always in 
> effect."` and `Have Sema pretend the pragma is in effect at all times, at 
> -O0`.


FWIW, I have no real opinion about this side of it, I see it more as a detail 
of how Clang wants to implement this kind of thing.


https://reviews.llvm.org/D28404



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


[PATCH] D29868: Recover more gracefully when __declspec is not supported as a keyword

2017-02-13 Thread David Majnemer via Phabricator via cfe-commits
majnemer added inline comments.



Comment at: lib/Parse/ParseDecl.cpp:2989
+
+  Diag(Loc, diag::err_ms_attributes_not_enabled);
+  continue;

aaron.ballman wrote:
> majnemer wrote:
> > aaron.ballman wrote:
> > > compnerd wrote:
> > > > aaron.ballman wrote:
> > > > > compnerd wrote:
> > > > > > I think that we want to emit the diagnostic even if there is no 
> > > > > > parenthesis as `__declspec` is a reserved identifier, and we would 
> > > > > > normally diagnose the bad `__declspec` (expected '(' after 
> > > > > > '__declspec').
> > > > > Yes, but it could also lead to a rejecting code that we used to 
> > > > > accept and properly handle when __declspec is an identifier rather 
> > > > > than a keyword. e.g.,
> > > > > ```
> > > > > struct __declspec {};
> > > > > 
> > > > > __declspec some_func(void);
> > > > > ```
> > > > > By looking for the paren, we run less risk of breaking working code, 
> > > > > even if that code abuses the implementation namespace (after all, 
> > > > > __declspec it not a keyword in this scenario).
> > > > But we would reject that code under `-fdeclspec` anyways.  I think 
> > > > having the code be more portable is a bit nicer.
> > > After discussing in IRC, I decided that I agree with @compnerd on this 
> > > and have changed the patch accordingly.
> > What if somebody wants to use __declspec and are using the compiler in a 
> > freestanding mode? Also, we aren't the only member of the implementor's 
> > namespace.
> Users using __declspec in a freestanding mode is a concern that I share. 
> However, I imagine there are *far* more users who accidentally forget to pass 
> `-fdeclspec` than there are users who are writing code in freestanding mode 
> that wish to use `__declspec` as an identifier in a situation that proves 
> problematic. That being said, do you think the approach in the patch would 
> work with a warning rather than an error? I went with an error because I felt 
> that a warning would require tentative parsing to be properly implemented, 
> which felt like a heavy solution for a problem I didn't think anyone would 
> run into in practice.
> 
> I'm not overly sympathetic to others in the implementor's namespace who use 
> `__declspec` but not to implement attributes under that name. However, I 
> could be convinced to be sympathetic if there was some conflict in practice. 
> Do you have a case in mind?
I suppose what you've got should be fine in practice. Heck, we used to have 
__declspec attributes available all the time...


https://reviews.llvm.org/D29868



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


r295007 - [c++1z] Synthesize implicit deduction guides from constructors on demand. Rank

2017-02-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Feb 13 18:25:28 2017
New Revision: 295007

URL: http://llvm.org/viewvc/llvm-project?rev=295007&view=rev
Log:
[c++1z] Synthesize implicit deduction guides from constructors on demand. Rank
such guides below explicit ones, and ensure that references to the class's
template parameters are not treated as forwarding references.

We make a few tweaks to the wording in the current standard:
1) The constructor parameter list is copied faithfully to the deduction guide,
   without losing default arguments or a varargs ellipsis (which the standard
   wording loses by omission).
2) If the class template declares no constructors, we add a T() -> T<...> guide
   (which will only ever work if T has default arguments for all non-pack
   template parameters).
3) If the class template declares nothing that looks like a copy or move
   constructor, we add a T(T<...>) -> T<...> guide.
#2 and #3 follow from the "pretend we had a class type with these constructors"
philosophy for deduction guides.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CXX/expr/expr.post/expr.type.conv/p1.cpp

cfe/trunk/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p3.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp
cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=295007&r1=295006&r2=295007&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 13 18:25:28 2017
@@ -1357,6 +1357,8 @@ public:
   ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS,
   const IdentifierInfo *Name, ArrayRef Args) const;
 
+  TemplateArgument getInjectedTemplateArg(NamedDecl *ParamDecl);
+
   /// Get a template argument list with one argument per template parameter
   /// in a template parameter list, such as for the injected class name of
   /// a class template.

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=295007&r1=295006&r2=295007&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Mon Feb 13 18:25:28 2017
@@ -1482,6 +1482,7 @@ public:
   
   using TemplateParmPosition::getDepth;
   using TemplateParmPosition::getPosition;
+  using TemplateParmPosition::setPosition;
   using TemplateParmPosition::getIndex;
 
   /// \brief Whether this template template parameter is a template

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=295007&r1=295006&r2=295007&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Feb 13 18:25:28 2017
@@ -6759,6 +6759,11 @@ public:
   bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc,
 bool Diagnose = true);
 
+  /// \brief Declare implicit deduction guides for a class template if we've
+  /// not already done so.
+  void DeclareImplicitDeductionGuides(TemplateDecl *Template,
+  SourceLocation Loc);
+
   QualType DeduceTemplateSpecializationFromInitializer(
   TypeSourceInfo *TInfo, const InitializedEntity &Entity,
   const InitializationKind &Kind, MultiExprArg Init);

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=295007&r1=295006&r2=295007&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 13 18:25:28 2017
@@ -3872,42 +3872,45 @@ ASTContext::getDependentTemplateSpeciali
   return QualType(T, 0);
 }
 
+TemplateArgument ASTContext::getInjectedTemplateArg(NamedDecl *Param) {
+  TemplateArgument Arg;
+  if (auto *TTP = dyn_cast(Param)) {
+QualType ArgType = getTypeDeclType(TTP);
+if (TTP->isParameterPack())
+  ArgType = getPackExpansionType(ArgType, None);
+
+Arg = TemplateArgument(ArgType);
+  } else if (auto *NTTP = dyn_cast(Param)) {
+Expr *E = new (*this) DeclRefExpr(
+NTTP, /*enclosing*/false,
+NT

  1   2   >