[clang-tools-extra] r325868 - [clangd] BindWithForward -> Bind. NFC

2018-02-23 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Feb 22 23:54:17 2018
New Revision: 325868

URL: http://llvm.org/viewvc/llvm-project?rev=325868&view=rev
Log:
[clangd] BindWithForward -> Bind. NFC

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/Function.h
clang-tools-extra/trunk/clangd/TUScheduler.cpp
clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=325868&r1=325867&r2=325868&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Thu Feb 22 23:54:17 2018
@@ -181,10 +181,9 @@ void ClangdServer::codeComplete(
 Callback(make_tagged(std::move(Result), std::move(TaggedFS.Tag)));
   };
 
-  WorkScheduler.runWithPreamble("CodeComplete", File,
-BindWithForward(Task, std::move(Contents),
-File.str(),
-std::move(Callback)));
+  WorkScheduler.runWithPreamble(
+  "CodeComplete", File,
+  Bind(Task, std::move(Contents), File.str(), std::move(Callback)));
 }
 
 void ClangdServer::signatureHelp(
@@ -224,9 +223,8 @@ void ClangdServer::signatureHelp(
 TaggedFS.Tag));
   };
 
-  WorkScheduler.runWithPreamble(
-  "SignatureHelp", File,
-  BindWithForward(Action, File.str(), std::move(Callback)));
+  WorkScheduler.runWithPreamble("SignatureHelp", File,
+Bind(Action, File.str(), std::move(Callback)));
 }
 
 llvm::Expected
@@ -312,7 +310,7 @@ void ClangdServer::rename(
 
   WorkScheduler.runWithAST(
   "Rename", File,
-  BindWithForward(Action, File.str(), NewName.str(), std::move(Callback)));
+  Bind(Action, File.str(), NewName.str(), std::move(Callback)));
 }
 
 Expected
@@ -378,8 +376,7 @@ void ClangdServer::dumpAST(PathRef File,
 Callback(Result);
   };
 
-  WorkScheduler.runWithAST("DumpAST", File,
-   BindWithForward(Action, std::move(Callback)));
+  WorkScheduler.runWithAST("DumpAST", File, Bind(Action, std::move(Callback)));
 }
 
 void ClangdServer::findDefinitions(
@@ -396,7 +393,7 @@ void ClangdServer::findDefinitions(
   };
 
   WorkScheduler.runWithAST("Definitions", File,
-   BindWithForward(Action, std::move(Callback)));
+   Bind(Action, std::move(Callback)));
 }
 
 llvm::Optional ClangdServer::switchSourceHeader(PathRef Path) {
@@ -493,7 +490,7 @@ void ClangdServer::findDocumentHighlight
   };
 
   WorkScheduler.runWithAST("Highlights", File,
-   BindWithForward(Action, std::move(Callback)));
+   Bind(Action, std::move(Callback)));
 }
 
 void ClangdServer::findHover(
@@ -516,8 +513,7 @@ void ClangdServer::findHover(
 Callback(make_tagged(std::move(Result), TaggedFS.Tag));
   };
 
-  WorkScheduler.runWithAST("Hover", File,
-   BindWithForward(Action, std::move(Callback)));
+  WorkScheduler.runWithAST("Hover", File, Bind(Action, std::move(Callback)));
 }
 
 void ClangdServer::scheduleReparseAndDiags(

Modified: clang-tools-extra/trunk/clangd/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Function.h?rev=325868&r1=325867&r2=325868&view=diff
==
--- clang-tools-extra/trunk/clangd/Function.h (original)
+++ clang-tools-extra/trunk/clangd/Function.h Thu Feb 22 23:54:17 2018
@@ -117,7 +117,7 @@ public:
  std::forward(Rest)...)) {
 
 #ifndef NDEBUG
-assert(!WasCalled && "Can only call result of BindWithForward once.");
+assert(!WasCalled && "Can only call result of Bind once.");
 WasCalled = true;
 #endif
 return CallImpl(llvm::index_sequence_for(),
@@ -132,7 +132,7 @@ public:
 /// The returned object must be called no more than once, as \p As are
 /// std::forwarded'ed (therefore can be moved) into \p F during the call.
 template 
-ForwardBinder BindWithForward(Func F, Args &&... As) {
+ForwardBinder Bind(Func F, Args &&... As) {
   return ForwardBinder(
   std::make_tuple(std::forward(F), std::forward(As)...));
 }

Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=325868&r1=325867&r2=325868&view=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Thu Feb 22 23:54:17 2018
@@ -218,7 +218,7 @@ void ASTWorker::update(
   OnUpdated(std::move(*Diags));
   };
 
-  startTask("Update", BindWithForward(Task, std::move(OnUpdated)), WantDiags);
+ 

[PATCH] D40731: Integrate CHash into CLang

2018-02-23 Thread Christian Dietrich via Phabricator via cfe-commits
stettberger updated this revision to Diff 135598.
stettberger added a comment.

[CHash] Stable TU-level AST Hashing for local and global hashes

This patch does integrate the AST hashing parts of the CHash project[1][2] into
CLang. The extension provided by this patch accomplishes 2 things:

- local hashes: It extends StmtDataCollector infrastructure by hash rules for 
declarations, types, and attributes. These rules are expressed in terms of 
TableGen files and capture what parts of a AST node are important to its 
semantic. Thereby, the rules only include information that is local to the 
respecting node (no pointers to other AST nodes should be followed).

  Since these DataCollectors do not impose rules how the AST nodes relate to 
each other, they provide a mechanism for "local" hashes.

- global hashes: The CHashVisitor combines the local hashes via the 
RecursiveAST Visitor into a global semantic hash that includes (for a given AST 
node) all local hashes of all AST nodes that can influence the compilation of 
this AST node.

  With these global hashes, we can deduce (early) in the compilation process 
wether the result of this compiler run will produce the same object file. This 
mechanism is *NOT* part of this commit.

[1] https://www.sra.uni-hannover.de/Research/cHash/
[2] "cHash: Detection of Redunandt Recompilations via AST hashing", USENIX 2017


Repository:
  rC Clang

https://reviews.llvm.org/D40731

Files:
  include/clang/AST/AttrDataCollectors.td
  include/clang/AST/CHashVisitor.h
  include/clang/AST/CMakeLists.txt
  include/clang/AST/DataCollection.h
  include/clang/AST/DeclDataCollectors.td
  include/clang/AST/StmtDataCollectors.td
  include/clang/AST/TypeDataCollectors.td
  unittests/AST/CHashTest.cpp
  unittests/AST/CMakeLists.txt

Index: unittests/AST/CMakeLists.txt
===
--- unittests/AST/CMakeLists.txt
+++ unittests/AST/CMakeLists.txt
@@ -17,6 +17,7 @@
   NamedDeclPrinterTest.cpp
   SourceLocationTest.cpp
   StmtPrinterTest.cpp
+  CHashTest.cpp
   )
 
 target_link_libraries(ASTTests
Index: unittests/AST/CHashTest.cpp
===
--- /dev/null
+++ unittests/AST/CHashTest.cpp
@@ -0,0 +1,91 @@
+//===- unittests/AST/DataCollectionTest.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains tests for the DataCollection module.
+//
+// They work by hashing the collected data of two nodes and asserting that the
+// hash values are equal iff the nodes are considered equal.
+//
+//===--===//
+
+#include "clang/AST/CHashVisitor.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace clang;
+using namespace tooling;
+
+
+class CHashConsumer : public ASTConsumer {
+CompilerInstance &CI;
+llvm::MD5::MD5Result *ASTHash;
+
+public:
+
+CHashConsumer(CompilerInstance &CI, llvm::MD5::MD5Result *ASTHash)
+: CI(CI), ASTHash(ASTHash){}
+
+virtual void HandleTranslationUnit(clang::ASTContext &Context) override {
+TranslationUnitDecl *TU = Context.getTranslationUnitDecl();
+
+// Traversing the translation unit decl via a RecursiveASTVisitor
+// will visit all nodes in the AST.
+CHashVisitor<> Visitor(Context);
+Visitor.TraverseDecl(TU);
+// Copy Away the resulting hash
+*ASTHash = *Visitor.getHash(TU);
+
+}
+
+~CHashConsumer() override {}
+};
+
+struct CHashAction : public ASTFrontendAction {
+llvm::MD5::MD5Result *Hash;
+
+CHashAction(llvm::MD5::MD5Result *Hash) : Hash(Hash) {}
+
+std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
+   StringRef) override {
+return std::unique_ptr(new CHashConsumer(CI, Hash));
+}
+};
+
+static testing::AssertionResult
+isASTHashEqual(StringRef Code1, StringRef Code2) {
+llvm::MD5::MD5Result Hash1, Hash2;
+if (!runToolOnCode(new CHashAction(&Hash1), Code1)) {
+return testing::AssertionFailure()
+<< "Parsing error in (A)\"" << Code1.str() << "\"";
+}
+if (!runToolOnCode(new CHashAction(&Hash2), Code2)) {
+return testing::AssertionFailure()
+<< "Parsing error in (B) \"" << Code2.str() << "\"";
+}
+return testing::AssertionResult(Hash1 == Hash2);
+}
+
+TEST(CHashVisitor, TestRecordTypes) {
+ASSERT_TRUE(isASTHashEqual( // Unused struct
+ "struct foobar { int a0; char a1; unsigned long a2; };",
+ "struct foobar { int a0; char a1;};"
+ ));
+
+}
+
+TEST(CHashVisitor, TestSourceStructure) {
+ASS

[PATCH] D43671: [clangd] Address FIXME and fix comment

2018-02-23 Thread Kirill Bobyrev via Phabricator via cfe-commits
omtcyfz created this revision.
omtcyfz added a reviewer: ioeric.
omtcyfz added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, jkorous-apple, ilya-biryukov.

- Address a FIXME by warning the user that both -run-synchronously and -j X are 
passed.
- Fix a comment to suppress clang-tidy warning by passing the correct argument 
name.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43671

Files:
  clangd/Context.cpp
  clangd/tool/ClangdMain.cpp


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -149,10 +149,14 @@
 return 1;
   }
 
-  // Ignore -j option if -run-synchonously is used.
-  // FIXME: a warning should be shown here.
-  if (RunSynchronously)
+  if (RunSynchronously) {
+if (WorkerThreadsCount != 0) {
+  llvm::errs()
+  << "-run-synchronously was used with a number of worker "
+ "threads greater than zero. Clangd will run synchronously.";
+}
 WorkerThreadsCount = 0;
+  }
 
   // Validate command line arguments.
   llvm::Optional InputMirrorStream;
Index: clangd/Context.cpp
===
--- clangd/Context.cpp
+++ clangd/Context.cpp
@@ -13,7 +13,7 @@
 namespace clang {
 namespace clangd {
 
-Context Context::empty() { return Context(/*Data=*/nullptr); }
+Context Context::empty() { return Context(/*DataPtr=*/nullptr); }
 
 Context::Context(std::shared_ptr DataPtr)
 : DataPtr(std::move(DataPtr)) {}


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -149,10 +149,14 @@
 return 1;
   }
 
-  // Ignore -j option if -run-synchonously is used.
-  // FIXME: a warning should be shown here.
-  if (RunSynchronously)
+  if (RunSynchronously) {
+if (WorkerThreadsCount != 0) {
+  llvm::errs()
+  << "-run-synchronously was used with a number of worker "
+ "threads greater than zero. Clangd will run synchronously.";
+}
 WorkerThreadsCount = 0;
+  }
 
   // Validate command line arguments.
   llvm::Optional InputMirrorStream;
Index: clangd/Context.cpp
===
--- clangd/Context.cpp
+++ clangd/Context.cpp
@@ -13,7 +13,7 @@
 namespace clang {
 namespace clangd {
 
-Context Context::empty() { return Context(/*Data=*/nullptr); }
+Context Context::empty() { return Context(/*DataPtr=*/nullptr); }
 
 Context::Context(std::shared_ptr DataPtr)
 : DataPtr(std::move(DataPtr)) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43671: [clangd] Address FIXME and fix comment

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

Thanks for the cleanup Kirill :)




Comment at: clangd/tool/ClangdMain.cpp:153
+  if (RunSynchronously) {
+if (WorkerThreadsCount != 0) {
+  llvm::errs()

`-j` is non-zero by default, and we shouldn't show warning if users only 
specify `-run-synchronously`. We should only warn if user explicitly set worker 
count while also providing `-run-synchronously`. 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43671



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


[PATCH] D43648: [clangd] Debounce streams of updates.

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



Comment at: clangd/TUScheduler.cpp:140
+  // Time to wait after an update to see whether another update obsoletes it.
+  steady_clock::duration UpdateDebounce;
 };

Maybe make it `const` and put beside `RunSync`? Both are scheduling options, so 
it probably makes sense to group them together.



Comment at: clangd/TUScheduler.cpp:324
+if (*Deadline)
+  RequestsCV.wait_until(Lock, **Deadline);
+else

It looks like if we unwrap `Optional` to `Deadline`, we could replace 
this code with `wait` helper from `Threading.h`.
The tracing code (e.g. `if (!Requests.empty) { /*...*/}`) could be changed to 
log only when `*Deadline - steady_clock::now()` is positive.
Will probably make the code simpler. WDYT?



Comment at: clangd/TUScheduler.cpp:358
+  for (const auto &R : Requests)
+if (R.UpdateType == None || R.UpdateType == WantDiagnostics::Yes)
+  return None;

NIT: I tend to find multi-level nested statements easier to read with braces, 
e.g. 
```
for (const auto &R : Requests) {
  if (Cond)
return None
}
```
But this is up to you.



Comment at: clangd/TUScheduler.h:55
+  ASTParsedCallback ASTCallback,
+  std::chrono::steady_clock::duration UpdateDebounce =
+  std::chrono::milliseconds(500));

As discussed offline, we want to expose the debounce parameter in 
`ClangdServer`, as there are existing clients of the code that already send 
updates with low frequency and it would be wasteful for them to do any extra 
waits.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43648



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


[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

2018-02-23 Thread Christian Bruel via Phabricator via cfe-commits
chrib updated this revision to Diff 135603.
chrib added a comment.
Herald added a subscriber: mehdi_amini.

hello, realizing  that this has been stuck for a while now. did I answer all 
the concerns ? rebased patch,

gentle ping :-)

many thanks,

Christian


https://reviews.llvm.org/D31140

Files:
  lib/CodeGen/AsmPrinter/ARMException.cpp
  lib/Target/ARM/ARMAsmPrinter.cpp
  test/CodeGen/ARM/PR35379.ll
  test/CodeGen/ARM/atomic-cmpxchg.ll
  test/CodeGen/ARM/big-endian-eh-unwind.ll
  test/CodeGen/ARM/constantpool-promote-duplicate.ll
  test/CodeGen/ARM/constantpool-promote.ll
  test/CodeGen/ARM/disable-fp-elim.ll
  test/CodeGen/ARM/ehabi-handlerdata-nounwind.ll
  test/CodeGen/ARM/ehabi-handlerdata.ll
  test/CodeGen/ARM/ehabi-no-landingpad.ll
  test/CodeGen/ARM/ehabi.ll
  test/CodeGen/ARM/execute-only.ll
  test/CodeGen/ARM/float-helpers.s
  test/CodeGen/ARM/fp16-promote.ll
  test/CodeGen/ARM/illegal-bitfield-loadstore.ll
  test/CodeGen/ARM/select_const.ll
  test/CodeGen/ARM/setcc-logic.ll
  test/CodeGen/ARM/vcvt.ll
  test/CodeGen/ARM/vuzp.ll
  test/CodeGen/Thumb/copy_thumb.ll
  test/CodeGen/Thumb/mvn.ll
  test/CodeGen/Thumb/stm-scavenging.ll
  test/LTO/ARM/link-arm-and-thumb.ll
  test/MC/ARM/data-in-code.ll

Index: test/MC/ARM/data-in-code.ll
===
--- test/MC/ARM/data-in-code.ll
+++ test/MC/ARM/data-in-code.ll
@@ -9,7 +9,7 @@
 ;; Ensure that if a jump table is generated that it has Mapping Symbols
 ;; marking the data-in-code region.
 
-define void @foo(i32* %ptr, i32 %b) nounwind uwtable ssp {
+define void @foo(i32* %ptr, i32 %b) nounwind ssp {
   %tmp = load i32, i32* %ptr, align 4
   switch i32 %tmp, label %exit [
 i32 0, label %bb0
Index: test/LTO/ARM/link-arm-and-thumb.ll
===
--- test/LTO/ARM/link-arm-and-thumb.ll
+++ test/LTO/ARM/link-arm-and-thumb.ll
@@ -14,6 +14,7 @@
 
 ; CHECK: .code  32
 ; CHECK-NEXT: main
+; CHECK-NEXT: .fnstart
 ; CHECK-NEXT: mov r0, #30
 
 ; CHECK: .code  16
Index: test/CodeGen/Thumb/stm-scavenging.ll
===
--- test/CodeGen/Thumb/stm-scavenging.ll
+++ test/CodeGen/Thumb/stm-scavenging.ll
@@ -3,6 +3,8 @@
 
 ; Use STM to save the three registers
 ; CHECK-LABEL: use_stm:
+; CHECK: .save   {r7, lr}
+; CHECK: .setfp  r7, sp
 ; CHECK: stm r3!, {r0, r1, r2}
 ; CHECK: bl throws_1
 define void @use_stm(i32 %a, i32 %b, i32 %c, i32* %d) local_unnamed_addr noreturn "no-frame-pointer-elim"="true" {
@@ -21,6 +23,8 @@
 ; the address. We could transform this with some extra math, but
 ; that currently isn't implemented.
 ; CHECK-LABEL: no_stm:
+; CHECK: .save   {r7, lr}
+; CHECK: .setfp  r7, sp
 ; CHECK: str r0,
 ; CHECK: str r1,
 ; CHECK: str r2,
Index: test/CodeGen/Thumb/mvn.ll
===
--- test/CodeGen/Thumb/mvn.ll
+++ test/CodeGen/Thumb/mvn.ll
@@ -61,6 +61,7 @@
 
 define void @loop8_2(i8* %a, i8* %b) {
 ; CHECK-LABEL: loop8_2:
+; CHECK: .save {r4, lr}
 ; CHECK-NEXT:push {r4, lr}
 ; CHECK-NEXT:movs r2, #0
 ; CHECK-NEXT:  .LBB3_1:
@@ -155,6 +156,7 @@
 
 define void @loop32_2(i32* %a, i32* %b) {
 ; CHECK-LABEL: loop32_2:
+; CHECK: .save {r4, lr}
 ; CHECK-NEXT:push {r4, lr}
 ; CHECK-NEXT:movs r2, #0
 ; CHECK-NEXT:  .LBB7_1:
Index: test/CodeGen/Thumb/copy_thumb.ll
===
--- test/CodeGen/Thumb/copy_thumb.ll
+++ test/CodeGen/Thumb/copy_thumb.ll
@@ -10,6 +10,7 @@
 ; CHECK-LOLOMOV-NEXT:   mov [[SRC1]], [[SRC2:r[01]]]
 ; CHECK-LOLOMOV-NEXT:   mov [[SRC2]], [[TMP]]
 ; CHECK-LOLOMOV-LABEL:  bar
+; CHECK-LOLOMOV-LABEL:  fnend
 ; 
 ; 'MOV lo, lo' in Thumb mode produces undefined results on pre-v6 hardware
 ; RUN: llc -mtriple=thumbv4t-none--eabi < %s | FileCheck %s --check-prefix=CHECK-NOLOLOMOV
@@ -19,6 +20,7 @@
 ; CHECK-NOLOLOMOV-NEXT:  movs [[SRC1]], [[SRC2:r[01]]]
 ; CHECK-NOLOLOMOV-NEXT:  movs [[SRC2]], [[TMP]]
 ; CHECK-NOLOLOMOV-LABEL: bar
+; CHECK-NOLOLOMOV-LABEL: fnend
 
 declare void @bar(i32, i32)
 
Index: test/CodeGen/ARM/vuzp.ll
===
--- test/CodeGen/ARM/vuzp.ll
+++ test/CodeGen/ARM/vuzp.ll
@@ -353,6 +353,7 @@
 define <8 x i8> @vuzp_trunc_and_shuffle(<8 x i8> %tr0, <8 x i8> %tr1,
 ; CHECK-LABEL: vuzp_trunc_and_shuffle:
 ; CHECK:   @ %bb.0:
+; CHECK-NEXT:	.save	{r11, lr}
 ; CHECK-NEXT:	push	{r11, lr}
 ; CHECK-NEXT:	add	r12, sp, #8
 ; CHECK-NEXT:	add	lr, sp, #24
@@ -458,7 +459,9 @@
 define <10 x i8> @vuzp_wide_type(<10 x i8> %tr0, <10 x i8> %tr1,
 ; CHECK-LABEL: vuzp_wide_type:
 ; CHECK:   @ %bb.0:
+; CHECK-NEXT:	.save	{r4, r10, r11, lr}
 ; CHECK-NEXT:	push	{r4, r10, r11, lr}
+; CHECK-NEXT:	.setfp	r11, sp, #8
 ; CHECK-NEXT:	add	r11, sp, #8
 ; CHECK-NEXT:	bic	sp, sp, #15
 ; CHECK-NEXT:	add	r12, r11, #32
Index: test/CodeGen/ARM/vcvt.ll
===

[PATCH] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

2018-02-23 Thread Christian Bruel via Phabricator via cfe-commits
chrib updated this revision to Diff 135610.
chrib added a comment.

damn it last diff was the llvm part (https://reviews.llvm.org/D31139). Here is 
the clang part.

sorry for the noise, still not experienced with Phabricator.


https://reviews.llvm.org/D31140

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Arch/ARM.cpp
  lib/Driver/ToolChains/Arch/ARM.h
  lib/Driver/ToolChains/BareMetal.cpp
  lib/Driver/ToolChains/BareMetal.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/CrossWindows.cpp
  lib/Driver/ToolChains/CrossWindows.h
  lib/Driver/ToolChains/Darwin.cpp
  lib/Driver/ToolChains/Darwin.h
  lib/Driver/ToolChains/Fuchsia.h
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/Gnu.h
  lib/Driver/ToolChains/Linux.cpp
  lib/Driver/ToolChains/Linux.h
  lib/Driver/ToolChains/MSVC.cpp
  lib/Driver/ToolChains/MSVC.h
  lib/Driver/ToolChains/MinGW.cpp
  lib/Driver/ToolChains/MinGW.h
  lib/Driver/ToolChains/NetBSD.h
  test/Driver/arm-unwind.c
  test/Driver/arm-unwind.cpp

Index: test/Driver/arm-unwind.cpp
===
--- /dev/null
+++ test/Driver/arm-unwind.cpp
@@ -0,0 +1,9 @@
+// Add function attribute "uwtable" for arm ehabi targets in C++.
+
+// RUN: %clang -target arm-none-eabi  -### -S %s -o %t.s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK-EABI %s
+// CHECK-EABI: -munwind-tables
+
+// RUN: %clang -target arm-linux-gnueabihf  -### -S %s -o %t.s 2>&1 \
+// RUN:| FileCheck --check-prefix=CHECK-GNU %s
+// CHECK-GNU: -munwind-tables
Index: test/Driver/arm-unwind.c
===
--- /dev/null
+++ test/Driver/arm-unwind.c
@@ -0,0 +1,9 @@
+// Do not add function attribute "uwtable" for arm ehabi targets for C mode.
+
+// RUN: %clang -target arm-none-eabi  -### -S %s -o %t.s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-EABI %s
+// CHECK-EABI-NOT: -munwind-tables
+
+// RUN: %clang -target arm-linux-gnueabihf -### -S %s -o %t.s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-GNU %s
+// CHECK-GNU-NOT: -munwind-tables
Index: lib/Driver/ToolChains/NetBSD.h
===
--- lib/Driver/ToolChains/NetBSD.h
+++ lib/Driver/ToolChains/NetBSD.h
@@ -65,7 +65,7 @@
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
 
-  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override {
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, types::ID InputType) const override {
 return true;
   }
 
Index: lib/Driver/ToolChains/MinGW.h
===
--- lib/Driver/ToolChains/MinGW.h
+++ lib/Driver/ToolChains/MinGW.h
@@ -60,7 +60,7 @@
 const llvm::opt::ArgList &Args);
 
   bool IsIntegratedAssemblerDefault() const override;
-  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args, types::ID InputType) const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "MinGW.h"
+#include "Arch/ARM.h"
 #include "InputInfo.h"
 #include "CommonArgs.h"
 #include "clang/Driver/Compilation.h"
@@ -353,8 +354,18 @@
   return new tools::MinGW::Linker(*this);
 }
 
-bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const {
-  return getArch() == llvm::Triple::x86_64;
+bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args, types::ID InputType) const {
+  switch (getArch()) {
+  case llvm::Triple::arm:
+  case llvm::Triple::armeb:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
+return tools::arm::ARMNeedUnwindTable(Args, types::isCXX(InputType));
+  case llvm::Triple::x86_64:
+return true;
+  default:
+return false;
+  }
 }
 
 bool toolchains::MinGW::isPICDefault() const {
Index: lib/Driver/ToolChains/MSVC.h
===
--- lib/Driver/ToolChains/MSVC.h
+++ lib/Driver/ToolChains/MSVC.h
@@ -73,7 +73,8 @@
 Action::OffloadKind DeviceOffloadKind) const override;
 
   bool IsIntegratedAssemblerDefault() const override;
-  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
+  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args,
+			 types::ID InputType) const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
Index: lib/Driver/ToolChains/MSVC.cpp
===
-

[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

2018-02-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Somewhat related thing i have noticed: https://godbolt.org/g/ow58JV
I wonder whether that also should be diagnosed? Where though, as clang-tidy 
check?


Repository:
  rC Clang

https://reviews.llvm.org/D43322



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


[PATCH] D43671: [clangd] Address FIXME and fix comment

2018-02-23 Thread Kirill Bobyrev via Phabricator via cfe-commits
omtcyfz updated this revision to Diff 135626.
omtcyfz added a comment.

Addressed review comment by actually checking whether -j option was actually 
passed to clangd.


https://reviews.llvm.org/D43671

Files:
  clangd/Context.cpp
  clangd/tool/ClangdMain.cpp


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -149,10 +149,13 @@
 return 1;
   }
 
-  // Ignore -j option if -run-synchonously is used.
-  // FIXME: a warning should be shown here.
-  if (RunSynchronously)
+  if (RunSynchronously) {
+if (WorkerThreadsCount.getNumOccurrences()) {
+  llvm::errs() << "-j option will be ignored because -run-synchronously is 
"
+  "used.\n";
+}
 WorkerThreadsCount = 0;
+  }
 
   // Validate command line arguments.
   llvm::Optional InputMirrorStream;
Index: clangd/Context.cpp
===
--- clangd/Context.cpp
+++ clangd/Context.cpp
@@ -13,7 +13,7 @@
 namespace clang {
 namespace clangd {
 
-Context Context::empty() { return Context(/*Data=*/nullptr); }
+Context Context::empty() { return Context(/*DataPtr=*/nullptr); }
 
 Context::Context(std::shared_ptr DataPtr)
 : DataPtr(std::move(DataPtr)) {}


Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -149,10 +149,13 @@
 return 1;
   }
 
-  // Ignore -j option if -run-synchonously is used.
-  // FIXME: a warning should be shown here.
-  if (RunSynchronously)
+  if (RunSynchronously) {
+if (WorkerThreadsCount.getNumOccurrences()) {
+  llvm::errs() << "-j option will be ignored because -run-synchronously is "
+  "used.\n";
+}
 WorkerThreadsCount = 0;
+  }
 
   // Validate command line arguments.
   llvm::Optional InputMirrorStream;
Index: clangd/Context.cpp
===
--- clangd/Context.cpp
+++ clangd/Context.cpp
@@ -13,7 +13,7 @@
 namespace clang {
 namespace clangd {
 
-Context Context::empty() { return Context(/*Data=*/nullptr); }
+Context Context::empty() { return Context(/*DataPtr=*/nullptr); }
 
 Context::Context(std::shared_ptr DataPtr)
 : DataPtr(std::move(DataPtr)) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43671: [clangd] Address FIXME and fix comment

2018-02-23 Thread Kirill Bobyrev via Phabricator via cfe-commits
omtcyfz marked an inline comment as done.
omtcyfz added inline comments.



Comment at: clangd/tool/ClangdMain.cpp:153
+  if (RunSynchronously) {
+if (WorkerThreadsCount != 0) {
+  llvm::errs()

ioeric wrote:
> `-j` is non-zero by default, and we shouldn't show warning if users only 
> specify `-run-synchronously`. We should only warn if user explicitly set 
> worker count while also providing `-run-synchronously`. 
Oh, you're correct, I should've been more careful. This should be fine now.


https://reviews.llvm.org/D43671



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


[PATCH] D43673: Make module use diagnostics refer to the top-level module

2018-02-23 Thread Daniel Jasper via Phabricator via cfe-commits
djasper created this revision.
djasper added a reviewer: rsmith.

All use declarations need to be directly placed in the top-level module anyway, 
knowing the submodule doesn't really help. The header that has the offending 
#include can easily be seen in the diagnostics source location.


https://reviews.llvm.org/D43673

Files:
  lib/Lex/ModuleMap.cpp
  test/Modules/Inputs/declare-use/h.h


Index: test/Modules/Inputs/declare-use/h.h
===
--- test/Modules/Inputs/declare-use/h.h
+++ test/Modules/Inputs/declare-use/h.h
@@ -1,7 +1,7 @@
 #ifndef H_H
 #define H_H
 #include "c.h"
-#include "d.h" // expected-error {{does not depend on a module exporting}}
+#include "d.h" // expected-error {{module XH does not depend on a module 
exporting}}
 #include "h1.h"
 const int h1 = aux_h*c*7*d;
 #endif
Index: lib/Lex/ModuleMap.cpp
===
--- lib/Lex/ModuleMap.cpp
+++ lib/Lex/ModuleMap.cpp
@@ -475,7 +475,7 @@
   // We have found a module, but we don't use it.
   if (NotUsed) {
 Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
-<< RequestingModule->getFullModuleName() << Filename;
+<< RequestingModule->getTopLevelModule()->Name << Filename;
 return;
   }
 
@@ -486,7 +486,7 @@
 
   if (LangOpts.ModulesStrictDeclUse) {
 Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
-<< RequestingModule->getFullModuleName() << Filename;
+<< RequestingModule->getTopLevelModule()->Name << Filename;
   } else if (RequestingModule && RequestingModuleIsModuleInterface &&
  LangOpts.isCompilingModule()) {
 // Do not diagnose when we are not compiling a module. 


Index: test/Modules/Inputs/declare-use/h.h
===
--- test/Modules/Inputs/declare-use/h.h
+++ test/Modules/Inputs/declare-use/h.h
@@ -1,7 +1,7 @@
 #ifndef H_H
 #define H_H
 #include "c.h"
-#include "d.h" // expected-error {{does not depend on a module exporting}}
+#include "d.h" // expected-error {{module XH does not depend on a module exporting}}
 #include "h1.h"
 const int h1 = aux_h*c*7*d;
 #endif
Index: lib/Lex/ModuleMap.cpp
===
--- lib/Lex/ModuleMap.cpp
+++ lib/Lex/ModuleMap.cpp
@@ -475,7 +475,7 @@
   // We have found a module, but we don't use it.
   if (NotUsed) {
 Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
-<< RequestingModule->getFullModuleName() << Filename;
+<< RequestingModule->getTopLevelModule()->Name << Filename;
 return;
   }
 
@@ -486,7 +486,7 @@
 
   if (LangOpts.ModulesStrictDeclUse) {
 Diags.Report(FilenameLoc, diag::err_undeclared_use_of_module)
-<< RequestingModule->getFullModuleName() << Filename;
+<< RequestingModule->getTopLevelModule()->Name << Filename;
   } else if (RequestingModule && RequestingModuleIsModuleInterface &&
  LangOpts.isCompilingModule()) {
 // Do not diagnose when we are not compiling a module. 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43581: [clang-tidy/google] Improve the Objective-C global variable declaration check ๐Ÿ”ง

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



Comment at: clang-tidy/google/GlobalVariableDeclarationCheck.cpp:92
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);

stephanemoore wrote:
> stephanemoore wrote:
> > Wizard wrote:
> > > aaron.ballman wrote:
> > > > We don't usually put hyperlinks in the diagnostic messages, so please 
> > > > remove this.
> > > > 
> > > > My suggestion about describing what constitutes an appropriate prefix 
> > > > was with regards to the style guide wording itself. For instance, that 
> > > > document doesn't mention that two capital letters is good. That's not 
> > > > on you to fix before this patch goes in, of course.
> > > Btw it is actually "2 or more" characters for prefix. I think it makes 
> > > sense because we need at least 2 or more characters to call it a "prefix" 
> > > :-)
> > Reverted the inclusion of the hyperlink in the message. I agree that 
> > embedding the hyperlink in the message is indirect and inconsistent with 
> > other diagnostic messages in LLVM projecta.
> ยง1 Regarding Prefixes And Character Count
> 
> Strictly speaking, a single character prefix (e.g., `extern const int 
> ALimit;` โŒ) is possible but not allowed for constants in Google Objective-C 
> style except for lowercase 'k' as a prefix for file scope constants (e.g., 
> `static const int kLimit = 3;` โœ”๏ธ). As hinted in the commit description, 
> Google currently enforces a minimum two character prefix (e.g., `extern const 
> int ABPrefix;` โœ”๏ธ) or exceptionally 'k' where appropriate.
> 
> Technically this modified regex allows authored code to include inadvisable 
> constant names with a single character prefix (e.g., `extern const int 
> APrefix;` โŒ). In this respect I would say that this change eliminates an 
> important category of false positives (constants prefixed with '[A-Z]{2,}') 
> while introducing a less important category of false negatives (constants 
> prefixed with only '[A-Z]'). The false positives are observed in standard 
> recommended code while the false negatives occur in non-standard 
> unrecommended code. Without a reliable mechanism to separate the constant 
> prefix from the constant name (e.g., splitting "FOOURL" into "FOO" and "URL" 
> or "HTTP2Header" into "HTTP2" and "Header"), I cannot immediately think of a 
> way to eliminate the introduced category of false negatives without 
> introducing other false positives. I intend to continue thinking about 
> alternative methods that might eliminate these false negatives without 
> introducing other compromises. If it is acceptable to the reviewers I would 
> propose to move forward with this proposed change to eliminate the observed 
> false positives and then consider addressing the false negatives in a 
> followup.
> 
> ยง2 Regarding the Google Objective-C Style Guide's Description of Appropriate 
> Prefixes
> 
> I agree that the Google Objective-C style guide should be clearer on this 
> topic and will pursue clarifying this promptly.
I don't think we should have the regex as part of the diagnostic either -- it's 
a distraction and it's not something we typically do. While it's nice for the 
diagnostic to explain how to fix the issue, the critical bit is diagnosing 
what's wrong with the code. The diagnostic without the regex does that and 
users have a place to find that information (the style guide docs).



Comment at: test/clang-tidy/google-objc-global-variable-declaration.m:33
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;

stephanemoore wrote:
> aaron.ballman wrote:
> > Can you also add the code from the style guide as a test case?
> > ```
> > extern NSString *const GTLServiceErrorDomain;
> > 
> > typedef NS_ENUM(NSInteger, GTLServiceError) {
> >   GTLServiceErrorQueryResultMissing = -3000,
> >   GTLServiceErrorWaitTimedOut   = -3001,
> > };
> > ```
> NS_ENUM and NSInteger are not defined in this implementation file.
> 
> I can either (1) Omit the macro and the type alias; or (2) reasonably 
> replicate the macro and type alias in this source file.
> 
> Which option is preferred? For the time being, I have pursued option (1) on 
> the assumption that NS_ENUM and NSInteger are not critical to this test case.
I think (1) is totally fine. It's the identifiers we're worried about, not the 
macros or types.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


Re: r325850 - [Darwin] Add a test to check clang produces accelerator tables.

2018-02-23 Thread Yvan Roux via cfe-commits
Hi Davide,


This patch broke ARM and AArch64 bots (x86_64 apple targets are not
available on these bots).
Logs are available here:
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/15940/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adebug-info-section-macho.c

Thanks
Yvan

On 23 February 2018 at 02:25, Davide Italiano via cfe-commits
 wrote:
> Author: davide
> Date: Thu Feb 22 17:25:03 2018
> New Revision: 325850
>
> URL: http://llvm.org/viewvc/llvm-project?rev=325850&view=rev
> Log:
> [Darwin] Add a test to check clang produces accelerator tables.
>
> This test was previously in lldb, and was only checking that clang
> was emitting the correct section. So, it belongs here and not
> in the debugger.
>
> Added:
> cfe/trunk/test/CodeGen/debug-info-section-macho.c
>
> Added: cfe/trunk/test/CodeGen/debug-info-section-macho.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-section-macho.c?rev=325850&view=auto
> ==
> --- cfe/trunk/test/CodeGen/debug-info-section-macho.c (added)
> +++ cfe/trunk/test/CodeGen/debug-info-section-macho.c Thu Feb 22 17:25:03 2018
> @@ -0,0 +1,16 @@
> +// Test that clang produces the __apple accelerator tables,
> +// e.g., __apple_types, correctly.
> +// RUN: %clang %s -target x86_64-apple-macosx10.13.0 -c -g -o %t-ex
> +// RUN: llvm-objdump -section-headers %t-ex | FileCheck %s
> +
> +int main (int argc, char const *argv[]) { return argc; }
> +
> +// CHECK: __debug_str
> +// CHECK-NEXT: __debug_abbrev
> +// CHECK-NEXT: __debug_info
> +// CHECK-NEXT: __debug_ranges
> +// CHECK-NEXT: __debug_macinfo
> +// CHECK-NEXT: __apple_names
> +// CHECK-NEXT: __apple_objc
> +// CHECK-NEXT: __apple_namespac
> +// CHECK-NEXT: __apple_types
>
>
> ___
> 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


r325872 - [mips] Reland r310704

2018-02-23 Thread Stefan Maksimovic via cfe-commits
Author: smaksimovic
Date: Fri Feb 23 00:37:48 2018
New Revision: 325872

URL: http://llvm.org/viewvc/llvm-project?rev=325872&view=rev
Log:
[mips] Reland r310704

Recommit this change which was previously reverted
for the 5.0.0 release since the failures identified
were dealt with in r325782.

Added:
cfe/trunk/test/CodeGen/mips-aggregate-arg.c
  - copied unchanged from r310703, 
cfe/trunk/test/CodeGen/mips-aggregate-arg.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=325872&r1=325871&r2=325872&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Feb 23 00:37:48 2018
@@ -6870,6 +6870,14 @@ MipsABIInfo::classifyArgumentType(QualTy
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
+// Use indirect if the aggregate cannot fit into registers for
+// passing arguments according to the ABI
+unsigned Threshold = IsO32 ? 16 : 64;
+
+if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
+  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
+ getContext().getTypeAlign(Ty) / 8 > 
Align);
+
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.


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


[PATCH] D43614: Define _PTHREADS for -pthread on NetBSD

2018-02-23 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski abandoned this revision.
krytarowski added a comment.

As discussed with Joerg, `_PTHREADS` is considered legacy and we can bear with 
lack of it and inconsistency with GCC.


Repository:
  rL LLVM

https://reviews.llvm.org/D43614



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


r325901 - Support for the mno-stack-arg-probe flag

2018-02-23 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Feb 23 05:47:36 2018
New Revision: 325901

URL: http://llvm.org/viewvc/llvm-project?rev=325901&view=rev
Log:
Support for the mno-stack-arg-probe flag

Adds support for this flag. There is also another piece for llvm
(separate review). More info:
https://bugs.llvm.org/show_bug.cgi?id=36221

By Ruslan Nikolaev!

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

Added:
cfe/trunk/test/CodeGen/stack-arg-probe.c
cfe/trunk/test/Driver/stack-arg-probe.c
Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=325901&r1=325900&r2=325901&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Fri Feb 23 05:47:36 2018
@@ -2192,6 +2192,10 @@ Set the stack alignment
 
 Set the stack probe size
 
+.. option:: -mstack-arg-probe, -mno-stack-arg-probe
+
+Disable stack probes
+
 .. option:: -mstackrealign, -mno-stackrealign
 
 Force realign the stack at entry to every function

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=325901&r1=325900&r2=325901&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Fri Feb 23 05:47:36 2018
@@ -1842,6 +1842,10 @@ def mstack_alignment : Joined<["-"], "ms
   HelpText<"Set the stack alignment">;
 def mstack_probe_size : Joined<["-"], "mstack-probe-size=">, Group, 
Flags<[CC1Option]>,
   HelpText<"Set the stack probe size">;
+def mstack_arg_probe : Flag<["-"], "mstack-arg-probe">, Group,
+  HelpText<"Enable stack probes">;
+def mno_stack_arg_probe : Flag<["-"], "mno-stack-arg-probe">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Disable stack probes which are enabled by default">;
 def mthread_model : Separate<["-"], "mthread-model">, Group, 
Flags<[CC1Option]>,
   HelpText<"The thread model to use, e.g. posix, single (posix by default)">, 
Values<"posix,single">;
 def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=325901&r1=325900&r2=325901&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Feb 23 05:47:36 2018
@@ -227,6 +227,7 @@ VALUE_CODEGENOPT(StackAlignment, 32,
 ///< alignment, if not 0.
 VALUE_CODEGENOPT(StackProbeSize, 32, 4096) ///< Overrides default stack
///< probe size, even if 0.
+CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
 CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
   ///< in debug info.
 

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=325901&r1=325900&r2=325901&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Feb 23 05:47:36 2018
@@ -2351,16 +2351,15 @@ public:
   }
 };
 
-static void addStackProbeSizeTargetAttribute(const Decl *D,
- llvm::GlobalValue *GV,
- CodeGen::CodeGenModule &CGM) {
-  if (D && isa(D)) {
-if (CGM.getCodeGenOpts().StackProbeSize != 4096) {
-  llvm::Function *Fn = cast(GV);
+static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+  CodeGen::CodeGenModule &CGM) {
+  if (llvm::Function *Fn = dyn_cast_or_null(GV)) {
 
+if (CGM.getCodeGenOpts().StackProbeSize != 4096)
   Fn->addFnAttr("stack-probe-size",
 llvm::utostr(CGM.getCodeGenOpts().StackProbeSize));
-}
+if (CGM.getCodeGenOpts().NoStackArgProbe)
+  Fn->addFnAttr("no-stack-arg-probe");
   }
 }
 
@@ -2369,7 +2368,7 @@ void WinX86_32TargetCodeGenInfo::setTarg
   X86_32TargetCodeGenInfo::setTargetAttributes(D, GV, CGM);
   if (GV->isDeclaration())
 return;
-  addStackProbeSizeTargetAttribute(D, GV, CGM);
+  addStackProbeTargetAttributes(D, GV, CGM);
 }
 
 class WinX86_64TargetC

[PATCH] D43108: Support for the mno-stack-arg-probe flag

2018-02-23 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325901: Support for the mno-stack-arg-probe flag (authored 
by hans, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D43108?vs=134377&id=135631#toc

Repository:
  rC Clang

https://reviews.llvm.org/D43108

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/stack-arg-probe.c
  test/Driver/stack-arg-probe.c

Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -2192,6 +2192,10 @@
 
 Set the stack probe size
 
+.. option:: -mstack-arg-probe, -mno-stack-arg-probe
+
+Disable stack probes
+
 .. option:: -mstackrealign, -mno-stackrealign
 
 Force realign the stack at entry to every function
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1842,6 +1842,10 @@
   HelpText<"Set the stack alignment">;
 def mstack_probe_size : Joined<["-"], "mstack-probe-size=">, Group, Flags<[CC1Option]>,
   HelpText<"Set the stack probe size">;
+def mstack_arg_probe : Flag<["-"], "mstack-arg-probe">, Group,
+  HelpText<"Enable stack probes">;
+def mno_stack_arg_probe : Flag<["-"], "mno-stack-arg-probe">, Group, Flags<[CC1Option]>,
+  HelpText<"Disable stack probes which are enabled by default">;
 def mthread_model : Separate<["-"], "mthread-model">, Group, Flags<[CC1Option]>,
   HelpText<"The thread model to use, e.g. posix, single (posix by default)">, Values<"posix,single">;
 def meabi : Separate<["-"], "meabi">, Group, Flags<[CC1Option]>,
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -227,6 +227,7 @@
 ///< alignment, if not 0.
 VALUE_CODEGENOPT(StackProbeSize, 32, 4096) ///< Overrides default stack
///< probe size, even if 0.
+CODEGENOPT(NoStackArgProbe, 1, 0) ///< Set when -mno-stack-arg-probe is used
 CODEGENOPT(DebugColumnInfo, 1, 0) ///< Whether or not to use column information
   ///< in debug info.
 
Index: test/CodeGen/stack-arg-probe.c
===
--- test/CodeGen/stack-arg-probe.c
+++ test/CodeGen/stack-arg-probe.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple=i686-windows-msvc -emit-llvm -o - -mno-stack-arg-probe | FileCheck %s -check-prefix=NO-STACKPROBE
+// RUN: %clang_cc1 %s -triple=i686-windows-msvc -emit-llvm -o - | FileCheck %s -check-prefix=STACKPROBE
+
+// NO-STACKPROBE: attributes #{{[0-9]+}} = {{{.*}} "no-stack-arg-probe"
+// STACKPROBE-NOT: attributes #{{[0-9]+}} = {{{.*}} "no-stack-arg-probe"
+
+void test1() {
+}
Index: test/Driver/stack-arg-probe.c
===
--- test/Driver/stack-arg-probe.c
+++ test/Driver/stack-arg-probe.c
@@ -0,0 +1,7 @@
+// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=STACKPROBE
+// RUN: %clang -### -mno-stack-arg-probe -mstack-arg-probe %s 2>&1 | FileCheck %s -check-prefix=STACKPROBE
+// RUN: %clang -### -mstack-arg-probe -mno-stack-arg-probe %s 2>&1 | FileCheck %s -check-prefix=NO-STACKPROBE
+// REQUIRES: clang-driver
+
+// NO-STACKPROBE: -mno-stack-arg-probe
+// STACKPROBE-NOT: -mno-stack-arg-probe
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4047,6 +4047,10 @@
   CmdArgs.push_back("-mstack-probe-size=0");
   }
 
+  if (!Args.hasFlag(options::OPT_mstack_arg_probe,
+options::OPT_mno_stack_arg_probe, true))
+CmdArgs.push_back(Args.MakeArgString("-mno-stack-arg-probe"));
+
   if (Arg *A = Args.getLastArg(options::OPT_mrestrict_it,
options::OPT_mno_restrict_it)) {
 if (A->getOption().matches(options::OPT_mrestrict_it)) {
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -923,6 +923,8 @@
 Opts.StackProbeSize = StackProbeSize;
   }
 
+  Opts.NoStackArgProbe = Args.hasArg(OPT_mno_stack_arg_probe);
+
   if (Arg *A = Args.getLastArg(OPT_fobjc_dispatch_method_EQ)) {
 StringRef Name = A->getValue();
 unsigned Method = llvm::StringSwitch(Name)
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp

[PATCH] D43510: [clangd] don't insert new includes if either original header or canonical header is already included.

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

Thanks, and sorry for the delay!




Comment at: clangd/Headers.cpp:45
 private:
-  std::set &Headers;
+  std::set &WrittenHeaders;
+  std::set &ResolvedHeaders;

nit: StringSet? std::set is pretty bad unless we need ordering


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43510



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


r325899 - [mips] Revert r325872

2018-02-23 Thread Stefan Maksimovic via cfe-commits
Author: smaksimovic
Date: Fri Feb 23 05:46:14 2018
New Revision: 325899

URL: http://llvm.org/viewvc/llvm-project?rev=325899&view=rev
Log:
[mips] Revert r325872

There are still outstanding issues with byVal arguments
that prevent this from being committed. Revert for now.

Removed:
cfe/trunk/test/CodeGen/mips-aggregate-arg.c
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=325899&r1=325898&r2=325899&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Feb 23 05:46:14 2018
@@ -6870,14 +6870,6 @@ MipsABIInfo::classifyArgumentType(QualTy
   return getNaturalAlignIndirect(Ty, RAA == CGCXXABI::RAA_DirectInMemory);
 }
 
-// Use indirect if the aggregate cannot fit into registers for
-// passing arguments according to the ABI
-unsigned Threshold = IsO32 ? 16 : 64;
-
-if(getContext().getTypeSizeInChars(Ty) > 
CharUnits::fromQuantity(Threshold))
-  return ABIArgInfo::getIndirect(CharUnits::fromQuantity(Align), true,
- getContext().getTypeAlign(Ty) / 8 > 
Align);
-
 // If we have reached here, aggregates are passed directly by coercing to
 // another structure type. Padding is inserted if the offset of the
 // aggregate is unaligned.

Removed: cfe/trunk/test/CodeGen/mips-aggregate-arg.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mips-aggregate-arg.c?rev=325898&view=auto
==
--- cfe/trunk/test/CodeGen/mips-aggregate-arg.c (original)
+++ cfe/trunk/test/CodeGen/mips-aggregate-arg.c (removed)
@@ -1,38 +0,0 @@
-// RUN: %clang_cc1 -triple mipsel-unknown-linux-gnu -S -emit-llvm -o - %s | 
FileCheck -check-prefix=O32 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n32 | FileCheck -check-prefix=N32-N64 %s
-// RUN: %clang_cc1 -triple mips64el-unknown-linux-gnu -S -emit-llvm -o - %s  
-target-abi n64 | FileCheck -check-prefix=N32-N64 %s
-
-struct t1 {
-  char t1[10];
-};
-
-struct t2 {
-  char t2[20];
-};
-
-struct t3 {
-  char t3[65];
-};
-
-extern struct t1 g1;
-extern struct t2 g2;
-extern struct t3 g3;
-extern void f1(struct t1);
-extern void f2(struct t2);
-extern void f3(struct t3);
-
-void f() {
-
-// O32:  call void @f1(i32 inreg %{{[0-9]+}}, i32 inreg %{{[0-9]+}}, i16 inreg 
%{{[0-9]+}})
-// O32:  call void @f2(%struct.t2* byval align 4 %{{.*}})
-// O32:  call void @f3(%struct.t3* byval align 4 %{{.*}})
-
-// N32-N64:  call void @f1(i64 inreg %{{[0-9]+}}, i16 inreg %{{[0-9]+}})
-// N32-N64:  call void @f2(i64 inreg %{{[0-9]+}}, i64 inreg %{{[0-9]+}}, i32 
inreg %{{[0-9]+}})
-// N32-N64:  call void @f3(%struct.t3* byval align 8 %{{.*}})
-
-  f1(g1);
-  f2(g2);
-  f3(g3);
-}
-


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


[PATCH] D43585: [libunwind] Permit additional compiler flags to be passed to tests.

2018-02-23 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a subscriber: arichardson.
sdardis added a comment.

This works as expected with your corresponding libcxx patch. However 
@arichardson 's https://reviews.llvm.org/D42139 does similar things for libcxx. 
We should wait for that to land, and ensure that this patch is rebased against 
that.




Comment at: CMakeLists.txt:142
 set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
+set(LIBUNWIND_TEST_CFLAGS "" CACHE PATH "Additional compiler flags for test 
programs.")
 

PATH should be STRING.



Comment at: test/lit.site.cfg.in:25
 config.cxx_ext_threads  = "@LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@"
+config.test_cflags  = "@LIBUNWIND_TEST_CFLAGS@"
 

This should be test_compiler_cflags.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D43585



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


[PATCH] D43660: [OpenMP] Add OpenMP data sharing infrastructure using global memory

2018-02-23 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:555
   Work.clear();
+  WrapperFunctionsMap.clear();
 

Do we need this?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:640-641
+  GlobalRecordSizeArg);
+  auto GlobalRecCastAddr = Bld.CreatePointerBitCastOrAddrSpaceCast(
+  GlobalRecValue, CGF.ConvertTypeForMem(RecTy)->getPointerTo());
+  FunctionToGlobalRecPtr.try_emplace(CGF.CurFn, GlobalRecValue);

`auto`->`llvm::Value *`



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:863-864
+//   - the master thread ID;
+emitCall(CGF, W, {Bld.getInt16(/*ParallelLevel=*/0),
+getMasterThreadID(CGF)});
 

1. Update it to the latest  version. And use clang-format!
2. This must be in a separate patch



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:933
 /// void *outlined_function, int16_t IsOMPRuntimeInitialized);
-llvm::Type *TypeParams[] = {CGM.Int8PtrTy,
-CGM.Int16Ty};
+llvm::Type *TypeParams[] = {CGM.Int8PtrTy, CGM.Int16Ty};
 llvm::FunctionType *FnTy =

Separate patch



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1101
+llvm::FunctionType *FnTy =
+llvm::FunctionType::get(CGM.VoidTy, {}, /*isVarArg*/ false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_end_sharing_variables");

`{}`->`llvm::None`



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1203-1210
+  auto *OutlinedFun = cast(
+  CGOpenMPRuntime::emitParallelOutlinedFunction(
+  D, ThreadIDVar, InnermostKind, CodeGen));
+  if (!isInSpmdExecutionMode()) {
+llvm::Function *WrapperFun =
+createDataSharingWrapper(OutlinedFun, D);
+WrapperFunctionsMap[OutlinedFun] = WrapperFun;

Should it be in this patch?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.h:324-331
+  /// Emit function which wraps the outline parallel region
+  /// and controls the parameters which are passed to this function.
+  /// The wrapper ensures that the outlined function is called
+  /// with the correct arguments when data is shared.
+  llvm::Function *
+  createDataSharingWrapper(llvm::Function *OutlinedParallelFn,
+  const OMPExecutableDirective &D);

Do we need this function at all?


Repository:
  rC Clang

https://reviews.llvm.org/D43660



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


[libcxxabi] r325907 - Creating release candidate rc3 from release_600 branch

2018-02-23 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Feb 23 07:09:53 2018
New Revision: 325907

URL: http://llvm.org/viewvc/llvm-project?rev=325907&view=rev
Log:
Creating release candidate rc3 from release_600 branch

Added:
libcxxabi/tags/RELEASE_600/rc3/
  - copied from r325906, libcxxabi/branches/release_60/

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


[libcxx] r325906 - Creating release candidate rc3 from release_600 branch

2018-02-23 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Feb 23 07:09:46 2018
New Revision: 325906

URL: http://llvm.org/viewvc/llvm-project?rev=325906&view=rev
Log:
Creating release candidate rc3 from release_600 branch

Added:
libcxx/tags/RELEASE_600/rc3/   (props changed)
  - copied from r325905, libcxx/branches/release_60/

Propchange: libcxx/tags/RELEASE_600/rc3/
--
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Feb 23 07:09:46 2018
@@ -0,0 +1,2 @@
+/libcxx/branches/apple:136569-137939
+/libcxx/trunk:321963,324153,324855,325147


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


[libunwind] r325913 - Creating release candidate rc3 from release_600 branch

2018-02-23 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Fri Feb 23 07:10:42 2018
New Revision: 325913

URL: http://llvm.org/viewvc/llvm-project?rev=325913&view=rev
Log:
Creating release candidate rc3 from release_600 branch

Added:
libunwind/tags/RELEASE_600/rc3/
  - copied from r325912, libunwind/branches/release_60/

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


[PATCH] D42139: Allow passing additional compiler/linker flags for the tests

2018-02-23 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325914: Allow passing additional compiler/linker flags for 
the tests (authored by arichardson, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D42139

Files:
  libcxx/trunk/test/CMakeLists.txt
  libcxx/trunk/test/lit.site.cfg.in
  libcxx/trunk/utils/libcxx/test/config.py


Index: libcxx/trunk/utils/libcxx/test/config.py
===
--- libcxx/trunk/utils/libcxx/test/config.py
+++ libcxx/trunk/utils/libcxx/test/config.py
@@ -510,6 +510,9 @@
 # and so that those tests don't have to be changed to tolerate
 # this insanity.
 self.cxx.compile_flags += ['-DNOMINMAX']
+additional_flags = self.get_lit_conf('test_compiler_flags')
+if additional_flags:
+self.cxx.compile_flags += shlex.split(additional_flags)
 
 def configure_default_compile_flags(self):
 # Try and get the std version from the command line. Fall back to
@@ -794,6 +797,9 @@
 self.use_system_cxx_lib]
 if self.is_windows and self.link_shared:
 self.add_path(self.cxx.compile_env, self.use_system_cxx_lib)
+additional_flags = self.get_lit_conf('test_linker_flags')
+if additional_flags:
+self.cxx.link_flags += shlex.split(additional_flags)
 
 def configure_link_flags_abi_library_path(self):
 # Configure ABI library paths.
Index: libcxx/trunk/test/lit.site.cfg.in
===
--- libcxx/trunk/test/lit.site.cfg.in
+++ libcxx/trunk/test/lit.site.cfg.in
@@ -22,6 +22,9 @@
 config.gcc_toolchain= "@LIBCXX_GCC_TOOLCHAIN@"
 config.generate_coverage= "@LIBCXX_GENERATE_COVERAGE@"
 config.target_info  = "@LIBCXX_TARGET_INFO@"
+config.test_linker_flags= "@LIBCXX_TEST_LINKER_FLAGS@"
+config.test_compiler_flags  = "@LIBCXX_TEST_COMPILER_FLAGS@"
+
 config.executor = "@LIBCXX_EXECUTOR@"
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.compiler_rt  = "@LIBCXX_USE_COMPILER_RT@"
Index: libcxx/trunk/test/CMakeLists.txt
===
--- libcxx/trunk/test/CMakeLists.txt
+++ libcxx/trunk/test/CMakeLists.txt
@@ -9,6 +9,11 @@
 set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
 "Configuration variant to use for LIT.")
 
+set(LIBCXX_TEST_LINKER_FLAGS "" CACHE STRING
+"Additonal linker flags to pass when compiling the tests")
+set(LIBCXX_TEST_COMPILER_FLAGS "" CACHE STRING
+"Additonal linker flags to pass when compiling the tests")
+
 # The tests shouldn't link to any ABI library when it has been linked into
 # libc++ statically or via a linker script.
 if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT)


Index: libcxx/trunk/utils/libcxx/test/config.py
===
--- libcxx/trunk/utils/libcxx/test/config.py
+++ libcxx/trunk/utils/libcxx/test/config.py
@@ -510,6 +510,9 @@
 # and so that those tests don't have to be changed to tolerate
 # this insanity.
 self.cxx.compile_flags += ['-DNOMINMAX']
+additional_flags = self.get_lit_conf('test_compiler_flags')
+if additional_flags:
+self.cxx.compile_flags += shlex.split(additional_flags)
 
 def configure_default_compile_flags(self):
 # Try and get the std version from the command line. Fall back to
@@ -794,6 +797,9 @@
 self.use_system_cxx_lib]
 if self.is_windows and self.link_shared:
 self.add_path(self.cxx.compile_env, self.use_system_cxx_lib)
+additional_flags = self.get_lit_conf('test_linker_flags')
+if additional_flags:
+self.cxx.link_flags += shlex.split(additional_flags)
 
 def configure_link_flags_abi_library_path(self):
 # Configure ABI library paths.
Index: libcxx/trunk/test/lit.site.cfg.in
===
--- libcxx/trunk/test/lit.site.cfg.in
+++ libcxx/trunk/test/lit.site.cfg.in
@@ -22,6 +22,9 @@
 config.gcc_toolchain= "@LIBCXX_GCC_TOOLCHAIN@"
 config.generate_coverage= "@LIBCXX_GENERATE_COVERAGE@"
 config.target_info  = "@LIBCXX_TARGET_INFO@"
+config.test_linker_flags= "@LIBCXX_TEST_LINKER_FLAGS@"
+config.test_compiler_flags  = "@LIBCXX_TEST_COMPILER_FLAGS@"
+
 config.executor = "@LIBCXX_EXECUTOR@"
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.compiler_rt  = "@LIBCXX_USE_COMPILER_RT@"
Index: libcxx/trunk/test/CMakeLists.txt
===
--- libcxx/trunk/test/CMakeLists.txt

[PATCH] D43621: [Driver] Allow using a canonical form of '-fuse-ld=' when cross-compiling on Windows.

2018-02-23 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth added a comment.

In https://reviews.llvm.org/D43621#1017027, @ruiu wrote:

> > That's weird, because lots of lldb tests compile and link test binaries on 
> > Windows with `-fuse-ld=lld` (without the `.exe`).  What makes you say the 
> > `.exe` is necessary?
>
> Maybe he is using clang (not clang-cl) and want to use ld.lld.exe instead of 
> lld-link?


The LLDB tests use clang, not clang-cl.  Here's a typical invocation:

  D:\src\llvm\build\ninja_release\bin\clang.exe  main.o -g -O0 -fno-builtin 
-m32  
-ID:\src\llvm\mono\llvm-project\lldb\packages\Python\lldbsuite\test\lang\c\conflicting-symbol/../../../make/../../../../../include
 
-ID:\src\llvm\mono\llvm-project\lldb\packages\Python\lldbsuite\test\lang\c\conflicting-symbol/
 -include 
D:\src\llvm\mono\llvm-project\lldb\packages\Python\lldbsuite\test\lang\c\conflicting-symbol/../../../make/test_common.h
 
-ID:\src\llvm\mono\llvm-project\lldb\packages\Python\lldbsuite\test\lang\c\conflicting-symbol/../../../make/
  -fno-limit-debug-info   -L. -LOne -lOne -LTwo -lTwo  -fuse-ld=lld 
--driver-mode=g++  -o "a.out"

Note that it's running `clang.exe` and passing `-fuse-ld=lld`.


Repository:
  rC Clang

https://reviews.llvm.org/D43621



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


[PATCH] D43514: Start settinng dso_local for COFF

2018-02-23 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola closed this revision.
espindola added a comment.

325915


https://reviews.llvm.org/D43514



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


[PATCH] D43681: [WebAssembly] Add exception handling option

2018-02-23 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100, jfb.

Add exception handling option to clang.


Repository:
  rC Clang

https://reviews.llvm.org/D43681

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  lib/Basic/Targets/WebAssembly.cpp
  lib/Basic/Targets/WebAssembly.h


Index: lib/Basic/Targets/WebAssembly.h
===
--- lib/Basic/Targets/WebAssembly.h
+++ lib/Basic/Targets/WebAssembly.h
@@ -32,11 +32,12 @@
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
+  bool HasExceptionHandling;
 
 public:
   explicit WebAssemblyTargetInfo(const llvm::Triple &T, const TargetOptions &)
   : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
-HasSignExt(false) {
+HasSignExt(false), HasExceptionHandling(false) {
 NoAsmVariants = true;
 SuitableAlign = 128;
 LargeArrayMinWidth = 128;
Index: lib/Basic/Targets/WebAssembly.cpp
===
--- lib/Basic/Targets/WebAssembly.cpp
+++ lib/Basic/Targets/WebAssembly.cpp
@@ -37,6 +37,7 @@
   .Case("simd128", SIMDLevel >= SIMD128)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
+  .Case("exception-handling", HasExceptionHandling)
   .Default(false);
 }
 
@@ -83,6 +84,14 @@
   HasSignExt = false;
   continue;
 }
+if (Feature == "+exception-handling") {
+  HasExceptionHandling = true;
+  continue;
+}
+if (Feature == "-exception-handling") {
+  HasExceptionHandling = false;
+  continue;
+}
 
 Diags.Report(diag::err_opt_not_valid_with_opt)
 << Feature << "-target-feature";
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1902,6 +1902,8 @@
 def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, 
Group;
 def msign_ext : Flag<["-"], "msign-ext">, Group;
 def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group;
+def mexception_handing : Flag<["-"], "mexception-handling">, 
Group;
+def mno_exception_handing : Flag<["-"], "mno-exception-handling">, 
Group;
 
 def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
   Flags<[HelpHidden]>,
Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst
+++ docs/ClangCommandLineReference.rst
@@ -2352,6 +2352,8 @@
 
 .. option:: -msimd128, -mno-simd128
 
+.. option:: -mexception-handling, -mno-exception-handling
+
 X86
 ---
 .. option:: -m3dnow, -mno-3dnow


Index: lib/Basic/Targets/WebAssembly.h
===
--- lib/Basic/Targets/WebAssembly.h
+++ lib/Basic/Targets/WebAssembly.h
@@ -32,11 +32,12 @@
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
+  bool HasExceptionHandling;
 
 public:
   explicit WebAssemblyTargetInfo(const llvm::Triple &T, const TargetOptions &)
   : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
-HasSignExt(false) {
+HasSignExt(false), HasExceptionHandling(false) {
 NoAsmVariants = true;
 SuitableAlign = 128;
 LargeArrayMinWidth = 128;
Index: lib/Basic/Targets/WebAssembly.cpp
===
--- lib/Basic/Targets/WebAssembly.cpp
+++ lib/Basic/Targets/WebAssembly.cpp
@@ -37,6 +37,7 @@
   .Case("simd128", SIMDLevel >= SIMD128)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
+  .Case("exception-handling", HasExceptionHandling)
   .Default(false);
 }
 
@@ -83,6 +84,14 @@
   HasSignExt = false;
   continue;
 }
+if (Feature == "+exception-handling") {
+  HasExceptionHandling = true;
+  continue;
+}
+if (Feature == "-exception-handling") {
+  HasExceptionHandling = false;
+  continue;
+}
 
 Diags.Report(diag::err_opt_not_valid_with_opt)
 << Feature << "-target-feature";
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1902,6 +1902,8 @@
 def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, Group;
 def msign_ext : Flag<["-"], "msign-ext">, Group;
 def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group;
+def mexception_handing : Flag<["-"], "mexception-handling">, Group;
+def mno_exception_handing : Flag<["-"], "mno-exception-handling">, Group;
 
 def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
   Flags<[HelpHidden]>,
Index: docs/ClangCommandLineReference.rst
===
--- docs/ClangCommandLineReference.rst

[libcxx] r325914 - Allow passing additional compiler/linker flags for the tests

2018-02-23 Thread Alexander Richardson via cfe-commits
Author: arichardson
Date: Fri Feb 23 07:19:48 2018
New Revision: 325914

URL: http://llvm.org/viewvc/llvm-project?rev=325914&view=rev
Log:
Allow passing additional compiler/linker flags for the tests

Summary:
These flags can be specified using the CMake variables
LIBCXX_TEST_LINKER_FLAGS and LIBCXX_TEST_COMPILER_FLAGS.
When building the tests for CHERI I need to pass additional
flags (such as -mabi=n64 or -mabi=purecap) to the compiler
for our test configurations

Reviewers: EricWF

Reviewed By: EricWF

Subscribers: christof, mgorny, cfe-commits

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

Modified:
libcxx/trunk/test/CMakeLists.txt
libcxx/trunk/test/lit.site.cfg.in
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=325914&r1=325913&r2=325914&view=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Fri Feb 23 07:19:48 2018
@@ -9,6 +9,11 @@ endmacro()
 set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING
 "Configuration variant to use for LIT.")
 
+set(LIBCXX_TEST_LINKER_FLAGS "" CACHE STRING
+"Additonal linker flags to pass when compiling the tests")
+set(LIBCXX_TEST_COMPILER_FLAGS "" CACHE STRING
+"Additonal linker flags to pass when compiling the tests")
+
 # The tests shouldn't link to any ABI library when it has been linked into
 # libc++ statically or via a linker script.
 if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT)

Modified: libcxx/trunk/test/lit.site.cfg.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.site.cfg.in?rev=325914&r1=325913&r2=325914&view=diff
==
--- libcxx/trunk/test/lit.site.cfg.in (original)
+++ libcxx/trunk/test/lit.site.cfg.in Fri Feb 23 07:19:48 2018
@@ -22,6 +22,9 @@ config.sysroot  = "@LIBC
 config.gcc_toolchain= "@LIBCXX_GCC_TOOLCHAIN@"
 config.generate_coverage= "@LIBCXX_GENERATE_COVERAGE@"
 config.target_info  = "@LIBCXX_TARGET_INFO@"
+config.test_linker_flags= "@LIBCXX_TEST_LINKER_FLAGS@"
+config.test_compiler_flags  = "@LIBCXX_TEST_COMPILER_FLAGS@"
+
 config.executor = "@LIBCXX_EXECUTOR@"
 config.llvm_unwinder= "@LIBCXXABI_USE_LLVM_UNWINDER@"
 config.compiler_rt  = "@LIBCXX_USE_COMPILER_RT@"

Modified: libcxx/trunk/utils/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/utils/libcxx/test/config.py?rev=325914&r1=325913&r2=325914&view=diff
==
--- libcxx/trunk/utils/libcxx/test/config.py (original)
+++ libcxx/trunk/utils/libcxx/test/config.py Fri Feb 23 07:19:48 2018
@@ -510,6 +510,9 @@ class Configuration(object):
 # and so that those tests don't have to be changed to tolerate
 # this insanity.
 self.cxx.compile_flags += ['-DNOMINMAX']
+additional_flags = self.get_lit_conf('test_compiler_flags')
+if additional_flags:
+self.cxx.compile_flags += shlex.split(additional_flags)
 
 def configure_default_compile_flags(self):
 # Try and get the std version from the command line. Fall back to
@@ -794,6 +797,9 @@ class Configuration(object):
 self.use_system_cxx_lib]
 if self.is_windows and self.link_shared:
 self.add_path(self.cxx.compile_env, self.use_system_cxx_lib)
+additional_flags = self.get_lit_conf('test_linker_flags')
+if additional_flags:
+self.cxx.link_flags += shlex.split(additional_flags)
 
 def configure_link_flags_abi_library_path(self):
 # Configure ABI library paths.


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


r325920 - Revert "[Darwin] Add a test to check clang produces accelerator tables."

2018-02-23 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Fri Feb 23 08:36:48 2018
New Revision: 325920

URL: http://llvm.org/viewvc/llvm-project?rev=325920&view=rev
Log:
Revert "[Darwin] Add a test to check clang produces accelerator tables."

This reverts commit 7e24e5f8bff77b7e78da3bfcc68abf42457a66c9.
aka r325850.  Clang should not have end-to-end tests.

Removed:
cfe/trunk/test/CodeGen/debug-info-section-macho.c

Removed: cfe/trunk/test/CodeGen/debug-info-section-macho.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-section-macho.c?rev=325919&view=auto
==
--- cfe/trunk/test/CodeGen/debug-info-section-macho.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-section-macho.c (removed)
@@ -1,16 +0,0 @@
-// Test that clang produces the __apple accelerator tables,
-// e.g., __apple_types, correctly.
-// RUN: %clang %s -target x86_64-apple-macosx10.13.0 -c -g -o %t-ex
-// RUN: llvm-objdump -section-headers %t-ex | FileCheck %s
-
-int main (int argc, char const *argv[]) { return argc; }
-
-// CHECK: __debug_str
-// CHECK-NEXT: __debug_abbrev
-// CHECK-NEXT: __debug_info
-// CHECK-NEXT: __debug_ranges
-// CHECK-NEXT: __debug_macinfo
-// CHECK-NEXT: __apple_names
-// CHECK-NEXT: __apple_objc
-// CHECK-NEXT: __apple_namespac
-// CHECK-NEXT: __apple_types


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


Re: r325850 - [Darwin] Add a test to check clang produces accelerator tables.

2018-02-23 Thread Davide Italiano via cfe-commits
Apologies, I'm taking a look now.

On Fri, Feb 23, 2018 at 5:33 AM, Yvan Roux  wrote:
> Hi Davide,
>
>
> This patch broke ARM and AArch64 bots (x86_64 apple targets are not
> available on these bots).
> Logs are available here:
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/15940/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adebug-info-section-macho.c
>
> Thanks
> Yvan
>
> On 23 February 2018 at 02:25, Davide Italiano via cfe-commits
>  wrote:
>> Author: davide
>> Date: Thu Feb 22 17:25:03 2018
>> New Revision: 325850
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=325850&view=rev
>> Log:
>> [Darwin] Add a test to check clang produces accelerator tables.
>>
>> This test was previously in lldb, and was only checking that clang
>> was emitting the correct section. So, it belongs here and not
>> in the debugger.
>>
>> Added:
>> cfe/trunk/test/CodeGen/debug-info-section-macho.c
>>
>> Added: cfe/trunk/test/CodeGen/debug-info-section-macho.c
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-section-macho.c?rev=325850&view=auto
>> ==
>> --- cfe/trunk/test/CodeGen/debug-info-section-macho.c (added)
>> +++ cfe/trunk/test/CodeGen/debug-info-section-macho.c Thu Feb 22 17:25:03 
>> 2018
>> @@ -0,0 +1,16 @@
>> +// Test that clang produces the __apple accelerator tables,
>> +// e.g., __apple_types, correctly.
>> +// RUN: %clang %s -target x86_64-apple-macosx10.13.0 -c -g -o %t-ex
>> +// RUN: llvm-objdump -section-headers %t-ex | FileCheck %s
>> +
>> +int main (int argc, char const *argv[]) { return argc; }
>> +
>> +// CHECK: __debug_str
>> +// CHECK-NEXT: __debug_abbrev
>> +// CHECK-NEXT: __debug_info
>> +// CHECK-NEXT: __debug_ranges
>> +// CHECK-NEXT: __debug_macinfo
>> +// CHECK-NEXT: __apple_names
>> +// CHECK-NEXT: __apple_objc
>> +// CHECK-NEXT: __apple_namespac
>> +// CHECK-NEXT: __apple_types
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: r325850 - [Darwin] Add a test to check clang produces accelerator tables.

2018-02-23 Thread via cfe-commits
Hi Davide,
Clang does not have end-to-end tests like this.  To verify we produce the
apple accelerator tables, you want a .ll source in llvm/test/CodeGen/X86.
In the meantime I've reverted the commit in r325920.
Thanks,
--paulr

> -Original Message-
> From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of
> Yvan Roux via cfe-commits
> Sent: Friday, February 23, 2018 5:34 AM
> To: Davide Italiano
> Cc: cfe-commits
> Subject: Re: r325850 - [Darwin] Add a test to check clang produces
> accelerator tables.
> 
> Hi Davide,
> 
> 
> This patch broke ARM and AArch64 bots (x86_64 apple targets are not
> available on these bots).
> Logs are available here:
> http://lab.llvm.org:8011/builders/clang-cmake-armv7-
> a15/builds/15940/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adebug-
> info-section-macho.c
> 
> Thanks
> Yvan
> 
> On 23 February 2018 at 02:25, Davide Italiano via cfe-commits
>  wrote:
> > Author: davide
> > Date: Thu Feb 22 17:25:03 2018
> > New Revision: 325850
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=325850&view=rev
> > Log:
> > [Darwin] Add a test to check clang produces accelerator tables.
> >
> > This test was previously in lldb, and was only checking that clang
> > was emitting the correct section. So, it belongs here and not
> > in the debugger.
> >
> > Added:
> > cfe/trunk/test/CodeGen/debug-info-section-macho.c
> >
> > Added: cfe/trunk/test/CodeGen/debug-info-section-macho.c
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-
> info-section-macho.c?rev=325850&view=auto
> >
> ==
> 
> > --- cfe/trunk/test/CodeGen/debug-info-section-macho.c (added)
> > +++ cfe/trunk/test/CodeGen/debug-info-section-macho.c Thu Feb 22
> 17:25:03 2018
> > @@ -0,0 +1,16 @@
> > +// Test that clang produces the __apple accelerator tables,
> > +// e.g., __apple_types, correctly.
> > +// RUN: %clang %s -target x86_64-apple-macosx10.13.0 -c -g -o %t-ex
> > +// RUN: llvm-objdump -section-headers %t-ex | FileCheck %s
> > +
> > +int main (int argc, char const *argv[]) { return argc; }
> > +
> > +// CHECK: __debug_str
> > +// CHECK-NEXT: __debug_abbrev
> > +// CHECK-NEXT: __debug_info
> > +// CHECK-NEXT: __debug_ranges
> > +// CHECK-NEXT: __debug_macinfo
> > +// CHECK-NEXT: __apple_names
> > +// CHECK-NEXT: __apple_objc
> > +// CHECK-NEXT: __apple_namespac
> > +// CHECK-NEXT: __apple_types
> >
> >
> > ___
> > 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
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43461: [CUDA] Include single GPU binary, NFCI.

2018-02-23 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 135649.
Hahnfeld marked an inline comment as done.
Hahnfeld added a comment.

Update comment.


https://reviews.llvm.org/D43461

Files:
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CGCUDANV.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/cuda-options.cu

Index: test/Driver/cuda-options.cu
===
--- test/Driver/cuda-options.cu
+++ test/Driver/cuda-options.cu
@@ -73,11 +73,10 @@
 // and that all results are included on the host side.
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=sm_35 --cuda-gpu-arch=sm_30 -c %s 2>&1 \
-// RUN: | FileCheck -check-prefix DEVICE -check-prefix DEVICE-NOSAVE \
-// RUN:-check-prefix DEVICE2 -check-prefix DEVICE-SM30 \
-// RUN:-check-prefix DEVICE2-SM35 -check-prefix HOST \
-// RUN:-check-prefix HOST-NOSAVE -check-prefix INCLUDES-DEVICE \
-// RUN:-check-prefix NOLINK %s
+// RUN: | FileCheck -check-prefixes DEVICE,DEVICE-NOSAVE,DEVICE2 \
+// RUN: -check-prefixes DEVICE-SM30,DEVICE2-SM35 \
+// RUN: -check-prefixes INCLUDES-DEVICE,INCLUDES-DEVICE2 \
+// RUN: -check-prefixes HOST,HOST-NOSAVE,NOLINK %s
 
 // Verify that device-side results are passed to the correct tool when
 // -save-temps is used.
@@ -182,17 +181,25 @@
 // DEVICE2-SAME: "-aux-triple" "x86_64--linux-gnu"
 // DEVICE2-SAME: "-fcuda-is-device"
 // DEVICE2-SM35-SAME: "-target-cpu" "sm_35"
-// DEVICE2-SAME: "-o" "[[GPUBINARY2:[^"]*]]"
+// DEVICE2-SAME: "-o" "[[PTXFILE2:[^"]*]]"
 // DEVICE2-SAME: "-x" "cuda"
 
+// Match another call to ptxas.
+// DEVICE2: ptxas
+// DEVICE2-SM35-DAG: "--gpu-name" "sm_35"
+// DEVICE2-DAG: "--output-file" "[[CUBINFILE2:[^"]*]]"
+// DEVICE2-DAG: "[[PTXFILE2]]"
+
 // Match no device-side compilation.
 // NODEVICE-NOT: "-cc1" "-triple" "nvptx64-nvidia-cuda"
 // NODEVICE-NOT: "-fcuda-is-device"
 
 // INCLUDES-DEVICE:fatbinary
 // INCLUDES-DEVICE-DAG: "--create" "[[FATBINARY:[^"]*]]"
 // INCLUDES-DEVICE-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE]]"
 // INCLUDES-DEVICE-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE]]"
+// INCLUDES-DEVICE2-DAG: "--image=profile=sm_{{[0-9]+}},file=[[CUBINFILE2]]"
+// INCLUDES-DEVICE2-DAG: "--image=profile=compute_{{[0-9]+}},file=[[PTXFILE2]]"
 
 // Match host-side preprocessor job with -save-temps.
 // HOST-SAVE: "-cc1" "-triple" "x86_64--linux-gnu"
@@ -207,7 +214,11 @@
 // HOST-SAME: "-o" "[[HOSTOUTPUT:[^"]*]]"
 // HOST-NOSAVE-SAME: "-x" "cuda"
 // HOST-SAVE-SAME: "-x" "cuda-cpp-output"
+// There is only one GPU binary after combining it with fatbinary!
+// INCLUDES-DEVICE2-NOT: "-fcuda-include-gpubinary"
 // INCLUDES-DEVICE-SAME: "-fcuda-include-gpubinary" "[[FATBINARY]]"
+// There is only one GPU binary after combining it with fatbinary.
+// INCLUDES-DEVICE2-NOT: "-fcuda-include-gpubinary"
 
 // Match external assembler that uses compilation output.
 // HOST-AS: "-o" "{{.*}}.o" "[[HOSTOUTPUT]]"
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1045,8 +1045,8 @@
   Args.getAllArgValues(OPT_fsanitize_trap_EQ), Diags,
   Opts.SanitizeTrap);
 
-  Opts.CudaGpuBinaryFileNames =
-  Args.getAllArgValues(OPT_fcuda_include_gpubinary);
+  Opts.CudaGpuBinaryFileName =
+  Args.getLastArgValue(OPT_fcuda_include_gpubinary);
 
   Opts.Backchain = Args.hasArg(OPT_mbackchain);
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4661,13 +4661,12 @@
   }
 
   if (IsCuda) {
-// Host-side cuda compilation receives device-side outputs as Inputs[1...].
-// Include them with -fcuda-include-gpubinary.
+// Host-side cuda compilation receives all device-side outputs in a single
+// fatbin as Inputs[1]. Include the binary with -fcuda-include-gpubinary.
 if (Inputs.size() > 1) {
-  for (auto I = std::next(Inputs.begin()), E = Inputs.end(); I != E; ++I) {
-CmdArgs.push_back("-fcuda-include-gpubinary");
-CmdArgs.push_back(I->getFilename());
-  }
+  assert(Inputs.size() == 2 && "More than one GPU binary!");
+  CmdArgs.push_back("-fcuda-include-gpubinary");
+  CmdArgs.push_back(Inputs[1].getFilename());
 }
 
 if (Args.hasFlag(options::OPT_fcuda_rdc, options::OPT_fno_cuda_rdc, false))
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -41,10 +41,10 @@
   /// Keeps track of kernel launch stubs emitted in this module
   llvm::SmallVector EmittedKernels;
   llvm::SmallVector, 16> DeviceVars;
-  /// Keeps track of variables containing handles of GPU binaries. Popu

[PATCH] D43322: Diagnose cases of "return x" that should be "return std::move(x)" for efficiency

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

In https://reviews.llvm.org/D43322#1017190, @lebedev.ri wrote:

> Somewhat related thing i have noticed: https://godbolt.org/g/ow58JV


IIUC, you're asking whether it would be possible to detect instances of

  return take(mysharedptr);

and rewrite them into

  return take(std::move(mysharedptr));

(Notice that the "return" context is relatively important, because if 
`mysharedptr` is used again after this use, then the move-from is unsafe and 
should not be suggested. Of course it's always possible for `mysharedptr` to be 
used again after a `return` or `throw` as well, e.g. during stack 
unwinding/destructors; but there's precedent there for C++ saying we'll take 
that chance.)

If you start treating names as rvalues no matter where they appear in larger 
expressions, then you run into trouble with

  std::string hello = ...;
  std::string &hello2 = hello;
  return concatenate(hello, hello2);

where the first use of `hello` on this line moves-out-of it, and then the 
second use reads the moved-from value. My best guess is that things like that 
occur frequently enough in real-world code that (A) the Standard can't specify 
move behavior there because it would quietly break code, and (B) a Clang 
diagnostic would produce mostly false positives (in the sense that accepting 
the fixits would quietly break the user's code).  I admit it would be 
interesting to write the code and find out empirically.

Whereas in this specific limited case of `return x;` and `throw x;`, 
programmers are already trained to expect a move, and there are no (new) 
aliasing issues.

> Where though, as clang-tidy check?

My experience with this patch suggests that when the thing you need to do 
involves "run a hypothetical overload-resolution," it is basically impossible 
to do with clang-tidy, and relatively easy to do in clang proper. (I tried 
writing this check into clang-tidy first, and couldn't figure out how to do the 
overload resolution part. Whereas it was painless in clang, especially with 
`-Wpessimizing-move` to copy off of.)


Repository:
  rC Clang

https://reviews.llvm.org/D43322



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Next, i suggest to look into code self-debugging, see comments.
Also, i have added a few questions, it would be great to know that my 
understanding is correct?

I'm sorry that it seems like we are going over and over and over over the same 
code again, 
this is the very base of the tool, i think it is important to get it as close 
to great as possible.
I *think* these review comments move it in that direction, not in the opposite 
direction?




Comment at: clang-doc/BitcodeWriter.cpp:47
+  BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
+  BitCodeConstants::LineNumFixedSize));  // Line number
+  Abbrev->Add(

So in other words this is making an assumption that no file with more than 
65535 lines will be analyzed, correct?
Can you add that as comment please?



Comment at: clang-doc/BitcodeWriter.cpp:56
+  StringRef Name;
+  AbbrevDsc Abbrev;
+

```
  AbbrevDsc Abbrev = nullptr;
```



Comment at: clang-doc/BitcodeWriter.cpp:57
+  AbbrevDsc Abbrev;
+
+  RecordIdDsc() = default;

```
// Is this 'description' valid?
operator bool() const {
  return Abbrev != nullptr && Name.data() != nullptr && !Name.empty();
}
```



Comment at: clang-doc/BitcodeWriter.cpp:137
+  {FUNCTION_LOCATION, {"Location", &LocationAbbrev}},
+  {FUNCTION_PARENT, {"Parent", &StringAbbrev}},
+  {FUNCTION_ACCESS, {"Access", &IntAbbrev}}};

So `FUNCTION_MANGLED_NAME` is phased out, and is thus missing, as far as i 
understand?



Comment at: clang-doc/BitcodeWriter.cpp:148
+void ClangDocBitcodeWriter::AbbreviationMap::add(RecordId RID,
+ unsigned AbbrevID) {
+  assert(Abbrevs.find(RID) == Abbrevs.end() && "Abbreviation already added.");

+`assert(RecordIdNameMap[ID] && "Unknown Abbreviation");`



Comment at: clang-doc/BitcodeWriter.cpp:153
+
+unsigned ClangDocBitcodeWriter::AbbreviationMap::get(RecordId RID) const {
+  assert(Abbrevs.find(RID) != Abbrevs.end() && "Unknown abbreviation.");

+`assert(RecordIdNameMap[ID] && "Unknown Abbreviation");`



Comment at: clang-doc/BitcodeWriter.cpp:158
+
+void ClangDocBitcodeWriter::AbbreviationMap::clear() { Abbrevs.clear(); }
+

Called only once, and that call does nothing.
I'd drop it.



Comment at: clang-doc/BitcodeWriter.cpp:175
+/// \brief Emits a block ID and the block name to the BLOCKINFO block.
+void ClangDocBitcodeWriter::emitBlockID(BlockId ID) {
+  Record.clear();

```
/// \brief Emits a block ID and the block name to the BLOCKINFO block.
void ClangDocBitcodeWriter::emitBlockID(BlockId ID) {
  const auto& BlockIdName = BlockIdNameMap[ID];
  assert(BlockIdName.data() && BlockIdName.size() && "Unknown BlockId!");

  Record.clear();
  Record.push_back(ID);
  Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);

  Record.clear();
  for (const char C : BlockIdName) Record.push_back(C);
  Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_BLOCKNAME, Record);
}
```



Comment at: clang-doc/BitcodeWriter.cpp:187
+void ClangDocBitcodeWriter::emitRecordID(RecordId ID) {
+  prepRecordData(ID);
+  for (const char C : RecordIdNameMap[ID].Name) Record.push_back(C);

```
/// \brief Emits a record name to the BLOCKINFO block.
void ClangDocBitcodeWriter::emitRecordID(RecordId ID) {
  assert(RecordIdNameMap[ID] && "Unknown Abbreviation");
  prepRecordData(ID);
```
(Yes, `prepRecordData()` will have the same code. It should get optimized away.)



Comment at: clang-doc/BitcodeWriter.cpp:194
+
+void ClangDocBitcodeWriter::emitAbbrev(RecordId ID, BlockId Block) {
+  auto Abbrev = std::make_shared();

```
void ClangDocBitcodeWriter::emitAbbrev(RecordId ID, BlockId Block) {
  assert(RecordIdNameMap[ID] && "Unknown Abbreviation");
  auto Abbrev = std::make_shared();
```



Comment at: clang-doc/BitcodeWriter.cpp:204
+void ClangDocBitcodeWriter::emitRecord(StringRef Str, RecordId ID) {
+  if (!prepRecordData(ID, !Str.empty())) return;
+  Record.push_back(Str.size());

So remember that in a previous iteration, seemingly useless `AbbrevDsc` stuff 
was added to the `RecordIdNameMap`?
It is going to pay-off now:
```
void ClangDocBitcodeWriter::emitRecord(StringRef Str, RecordId ID) {
  assert(RecordIdNameMap[ID] && "Unknown Abbreviation");
  assert(RecordIdNameMap[ID].Abbrev == &StringAbbrev && "Abbrev type mismatch");
  if (!prepRecordData(ID, !Str.empty())) return;
...
```
And if we did not add an `RecordIdNameMap` entry for this `RecordId`, then i 
believe that will also be detected because `Abbrev` will be a `nullptr`.



Comment at: clang-doc/BitcodeWriter.cpp:205
+  if (!prepRecordData(ID, !Str.empty())) return;
+  Record.push

[PATCH] D41102: Setup clang-doc frontend framework

2018-02-23 Thread Athos via Phabricator via cfe-commits
Athosvk added a comment.

The change to USR seems like quite an improvement already! That being said, I 
do think that it might be preferable to opt out of the use of strings for 
linking things together. What we did with our clang-doc is that we directly 
used pointers to refer to other types. So for example, our class for storing 
Record/CXX related information has something like:

  std::vectormMethods;
  std::vectormVariables;
  std::vectormEnums;
  std::vector mTypedefs;

Only upon serialization we fetch some kind of USR that would uniquely identify 
the type. This is especially useful to us for the conversion to HTML and I 
think the same would go for this backend, as it seems this way you'll have to 
do string lookups to get to the actual types, which would be inefficient in 
multiple aspects. It can make the backend a little more of a one-on-one 
conversion, e.g. with one of our HTML template definitions (note: this is a 
Jinja2 template in Python):

  {%- for enum in inEntry.GetMemberEnums() -%}




{{- 
Modifiers.RenderAccessModifier(enum.GetAccessModifier()) -}}
enum {{- enum.GetName().GetName()|e -}}
{{- 
Descriptions.RenderDescription(enum.GetBriefDescription()) -}}

  {%- endfor -%}

Disadvantage is of course that you add complexity to certain parts of the 
deserialization (/serialization) for nested types and inheritance, by either 
having to do so in the correct order or having to defer the process of 
initializing these pointers. But see this as just as some thought sharing. I do 
think this would improve the interaction in the backend (assuming you use the 
same representation as currently in the frontend). Also, we didn't apply this 
to our Type representation (which we use to store the type of a member, 
parameter etc.), which stores the name of the type rather than a pointer to it 
(since it can also be a built-in), though it embeds pretty much every possible 
modifier on said type, like this:

  EntryName mName;  

  bool  mIsConst = false;   

  EReferenceTypemReferenceType = EReferenceType::None;  
  std::vector mPointerConstnessMask;  

  std::vector  mArraySizes;

  bool  mIsAtomic = false;  

  std::vectormAttributes;

  bool  mIsExpansion = false;   

  std::vector mTemplateArguments; 

  std::unique_ptr mFunctionTypeProperties = 
nullptr;
  EntryName mParentCXXEntry;

The last member refers to the case where a pointer is a pointer to member, 
though some other fields may require some explaining too. Anyway, this is just 
to give some insight into how we structured our representation, where we 
largely omitted string representations where possible.

Have you actually started work already on some backend? Developing backend and 
frontend in tandem can provide some additional insights as to how things should 
be structured, especially representation-wise!




Comment at: clang-doc/Representation.h:113
+  TagTypeKind TagType;
+  llvm::SmallVector, 4> Members;
+  llvm::SmallVector ParentUSRs;

How come these are actually unique ptrs? They can be stored directly in the 
vector, right? (same for CommentInfo children, FnctionInfo params etc.)


https://reviews.llvm.org/D41102



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


r325930 - Convert test to FileCheck. NFC.

2018-02-23 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Fri Feb 23 10:18:01 2018
New Revision: 325930

URL: http://llvm.org/viewvc/llvm-project?rev=325930&view=rev
Log:
Convert test to FileCheck. NFC.

Modified:
cfe/trunk/test/CodeGen/tentative-decls.c

Modified: cfe/trunk/test/CodeGen/tentative-decls.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tentative-decls.c?rev=325930&r1=325929&r2=325930&view=diff
==
--- cfe/trunk/test/CodeGen/tentative-decls.c (original)
+++ cfe/trunk/test/CodeGen/tentative-decls.c Fri Feb 23 10:18:01 2018
@@ -1,16 +1,16 @@
-// RUN: %clang_cc1 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -emit-llvm -w -o - %s | FileCheck %s
 
-// RUN: grep '@r = common global \[1 x .*\] zeroinitializer' %t
+// CHECK-DAG: @r = common global [1 x {{.*}}] zeroinitializer
 
 int r[];
 int (*a)[] = &r;
 
 struct s0;
 struct s0 x;
-// RUN: grep '@x = common global .struct.s0 zeroinitializer' %t
+// CHECK-DAG: @x = common global %struct.s0 zeroinitializer
 
 struct s0 y;
-// RUN: grep '@y = common global .struct.s0 zeroinitializer' %t
+// CHECK-DAG: @y = common global %struct.s0 zeroinitializer
 struct s0 *f0() {
   return &y;
 }
@@ -19,19 +19,19 @@ struct s0 {
   int x;
 };
 
-// RUN: grep '@b = common global \[1 x .*\] zeroinitializer' %t
+// CHECK-DAG: @b = common global [1 x {{.*}}] zeroinitializer
 int b[];
 int *f1() {
   return b;
 }
 
 // Check that the most recent tentative definition wins.
-// RUN: grep '@c = common global \[4 x .*\] zeroinitializer' %t
+// CHECK-DAG: @c = common global [4 x {{.*}}] zeroinitializer
 int c[];
 int c[4];
 
 // Check that we emit static tentative definitions
-// RUN: grep '@c5 = internal global \[1 x .*\] zeroinitializer' %t
+// CHECK-DAG: @c5 = internal global [1 x {{.*}}] zeroinitializer
 static int c5[];
 static int func() { return c5[0]; }
 int callfunc() { return func(); }


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


[PATCH] D43648: [clangd] Debounce streams of updates.

2018-02-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/TUScheduler.cpp:324
+if (*Deadline)
+  RequestsCV.wait_until(Lock, **Deadline);
+else

ilya-biryukov wrote:
> It looks like if we unwrap `Optional` to `Deadline`, we could 
> replace this code with `wait` helper from `Threading.h`.
> The tracing code (e.g. `if (!Requests.empty) { /*...*/}`) could be changed to 
> log only when `*Deadline - steady_clock::now()` is positive.
> Will probably make the code simpler. WDYT?
Made Deadline a real type, and added a wait() overload without a condition.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43648



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


[PATCH] D43648: [clangd] Debounce streams of updates.

2018-02-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 135660.
sammccall marked 3 inline comments as done.
sammccall added a comment.

Make Deadline a real type with 0/finite/inf semantics.
Pull out another wait() overload.
Expose debounce delay option in clangdserver.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43648

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/DraftStore.cpp
  clangd/DraftStore.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Headers.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  clangd/Threading.cpp
  clangd/Threading.h
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -50,7 +50,7 @@
   auto Missing = testPath("missing.cpp");
   Files[Missing] = "";
 
-  S.update(Added, getInputs(Added, ""), ignoreUpdate);
+  S.update(Added, getInputs(Added, ""), WantDiagnostics::No, ignoreUpdate);
 
   // Assert each operation for missing file is an error (even if it's available
   // in VFS).
@@ -88,6 +88,58 @@
   S.remove(Added);
 }
 
+TEST_F(TUSchedulerTests, WantDiagnostics) {
+  std::atomic CallbackCount(0);
+  {
+// To avoid a racy test, don't allow tasks to actualy run on the worker
+// thread until we've scheduled them all.
+Notification Ready;
+TUScheduler S(getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
+  /*ASTParsedCallback=*/nullptr);
+auto Path = testPath("foo.cpp");
+S.update(Path, getInputs(Path, ""), WantDiagnostics::Yes,
+ [&](std::vector) { Ready.wait(); });
+
+S.update(Path, getInputs(Path, "request diags"), WantDiagnostics::Yes,
+ [&](std::vector Diags) { ++CallbackCount; });
+S.update(Path, getInputs(Path, "auto (clobbered)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "auto should have been cancelled by auto";
+ });
+S.update(Path, getInputs(Path, "request no diags"), WantDiagnostics::No,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "no diags should not be called back";
+ });
+S.update(Path, getInputs(Path, "auto (produces)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+Ready.notify();
+  }
+  EXPECT_EQ(2, CallbackCount);
+}
+
+TEST_F(TUSchedulerTests, Debounce) {
+  std::atomic CallbackCount(0);
+  {
+TUScheduler S(getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
+  /*ASTParsedCallback=*/nullptr,
+  /*UpdateDebounce=*/std::chrono::milliseconds(50));
+auto Path = testPath("foo.cpp");
+S.update(Path, getInputs(Path, "auto (debounced)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "auto should have been debounced and canceled";
+ });
+std::this_thread::sleep_for(std::chrono::milliseconds(10));
+S.update(Path, getInputs(Path, "auto (timed out)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+std::this_thread::sleep_for(std::chrono::milliseconds(60));
+S.update(Path, getInputs(Path, "auto (shut down)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+  }
+  EXPECT_EQ(2, CallbackCount);
+}
+
 TEST_F(TUSchedulerTests, ManyUpdates) {
   const int FilesCount = 3;
   const int UpdatesPerFile = 10;
@@ -132,7 +184,7 @@
 
 {
   WithContextValue WithNonce(NonceKey, ++Nonce);
-  S.update(File, Inputs,
+  S.update(File, Inputs, WantDiagnostics::Auto,
[Nonce, &Mut, &TotalUpdates](
llvm::Optional> Diags) {
  EXPECT_THAT(Context::current().get(NonceKey),
Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "Annotations.h"
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "Matchers.h"
@@ -77,6 +78,43 @@
   VFSTag LastVFSTag = VFSTag();
 };
 
+/// For each file, record whether the last published diagnostics contained at
+/// least one error.
+class MultipleErrorCheckingDiagConsumer : public DiagnosticsConsumer {
+public:
+  void
+  onDiagnosticsReady(PathRef File,
+ Tagged> Diagnostics) override {
+bool HadError = diagsContainErrors(Diagnostics.Value);
+
+std::lock_

[PATCH] D43648: [clangd] Debounce streams of updates.

2018-02-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 135661.
sammccall added a comment.

rebase


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43648

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/TUScheduler.cpp
  clangd/TUScheduler.h
  clangd/Threading.cpp
  clangd/Threading.h
  unittests/clangd/TUSchedulerTests.cpp

Index: unittests/clangd/TUSchedulerTests.cpp
===
--- unittests/clangd/TUSchedulerTests.cpp
+++ unittests/clangd/TUSchedulerTests.cpp
@@ -118,6 +118,28 @@
   EXPECT_EQ(2, CallbackCount);
 }
 
+TEST_F(TUSchedulerTests, Debounce) {
+  std::atomic CallbackCount(0);
+  {
+TUScheduler S(getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
+  /*ASTParsedCallback=*/nullptr,
+  /*UpdateDebounce=*/std::chrono::milliseconds(50));
+auto Path = testPath("foo.cpp");
+S.update(Path, getInputs(Path, "auto (debounced)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) {
+   ADD_FAILURE() << "auto should have been debounced and canceled";
+ });
+std::this_thread::sleep_for(std::chrono::milliseconds(10));
+S.update(Path, getInputs(Path, "auto (timed out)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+std::this_thread::sleep_for(std::chrono::milliseconds(60));
+S.update(Path, getInputs(Path, "auto (shut down)"), WantDiagnostics::Auto,
+ [&](std::vector Diags) { ++CallbackCount; });
+  }
+  EXPECT_EQ(2, CallbackCount);
+}
+
 TEST_F(TUSchedulerTests, ManyUpdates) {
   const int FilesCount = 3;
   const int UpdatesPerFile = 10;
Index: clangd/Threading.h
===
--- clangd/Threading.h
+++ clangd/Threading.h
@@ -50,18 +50,48 @@
   std::size_t FreeSlots;
 };
 
-/// A point in time we may wait for, or None to wait forever.
+/// A point in time we can wait for.
+/// Can be zero (don't wait) or infinity (wait forever).
 /// (Not time_point::max(), because many std::chrono implementations overflow).
-using Deadline = llvm::Optional;
-/// Makes a deadline from a timeout in seconds.
+class Deadline {
+public:
+  Deadline(std::chrono::steady_clock::time_point Time)
+  : Type(Finite), Time(Time) {}
+  static Deadline zero() { return Deadline(Zero); }
+  static Deadline infinity() { return Deadline(Infinite); }
+
+  std::chrono::steady_clock::time_point time() const {
+assert(Type == Finite);
+return Time;
+  }
+  bool expired() const {
+return (Type == Zero) ||
+   (Type == Finite && Time < std::chrono::steady_clock::now());
+  }
+  bool operator==(const Deadline &Other) const {
+return (Type == Other.Type) && (Type != Finite || Time == Other.Time);
+  }
+
+private:
+  enum Type { Zero, Infinite, Finite } Type;
+  Deadline(enum Type Type) : Type(Type) {}
+  std::chrono::steady_clock::time_point Time;
+};
+
+/// Makes a deadline from a timeout in seconds. None means wait forever.
 Deadline timeoutSeconds(llvm::Optional Seconds);
+/// Wait once for on CV for the specified duration.
+void wait(std::unique_lock &Lock, std::condition_variable &CV,
+  Deadline D);
 /// Waits on a condition variable until F() is true or D expires.
 template 
 LLVM_NODISCARD bool wait(std::unique_lock &Lock,
  std::condition_variable &CV, Deadline D, Func F) {
-  if (D)
-return CV.wait_until(Lock, *D, F);
-  CV.wait(Lock, F);
+  while (!F()) {
+if (D.expired())
+  return false;
+wait(Lock, CV, D);
+  }
   return true;
 }
 
@@ -73,7 +103,7 @@
   /// Destructor waits for all pending tasks to finish.
   ~AsyncTaskRunner();
 
-  void wait() const { (void) wait(llvm::None); }
+  void wait() const { (void)wait(Deadline::infinity()); }
   LLVM_NODISCARD bool wait(Deadline D) const;
   // The name is used for tracing and debugging (e.g. to name a spawned thread).
   void runAsync(llvm::Twine Name, UniqueFunction Action);
Index: clangd/Threading.cpp
===
--- clangd/Threading.cpp
+++ clangd/Threading.cpp
@@ -76,10 +76,19 @@
 Deadline timeoutSeconds(llvm::Optional Seconds) {
   using namespace std::chrono;
   if (!Seconds)
-return llvm::None;
+return Deadline::infinity();
   return steady_clock::now() +
  duration_cast(duration(*Seconds));
 }
 
+void wait(std::unique_lock &Lock, std::condition_variable &CV,
+  Deadline D) {
+  if (D == Deadline::zero())
+return;
+  if (D == Deadline::infinity())
+return CV.wait(Lock);
+  CV.wait_until(Lock, D.time());
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/TUScheduler.h
===
--- clangd/TUScheduler.h
+++ clangd/TUScheduler.h
@@ -17,6 +17,7 @@
 
 namespace clang {
 namespace clangd {
+
 /// Returns a number of a default async threads to use for TUSchedul

[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-02-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please run Clang-format and Clang-tidy modernize over new code.




Comment at: clang-doc/generators/Generators.h:29
+  Generator(std::unique_ptr &IS, StringRef Root, StringRef Format)
+  : IS(IS), Root(Root), Format(Format){};
+  virtual ~Generator(){};

Unnecessary ; after constructor body. Please enable Clang's -Wextra-semi



Comment at: clang-doc/generators/Generators.h:30
+  : IS(IS), Root(Root), Format(Format){};
+  virtual ~Generator(){};
+

Please use = default;



Comment at: clang-doc/generators/Generators.h:47
+  YAMLGenerator(std::unique_ptr &IS, StringRef Root, StringRef Format)
+  : Generator(IS, Root, Format){};
+  virtual ~YAMLGenerator(){};

Unnecessary ; after constructor body.



Comment at: clang-doc/generators/Generators.h:48
+  : Generator(IS, Root, Format){};
+  virtual ~YAMLGenerator(){};
+

Please use = default;



Comment at: test/clang-doc/namespace-yaml.cpp:11
+void f();
+void f() {};
+

Unnecessary ; after function body.


https://reviews.llvm.org/D43667



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


[PATCH] D43667: [clang-doc] Implement a YAML generator

2018-02-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I may be mistaken, but Clang source code didn't use llvm namespace by default. 
Insetad you should include clang/Basic/LLVM.h and use llvm:: for rest of things.




Comment at: clang-doc/tool/ClangDocMain.cpp:42
 
 namespace {
 

There is no need to enclose static definitions in anonymous namespace.


https://reviews.llvm.org/D43667



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


LLVM buildmaster will be updated and restarted tonight

2018-02-23 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 6PM Pacific time today.

Thanks

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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please run Clang-format and Clang-tidy modernize.




Comment at: clang-doc/Representation.h:80
+  : LineNumber(LineNumber), Filename(std::move(Filename)) {}
+  int LineNumber;
+  std::string Filename;

Please separate constructors from data members with empty line.


https://reviews.llvm.org/D41102



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


[PATCH] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-02-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please run Clang-format and Clang-tidy modernize.




Comment at: clang-doc/BitcodeReader.h:36
+ public:
+  ClangDocBitcodeReader() {}
+  using RecordData = SmallVector;

Please use = default;


https://reviews.llvm.org/D43341



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


[PATCH] D43424: [clang-doc] Implement a (simple) Markdown generator

2018-02-23 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please run Clang-format and Clang-tidy modernize.




Comment at: clang-doc/generators/Generators.h:46
+public:
+  MDGenerator(std::unique_ptr &IS, StringRef Root, StringRef Format) 
: Generator(IS, Root, Format) {};
+  virtual ~MDGenerator() {};

Please remove semicolon after constructor body. Please enable CLang's 
-Wextra-semi.



Comment at: clang-doc/generators/Generators.h:47
+  MDGenerator(std::unique_ptr &IS, StringRef Root, StringRef Format) 
: Generator(IS, Root, Format) {};
+  virtual ~MDGenerator() {};
+  

Please use = default;


https://reviews.llvm.org/D43424



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


[PATCH] D43533: [CFG] [analyzer] NFC: Refactor ConstructionContext into a finite set of cases.

2018-02-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 135667.
NoQ added a comment.

Missing break!~~


https://reviews.llvm.org/D43533

Files:
  include/clang/Analysis/CFG.h
  include/clang/Analysis/ConstructionContext.h
  lib/Analysis/CFG.cpp
  lib/Analysis/CMakeLists.txt
  lib/Analysis/ConstructionContext.cpp
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/Analysis/Analyses/LiveVariables.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "llvm/ADT/SmallSet.h"
@@ -635,10 +636,11 @@
 
 const CXXConstructExpr *CtorExpr = Ctor.getOriginExpr();
 
-auto CC = getCurrentCFGElement().getAs();
-const Stmt *ParentExpr = CC ? CC->getTriggerStmt() : nullptr;
+auto CCE = getCurrentCFGElement().getAs();
+const ConstructionContext *CC = CCE ? CCE->getConstructionContext()
+: nullptr;
 
-if (ParentExpr && isa(ParentExpr) &&
+if (CC && isa(CC) &&
 !Opts.mayInlineCXXAllocator())
   return CIP_DisallowedOnce;
 
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -12,6 +12,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/ParentMap.h"
@@ -111,47 +112,20 @@
   // See if we're constructing an existing region by looking at the
   // current construction context.
   if (CC) {
-if (const Stmt *TriggerStmt = CC->getTriggerStmt()) {
-  if (const CXXNewExpr *CNE = dyn_cast(TriggerStmt)) {
-if (AMgr.getAnalyzerOptions().mayInlineCXXAllocator()) {
-  // TODO: Detect when the allocator returns a null pointer.
-  // Constructor shall not be called in this case.
-  if (const SubRegion *MR = dyn_cast_or_null(
-  getCXXNewAllocatorValue(State, CNE, LCtx).getAsRegion())) {
-if (CNE->isArray()) {
-  // TODO: In fact, we need to call the constructor for every
-  // allocated element, not just the first one!
-  CallOpts.IsArrayCtorOrDtor = true;
-  return getStoreManager().GetElementZeroRegion(
-  MR, CNE->getType()->getPointeeType());
-}
-return MR;
-  }
-}
-  } else if (auto *DS = dyn_cast(TriggerStmt)) {
-const auto *Var = cast(DS->getSingleDecl());
-SVal LValue = State->getLValue(Var, LCtx);
-QualType Ty = Var->getType();
-LValue = makeZeroElementRegion(State, LValue, Ty,
-   CallOpts.IsArrayCtorOrDtor);
-return LValue.getAsRegion();
-  } else if (isa(TriggerStmt)) {
-// TODO: We should construct into a CXXBindTemporaryExpr or a
-// MaterializeTemporaryExpr around the call-expression on the previous
-// stack frame. Currently we re-bind the temporary to the correct region
-// later, but that's not semantically correct. This of course does not
-// apply when we're in the top frame. But if we are in an inlined
-// function, we should be able to take the call-site CFG element,
-// and it should contain (but right now it wouldn't) some sort of
-// construction context that'd give us the right temporary expression.
-CallOpts.IsTemporaryCtorOrDtor = true;
-return MRMgr.getCXXTempObjectRegion(CE, LCtx);
-  } else if (isa(TriggerStmt)) {
-CallOpts.IsTemporaryCtorOrDtor = true;
-return MRMgr.getCXXTempObjectRegion(CE, LCtx);
-  }
-  // TODO: Consider other directly initialized elements.
-} else if (const CXXCtorInitializer *Init = CC->getTriggerInit()) {
+switch (CC->getKind()) {
+case ConstructionContext::SimpleVariableKind: {
+  const auto *DSCC = cast(CC);
+  const auto *DS = DSCC->getDeclStmt();
+  const auto *Var = cast(DS->getSingleDecl());
+  SVal LValue = State->getLValue(Var, LCtx);
+  QualType Ty = Var->getType();
+  LValue =
+  makeZeroElementRegion(State, LValue, Ty, CallOpts.IsArrayCtorOrDtor);
+  return LValue.getAsRegion();
+}
+case ConstructionContext::ConstructorInitializerKind: {
+  const auto *ICC = cast(CC);
+  const auto *Init = ICC->getCXXCto

[PATCH] D42217: Set Module Metadata "AvoidPLT" when -fno-plt is used.

2018-02-23 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram added a comment.

Ping.


https://reviews.llvm.org/D42217



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


[PATCH] D43689: [analyzer] Disable constructor inlining when lifetime extension through fields occurs.

2018-02-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet.
Herald added subscribers: cfe-commits, rnkovacs.

As i mentioned in https://reviews.llvm.org/D43497, automatic destructors are 
missing in the CFG in situations like

  const int &x = C().x;

For now i'd rather disable construction inlining, because inlining constructors 
while doing nothing on destructors is very bad.


Repository:
  rC Clang

https://reviews.llvm.org/D43689

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  test/Analysis/lifetime-extension.cpp


Index: test/Analysis/lifetime-extension.cpp
===
--- test/Analysis/lifetime-extension.cpp
+++ test/Analysis/lifetime-extension.cpp
@@ -39,18 +39,10 @@
   const int &y = A().j[1]; // no-crash
   const int &z = (A().j[1], A().j[0]); // no-crash
 
-  clang_analyzer_eval(x == 1);
-  clang_analyzer_eval(y == 3);
-  clang_analyzer_eval(z == 2);
-#ifdef TEMPORARIES
- // expected-warning@-4{{TRUE}}
- // expected-warning@-4{{TRUE}}
- // expected-warning@-4{{TRUE}}
-#else
- // expected-warning@-8{{UNKNOWN}}
- // expected-warning@-8{{UNKNOWN}}
- // expected-warning@-8{{UNKNOWN}}
-#endif
+  // FIXME: All of these should be TRUE, but constructors aren't inlined.
+  clang_analyzer_eval(x == 1); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(y == 3); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(z == 2); // expected-warning{{UNKNOWN}}
 }
 } // end namespace pr19539_crash_on_destroying_an_integer
 
@@ -144,12 +136,7 @@
 const bool &x = C(true, &after, &before).x; // no-crash
   }
   // FIXME: Should be TRUE. Should not warn about garbage value.
-  clang_analyzer_eval(after == before);
-#ifdef TEMPORARIES
-  // expected-warning@-2{{The left operand of '==' is a garbage value}}
-#else
-  // expected-warning@-4{{UNKNOWN}}
-#endif
+  clang_analyzer_eval(after == before); // expected-warning{{UNKNOWN}}
 }
 } // end namespace maintain_original_object_address_on_lifetime_extension
 
Index: lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -678,6 +678,11 @@
   // the fake temporary target.
   if (CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion)
 return CIP_DisallowedOnce;
+
+  // If the temporary is lifetime-extended by binding a smaller object
+  // within it to a reference, automatic destructors don't work properly.
+  if (CallOpts.IsTemporaryLifetimeExtendedViaSubobject)
+return CIP_DisallowedOnce;
 }
 
 break;
Index: lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -168,6 +168,18 @@
   break;
 }
 case ConstructionContext::TemporaryObjectKind: {
+  const auto *TOCC = cast(CC);
+  // See if we're lifetime-extended via our field. If so, take a note.
+  // Because automatic destructors aren't quite working in this case.
+  if (const auto *MTE = TOCC->getMaterializedTemporaryExpr()) {
+if (const ValueDecl *VD = MTE->getExtendingDecl()) {
+  assert(VD->getType()->isReferenceType());
+  if (VD->getType()->getPointeeType().getCanonicalType() !=
+  MTE->GetTemporaryExpr()->getType().getCanonicalType()) {
+CallOpts.IsTemporaryLifetimeExtendedViaSubobject = true;
+  }
+}
+  }
   // TODO: Support temporaries lifetime-extended via static references.
   // They'd need a getCXXStaticTempObjectRegion().
   CallOpts.IsTemporaryCtorOrDtor = true;
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -65,6 +65,9 @@
 bool IsArrayCtorOrDtor = false;
 /// This call is a constructor or a destructor of a temporary value.
 bool IsTemporaryCtorOrDtor = false;
+/// This call is a constructor for a temporary that is lifetime-extended
+/// by binding a smaller object within it to a reference.
+bool IsTemporaryLifetimeExtendedViaSubobject = false;
 
 EvalCallOptions() {}
   };


Index: test/Analysis/lifetime-extension.cpp
===
--- test/Analysis/lifetime-extension.cpp
+++ test/Analysis/lifetime-extension.cpp
@@ -39,18 +39,10 @@
   const int &y = A().j[1]; // no-crash
   const int &z = (A().j[1], A().j[0]); // no-crash
 
-  clang_analyzer_eval(x == 1);
-  clang_analyzer_eval(y == 3);
-  clang_analyzer_ev

[PATCH] D41880: Adding nocf_check attribute for cf-protection fine tuning

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



Comment at: test/Sema/attr-nocf_check.c:1
+// RUN: %clang_cc1 -verify -fcf-protection=branch -target-feature +ibt 
-fsyntax-only %s
+

You likely need to specify an explicit triple here, or some of the bots fail 
this test because the attribute isn't supported on that architecture. You 
should also add a test that verifies the attribute isn't supported on non-x86 
platforms.



Comment at: test/Sema/attr-nocf_check.cpp:1
+// RUN: %clang_cc1 -verify -fcf-protection=branch -target-feature +ibt 
-fsyntax-only %s
+

aaron.ballman wrote:
> For better test coverage, you can switch to the `[[gnu::nocf_check]]` 
> spelling in this file and pass `-std=c++11`
This one also likely needs an explicit triple.


Repository:
  rL LLVM

https://reviews.llvm.org/D41880



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


r325942 - Fix one last test on a windows host.

2018-02-23 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Fri Feb 23 11:36:20 2018
New Revision: 325942

URL: http://llvm.org/viewvc/llvm-project?rev=325942&view=rev
Log:
Fix one last test on a windows host.

Modified:
cfe/trunk/test/CodeGenCUDA/filter-decl.cu

Modified: cfe/trunk/test/CodeGenCUDA/filter-decl.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/filter-decl.cu?rev=325942&r1=325941&r2=325942&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/filter-decl.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/filter-decl.cu Fri Feb 23 11:36:20 2018
@@ -21,7 +21,7 @@ __device__ char devicedata[256];
 // CHECK-DEVICE: shareddata = global
 __shared__ char shareddata[256];
 
-// CHECK-HOST: hostdata = global
+// CHECK-HOST: hostdata = {{(dso_local )?}}global
 // CHECK-DEVICE-NOT: hostdata = global
 char hostdata[256];
 


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


r325943 - Really fix test on windows.

2018-02-23 Thread Rafael Espindola via cfe-commits
Author: rafael
Date: Fri Feb 23 11:38:41 2018
New Revision: 325943

URL: http://llvm.org/viewvc/llvm-project?rev=325943&view=rev
Log:
Really fix test on windows.

Sorry for the noise.

Modified:
cfe/trunk/test/CodeGenCUDA/filter-decl.cu

Modified: cfe/trunk/test/CodeGenCUDA/filter-decl.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/filter-decl.cu?rev=325943&r1=325942&r2=325943&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/filter-decl.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/filter-decl.cu Fri Feb 23 11:38:41 2018
@@ -10,15 +10,15 @@
 __asm__("file scope asm is host only");
 
 // CHECK-HOST: constantdata = internal global
-// CHECK-DEVICE: constantdata = externally_initialized global
+// CHECK-DEVICE: constantdata = {{(dso_local )?}}externally_initialized global
 __constant__ char constantdata[256];
 
 // CHECK-HOST: devicedata = internal global
-// CHECK-DEVICE: devicedata = externally_initialized global
+// CHECK-DEVICE: devicedata = {{(dso_local )?}}externally_initialized global
 __device__ char devicedata[256];
 
 // CHECK-HOST: shareddata = internal global
-// CHECK-DEVICE: shareddata = global
+// CHECK-DEVICE: shareddata = {{(dso_local )?}}global
 __shared__ char shareddata[256];
 
 // CHECK-HOST: hostdata = {{(dso_local )?}}global


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


[PATCH] D41316: [libcxx] Allow random_device to be built optionally

2018-02-23 Thread Weiming Zhao via Phabricator via cfe-commits
weimingz added a comment.

ping?


https://reviews.llvm.org/D41316



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


Re: [PATCH] D42217: Set Module Metadata "AvoidPLT" when -fno-plt is used.

2018-02-23 Thread Rafael Avila de Espindola via cfe-commits
Sriraman Tallam via Phabricator  writes:
> +  if (CodeGenOpts.NoPLT) {
> +getModule().setAvoidPLT();
> +  }
> +

You don't need the {}.

LGTM with that.

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


Re: [PATCH] D42217: Set Module Metadata "AvoidPLT" when -fno-plt is used.

2018-02-23 Thread Sriraman Tallam via cfe-commits
On Fri, Feb 23, 2018 at 11:54 AM, Rafael Avila de Espindola
 wrote:
> Sriraman Tallam via Phabricator  writes:
>> +  if (CodeGenOpts.NoPLT) {
>> +getModule().setAvoidPLT();
>> +  }
>> +
>
> You don't need the {}.
>
> LGTM with that.

Thanks!
Sri

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


[PATCH] D43545: [Driver] Make -fno-common default for Fuchsia

2018-02-23 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325945: [Driver] Make -fno-common default for Fuchsia 
(authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43545?vs=135193&id=135675#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43545

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/fuchsia.c


Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -10,6 +10,7 @@
 // CHECK: "-fuse-init-array"
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: "-fno-common"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1306,6 +1306,8 @@
 static bool isNoCommonDefault(const llvm::Triple &Triple) {
   switch (Triple.getArch()) {
   default:
+if (Triple.isOSFuchsia())
+  return true;
 return false;
 
   case llvm::Triple::xcore:


Index: cfe/trunk/test/Driver/fuchsia.c
===
--- cfe/trunk/test/Driver/fuchsia.c
+++ cfe/trunk/test/Driver/fuchsia.c
@@ -10,6 +10,7 @@
 // CHECK: "-fuse-init-array"
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: "-fno-common"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -1306,6 +1306,8 @@
 static bool isNoCommonDefault(const llvm::Triple &Triple) {
   switch (Triple.getArch()) {
   default:
+if (Triple.isOSFuchsia())
+  return true;
 return false;
 
   case llvm::Triple::xcore:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325945 - [Driver] Make -fno-common default for Fuchsia

2018-02-23 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Fri Feb 23 12:10:14 2018
New Revision: 325945

URL: http://llvm.org/viewvc/llvm-project?rev=325945&view=rev
Log:
[Driver] Make -fno-common default for Fuchsia

We never want to generate common symbols on Fuchsia.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/fuchsia.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=325945&r1=325944&r2=325945&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Feb 23 12:10:14 2018
@@ -1306,6 +1306,8 @@ static bool isSignedCharDefault(const ll
 static bool isNoCommonDefault(const llvm::Triple &Triple) {
   switch (Triple.getArch()) {
   default:
+if (Triple.isOSFuchsia())
+  return true;
 return false;
 
   case llvm::Triple::xcore:

Modified: cfe/trunk/test/Driver/fuchsia.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=325945&r1=325944&r2=325945&view=diff
==
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Fri Feb 23 12:10:14 2018
@@ -10,6 +10,7 @@
 // CHECK: "-fuse-init-array"
 // CHECK: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]{{/|}}include"
+// CHECK: "-fno-common"
 // CHECK: {{.*}}ld.lld{{.*}}" "-z" "rodynamic"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"


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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-23 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135678.
juliehockett marked 29 inline comments as done.
juliehockett added a comment.

1. Continued refactoring the bitcode writer
2. Added a USR attribute to infos
3. Created a Reference struct to replace the string references to other infos


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,32 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@U@D'
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
+
+
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@c.bc --dump | FileCheck %s
+
+struct C { int i; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@C'
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
+
+
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@n...@a.bc --dump | FileCheck %s
+
+namespace A {}
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@N@A'
+  // CHECK:  blob data = 'A'
+// CHECK: 
+
+
+
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,33 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@S@G@F@Method#I#.bc --dump | FileCheck %s
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@G@F@Method#I#'
+  // CHECK:  blob data = 'Method'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@G'
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
+
+
+
Index: test/clang-doc/mapper-function.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-function.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@F@F#I#.bc --dump | FileCheck %s
+
+int F(int param) { return param; }
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@F@F#I#'
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
+
+
+
Index: test/clang-doc/mapper-enum.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-enum.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+

[PATCH] D41102: Setup clang-doc frontend framework

2018-02-23 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

In https://reviews.llvm.org/D41102#1017499, @Athosvk wrote:

> Disadvantage is of course that you add complexity to certain parts of the 
> deserialization (/serialization) for nested types and inheritance, by either 
> having to do so in the correct order or having to defer the process of 
> initializing these pointers. But see this as just as some thought sharing. I 
> do think this would improve the interaction in the backend (assuming you use 
> the same representation as currently in the frontend).


I agree that the pointer approach would be much more efficient on the backend, 
but the issue here is that the mapper has no idea where the representation of 
anything other than the decl it's currently looking at will be, since it sees 
each decl and serializes it immediately. The reducer, on the other hand, will 
be able to see everything, and so such pointers could be added as a pass over 
the final reduced data structure.
So, as an idea (as this diff implements), I updated the string references to be 
a struct, which holds the USR of the referenced type (for serialization, both 
here in the mapper and for the dump option in the reducer, as well as a pointer 
to an `Info` struct. This pointer is not used at this point, but would be 
populated by the reducer. Thoughts?

> Have you actually started work already on some backend? Developing backend 
> and frontend in tandem can provide some additional insights as to how things 
> should be structured, especially representation-wise!

I added you as a subscriber on the follow-up patches (the reducer, YAML/MD 
formats) -- would love to hear your thoughts! As of now, the MD output is very 
rough, but I'm hoping to keep moving forward on that in the next few days.




Comment at: clang-doc/BitcodeWriter.h:53
+  BI_LAST = BI_COMMENT_BLOCK_ID
+};
+

lebedev.ri wrote:
> So what *exactly* does `BitCodeConstants::SubblockIDSize` mean?
> ```
> static_assert(BI_LAST < (1U << BitCodeConstants::SubblockIDSize), "Too many 
> block id's!");
> ```
> ?
It's the current abbrev id width for the block (described [[ 
https://llvm.org/docs/BitCodeFormat.html#enter-subblock-encoding | here ]]), so 
it's the max id width for the block's abbrevs.



Comment at: clang-doc/BitcodeWriter.h:94
+  FUNCTION_LOCATION,
+  FUNCTION_MANGLED_NAME,
+  FUNCTION_PARENT,

lebedev.ri wrote:
> So i have a question: if something (`FUNCTION_MANGLED_NAME` in this case) is 
> phased out, does it have to stay in this enum?
> That will introduce holes in `RecordIdNameMap`.
> Are the actual numerical id's of enumerators stored in the bitcode, or the 
> string (abbrev, `RecordIdNameMap[].Name`)?
> 
> Looking at tests, i guess these enums are internal detail, and they can be 
> changed freely, including removing enumerators.
> Am i wrong?
> 
> I think that should be explained in a comment before this `enum`.
Yes, the enum is an implementation detail (`FUNCTION_MANGLED_NAME` should have 
been removed earlier). I'll put the comment describing how it works!


https://reviews.llvm.org/D41102



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-23 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 135682.
juliehockett added a comment.

Fixing CMakeLists formatting


https://reviews.llvm.org/D41102

Files:
  CMakeLists.txt
  clang-doc/BitcodeWriter.cpp
  clang-doc/BitcodeWriter.h
  clang-doc/CMakeLists.txt
  clang-doc/ClangDoc.h
  clang-doc/Mapper.cpp
  clang-doc/Mapper.h
  clang-doc/Representation.h
  clang-doc/tool/CMakeLists.txt
  clang-doc/tool/ClangDocMain.cpp
  docs/clang-doc.rst
  test/CMakeLists.txt
  test/clang-doc/mapper-class.cpp
  test/clang-doc/mapper-enum.cpp
  test/clang-doc/mapper-function.cpp
  test/clang-doc/mapper-method.cpp
  test/clang-doc/mapper-namespace.cpp
  test/clang-doc/mapper-struct.cpp
  test/clang-doc/mapper-union.cpp

Index: test/clang-doc/mapper-union.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-union.cpp
@@ -0,0 +1,32 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@u...@d.bc --dump | FileCheck %s
+
+union D { int X; int Y; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@U@D'
+  // CHECK:  blob data = 'D'
+  // CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::X'
+// CHECK: 
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'D::Y'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
+
+
Index: test/clang-doc/mapper-struct.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-struct.cpp
@@ -0,0 +1,26 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@s...@c.bc --dump | FileCheck %s
+
+struct C { int i; };
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@C'
+  // CHECK:  blob data = 'C'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'C::i'
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+
+
+
+
Index: test/clang-doc/mapper-namespace.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-namespace.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@n...@a.bc --dump | FileCheck %s
+
+namespace A {}
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@N@A'
+  // CHECK:  blob data = 'A'
+// CHECK: 
+
+
+
Index: test/clang-doc/mapper-method.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-method.cpp
@@ -0,0 +1,33 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@S@G@F@Method#I#.bc --dump | FileCheck %s
+
+class G {
+public: 
+	int Method(int param) { return param; }
+};
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@S@G@F@Method#I#'
+  // CHECK:  blob data = 'Method'
+  // CHECK: 
+  // CHECK:  blob data = 'c:@S@G'
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
+
+
+
Index: test/clang-doc/mapper-function.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-function.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcanalyzer %t/docs/c:@F@F#I#.bc --dump | FileCheck %s
+
+int F(int param) { return param; }
+// CHECK: 
+// CHECK: 
+  // CHECK: 
+// CHECK: 
+// CHECK: 
+  // CHECK:  blob data = 'c:@F@F#I#'
+  // CHECK:  blob data = 'F'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+  // CHECK: 
+  // CHECK: 
+// CHECK:  blob data = 'int'
+// CHECK:  blob data = 'param'
+  // CHECK: 
+// CHECK: 
+
+
+
+
+
Index: test/clang-doc/mapper-enum.cpp
===
--- /dev/null
+++ test/clang-doc/mapper-enum.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "" > %t/compile_flags.txt
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-doc --dump --omit-filenames -doxygen -p %t %t/test.cpp -output=%t/docs
+// RUN: llvm-bcana

r325961 - Set Module Metadata "RtLibUseGOT" when fno-plt is used.

2018-02-23 Thread Sriraman Tallam via cfe-commits
Author: tmsriram
Date: Fri Feb 23 13:27:33 2018
New Revision: 325961

URL: http://llvm.org/viewvc/llvm-project?rev=325961&view=rev
Log:
Set Module Metadata "RtLibUseGOT" when fno-plt is used.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/noplt.c

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=325961&r1=325960&r2=325961&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Feb 23 13:27:33 2018
@@ -555,6 +555,9 @@ void CodeGenModule::Release() {
   getModule().setPIELevel(static_cast(PLevel));
   }
 
+  if (CodeGenOpts.NoPLT)
+getModule().setRtLibUseGOT();
+
   SimplifyPersonality();
 
   if (getCodeGenOpts().EmitDeclMetadata)

Modified: cfe/trunk/test/CodeGen/noplt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/noplt.c?rev=325961&r1=325960&r2=325961&view=diff
==
--- cfe/trunk/test/CodeGen/noplt.c (original)
+++ cfe/trunk/test/CodeGen/noplt.c Fri Feb 23 13:27:33 2018
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT
+// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT -check-prefix=CHECK-NOPLT-METADATA
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
 // CHECK-NOPLT-NEXT: declare {{.*}}i32 @foo
+// CHECK-NOPLT-METADATA: !"RtLibUseGOT"
 int foo();
 
 int bar() {


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


[PATCH] D42217: Set Module Metadata "AvoidPLT" when -fno-plt is used.

2018-02-23 Thread Sriraman Tallam via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325961: Set Module Metadata "RtLibUseGOT" when 
fno-plt is used. (authored by tmsriram, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42217?vs=135144&id=135689#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42217

Files:
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/test/CodeGen/noplt.c


Index: cfe/trunk/test/CodeGen/noplt.c
===
--- cfe/trunk/test/CodeGen/noplt.c
+++ cfe/trunk/test/CodeGen/noplt.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT
+// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s 
-check-prefix=CHECK-NOPLT -check-prefix=CHECK-NOPLT-METADATA
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
 // CHECK-NOPLT-NEXT: declare {{.*}}i32 @foo
+// CHECK-NOPLT-METADATA: !"RtLibUseGOT"
 int foo();
 
 int bar() {
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -555,6 +555,9 @@
   getModule().setPIELevel(static_cast(PLevel));
   }
 
+  if (CodeGenOpts.NoPLT)
+getModule().setRtLibUseGOT();
+
   SimplifyPersonality();
 
   if (getCodeGenOpts().EmitDeclMetadata)


Index: cfe/trunk/test/CodeGen/noplt.c
===
--- cfe/trunk/test/CodeGen/noplt.c
+++ cfe/trunk/test/CodeGen/noplt.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s -check-prefix=CHECK-NOPLT
+// RUN: %clang_cc1 -emit-llvm -fno-plt %s -o - | FileCheck %s -check-prefix=CHECK-NOPLT -check-prefix=CHECK-NOPLT-METADATA
 
 // CHECK-NOPLT: Function Attrs: nonlazybind
 // CHECK-NOPLT-NEXT: declare {{.*}}i32 @foo
+// CHECK-NOPLT-METADATA: !"RtLibUseGOT"
 int foo();
 
 int bar() {
Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -555,6 +555,9 @@
   getModule().setPIELevel(static_cast(PLevel));
   }
 
+  if (CodeGenOpts.NoPLT)
+getModule().setRtLibUseGOT();
+
   SimplifyPersonality();
 
   if (getCodeGenOpts().EmitDeclMetadata)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D37797: Fix crash in Sema when wrongly assuming VarDecl init is not value dependent.

2018-02-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Could you double-check if we can add this to an existing test? Would 
`test/SemaCXX/pr25181-crash-on-invalid.cpp` fit and potentially rename it.




Comment at: test/SemaCXX/cxx11-odr-use-crash-on-invalid.cpp:8
+c : d() { // expected-error {{unexpected ':'}} \
+// expected-error {{nested name specifier 
'c::' for declaration does not refer}}
+  c &e = b;

Looks like this line has spacing problems.


https://reviews.llvm.org/D37797



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


[PATCH] D43696: Reduce hash collisions for reference and pointer types

2018-02-23 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: rtrieu, rsmith.

While investigating the work done in D41416  I 
found out that the hash values for pointer and reference types are the same.


Repository:
  rC Clang

https://reviews.llvm.org/D43696

Files:
  lib/AST/ODRHash.cpp


Index: lib/AST/ODRHash.cpp
===
--- lib/AST/ODRHash.cpp
+++ lib/AST/ODRHash.cpp
@@ -577,7 +577,19 @@
 Inherited::Visit(T);
   }
 
-  void VisitType(const Type *T) {}
+  void VisitType(const Type *T) {
+ID.AddInteger(T->getTypeClass());
+  }
+
+  void VisitPointerType(const PointerType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);
+  }
+
+  void VisitReferenceType(const ReferenceType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);
+  }
 
   void VisitAdjustedType(const AdjustedType *T) {
 AddQualType(T->getOriginalType());


Index: lib/AST/ODRHash.cpp
===
--- lib/AST/ODRHash.cpp
+++ lib/AST/ODRHash.cpp
@@ -577,7 +577,19 @@
 Inherited::Visit(T);
   }
 
-  void VisitType(const Type *T) {}
+  void VisitType(const Type *T) {
+ID.AddInteger(T->getTypeClass());
+  }
+
+  void VisitPointerType(const PointerType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);
+  }
+
+  void VisitReferenceType(const ReferenceType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);
+  }
 
   void VisitAdjustedType(const AdjustedType *T) {
 AddQualType(T->getOriginalType());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32111: [modules] Attempt to fix PR31905 - #include "stddef.h" breaks module map search paths; causes redefinitions.

2018-02-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Serialization/ASTReader.cpp:2554-2556
+  Module *M = PP.getHeaderSearchInfo().lookupModule(
+  F.ModuleName,
+  /*AllowSearch*/ true, /*SearchTopLevelOnly*/ true);

This is only trying to catch the case where we've already loaded a module map 
for the module and the two conflict. We should just set `AllowSearch` to 
`false` here. If we want to also perform validation on the case where we load 
the module map after importing another definition, that should be handled 
if/when we load the module map.


https://reviews.llvm.org/D32111



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


r325966 - [CFG] [analyzer] NFC: Allow more complicated construction contexts.

2018-02-23 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Feb 23 14:20:39 2018
New Revision: 325966

URL: http://llvm.org/viewvc/llvm-project?rev=325966&view=rev
Log:
[CFG] [analyzer] NFC: Allow more complicated construction contexts.

ConstructionContexts introduced in D42672 are an additional piece of information
included with CFGConstructor elements that help the client of the CFG (such as
the Static Analyzer) understand where the newly constructed object is stored.

The patch refactors the ConstructionContext class to prepare for including
multi-layered contexts that are being constructed gradually, layer-by-layer,
as the AST is traversed.

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

Modified:
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=325966&r1=325965&r2=325966&view=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Fri Feb 23 14:20:39 2018
@@ -155,14 +155,35 @@ private:
   // new-expression triggers construction of the newly allocated object(s).
   TriggerTy Trigger;
 
-public:
+  // Sometimes a single trigger is not enough to describe the construction 
site.
+  // In this case we'd have a chain of "partial" construction contexts.
+  // Some examples:
+  // - A constructor within in an aggregate initializer list within a variable
+  //   would have a construction context of the initializer list with the 
parent
+  //   construction context of a variable.
+  // - A constructor for a temporary that needs to be both destroyed
+  //   and materialized into an elidable copy constructor would have a
+  //   construction context of a CXXBindTemporaryExpr with the parent
+  //   construction context of a MaterializeTemproraryExpr.
+  // Not all of these are currently supported.
+  const ConstructionContext *Parent = nullptr;
+
   ConstructionContext() = default;
-  ConstructionContext(TriggerTy Trigger)
-  : Trigger(Trigger) {}
+  ConstructionContext(TriggerTy Trigger, const ConstructionContext *Parent)
+  : Trigger(Trigger), Parent(Parent) {}
+
+public:
+  static const ConstructionContext *
+  create(BumpVectorContext &C, TriggerTy Trigger,
+ const ConstructionContext *Parent = nullptr) {
+ConstructionContext *CC = C.getAllocator().Allocate();
+return new (CC) ConstructionContext(Trigger, Parent);
+  }
 
   bool isNull() const { return Trigger.isNull(); }
 
   TriggerTy getTrigger() const { return Trigger; }
+  const ConstructionContext *getParent() const { return Parent; }
 
   const Stmt *getTriggerStmt() const {
 return Trigger.dyn_cast();
@@ -172,10 +193,27 @@ public:
 return Trigger.dyn_cast();
   }
 
-  const ConstructionContext *getPersistentCopy(BumpVectorContext &C) const {
-ConstructionContext *CC = C.getAllocator().Allocate();
-*CC = *this;
-return CC;
+  bool isSameAsPartialContext(const ConstructionContext *Other) const {
+assert(Other);
+return (Trigger == Other->Trigger);
+  }
+
+  // See if Other is a proper initial segment of this construction context
+  // in terms of the parent chain - i.e. a few first parents coincide and
+  // then the other context terminates but our context goes further - i.e.,
+  // we are providing the same context that the other context provides,
+  // and a bit more above that.
+  bool isStrictlyMoreSpecificThan(const ConstructionContext *Other) const {
+const ConstructionContext *Self = this;
+while (true) {
+  if (!Other)
+return Self;
+  if (!Self || !Self->isSameAsPartialContext(Other))
+return false;
+  Self = Self->getParent();
+  Other = Other->getParent();
+}
+llvm_unreachable("The above loop can only be terminated via return!");
   }
 };
 
@@ -834,9 +872,9 @@ public:
 Elements.push_back(CFGStmt(statement), C);
   }
 
-  void appendConstructor(CXXConstructExpr *CE, const ConstructionContext &CC,
+  void appendConstructor(CXXConstructExpr *CE, const ConstructionContext *CC,
  BumpVectorContext &C) {
-Elements.push_back(CFGConstructor(CE, CC.getPersistentCopy(C)), C);
+Elements.push_back(CFGConstructor(CE, CC), C);
   }
 
   void appendInitializer(CXXCtorInitializer *initializer,

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=325966&r1=325965&r2=325966&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Feb 23 14:20:39 2018
@@ -475,7 +475,8 @@ class CFGBuilder {
   // Information about the currently visited C++ object construction site.
   // This is set in the construction trigger and read when the constructor
   // itself is being visited.
-  ConstructionC

[PATCH] D43428: [CFG] [analyzer] NFC: Allow more complicated construction contexts.

2018-02-23 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325966: [CFG] [analyzer] NFC: Allow more complicated 
construction contexts. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43428?vs=134785&id=135701#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43428

Files:
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/lib/Analysis/CFG.cpp

Index: cfe/trunk/include/clang/Analysis/CFG.h
===
--- cfe/trunk/include/clang/Analysis/CFG.h
+++ cfe/trunk/include/clang/Analysis/CFG.h
@@ -155,14 +155,35 @@
   // new-expression triggers construction of the newly allocated object(s).
   TriggerTy Trigger;
 
-public:
+  // Sometimes a single trigger is not enough to describe the construction site.
+  // In this case we'd have a chain of "partial" construction contexts.
+  // Some examples:
+  // - A constructor within in an aggregate initializer list within a variable
+  //   would have a construction context of the initializer list with the parent
+  //   construction context of a variable.
+  // - A constructor for a temporary that needs to be both destroyed
+  //   and materialized into an elidable copy constructor would have a
+  //   construction context of a CXXBindTemporaryExpr with the parent
+  //   construction context of a MaterializeTemproraryExpr.
+  // Not all of these are currently supported.
+  const ConstructionContext *Parent = nullptr;
+
   ConstructionContext() = default;
-  ConstructionContext(TriggerTy Trigger)
-  : Trigger(Trigger) {}
+  ConstructionContext(TriggerTy Trigger, const ConstructionContext *Parent)
+  : Trigger(Trigger), Parent(Parent) {}
+
+public:
+  static const ConstructionContext *
+  create(BumpVectorContext &C, TriggerTy Trigger,
+ const ConstructionContext *Parent = nullptr) {
+ConstructionContext *CC = C.getAllocator().Allocate();
+return new (CC) ConstructionContext(Trigger, Parent);
+  }
 
   bool isNull() const { return Trigger.isNull(); }
 
   TriggerTy getTrigger() const { return Trigger; }
+  const ConstructionContext *getParent() const { return Parent; }
 
   const Stmt *getTriggerStmt() const {
 return Trigger.dyn_cast();
@@ -172,10 +193,27 @@
 return Trigger.dyn_cast();
   }
 
-  const ConstructionContext *getPersistentCopy(BumpVectorContext &C) const {
-ConstructionContext *CC = C.getAllocator().Allocate();
-*CC = *this;
-return CC;
+  bool isSameAsPartialContext(const ConstructionContext *Other) const {
+assert(Other);
+return (Trigger == Other->Trigger);
+  }
+
+  // See if Other is a proper initial segment of this construction context
+  // in terms of the parent chain - i.e. a few first parents coincide and
+  // then the other context terminates but our context goes further - i.e.,
+  // we are providing the same context that the other context provides,
+  // and a bit more above that.
+  bool isStrictlyMoreSpecificThan(const ConstructionContext *Other) const {
+const ConstructionContext *Self = this;
+while (true) {
+  if (!Other)
+return Self;
+  if (!Self || !Self->isSameAsPartialContext(Other))
+return false;
+  Self = Self->getParent();
+  Other = Other->getParent();
+}
+llvm_unreachable("The above loop can only be terminated via return!");
   }
 };
 
@@ -834,9 +872,9 @@
 Elements.push_back(CFGStmt(statement), C);
   }
 
-  void appendConstructor(CXXConstructExpr *CE, const ConstructionContext &CC,
+  void appendConstructor(CXXConstructExpr *CE, const ConstructionContext *CC,
  BumpVectorContext &C) {
-Elements.push_back(CFGConstructor(CE, CC.getPersistentCopy(C)), C);
+Elements.push_back(CFGConstructor(CE, CC), C);
   }
 
   void appendInitializer(CXXCtorInitializer *initializer,
Index: cfe/trunk/lib/Analysis/CFG.cpp
===
--- cfe/trunk/lib/Analysis/CFG.cpp
+++ cfe/trunk/lib/Analysis/CFG.cpp
@@ -475,7 +475,8 @@
   // Information about the currently visited C++ object construction site.
   // This is set in the construction trigger and read when the constructor
   // itself is being visited.
-  ConstructionContext CurrentConstructionContext = {};
+  llvm::DenseMap
+  ConstructionContextMap{};
 
   bool badCFG = false;
   const CFG::BuildOptions &BuildOpts;
@@ -654,12 +655,12 @@
   // to the trigger statement. The construction context will be unset once
   // it is consumed when the CFG building procedure processes the
   // construct-expression and adds the respective CFGConstructor element.
-  void EnterConstructionContextIfNecessary(
-  ConstructionContext::TriggerTy Trigger, Stmt *Child);
+  void findConstructionContexts(const ConstructionContext *ContextSoFar,
+Stmt *Child);
   // Unset the construction context after consuming i

[PATCH] D43673: Make module use diagnostics refer to the top-level module

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

Makes sense -- as dependencies can only be declared on top-level modules, 
that's what we should be talking about here.


https://reviews.llvm.org/D43673



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


[PATCH] D41228: [ObjC] Enable __strong pointers in structs under ARC

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

Address review comments.


https://reviews.llvm.org/D41228

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Decl.h
  include/clang/AST/Type.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/AST/Decl.cpp
  lib/AST/Type.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGNonTrivialStruct.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.h
  lib/Lex/PPMacroExpansion.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  test/ARCMT/checking.m
  test/CodeGenObjC/nontrivial-c-struct-exception.m
  test/CodeGenObjC/nontrivial-c-struct-func-name-collision.m
  test/CodeGenObjC/strong-in-c-struct.m
  test/Lexer/has_feature_objc_arc.m
  test/SemaObjC/arc-decls.m
  test/SemaObjC/arc-system-header.m
  test/SemaObjC/strong-in-c-struct.m

Index: test/SemaObjC/strong-in-c-struct.m
===
--- /dev/null
+++ test/SemaObjC/strong-in-c-struct.m
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -fblocks  -fobjc-runtime=ios-11.0 -fsyntax-only -verify %s
+
+typedef struct {
+  id a;
+} Strong;
+
+void callee_variadic(const char *, ...);
+
+void test_variadic(void) {
+  Strong t;
+  callee_variadic("s", t); // expected-error {{cannot pass non-trivial C object of type 'Strong' by value to variadic function}}
+}
+
+void test_jump0(int cond) {
+  switch (cond) {
+  case 0:
+;
+Strong x; // expected-note {{jump bypasses initialization of variable of non-trivial C struct type}}
+break;
+  case 1: // expected-error {{cannot jump from switch statement to this case label}}
+x.a = 0;
+break;
+  }
+}
+
+void test_jump1(void) {
+  static void *ips[] = { &&L0 };
+L0:  // expected-note {{possible target of indirect goto}}
+  ;
+  Strong x; // expected-note {{jump exits scope of variable with non-trivial destructor}}
+  goto *ips; // expected-error {{cannot jump}}
+}
+
+typedef void (^BlockTy)(void);
+void func(BlockTy);
+void func2(Strong);
+
+void test_block_scope0(int cond) {
+  Strong x; // expected-note {{jump enters lifetime of block which captures a C struct that is non-trivial to destroy}}
+  switch (cond) {
+  case 0:
+func(^{ func2(x); });
+break;
+  default: // expected-error {{cannot jump from switch statement to this case label}}
+break;
+  }
+}
+
+void test_block_scope1(void) {
+  static void *ips[] = { &&L0 };
+L0:  // expected-note {{possible target of indirect goto}}
+  ;
+  Strong x; // expected-note {{jump exits scope of variable with non-trivial destructor}} expected-note {{jump exits lifetime of block which captures a C struct that is non-trivial to destroy}}
+  func(^{ func2(x); });
+  goto *ips; // expected-error {{cannot jump}}
+}
Index: test/SemaObjC/arc-system-header.m
===
--- test/SemaObjC/arc-system-header.m
+++ test/SemaObjC/arc-system-header.m
@@ -23,8 +23,7 @@
 }
 
 void test5(struct Test5 *p) {
-  p->field = 0; // expected-error {{'field' is unavailable in ARC}}
-// expected-note@arc-system-header.h:25 {{field has non-trivial ownership qualification}}
+  p->field = 0;
 }
 
 id test6() {
@@ -49,8 +48,7 @@
 
 extern void doSomething(Test9 arg);
 void test9() {
-Test9 foo2 = {0, 0}; // expected-error {{'field' is unavailable in ARC}}
- // expected-note@arc-system-header.h:56 {{field has non-trivial ownership qualification}}
+Test9 foo2 = {0, 0};
 doSomething(foo2);
 }
 #endif
Index: test/SemaObjC/arc-decls.m
===
--- test/SemaObjC/arc-decls.m
+++ test/SemaObjC/arc-decls.m
@@ -3,7 +3,7 @@
 // rdar://8843524
 
 struct A {
-id x; // expected-error {{ARC forbids Objective-C objects in struct}}
+id x;
 };
 
 union u {
@@ -13,7 +13,7 @@
 @interface I {
struct A a; 
struct B {
-id y[10][20]; // expected-error {{ARC forbids Objective-C objects in struct}}
+id y[10][20];
 id z;
} b;
 
@@ -23,7 +23,7 @@
 
 // rdar://10260525
 struct r10260525 {
-  id (^block) (); // expected-error {{ARC forbids blocks in struct}}
+  id (^block) ();
 };
 
 struct S { 
Index: test/Lexer/has_feature_objc_arc.m
===
--- test/Lexer/has_feature_objc_arc.m
+++ test/Lexer/has_feature_objc_arc.m
@@ -13,8 +13,16 @@
 void no_objc_arc_weak_feature();
 #endif
 
+#if __has_feature(objc_arc_fields)
+void has_objc_arc_fields();
+#else
+void no_objc_arc_fields();
+#endif
+
 // CHECK-ARC: void has_objc_arc_feature();
 // CHECK-ARC: void has_objc_arc_weak_feature();
+// CHECK-ARC: void has_objc_arc_fields();
 
 // CHECK-ARCLITE: void has_objc_arc_feature();
 // CHECK-ARCLITE: void no_ob

[PATCH] D41228: [ObjC] Enable __strong pointers in structs under ARC

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



Comment at: include/clang/AST/Type.h:1108
+PCK_ARCStrong,  // objc strong pointer.
+PCK_Struct   // non-trivial C struct.
+  };

rjmccall wrote:
> These should all be /// documentation comments, and they mostly shouldn't 
> talk about fields since this is a query on QualType, not FieldDecl.  I would 
> suggest something like:
> 
> for Trivial - The type does not fall into any of the following categories.  
> Note that this case is zero-valued so that values of this enum can be used as 
> a boolean condition for non-triviality.
> 
> for VolatileTrivial - The type would be trivial except that it is 
> volatile-qualified.  Types that fall into one of the other non-trivial cases 
> may additionally be volatile-qualified.
> 
> for ARCStrong - The type is an Objective-C retainable pointer type that is 
> qualified with the ARC __strong qualifier.
> 
> for Struct - The type is a struct containing a field whose type is not 
> PCK_Trivial.  Note that a C++ struct type does not necessarily match this; 
> C++ copying semantics are too complex to express here, in part because they 
> depend on the exact constructor or assignment operator that is chosen by 
> overload resolution to do the copy.
Thanks, I copied your comments verbatim except the comment on PCK_Struct: types 
that are PCK_Struct have a field that is neither PCK_Trivial nor 
PCK_VolatileTrivial. We can use the original comment once we start 
distinguishing PCK_Trivial structs that have volatile fields from those that 
don't. 



Comment at: lib/CodeGen/CGBlocks.cpp:1779
+break;
   }
 

rjmccall wrote:
> This entire switch can be within an `#ifndef NDEBUG` if you really feel it's 
> important to assert.
It's probably not important to assert here, so I removed the switch.



Comment at: lib/CodeGen/CGBlocks.cpp:1792
+return std::make_pair(BlockCaptureEntityKind::BlockObject,
+  getBlockFieldFlagsForObjCObjectPointer(CI, T));
 

rjmccall wrote:
> I think you should leave the byref case of that function here, but you can 
> make it local to this if-clause.
I also simplified the QualType::DK_none case below.



Comment at: lib/CodeGen/CGDecl.cpp:1421
+destroyer = CodeGenFunction::destroyNonTrivialCStruct;
+cleanupKind = getARCCleanupKind();
+break;

rjmccall wrote:
> rjmccall wrote:
> > rjmccall wrote:
> > > ahatanak wrote:
> > > > rjmccall wrote:
> > > > > This can only be getARCCleanupKind() if it's non-trivial to destroy 
> > > > > solely because of __strong members.  Since the setup here is 
> > > > > significantly more general than ARC, I think you need to default to 
> > > > > the more-correct behavior; if you want to add a special-case check 
> > > > > for only __strong members, you ought to do that explicitly.
> > > > I added a DestructionKind (DK_c_struct_strong_field) that is used just 
> > > > for structs that have strong fields (but doesn't have weak fields).
> > > Sure, that's a simple enough way to do it, and I think it's fairly 
> > > warranted.
> > Okay, since you don't have a DK_c_struct_strong_field anymore, you either 
> > need to stop using getARCCleanupKind() or do the test for just __strong 
> > fields.
> Ping about this again.
Sorry I missed this one.


https://reviews.llvm.org/D41228



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


[PATCH] D40218: [Clang] Add __builtin_launder

2018-02-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:1947-1948
+const auto *Record = ArgTy->getAsCXXRecordDecl();
+if (CGM.getCodeGenOpts().StrictVTablePointers && Record &&
+Record->isDynamicClass())
+  Ptr = Builder.CreateInvariantGroupBarrier(Ptr);

I think you also need to catch class types that contain dynamic classes as 
subobjects.



Comment at: lib/Sema/SemaChecking.cpp:860
+
+  int DiagSelect = [&]() {
+if (!ArgTy->isPointerType())

Might be a bit clearer to use `llvm::Optional` as the type of this.



Comment at: test/CodeGenCXX/builtin-launder.cpp:93-96
+/// The test cases in this namespace technically need to be laundered according
+/// to the language in the standard (ie they have const or reference 
subobjects)
+/// but LLVM doesn't currently optimize on these cases -- so Clang emits
+/// __builtin_launder as a nop.

I would note that this means adding optimizations for those cases later is an 
LTO ABI break. That's probably OK, but just something we're going to need to 
remember.


https://reviews.llvm.org/D40218



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


r325969 - [CFG] NFC: Speculative attempt to fix MSVC internal compiler error on buildbot.

2018-02-23 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Feb 23 14:49:25 2018
New Revision: 325969

URL: http://llvm.org/viewvc/llvm-project?rev=325969&view=rev
Log:
[CFG] NFC: Speculative attempt to fix MSVC internal compiler error on buildbot.

Don't use fancy initialization and member access in a DenseMap.

Modified:
cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=325969&r1=325968&r2=325969&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Feb 23 14:49:25 2018
@@ -476,7 +476,7 @@ class CFGBuilder {
   // This is set in the construction trigger and read when the constructor
   // itself is being visited.
   llvm::DenseMap
-  ConstructionContextMap{};
+  ConstructionContextMap;
 
   bool badCFG = false;
   const CFG::BuildOptions &BuildOpts;
@@ -497,7 +497,8 @@ public:
   explicit CFGBuilder(ASTContext *astContext,
   const CFG::BuildOptions &buildOpts)
   : Context(astContext), cfg(new CFG()), // crew a new CFG
-BuildOpts(buildOpts) {}
+ConstructionContextMap(), BuildOpts(buildOpts) {}
+
 
   // buildCFG - Used by external clients to construct the CFG.
   std::unique_ptr buildCFG(const Decl *D, Stmt *Statement);
@@ -1162,7 +1163,9 @@ void CFGBuilder::findConstructionContext
   assert(PreviousContext->isStrictlyMoreSpecificThan(ContextSoFar) &&
  "Already within a different construction context!");
 } else {
-  ConstructionContextMap[CE] = ContextSoFar;
+  auto Pair =
+  ConstructionContextMap.insert(std::make_pair(CE, ContextSoFar));
+  assert(Pair.second && "Already within a construction context!");
 }
   } else if (auto *Cleanups = dyn_cast(Child)) {
 findConstructionContexts(ContextSoFar, Cleanups->getSubExpr());


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


[PATCH] D42498: [ExprConstant] Fix crash when initialize an indirect field with another field.

2018-02-23 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 135708.
vsapsai added a comment.

- Override `This` for indirect field initializer more like it is done for 
`InitListExpr`.

I rebased my changes, so the diff between different versions can be noisy.


https://reviews.llvm.org/D42498

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constant-expression-cxx1y.cpp

Index: clang/test/SemaCXX/constant-expression-cxx1y.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1044,3 +1044,44 @@
   constexpr B b;
   constexpr int p = b.n; // expected-error {{constant expression}} expected-note {{mutable}}
 }
+
+namespace IndirectFields {
+
+// Reference indirect field.
+struct A {
+  struct {
+union {
+  int x = x = 3; // expected-note {{outside its lifetime}}
+};
+  };
+  constexpr A() {}
+};
+static_assert(A().x == 3, ""); // expected-error{{not an integral constant expression}} expected-note{{in call to 'A()'}}
+
+// Reference another indirect field, with different 'this'.
+struct B {
+  struct {
+union {
+  int x = 3;
+};
+int y = x;
+  };
+  constexpr B() {}
+};
+static_assert(B().y == 3, "");
+
+// Nested evaluation of indirect field initializers.
+struct C {
+  union {
+int x = 1;
+  };
+};
+struct D {
+  struct {
+C c;
+int y = c.x + 1;
+  };
+};
+static_assert(D().y == 2, "");
+
+} // namespace IndirectFields
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4383,6 +4383,7 @@
 #endif
   for (const auto *I : Definition->inits()) {
 LValue Subobject = This;
+LValue SubobjectParent = This;
 APValue *Value = &Result;
 
 // Determine the subobject to initialize.
@@ -4413,7 +4414,8 @@
 } else if (IndirectFieldDecl *IFD = I->getIndirectMember()) {
   // Walk the indirect field decl's chain to find the object to initialize,
   // and make sure we've initialized every step along it.
-  for (auto *C : IFD->chain()) {
+  auto IndirectFieldChain = IFD->chain();
+  for (auto *C : IndirectFieldChain) {
 FD = cast(C);
 CXXRecordDecl *CD = cast(FD->getParent());
 // Switch the union field if it differs. This happens if we had
@@ -4429,6 +4431,10 @@
 *Value = APValue(APValue::UninitStruct(), CD->getNumBases(),
  std::distance(CD->field_begin(), CD->field_end()));
 }
+// Store Subobject as its parent before updating it for the last element
+// in the chain.
+if (C == IndirectFieldChain.back())
+  SubobjectParent = Subobject;
 if (!HandleLValueMember(Info, I->getInit(), Subobject, FD))
   return false;
 if (CD->isUnion())
@@ -4440,10 +4446,16 @@
   llvm_unreachable("unknown base initializer kind");
 }
 
+// Need to override This for implicit field initializers as in this case
+// This refers to innermost anonymous struct/union containing initializer,
+// not to currently constructed class.
+const Expr *Init = I->getInit();
+ThisOverrideRAII ThisOverride(*Info.CurrentCall, &SubobjectParent,
+  isa(Init));
 FullExpressionRAII InitScope(Info);
-if (!EvaluateInPlace(*Value, Info, Subobject, I->getInit()) ||
-(FD && FD->isBitField() && !truncateBitfieldValue(Info, I->getInit(),
-  *Value, FD))) {
+if (!EvaluateInPlace(*Value, Info, Subobject, Init) ||
+(FD && FD->isBitField() &&
+ !truncateBitfieldValue(Info, Init, *Value, FD))) {
   // If we're checking for a potential constant expression, evaluate all
   // initializers even if some of them fail.
   if (!Info.noteFailure())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41102: Setup clang-doc frontend framework

2018-02-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Could you please add a bit more tests? In particular, i'd like to see how 
blocks-in-blocks work.
I.e. class-in-class, class-in-function, ...

Is there some (internal to `BitstreamWriter`) logic that would 'assert()' if 
trying to output some recordid
which is, according to the `BLOCKINFO_BLOCK`, should not be there?
E.g. outputting `VERSION` in `BI_COMMENT_BLOCK_ID`?




Comment at: clang-doc/BitcodeWriter.cpp:30
+
+static void IntAbbrev(std::shared_ptr &Abbrev) {
+  Abbrev->Add(llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed,

Ok, these three functions still look off, how about this?
```
// Yes, not by reference, https://godbolt.org/g/T52Vcj
static void AbbrevGen(std::shared_ptr &Abbrev,
  const std::initializer_list Ops) {
  for(const auto &Op : Ops)
Abbrev->Add(Op);
}

static void IntAbbrev(std::shared_ptr &Abbrev) {
  AbbrevGen(Abbrev, {
// 0. Fixed-size integer
{llvm::BitCodeAbbrevOp::Fixed, BitCodeConstants::IntSize}});
}

static void StringAbbrev(std::shared_ptr &Abbrev) {
  AbbrevGen(Abbrev, {
// 0. Fixed-size integer (length of the following string)
{llvm::BitCodeAbbrevOp::Fixed, BitCodeConstants::StringLengthSize},
// 1. The string blob
{llvm::BitCodeAbbrevOp::Blob}});
}

// Assumes that the file will not have more than 65535 lines.
static void LocationAbbrev(std::shared_ptr &Abbrev) {
  AbbrevGen(Abbrev, {
// 0. Fixed-size integer (line number)
{llvm::BitCodeAbbrevOp::Fixed, BitCodeConstants::LineNumberSize},
// 1. Fixed-size integer (length of the following string (filename))
{llvm::BitCodeAbbrevOp::Fixed, BitCodeConstants::StringLengthSize},
// 2. the string blob
{llvm::BitCodeAbbrevOp::Blob}});
}
```
Though i bet clang-format will mess-up the formatting again :/



Comment at: clang-doc/BitcodeWriter.cpp:108
+  {COMMENT_CLOSENAME, {"CloseName", &StringAbbrev}},
+  {COMMENT_SELFCLOSING, {"SelfClosing", &IntAbbrev}},
+  {COMMENT_EXPLICIT, {"Explicit", &IntAbbrev}},

Some of these `IntAbbrev`'s are actually `bool`s.
Would it make sense to already think about being bitcode-size-conservative and 
introduce `BoolAbbrev` from the get go?
```
static void BoolAbbrev(std::shared_ptr &Abbrev) {
  AbbrevGen(Abbrev, {
// 0. Fixed-size boolean
{llvm::BitCodeAbbrevOp::Fixed, BitCodeConstants::BoolSize}});
}
```
where `BitCodeConstants::BoolSize` = `1U`
 ?
Or is there some internal padding that would make that pointless?



Comment at: clang-doc/BitcodeWriter.cpp:156
+ unsigned AbbrevID) {
+  assert(RecordIdNameMap[RID] && "Unknown Abbreviation");
+  assert(Abbrevs.find(RID) == Abbrevs.end() && "Abbreviation already added.");

Uh, oh, i'm sorry, all(?) these `"Unknown Abbreviation"` are likely copypaste 
gone wrong.
I'm not sure why i wrote that comment. `"Unknown RecordId"` might make more 
sense?



Comment at: clang-doc/BitcodeWriter.cpp:240
+  if (!prepRecordData(ID, Val)) return;
+  assert(Val < (1U << BitCodeConstants::IntSize));
+  Record.push_back(Val);

Ok, now that i think about it, it can't be that easy.
Maybe
```
FIXME: assumes 8 bits per byte
assert(llvm::APInt(8U*sizeof(Val), Val, /*isSigned=*/true).getBitWidth() <= 
BitCodeConstants::IntSize));
```
Not sure whether `getBitWidth()` is really the right function to ask though.
(Not sure how this all works for negative numbers)



Comment at: clang-doc/BitcodeWriter.h:53
+  BI_LAST = BI_COMMENT_BLOCK_ID
+};
+

juliehockett wrote:
> lebedev.ri wrote:
> > So what *exactly* does `BitCodeConstants::SubblockIDSize` mean?
> > ```
> > static_assert(BI_LAST < (1U << BitCodeConstants::SubblockIDSize), "Too many 
> > block id's!");
> > ```
> > ?
> It's the current abbrev id width for the block (described [[ 
> https://llvm.org/docs/BitCodeFormat.html#enter-subblock-encoding | here ]]), 
> so it's the max id width for the block's abbrevs.
So in other words that `static_assert()` is doing the right thing?
Add it after the `enum BlockId{}` then please, will both document things, and 
ensure that things remain in a sane state.



Comment at: clang-doc/BitcodeWriter.h:172
+AbbreviationMap() : Abbrevs(RecordIdCount) {}
+void add(RecordId RID, unsigned AbbrevID);
+unsigned get(RecordId RID) const;

Newline after constructor



Comment at: clang-doc/BitcodeWriter.h:216
+
+  // Emission of different abbreviation types
+  void emitAbbrev(RecordId ID, BlockId Block);

`// Emission of appropriate abbreviation type`


https://reviews.llvm.org/D41102



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


[PATCH] D42766: [DebugInfo] Support DWARFv5 source code embedding extension

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

With https://reviews.llvm.org/D42765 committed I think this is ready for review.


Repository:
  rC Clang

https://reviews.llvm.org/D42766



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


[PATCH] D43584: [test] Permit additional CFLAGS for tests to be set via config.test_cflags.

2018-02-23 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb abandoned this revision.
bsdjhb added a comment.

Obsoleted by https://reviews.llvm.org/rCXX325914.


Repository:
  rCXX libc++

https://reviews.llvm.org/D43584



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


[PATCH] D42498: [ExprConstant] Fix crash when initialize an indirect field with another field.

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

Looks good, thanks!

In https://reviews.llvm.org/D42498#1015419, @vsapsai wrote:

> In https://reviews.llvm.org/D42498#1007028, @rsmith wrote:
>
> > [โ€ฆ] your approach will still go wrong if the `This` pointer is used in 
> > other ways, such as an explicit mention of `this` or a member function call.
>
>
> I wasn't able to find a failing test case. Maybe I misunderstood you but in 
> my testing functions declared in named structs had correct `This` pointer and 
> in anonymous structs functions cannot be declared.


Here's a testcase that fails today:

  struct A { int n = 0; struct { void *p = this; }; void *q = this; };
  constexpr A a = A();
  static_assert(a.p != a.q, ""); // fails today, should pass
  
  constexpr A b = A{0};
  static_assert(b.p != b.q, ""); // passes today

With the previous approach of fixing up the `This` value only in class member 
access, the above testcase would presumably still fail. I expect it to pass 
with your new approach.


https://reviews.llvm.org/D42498



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


[PATCH] D43585: [libunwind] Permit additional compiler flags to be passed to tests.

2018-02-23 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb marked 2 inline comments as done.
bsdjhb added a comment.

My only question is if this should be named LIBUNWIND_TEST_COMPILER_FLAGS to 
match the name used in libc++?


Repository:
  rUNW libunwind

https://reviews.llvm.org/D43585



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


[PATCH] D43585: [libunwind] Permit additional compiler flags to be passed to tests.

2018-02-23 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb updated this revision to Diff 135714.
bsdjhb added a comment.

- Use STRING instead of PATH.
- Update for committed libcxx change.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D43585

Files:
  CMakeLists.txt
  test/lit.site.cfg.in


Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -22,6 +22,7 @@
 config.sysroot  = "@LIBUNWIND_SYSROOT@"
 config.gcc_toolchain= "@LIBUNWIND_GCC_TOOLCHAIN@"
 config.cxx_ext_threads  = "@LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@"
+config.test_compiler_flags  = "@LIBUNWIND_TEST_CFLAGS@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBUNWIND_SOURCE_DIR@/test/lit.cfg")
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -139,6 +139,7 @@
 set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross 
compiling.")
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
 set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
+set(LIBUNWIND_TEST_CFLAGS "" CACHE STRING "Additional compiler flags for test 
programs.")
 
 if (NOT LIBUNWIND_ENABLE_SHARED AND NOT LIBUNWIND_ENABLE_STATIC)
   message(FATAL_ERROR "libunwind must be built as either a shared or static 
library.")


Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -22,6 +22,7 @@
 config.sysroot  = "@LIBUNWIND_SYSROOT@"
 config.gcc_toolchain= "@LIBUNWIND_GCC_TOOLCHAIN@"
 config.cxx_ext_threads  = "@LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@"
+config.test_compiler_flags  = "@LIBUNWIND_TEST_CFLAGS@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBUNWIND_SOURCE_DIR@/test/lit.cfg")
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -139,6 +139,7 @@
 set(LIBUNWIND_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.")
 set(LIBUNWIND_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.")
 set(LIBUNWIND_SYSROOT "" CACHE PATH "Sysroot for cross compiling.")
+set(LIBUNWIND_TEST_CFLAGS "" CACHE STRING "Additional compiler flags for test programs.")
 
 if (NOT LIBUNWIND_ENABLE_SHARED AND NOT LIBUNWIND_ENABLE_STATIC)
   message(FATAL_ERROR "libunwind must be built as either a shared or static library.")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325975 - [analyzer] Consider switch- and goto- labels when constructing the set of executed lines

2018-02-23 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Feb 23 15:26:54 2018
New Revision: 325975

URL: http://llvm.org/viewvc/llvm-project?rev=325975&view=rev
Log:
[analyzer] Consider switch- and goto- labels when constructing the set of 
executed lines

When viewing the report in the collapsed mode the label signifying where
did the execution go is often necessary for properly understanding the
context.

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

Added:
cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/goto.c
cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/switch.c
cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/switch_default.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=325975&r1=325974&r2=325975&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Fri Feb 23 15:26:54 2018
@@ -3547,6 +3547,16 @@ static void populateExecutedLinesWithFun
 ExecutedLines->operator[](FID.getHashValue()).insert(Line);
 }
 
+static void populateExecutedLinesWithStmt(
+const Stmt *S, SourceManager &SM,
+std::unique_ptr &ExecutedLines) {
+  SourceLocation Loc = S->getSourceRange().getBegin();
+  SourceLocation ExpansionLoc = SM.getExpansionLoc(Loc);
+  FileID FID = SM.getFileID(ExpansionLoc);
+  unsigned LineNo = SM.getExpansionLineNumber(ExpansionLoc);
+  ExecutedLines->operator[](FID.getHashValue()).insert(LineNo);
+}
+
 /// \return all executed lines including function signatures on the path
 /// starting from \p N.
 static std::unique_ptr
@@ -3567,13 +3577,21 @@ findExecutedLines(SourceManager &SM, con
   populateExecutedLinesWithFunctionSignature(D, SM, ExecutedLines);
 
 } else if (const Stmt *S = PathDiagnosticLocation::getStmt(N)) {
+  populateExecutedLinesWithStmt(S, SM, ExecutedLines);
+
+  // Show extra context for some parent kinds.
+  const Stmt *P = N->getParentMap().getParent(S);
+
+  // The path exploration can die before the node with the associated
+  // return statement is generated, but we do want to show the whole
+  // return.
+  if (auto *RS = dyn_cast_or_null(P)) {
+populateExecutedLinesWithStmt(RS, SM, ExecutedLines);
+P = N->getParentMap().getParent(RS);
+  }
 
-  // Otherwise: show lines associated with the processed statement.
-  SourceLocation Loc = S->getSourceRange().getBegin();
-  SourceLocation ExpansionLoc = SM.getExpansionLoc(Loc);
-  FileID FID = SM.getFileID(ExpansionLoc);
-  unsigned LineNo = SM.getExpansionLineNumber(ExpansionLoc);
-  ExecutedLines->operator[](FID.getHashValue()).insert(LineNo);
+  if (P && (isa(P) || isa(P)))
+populateExecutedLinesWithStmt(P, SM, ExecutedLines);
 }
 
 N = N->getFirstPred();

Added: cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/goto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/goto.c?rev=325975&view=auto
==
--- cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/goto.c (added)
+++ cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/goto.c Fri Feb 23 
15:26:54 2018
@@ -0,0 +1,13 @@
+int goto_test(int input) {
+  int *p = 0;
+  if (input)
+goto mylabel;
+  return 0;
+mylabel:
+  return *p;
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output 
html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"1": 1,  "2": 1, "3": 1, "4": 1, "6": 1, 
"7": 1}};

Added: cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/switch.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/switch.c?rev=325975&view=auto
==
--- cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/switch.c (added)
+++ cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/switch.c Fri Feb 23 
15:26:54 2018
@@ -0,0 +1,20 @@
+enum E {
+  A, B, C
+};
+
+int f(enum E input) {
+  int *x = 0;
+  switch (input) {
+case A:
+  return 1;
+case B:
+  return 0;
+case C:
+  return *x;
+  }
+}
+
+// RUN: rm -rf %t.output
+// RUN: %clang_analyze_cc1 -analyze -analyzer-checker=core -analyzer-output 
html -o %t.output %s
+// RUN: cat %t.output/* | FileCheck %s --match-full-lines
+// CHECK: var relevant_lines = {"1": {"5": 1, "6": 1, "7": 1, "12": 1, "13": 
1}};

Added: cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/switch_default.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/html_diagnostics/relevant_lines/sw

r325976 - [analyzer] mark returns of functions where the region passed as parameter was not initialized

2018-02-23 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Feb 23 15:26:56 2018
New Revision: 325976

URL: http://llvm.org/viewvc/llvm-project?rev=325976&view=rev
Log:
[analyzer] mark returns of functions where the region passed as parameter was 
not initialized

In the wild, many cases of null pointer dereference, or uninitialized
value read occur because the value was meant to be initialized by the
inlined function, but did not, most often due to error condition in the
inlined function.
This change highlights the return branch taken by the inlined function,
in order to help user understand the error report and see why the value
was uninitialized.

rdar://36287652

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

Added:
cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.c
cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.cpp
cfe/trunk/test/Analysis/diagnostics/no-store-func-path-notes.m
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/diagnostics/undef-value-param.c
cfe/trunk/test/Analysis/diagnostics/undef-value-param.m

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=325976&r1=325975&r2=325976&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Fri Feb 23 
15:26:56 2018
@@ -184,6 +184,276 @@ static bool isFunctionMacroExpansion(Sou
 
 namespace {
 
+/// Put a diagnostic on return statement of all inlined functions
+/// for which  the region of interest \p RegionOfInterest was passed into,
+/// but not written inside, and it has caused an undefined read or a null
+/// pointer dereference outside.
+class NoStoreFuncVisitor final
+: public BugReporterVisitorImpl {
+
+  const SubRegion *RegionOfInterest;
+  static constexpr const char *DiagnosticsMsg =
+  "Returning without writing to '";
+  bool Initialized = false;
+
+  /// Frames writing into \c RegionOfInterest.
+  /// This visitor generates a note only if a function does not write into
+  /// a region of interest. This information is not immediately available
+  /// by looking at the node associated with the exit from the function
+  /// (usually the return statement). To avoid recomputing the same information
+  /// many times (going up the path for each node and checking whether the
+  /// region was written into) we instead pre-compute and store all
+  /// stack frames along the path which write into the region of interest
+  /// on the first \c VisitNode invocation.
+  llvm::SmallPtrSet FramesModifyingRegion;
+
+public:
+  NoStoreFuncVisitor(const SubRegion *R) : RegionOfInterest(R) {}
+
+  void Profile(llvm::FoldingSetNodeID &ID) const override {
+static int Tag = 0;
+ID.AddPointer(&Tag);
+  }
+
+  std::shared_ptr VisitNode(const ExplodedNode *N,
+ const ExplodedNode *PrevN,
+ BugReporterContext &BRC,
+ BugReport &BR) override {
+if (!Initialized) {
+  findModifyingFrames(N);
+  Initialized = true;
+}
+
+const LocationContext *Ctx = N->getLocationContext();
+const StackFrameContext *SCtx = Ctx->getCurrentStackFrame();
+ProgramStateRef State = N->getState();
+auto CallExitLoc = N->getLocationAs();
+
+// No diagnostic if region was modified inside the frame.
+if (!CallExitLoc || FramesModifyingRegion.count(SCtx))
+  return nullptr;
+
+CallEventRef<> Call =
+BRC.getStateManager().getCallEventManager().getCaller(SCtx, State);
+
+const PrintingPolicy &PP = BRC.getASTContext().getPrintingPolicy();
+const SourceManager &SM = BRC.getSourceManager();
+if (auto *CCall = dyn_cast(Call)) {
+  const MemRegion *ThisRegion = CCall->getCXXThisVal().getAsRegion();
+  if (RegionOfInterest->isSubRegionOf(ThisRegion) &&
+  !CCall->getDecl()->isImplicit())
+return notModifiedInConstructorDiagnostics(Ctx, SM, PP, *CallExitLoc,
+   CCall, ThisRegion);
+}
+
+ArrayRef parameters = getCallParameters(Call);
+for (unsigned I = 0, E = Call->getNumArgs(); I != E; ++I) {
+  const ParmVarDecl *PVD = parameters[I];
+  SVal S = Call->getArgSVal(I);
+  unsigned IndirectionLevel = 1;
+  QualType T = PVD->getType();
+  while (const MemRegion *R = S.getAsRegion()) {
+if (RegionOfInterest->isSubRegionOf(R) &&
+!isPointerToConst(PVD->getType()))
+  return notModifiedDiagnostics(
+  Ctx, SM, PP, *CallExitLoc, Call, PVD, R, IndirectionLevel);
+QualType PT = T->getPointeeType();
+if (PT.isNull() || PT->isVoidType()) break;
+S = State->getSVa

r325977 - [analyzer] Relax the assert used when traversing the node graph.

2018-02-23 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Fri Feb 23 15:26:57 2018
New Revision: 325977

URL: http://llvm.org/viewvc/llvm-project?rev=325977&view=rev
Log:
[analyzer] Relax the assert used when traversing the node graph.

The assertion gets exposed when changing the exploration order.
This is a quick hacky fix, but the intention is that if the nodes do
merge, it should not matter which predecessor should be traverse.
A proper fix would be not to traverse predecessors at all, as all
information relevant for any decision should be avilable locally.

rdar://37540480

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

Added:
cfe/trunk/test/Analysis/exploration_order/noexprcrash.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp?rev=325977&r1=325976&r2=325977&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp Fri Feb 23 15:26:57 2018
@@ -760,7 +760,11 @@ void ExprEngine::VisitGuardedExpr(const
   for (const ExplodedNode *N = Pred ; N ; N = *N->pred_begin()) {
 ProgramPoint PP = N->getLocation();
 if (PP.getAs() || PP.getAs()) {
-  assert(N->pred_size() == 1);
+  // If the state N has multiple predecessors P, it means that successors
+  // of P are all equivalent.
+  // In turn, that means that all nodes at P are equivalent in terms
+  // of observable behavior at N, and we can follow any of them.
+  // FIXME: a more robust solution which does not walk up the tree.
   continue;
 }
 SrcBlock = PP.castAs().getSrc();

Added: cfe/trunk/test/Analysis/exploration_order/noexprcrash.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploration_order/noexprcrash.c?rev=325977&view=auto
==
--- cfe/trunk/test/Analysis/exploration_order/noexprcrash.c (added)
+++ cfe/trunk/test/Analysis/exploration_order/noexprcrash.c Fri Feb 23 15:26:57 
2018
@@ -0,0 +1,17 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
-analyzer-config exploration_strategy=unexplored_first %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
-analyzer-config exploration_strategy=dfs %s
+
+extern void clang_analyzer_eval(int);
+
+typedef struct { char a; } b;
+int c(b* input) {
+int x = (input->a ?: input) ? 1 : 0; // expected-warning{{pointer/integer 
type mismatch}}
+if (input->a) {
+  // FIXME: The value should actually be "TRUE",
+  // but is incorrect due to a bug.
+  clang_analyzer_eval(x); // expected-warning{{FALSE}}
+} else {
+  clang_analyzer_eval(x); // expected-warning{{TRUE}}
+}
+return x;
+}


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


r325978 - [CFG] Try to narrow down MSVC compiler crash via binary search.

2018-02-23 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Feb 23 15:38:41 2018
New Revision: 325978

URL: http://llvm.org/viewvc/llvm-project?rev=325978&view=rev
Log:
[CFG] Try to narrow down MSVC compiler crash via binary search.

Split the presumably offending function in two to see which part of it causes
the crash to occur.

The crash was introduced in r325966.
r325969 did not help.

Modified:
cfe/trunk/lib/Analysis/CFG.cpp

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=325978&r1=325977&r2=325978&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Feb 23 15:38:41 2018
@@ -650,6 +650,10 @@ private:
 return Block;
   }
 
+  // Remember to apply \p CC when constructing the CFG element for \p CE.
+  void consumeConstructionContext(const ConstructionContext *CC,
+  CXXConstructExpr *CE);
+
   // Scan the child statement \p Child to find the constructor that might
   // have been directly triggered by the current node, \p Trigger. If such
   // constructor has been found, set current construction context to point
@@ -1149,6 +1153,18 @@ static const VariableArrayType *FindVA(c
   return nullptr;
 }
 
+void CFGBuilder::consumeConstructionContext(const ConstructionContext *CC, 
CXXConstructExpr *CE) {
+  if (const ConstructionContext *PreviousContext =
+  ConstructionContextMap.lookup(CE)) {
+// We might have visited this child when we were finding construction
+// contexts within its parents.
+assert(PreviousContext->isStrictlyMoreSpecificThan(CC) &&
+   "Already within a different construction context!");
+  } else {
+ConstructionContextMap[CE] = CC;
+  }
+}
+
 void CFGBuilder::findConstructionContexts(
 const ConstructionContext *ContextSoFar, Stmt *Child) {
   if (!BuildOpts.AddRichCXXConstructors)
@@ -1156,17 +1172,7 @@ void CFGBuilder::findConstructionContext
   if (!Child)
 return;
   if (auto *CE = dyn_cast(Child)) {
-if (const ConstructionContext *PreviousContext =
-ConstructionContextMap.lookup(CE)) {
-  // We might have visited this child when we were finding construction
-  // contexts within its parents.
-  assert(PreviousContext->isStrictlyMoreSpecificThan(ContextSoFar) &&
- "Already within a different construction context!");
-} else {
-  auto Pair =
-  ConstructionContextMap.insert(std::make_pair(CE, ContextSoFar));
-  assert(Pair.second && "Already within a construction context!");
-}
+consumeConstructionContext(ContextSoFar, CE);
   } else if (auto *Cleanups = dyn_cast(Child)) {
 findConstructionContexts(ContextSoFar, Cleanups->getSubExpr());
   } else if (auto *BTE = dyn_cast(Child)) {


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


[PATCH] D43696: Reduce hash collisions for reference and pointer types

2018-02-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Looks reasonable, can you add a testcase that shows the ODR checker now 
distinguishes pointers/references to distinct types?




Comment at: lib/AST/ODRHash.cpp:581
+  void VisitType(const Type *T) {
+ID.AddInteger(T->getTypeClass());
+  }

This looks redundant, the above `Visit(const Type*)` function seems to already 
do this.


Repository:
  rC Clang

https://reviews.llvm.org/D43696



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


r325994 - [Sema][ObjC] Process category attributes before checking protocol uses

2018-02-23 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Feb 23 15:49:43 2018
New Revision: 325994

URL: http://llvm.org/viewvc/llvm-project?rev=325994&view=rev
Log:
[Sema][ObjC] Process category attributes before checking protocol uses

This ensures that any availability attributes are attached to the
category before the availability for the referenced protocols is checked.

rdar://37829755

Added:
cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=325994&r1=325993&r2=325994&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Feb 23 15:49:43 2018
@@ -1835,6 +1835,13 @@ ActOnStartCategoryInterface(SourceLocati
   // FIXME: PushOnScopeChains?
   CurContext->addDecl(CDecl);
 
+  // Process the attributes before looking at protocols to ensure that the
+  // availability attribute is attached to the category to provide availability
+  // checking for protocol uses.
+  if (AttrList)
+ProcessDeclAttributeList(TUScope, CDecl, AttrList);
+  AddPragmaAttributes(TUScope, CDecl);
+
   if (NumProtoRefs) {
 diagnoseUseOfProtocols(*this, CDecl, (ObjCProtocolDecl*const*)ProtoRefs,
NumProtoRefs, ProtoLocs);
@@ -1846,10 +1853,6 @@ ActOnStartCategoryInterface(SourceLocati
 NumProtoRefs, Context); 
   }
 
-  if (AttrList)
-ProcessDeclAttributeList(TUScope, CDecl, AttrList);
-  AddPragmaAttributes(TUScope, CDecl);
-
   CheckObjCDeclScope(CDecl);
   return ActOnObjCContainerStartDefinition(CDecl);
 }

Added: cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m?rev=325994&view=auto
==
--- cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m 
(added)
+++ cfe/trunk/test/SemaObjC/unguarded-availability-category-protocol-use.m Fri 
Feb 23 15:49:43 2018
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios10 -Wunguarded-availability -fblocks 
-fsyntax-only -verify %s
+
+__attribute__((availability(ios,unavailable)))
+@protocol Prot // expected-note {{here}}
+
+@end
+
+@interface A
+@end
+
+__attribute__((availability(ios,unavailable)))
+@interface A (Cat)  // No error.
+@end
+
+__attribute__((availability(tvos,unavailable)))
+@interface B @end
+@interface B (Cat)  // expected-error {{'Prot' is unavailable: not 
available on iOS}}
+@end


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


[PATCH] D43700: Emit proper CodeView even when not using the cl driver.

2018-02-23 Thread Zachary Turner via Phabricator via cfe-commits
zturner created this revision.
zturner added a reviewer: rnk.

Although the supported way of invoking clang on Windows is via the cl driver, 
some people may wish to use the g++ driver. and manually specify `-gcodeview`.  
This codepath is currently broken, as it will cause column information to be 
emitted, which causes debuggers to not work.

While we still don't claim to support clang on Windows without the cl driver, 
this is a straightforward patch to make things slightly better for people who 
want to go this route anyway.


https://reviews.llvm.org/D43700

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2965,7 +2965,7 @@
 
   // Forward -gcodeview. EmitCodeView might have been set by CL-compatibility
   // argument parsing.
-  if (Args.hasArg(options::OPT_gcodeview) || EmitCodeView) {
+  if (EmitCodeView) {
 // DWARFVersion remains at 0 if no explicit choice was made.
 CmdArgs.push_back("-gcodeview");
   } else if (DWARFVersion == 0 &&
@@ -3552,6 +3552,8 @@
   types::ID InputType = Input.getType();
   if (D.IsCLMode())
 AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView);
+  else
+EmitCodeView = Args.hasArg(options::OPT_gcodeview);
 
   const Arg *SplitDWARFArg = nullptr;
   RenderDebugOptions(getToolChain(), D, RawTriple, Args, EmitCodeView,


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2965,7 +2965,7 @@
 
   // Forward -gcodeview. EmitCodeView might have been set by CL-compatibility
   // argument parsing.
-  if (Args.hasArg(options::OPT_gcodeview) || EmitCodeView) {
+  if (EmitCodeView) {
 // DWARFVersion remains at 0 if no explicit choice was made.
 CmdArgs.push_back("-gcodeview");
   } else if (DWARFVersion == 0 &&
@@ -3552,6 +3552,8 @@
   types::ID InputType = Input.getType();
   if (D.IsCLMode())
 AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView);
+  else
+EmitCodeView = Args.hasArg(options::OPT_gcodeview);
 
   const Arg *SplitDWARFArg = nullptr;
   RenderDebugOptions(getToolChain(), D, RawTriple, Args, EmitCodeView,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42766: [DebugInfo] Support DWARFv5 source code embedding extension

2018-02-23 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Looks generally straightforward.  I'd give other people a chance to chime in 
but I have only minor comments.




Comment at: lib/CodeGen/CGDebugInfo.cpp:411
 // If the location is not valid then use main input file.
-return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
-   remapDIPath(TheCU->getDirectory()),
-   TheCU->getFile()->getChecksumKind(),
-   TheCU->getFile()->getChecksum());
+return getOrCreateMainFile();
 

Looks like this simplification (replace two calls to createFile() with 
getOrCreateMainFile()) could be its own NFC commit and simplify this patch 
slightly.



Comment at: lib/Driver/ToolChains/Clang.cpp:3021
+  if (Args.hasFlag(options::OPT_gembed_source, options::OPT_gno_embed_source, 
false)) {
+// Source embedding is a DWARFv5 extension. By now we have checked if a
+// DWARF version was stated explicitly, and have otherwise fallen back to

Maybe "is an extension to DWARF v5" to clarify it's not actually part of DWARF 
v5.


Repository:
  rC Clang

https://reviews.llvm.org/D42766



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


r325997 - [ExprConstant] Fix crash when initialize an indirect field with another field.

2018-02-23 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Fri Feb 23 15:59:20 2018
New Revision: 325997

URL: http://llvm.org/viewvc/llvm-project?rev=325997&view=rev
Log:
[ExprConstant] Fix crash when initialize an indirect field with another field.

When indirect field is initialized with another field, you have
MemberExpr with CXXThisExpr that corresponds to the field's immediate
anonymous parent. But 'this' was referring to the non-anonymous parent.
So when we were building LValue Designator, it was incorrect as it had
wrong starting point. Usage of such designator would cause unexpected
APValue changes and crashes.

The fix is in adjusting 'this' for indirect fields from non-anonymous
parent to the field's immediate parent.

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

rdar://problem/36359187

Reviewers: rsmith, efriedma

Reviewed By: rsmith

Subscribers: cfe-commits, jkorous-apple

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


Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=325997&r1=325996&r2=325997&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Feb 23 15:59:20 2018
@@ -4383,6 +4383,7 @@ static bool HandleConstructorCall(const
 #endif
   for (const auto *I : Definition->inits()) {
 LValue Subobject = This;
+LValue SubobjectParent = This;
 APValue *Value = &Result;
 
 // Determine the subobject to initialize.
@@ -4413,7 +4414,8 @@ static bool HandleConstructorCall(const
 } else if (IndirectFieldDecl *IFD = I->getIndirectMember()) {
   // Walk the indirect field decl's chain to find the object to initialize,
   // and make sure we've initialized every step along it.
-  for (auto *C : IFD->chain()) {
+  auto IndirectFieldChain = IFD->chain();
+  for (auto *C : IndirectFieldChain) {
 FD = cast(C);
 CXXRecordDecl *CD = cast(FD->getParent());
 // Switch the union field if it differs. This happens if we had
@@ -4429,6 +4431,10 @@ static bool HandleConstructorCall(const
 *Value = APValue(APValue::UninitStruct(), CD->getNumBases(),
  std::distance(CD->field_begin(), 
CD->field_end()));
 }
+// Store Subobject as its parent before updating it for the last 
element
+// in the chain.
+if (C == IndirectFieldChain.back())
+  SubobjectParent = Subobject;
 if (!HandleLValueMember(Info, I->getInit(), Subobject, FD))
   return false;
 if (CD->isUnion())
@@ -4440,10 +4446,16 @@ static bool HandleConstructorCall(const
   llvm_unreachable("unknown base initializer kind");
 }
 
+// Need to override This for implicit field initializers as in this case
+// This refers to innermost anonymous struct/union containing initializer,
+// not to currently constructed class.
+const Expr *Init = I->getInit();
+ThisOverrideRAII ThisOverride(*Info.CurrentCall, &SubobjectParent,
+  isa(Init));
 FullExpressionRAII InitScope(Info);
-if (!EvaluateInPlace(*Value, Info, Subobject, I->getInit()) ||
-(FD && FD->isBitField() && !truncateBitfieldValue(Info, I->getInit(),
-  *Value, FD))) {
+if (!EvaluateInPlace(*Value, Info, Subobject, Init) ||
+(FD && FD->isBitField() &&
+ !truncateBitfieldValue(Info, Init, *Value, FD))) {
   // If we're checking for a potential constant expression, evaluate all
   // initializers even if some of them fail.
   if (!Info.noteFailure())

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp?rev=325997&r1=325996&r2=325997&view=diff
==
--- cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp Fri Feb 23 15:59:20 
2018
@@ -1045,3 +1045,57 @@ namespace Mutable {
   constexpr B b;
   constexpr int p = b.n; // expected-error {{constant expression}} 
expected-note {{mutable}}
 }
+
+namespace IndirectFields {
+
+// Reference indirect field.
+struct A {
+  struct {
+union {
+  int x = x = 3; // expected-note {{outside its lifetime}}
+};
+  };
+  constexpr A() {}
+};
+static_assert(A().x == 3, ""); // expected-error{{not an integral constant 
expression}} expected-note{{in call to 'A()'}}
+
+// Reference another indirect field, with different 'this'.
+struct B {
+  struct {
+union {
+  int x = 3;
+};
+int y = x;
+  };
+  constexpr B() {}
+};
+static_assert(B().y == 3, "");
+
+// Nested evaluation of i

[PATCH] D42498: [ExprConstant] Fix crash when initialize an indirect field with another field.

2018-02-23 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC325997: [ExprConstant] Fix crash when initialize an indirect 
field with another field. (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42498?vs=135708&id=135725#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42498

Files:
  lib/AST/ExprConstant.cpp
  test/SemaCXX/constant-expression-cxx1y.cpp

Index: test/SemaCXX/constant-expression-cxx1y.cpp
===
--- test/SemaCXX/constant-expression-cxx1y.cpp
+++ test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1045,3 +1045,57 @@
   constexpr B b;
   constexpr int p = b.n; // expected-error {{constant expression}} expected-note {{mutable}}
 }
+
+namespace IndirectFields {
+
+// Reference indirect field.
+struct A {
+  struct {
+union {
+  int x = x = 3; // expected-note {{outside its lifetime}}
+};
+  };
+  constexpr A() {}
+};
+static_assert(A().x == 3, ""); // expected-error{{not an integral constant expression}} expected-note{{in call to 'A()'}}
+
+// Reference another indirect field, with different 'this'.
+struct B {
+  struct {
+union {
+  int x = 3;
+};
+int y = x;
+  };
+  constexpr B() {}
+};
+static_assert(B().y == 3, "");
+
+// Nested evaluation of indirect field initializers.
+struct C {
+  union {
+int x = 1;
+  };
+};
+struct D {
+  struct {
+C c;
+int y = c.x + 1;
+  };
+};
+static_assert(D().y == 2, "");
+
+// Explicit 'this'.
+struct E {
+  int n = 0;
+  struct {
+void *x = this;
+  };
+  void *y = this;
+};
+constexpr E e1 = E();
+static_assert(e1.x != e1.y, "");
+constexpr E e2 = E{0};
+static_assert(e2.x != e2.y, "");
+
+} // namespace IndirectFields
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -4383,6 +4383,7 @@
 #endif
   for (const auto *I : Definition->inits()) {
 LValue Subobject = This;
+LValue SubobjectParent = This;
 APValue *Value = &Result;
 
 // Determine the subobject to initialize.
@@ -4413,7 +4414,8 @@
 } else if (IndirectFieldDecl *IFD = I->getIndirectMember()) {
   // Walk the indirect field decl's chain to find the object to initialize,
   // and make sure we've initialized every step along it.
-  for (auto *C : IFD->chain()) {
+  auto IndirectFieldChain = IFD->chain();
+  for (auto *C : IndirectFieldChain) {
 FD = cast(C);
 CXXRecordDecl *CD = cast(FD->getParent());
 // Switch the union field if it differs. This happens if we had
@@ -4429,6 +4431,10 @@
 *Value = APValue(APValue::UninitStruct(), CD->getNumBases(),
  std::distance(CD->field_begin(), CD->field_end()));
 }
+// Store Subobject as its parent before updating it for the last element
+// in the chain.
+if (C == IndirectFieldChain.back())
+  SubobjectParent = Subobject;
 if (!HandleLValueMember(Info, I->getInit(), Subobject, FD))
   return false;
 if (CD->isUnion())
@@ -4440,10 +4446,16 @@
   llvm_unreachable("unknown base initializer kind");
 }
 
+// Need to override This for implicit field initializers as in this case
+// This refers to innermost anonymous struct/union containing initializer,
+// not to currently constructed class.
+const Expr *Init = I->getInit();
+ThisOverrideRAII ThisOverride(*Info.CurrentCall, &SubobjectParent,
+  isa(Init));
 FullExpressionRAII InitScope(Info);
-if (!EvaluateInPlace(*Value, Info, Subobject, I->getInit()) ||
-(FD && FD->isBitField() && !truncateBitfieldValue(Info, I->getInit(),
-  *Value, FD))) {
+if (!EvaluateInPlace(*Value, Info, Subobject, Init) ||
+(FD && FD->isBitField() &&
+ !truncateBitfieldValue(Info, Init, *Value, FD))) {
   // If we're checking for a potential constant expression, evaluate all
   // initializers even if some of them fail.
   if (!Info.noteFailure())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42498: [ExprConstant] Fix crash when initialize an indirect field with another field.

2018-02-23 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL325997: [ExprConstant] Fix crash when initialize an indirect 
field with another field. (authored by vsapsai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D42498?vs=135708&id=135726#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42498

Files:
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp

Index: cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
===
--- cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1045,3 +1045,57 @@
   constexpr B b;
   constexpr int p = b.n; // expected-error {{constant expression}} expected-note {{mutable}}
 }
+
+namespace IndirectFields {
+
+// Reference indirect field.
+struct A {
+  struct {
+union {
+  int x = x = 3; // expected-note {{outside its lifetime}}
+};
+  };
+  constexpr A() {}
+};
+static_assert(A().x == 3, ""); // expected-error{{not an integral constant expression}} expected-note{{in call to 'A()'}}
+
+// Reference another indirect field, with different 'this'.
+struct B {
+  struct {
+union {
+  int x = 3;
+};
+int y = x;
+  };
+  constexpr B() {}
+};
+static_assert(B().y == 3, "");
+
+// Nested evaluation of indirect field initializers.
+struct C {
+  union {
+int x = 1;
+  };
+};
+struct D {
+  struct {
+C c;
+int y = c.x + 1;
+  };
+};
+static_assert(D().y == 2, "");
+
+// Explicit 'this'.
+struct E {
+  int n = 0;
+  struct {
+void *x = this;
+  };
+  void *y = this;
+};
+constexpr E e1 = E();
+static_assert(e1.x != e1.y, "");
+constexpr E e2 = E{0};
+static_assert(e2.x != e2.y, "");
+
+} // namespace IndirectFields
Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -4383,6 +4383,7 @@
 #endif
   for (const auto *I : Definition->inits()) {
 LValue Subobject = This;
+LValue SubobjectParent = This;
 APValue *Value = &Result;
 
 // Determine the subobject to initialize.
@@ -4413,7 +4414,8 @@
 } else if (IndirectFieldDecl *IFD = I->getIndirectMember()) {
   // Walk the indirect field decl's chain to find the object to initialize,
   // and make sure we've initialized every step along it.
-  for (auto *C : IFD->chain()) {
+  auto IndirectFieldChain = IFD->chain();
+  for (auto *C : IndirectFieldChain) {
 FD = cast(C);
 CXXRecordDecl *CD = cast(FD->getParent());
 // Switch the union field if it differs. This happens if we had
@@ -4429,6 +4431,10 @@
 *Value = APValue(APValue::UninitStruct(), CD->getNumBases(),
  std::distance(CD->field_begin(), CD->field_end()));
 }
+// Store Subobject as its parent before updating it for the last element
+// in the chain.
+if (C == IndirectFieldChain.back())
+  SubobjectParent = Subobject;
 if (!HandleLValueMember(Info, I->getInit(), Subobject, FD))
   return false;
 if (CD->isUnion())
@@ -4440,10 +4446,16 @@
   llvm_unreachable("unknown base initializer kind");
 }
 
+// Need to override This for implicit field initializers as in this case
+// This refers to innermost anonymous struct/union containing initializer,
+// not to currently constructed class.
+const Expr *Init = I->getInit();
+ThisOverrideRAII ThisOverride(*Info.CurrentCall, &SubobjectParent,
+  isa(Init));
 FullExpressionRAII InitScope(Info);
-if (!EvaluateInPlace(*Value, Info, Subobject, I->getInit()) ||
-(FD && FD->isBitField() && !truncateBitfieldValue(Info, I->getInit(),
-  *Value, FD))) {
+if (!EvaluateInPlace(*Value, Info, Subobject, Init) ||
+(FD && FD->isBitField() &&
+ !truncateBitfieldValue(Info, Init, *Value, FD))) {
   // If we're checking for a potential constant expression, evaluate all
   // initializers even if some of them fail.
   if (!Info.noteFailure())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43700: Emit proper CodeView even when not using the cl driver.

2018-02-23 Thread Colden Cullen via Phabricator via cfe-commits
colden added a comment.

Seems good to me! I'll give it a test on my end.

One alternate implementation idea though, what if you defaulted EmitCodeView to 
the hasArg check instead of false, then removed the `else *EmitCodeView = 
false;` block on line 4999?


https://reviews.llvm.org/D43700



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


r325998 - Add another test for PR36157.

2018-02-23 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 23 16:00:58 2018
New Revision: 325998

URL: http://llvm.org/viewvc/llvm-project?rev=325998&view=rev
Log:
Add another test for PR36157.

Modified:
cfe/trunk/test/Sema/vla.c

Modified: cfe/trunk/test/Sema/vla.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vla.c?rev=325998&r1=325997&r2=325998&view=diff
==
--- cfe/trunk/test/Sema/vla.c (original)
+++ cfe/trunk/test/Sema/vla.c Fri Feb 23 16:00:58 2018
@@ -68,3 +68,11 @@ void pr23151(int (*p1)[*]) // expected-e
 int TransformBug(int a) {
  return sizeof(*(int(*)[({ goto v; v: a;})]) 0); // expected-warning {{use of 
GNU statement expression extension}}
 }
+
+// PR36157
+struct {
+  int a[ // expected-error {{variable length array in struct}}
+implicitly_declared() // expected-warning {{implicit declaration}}
+  ];
+};
+int (*use_implicitly_declared)() = implicitly_declared; // ok, was implicitly 
declared at file scope


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


[PATCH] D42498: [ExprConstant] Fix crash when initialize an indirect field with another field.

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

Thanks for the review. Explicit `this` usage is a good test, added it.

Checked that it happened to work with my previous approach because initializer 
was `CXXDefaultInitExpr` with expression

  ImplicitCastExpr 0x7fe966808c40 'void *' 
  `-CXXThisExpr 0x7fe966808c28 'struct A::(anonymous at file.cc:3:5) *' this


Repository:
  rL LLVM

https://reviews.llvm.org/D42498



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


[PATCH] D43700: Emit proper CodeView even when not using the cl driver.

2018-02-23 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a comment.

In https://reviews.llvm.org/D43700#1018042, @colden wrote:

> Seems good to me! I'll give it a test on my end.
>
> One alternate implementation idea though, what if you defaulted EmitCodeView 
> to the hasArg check instead of false, then removed the `else *EmitCodeView = 
> false;` block on line 4999?


That would actually change the behavior of the cl driver, which I kind of don't 
want to do since it's not necessary.  It would whitelist an additional clang 
option to be recognized by the cl driver.  Specifically, you could then get 
debug info via the cl driver without specifying /Z7 or /Zi.  It makes the 
possibilities more confusing, and someone will invariably try to do it and 
screw something up.  We already whitelist some dash options so that the cl 
driver will recognize them, but it's on a case by case basis and only when 
there's a strong need for it.


https://reviews.llvm.org/D43700



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


[PATCH] D43700: Emit proper CodeView even when not using the cl driver.

2018-02-23 Thread Colden Cullen via Phabricator via cfe-commits
colden added a comment.

In https://reviews.llvm.org/D43700#1018087, @zturner wrote:

> In https://reviews.llvm.org/D43700#1018042, @colden wrote:
>
> > Seems good to me! I'll give it a test on my end.
> >
> > One alternate implementation idea though, what if you defaulted 
> > EmitCodeView to the hasArg check instead of false, then removed the `else 
> > *EmitCodeView = false;` block on line 4999?
>
>
> That would actually change the behavior of the cl driver, which I kind of 
> don't want to do since it's not necessary.  It would whitelist an additional 
> clang option to be recognized by the cl driver.  Specifically, you could then 
> get debug info via the cl driver without specifying /Z7 or /Zi.  It makes the 
> possibilities more confusing, and someone will invariably try to do it and 
> screw something up.  We already whitelist some dash options so that the cl 
> driver will recognize them, but it's on a case by case basis and only when 
> there's a strong need for it.


Good point, that's a pretty good reason not to.


https://reviews.llvm.org/D43700



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


[PATCH] D43696: Reduce hash collisions for reference and pointer types

2018-02-23 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added inline comments.



Comment at: lib/AST/ODRHash.cpp:581
+  void VisitType(const Type *T) {
+ID.AddInteger(T->getTypeClass());
+  }

rsmith wrote:
> This looks redundant, the above `Visit(const Type*)` function seems to 
> already do this.
That's correct, VisitType is intended to be empty.  The TypeClass enum value is 
added in Visit so that it is the first value added to the data stream.



Comment at: lib/AST/ODRHash.cpp:590
+  void VisitReferenceType(const ReferenceType *T) {
+AddQualType(T->getPointeeType());
+VisitType(T);

Use T->getPointeeTypeAsWritten() here.


Repository:
  rC Clang

https://reviews.llvm.org/D43696



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


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

2018-02-23 Thread Erik Nyquist via Phabricator via cfe-commits
enyquist updated this revision to Diff 135744.
enyquist added a comment.

Rebased on current master. No functional changes, just a minor conflict where a 
variable got re-named


Repository:
  rL LLVM

https://reviews.llvm.org/D28462

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/WhitespaceManager.cpp
  lib/Format/WhitespaceManager.h
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8933,8 +8933,104 @@
   verifyFormat("a or_eq 8;", Spaces);
 }
 
+TEST_F(FormatTest, AlignConsecutiveMacros) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignConsecutiveAssignments = true;
+  Style.AlignConsecutiveDeclarations = true;
+  Style.AlignConsecutiveMacros = false;
+
+  verifyFormat("#define a 3\n"
+   "#define  4\n"
+   "#define ccc (5)",
+   Style);
+
+  verifyFormat("#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y) (x - y)",
+   Style);
+
+  verifyFormat("#define foo(x, y) (x + y)\n"
+   "#define bar (5, 6)(2 + 2)",
+   Style);
+
+  verifyFormat("#define a 3\n"
+   "#define  4\n"
+   "#define ccc (5)\n"
+   "#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y) (x - y)",
+   Style);
+
+  Style.AlignConsecutiveMacros = true;
+  verifyFormat("#define a3\n"
+   "#define  4\n"
+   "#define ccc  (5)",
+   Style);
+
+  verifyFormat("#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y)   (x - y)",
+   Style);
+
+  verifyFormat("#define foo(x, y) (x + y)\n"
+   "#define bar   (5, 6)(2 + 2)",
+   Style);
+
+  verifyFormat("#define a3\n"
+   "#define  4\n"
+   "#define ccc  (5)\n"
+   "#define f(x) (x * x)\n"
+   "#define fff(x, y, z) (x * y + z)\n"
+   "#define (x, y)   (x - y)",
+   Style);
+
+  verifyFormat("#define a 5\n"
+   "#define foo(x, y) (x + y)\n"
+   "#define CCC   (6)\n"
+   "auto lambda = []() {\n"
+   "  auto  ii = 0;\n"
+   "  float j  = 0;\n"
+   "  return 0;\n"
+   "};\n"
+   "int   i  = 0;\n"
+   "float i2 = 0;\n"
+   "auto  v  = type{\n"
+   "i = 1,   //\n"
+   "(i = 2), //\n"
+   "i = 3//\n"
+   "};",
+   Style);
+
+  Style.AlignConsecutiveMacros = false;
+  Style.ColumnLimit = 20;
+
+  verifyFormat("#define a  \\\n"
+   "  \"aa\"\n"
+   "#define D  \\\n"
+   "  \"aa\" \\\n"
+   "  \"ccdde\"\n"
+   "#define B  \\\n"
+   "  \"Q\"  \\\n"
+   "  \"F\"  \\\n"
+   "  \"\"\n",
+   Style);
+
+  Style.AlignConsecutiveMacros = true;
+  verifyFormat("#define a  \\\n"
+   "  \"aa\"\n"
+   "#define D  \\\n"
+   "  \"aa\" \\\n"
+   "  \"ccdde\"\n"
+   "#define B  \\\n"
+   "  \"Q\"  \\\n"
+   "  \"F\"  \\\n"
+   "  \"\"\n",
+   Style);
+}
+
 TEST_F(FormatTest, AlignConsecutiveAssignments) {
   FormatStyle Alignment = getLLVMStyle();
+  Alignment.AlignConsecutiveMacros = true;
   Alignment.AlignConsecutiveAssignments = false;
   verifyFormat("int a = 5;\n"
"int oneTwoThree = 123;",
@@ -9124,6 +9220,7 @@
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
   FormatStyle Alignment = getLLVMStyle();
+  Alignment.AlignConsecutiveMacros = true;
   Alignment.AlignConsecutiveDeclarations = false;
   verifyFormat("float const a = 5;\n"
"int oneTwoThree = 123;",
@@ -10237,6 +10334,7 @@
   Style.Language = FormatStyle::LK_Cpp;
   CHECK_PARSE_BOOL(AlignOperands);
   CHECK_PARSE_BOOL(AlignTrailingComments);
+  CHECK_PARSE_BOOL(AlignConsecutiveMacros);
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
Index: lib/Format/WhitespaceManager.h
===
--- lib/Format/WhitespaceManager.h
+++ lib/Format/WhitespaceManager.h
@@ -170,6 +170,9 @@
   /// \c EscapedNewlineColumn for the first tokens or token

[PATCH] D43581: [clang-tidy/google] Improve the Objective-C global variable declaration check ๐Ÿ”ง

2018-02-23 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 135745.
stephanemoore marked 3 inline comments as done.
stephanemoore added a comment.

Removed the regex from the diagnostic โœ‚๏ธ


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581

Files:
  clang-tidy/google/GlobalVariableDeclarationCheck.cpp
  test/clang-tidy/google-objc-global-variable-declaration.m


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 
'myConstString' must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,16 +22,24 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' 
must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
 static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with 'k[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' 
must have a name which starts with an appropriate prefix 
[google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const k_Alpha = @"SecondNotAlpha";
 
 static NSString* const kGood = @"hello";
+static NSString* const XYGood = @"hello";
 static NSString* gMyIntGood = 0;
 
+extern NSString* const GTLServiceErrorDomain;
+
+enum GTLServiceError {
+  GTLServiceErrorQueryResultMissing = -3000,
+  GTLServiceErrorWaitTimedOut   = -3001,
+};
+
 @implementation Foo
 - (void)f {
 int x = 0;
Index: clang-tidy/google/GlobalVariableDeclarationCheck.cpp
===
--- clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -72,7 +72,7 @@
   this);
   Finder->addMatcher(varDecl(hasGlobalStorage(), hasType(isConstQualified()),
  unless(isLocalVariable()),
- unless(matchesName("::k[A-Z]")))
+ unless(matchesName("::(k[A-Z]|[A-Z]{2,})")))
  .bind("global_const"),
  this);
 }
@@ -88,7 +88,7 @@
   if (const auto *Decl = Result.Nodes.getNodeAs("global_const")) {
 diag(Decl->getLocation(),
  "const global variable '%0' must have a name which starts with "
- "'k[A-Z]'")
+ "an appropriate prefix")
 << Decl->getName() << generateFixItHint(Decl, true);
   }
 }


Index: test/clang-tidy/google-objc-global-variable-declaration.m
===
--- test/clang-tidy/google-objc-global-variable-declaration.m
+++ test/clang-tidy/google-objc-global-variable-declaration.m
@@ -2,7 +2,7 @@
 
 @class NSString;
 static NSString* const myConstString = @"hello";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'myConstString' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const kMyConstString = @"hello";
 
 static NSString* MyString = @"hi";
@@ -22,16 +22,24 @@
 // CHECK-FIXES: static NSString* gNoDef;
 
 static NSString* const _notAlpha = @"NotBeginWithAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' must have a name which starts with 'k[A-Z]' [google-objc-global-variable-declaration]
+// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable '_notAlpha' must have a name which starts with an appropriate prefix [google-objc-global-variable-declaration]
 // CHECK-FIXES: static NSString* const _notAlpha = @"NotBeginWithAlpha";
 
 static NSString* const k_Alpha = @"SecondNotAlpha";
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: const global variable 'k_Alpha' must have a name which starts with 'k[A-Z

[PATCH] D43581: [clang-tidy/google] Improve the Objective-C global variable declaration check ๐Ÿ”ง

2018-02-23 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore marked 2 inline comments as done.
stephanemoore added inline comments.



Comment at: clang-tidy/google/GlobalVariableDeclarationCheck.cpp:92
+ "an appropriate prefix (see "
+ "http://google.github.io/styleguide/objcguide#constants).")
 << Decl->getName() << generateFixItHint(Decl, true);

aaron.ballman wrote:
> stephanemoore wrote:
> > stephanemoore wrote:
> > > Wizard wrote:
> > > > aaron.ballman wrote:
> > > > > We don't usually put hyperlinks in the diagnostic messages, so please 
> > > > > remove this.
> > > > > 
> > > > > My suggestion about describing what constitutes an appropriate prefix 
> > > > > was with regards to the style guide wording itself. For instance, 
> > > > > that document doesn't mention that two capital letters is good. 
> > > > > That's not on you to fix before this patch goes in, of course.
> > > > Btw it is actually "2 or more" characters for prefix. I think it makes 
> > > > sense because we need at least 2 or more characters to call it a 
> > > > "prefix" :-)
> > > Reverted the inclusion of the hyperlink in the message. I agree that 
> > > embedding the hyperlink in the message is indirect and inconsistent with 
> > > other diagnostic messages in LLVM projecta.
> > ยง1 Regarding Prefixes And Character Count
> > 
> > Strictly speaking, a single character prefix (e.g., `extern const int 
> > ALimit;` โŒ) is possible but not allowed for constants in Google Objective-C 
> > style except for lowercase 'k' as a prefix for file scope constants (e.g., 
> > `static const int kLimit = 3;` โœ”๏ธ). As hinted in the commit description, 
> > Google currently enforces a minimum two character prefix (e.g., `extern 
> > const int ABPrefix;` โœ”๏ธ) or exceptionally 'k' where appropriate.
> > 
> > Technically this modified regex allows authored code to include inadvisable 
> > constant names with a single character prefix (e.g., `extern const int 
> > APrefix;` โŒ). In this respect I would say that this change eliminates an 
> > important category of false positives (constants prefixed with '[A-Z]{2,}') 
> > while introducing a less important category of false negatives (constants 
> > prefixed with only '[A-Z]'). The false positives are observed in standard 
> > recommended code while the false negatives occur in non-standard 
> > unrecommended code. Without a reliable mechanism to separate the constant 
> > prefix from the constant name (e.g., splitting "FOOURL" into "FOO" and 
> > "URL" or "HTTP2Header" into "HTTP2" and "Header"), I cannot immediately 
> > think of a way to eliminate the introduced category of false negatives 
> > without introducing other false positives. I intend to continue thinking 
> > about alternative methods that might eliminate these false negatives 
> > without introducing other compromises. If it is acceptable to the reviewers 
> > I would propose to move forward with this proposed change to eliminate the 
> > observed false positives and then consider addressing the false negatives 
> > in a followup.
> > 
> > ยง2 Regarding the Google Objective-C Style Guide's Description of 
> > Appropriate Prefixes
> > 
> > I agree that the Google Objective-C style guide should be clearer on this 
> > topic and will pursue clarifying this promptly.
> I don't think we should have the regex as part of the diagnostic either -- 
> it's a distraction and it's not something we typically do. While it's nice 
> for the diagnostic to explain how to fix the issue, the critical bit is 
> diagnosing what's wrong with the code. The diagnostic without the regex does 
> that and users have a place to find that information (the style guide docs).
Sounds good to me ๐Ÿ‘Œ Removed the regex from the diagnostic.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D43581



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


r326014 - [CFG] Provide construction contexts for lifetime-extended temporaries.

2018-02-23 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Feb 23 18:00:30 2018
New Revision: 326014

URL: http://llvm.org/viewvc/llvm-project?rev=326014&view=rev
Log:
[CFG] Provide construction contexts for lifetime-extended temporaries.

When constructing a temporary that is going to be lifetime-extended through a
MaterializeTemporaryExpr later, CFG elements for the respective constructor
can now be queried to obtain the reference to that MaterializeTemporaryExpr
and therefore gain information about lifetime extension.

This may produce multi-layered construction contexts when information about
both temporary destruction and lifetime extension is available.

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

Modified:
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
cfe/trunk/test/Analysis/temp-obj-dtors-cfg-output.cpp

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=326014&r1=326013&r2=326014&view=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Fri Feb 23 18:00:30 2018
@@ -193,6 +193,17 @@ public:
 return Trigger.dyn_cast();
   }
 
+  const MaterializeTemporaryExpr *getMaterializedTemporary() const {
+// TODO: Be more careful to ensure that there's only one MTE around.
+for (const ConstructionContext *CC = this; CC; CC = CC->getParent()) {
+  if (const auto *MTE = dyn_cast_or_null(
+  CC->getTriggerStmt())) {
+return MTE;
+  }
+}
+return nullptr;
+  }
+
   bool isSameAsPartialContext(const ConstructionContext *Other) const {
 assert(Other);
 return (Trigger == Other->Trigger);
@@ -248,6 +259,10 @@ public:
 return getConstructionContext()->getTriggerInit();
   }
 
+  const MaterializeTemporaryExpr *getMaterializedTemporary() const {
+return getConstructionContext()->getMaterializedTemporary();
+  }
+
 private:
   friend class CFGElement;
 

Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=326014&r1=326013&r2=326014&view=diff
==
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Fri Feb 23 18:00:30 2018
@@ -548,6 +548,8 @@ private:
  Stmt *Term,
  CFGBlock *TrueBlock,
  CFGBlock *FalseBlock);
+  CFGBlock *VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *MTE,
+  AddStmtChoice asc);
   CFGBlock *VisitMemberExpr(MemberExpr *M, AddStmtChoice asc);
   CFGBlock *VisitObjCAtCatchStmt(ObjCAtCatchStmt *S);
   CFGBlock *VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S);
@@ -1840,6 +1842,10 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, Ad
 case Stmt::LambdaExprClass:
   return VisitLambdaExpr(cast(S), asc);
 
+case Stmt::MaterializeTemporaryExprClass:
+  return VisitMaterializeTemporaryExpr(cast(S),
+   asc);
+
 case Stmt::MemberExprClass:
   return VisitMemberExpr(cast(S), asc);
 
@@ -2975,6 +2981,16 @@ CFGBlock *CFGBuilder::VisitForStmt(ForSt
   return EntryConditionBlock;
 }
 
+CFGBlock *
+CFGBuilder::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *MTE,
+  AddStmtChoice asc) {
+  findConstructionContexts(
+  ConstructionContext::create(cfg->getBumpVectorContext(), MTE),
+  MTE->getTemporary());
+
+  return VisitStmt(MTE, asc);
+}
+
 CFGBlock *CFGBuilder::VisitMemberExpr(MemberExpr *M, AddStmtChoice asc) {
   if (asc.alwaysAdd(*this, M)) {
 autoCreateBlock();
@@ -4706,13 +4722,20 @@ static void print_elem(raw_ostream &OS,
 } else if (const CXXConstructExpr *CCE = dyn_cast(S)) {
   OS << " (CXXConstructExpr, ";
   if (Optional CE = E.getAs()) {
+// TODO: Refactor into ConstructionContext::print().
 if (const Stmt *S = CE->getTriggerStmt())
-  Helper.handledStmt((const_cast(S)), OS);
+  Helper.handledStmt(const_cast(S), OS);
 else if (const CXXCtorInitializer *I = CE->getTriggerInit())
   print_initializer(OS, Helper, I);
 else
   llvm_unreachable("Unexpected trigger kind!");
 OS << ", ";
+if (const Stmt *S = CE->getMaterializedTemporary()) {
+  if (S != CE->getTriggerStmt()) {
+Helper.handledStmt(const_cast(S), OS);
+OS << ", ";
+  }
+}
   }
   OS << CCE->getType().getAsString() << ")";
 } else if (const CastExpr *CE = dyn_cast(S)) {

Modified: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
URL: 
http://llvm.org/viewvc/ll

  1   2   >