[PATCH] D65029: [Driver] Support for disabling sanitizer runtime linking

2019-07-19 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added subscribers: filcab, pcc.
pcc added a comment.

It's also worth asking whether `-nodefaultlibs` would work for this use case as 
@filcab suggested on D64547 .


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65029/new/

https://reviews.llvm.org/D65029



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


[PATCH] D65029: [Driver] Support for disabling sanitizer runtime linking

2019-07-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

There is an existing option `-fsanitize-minimal-runtime`, will 
`-fsanitize-no-runtime` be a name providing more consistency?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65029/new/

https://reviews.llvm.org/D65029



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


[PATCH] D65028: [WebAssembly] Compute and export TLS block alignment

2019-07-19 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: lld/trunk/wasm/Symbols.h:438
 
+  // __tls_size
+  // Symbol whose value is the alignment of the TLS block.

__tls_align




Comment at: lld/trunk/wasm/Symbols.h:439
+  // __tls_size
+  // Symbol whose value is the alignment of the TLS block.
+  static GlobalSymbol *tlsAlign;

Is this stored as power of 2?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65028/new/

https://reviews.llvm.org/D65028



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


[PATCH] D65029: [Driver] Support for disabling sanitizer runtime linking

2019-07-19 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65029/new/

https://reviews.llvm.org/D65029



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


Re: [clang-tools-extra] r366458 - [clangd] Refactor background-index shard loading

2019-07-19 Thread Azhar Mohammed via cfe-commits
Looks good now. Thanks Kadir!

> On Jul 19, 2019, at 3:18 AM, Kadir Çetinkaya  wrote:
> 
> Hi Azhar, D64980 should fix the problem. I am reverting your revert while 
> adding the fix in r366559.
> 
> On Fri, Jul 19, 2019 at 11:29 AM Azhar Mohammed  > wrote:
> Reverted in r366551. 
> 
> 
> Revert r366458, r366467 and r366468
> 
> r366458 is causing test failures. r366467 and r366468 had to be reverted 
> as
> they were casuing conflict while reverting r366458.
> 
> r366468 [clangd] Remove dead code from BackgroundIndex
> r366467 [clangd] BackgroundIndex stores shards to the closest project
> r366458 [clangd] Refactor background-index shard loading
> 
>> On Jul 18, 2019, at 6:21 PM, Azhar Mohammed > > wrote:
>> 
>> Hi Kadir
>> 
>> This change is causing test failures, can you please look into it. Refer to 
>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/58104/testReport/
>>  
>> .
>>  
>> 
>> Assertion failed: (TUsIt != FileToTU.end() && "No TU registered for the 
>> shard"), function takeResult, file 
>> /Users/buildslave/jenkins/workspace/clang-stage1-configure-RA/llvm/tools/clang/tools/extra/clangd/index/BackgroundIndexLoader.cpp,
>>  line 131.
>> 
>> 
>> Failing Tests (10):
>> Clangd :: did-change-configuration-params.test
>> Clangd Unit Tests :: ./ClangdTests/BackgroundIndexTest.CmdLineHash
>> Clangd Unit Tests :: ./ClangdTests/BackgroundIndexTest.DirectIncludesTest
>> Clangd Unit Tests :: ./ClangdTests/BackgroundIndexTest.IndexTwoFiles
>> Clangd Unit Tests :: ./ClangdTests/BackgroundIndexTest.NoCrashOnErrorFile
>> Clangd Unit Tests :: ./ClangdTests/BackgroundIndexTest.NoDotsInAbsPath
>> Clangd Unit Tests :: 
>> ./ClangdTests/BackgroundIndexTest.ShardStorageEmptyFile
>> Clangd Unit Tests :: ./ClangdTests/BackgroundIndexTest.ShardStorageLoad
>> Clangd Unit Tests :: ./ClangdTests/BackgroundIndexTest.ShardStorageTest
>> Clangd Unit Tests :: ./ClangdTests/BackgroundIndexTest.UncompilableFiles
>> 
>> 
>>> On Jul 18, 2019, at 9:25 AM, Kadir Cetinkaya via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> 
>>> Author: kadircet
>>> Date: Thu Jul 18 09:25:36 2019
>>> New Revision: 366458
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=366458=rev 
>>> 
>>> Log:
>>> [clangd] Refactor background-index shard loading
>>> 
>>> Reviewers: sammccall
>>> 
>>> Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits
>>> 
>>> Tags: #clang
>>> 
>>> Differential Revision: https://reviews.llvm.org/D64712 
>>> 
>>> 
>>> Added:
>>>clang-tools-extra/trunk/clangd/index/BackgroundIndexLoader.cpp
>>>clang-tools-extra/trunk/clangd/index/BackgroundIndexLoader.h
>>> Modified:
>>>clang-tools-extra/trunk/clangd/CMakeLists.txt
>>>clang-tools-extra/trunk/clangd/index/Background.cpp
>>>clang-tools-extra/trunk/clangd/index/Background.h
>>>clang-tools-extra/trunk/clangd/index/BackgroundRebuild.cpp
>>>clang-tools-extra/trunk/clangd/index/BackgroundRebuild.h
>>>clang-tools-extra/trunk/clangd/unittests/BackgroundIndexTests.cpp
>>> 
>>> Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=366458=366457=366458=diff
>>>  
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
>>> +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Thu Jul 18 09:25:36 2019
>>> @@ -73,6 +73,7 @@ add_clang_library(clangDaemon
>>>   XRefs.cpp
>>> 
>>>   index/Background.cpp
>>> +  index/BackgroundIndexLoader.cpp
>>>   index/BackgroundIndexStorage.cpp
>>>   index/BackgroundQueue.cpp
>>>   index/BackgroundRebuild.cpp
>>> 
>>> Modified: clang-tools-extra/trunk/clangd/index/Background.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Background.cpp?rev=366458=366457=366458=diff
>>>  
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/index/Background.cpp (original)
>>> +++ clang-tools-extra/trunk/clangd/index/Background.cpp Thu Jul 18 09:25:36 
>>> 2019
>>> @@ -10,6 +10,7 @@
>>> #include "ClangdUnit.h"
>>> #include "Compiler.h"
>>> #include "Context.h"
>>> +#include "FSProvider.h"
>>> #include "Headers.h"
>>> #include "Logger.h"
>>> #include "Path.h"
>>> @@ -18,6 +19,7 @@
>>> #include "Threading.h"
>>> #include "Trace.h"
>>> #include "URI.h"
>>> +#include 

r366620 - [NFC] Remove unused variable

2019-07-19 Thread Denis Bakhvalov via cfe-commits
Author: dendibakh
Date: Fri Jul 19 14:59:42 2019
New Revision: 366620

URL: http://llvm.org/viewvc/llvm-project?rev=366620=rev
Log:
[NFC] Remove unused variable

Change-Id: I5aee24dcdf6eebfbf788e52be22463387f23d927

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=366620=366619=366620=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Jul 19 14:59:42 2019
@@ -9329,7 +9329,7 @@ bool RISCVABIInfo::detectFPCCEligibleStr
   if (const auto *RTy = Ty->getAs()) {
 // Structures with either a non-trivial destructor or a non-trivial
 // copy constructor are not eligible for the FP calling convention.
-if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, CGT.getCXXABI()))
+if (getRecordArgABI(Ty, CGT.getCXXABI()))
   return false;
 if (isEmptyRecord(getContext(), Ty, true))
   return true;


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


[PATCH] D65030: [clang-doc] Add second index for sections within info's content

2019-07-19 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran created this revision.
DiegoAstiazaran added reviewers: juliehockett, jakehehrlich, lebedev.ri.
DiegoAstiazaran added a project: clang-tools-extra.
Herald added a subscriber: arphaman.

This new index contains links to the main section of infos: Namespaces, 
Records, Functions, Enums, Members.
Also to each child function or enum.
Index is currently rendered on top of the info content, this will be fixed 
later with CSS.

  

Depends on D65003 


https://reviews.llvm.org/D65030

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -44,26 +44,36 @@
   std::string Expected = R"raw(
 
 namespace Namespace
+
+  Namespaces
+  Records
+  Functions
+  OneFunction
+
+  Enums
+  OneEnum
+
+
 
   namespace Namespace
-  Namespaces
+  Namespaces
   
 ChildNamespace
   
-  Records
+  Records
   
 ChildStruct
   
-  Functions
+  Functions
   
-OneFunction
+OneFunction
 
   OneFunction()
 
   
-  Enums
+  Enums
   
-enum OneEnum
+enum OneEnum
   
 
 )raw";
@@ -106,6 +116,16 @@
   std::string Expected = R"raw(
 
 class r
+
+  Members
+  Records
+  Functions
+  OneFunction
+
+  Enums
+  OneEnum
+
+
 
   class r
   
@@ -117,25 +137,25 @@
  R"raw(">F
 , G
   
-  Members
+  Members
   
 private int X
   
-  Records
+  Records
   
 ChildStruct
   
-  Functions
+  Functions
   
-OneFunction
+OneFunction
 
   OneFunction()
 
   
-  Enums
+  Enums
   
-enum OneEnum
+enum OneEnum
   
 
 )raw";
@@ -172,7 +192,7 @@
 
 
 
-  f
+  f
   
 float
@@ -211,7 +231,7 @@
 
 
 
-  enum class e
+  enum class e
   
 X
   
@@ -271,7 +291,7 @@
 
 
 
-  f
+  f
   
 void f(int I, int J)
   
Index: clang-tools-extra/clang-doc/Representation.h
===
--- clang-tools-extra/clang-doc/Representation.h
+++ clang-tools-extra/clang-doc/Representation.h
@@ -239,7 +239,7 @@
   void mergeBase(Info &);
   bool mergeable(const Info );
 
-  llvm::SmallString<16> extractName();
+  llvm::SmallString<16> extractName() const;
 
   // Returns a reference to the parent scope (that is, the immediate parent
   // namespace or class in which this decl resides).
@@ -340,11 +340,14 @@
 
 struct Index : public Reference {
   Index() = default;
+  Index(StringRef Name, StringRef JumpToSection)
+  : Reference(Name), JumpToSection(JumpToSection) {}
   Index(SymbolID USR, StringRef Name, InfoType IT, StringRef Path)
   : Reference(USR, Name, IT, Path) {}
   bool operator==(const SymbolID ) const { return USR == Other; }
   bool operator<(const Index ) const { return Name < Other.Name; }
 
+  SmallString<16> JumpToSection;
   std::vector Children;
 
   void sort();
Index: clang-tools-extra/clang-doc/Representation.cpp
===
--- clang-tools-extra/clang-doc/Representation.cpp
+++ clang-tools-extra/clang-doc/Representation.cpp
@@ -197,7 +197,7 @@
   SymbolInfo::merge(std::move(Other));
 }
 
-llvm::SmallString<16> Info::extractName() {
+llvm::SmallString<16> Info::extractName() const {
   if (!Name.empty())
 return Name;
 
Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp
===
--- clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -252,13 +252,20 @@
   return LinkNode;
 }
 
-static std::unique_ptr genTypeReference(const Reference ,
-  StringRef CurrentDirectory) {
-  if (Type.Path.empty())
-return llvm::make_unique(Type.Name);
+static std::unique_ptr
+genTypeReference(const Reference , StringRef CurrentDirectory,
+ StringRef JumpToSection = "") {
+  if (Type.Path.empty()) {
+if (JumpToSection.empty())
+  return llvm::make_unique(Type.Name);
+else
+  return genLink(Type.Name, "#" + JumpToSection);
+  }
   llvm::SmallString<128> Path =
   computeRelativePath(Type.Path, CurrentDirectory);
   llvm::sys::path::append(Path, Type.Name + ".html");
+  if (!JumpToSection.empty())
+Path += ("#" + JumpToSection).str();
   return genLink(Type.Name, Path);
 }
 
@@ -285,6 +292,7 @@
 
   std::vector> Out;
   Out.emplace_back(llvm::make_unique(HTMLTag::TAG_H2, "Enums"));
+  Out.back()->Attributes.try_emplace("id", "Enums");
   Out.emplace_back(llvm::make_unique(HTMLTag::TAG_DIV));
   auto  = Out.back();
   for (const auto  : Enums) {
@@ -313,6 +321,7 @@
 
   std::vector> Out;
   

[PATCH] D65029: [Driver] Support for disabling sanitizer runtime linking

2019-07-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: vitalybuka, morehouse, kcc.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change introduces a pair of -fsanitize-link-deps and
-fno-sanitize-link-deps flags which can be used to control linking
of sanitizer runtimes. This is useful in certain environments like
kernels where existing runtime libraries cannot be used.


Repository:
  rC Clang

https://reviews.llvm.org/D65029

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -843,3 +843,19 @@
 // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-ldl"
 // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic"
 // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "--dynamic-list"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address 
-fsanitize-link-deps \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SANITIZE-LINK-DEPS %s
+//
+// CHECK-SANITIZE-LINK-DEPS: libclang_rt.asan-i386.a"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address 
-fno-sanitize-link-deps \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-SANITIZE-LINK-DEPS %s
+//
+// CHECK-NO-SANITIZE-LINK-DEPS-NOT: libclang_rt.asan-i386.a"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -701,6 +701,10 @@
 // C runtime, etc). Returns true if sanitizer system deps need to be linked in.
 bool tools::addSanitizerRuntimes(const ToolChain , const ArgList ,
  ArgStringList ) {
+  if (!Args.hasFlag(options::OPT_fsanitize_link_deps,
+options::OPT_fno_sanitize_link_deps, true))
+return false;
+
   SmallVector SharedRuntimes, StaticRuntimes,
   NonWholeStaticRuntimes, HelperStaticRuntimes, RequiredSymbols;
   collectSanitizerRuntimes(TC, Args, SharedRuntimes, StaticRuntimes,
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1088,6 +1088,15 @@
   HelpText<"Strip (or keep only, if negative) a given number of path 
components "
"when emitting check metadata.">;
 
+def fsanitize_link_deps : Flag<["-"], "fsanitize-link-deps">,
+  Group,
+  Flags<[CC1Option]>,
+  HelpText<"Enable linking of sanitizer dependencies">;
+def fno_sanitize_link_deps : Flag<["-"], "fno-sanitize-link-deps">,
+ Group,
+ Flags<[CC1Option]>,
+ HelpText<"Disable linking of sanitizer 
dependencies">;
+
 } // end -f[no-]sanitize* flags
 
 def funsafe_math_optimizations : Flag<["-"], "funsafe-math-optimizations">,


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -843,3 +843,19 @@
 // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-ldl"
 // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic"
 // CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "--dynamic-list"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -fsanitize-link-deps \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SANITIZE-LINK-DEPS %s
+//
+// CHECK-SANITIZE-LINK-DEPS: libclang_rt.asan-i386.a"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -fno-sanitize-link-deps \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-SANITIZE-LINK-DEPS %s
+//
+// CHECK-NO-SANITIZE-LINK-DEPS-NOT: libclang_rt.asan-i386.a"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -701,6 +701,10 @@
 // C runtime, etc). Returns true if sanitizer system deps need to be linked in.
 bool tools::addSanitizerRuntimes(const 

[PATCH] D65028: [WebAssembly] Compute and export TLS block alignment

2019-07-19 Thread Guanzhong Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366624: [WebAssembly] Compute and export TLS block alignment 
(authored by quantum, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D65028?vs=210930=210934#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65028/new/

https://reviews.llvm.org/D65028

Files:
  cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtins-wasm.c
  lld/trunk/test/wasm/tls-align.ll
  lld/trunk/test/wasm/tls.ll
  lld/trunk/wasm/Driver.cpp
  lld/trunk/wasm/Symbols.cpp
  lld/trunk/wasm/Symbols.h
  lld/trunk/wasm/Writer.cpp
  llvm/trunk/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/trunk/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/trunk/test/CodeGen/WebAssembly/tls-general-dynamic.ll

Index: lld/trunk/wasm/Symbols.cpp
===
--- lld/trunk/wasm/Symbols.cpp
+++ lld/trunk/wasm/Symbols.cpp
@@ -35,6 +35,7 @@
 GlobalSymbol *WasmSym::stackPointer;
 GlobalSymbol *WasmSym::tlsBase;
 GlobalSymbol *WasmSym::tlsSize;
+GlobalSymbol *WasmSym::tlsAlign;
 UndefinedGlobal *WasmSym::tableBase;
 UndefinedGlobal *WasmSym::memoryBase;
 
Index: lld/trunk/wasm/Writer.cpp
===
--- lld/trunk/wasm/Writer.cpp
+++ lld/trunk/wasm/Writer.cpp
@@ -247,6 +247,9 @@
 if (WasmSym::tlsSize && seg->name == ".tdata") {
   auto *tlsSize = cast(WasmSym::tlsSize);
   tlsSize->global->global.InitExpr.Value.Int32 = seg->size;
+
+  auto *tlsAlign = cast(WasmSym::tlsAlign);
+  tlsAlign->global->global.InitExpr.Value.Int32 = 1U << seg->alignment;
 }
   }
 
Index: lld/trunk/wasm/Symbols.h
===
--- lld/trunk/wasm/Symbols.h
+++ lld/trunk/wasm/Symbols.h
@@ -435,6 +435,10 @@
   // Symbol whose value is the size of the TLS block.
   static GlobalSymbol *tlsSize;
 
+  // __tls_size
+  // Symbol whose value is the alignment of the TLS block.
+  static GlobalSymbol *tlsAlign;
+
   // __data_end
   // Symbol marking the end of the data and bss.
   static DefinedData *dataEnd;
Index: lld/trunk/wasm/Driver.cpp
===
--- lld/trunk/wasm/Driver.cpp
+++ lld/trunk/wasm/Driver.cpp
@@ -450,6 +450,16 @@
   return sym;
 }
 
+static GlobalSymbol *createGlobalVariable(StringRef name, bool isMutable) {
+  llvm::wasm::WasmGlobal wasmGlobal;
+  wasmGlobal.Type = {WASM_TYPE_I32, isMutable};
+  wasmGlobal.InitExpr.Value.Int32 = 0;
+  wasmGlobal.InitExpr.Opcode = WASM_OPCODE_I32_CONST;
+  wasmGlobal.SymbolName = name;
+  return symtab->addSyntheticGlobal(name, WASM_SYMBOL_VISIBILITY_HIDDEN,
+make(wasmGlobal, nullptr));
+}
+
 // Create ABI-defined synthetic symbols
 static void createSyntheticSymbols() {
   static WasmSignature nullSignature = {{}, {}};
@@ -517,24 +527,9 @@
   }
 
   if (config->sharedMemory && !config->shared) {
-llvm::wasm::WasmGlobal tlsBaseGlobal;
-tlsBaseGlobal.Type = {WASM_TYPE_I32, true};
-tlsBaseGlobal.InitExpr.Value.Int32 = 0;
-tlsBaseGlobal.InitExpr.Opcode = WASM_OPCODE_I32_CONST;
-tlsBaseGlobal.SymbolName = "__tls_base";
-WasmSym::tlsBase =
-symtab->addSyntheticGlobal("__tls_base", WASM_SYMBOL_VISIBILITY_HIDDEN,
-   make(tlsBaseGlobal, nullptr));
-
-llvm::wasm::WasmGlobal tlsSizeGlobal;
-tlsSizeGlobal.Type = {WASM_TYPE_I32, false};
-tlsSizeGlobal.InitExpr.Value.Int32 = 0;
-tlsSizeGlobal.InitExpr.Opcode = WASM_OPCODE_I32_CONST;
-tlsSizeGlobal.SymbolName = "__tls_size";
-WasmSym::tlsSize =
-symtab->addSyntheticGlobal("__tls_size", WASM_SYMBOL_VISIBILITY_HIDDEN,
-   make(tlsSizeGlobal, nullptr));
-
+WasmSym::tlsBase = createGlobalVariable("__tls_base", true);
+WasmSym::tlsSize = createGlobalVariable("__tls_size", false);
+WasmSym::tlsAlign = createGlobalVariable("__tls_align", false);
 WasmSym::initTLS = symtab->addSyntheticFunction(
 "__wasm_init_tls", WASM_SYMBOL_VISIBILITY_HIDDEN,
 make(i32ArgSignature, "__wasm_init_tls"));
Index: lld/trunk/test/wasm/tls-align.ll
===
--- lld/trunk/test/wasm/tls-align.ll
+++ lld/trunk/test/wasm/tls-align.ll
@@ -0,0 +1,51 @@
+; RUN: llc -mattr=+bulk-memory -filetype=obj %s -o %t.o
+
+target triple = "wasm32-unknown-unknown"
+
+@no_tls = global i32 0, align 4
+@tls1 = thread_local(localexec) global i32 1, align 4
+@tls2 = thread_local(localexec) global i32 1, align 16
+
+define i32* @tls1_addr() {
+  ret i32* @tls1
+}
+
+define i32* @tls2_addr() {
+  ret i32* @tls2
+}
+
+; RUN: wasm-ld -no-gc-sections --shared-memory --max-memory=131072 

r366624 - [WebAssembly] Compute and export TLS block alignment

2019-07-19 Thread Guanzhong Chen via cfe-commits
Author: quantum
Date: Fri Jul 19 16:34:16 2019
New Revision: 366624

URL: http://llvm.org/viewvc/llvm-project?rev=366624=rev
Log:
[WebAssembly] Compute and export TLS block alignment

Summary:
Add immutable WASM global `__tls_align` which stores the alignment
requirements of the TLS segment.

Add `__builtin_wasm_tls_align()` intrinsic to get this alignment in Clang.

The expected usage has now changed to:

__wasm_init_tls(memalign(__builtin_wasm_tls_align(),
 __builtin_wasm_tls_size()));

Reviewers: tlively, aheejin, sbc100, sunfish, alexcrichton

Reviewed By: tlively

Subscribers: dschuff, jgravelle-google, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins-wasm.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def?rev=366624=366623=366624=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsWebAssembly.def Fri Jul 19 16:34:16 
2019
@@ -31,6 +31,7 @@ TARGET_BUILTIN(__builtin_wasm_data_drop,
 
 // Thread-local storage
 TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory")
+TARGET_BUILTIN(__builtin_wasm_tls_align, "z", "nc", "bulk-memory")
 TARGET_BUILTIN(__builtin_wasm_tls_base, "v*", "nU", "bulk-memory")
 
 // Floating point min/max

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=366624=366623=366624=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Fri Jul 19 16:34:16 2019
@@ -13924,6 +13924,11 @@ Value *CodeGenFunction::EmitWebAssemblyB
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_size, ResultType);
 return Builder.CreateCall(Callee);
   }
+  case WebAssembly::BI__builtin_wasm_tls_align: {
+llvm::Type *ResultType = ConvertType(E->getType());
+Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_align, ResultType);
+return Builder.CreateCall(Callee);
+  }
   case WebAssembly::BI__builtin_wasm_tls_base: {
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_tls_base);
 return Builder.CreateCall(Callee);

Modified: cfe/trunk/test/CodeGen/builtins-wasm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-wasm.c?rev=366624=366623=366624=diff
==
--- cfe/trunk/test/CodeGen/builtins-wasm.c (original)
+++ cfe/trunk/test/CodeGen/builtins-wasm.c Fri Jul 19 16:34:16 2019
@@ -44,6 +44,12 @@ __SIZE_TYPE__ tls_size() {
   // WEBASSEMBLY64: call i64 @llvm.wasm.tls.size.i64()
 }
 
+__SIZE_TYPE__ tls_align() {
+  return __builtin_wasm_tls_align();
+  // WEBASSEMBLY32: call i32 @llvm.wasm.tls.align.i32()
+  // WEBASSEMBLY64: call i64 @llvm.wasm.tls.align.i64()
+}
+
 void *tls_base() {
   return __builtin_wasm_tls_base();
   // WEBASSEMBLY: call i8* @llvm.wasm.tls.base()


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


[PATCH] D65028: [WebAssembly] Compute and export TLS block alignment

2019-07-19 Thread Thomas Lively via Phabricator via cfe-commits
tlively accepted this revision.
tlively added a comment.
This revision is now accepted and ready to land.

Nice


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65028/new/

https://reviews.llvm.org/D65028



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


[PATCH] D65028: [WebAssembly] Compute and export TLS block alignment

2019-07-19 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum created this revision.
quantum added reviewers: tlively, aheejin, sbc100, sunfish, alexcrichton.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, 
jgravelle-google, dschuff.
Herald added projects: clang, LLVM.

Add immutable WASM global `__tls_align` which stores the alignment
requirements of the TLS segment.

Add `__builtin_wasm_tls_align()` intrinsic to get this alignment in Clang.

The expected usage has now changed to:

  __wasm_init_tls(memalign(__builtin_wasm_tls_align(),
   __builtin_wasm_tls_size()));


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65028

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  lld/test/wasm/tls-align.ll
  lld/test/wasm/tls.ll
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll

Index: llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll
===
--- llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll
+++ llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll
@@ -75,6 +75,15 @@
   ret i32 %1
 }
 
+; CHECK-LABEL: tls_align:
+; CHECK-NEXT: .functype tls_align () -> (i32)
+define i32 @tls_align() {
+; CHECK-NEXT: global.get __tls_align
+; CHECK-NEXT: return
+  %1 = call i32 @llvm.wasm.tls.align.i32()
+  ret i32 %1
+}
+
 ; CHECK-LABEL: tls_base:
 ; CHECK-NEXT: .functype tls_base () -> (i32)
 define i8* @tls_base() {
@@ -104,4 +113,5 @@
 @tls = internal thread_local global i32 0
 
 declare i32 @llvm.wasm.tls.size.i32()
+declare i32 @llvm.wasm.tls.align.i32()
 declare i8* @llvm.wasm.tls.base()
Index: llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
@@ -79,7 +79,7 @@
   // Clang-provided symbols.
   if (strcmp(Name, "__stack_pointer") == 0 || strcmp(Name, "__tls_base") == 0 ||
   strcmp(Name, "__memory_base") == 0 || strcmp(Name, "__table_base") == 0 ||
-  strcmp(Name, "__tls_size") == 0) {
+  strcmp(Name, "__tls_size") == 0 || strcmp(Name, "__tls_align") == 0) {
 bool Mutable =
 strcmp(Name, "__stack_pointer") == 0 || strcmp(Name, "__tls_base") == 0;
 WasmSym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL);
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
@@ -224,6 +224,16 @@
   ReplaceNode(Node, TLSSize);
   return;
 }
+case Intrinsic::wasm_tls_align: {
+  MVT PtrVT = TLI->getPointerTy(CurDAG->getDataLayout());
+  assert(PtrVT == MVT::i32 && "only wasm32 is supported for now");
+
+  MachineSDNode *TLSAlign = CurDAG->getMachineNode(
+  WebAssembly::GLOBAL_GET_I32, DL, PtrVT,
+  CurDAG->getTargetExternalSymbol("__tls_align", MVT::i32));
+  ReplaceNode(Node, TLSAlign);
+  return;
+}
 }
 break;
   }
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -133,6 +133,11 @@
 [],
 [IntrNoMem, IntrSpeculatable]>;
 
+def int_wasm_tls_align :
+  Intrinsic<[llvm_anyint_ty],
+[],
+[IntrNoMem, IntrSpeculatable]>;
+
 def int_wasm_tls_base :
   Intrinsic<[llvm_ptr_ty],
 [],
Index: lld/wasm/Writer.cpp
===
--- lld/wasm/Writer.cpp
+++ lld/wasm/Writer.cpp
@@ -247,6 +247,9 @@
 if (WasmSym::tlsSize && seg->name == ".tdata") {
   auto *tlsSize = cast(WasmSym::tlsSize);
   tlsSize->global->global.InitExpr.Value.Int32 = seg->size;
+
+  auto *tlsAlign = cast(WasmSym::tlsAlign);
+  tlsAlign->global->global.InitExpr.Value.Int32 = 1U << seg->alignment;
 }
   }
 
Index: lld/wasm/Symbols.h
===
--- lld/wasm/Symbols.h
+++ lld/wasm/Symbols.h
@@ -435,6 +435,10 @@
   // Symbol whose value is the size of the TLS block.
   static GlobalSymbol *tlsSize;
 
+  // __tls_size
+  // Symbol whose value is the alignment of the TLS block.
+  static GlobalSymbol *tlsAlign;
+
   // __data_end
   // Symbol marking the end of the data and bss.
   static DefinedData *dataEnd;
Index: lld/wasm/Symbols.cpp
===
--- lld/wasm/Symbols.cpp
+++ lld/wasm/Symbols.cpp
@@ -35,6 +35,7 

[PATCH] D65009: [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1

2019-07-19 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366623: [LTO] Always mark regular LTO units with 
EnableSplitLTOUnit=1 (authored by tejohnson, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65009/new/

https://reviews.llvm.org/D65009

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/split-lto-unit.c


Index: cfe/trunk/test/CodeGen/split-lto-unit.c
===
--- cfe/trunk/test/CodeGen/split-lto-unit.c
+++ cfe/trunk/test/CodeGen/split-lto-unit.c
@@ -0,0 +1,12 @@
+// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
+// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
+// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
+//
+// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis 
-o - | FileCheck %s --check-prefix=SPLIT
+// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
+//
+// ; Check that regular LTO has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=SPLIT
+
+int main() {}
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -852,7 +852,7 @@
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
+ uint32_t(1));
   }
 
   PerModulePasses.add(createBitcodeWriterPass(


Index: cfe/trunk/test/CodeGen/split-lto-unit.c
===
--- cfe/trunk/test/CodeGen/split-lto-unit.c
+++ cfe/trunk/test/CodeGen/split-lto-unit.c
@@ -0,0 +1,12 @@
+// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
+// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
+// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
+//
+// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --check-prefix=SPLIT
+// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
+//
+// ; Check that regular LTO has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
+
+int main() {}
Index: cfe/trunk/lib/CodeGen/BackendUtil.cpp
===
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp
@@ -852,7 +852,7 @@
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
+ uint32_t(1));
   }
 
   PerModulePasses.add(createBitcodeWriterPass(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366623 - [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1

2019-07-19 Thread Teresa Johnson via cfe-commits
Author: tejohnson
Date: Fri Jul 19 16:02:58 2019
New Revision: 366623

URL: http://llvm.org/viewvc/llvm-project?rev=366623=rev
Log:
[LTO] Always mark regular LTO units with EnableSplitLTOUnit=1

Summary:
Regular LTO modules do not need LTO Unit splitting, only ThinLTO does
(they must be consistently split into regular and Thin units for
optimizations such as whole program devirtualization and lower type
tests). In order to avoid spurious errors from LTO when combining with
split ThinLTO modules, always set this flag for regular LTO modules.

Reviewers: pcc

Subscribers: mehdi_amini, Prazek, inglorion, steven_wu, dexonsmith, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGen/split-lto-unit.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=366623=366622=366623=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Jul 19 16:02:58 2019
@@ -852,7 +852,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
+ uint32_t(1));
   }
 
   PerModulePasses.add(createBitcodeWriterPass(

Added: cfe/trunk/test/CodeGen/split-lto-unit.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-lto-unit.c?rev=366623=auto
==
--- cfe/trunk/test/CodeGen/split-lto-unit.c (added)
+++ cfe/trunk/test/CodeGen/split-lto-unit.c Fri Jul 19 16:02:58 2019
@@ -0,0 +1,12 @@
+// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
+// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
+// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
+//
+// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis 
-o - | FileCheck %s --check-prefix=SPLIT
+// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
+//
+// ; Check that regular LTO has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=SPLIT
+
+int main() {}


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


[PATCH] D64765: [OPENMP]Add support for analysis of firstprivate variables.

2019-07-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: include/clang/AST/OpenMPClause.h:2102-2103
   child_range used_children() {
-return child_range(child_iterator(), child_iterator());
+return child_range(reinterpret_cast(varlist_begin()),
+   reinterpret_cast(varlist_end()));
   }

NoQ wrote:
> So, basically, the first approximation is that all children are used?
Yes, but only for some clauses.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64765/new/

https://reviews.llvm.org/D64765



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


[PATCH] D65009: [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1

2019-07-19 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65009/new/

https://reviews.llvm.org/D65009



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


[PATCH] D65009: [LTO] Always mark regular LTO units with EnableSplitLTOUnit=1

2019-07-19 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 210918.
tejohnson added a comment.

Address comments


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65009/new/

https://reviews.llvm.org/D65009

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/split-lto-unit.c


Index: test/CodeGen/split-lto-unit.c
===
--- /dev/null
+++ test/CodeGen/split-lto-unit.c
@@ -0,0 +1,12 @@
+// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
+// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
+// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
+//
+// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis 
-o - | FileCheck %s --check-prefix=SPLIT
+// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
+//
+// ; Check that regular LTO has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=SPLIT
+
+int main() {}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -848,7 +848,7 @@
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
+ uint32_t(1));
   }
 
   PerModulePasses.add(createBitcodeWriterPass(


Index: test/CodeGen/split-lto-unit.c
===
--- /dev/null
+++ test/CodeGen/split-lto-unit.c
@@ -0,0 +1,12 @@
+// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
+// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
+// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
+//
+// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --check-prefix=SPLIT
+// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
+//
+// ; Check that regular LTO has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=SPLIT
+
+int main() {}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -848,7 +848,7 @@
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
 TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
+ uint32_t(1));
   }
 
   PerModulePasses.add(createBitcodeWriterPass(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65009: [LTO] Don't mark regular LTO units with EnableSplitLTOUnit

2019-07-19 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D65009#1594009 , @pcc wrote:

> Sorry, just realized this. If I do
>
>   clang++ -c -flto a.cpp # "split"
>   clang++ -c -flto=thin b.cpp -fwhole-program-vtables # non-split
>   clang++ a.o b.o
>
>
> this should fail, right? If I'm not mistaken, this patch series will cause 
> this to succeed. I think we need to change this patch so that it always sets 
> `EnableSplitLTOUnit` to 1 for regular LTO, then you can drop the other patch.


This is a good point. We could detect and handle this during the LTO merging 
here, but I don't think it is worth it (it would essentially be treating 
regular LTO as split in any case). The change you suggested fixes the original 
bug, re running the llvm/clang tests now and will update the patches afterwards.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65009/new/

https://reviews.llvm.org/D65009



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


[PATCH] D64765: [OPENMP]Add support for analysis of firstprivate variables.

2019-07-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/AST/OpenMPClause.h:2102-2103
   child_range used_children() {
-return child_range(child_iterator(), child_iterator());
+return child_range(reinterpret_cast(varlist_begin()),
+   reinterpret_cast(varlist_end()));
   }

So, basically, the first approximation is that all children are used?



Comment at: test/Analysis/cfg-openmp.cpp:188
 // CHECK-NEXT:  [[#TARGET+6]]: [B1.[[#TARGET+5]]] (ImplicitCastExpr, 
IntegralToBoolean, _Bool)
-// CHECK-NEXT:  [[#TARGET+7]]: #pragma omp target depend(in : argc) if(cond)
+// CHECK-NEXT:  [[#TARGET+7]]: fp
+// CHECK-NEXT:  [[#TARGET+8]]: argc

ABataev wrote:
> In `task` and `target` regions some of the variables might be implicit 
> firstprivate just like in this case.
Aha, yup, i see, so we need to evaluate them again because we're after their 
lvalues so that to capture them by reference. I guess this kinda sorts out my 
questions.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64765/new/

https://reviews.llvm.org/D64765



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


[PATCH] D65022: [Sema] Always instantiate the initializer of a variable template with undeduced type (8.0 regression)

2019-07-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Well, this restores an incorrect behaviour: we're not permitted to substitute 
into the initializer of the variable template here.

Can you look into fixing this properly, by instantiating the type when forming 
the MemberExpr? If not, taking this to fix the regression seems OK, but please 
file a bug for the introduced misbehaviour.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65022/new/

https://reviews.llvm.org/D65022



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


[PATCH] D65012: Adds support for formatting NS_CLOSED_ENUM alongside NS_ENUM.

2019-07-19 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton requested changes to this revision.
benhamilton added a comment.
This revision now requires changes to proceed.

Thanks! Don't forget the CF version.




Comment at: clang/lib/Format/FormatToken.h:793
   IdentifierInfo *kw_CF_OPTIONS;
+  IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;

We'll also need `CF_CLOSED_ENUM`.




Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1219
+ Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS,
+ Keywords.kw_NS_CLOSED_ENUM))
 parseEnum();

`Keywords.CF_CLOSED_ENUM` here as well.




Comment at: clang/unittests/Format/FormatTest.cpp:1717-1736
 TEST_F(FormatTest, FormatsNSEnums) {
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, SomeName) { AAA, BBB }");
+  verifyGoogleFormat(
+  "typedef NS_CLOSED_ENUM(NSInteger, SomeName) { AAA, BBB }");
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n"
  "  // Information about someDecentlyLongValue.\n"
  "  someDecentlyLongValue,\n"

Please also add a test for `CF_CLOSED_ENUM`.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65012/new/

https://reviews.llvm.org/D65012



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


[PATCH] D65022: [Sema] Always instantiate the initializer of a variable template with undeduced type (8.0 regression)

2019-07-19 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, rjmccall.
Herald added subscribers: dexonsmith, jkorous.
Herald added a project: clang.

This patch fixes a regression introduced in r359947. Here:

  template  struct Outer {
template  static constexpr auto x = 1;
  };
  
  int main() {
Outer x;
int i = x.x;
  }

We'd defer the instantiation of the initializer of the variable template when 
instantiating Outer (leaving the variable template with an undeduced 
type). We do eventually instantiate the initializer and deduce the type of the 
variable when we're marking `Outer::x` referenced, but not before 
forming a MemberExpr that refers to the undeduced type. I think we could avoid 
instantiating the initializer of the variable template here, but that doesn't 
appear to be the intent of r359947, so this patch just falls back to the 8.0 
behaviour.

Fixes rdar://52619644

Thanks for taking a look!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D65022

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp


Index: clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
===
--- clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -395,3 +395,20 @@
   }
   int  = B::template n; // expected-error {{use of variable template 'n' 
requires template arguments}}
 }
+
+#ifndef PRECXX11
+namespace auto_variable_instantiate_initializer {
+template  struct S {
+  template  static constexpr auto v = 1;
+  template  static constexpr auto v2 = T{};
+};
+
+void useit() {
+  S x;
+  // We used to fail to instantiate the initializer, leading to an auto type
+  // leaking through here.
+  int i = x.v;
+  float j = x.v2;
+}
+}
+#endif
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4506,11 +4506,11 @@
   Context.setStaticLocalNumber(NewVar, Context.getStaticLocalNumber(OldVar));
 
   // Figure out whether to eagerly instantiate the initializer.
-  if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
-// We're producing a template. Don't instantiate the initializer yet.
-  } else if (NewVar->getType()->isUndeducedType()) {
+  if (NewVar->getType()->isUndeducedType()) {
 // We need the type to complete the declaration of the variable.
 InstantiateVariableInitializer(NewVar, OldVar, TemplateArgs);
+  } else if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
+// We're producing a template. Don't instantiate the initializer yet.
   } else if (InstantiatingSpecFromTemplate ||
  (OldVar->isInline() && OldVar->isThisDeclarationADefinition() &&
   !NewVar->isThisDeclarationADefinition())) {


Index: clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
===
--- clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -395,3 +395,20 @@
   }
   int  = B::template n; // expected-error {{use of variable template 'n' requires template arguments}}
 }
+
+#ifndef PRECXX11
+namespace auto_variable_instantiate_initializer {
+template  struct S {
+  template  static constexpr auto v = 1;
+  template  static constexpr auto v2 = T{};
+};
+
+void useit() {
+  S x;
+  // We used to fail to instantiate the initializer, leading to an auto type
+  // leaking through here.
+  int i = x.v;
+  float j = x.v2;
+}
+}
+#endif
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4506,11 +4506,11 @@
   Context.setStaticLocalNumber(NewVar, Context.getStaticLocalNumber(OldVar));
 
   // Figure out whether to eagerly instantiate the initializer.
-  if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
-// We're producing a template. Don't instantiate the initializer yet.
-  } else if (NewVar->getType()->isUndeducedType()) {
+  if (NewVar->getType()->isUndeducedType()) {
 // We need the type to complete the declaration of the variable.
 InstantiateVariableInitializer(NewVar, OldVar, TemplateArgs);
+  } else if (InstantiatingVarTemplate || InstantiatingVarTemplatePartialSpec) {
+// We're producing a template. Don't instantiate the initializer yet.
   } else if (InstantiatingSpecFromTemplate ||
  (OldVar->isInline() && OldVar->isThisDeclarationADefinition() &&
   !NewVar->isThisDeclarationADefinition())) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D58091: Customize warnings for missing built-in type

2019-07-19 Thread Brian Cain via Phabricator via cfe-commits
bcain accepted this revision.
bcain added a comment.
Herald added a subscriber: dmgreen.

@jdoerfert @jyknight @lebedev.ri@rsmith @aaron.ballman

This will appear as a 9.0 regression, right?  Let's please consider a way to 
address it for 9.0 before it's released.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58091/new/

https://reviews.llvm.org/D58091



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


[PATCH] D64780: Disallow most calling convention attributes on PS4.

2019-07-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366617: Disallow most calling convention attributes on PS4 
(authored by ssrivastava, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64780?vs=210674=210902#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64780/new/

https://reviews.llvm.org/D64780

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/Basic/Targets/OSTargets.h
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/no_callconv.cpp
  cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2966,6 +2966,7 @@
   "|on builtin function"
   "}1">,
   InGroup;
+def error_cconv_unsupported : Error;
 def err_cconv_knr : Error<
   "function with no prototype cannot use the %0 calling convention">;
 def warn_cconv_knr : Warning<
Index: cfe/trunk/include/clang/Basic/TargetInfo.h
===
--- cfe/trunk/include/clang/Basic/TargetInfo.h
+++ cfe/trunk/include/clang/Basic/TargetInfo.h
@@ -1268,6 +1268,7 @@
 CCCR_OK,
 CCCR_Warning,
 CCCR_Ignore,
+CCCR_Error,
   };
 
   /// Determines whether a given calling convention is valid for the
Index: cfe/trunk/test/Sema/no_callconv.cpp
===
--- cfe/trunk/test/Sema/no_callconv.cpp
+++ cfe/trunk/test/Sema/no_callconv.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -DPS4 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fsyntax-only -verify
+
+#ifdef PS4
+
+// PS4 does not support these.
+void __vectorcall func_vc() {} // expected-error {{'__vectorcall' calling convention is not supported for this target}}
+void __regcall func_rc() {} // expected-error {{'__regcall' calling convention is not supported for this target}}
+void __attribute__((vectorcall)) funcA() {} // expected-error {{'vectorcall' calling convention is not supported for this target}}
+void __attribute__((regcall)) funcB() {} // expected-error {{'regcall' calling convention is not supported for this target}}
+void __attribute__((ms_abi)) funcH() {} // expected-error {{'ms_abi' calling convention is not supported for this target}}
+void __attribute__((intel_ocl_bicc)) funcJ() {} // expected-error {{'intel_ocl_bicc' calling convention is not supported for this target}}
+void __attribute__((swiftcall)) funcK() {} // expected-error {{'swiftcall' calling convention is not supported for this target}}
+void __attribute__((pascal)) funcG() {} // expected-error {{'pascal' calling convention is not supported for this target}}
+void __attribute__((preserve_most)) funcL() {} // expected-error {{'preserve_most' calling convention is not supported for this target}}
+void __attribute__((preserve_all)) funcM() {} // expected-error {{'preserve_all' calling convention is not supported for this target}}
+void __attribute__((stdcall)) funcD() {} // expected-error {{'stdcall' calling convention is not supported for this target}}
+void __attribute__((fastcall)) funcE() {} // expected-error {{'fastcall' calling convention is not supported for this target}}
+void __attribute__((thiscall)) funcF() {} // expected-error {{'thiscall' calling convention is not supported for this target}}
+#else
+
+void __vectorcall func_vc() {}
+void __regcall func_rc() {}
+void __attribute__((vectorcall)) funcA() {}
+void __attribute__((regcall)) funcB() {}
+void __attribute__((ms_abi)) funcH() {}
+void __attribute__((intel_ocl_bicc)) funcJ() {}
+void __attribute__((swiftcall)) funcK() {}
+void __attribute__((preserve_most)) funcL() {}
+void __attribute__((preserve_all)) funcM() {}
+
+// Same function with different calling conventions. Error with a note pointing to the last decl.
+void __attribute__((preserve_all)) funcR(); // expected-note {{previous declaration is here}}
+void __attribute__((preserve_most)) funcR(); // expected-error {{function declared 'preserve_most' here was previously declared 'preserve_all'}}
+
+void __attribute__((pascal)) funcG() {} // expected-warning {{'pascal' calling convention is not supported for this target}}
+
+void __attribute__((stdcall)) funcD() {} // expected-warning {{'stdcall' calling convention is not supported for this target}}
+void __attribute__((fastcall)) funcE() {} // expected-warning {{'fastcall' calling convention is not supported for this target}}
+void __attribute__((thiscall)) funcF() {} // expected-warning {{'thiscall' calling convention is not supported for this target}}
+#endif
+
+void __attribute__((sysv_abi)) funcI() 

[PATCH] D61479: Finish "Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO"

2019-07-19 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D61479#1586987 , @sberg wrote:

> eh, the summary here doesn't get updated from the actual git commit message :(
>
> thanks for the reviews!


You can use `arc diff --verbatim` to update the summary based on your local 
commit message. You'll want to have done an `arc amend` before that to get any 
extra reviewers, subscribers, etc. from Phabricator into your local commit 
message, otherwise the `arc diff --verbatim` will happily override those too.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61479/new/

https://reviews.llvm.org/D61479



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


[PATCH] D64646: [OPENMP]Add support for analysis of if clauses.

2019-07-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/cfg-openmp.cpp:58-67
 #pragma omp distribute simd
   for (int i = 0; i < 10; ++i)
 argc = x;
-// CHECK-NEXT:  27: x
-// CHECK-NEXT:  28: [B1.27] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:  29: argc
-// CHECK-NEXT:  30: [B1.29] = [B1.28]
-// CHECK-NEXT:  31: #pragma omp for
+// CHECK-NEXT:  [[#FOR:]]: x
+// CHECK-NEXT:  [[#FOR+1]]: [B1.[[#FOR]]] (ImplicitCastExpr, LValueToRValue, 
int)
+// CHECK-NEXT:  [[#FOR+2]]: argc
+// CHECK-NEXT:  [[#FOR+3]]: [B1.[[#FOR+2]]] = [B1.[[#FOR+1]]]

ABataev wrote:
> NoQ wrote:
> > I'm slowly updating my mental model of these CFGs. Just to confirm my 
> > understanding - tried the following example:
> > 
> > ```lang=c++
> > int main(int argc, char **argv) {
> >   int x = 0;
> > #pragma omp for
> >   for (int i = 0; i < 10; ++i)
> > x += argv[i];
> > }
> > ```
> > 
> > The CFG was as follows:
> > 
> > ```
> >1: 0
> >2: int x = 0;
> >3: x
> >4: argv
> >5: [B1.4] (ImplicitCastExpr, LValueToRValue, char **)
> >6: i
> >7: [B1.6] (ImplicitCastExpr, LValueToRValue, int)
> >8: [B1.5][[B1.7]]
> >9: [B1.8] (ImplicitCastExpr, LValueToRValue, char *)
> >   10: [B1.3] += [B1.9]
> >   11: #pragma omp for
> > for (int i = 0; i < 10; ++i)
> > [B1.10];
> > ```
> > 
> > Do i understand correctly that `[B1.10]` aka `argv[0]` is going to act like 
> > an "argument" to the "outlined function" and then it's going to be re-used 
> > (as if it was a "local" "variable") on subsequent iterations of the loop 
> > (i.e., assigned values `argv[1]`, ..., `argv[9]`)? I.e., the "function" is 
> > going to be responsible for computing `argv[1]` and storing it in the 
> > "parameter variable" (`OMPCapturedExprDecl` which is a sub-class of 
> > `VarDecl`) that previously contained `argv[0]`, but it's not responsible 
> > for computing `argv[0]` itself, right?
> `argv` here is the shared variable, so it is passed by reference to the 
> "outlined function". We do not create local copy of this variable here, we 
> use the original `argv` in the "outlined function".
> you can consider this code as something like this:
> ```
> char **argv;
> int x = 0;
> outlined(x, argv);
> ...
> 
> void outlined(char **, int ) {
>   for(int i =0; i < 10; ++i)
>   x += argv[i];
> }
> 
> ```
> This is very schematic but good enough to understand how it works.
> 
> `OMPCapturedExprDecl` is used only in some rare cases, when we need to pass 
> the expression to the outlined region. For example:
> ```
> #pragma omp target parallel if(a+b)
> 
> ```
> After codegen it must look like this:
> ```
>  int .captured_expr. = a+b;
> if (.captured_expr.) {
>   offload target_outlined(.captured_expr.)
> } else {
>   call on host target_outlined(.captured_expr.)
> }
> ...
> void target_outlined(int .captured_expr.) {
>   if (.captured_expr.)
> parallel outlined();
>   else
> serialized outlined();
> }
> ...
> void outined() {
> ;
> }
> ```
> In this case `if` clause is applied to both, `target` and `parallel` 
> constructs. We could capture variables `a` and `b` and calculate `a+b` inside 
> of the target region but this is not effective. Instead, it is better to 
> capture the result of `a+b` condition into the special variable and capture 
> only this single variable by value (the value of clauses in most cases must 
> be pre-evaluated before the real execution of the OpenMP construct). Does it 
> make it a little bit clearer?
> `OMPCapturedExprDecl` is used only in some rare cases, only for the complex 
> combined constructs (which consists of several simple constructs) and only 
> for the clauses, which require expression evaluation before entering the 
> construct.
I think i managed to consume this, thanks!! I'll ask more questions when i have 
them.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64646/new/

https://reviews.llvm.org/D64646



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


r366617 - Disallow most calling convention attributes on PS4

2019-07-19 Thread Sunil Srivastava via cfe-commits
Author: ssrivastava
Date: Fri Jul 19 14:38:34 2019
New Revision: 366617

URL: http://llvm.org/viewvc/llvm-project?rev=366617=rev
Log:
Disallow most calling convention attributes on PS4

PS4 now only allows "cdecl", and its equivalent on PS4, "sysv_abi".

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

Added:
cfe/trunk/test/Sema/no_callconv.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/Basic/Targets/OSTargets.h
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=366617=366616=366617=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Jul 19 14:38:34 
2019
@@ -2966,6 +2966,7 @@ def warn_cconv_unsupported : Warning<
   "|on builtin function"
   "}1">,
   InGroup;
+def error_cconv_unsupported : Error;
 def err_cconv_knr : Error<
   "function with no prototype cannot use the %0 calling convention">;
 def warn_cconv_knr : Warning<

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=366617=366616=366617=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Fri Jul 19 14:38:34 2019
@@ -1268,6 +1268,7 @@ public:
 CCCR_OK,
 CCCR_Warning,
 CCCR_Ignore,
+CCCR_Error,
   };
 
   /// Determines whether a given calling convention is valid for the

Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=366617=366616=366617=diff
==
--- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
+++ cfe/trunk/lib/Basic/Targets/OSTargets.h Fri Jul 19 14:38:34 2019
@@ -561,6 +561,10 @@ public:
   break;
 }
   }
+  TargetInfo::CallingConvCheckResult
+  checkCallingConvention(CallingConv CC) const override {
+return (CC == CC_C) ? TargetInfo::CCCR_OK : TargetInfo::CCCR_Error;
+  }
 };
 
 // RTEMS Target

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=366617=366616=366617=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Fri Jul 19 14:38:34 2019
@@ -4668,6 +4668,11 @@ bool Sema::CheckCallingConvAttr(const Pa
 CC = CC_C;
 break;
 
+  case TargetInfo::CCCR_Error:
+Diag(Attrs.getLoc(), diag::error_cconv_unsupported)
+<< Attrs << (int)CallingConventionIgnoredReason::ForThisTarget;
+break;
+
   case TargetInfo::CCCR_Warning: {
 Diag(Attrs.getLoc(), diag::warn_cconv_unsupported)
 << Attrs << (int)CallingConventionIgnoredReason::ForThisTarget;

Added: cfe/trunk/test/Sema/no_callconv.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/no_callconv.cpp?rev=366617=auto
==
--- cfe/trunk/test/Sema/no_callconv.cpp (added)
+++ cfe/trunk/test/Sema/no_callconv.cpp Fri Jul 19 14:38:34 2019
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -DPS4 -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fsyntax-only -verify
+
+#ifdef PS4
+
+// PS4 does not support these.
+void __vectorcall func_vc() {} // expected-error {{'__vectorcall' calling 
convention is not supported for this target}}
+void __regcall func_rc() {} // expected-error {{'__regcall' calling convention 
is not supported for this target}}
+void __attribute__((vectorcall)) funcA() {} // expected-error {{'vectorcall' 
calling convention is not supported for this target}}
+void __attribute__((regcall)) funcB() {} // expected-error {{'regcall' calling 
convention is not supported for this target}}
+void __attribute__((ms_abi)) funcH() {} // expected-error {{'ms_abi' calling 
convention is not supported for this target}}
+void __attribute__((intel_ocl_bicc)) funcJ() {} // expected-error 
{{'intel_ocl_bicc' calling convention is not supported for this target}}
+void __attribute__((swiftcall)) funcK() {} // expected-error {{'swiftcall' 
calling convention is not supported for this target}}
+void __attribute__((pascal)) funcG() {} // expected-error {{'pascal' calling 
convention is not supported for this target}}
+void __attribute__((preserve_most)) funcL() {} // expected-error 
{{'preserve_most' calling convention is not supported for this target}}
+void 

[PATCH] D64744: #pragma clang loop vectorize_predicate(enable|disable)

2019-07-19 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

I prefer having the documentation change to be in the same patch as the 
functional change. Makes it easier to check whether they match.




Comment at: clang/test/CodeGenCXX/pragma-loop.cpp:163
 
-// CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[UNROLL_FULL:.*]]}
-// CHECK: ![[UNROLL_FULL]] = !{!"llvm.loop.unroll.full"}
-
-// CHECK: ![[LOOP_2]] = distinct !{![[LOOP_2]], ![[UNROLL_DISABLE:.*]], 
![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_8:.*]], ![[INTERLEAVE_4:.*]]}
-// CHECK: ![[UNROLL_DISABLE]] = !{!"llvm.loop.unroll.disable"}
-// CHECK: ![[DISTRIBUTE_DISABLE]] = !{!"llvm.loop.distribute.enable", i1 false}
-// CHECK: ![[WIDTH_8]] = !{!"llvm.loop.vectorize.width", i32 8}
-// CHECK: ![[INTERLEAVE_4]] = !{!"llvm.loop.interleave.count", i32 4}
-
-// CHECK: ![[LOOP_3]] = distinct !{![[LOOP_3]], ![[INTERLEAVE_4:.*]], 
![[INTENABLE_1:.*]], ![[FOLLOWUP_VECTOR_3:.*]]}
-// CHECK: ![[INTENABLE_1]] = !{!"llvm.loop.vectorize.enable", i1 true}
-// CHECK: ![[FOLLOWUP_VECTOR_3]] = !{!"llvm.loop.vectorize.followup_all", 
![[AFTER_VECTOR_3:.*]]}
-// CHECK: ![[AFTER_VECTOR_3]] = distinct !{![[AFTER_VECTOR_3]], 
![[ISVECTORIZED:.*]], ![[UNROLL_8:.*]]}
-// CHECK: ![[ISVECTORIZED]] = !{!"llvm.loop.isvectorized"}
-// CHECK: ![[UNROLL_8]] = !{!"llvm.loop.unroll.count", i32 8}
-
-// CHECK: ![[LOOP_4]] = distinct !{![[LOOP_4]], ![[WIDTH_2:.*]], 
![[INTERLEAVE_2:.*]]}
-// CHECK: ![[WIDTH_2]] = !{!"llvm.loop.vectorize.width", i32 2}
-// CHECK: ![[INTERLEAVE_2]] = !{!"llvm.loop.interleave.count", i32 2}
-
-// CHECK: ![[LOOP_5]] = distinct !{![[LOOP_5]], ![[UNROLL_DISABLE:.*]], 
![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_1:.*]]}
-// CHECK: ![[WIDTH_1]] = !{!"llvm.loop.vectorize.width", i32 1}
-
-// CHECK: ![[LOOP_6]] = distinct !{![[LOOP_6]], ![[WIDTH_2:.*]], 
![[INTERLEAVE_2:.*]], ![[FOLLOWUP_VECTOR_6:.*]]}
-// CHECK: ![[FOLLOWUP_VECTOR_6]] = !{!"llvm.loop.vectorize.followup_all", 
![[AFTER_VECTOR_6:.*]]}
-// CHECK: ![[AFTER_VECTOR_6]] = distinct !{![[AFTER_VECTOR_6]], 
![[ISVECTORIZED:.*]], ![[UNROLL_8:.*]]}
-
-// CHECK: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[WIDTH_5:.*]]}
-// CHECK: ![[WIDTH_5]] = !{!"llvm.loop.vectorize.width", i32 5}
-
-// CHECK: ![[LOOP_8]] = distinct !{![[LOOP_8]], ![[WIDTH_5:.*]]}
-
-// CHECK: ![[LOOP_9]] = distinct !{![[LOOP_9]], ![[WIDTH_8:.*]], 
![[INTERLEAVE_8:.*]], ![[FOLLOWUP_VECTOR_9:.*]]}
-// CHECK: ![[FOLLOWUP_VECTOR_9]] = !{!"llvm.loop.vectorize.followup_all", 
![[AFTER_VECTOR_9:.*]]}
-// CHECK: ![[AFTER_VECTOR_9]] = distinct !{![[AFTER_VECTOR_9]], 
![[ISVECTORIZED:.*]], ![[UNROLL_8:.*]]}
-
-// CHECK: ![[LOOP_10]] = distinct !{![[LOOP_10]], ![[WIDTH_2:.*]], 
![[INTERLEAVE_2:.*]], ![[FOLLOWUP_VECTOR_10:.*]]}
-// CHECK: ![[FOLLOWUP_VECTOR_10]] = !{!"llvm.loop.vectorize.followup_all", 
![[AFTER_VECTOR_10:.*]]}
-// CHECK: ![[AFTER_VECTOR_10]] = distinct !{![[AFTER_VECTOR_10]], 
![[ISVECTORIZED:.*]], ![[UNROLL_8:.*]]}
-
-// CHECK: ![[LOOP_11]] = distinct !{![[LOOP_11]], ![[WIDTH_2:.*]], 
![[INTERLEAVE_4:.*]], ![[FOLLOWUP_VECTOR_11:.*]]}
-// CHECK: ![[FOLLOWUP_VECTOR_11]] = !{!"llvm.loop.vectorize.followup_all", 
![[AFTER_VECTOR_11:.*]]}
-// CHECK: ![[AFTER_VECTOR_11]] = distinct !{![[AFTER_VECTOR_11]], 
![[ISVECTORIZED:.*]], ![[UNROLL_8:.*]]}
-
-// CHECK: ![[LOOP_12]] = distinct !{![[LOOP_12]], ![[WIDTH_6:.*]], 
![[INTERLEAVE_10:.*]], ![[FOLLOWUP_VECTOR_12:.*]]}
-// CHECK: ![[FOLLOWUP_VECTOR_12]] = !{!"llvm.loop.vectorize.followup_all", 
![[AFTER_VECTOR_12:.*]]}
-// CHECK: ![[AFTER_VECTOR_12]] = distinct !{![[AFTER_VECTOR_12]], 
![[ISVECTORIZED:.*]], ![[UNROLL_24:.*]]}
-// CHECK: ![[UNROLL_24]] = !{!"llvm.loop.unroll.count", i32 24}
-
-// CHECK: ![[LOOP_13]] = distinct !{![[LOOP_13]], ![[WIDTH_8:.*]], 
![[INTERLEAVE_16:.*]], ![[FOLLOWUP_VECTOR_13:.*]]}
-// CHECK: ![[INTERLEAVE_16]] = !{!"llvm.loop.interleave.count", i32 16}
-// CHECK: ![[FOLLOWUP_VECTOR_13]] = !{!"llvm.loop.vectorize.followup_all", 
![[AFTER_VECTOR_13:.*]]}
-// CHECK: ![[AFTER_VECTOR_13]] = distinct !{![[AFTER_VECTOR_13]], 
![[ISVECTORIZED:.*]], ![[UNROLL_32:.*]]}
-// CHECK: ![[UNROLL_32]] = !{!"llvm.loop.unroll.count", i32 32}
-
-// CHECK: ![[LOOP_14]] = distinct !{![[LOOP_14]], ![[WIDTH_10:.*]]}
-// CHECK: ![[WIDTH_10]] = !{!"llvm.loop.vectorize.width", i32 10}
+// CHECK: !2 = distinct !{!2, !3}
+// CHECK: !3 = !{!"llvm.loop.unroll.full"}

I spent quite some time in the past to ensure that the MDNode matchers use 
regexes instead of literals. I'd suggest you create a new test file for 
`vectorize_predicate`, then you don't have to change anything here.



Comment at: clang/test/Parser/pragma-loop.cpp:253
+#pragma clang loop vectorize_predicate(enable)
+/* expected-error {{duplicate directives 'vectorize_predicate(enable)' and 
'vectorize_predicate(disable)'}} */ #pragma clang loop 
vectorize_predicate(disable)
 #pragma clang loop unroll(full)

Can you make the `#pragma` have its own line. You can use `expected-error@+1` 
to make it match another 

[PATCH] D65009: [LTO] Don't mark regular LTO units with EnableSplitLTOUnit

2019-07-19 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Sorry, just realized this. If I do

  clang++ -c -flto a.cpp # "split"
  clang++ -c -flto=thin b.cpp -fwhole-program-vtables # non-split
  clang++ a.o b.o

this should fail, right? If I'm not mistaken, this patch series will cause this 
to succeed. I think we need to change this patch so that it always sets 
`EnableSplitLTOUnit` to 1 for regular LTO, then you can drop the other patch.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65009/new/

https://reviews.llvm.org/D65009



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


[PATCH] D65012: Adds support for formatting NS_CLOSED_ENUM alongside NS_ENUM.

2019-07-19 Thread Hank Heijink via Phabricator via cfe-commits
heijink created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65012

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestObjC.cpp


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -118,6 +118,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style = getStyle("{}", "a.h", "none",
+   "typedef NS_CLOSED_ENUM(NSInteger, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1716,6 +1716,8 @@
 
 TEST_F(FormatTest, FormatsNSEnums) {
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, SomeName) { AAA, BBB }");
+  verifyGoogleFormat(
+  "typedef NS_CLOSED_ENUM(NSInteger, SomeName) { AAA, BBB }");
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n"
  "  // Information about someDecentlyLongValue.\n"
  "  someDecentlyLongValue,\n"
@@ -1724,6 +1726,14 @@
  "  // Information about aThirdDecentlyLongValue.\n"
  "  aThirdDecentlyLongValue\n"
  "};");
+  verifyGoogleFormat("typedef NS_CLOSED_ENUM(NSInteger, MyType) {\n"
+ "  // Information about someDecentlyLongValue.\n"
+ "  someDecentlyLongValue,\n"
+ "  // Information about anotherDecentlyLongValue.\n"
+ "  anotherDecentlyLongValue,\n"
+ "  // Information about aThirdDecentlyLongValue.\n"
+ "  aThirdDecentlyLongValue\n"
+ "};");
   verifyGoogleFormat("typedef NS_OPTIONS(NSInteger, MyType) {\n"
  "  a = 1,\n"
  "  b = 2,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1215,7 +1215,8 @@
 case tok::kw_typedef:
   nextToken();
   if (FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS,
- Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS))
+ Keywords.kw_CF_ENUM, Keywords.kw_CF_OPTIONS,
+ Keywords.kw_NS_CLOSED_ENUM))
 parseEnum();
   break;
 case tok::kw_struct:
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -679,6 +679,7 @@
 kw_of = ("of");
 kw_CF_ENUM = ("CF_ENUM");
 kw_CF_OPTIONS = ("CF_OPTIONS");
+kw_NS_CLOSED_ENUM = ("NS_CLOSED_ENUM");
 kw_NS_ENUM = ("NS_ENUM");
 kw_NS_OPTIONS = ("NS_OPTIONS");
 
@@ -789,6 +790,7 @@
   IdentifierInfo *kw_of;
   IdentifierInfo *kw_CF_ENUM;
   IdentifierInfo *kw_CF_OPTIONS;
+  IdentifierInfo *kw_NS_CLOSED_ENUM;
   IdentifierInfo *kw_NS_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;


Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -118,6 +118,11 @@
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
 
+  Style = getStyle("{}", "a.h", "none",
+   "typedef NS_CLOSED_ENUM(NSInteger, Foo) {};\n");
+  ASSERT_TRUE((bool)Style);
+  EXPECT_EQ(FormatStyle::LK_ObjC, Style->Language);
+
   Style = getStyle("{}", "a.h", "none", "enum Foo {};");
   ASSERT_TRUE((bool)Style);
   EXPECT_EQ(FormatStyle::LK_Cpp, Style->Language);
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1716,6 +1716,8 @@
 
 TEST_F(FormatTest, FormatsNSEnums) {
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, SomeName) { AAA, BBB }");
+  verifyGoogleFormat(
+  "typedef NS_CLOSED_ENUM(NSInteger, SomeName) { AAA, BBB }");
   verifyGoogleFormat("typedef NS_ENUM(NSInteger, MyType) {\n"
  "  // Information about someDecentlyLongValue.\n"
  "  someDecentlyLongValue,\n"
@@ -1724,6 +1726,14 @@
  "  // Information about 

[PATCH] D59555: [analyzer] Add yaml parser to GenericTaintChecker

2019-07-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: test/Analysis/taint-generic.c:24
+// CHECK-INVALID-FILE-SAME:
'alpha.security.taint.TaintPropagation:Config',
+// CHECK-INVALID-FILE-SAME:that expects a valid filename
 

Szelethus wrote:
> NoQ wrote:
> > Szelethus wrote:
> > > Could you please add the rest of the error message?
> > I'd rather remove the rest of the error message. There's no need to 
> > duplicate something that the user has already written on the command line.
> > 
> > Or do we think like \escapes?
> I'm not sure what \escapes mean -- however, if we emit the filename in the 
> error message, we should test it. Also, how many filenames has the user 
> written in the comand line? Include paths for this and that, output file, 
> inputfile, files to link against... I would very much prefer preserving the 
> current error message.
I'm thinking, like, the user is using zsh and writing `file#1.txt` instead of 
`file\#1.txt`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59555/new/

https://reviews.llvm.org/D59555



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


[PATCH] D65009: [LTO] Don't mark regular LTO units with EnableSplitLTOUnit

2019-07-19 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added a reviewer: pcc.
Herald added subscribers: dexonsmith, steven_wu, inglorion, Prazek, mehdi_amini.
Herald added a project: clang.

LTO Unit splitting does not apply to regular LTO modules, only ThinLTO
(which must be consistently split into regular and Thin units for
optimizations such as whole program devirtualization and lower type
tests). Don't add the corresponding module flag to regular LTO modules,
to avoid mismatched module flag errors when linking a regular LTO module
with the regular LTO part of a split ThinLTO module.

This relies on a corresponding LTO patch that ignores the status of this
module flag on non-ThinLTO modules.

Depends on D65008 .


Repository:
  rC Clang

https://reviews.llvm.org/D65009

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/split-lto-unit.c


Index: test/CodeGen/split-lto-unit.c
===
--- /dev/null
+++ test/CodeGen/split-lto-unit.c
@@ -0,0 +1,13 @@
+// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
+// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
+// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
+//
+// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis 
-o - | FileCheck %s --check-prefix=SPLIT
+// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
+//
+// ; Check that regular LTO has no EnableSplitLTOUnit flag
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | 
llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" 
--check-prefix=THINLTOOFF
+// THINLTOOFF: !{i32 1, !"ThinLTO", i32 0}
+
+int main() {}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -847,8 +847,6 @@
   if (EmitLTOSummary) {
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
-TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
   }
 
   PerModulePasses.add(createBitcodeWriterPass(


Index: test/CodeGen/split-lto-unit.c
===
--- /dev/null
+++ test/CodeGen/split-lto-unit.c
@@ -0,0 +1,13 @@
+// ; Check that -flto=thin without -fsplit-lto-unit has EnableSplitLTOUnit = 0
+// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s
+// CHECK: !{i32 1, !"EnableSplitLTOUnit", i32 0}
+//
+// ; Check that -flto=thin with -fsplit-lto-unit has EnableSplitLTOUnit = 1
+// RUN: %clang_cc1 -flto=thin -fsplit-lto-unit -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --check-prefix=SPLIT
+// SPLIT: !{i32 1, !"EnableSplitLTOUnit", i32 1}
+//
+// ; Check that regular LTO has no EnableSplitLTOUnit flag
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-dis -o - | FileCheck %s --implicit-check-not="EnableSplitLTOUnit" --check-prefix=THINLTOOFF
+// THINLTOOFF: !{i32 1, !"ThinLTO", i32 0}
+
+int main() {}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -847,8 +847,6 @@
   if (EmitLTOSummary) {
 if (!TheModule->getModuleFlag("ThinLTO"))
   TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
-TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
- CodeGenOpts.EnableSplitLTOUnit);
   }
 
   PerModulePasses.add(createBitcodeWriterPass(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D65005: [clang-doc] Fix output format of html

2019-07-19 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran created this revision.
DiegoAstiazaran added reviewers: juliehockett, jakehehrlich, lebedev.ri.
DiegoAstiazaran added a project: clang-tools-extra.

The children of a TagNode are rendered in the same line as the parent only if 
they are all TextNodes.
When children are not inline; two text nodes that are adjacent won't have a new 
line between them, each tag node is rendered in its own line.


https://reviews.llvm.org/D65005

Files:
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -56,9 +56,7 @@
   Functions
   
 OneFunction
-
-  OneFunction()
-
+OneFunction()
   
   Enums
   
@@ -107,9 +105,7 @@
 class r
 
   class r
-  
-Defined at line 10 of test.cpp
-  
+  Defined at line 10 of test.cpp
   
 Inherits from 
 
   Members
   
-private int X
+
+  private 
+  int
+   X
+
   
   Records
   
@@ -128,9 +128,7 @@
   Functions
   
 OneFunction
-
-  OneFunction()
-
+OneFunction()
   
   Enums
   
@@ -180,9 +178,7 @@
  R"raw(">int
  P)
   
-  
-Defined at line 10 of test.cpp
-  
+  Defined at line 10 of test.cpp
 
 )raw";
 
@@ -214,9 +210,7 @@
   
 X
   
-  
-Defined at line 10 of test.cpp
-  
+  Defined at line 10 of test.cpp
 
 )raw";
 
@@ -271,20 +265,12 @@
 
 
   f
-  
-void f(int I, int J)
-  
-  
-Defined at line 10 of test.cpp
-  
+  void f(int I, int J)
+  Defined at line 10 of test.cpp
   
 
-  
- Brief description.
-  
-  
- Extended description that continues onto the next line.
-  
+   Brief description.
+   Extended description that continues onto the next line.
 
   
 
Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp
===
--- clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -43,9 +43,6 @@
   operator bool() = delete;
 
   bool IsSelfClosing() const;
-
-  bool HasInlineChildren() const;
-
   llvm::SmallString<16> ToString() const;
 
 private:
@@ -66,29 +63,20 @@
 };
 
 struct TextNode : public HTMLNode {
-  TextNode(const Twine , bool Indented = true)
-  : HTMLNode(NodeType::NODE_TEXT), Text(Text.str()), Indented(Indented) {}
+  TextNode(const Twine )
+  : HTMLNode(NodeType::NODE_TEXT), Text(Text.str()) {}
 
   std::string Text; // Content of node
-  bool Indented; // Indicates if an indentation must be rendered before the text
   void Render(llvm::raw_ostream , int IndentationLevel) override;
 };
 
 struct TagNode : public HTMLNode {
-  TagNode(HTMLTag Tag)
-  : HTMLNode(NodeType::NODE_TAG), Tag(Tag),
-InlineChildren(Tag.HasInlineChildren()),
-SelfClosing(Tag.IsSelfClosing()) {}
+  TagNode(HTMLTag Tag) : HTMLNode(NodeType::NODE_TAG), Tag(Tag) {}
   TagNode(HTMLTag Tag, const Twine ) : TagNode(Tag) {
-Children.emplace_back(
-llvm::make_unique(Text.str(), !InlineChildren));
+Children.emplace_back(llvm::make_unique(Text.str()));
   }
 
-  HTMLTag Tag; // Name of HTML Tag (p, div, h1)
-  bool InlineChildren; // Indicates if children nodes are rendered in the same
-   // line as itself or if children must rendered in the
-   // next line and with additional indentation
-  bool SelfClosing;// Indicates if tag is self-closing
+  HTMLTag Tag; // Name of HTML Tag (p, div, h1)
   std::vector> Children; // List of child nodes
   llvm::StringMap>
   Attributes; // List of key-value attributes for tag
@@ -129,24 +117,6 @@
   llvm_unreachable("Unhandled HTMLTag::TagType");
 }
 
-bool HTMLTag::HasInlineChildren() const {
-  switch (Value) {
-  case HTMLTag::TAG_META:
-  case HTMLTag::TAG_TITLE:
-  case HTMLTag::TAG_H1:
-  case HTMLTag::TAG_H2:
-  case HTMLTag::TAG_H3:
-  case HTMLTag::TAG_LI:
-  case HTMLTag::TAG_A:
-return true;
-  case HTMLTag::TAG_DIV:
-  case HTMLTag::TAG_P:
-  case HTMLTag::TAG_UL:
-return false;
-  }
-  llvm_unreachable("Unhandled HTMLTag::TagType");
-}
-
 llvm::SmallString<16> HTMLTag::ToString() const {
   switch (Value) {
   case HTMLTag::TAG_META:
@@ -174,17 +144,23 @@
 }
 
 void TextNode::Render(llvm::raw_ostream , int IndentationLevel) {
-  if (Indented)
-OS.indent(IndentationLevel * 2);
+  OS.indent(IndentationLevel * 2);
   OS << Text;
 }
 
 void TagNode::Render(llvm::raw_ostream , int IndentationLevel) {
+  // Children nodes are rendered in the same line if all of them are text nodes
+  bool InlineChildren = true;
+  for (const auto  : Children)
+if (C->Type == NodeType::NODE_TAG) {
+  InlineChildren = false;
+  break;
+}
   

[PATCH] D64907: [AST] Traverse attributes inside DEF_TRAVERSE_DECL macro

2019-07-19 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Looks like a good idea to me.

Regarding tests, I couldn't find existing tests that check order either. Seems 
like you'd need to make some minimal infrastructure for that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64907/new/

https://reviews.llvm.org/D64907



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


[PATCH] D64780: Disallow most calling convention attributes on PS4.

2019-07-19 Thread Warren Ristow via Phabricator via cfe-commits
wristow accepted this revision.
wristow added a comment.

In D64780#1593624 , @aaron.ballman 
wrote:

> LGTM aside from a nit. You should give other reviewers a chance to sign off 
> in case they have additional comments.


LGTM too, once the line-length is fixed (and IMO, no need to update the review 
for just that line-length change).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64780/new/

https://reviews.llvm.org/D64780



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


[PATCH] D64780: Disallow most calling convention attributes on PS4.

2019-07-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.

lgtm


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64780/new/

https://reviews.llvm.org/D64780



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


[PATCH] D64671: [clang-tidy] New check: misc-init-local-variables

2019-07-19 Thread Jussi Pakkanen via Phabricator via cfe-commits
jpakkane marked 4 inline comments as done.
jpakkane added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:21
+  Finder->addMatcher(
+  varDecl(unless(hasInitializer(anything(.bind("vardecl"), this);
+}

alexfh wrote:
> jpakkane wrote:
> > alexfh wrote:
> > > jpakkane wrote:
> > > > alexfh wrote:
> > > > > jpakkane wrote:
> > > > > > alexfh wrote:
> > > > > > > I believe, this should skip matches within template 
> > > > > > > instantiations. Consider this code:
> > > > > > > ```
> > > > > > > template
> > > > > > > void f(T) { T t; }
> > > > > > > void g() {
> > > > > > > f(0);
> > > > > > > f(0.0);
> > > > > > > }
> > > > > > > ```
> > > > > > > 
> > > > > > > What will the fix  be?
> > > > > > I tested with the following function:
> > > > > > 
> > > > > > 
> > > > > > ```
> > > > > > template
> > > > > > void template_test_function() {
> > > > > >   T t;
> > > > > >   int uninitialized;
> > > > > > }
> > > > > > ```
> > > > > > 
> > > > > > Currently it warns on the "uninitialized" variable regardless of 
> > > > > > whether the template is instantiated or not. If you call it with an 
> > > > > > int type, it will warn about variable t being uninitialized. If you 
> > > > > > call it with a, say, struct type, there is no warnings. Is this a 
> > > > > > reasonable approach?
> > > > > And what happens, if there are multiple instantiations of the same 
> > > > > template, each of them requiring a different fix? Can you try the 
> > > > > check with my example above (and maybe also add `f("");`inside 
> > > > > `g()`). I believe, the check will produce multiple warnings with 
> > > > > conflicting fixes (and each of them will be wrong, btw).
> > > > Interestingly it does warn about it, but only once, even if you have 
> > > > two different template specializations.
> > > > 
> > > > I tried to suppress this warning when the type being instantiated is a 
> > > > template argument type but no matter what I tried I could not get this 
> > > > to work. Is there a way to get this information from the MatchedDecl 
> > > > object or does one need to do something more complicated like going up 
> > > > the AST until a function definition is found and checking if it is a 
> > > > template specialization (presumably with TemplatedKind)? Any help would 
> > > > be appreciated.
> > > If there are multiple warnings with the same message at the same location 
> > > (clang-tidy/ClangTidyDiagnosticConsumer.cpp:745), they will be 
> > > deduplicated. Thus, a random fix will probably be suggested. The proper 
> > > way to filter out matches in template instantiations is to add 
> > > `unless(isInTemplateInstantiation())` to the matcher.
> > I tried to make this work but I just could not combine statement and 
> > declaration matching in a reliable way. Matching a statement that is not in 
> > a template declaration can be done, as well as matching a declaration 
> > without intial value, but combining those two into one is hard. After 
> > trying many, many things the best I could come up with was this:
> > 
> > ```
> > declStmt(containsDeclaration(0, 
> > varDecl(unless(hasInitializer(anything(.bind("vardecl"))), this)
> > ```
> > 
> > The problem is that `containsDeclaration` takes an integer denoting how 
> > manyth declaration should be processed. Manually adding matchers for, say, 
> > 0, 1, 2, 3 and 4 works and does the right thing but fails if anyone has an 
> > uninitialized variable in the sixth location, things will silently fail.
> > 
> > The weird thing is that if you do the matching this way, you don't need to 
> > filter out things with `unless(isInTemplateInstantiation())`. Maybe 
> > statements are handled differently from declarations?
> I was struggling to understand, why you want to match a statement, but then I 
> figured out that I should have been more precise: while 
> `isInTemplateInstantiation` only works for `Stmt`s, there's a related matcher 
> that works for `Decl`s: `isInstantiated`. See 
> clang/include/clang/ASTMatchers/ASTMatchers.h:5187. In general, looking into 
> this header can be useful, if you want to find a matcher that you can vaguely 
> describe (e.g. when looking for something related to instantiations, you can 
> search for the relevant substring and find  this and a bunch of other 
> matchers).
> 
> Sorry for the confusion. I hope, the suggestion helps.
Thanks, got it working now.



Comment at: clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp:32
+  StringRef VarName = MatchedDecl->getName();
+  if (VarName.empty() || VarName.front() == '_') {
+// Some standard library methods such as "be64toh" are implemented

alexfh wrote:
> jpakkane wrote:
> > alexfh wrote:
> > > Should this just disallow all fixes within macros? Maybe warnings as well.
> > I can change that, seems reasonable. Should it still retain this check, 
> > though? One would 

[PATCH] D64671: [clang-tidy] New check: misc-init-local-variables

2019-07-19 Thread Jussi Pakkanen via Phabricator via cfe-commits
jpakkane updated this revision to Diff 210868.
jpakkane added a comment.

Now properly deals with template instantiations and macros.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64671/new/

https://reviews.llvm.org/D64671

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.cpp
  clang-tools-extra/clang-tidy/misc/InitLocalVariablesCheck.h
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-init-local-variables.rst
  clang-tools-extra/test/clang-tidy/misc-init-local-variables.cpp

Index: clang-tools-extra/test/clang-tidy/misc-init-local-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/misc-init-local-variables.cpp
@@ -0,0 +1,99 @@
+// RUN: %check_clang_tidy %s misc-init-local-variables %t
+
+#include 
+
+#define DO_NOTHING(x) ((void)x)
+
+// Ensure that function declarations are not changed.
+void some_func(int x, double d, bool b, const char *p);
+
+int do_not_modify_me;
+
+typedef struct {
+  int unaltered1;
+  int unaltered2;
+} UnusedStruct;
+
+typedef int my_int_type;
+#define MACRO_INT int
+#define FULL_DECLARATION() int macrodecl;
+
+template 
+void template_test_function() {
+  T t;
+  int uninitialized;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'uninitialized' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  int uninitialized = 0;{{$}}
+
+  DO_NOTHING(t);
+  DO_NOTHING(uninitialized);
+}
+
+void init_unit_tests() {
+  int x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'x' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  int x = 0;{{$}}
+  int32_t sized_var;
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: variable 'sized_var' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  int32_t sized_var = 0;{{$}}
+  my_int_type myint;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'myint' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  my_int_type myint = 0;{{$}}
+
+  MACRO_INT macroint;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'macroint' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  MACRO_INT macroint = 0;{{$}}
+  FULL_DECLARATION();
+
+  int x0 = 1, x1, x2 = 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'x1' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  int x0 = 1, x1 = 0, x2 = 2;{{$}}
+  int y0, y1 = 1, y2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'y0' is not initialized [misc-init-local-variables]
+  // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: variable 'y2' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  int y0 = 0, y1 = 1, y2 = 0;{{$}}
+  int hasval = 42;
+
+  float f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'f' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  float f = (0.0/0.0);{{$}}
+  float fval = 85.0;
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: variable 'd' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  double d = (0.0/0.0);{{$}}
+  double dval = 99.0;
+
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  bool b = 0;{{$}}
+  bool bval = true;
+
+  const char *ptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'ptr' is not initialized [misc-init-local-variables]
+  // CHECK-FIXES: {{^}}  const char *ptr = nullptr;{{$}}
+  const char *ptrval = "a string";
+
+  UnusedStruct u;
+
+  DO_NOTHING(x);
+  DO_NOTHING(sized_var);
+  DO_NOTHING(myint);
+  DO_NOTHING(macroint);
+  DO_NOTHING(macrodecl);
+  DO_NOTHING(x0);
+  DO_NOTHING(x1);
+  DO_NOTHING(x2);
+  DO_NOTHING(y0);
+  DO_NOTHING(y1);
+  DO_NOTHING(y2);
+  DO_NOTHING(hasval);
+  DO_NOTHING(f);
+  DO_NOTHING(fval);
+  DO_NOTHING(d);
+  DO_NOTHING(dval);
+  DO_NOTHING(b);
+  DO_NOTHING(bval);
+  DO_NOTHING(ptr);
+  DO_NOTHING(ptrval);
+  DO_NOTHING(u);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/misc-init-local-variables.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-init-local-variables.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - misc-init-local-variables
+
+misc-init-local-variables
+=
+
+Checks whether there are local variables that are declared without an
+initial value. These may lead to unexpected behaviour if there is a
+code path that reads the variable before assigning to it.
+
+Only integers, booleans, floats, doubles and pointers are checked. The
+fix option initializes all detected values with the value of zero. An
+exception is float and double types, which are initialized to NaN.
+

[PATCH] D65003: [clang-doc] Add index in each info html file

2019-07-19 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran created this revision.
DiegoAstiazaran added reviewers: juliehockett, jakehehrlich, lebedev.ri.
DiegoAstiazaran added a project: clang-tools-extra.
Herald added subscribers: kadircet, arphaman, mgrang, mgorny.

An index structure is created while reducing the infos. This is then passed to 
the HTML generator so it's included in each file created.
Paths in the index are fixed (relative to the current file) for each file.
Index is currently rendered on top of the info content, this will be fixed 
later with CSS.


https://reviews.llvm.org/D65003

Files:
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Generators.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/YAMLGenerator.cpp
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/unittests/clang-doc/CMakeLists.txt
  clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
  clang-tools-extra/unittests/clang-doc/ClangDocTest.h
  clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
@@ -40,7 +40,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
@@ -94,7 +94,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
@@ -158,7 +158,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
@@ -206,7 +206,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
@@ -343,7 +343,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(---
Index: clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
@@ -38,7 +38,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected = R"raw(# namespace Namespace
 
@@ -101,7 +101,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected = R"raw(# class r
 
@@ -162,7 +162,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected = R"raw(### f
 
@@ -190,7 +190,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected = R"raw(| enum class e |
 
@@ -320,7 +320,7 @@
   assert(G);
   std::string Buffer;
   llvm::raw_string_ostream Actual(Buffer);
-  auto Err = G->generateDocForInfo(, Actual);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
   assert(!Err);
   std::string Expected =
   R"raw(### f
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -9,6 +9,7 @@
 #include "ClangDocTest.h"
 #include "Generators.h"
 #include "Representation.h"

[PATCH] D62648: [Sema][Typo] Fix assertion failure for expressions with multiple typos

2019-07-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 210862.
dgoldman added a comment.

- Minor fixes


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62648/new/

https://reviews.llvm.org/D62648

Files:
  lib/Sema/SemaExprCXX.cpp
  test/Sema/typo-correction-recursive.cpp
  test/SemaCXX/typo-correction-cxx11.cpp

Index: test/SemaCXX/typo-correction-cxx11.cpp
===
--- test/SemaCXX/typo-correction-cxx11.cpp
+++ test/SemaCXX/typo-correction-cxx11.cpp
@@ -50,10 +50,10 @@
 };
 
 void run(A *annotations) {
-  map new_annotations;
+  map annotation_map;
 
   auto  = *annotations;
-  auto new_it = new_annotations.find(5);
+  auto new_it = annotation_map.find(5);
   auto _anotation = new_it.second;  // expected-note {{'new_anotation' declared here}}
   new_annotation->Swap();  // expected-error {{use of undeclared identifier 'new_annotation'; did you mean 'new_anotation'?}}
 }
Index: test/Sema/typo-correction-recursive.cpp
===
--- /dev/null
+++ test/Sema/typo-correction-recursive.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Check the following typo correction behavior:
+// - multiple typos in a single member call chain are all diagnosed
+// - no typos are diagnosed for multiple typos in an expression when not all
+//   typos can be corrected
+
+class DeepClass
+{
+public:
+  void trigger() const;  // expected-note {{'trigger' declared here}}
+};
+
+class Y
+{
+public:
+  const DeepClass& getX() const { return m_deepInstance; }  // expected-note {{'getX' declared here}}
+private:
+  DeepClass m_deepInstance;
+  int m_n;
+};
+
+class Z
+{
+public:
+  const Y& getY0() const { return m_y0; }  // expected-note {{'getY0' declared here}}
+  const Y& getActiveY() const { return m_y0; }
+
+private:
+  Y m_y0;
+  Y m_y1;
+};
+
+Z z_obj;
+
+void testMultipleCorrections()
+{
+  z_obj.getY2().  // expected-error {{no member named 'getY2' in 'Z'; did you mean 'getY0'}}
+  getM(). // expected-error {{no member named 'getM' in 'Y'; did you mean 'getX'}}
+  triggee();  // expected-error {{no member named 'triggee' in 'DeepClass'; did you mean 'trigger'}}
+}
+
+void testNoCorrections()
+{
+  z_obj.getY2().  // expected-error {{no member named 'getY2' in 'Z'}}
+  getM().
+  thisDoesntSeemToMakeSense();
+}
+
+struct C {};
+struct D { int value; };
+struct A {
+  C get_me_a_C();
+};
+struct B {
+  D get_me_a_D();  // expected-note {{'get_me_a_D' declared here}}
+};
+class Scope {
+public:
+  A make_an_A();
+  B make_a_B();  // expected-note {{'make_a_B' declared here}}
+};
+
+Scope scope_obj;
+
+int testDiscardedCorrections() {
+  return scope_obj.make_an_E().  // expected-error {{no member named 'make_an_E' in 'Scope'; did you mean 'make_a_B'}}
+  get_me_a_Z().value;// expected-error {{no member named 'get_me_a_Z' in 'B'; did you mean 'get_me_a_D'}}
+}
+
+class AmbiguousHelper {
+public:
+  int helpMe();
+  int helpBe();
+};
+class Ambiguous {
+public:
+  int calculateA();
+  int calculateB();
+
+  AmbiguousHelper getHelp1();
+  AmbiguousHelper getHelp2();
+};
+
+Ambiguous ambiguous_obj;
+
+int testDirectAmbiguousCorrection() {
+  return ambiguous_obj.calculateZ();  // expected-error {{no member named 'calculateZ' in 'Ambiguous'}}
+}
+
+int testRecursiveAmbiguousCorrection() {
+  return ambiguous_obj.getHelp3().// expected-error {{no member named 'getHelp3' in 'Ambiguous'}}
+  helpCe();
+}
+
+
+class DeepAmbiguityHelper {
+public:
+  DeepAmbiguityHelper& help1();
+  DeepAmbiguityHelper& help2();
+
+  DeepAmbiguityHelper& methodA();
+  DeepAmbiguityHelper& somethingMethodB();
+  DeepAmbiguityHelper& functionC();
+  DeepAmbiguityHelper& deepMethodD();
+  DeepAmbiguityHelper& asDeepAsItGets();
+};
+
+DeepAmbiguityHelper deep_obj;
+
+int testDeepAmbiguity() {
+  deep_obj.
+  methodB(). // expected-error {{no member named 'methodB' in 'DeepAmbiguityHelper'}}
+  somethingMethodC().
+  functionD().
+  deepMethodD().
+  help3().
+  asDeepASItGet().
+  functionE();
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -7610,15 +7610,22 @@
   llvm::SmallDenseMap OverloadResolution;
 
   /// Emit diagnostics for all of the TypoExprs encountered.
+  ///
   /// If the TypoExprs were successfully corrected, then the diagnostics should
   /// suggest the corrections. Otherwise the diagnostics will not suggest
   /// anything (having been passed an empty TypoCorrection).
-  void EmitAllDiagnostics() {
+  ///
+  /// If we've failed to correct due to ambiguous corrections, we need to
+  /// be sure to pass empty corrections and replacements. Otherwise it's
+  /// possible that the Consumer has a TypoCorrection that failed to ambiguity
+  /// and we don't want to report those diagnostics.
+  void 

[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2019-07-19 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 210861.
martong added a comment.

- Further simplify by removing the last for loop


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D44100/new/

https://reviews.llvm.org/D44100

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1472,7 +1472,7 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
-   DISABLED_CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
+   CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
   // The original recursive algorithm of ASTImporter first imports 'c' then
@@ -5232,5 +5232,16 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, LLDBLookupTest,
 DefaultTestValuesForRunOptions, );
 
+TEST_P(ImportDecl, ImportFieldOrder) {
+  MatchVerifier Verifier;
+  testImport("struct declToImport {"
+ "  int b = a + 2;"
+ "  int a = 5;"
+ "};",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ recordDecl(hasFieldOrder({"b", "a"})));
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1645,7 +1645,6 @@
   bool AccumulateChildErrors = isa(FromDC);
 
   Error ChildErrors = Error::success();
-  llvm::SmallVector ImportedDecls;
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
 if (!ImportedOrErr) {
@@ -1657,6 +1656,58 @@
 }
   }
 
+  // We reorder declarations in RecordDecls because they may have another order
+  // in the "to" context than they have in the "from" context. This may happen
+  // e.g when we import a class like this:
+  //struct declToImport {
+  //int a = c + b;
+  //int b = 1;
+  //int c = 2;
+  //};
+  // During the import of `a` we import first the dependencies in sequence,
+  // thus the order would be `c`, `b`, `a`. We will get the normal order by
+  // first removing the already imported members and then adding them in the
+  // order as they apper in the "from" context.
+  //
+  // Keeping field order is vital because it determines structure layout.
+  //
+  // Here and below, we cannot call field_begin() method and its callers on
+  // ToDC if it has an external storage. Calling field_begin() will
+  // automatically load all the fields by calling
+  // LoadFieldsFromExternalStorage().  LoadFieldsFromExternalStorage() would
+  // call ASTImporter::Import(). This is because the ExternalASTSource
+  // interface in LLDB is implemented by the means of the ASTImporter. However,
+  // calling an import at this point would result in an uncontrolled import, we
+  // must avoid that.
+  const auto *FromRD = dyn_cast(FromDC);
+  if (!FromRD)
+return ChildErrors;
+  auto ToDCOrErr = Importer.ImportContext(FromDC);
+  if (!ToDCOrErr) {
+consumeError(std::move(ChildErrors));
+return ToDCOrErr.takeError();
+  }
+
+  DeclContext *ToDC = *ToDCOrErr;
+  // Remove all declarations, which may be in wrong order in the
+  // lexical DeclContext and then add them in the proper order.
+  for (auto *D : FromRD->decls()) {
+if (isa(D) || isa(D)) {
+  assert(D && "DC has a contained decl which is null?");
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  // Remove only the decls which we successfully imported.
+  if (ToD) {
+assert(ToDC == ToD->getLexicalDeclContext() && ToDC->containsDecl(ToD));
+// Remove the decl from its wrong place in the linked list.
+ToDC->removeDecl(ToD);
+// Add the decl to the end of the linked list.
+// This time it will be at the proper place because the enclosing for
+// loop iterates in the original (good) order of the decls.
+ToDC->addDeclInternal(ToD);
+  }
+}
+  }
+
   return ChildErrors;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64762: [AST] Treat semantic form of InitListExpr as implicit code in traversals

2019-07-19 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:2332
   S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
   TRY_TO(TraverseSynOrSemInitListExpr(
   S->isSemanticForm() ? S : S->getSemanticForm(), Queue));

ilya-biryukov wrote:
> ilya-biryukov wrote:
> > gribozavr wrote:
> > > Instead of adding a whole new if statement, could you wrap the second 
> > > existing TRY_TO in `if(shouldVisitImplicitCode())` ?
> > Despite looking very similar, that would **not** be equivalent to the 
> > current version.
> > 
> > For most init lists (that do not have alternative "form"), the following 
> > invariants hold:
> > ```
> > InitList* E = ...;
> > assert(E->isSemanticForm());
> > assert(E->isSyntacticForm()); 
> > assert(E->getSynacticForm() == nullptr);
> > ```
> > 
> > This subtle fact means the current code does not traversed the list twice 
> > if they do not have an alternative form (either semantic or syntactic).
> > 
> > Now, if we only run the first statement, we will call 
> > `TraverseSynOrSemInitListExpr(S->getSyntacticForm())` and 
> > `S->getSyntacticForm()` returns `null`. So we don't traverse anything.
> > 
> > I tried various ways to keep both calls, but they all ended up being too 
> > complicated, hence the final version. Let me know if you see a better way 
> > to address this.
> To make the last sentence less confusing:
> I tried various ways to keep **only two** calls, but they were too 
> complicated and I ended up introducing an extra call to `TraverseSyn...` 
> instead.
> 
> assert(E->getSynacticForm() == nullptr);

That's... a really nice API.

What do you think about the following:

```
if (S->isSyntacticForm() && S->isSemanticForm()) {
  // `S` does not have alternative forms, traverse the only form that's 
available.
  TRY_TO(TraverseSynOrSemInitListExpr(S, Queue));
  return true;
}

TRY_TO(TraverseSynOrSemInitListExpr(
  S->isSemanticForm() ? S->getSyntacticForm() : S, Queue));
if (getDerived().shouldVisitImplicitCode()) {
  TRY_TO(TraverseSynOrSemInitListExpr(
S->isSyntacticForm() ? S->getSemanticForm() : S, Queue));
}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64762/new/

https://reviews.llvm.org/D64762



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


[PATCH] D64736: [clang-tidy] New bugprone-infinite-loop check for detecting obvious infinite loops

2019-07-19 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:25
+
+static bool isAccessForVar(const Stmt *St, const VarDecl *Var) {
+  if (const auto *DRE = dyn_cast(St))

St => S

"S" is a common abbreviation in the Clang codebase, "St" isn't.

(everywhere in the patch)



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:49
+
+static bool hasPtrOrReferenceBefore(const Stmt *St, const Stmt *LoopStmt,
+const VarDecl *Var) {

Please add documentation comments.



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:92
+   ASTContext *Context) {
+  if (const auto *DRE = dyn_cast(Cond)) {
+if (const auto *Var = dyn_cast(DRE->getDecl())) {

Please separate the logic that finds variables from the rest of the logic.

Finding variables has to be recursive, the rest does not have to be.



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:160
+  allOf(hasCondition(expr().bind("condition")),
+unless(hasBody(hasDescendant(loopEndingStmt();
+

hasDescendant will recurse into other functions defined in the loop body, for 
example into lambdas.

```
for (...) {
  auto x = []() { throw 0; }
}
```

You can add the forFunction matcher to the loop ending statement matcher, and 
then use equalsNode to confirm that the loop ending statement is in the same 
function as the for loop.

Please also add tests for this case.



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:181
+
+  diag(getFirstCondVar(Cond)->getLocation(),
+   "None of the condition variables "

I'd suggest to attach the diagnostic to the loop -- the problem is with the 
loop, not with the first reference to the variable.



Comment at: clang-tidy/bugprone/InfiniteLoopCheck.cpp:182
+  diag(getFirstCondVar(Cond)->getLocation(),
+   "None of the condition variables "
+   "(%0) are updated in the loop body")

ClangTidy messages are sentence fragments that start with a lowercase letter.

It would be also helpful to state the problem explicitly.

"this loop is infinite; none of its condition variables are updated in the loop 
body"



Comment at: docs/clang-tidy/checks/bugprone-infinite-loop.rst:6
+
+Checks for obvious infinite loops (loops where the condition variable is not
+changed at all).

s/checks for/finds/ (everywhere in the patch)



Comment at: docs/clang-tidy/checks/bugprone-infinite-loop.rst:9
+
+Detecting infinite loops by a finite program is well known to be impossible
+(Halting-problem). However there are some simple but common cases where it

"Finding infinite loops is well-known to be impossible (halting problem)."



Comment at: docs/clang-tidy/checks/bugprone-infinite-loop.rst:10
+Detecting infinite loops by a finite program is well known to be impossible
+(Halting-problem). However there are some simple but common cases where it
+is possible: the loop condition is not changed in the loop at all. This check

"However, it is possible to detect some obvious infinite loops, for example, if 
the loop condition is not changed."



Comment at: docs/clang-tidy/checks/bugprone-infinite-loop.rst:16
+
+- It is a local variable of the function.
+- It has no reference or pointer aliases before or inside the loop.

"It is a local variable" (local variables can only be declared in functions)



Comment at: docs/clang-tidy/checks/bugprone-infinite-loop.rst:18
+- It has no reference or pointer aliases before or inside the loop.
+- It is no member expression.
+

I don't quite understand what you mean by "it is no member expression". Also, 
users likely won't understand the term "member expression".



Comment at: docs/clang-tidy/checks/bugprone-infinite-loop.rst:23
+
+For example, the following loop is considered as infinite since mistakenly
+`j` is incremented instead of `i`:

s/considered as infinite/considered infinite/



Comment at: docs/clang-tidy/checks/bugprone-infinite-loop.rst:24
+For example, the following loop is considered as infinite since mistakenly
+`j` is incremented instead of `i`:
+

I don't think we can say the "mistakenly" part. Explaining checker's behavior 
like that suggests that the checker detects the user's intent, which it does 
not. For example, it could also be the case that the user wanted to increment 
both i and j in the loop body.

All we can say is the loop is infinite because in the loop condition "i < 10" 
all variables (i) never change.



Comment at: test/clang-tidy/bugprone-infinite-loop.cpp:43
+  int Limit = 100;
+  while (i < Limit) { // Not an 

[PATCH] D64744: #pragma clang loop vectorize_predicate(enable|disable)

2019-07-19 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 210857.
SjoerdMeijer added a comment.

Removed the separate function that created the loop.llvm.vectorize.predicate 
metadata. This is now just part of function `createLoopVectorizeMetadata`, that 
creates all other vectorize metadata.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64744/new/

https://reviews.llvm.org/D64744

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/AST/ast-print-pragmas.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  clang/test/Parser/pragma-loop.cpp
  clang/test/Parser/pragma-unroll-and-jam.cpp

Index: clang/test/Parser/pragma-unroll-and-jam.cpp
===
--- clang/test/Parser/pragma-unroll-and-jam.cpp
+++ clang/test/Parser/pragma-unroll-and-jam.cpp
@@ -67,7 +67,7 @@
   }
 
 // pragma clang unroll_and_jam is disabled for the moment
-/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop unroll_and_jam(4)
+/* expected-error {{invalid option 'unroll_and_jam'; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribute}} */ #pragma clang loop unroll_and_jam(4)
   for (int i = 0; i < Length; i++) {
 for (int j = 0; j < Length; j++) {
   List[i * Length + j] = Value;
Index: clang/test/Parser/pragma-loop.cpp
===
--- clang/test/Parser/pragma-loop.cpp
+++ clang/test/Parser/pragma-loop.cpp
@@ -81,6 +81,7 @@
 
 #pragma clang loop vectorize(enable)
 #pragma clang loop interleave(enable)
+#pragma clang loop vectorize_predicate(enable)
 #pragma clang loop unroll(full)
   while (i + 1 < Length) {
 List[i] = i;
@@ -95,6 +96,7 @@
 
 #pragma clang loop vectorize(disable)
 #pragma clang loop interleave(disable)
+#pragma clang loop vectorize_predicate(disable)
 #pragma clang loop unroll(disable)
   while (i - 1 < Length) {
 List[i] = i;
@@ -111,7 +113,7 @@
   }
 
   int VList[Length];
-#pragma clang loop vectorize(disable) interleave(disable) unroll(disable)
+#pragma clang loop vectorize(disable) interleave(disable) unroll(disable) vectorize_predicate(disable)
   for (int j : VList) {
 VList[j] = List[j];
   }
@@ -130,11 +132,13 @@
 
 /* expected-error {{expected '('}} */ #pragma clang loop vectorize
 /* expected-error {{expected '('}} */ #pragma clang loop interleave
+/* expected-error {{expected '('}} */ #pragma clang loop vectorize_predicate
 /* expected-error {{expected '('}} */ #pragma clang loop unroll
 /* expected-error {{expected '('}} */ #pragma clang loop distribute
 
 /* expected-error {{expected ')'}} */ #pragma clang loop vectorize(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop interleave(enable
+/* expected-error {{expected ')'}} */ #pragma clang loop vectorize_predicate(enable
 /* expected-error {{expected ')'}} */ #pragma clang loop unroll(full
 /* expected-error {{expected ')'}} */ #pragma clang loop distribute(enable
 
@@ -147,7 +151,7 @@
 /* expected-error {{missing argument; expected 'enable', 'full' or 'disable'}} */ #pragma clang loop unroll()
 /* expected-error {{missing argument; expected 'enable' or 'disable'}} */ #pragma clang loop distribute()
 
-/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, or distribute}} */ #pragma clang loop
+/* expected-error {{missing option; expected vectorize, vectorize_width, interleave, interleave_count, unroll, unroll_count, pipeline, pipeline_initiation_interval, vectorize_predicate, or distribute}} */ #pragma clang loop
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop badkeyword(enable)
 /* expected-error {{invalid option 'badkeyword'}} */ #pragma clang loop vectorize(enable) badkeyword(4)
@@ -245,6 +249,8 @@
 /* expected-error {{duplicate directives 'vectorize(enable)' and 'vectorize(disable)'}} */ #pragma clang loop vectorize(disable)
 #pragma clang loop interleave(enable)
 /* expected-error {{duplicate directives 'interleave(enable)' and 'interleave(disable)'}} */ #pragma clang loop interleave(disable)
+#pragma clang loop vectorize_predicate(enable)
+/* expected-error {{duplicate directives 'vectorize_predicate(enable)' and 'vectorize_predicate(disable)'}} */ #pragma clang loop vectorize_predicate(disable)
 #pragma clang loop unroll(full)
 /* expected-error {{duplicate directives 'unroll(full)' and 'unroll(disable)'}} */ #pragma clang loop unroll(disable)

[PATCH] D64775: [Format/ObjC] Avoid breaking between unary operators and operands

2019-07-19 Thread Ben Hamilton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366592: [Format/ObjC] Avoid breaking between unary operators 
and operands (authored by benhamilton, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64775?vs=210095=210859#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64775/new/

https://reviews.llvm.org/D64775

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


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2429,6 +2429,8 @@
   if (Left.is(TT_JavaAnnotation))
 return 50;
 
+  if (Left.is(TT_UnaryOperator))
+return 60;
   if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
   Left.Previous->isLabelString() &&
   (Left.NextOperator || Left.OperatorIndex != 0))
Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp
===
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp
@@ -886,6 +886,18 @@
" bb:42\n"
" cc:42];");
 
+  // Avoid breaking between unary operators and ObjC method expressions.
+  Style.ColumnLimit = 45;
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "![foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "+[foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "-[foo bar]) {\n"
+   "}");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2429,6 +2429,8 @@
   if (Left.is(TT_JavaAnnotation))
 return 50;
 
+  if (Left.is(TT_UnaryOperator))
+return 60;
   if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
   Left.Previous->isLabelString() &&
   (Left.NextOperator || Left.OperatorIndex != 0))
Index: cfe/trunk/unittests/Format/FormatTestObjC.cpp
===
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp
@@ -886,6 +886,18 @@
" bb:42\n"
" cc:42];");
 
+  // Avoid breaking between unary operators and ObjC method expressions.
+  Style.ColumnLimit = 45;
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "![foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "+[foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "-[foo bar]) {\n"
+   "}");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366592 - [Format/ObjC] Avoid breaking between unary operators and operands

2019-07-19 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Fri Jul 19 09:50:24 2019
New Revision: 366592

URL: http://llvm.org/viewvc/llvm-project?rev=366592=rev
Log:
[Format/ObjC] Avoid breaking between unary operators and operands

Summary:
Test Plan:
  New tests added. Ran tests with:
  % ninja FormatTests && ./tools/clang/unittests/Format/FormatTests
  Confirmed tests failed before change and passed after change.

Reviewers: krasimir, djasper, sammccall, klimek

Reviewed By: sammccall

Subscribers: klimek, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=366592=366591=366592=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jul 19 09:50:24 2019
@@ -2429,6 +2429,8 @@ unsigned TokenAnnotator::splitPenalty(co
   if (Left.is(TT_JavaAnnotation))
 return 50;
 
+  if (Left.is(TT_UnaryOperator))
+return 60;
   if (Left.isOneOf(tok::plus, tok::comma) && Left.Previous &&
   Left.Previous->isLabelString() &&
   (Left.NextOperator || Left.OperatorIndex != 0))

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=366592=366591=366592=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Fri Jul 19 09:50:24 2019
@@ -886,6 +886,18 @@ TEST_F(FormatTestObjC, FormatObjCMethodE
" bb:42\n"
" cc:42];");
 
+  // Avoid breaking between unary operators and ObjC method expressions.
+  Style.ColumnLimit = 45;
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "![foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "+[foo bar]) {\n"
+   "}");
+  verifyFormat("if (a012345678901234567890123 &&\n"
+   "-[foo bar]) {\n"
+   "}");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"


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


[PATCH] D64780: Disallow most calling convention attributes on PS4.

2019-07-19 Thread Sunil Srivastava via Phabricator via cfe-commits
Sunil_Srivastava marked an inline comment as done.
Sunil_Srivastava added inline comments.



Comment at: lib/Basic/Targets/OSTargets.h:564
   }
+  TargetInfo::CallingConvCheckResult checkCallingConvention(CallingConv CC) 
const override {
+return (CC == CC_C) ? TargetInfo::CCCR_OK : TargetInfo::CCCR_Error;

aaron.ballman wrote:
> Line length seems a bit long for coding style requirements.
Ooops. You are right. Will split according to clang-format. Would you want me 
to update the review?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64780/new/

https://reviews.llvm.org/D64780



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


[PATCH] D64592: [OpenMP] Fix declare target link implementation

2019-07-19 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 210856.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64592/new/

https://reviews.llvm.org/D64592

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/declare_target_codegen.cpp
  test/OpenMP/declare_target_link_codegen.cpp
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -31,10 +31,10 @@
 }
 
 // CHECK-HOST: [[VAR:@.+]] = global double 1.00e+01
-// CHECK-HOST: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+// CHECK-HOST: [[VAR_DECL_TGT_LINK_PTR:@.+]] = weak global double* [[VAR]]
 
 // CHECK-HOST: [[TO_VAR:@.+]] = global double 2.00e+01
-// CHECK-HOST: [[VAR_DECL_TGT_TO_PTR:@.+]] = global double* [[TO_VAR]]
+// CHECK-HOST: [[VAR_DECL_TGT_TO_PTR:@.+]] = weak global double* [[TO_VAR]]
 
 // CHECK-HOST: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 8]
 // CHECK-HOST: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 800, i64 800]
@@ -45,8 +45,6 @@
 // CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME:@.+]] = internal unnamed_addr constant [24 x i8]
 // CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR:@.+]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (double** [[VAR_DECL_TGT_TO_PTR]] to i8*), i8* getelementptr inbounds ([24 x i8], [24 x i8]* [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME]], i32 0, i32 0), i64 8, i32 0, i32 0 }, section ".omp_offloading.entries"
 
-// CHECK-HOST: @llvm.used = appending global [2 x i8*] [i8* bitcast (double** [[VAR_DECL_TGT_LINK_PTR]] to i8*), i8* bitcast (double** [[VAR_DECL_TGT_TO_PTR]] to i8*)], section "llvm.metadata"
-
 // CHECK-HOST: [[N_CASTED:%.+]] = alloca i64
 // CHECK-HOST: [[SUM_CASTED:%.+]] = alloca i64
 
@@ -75,10 +73,8 @@
 
 // CHECK-HOST: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 2, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
 
-// CHECK-DEVICE: [[VAR_LINK:@.+]] = common global double* null
-// CHECK-DEVICE: [[VAR_TO:@.+]] = common global double* null
-
-// CHECK-DEVICE: @llvm.used = appending global [2 x i8*] [i8* bitcast (double** [[VAR_LINK]] to i8*), i8* bitcast (double** [[VAR_TO]] to i8*)], section "llvm.metadata"
+// CHECK-DEVICE: [[VAR_LINK:@.+]] = weak global double* null
+// CHECK-DEVICE: [[VAR_TO:@.+]] = weak global double* null
 
 // CHECK-DEVICE: [[VAR_TO_PTR:%.+]] = load double*, double** [[VAR_TO]]
 // CHECK-DEVICE: load double, double* [[VAR_TO_PTR]]
Index: test/OpenMP/declare_target_link_codegen.cpp
===
--- test/OpenMP/declare_target_link_codegen.cpp
+++ test/OpenMP/declare_target_link_codegen.cpp
@@ -18,24 +18,31 @@
 #define HEADER
 
 // HOST-DAG: @c = external global i32,
-// HOST-DAG: @c_decl_tgt_ref_ptr = global i32* @c
+// HOST-DAG: @c_decl_tgt_ref_ptr = weak global i32* @c
+// HOST-DAG: @[[D:.+]] = internal global i32 2
+// HOST-DAG: @[[D_PTR:.+]] = weak global i32* @[[D]]
 // DEVICE-NOT: @c =
-// DEVICE: @c_decl_tgt_ref_ptr = common global i32* null
-// HOST: [[SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 4]
-// HOST: [[MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 35, i64 531]
+// DEVICE: @c_decl_tgt_ref_ptr = weak global i32* null
+// HOST: [[SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 4, i64 4]
+// HOST: [[MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 35, i64 531, i64 531]
 // HOST: @.omp_offloading.entry_name{{.*}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_decl_tgt_ref_ptr\00"
 // HOST: @.omp_offloading.entry.c_decl_tgt_ref_ptr = weak constant %struct.__tgt_offload_entry { i8* bitcast (i32** @c_decl_tgt_ref_ptr to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @.omp_offloading.entry_name, i32 0, i32 0), i64 8, i32 1, i32 0 }, section ".omp_offloading.entries", align 1
-// DEVICE-NOT: internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_decl_tgt_ref_ptr\00"
-// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32** @c_decl_tgt_ref_ptr to i8*)]
+// DEVICE-NOT: internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_{{.*}}_decl_tgt_ref_ptr\00"
+// HOST: @.omp_offloading.entry_name{{.*}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"_{{.*}}d_{{.*}}_decl_tgt_ref_ptr\00"
+// HOST: @.omp_offloading.entry.[[D_PTR]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (i32** @[[D_PTR]] to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @.omp_offloading.entry_name{{.*}}, i32 0, i32 0
 
 extern 

[PATCH] D64592: [OpenMP] Fix declare target link implementation

2019-07-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

LG with a nit.




Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2595
+unsigned DeviceID, Line;
+unsigned FileID = 0;
+getTargetEntryUniqueInfo(CGM.getContext(),

No need to initialize FileID.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64592/new/

https://reviews.llvm.org/D64592



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


[PATCH] D64569: [OpenCL] Improve destructor support in C++ for OpenCL

2019-07-19 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64569/new/

https://reviews.llvm.org/D64569



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


[PATCH] D64592: [OpenMP] Fix declare target link implementation

2019-07-19 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 210854.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64592/new/

https://reviews.llvm.org/D64592

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/declare_target_codegen.cpp
  test/OpenMP/declare_target_link_codegen.cpp
  test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp

Index: test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
===
--- test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
+++ test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
@@ -31,10 +31,10 @@
 }
 
 // CHECK-HOST: [[VAR:@.+]] = global double 1.00e+01
-// CHECK-HOST: [[VAR_DECL_TGT_LINK_PTR:@.+]] = global double* [[VAR]]
+// CHECK-HOST: [[VAR_DECL_TGT_LINK_PTR:@.+]] = weak global double* [[VAR]]
 
 // CHECK-HOST: [[TO_VAR:@.+]] = global double 2.00e+01
-// CHECK-HOST: [[VAR_DECL_TGT_TO_PTR:@.+]] = global double* [[TO_VAR]]
+// CHECK-HOST: [[VAR_DECL_TGT_TO_PTR:@.+]] = weak global double* [[TO_VAR]]
 
 // CHECK-HOST: [[OFFLOAD_SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 8]
 // CHECK-HOST: [[OFFLOAD_MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 800, i64 800]
@@ -45,8 +45,6 @@
 // CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME:@.+]] = internal unnamed_addr constant [24 x i8]
 // CHECK-HOST: [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR:@.+]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (double** [[VAR_DECL_TGT_TO_PTR]] to i8*), i8* getelementptr inbounds ([24 x i8], [24 x i8]* [[OMP_OFFLOAD_ENTRY_TO_VAR_PTR_NAME]], i32 0, i32 0), i64 8, i32 0, i32 0 }, section ".omp_offloading.entries"
 
-// CHECK-HOST: @llvm.used = appending global [2 x i8*] [i8* bitcast (double** [[VAR_DECL_TGT_LINK_PTR]] to i8*), i8* bitcast (double** [[VAR_DECL_TGT_TO_PTR]] to i8*)], section "llvm.metadata"
-
 // CHECK-HOST: [[N_CASTED:%.+]] = alloca i64
 // CHECK-HOST: [[SUM_CASTED:%.+]] = alloca i64
 
@@ -75,10 +73,8 @@
 
 // CHECK-HOST: call i32 @__tgt_target(i64 -1, i8* @{{.*}}.region_id, i32 2, i8** [[BPTR7]], i8** [[BPTR8]], i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[OFFLOAD_MAPTYPES]], i32 0, i32 0))
 
-// CHECK-DEVICE: [[VAR_LINK:@.+]] = common global double* null
-// CHECK-DEVICE: [[VAR_TO:@.+]] = common global double* null
-
-// CHECK-DEVICE: @llvm.used = appending global [2 x i8*] [i8* bitcast (double** [[VAR_LINK]] to i8*), i8* bitcast (double** [[VAR_TO]] to i8*)], section "llvm.metadata"
+// CHECK-DEVICE: [[VAR_LINK:@.+]] = weak global double* null
+// CHECK-DEVICE: [[VAR_TO:@.+]] = weak global double* null
 
 // CHECK-DEVICE: [[VAR_TO_PTR:%.+]] = load double*, double** [[VAR_TO]]
 // CHECK-DEVICE: load double, double* [[VAR_TO_PTR]]
Index: test/OpenMP/declare_target_link_codegen.cpp
===
--- test/OpenMP/declare_target_link_codegen.cpp
+++ test/OpenMP/declare_target_link_codegen.cpp
@@ -18,24 +18,31 @@
 #define HEADER
 
 // HOST-DAG: @c = external global i32,
-// HOST-DAG: @c_decl_tgt_ref_ptr = global i32* @c
+// HOST-DAG: @c_decl_tgt_ref_ptr = weak global i32* @c
+// HOST-DAG: @[[D:.+]] = internal global i32 2
+// HOST-DAG: @[[D_PTR:.+]] = weak global i32* @[[D]]
 // DEVICE-NOT: @c =
-// DEVICE: @c_decl_tgt_ref_ptr = common global i32* null
-// HOST: [[SIZES:@.+]] = private unnamed_addr constant [2 x i64] [i64 4, i64 4]
-// HOST: [[MAPTYPES:@.+]] = private unnamed_addr constant [2 x i64] [i64 35, i64 531]
+// DEVICE: @c_decl_tgt_ref_ptr = weak global i32* null
+// HOST: [[SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 4, i64 4]
+// HOST: [[MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 35, i64 531, i64 531]
 // HOST: @.omp_offloading.entry_name{{.*}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_decl_tgt_ref_ptr\00"
 // HOST: @.omp_offloading.entry.c_decl_tgt_ref_ptr = weak constant %struct.__tgt_offload_entry { i8* bitcast (i32** @c_decl_tgt_ref_ptr to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @.omp_offloading.entry_name, i32 0, i32 0), i64 8, i32 1, i32 0 }, section ".omp_offloading.entries", align 1
-// DEVICE-NOT: internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_decl_tgt_ref_ptr\00"
-// CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32** @c_decl_tgt_ref_ptr to i8*)]
+// DEVICE-NOT: internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_{{.*}}_decl_tgt_ref_ptr\00"
+// HOST: @.omp_offloading.entry_name{{.*}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"_{{.*}}d_{{.*}}_decl_tgt_ref_ptr\00"
+// HOST: @.omp_offloading.entry.[[D_PTR]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (i32** @[[D_PTR]] to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @.omp_offloading.entry_name{{.*}}, i32 0, i32 0
 
 extern 

[PATCH] D64592: [OpenMP] Fix declare target link implementation

2019-07-19 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: test/OpenMP/declare_target_link_codegen.cpp:22-23
+// HOST-DAG: @c_decl_tgt_ref_ptr = weak global i32* @c
+// HOST-DAG: @_{{.*}}d = internal global i32 2
+// HOST-DAG: @_{{.*}}d_{{.*}}_decl_tgt_ref_ptr = weak global i32* @_{{.*}}d
 // DEVICE-NOT: @c =

ABataev wrote:
> Better to define the variable with the name of the original `d` variable for 
> better and stable check
Can you rephrase your comment please? I don't understand what you'd like me to 
do here.

Do you want me to use  [[...]] to define the variable? 


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64592/new/

https://reviews.llvm.org/D64592



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


[PATCH] D64863: [clangd] Ignore diags from builtin files

2019-07-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:563
 FillDiagBase(*LastDiag);
-adjustDiagFromHeader(*LastDiag, Info, *LangOpts);
+if (!InsideMainFile)
+  LastDiagWasAdjusted = adjustDiagFromHeader(*LastDiag, Info, *LangOpts);

ilya-biryukov wrote:
> We probably want to **always** set the value of this field to avoid 
> accidentally reading the flag for the previous `LastDiag`
I don't follow, this is always set in line `475` at the beginning of 
`HandleDiagnostic` method.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64863/new/

https://reviews.llvm.org/D64863



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


[PATCH] D64569: [OpenCL] Improve destructor support in C++ for OpenCL

2019-07-19 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

In D64569#1592059 , @rjmccall wrote:

> Yes, that's the right fix, although you might also consider adding a 
> `getObjectType()` to `CXXMemberCallExpr`.


Thanks, John, it should be better now, but let me know if I can improve 
something.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64569/new/

https://reviews.llvm.org/D64569



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


[PATCH] D64569: [OpenCL] Improve destructor support in C++ for OpenCL

2019-07-19 Thread Marco Antognini via Phabricator via cfe-commits
mantognini updated this revision to Diff 210850.
mantognini added a comment.

- Add minimal regression test for PR42665
- Add CXXMemberCallExpr::getObjectType()


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64569/new/

https://reviews.llvm.org/D64569

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenCXX/PR42665.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-ctor.cl
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.cl

Index: clang/test/CodeGenOpenCLCXX/addrspace-with-class.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/addrspace-with-class.cl
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s --check-prefix=CHECK-DEFINITIONS
+
+// This test ensures the proper address spaces and address space cast are used
+// for constructors, member functions and destructors.
+// See also atexit.cl and global_init.cl for other specific tests.
+
+// CHECK: %struct.MyType = type { i32 }
+struct MyType {
+  MyType(int i) : i(i) {}
+  MyType(int i) __constant : i(i) {}
+  ~MyType() {}
+  ~MyType() __constant {}
+  int bar() { return i + 2; }
+  int bar() __constant { return i + 1; }
+  int i;
+};
+
+// CHECK: @const1 = addrspace(2) global %struct.MyType zeroinitializer
+__constant MyType const1 = 1;
+// CHECK: @const2 = addrspace(2) global %struct.MyType zeroinitializer
+__constant MyType const2(2);
+// CHECK: @glob = addrspace(1) global %struct.MyType zeroinitializer
+MyType glob(1);
+
+// CHECK: call void @_ZNU3AS26MyTypeC1Ei(%struct.MyType addrspace(2)* @const1, i32 1)
+// CHECK: call void @_ZNU3AS26MyTypeC1Ei(%struct.MyType addrspace(2)* @const2, i32 2)
+// CHECK: call void @_ZNU3AS46MyTypeC1Ei(%struct.MyType addrspace(4)* addrspacecast (%struct.MyType addrspace(1)* @glob to %struct.MyType addrspace(4)*), i32 1)
+
+// CHECK-LABEL: define spir_kernel void @fooGlobal()
+kernel void fooGlobal() {
+  // CHECK: call i32 @_ZNU3AS46MyType3barEv(%struct.MyType addrspace(4)* addrspacecast (%struct.MyType addrspace(1)* @glob to %struct.MyType addrspace(4)*))
+  glob.bar();
+  // CHECK: call i32 @_ZNU3AS26MyType3barEv(%struct.MyType addrspace(2)* @const1)
+  const1.bar();
+  // CHECK: call void @_ZNU3AS26MyTypeD1Ev(%struct.MyType addrspace(2)* @const1)
+  const1.~MyType();
+}
+
+// CHECK-LABEL: define spir_kernel void @fooLocal()
+kernel void fooLocal() {
+  // CHECK: [[VAR:%.*]] = alloca %struct.MyType
+  // CHECK: [[REG:%.*]] = addrspacecast %struct.MyType* [[VAR]] to %struct.MyType addrspace(4)*
+  // CHECK: call void @_ZNU3AS46MyTypeC1Ei(%struct.MyType addrspace(4)* [[REG]], i32 3)
+  MyType myLocal(3);
+  // CHECK: [[REG:%.*]] = addrspacecast %struct.MyType* [[VAR]] to %struct.MyType addrspace(4)*
+  // CHECK: call i32 @_ZNU3AS46MyType3barEv(%struct.MyType addrspace(4)* [[REG]])
+  myLocal.bar();
+  // CHECK: [[REG:%.*]] = addrspacecast %struct.MyType* [[VAR]] to %struct.MyType addrspace(4)*
+  // CHECK: call void @_ZNU3AS46MyTypeD1Ev(%struct.MyType addrspace(4)* [[REG]])
+}
+
+// Ensure all members are defined for all the required address spaces.
+// CHECK-DEFINITIONS-DAG: define linkonce_odr void @_ZNU3AS26MyTypeC1Ei(%struct.MyType addrspace(2)* %this, i32 %i)
+// CHECK-DEFINITIONS-DAG: define linkonce_odr void @_ZNU3AS46MyTypeC1Ei(%struct.MyType addrspace(4)* %this, i32 %i)
+// CHECK-DEFINITIONS-DAG: define linkonce_odr void @_ZNU3AS26MyTypeD1Ev(%struct.MyType addrspace(2)* %this)
+// CHECK-DEFINITIONS-DAG: define linkonce_odr void @_ZNU3AS46MyTypeD1Ev(%struct.MyType addrspace(4)* %this)
+// CHECK-DEFINITIONS-DAG: define linkonce_odr i32 @_ZNU3AS26MyType3barEv(%struct.MyType addrspace(2)* %this)
+// CHECK-DEFINITIONS-DAG: define linkonce_odr i32 @_ZNU3AS46MyType3barEv(%struct.MyType addrspace(4)* %this)
Index: clang/test/CodeGenOpenCLCXX/addrspace-ctor.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-ctor.cl
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
-
-struct MyType {
-  MyType(int i) : i(i) {}
-  MyType(int i) __constant : i(i) {}
-  int i;
-};
-
-//CHECK: call void @_ZNU3AS26MyTypeC1Ei(%struct.MyType addrspace(2)* @const1, i32 1)
-__constant MyType const1 = 1;
-//CHECK: call void @_ZNU3AS26MyTypeC1Ei(%struct.MyType addrspace(2)* @const2, i32 2)
-__constant 

[PATCH] D65000: [ARM] Set default alignment to 64bits

2019-07-19 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio created this revision.
dnsampaio added reviewers: ostannard, dmgreen.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

The maximum alignment used by ARM arch
is 64bits, not 128.

This could cause overaligned memory
access for 128 bit neon vector that
have unpredictable behaviour.

This fixes: https://bugs.llvm.org/show_bug.cgi?id=42668


Repository:
  rC Clang

https://reviews.llvm.org/D65000

Files:
  lib/Basic/Targets/ARM.cpp
  test/CodeGen/ARM/exception-alignment.cpp
  test/SemaCXX/warn-overaligned-type-thrown.cpp


Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- test/SemaCXX/warn-overaligned-type-thrown.cpp
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -2,11 +2,11 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions  -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
-// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple aarch64-linux-gnueabi -verify -fsyntax-only 
-std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -verify -fsyntax-only -std=c++11 
-fcxx-exceptions -fexceptions %s
Index: test/CodeGen/ARM/exception-alignment.cpp
===
--- /dev/null
+++ test/CodeGen/ARM/exception-alignment.cpp
@@ -0,0 +1,17 @@
+// Bug: https://bugs.llvm.org/show_bug.cgi?id=42668
+// REQUIRES: arm-registered-target
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-a -S -emit-llvm -Os -o 
- %s | FileCheck %s
+// CHECK: [[E:%[A-z0-9]+]] = tail call i8* @__cxa_allocate_exception
+// CHECK-NEXT: [[BC:%[A-z0-9]+]] = bitcast i8* [[E]] to <2 x i64>*
+// CHECK-NEXT: store <2 x i64> , <2 x i64>* [[BC]], align 8
+#include 
+
+int main(void) {
+  try {
+throw vld1q_u64(((const uint64_t[2]){1, 2}));
+  } catch (uint64x2_t exc) {
+return 0;
+  }
+  return 1;
+}
+
Index: lib/Basic/Targets/ARM.cpp
===
--- lib/Basic/Targets/ARM.cpp
+++ lib/Basic/Targets/ARM.cpp
@@ -325,6 +325,9 @@
: "\01mcount";
 
   SoftFloatABI = llvm::is_contained(Opts.FeaturesAsWritten, "+soft-float-abi");
+
+  // For AArch32, the largest alignment required by the ABI is 64-bit
+  DefaultAlignForAttributeAligned = 64;
 }
 
 StringRef ARMTargetInfo::getABI() const { return ABI; }


Index: test/SemaCXX/warn-overaligned-type-thrown.cpp
===
--- test/SemaCXX/warn-overaligned-type-thrown.cpp
+++ test/SemaCXX/warn-overaligned-type-thrown.cpp
@@ -2,11 +2,11 @@
 // RUN: %clang_cc1 -triple arm64-apple-ios10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos4 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions -DUNDERALIGNED %s
+// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions  -DUNDERALIGNED %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.14 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-ios12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos12 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple arm64-apple-watchos5 -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
-// RUN: %clang_cc1 -triple arm-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple aarch64-linux-gnueabi -verify -fsyntax-only -std=c++11 -fcxx-exceptions -fexceptions %s
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -verify -fsyntax-only 

[PATCH] D61452: [WebAssembly] Always include /lib in library path

2019-07-19 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

> This allows for us to fall back from arch-specific to generic headers as 
> needed.  The same can be true of libraries.  Not all libraries contains 
> compiled code.  `.so` files can also be linker scripts that reference other 
> libraries in which case they can be arch-neutral.

If we add support for implicit linker scripts in wasm-ld, we can look into 
this. That said, it's not clear we'll want to. They're rare, and when they are 
used they're another moving part in the middle of a complex system. There are 
usually other ways to do what they do.

> Secondly, not everyone is going to want to use a multi-arch sysroot.  For 
> example I would argue that the wasi SDK would make more sense being single 
> arch since it has exactly one purpose.  Its only when installing wasi into an 
> existing system that one really needs to be multi-arch.  In any case we 
> should not dictate this.

We're anticipating wasm64. And it's possible WASI could have other triple 
variants in the future too.

I'm aware some users will sometimes know that they only care about wasm32-wasi. 
Some of those users may write code, and perhaps some of those that do will 
share it with others. If such code assumes it can install into $SYSROOT/lib, it 
may break things for others using a multiarch setup. Unless there are reasons 
otherwise, it seems valuable to minimize fragmentation between multiarch and 
non-multiarch users. That seems more valuable than enabling some users to have 
shorter library paths.

> We've already have one person trying to build a wasi-sdk without using 
> multi-arch paths.

They ended up deciding they misunderstood the project for other reasons and 
left, so it's unclear what conclusion to draw.

> I'm not sure what you mean by "single arch sysroots are possible either way". 
>  The point of a single arch sysroot would be avoid the unnecessary extra path 
> components and I thats exactly what this change is allowing for.

I just mean you can have a multi-arch-style directory tree with a single arch 
installed in it.

> Thirdly, its what the linux driver does, which is the example we are 
> following of how to build a multi-arch toolchain.

The Linux driver has to stay compatible with existing pre-multi-arch systems; 
we don't.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61452/new/

https://reviews.llvm.org/D61452



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


[libunwind] r366587 - [libunwind][ARM] Fix loading FP registers on big-endian targets

2019-07-19 Thread Mikhail Maltsev via cfe-commits
Author: miyuki
Date: Fri Jul 19 08:20:32 2019
New Revision: 366587

URL: http://llvm.org/viewvc/llvm-project?rev=366587=rev
Log:
[libunwind][ARM] Fix loading FP registers on big-endian targets

Summary:
The function Unwind-EHABI.cpp:_Unwind_VRS_Pop loads the saved values of
64-bit FP registers as two 32-bit words because they might not be
8-byte aligned. Combining these words into a 64-bit value has to be
done differently on big-endian platforms.

Reviewers: ostannard, john.brawn, dmgreen

Reviewed By: ostannard

Subscribers: kristof.beyls, christof, libcxx-commits

Tags: #libc

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

Modified:
libunwind/trunk/src/Unwind-EHABI.cpp

Modified: libunwind/trunk/src/Unwind-EHABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-EHABI.cpp?rev=366587=366586=366587=diff
==
--- libunwind/trunk/src/Unwind-EHABI.cpp (original)
+++ libunwind/trunk/src/Unwind-EHABI.cpp Fri Jul 19 08:20:32 2019
@@ -941,8 +941,13 @@ _Unwind_VRS_Pop(_Unwind_Context *context
   // format 1", which is equivalent to FSTMD + a padding word.
   for (uint32_t i = first; i < end; ++i) {
 // SP is only 32-bit aligned so don't copy 64-bit at a time.
-uint64_t value = *sp++;
-value |= ((uint64_t)(*sp++)) << 32;
+uint32_t w0 = *sp++;
+uint32_t w1 = *sp++;
+#ifdef __LITTLE_ENDIAN__
+uint64_t value = (w1 << 32) | w0;
+#else
+uint64_t value = (w0 << 32) | w1;
+#endif
 if (_Unwind_VRS_Set(context, regclass, i, representation, ) !=
 _UVRSR_OK)
   return _UVRSR_FAILED;


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


[PATCH] D64780: Disallow most calling convention attributes on PS4.

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

LGTM aside from a nit. You should give other reviewers a chance to sign off in 
case they have additional comments.




Comment at: lib/Basic/Targets/OSTargets.h:564
   }
+  TargetInfo::CallingConvCheckResult checkCallingConvention(CallingConv CC) 
const override {
+return (CC == CC_C) ? TargetInfo::CCCR_OK : TargetInfo::CCCR_Error;

Line length seems a bit long for coding style requirements.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64780/new/

https://reviews.llvm.org/D64780



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


[PATCH] D63648: [Preprocessor] Honor absolute paths in diagnostics

2019-07-19 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D63648#1591469 , @aganea wrote:

> It totally makes sense, thanks for the explanation Nico! Let's forget about 
> `cl` compatibility, that wasn't my initial intent.
>
> We always pass //relative// paths on the cmd-line, for all the reasons you've 
> mentioned. We also pass `-fdiagnostics-absolute-paths` hoping to fix the 
> Visual Studio jump-to-location issue I've mentioned above. However that 
> doesn't work, because we do:
>
>   (locally, on my PC)
> $ clang-cl file.cpp -Isome/relative/path/ -fdiagnostics-absolute-paths 
> /showIncludes -E >file_pre.cpp
>  
>   (and then, on a remote PC)
> $ clang-cl file_pre.cpp -fdiagnostics-absolute-paths
>   (the remote stdout is then displayed on my PC)
>
>
> `-fdiagnostics-absolute-paths` has no effect in the latter case, because the 
> paths are extracted from the preprocessed file, and paths can't be 
> absolutized anymore on the remote PC because it doesn't have the source code 
> (it is only a worker server).
>  So we end with relative paths in diagnostics, and Visual Studio can't jump 
> to the location of the diagnostic.
>
> What would you suggest? Use absolute paths along with `-fdebug-prefix-map`?


I see, thanks for the details.  A few more questions (sorry!):

- Does fastbuild have something like distcc-pump? (In pump mode, distcc sends 
the raw cc files and all included headers to the server, and preprocessing 
happens remotely – 
http://manpages.ubuntu.com/manpages/bionic/man1/distcc.1.html#how%20distcc-pump%20mode%20works)
 I think this would address this (?)

- IIRC we used to use fdiagnostics-absolute-paths in Chromium but eventually 
stopped because someone figured out how to make MSVC's jump-to-diag work even 
with relative paths (?)

I'm not sure what the Right Fix is here – I can see use cases for `-E` both 
with relative and with absolute paths, even if `-fdiagnostics-absolute-paths` 
:-/

I think `-fdebug-prefix-map` doesn't affect `-E` output as far as I know.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63648/new/

https://reviews.llvm.org/D63648



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


[PATCH] D64696: Adds a warning when an inline Doxygen comment has no argument

2019-07-19 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Is it true that all inline commands require an argument?

For example, "\&" does not.




Comment at: clang/test/Sema/warn-documentation.cpp:1030
 
+// The inline comments expect a string after the command.
+// expected-warning@+1 {{'\a' command does not have an argument}}

Please move this new section below the test_attach tests.



Comment at: clang/test/Sema/warn-documentation.cpp:1033
+/// \a
+int test_inline_no_argument_a_b(int);
+

Please un-abbreviate b and g into bad and good.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64696/new/

https://reviews.llvm.org/D64696



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


[PATCH] D64998: Improve clang-format-diff help output

2019-07-19 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: krasimir.

The description in clang-format-diff.py is more useful than the one
in `clang-format-diff -h`, so use the same description in both places.


https://reviews.llvm.org/D64998

Files:
  clang/tools/clang-format/clang-format-diff.py


Index: clang/tools/clang-format/clang-format-diff.py
===
--- clang/tools/clang-format/clang-format-diff.py
+++ clang/tools/clang-format/clang-format-diff.py
@@ -8,10 +8,7 @@
 #
 
#======#
 
-r"""
-ClangFormat Diff Reformatter
-
-
+"""
 This script reads input from a unified diff and reformats all the changed
 lines. This is useful to reformat all the lines touched by a specific patch.
 Example usage for git/svn users:
@@ -35,10 +32,9 @@
 
 
 def main():
-  parser = argparse.ArgumentParser(description=
-   'Reformat changed lines in diff. Without -i 
'
-   'option just output the diff that would be '
-   'introduced.')
+  parser = argparse.ArgumentParser(description=__doc__,
+   formatter_class=
+   
argparse.RawDescriptionHelpFormatter)
   parser.add_argument('-i', action='store_true', default=False,
   help='apply edits to files instead of displaying a diff')
   parser.add_argument('-p', metavar='NUM', default=0,


Index: clang/tools/clang-format/clang-format-diff.py
===
--- clang/tools/clang-format/clang-format-diff.py
+++ clang/tools/clang-format/clang-format-diff.py
@@ -8,10 +8,7 @@
 #
 #======#
 
-r"""
-ClangFormat Diff Reformatter
-
-
+"""
 This script reads input from a unified diff and reformats all the changed
 lines. This is useful to reformat all the lines touched by a specific patch.
 Example usage for git/svn users:
@@ -35,10 +32,9 @@
 
 
 def main():
-  parser = argparse.ArgumentParser(description=
-   'Reformat changed lines in diff. Without -i '
-   'option just output the diff that would be '
-   'introduced.')
+  parser = argparse.ArgumentParser(description=__doc__,
+   formatter_class=
+   argparse.RawDescriptionHelpFormatter)
   parser.add_argument('-i', action='store_true', default=False,
   help='apply edits to files instead of displaying a diff')
   parser.add_argument('-p', metavar='NUM', default=0,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64863: [clangd] Ignore diags from builtin files

2019-07-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 210838.
kadircet marked 5 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64863/new/

https://reviews.llvm.org/D64863

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -907,7 +907,6 @@
 int x = 5/0;)cpp");
   TestTU TU = TestTU::withCode(Main.code());
   TU.AdditionalFiles = {{"a.h", Header.code()}};
-  auto diags = TU.build().getDiagnostics();
   EXPECT_THAT(TU.build().getDiagnostics(),
   UnorderedElementsAre(AllOf(
   Diag(Main.range(), "in included file: C++ requires "
@@ -915,6 +914,19 @@
   WithNote(Diag(Header.range(), "error occurred here");
 }
 
+TEST(IgnoreDiags, FromNonWrittenSources) {
+  Annotations Main(R"cpp(
+#include [["a.h"]]
+void foo() {})cpp");
+  Annotations Header(R"cpp(
+int x = 5/0;
+int b = [[FOO]];)cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles = {{"a.h", Header.code()}};
+  TU.ExtraArgs = {"-DFOO=NOOO"};
+  EXPECT_THAT(TU.build().getDiagnostics(), UnorderedElementsAre());
+}
+
 } // namespace
 
 } // namespace clangd
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -145,6 +145,9 @@
   std::vector Output;
   llvm::Optional LangOpts;
   llvm::Optional LastDiag;
+  // Set by adjustDiagFromHeader to indicate the fact that LastDiag was not
+  // inside main file initially.
+  bool LastDiagWasAdjusted = false;
   llvm::DenseSet IncludeLinesWithErrors;
   bool LastPrimaryDiagnosticWasSuppressed = false;
 };
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -20,6 +20,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Capacity.h"
@@ -107,8 +108,12 @@
   return halfOpenToRange(M, R);
 }
 
-void adjustDiagFromHeader(Diag , const clang::Diagnostic ,
+bool adjustDiagFromHeader(Diag , const clang::Diagnostic ,
   const LangOptions ) {
+  // We only report diagnostics with at least error severity from headers.
+  if (D.Severity < DiagnosticsEngine::Level::Error)
+return false;
+
   const SourceLocation  = Info.getLocation();
   const SourceManager  = Info.getSourceManager();
   SourceLocation IncludeInMainFile;
@@ -119,13 +124,14 @@
IncludeLocation = GetIncludeLoc(IncludeLocation))
 IncludeInMainFile = IncludeLocation;
   if (IncludeInMainFile.isInvalid())
-return;
+return false;
 
   // Update diag to point at include inside main file.
   D.File = SM.getFileEntryForID(SM.getMainFileID())->getName().str();
   D.Range.start = sourceLocToPosition(SM, IncludeInMainFile);
   D.Range.end = sourceLocToPosition(
   SM, Lexer::getLocForEndOfToken(IncludeInMainFile, 0, SM, LangOpts));
+  D.InsideMainFile = true;
 
   // Add a note that will point to real diagnostic.
   const auto *FE = SM.getFileEntryForID(SM.getFileID(DiagLoc));
@@ -138,6 +144,7 @@
 
   // Update message to mention original file.
   D.Message = llvm::Twine("in included file: ", D.Message).str();
+  return true;
 }
 
 bool isInsideMainFile(const clang::Diagnostic ) {
@@ -465,6 +472,7 @@
   }
 
   bool InsideMainFile = isInsideMainFile(Info);
+  SourceManager  = Info.getSourceManager();
 
   auto FillDiagBase = [&](DiagBase ) {
 D.Range = diagnosticRange(Info, *LangOpts);
@@ -472,8 +480,7 @@
 Info.FormatDiagnostic(Message);
 D.Message = Message.str();
 D.InsideMainFile = InsideMainFile;
-D.File = Info.getSourceManager().getFilename(Info.getLocation());
-auto  = Info.getSourceManager();
+D.File = SM.getFilename(Info.getLocation());
 D.AbsFile = getCanonicalPath(
 SM.getFileEntryForID(SM.getFileID(Info.getLocation())), SM);
 D.Severity = DiagLevel;
@@ -496,10 +503,9 @@
   if (FixIt.RemoveRange.getBegin().isMacroID() ||
   FixIt.RemoveRange.getEnd().isMacroID())
 return false;
-  if (!isInsideMainFile(FixIt.RemoveRange.getBegin(),
-Info.getSourceManager()))
+  if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
 return false;
-  Edits.push_back(toTextEdit(FixIt, Info.getSourceManager(), *LangOpts));
+  

[PATCH] D64863: [clangd] Ignore diags from builtin files

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:128
+return false;
+  Position StartPos = sourceLocToPosition(SM, IncludeInMainFile);
 

NIT: inline `StartPos`, it has online a single usage now.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:563
 FillDiagBase(*LastDiag);
-adjustDiagFromHeader(*LastDiag, Info, *LangOpts);
+if (!InsideMainFile)
+  LastDiagWasAdjusted = adjustDiagFromHeader(*LastDiag, Info, *LangOpts);

We probably want to **always** set the value of this field to avoid 
accidentally reading the flag for the previous `LastDiag`



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:608
+  (!LastDiagWasAdjusted ||
+   // Only report the first diagnostic coming from a header.
IncludeLinesWithErrors.insert(LastDiag->Range.start.line).second)) {

NIT: maybe be more specific? coming from **each particular** header?



Comment at: clang-tools-extra/clangd/Diagnostics.h:148
   llvm::Optional LastDiag;
+  bool LastDiagWasAdjusted = false;
   llvm::DenseSet IncludeLinesWithErrors;

NIT: add a comment that it was `adjustDiagFromHeader` that made the adjustment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64863/new/

https://reviews.llvm.org/D64863



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


[PATCH] D64863: [clangd] Ignore diags from builtin files

2019-07-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 210834.
kadircet added a comment.

- Move deduplication logic back into the `flushLastDiag` as discussed offline.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64863/new/

https://reviews.llvm.org/D64863

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -907,7 +907,6 @@
 int x = 5/0;)cpp");
   TestTU TU = TestTU::withCode(Main.code());
   TU.AdditionalFiles = {{"a.h", Header.code()}};
-  auto diags = TU.build().getDiagnostics();
   EXPECT_THAT(TU.build().getDiagnostics(),
   UnorderedElementsAre(AllOf(
   Diag(Main.range(), "in included file: C++ requires "
@@ -915,6 +914,19 @@
   WithNote(Diag(Header.range(), "error occurred here");
 }
 
+TEST(IgnoreDiags, FromNonWrittenSources) {
+  Annotations Main(R"cpp(
+#include [["a.h"]]
+void foo() {})cpp");
+  Annotations Header(R"cpp(
+int x = 5/0;
+int b = [[FOO]];)cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.AdditionalFiles = {{"a.h", Header.code()}};
+  TU.ExtraArgs = {"-DFOO=NOOO"};
+  EXPECT_THAT(TU.build().getDiagnostics(), UnorderedElementsAre());
+}
+
 } // namespace
 
 } // namespace clangd
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -145,6 +145,7 @@
   std::vector Output;
   llvm::Optional LangOpts;
   llvm::Optional LastDiag;
+  bool LastDiagWasAdjusted = false;
   llvm::DenseSet IncludeLinesWithErrors;
   bool LastPrimaryDiagnosticWasSuppressed = false;
 };
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -20,6 +20,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Capacity.h"
@@ -107,8 +108,12 @@
   return halfOpenToRange(M, R);
 }
 
-void adjustDiagFromHeader(Diag , const clang::Diagnostic ,
+bool adjustDiagFromHeader(Diag , const clang::Diagnostic ,
   const LangOptions ) {
+  // We only report diagnostics with at least error severity from headers.
+  if (D.Severity < DiagnosticsEngine::Level::Error)
+return false;
+
   const SourceLocation  = Info.getLocation();
   const SourceManager  = Info.getSourceManager();
   SourceLocation IncludeInMainFile;
@@ -119,13 +124,15 @@
IncludeLocation = GetIncludeLoc(IncludeLocation))
 IncludeInMainFile = IncludeLocation;
   if (IncludeInMainFile.isInvalid())
-return;
+return false;
+  Position StartPos = sourceLocToPosition(SM, IncludeInMainFile);
 
   // Update diag to point at include inside main file.
   D.File = SM.getFileEntryForID(SM.getMainFileID())->getName().str();
-  D.Range.start = sourceLocToPosition(SM, IncludeInMainFile);
+  D.Range.start = std::move(StartPos);
   D.Range.end = sourceLocToPosition(
   SM, Lexer::getLocForEndOfToken(IncludeInMainFile, 0, SM, LangOpts));
+  D.InsideMainFile = true;
 
   // Add a note that will point to real diagnostic.
   const auto *FE = SM.getFileEntryForID(SM.getFileID(DiagLoc));
@@ -138,6 +145,7 @@
 
   // Update message to mention original file.
   D.Message = llvm::Twine("in included file: ", D.Message).str();
+  return true;
 }
 
 bool isInsideMainFile(const clang::Diagnostic ) {
@@ -465,6 +473,7 @@
   }
 
   bool InsideMainFile = isInsideMainFile(Info);
+  SourceManager  = Info.getSourceManager();
 
   auto FillDiagBase = [&](DiagBase ) {
 D.Range = diagnosticRange(Info, *LangOpts);
@@ -472,8 +481,7 @@
 Info.FormatDiagnostic(Message);
 D.Message = Message.str();
 D.InsideMainFile = InsideMainFile;
-D.File = Info.getSourceManager().getFilename(Info.getLocation());
-auto  = Info.getSourceManager();
+D.File = SM.getFilename(Info.getLocation());
 D.AbsFile = getCanonicalPath(
 SM.getFileEntryForID(SM.getFileID(Info.getLocation())), SM);
 D.Severity = DiagLevel;
@@ -496,10 +504,9 @@
   if (FixIt.RemoveRange.getBegin().isMacroID() ||
   FixIt.RemoveRange.getEnd().isMacroID())
 return false;
-  if (!isInsideMainFile(FixIt.RemoveRange.getBegin(),
-Info.getSourceManager()))
+  if (!isInsideMainFile(FixIt.RemoveRange.getBegin(), SM))
 return false;
-  Edits.push_back(toTextEdit(FixIt, Info.getSourceManager(), 

[PATCH] D64838: [Attr] Support _attribute__ ((fallthrough))

2019-07-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D64838#1592520 , 
@Nathan-Huckleberry wrote:

>   void foo() {
> __attribute__((address_space(0))) *x;
> *y;
>   }
>
>
> If the attributes are parsed then function body looks like this to the parser:
>
>   {
> *x; //this one has attributes now
> *y;
>   {
>
>
> The first line should be a valid declaration and the second like should be a 
> dereference of an uninitialized variable. If the attributes token is 
> discarded before parsing the rest of the line the only way to differentiate 
> these is by looking at the attributes added to them.
>
> An alternative may be parse the attributes list and immediately try to parse 
> as a declaration then if that parsing fails attempt to parse as something 
> else. Although this approach also has the scary implication of things that 
> are supposed to be declarations getting reparsed as something entirely 
> different.


The issue is that a leading GNU-style attribute is not sufficient information 
to determine whether we're parsing a declaration or a statement; it shouldn't 
always be treated as a decl-specifier. I spoke with a GCC dev about how they 
handle this, and effectively, they parse the attributes first then attempt to 
parse a declaration; if that fails, they fall back to parsing a statement. I 
think the way forward for us that should be similar is to parse the attributes 
first and then wait until we see a decl-specifier before determining whether we 
want to parse a declaration or a statement, and attach the attributes after 
we've figured out which production we have. @rsmith may have even better 
approaches in mind, but we're definitely agreed that we should not parse 
statement/decl based on attribute identity. I would hope we could find a way to 
avoid lots of re-parsing work if we can (even to the point of perhaps breaking 
the `address_space` case because implicit int is pretty horrible to rely on in 
the first place; it depends on whether breaking that will break a lot of code 
or not).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64838/new/

https://reviews.llvm.org/D64838



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


[libclc] r366581 - Creating release candidate final from release_801 branch

2019-07-19 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Jul 19 07:14:12 2019
New Revision: 366581

URL: http://llvm.org/viewvc/llvm-project?rev=366581=rev
Log:
Creating release candidate final from release_801 branch

Added:
libclc/tags/RELEASE_801/final/
  - copied from r366580, libclc/branches/release_80/

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


[libunwind] r366581 - Creating release candidate final from release_801 branch

2019-07-19 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Fri Jul 19 07:14:12 2019
New Revision: 366581

URL: http://llvm.org/viewvc/llvm-project?rev=366581=rev
Log:
Creating release candidate final from release_801 branch

Added:
libunwind/tags/RELEASE_801/final/
  - copied from r366580, libunwind/branches/release_80/

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


[PATCH] D64863: [clangd] Ignore diags from builtin files

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:601
-  if (mentionsMainFile(*LastDiag) ||
-  (LastDiag->Severity >= DiagnosticsEngine::Level::Error &&
-   IncludeLinesWithErrors.insert(LastDiag->Range.start.line).second)) {

It's not clear why we these conditions should be checked somewhere else.
Could you explain in more detail?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64863/new/

https://reviews.llvm.org/D64863



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


[PATCH] D64592: [OpenMP] Fix declare target link implementation

2019-07-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:2592-2593
   llvm::raw_svector_ostream OS(PtrName);
-  OS << CGM.getMangledName(GlobalDecl(VD)) << "_decl_tgt_ref_ptr";
+  unsigned DeviceID, Line;
+  unsigned FileID = 0;
+  OS << CGM.getMangledName(GlobalDecl(VD));

Move those 3 vars to `if` statement, they are not needed here.



Comment at: test/OpenMP/declare_target_link_codegen.cpp:22-23
+// HOST-DAG: @c_decl_tgt_ref_ptr = weak global i32* @c
+// HOST-DAG: @_{{.*}}d = internal global i32 2
+// HOST-DAG: @_{{.*}}d_{{.*}}_decl_tgt_ref_ptr = weak global i32* @_{{.*}}d
 // DEVICE-NOT: @c =

Better to define the variable with the name of the original `d` variable for 
better and stable check


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64592/new/

https://reviews.llvm.org/D64592



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


[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

The fix for a race condition on remove has landed in rL366577 
, this revision would need a small update 
after it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64475/new/

https://reviews.llvm.org/D64475



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


[PATCH] D64985: [clangd] Provide a way to publish highlightings in non-racy manner

2019-07-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366577: [clangd] Provide a way to publish highlightings in 
non-racy manner (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64985?vs=210823=210824#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64985/new/

https://reviews.llvm.org/D64985

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/TUScheduler.cpp
  clang-tools-extra/trunk/clangd/TUScheduler.h
  clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/trunk/clangd/TUScheduler.h
===
--- clang-tools-extra/trunk/clangd/TUScheduler.h
+++ clang-tools-extra/trunk/clangd/TUScheduler.h
@@ -15,6 +15,7 @@
 #include "Threading.h"
 #include "index/CanonicalIncludes.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -98,6 +99,10 @@
   virtual void onPreambleAST(PathRef Path, ASTContext ,
  std::shared_ptr PP,
  const CanonicalIncludes &) {}
+
+  /// The argument function is run under the critical section guarding against
+  /// races when closing the files.
+  using PublishFn = llvm::function_ref)>;
   /// Called on the AST built for the file itself. Note that preamble AST nodes
   /// are not deserialized and should be processed in the onPreambleAST call
   /// instead.
@@ -108,10 +113,17 @@
   /// etc. Clients are expected to process only the AST nodes from the main file
   /// in this callback (obtained via ParsedAST::getLocalTopLevelDecls) to obtain
   /// optimal performance.
-  virtual void onMainAST(PathRef Path, ParsedAST ) {}
-
-  /// Called whenever the diagnostics for \p File are produced.
-  virtual void onDiagnostics(PathRef File, std::vector Diags) {}
+  ///
+  /// When information about the file (diagnostics, syntax highlighting) is
+  /// published to clients, this should be wrapped in Publish, e.g.
+  ///   void onMainAST(...) {
+  /// Highlights = computeHighlights();
+  /// Publish([&] { notifyHighlights(Path, Highlights); });
+  ///   }
+  /// This guarantees that clients will see results in the correct sequence if
+  /// the file is concurrently closed and/or reopened. (The lambda passed to
+  /// Publish() may never run in this case).
+  virtual void onMainAST(PathRef Path, ParsedAST , PublishFn Publish) {}
 
   /// Called whenever the TU status is updated.
   virtual void onFileUpdated(PathRef File, const TUStatus ) {}
Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -14,6 +14,7 @@
 #include "FormattedString.h"
 #include "Headers.h"
 #include "Protocol.h"
+#include "SemanticHighlighting.h"
 #include "SourceCode.h"
 #include "TUScheduler.h"
 #include "Trace.h"
@@ -31,6 +32,7 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
@@ -60,15 +62,20 @@
   FIndex->updatePreamble(Path, Ctx, std::move(PP), CanonIncludes);
   }
 
-  void onMainAST(PathRef Path, ParsedAST ) override {
+  void onMainAST(PathRef Path, ParsedAST , PublishFn Publish) override {
 if (FIndex)
   FIndex->updateMain(Path, AST);
+
+std::vector Diagnostics = AST.getDiagnostics();
+std::vector Highlightings;
 if (SemanticHighlighting)
-  DiagConsumer.onHighlightingsReady(Path, getSemanticHighlightings(AST));
-  }
+  Highlightings = getSemanticHighlightings(AST);
 
-  void onDiagnostics(PathRef File, std::vector Diags) override {
-DiagConsumer.onDiagnosticsReady(File, std::move(Diags));
+Publish([&]() {
+  DiagConsumer.onDiagnosticsReady(Path, std::move(Diagnostics));
+  if (SemanticHighlighting)
+DiagConsumer.onHighlightingsReady(Path, std::move(Highlightings));
+});
   }
 
   void onFileUpdated(PathRef File, const TUStatus ) override {
Index: clang-tools-extra/trunk/clangd/TUScheduler.cpp
===
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp
@@ -249,9 +249,8 @@
   TUStatus Status;
 
   Semaphore 
-  /// Whether the diagnostics for the current FileInputs were reported to the
-  /// users before.
-  bool DiagsWereReported = false;
+  /// Whether the 'onMainAST' callback ran for the current FileInputs.
+  bool RanASTCallback = false;
   /// Guards members used by both TUScheduler and the worker thread.
   mutable 

[clang-tools-extra] r366577 - [clangd] Provide a way to publish highlightings in non-racy manner

2019-07-19 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Fri Jul 19 06:51:01 2019
New Revision: 366577

URL: http://llvm.org/viewvc/llvm-project?rev=366577=rev
Log:
[clangd] Provide a way to publish highlightings in non-racy manner

Summary:
By exposing a callback that can guard code publishing results of
'onMainAST' callback in the same manner we guard diagnostics.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: javed.absar, MaskRay, jkorous, arphaman, kadircet, hokein, 
jvikstrom, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=366577=366576=366577=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Fri Jul 19 06:51:01 2019
@@ -14,6 +14,7 @@
 #include "FormattedString.h"
 #include "Headers.h"
 #include "Protocol.h"
+#include "SemanticHighlighting.h"
 #include "SourceCode.h"
 #include "TUScheduler.h"
 #include "Trace.h"
@@ -31,6 +32,7 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
@@ -60,15 +62,20 @@ struct UpdateIndexCallbacks : public Par
   FIndex->updatePreamble(Path, Ctx, std::move(PP), CanonIncludes);
   }
 
-  void onMainAST(PathRef Path, ParsedAST ) override {
+  void onMainAST(PathRef Path, ParsedAST , PublishFn Publish) override {
 if (FIndex)
   FIndex->updateMain(Path, AST);
+
+std::vector Diagnostics = AST.getDiagnostics();
+std::vector Highlightings;
 if (SemanticHighlighting)
-  DiagConsumer.onHighlightingsReady(Path, getSemanticHighlightings(AST));
-  }
+  Highlightings = getSemanticHighlightings(AST);
 
-  void onDiagnostics(PathRef File, std::vector Diags) override {
-DiagConsumer.onDiagnosticsReady(File, std::move(Diags));
+Publish([&]() {
+  DiagConsumer.onDiagnosticsReady(Path, std::move(Diagnostics));
+  if (SemanticHighlighting)
+DiagConsumer.onHighlightingsReady(Path, std::move(Highlightings));
+});
   }
 
   void onFileUpdated(PathRef File, const TUStatus ) override {

Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=366577=366576=366577=diff
==
--- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original)
+++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Fri Jul 19 06:51:01 2019
@@ -249,9 +249,8 @@ private:
   TUStatus Status;
 
   Semaphore 
-  /// Whether the diagnostics for the current FileInputs were reported to the
-  /// users before.
-  bool DiagsWereReported = false;
+  /// Whether the 'onMainAST' callback ran for the current FileInputs.
+  bool RanASTCallback = false;
   /// Guards members used by both TUScheduler and the worker thread.
   mutable std::mutex Mutex;
   /// File inputs, currently being used by the worker.
@@ -265,15 +264,16 @@ private:
   bool Done;/* GUARDED_BY(Mutex) */
   std::deque Requests; /* GUARDED_BY(Mutex) */
   mutable std::condition_variable RequestsCV;
-  // FIXME: rename it to better fix the current usage, we also use it to guard
-  // emitting TUStatus.
-  /// Guards a critical section for running the diagnostics callbacks.
-  std::mutex DiagsMu;
-  // Used to prevent remove document + leading to out-of-order diagnostics:
+  /// Guards the callback that publishes results of AST-related computations
+  /// (diagnostics, highlightings) and file statuses.
+  std::mutex PublishMu;
+  // Used to prevent remove document + add document races that lead to
+  // out-of-order callbacks for publishing results of onMainAST callback.
+  //
   // The lifetime of the old/new ASTWorkers will overlap, but their handles
   // don't. When the old handle is destroyed, the old worker will stop 
reporting
-  // diagnostics.
-  bool ReportDiagnostics = true; /* GUARDED_BY(DiagsMu) */
+  // any results to the user.
+  bool CanPublishResults = true; /* GUARDED_BY(PublishMu) */
 };
 
 /// A smart-pointer-like class that points to an active ASTWorker.
@@ -381,12 +381,12 @@ void ASTWorker::update(ParseInputs Input
 std::tie(Inputs.CompileCommand, Inputs.Contents);
 
 tooling::CompileCommand OldCommand = PrevInputs->CompileCommand;
-bool PrevDiagsWereReported = DiagsWereReported;
+bool RanCallbackForPrevInputs = RanASTCallback;
 {
   std::lock_guard Lock(Mutex);
   

[PATCH] D64416: [AArch64] Add support for Transactional Memory Extension (TME)

2019-07-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/test/CodeGen/AArch64/tme-tcancel.ll:1
+; RUN: llc %s -o - | FileCheck %s
+

Would it make sense to add -verify-machineinstrs to all these 
Codegen/AArch64/tme-*.ll tests?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64416/new/

https://reviews.llvm.org/D64416



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


[PATCH] D64739: [SVE][Inline-Asm] Add support to specify SVE registers in the clobber list

2019-07-19 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 210821.
kmclaughlin retitled this revision from "[SVE][Inline-Asm] Add support to clang 
for SVE inline assembly" to "[SVE][Inline-Asm] Add support to specify SVE 
registers in the clobber list".
kmclaughlin added a comment.

- Removed typo fixes from this patch
- Consolidated the tests in aarch64-sve-inline-asm.c into one test & fixed 
formatting
- Added a test without +sve to ensure we get the correct diagnostic


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64739/new/

https://reviews.llvm.org/D64739

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-sve-inline-asm.c


Index: clang/test/CodeGen/aarch64-sve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-inline-asm.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -target-feature 
+sve -o - %s | FileCheck %s -check-prefix=CHECK-SVE
+// RUN: not %clang_cc1 -triple aarch64-none-linux-gnu -S %s -o - 2>&1 | 
FileCheck %s -check-prefix=CHECK-ERROR
+
+long test_sve_asm() {
+  long t;
+
+  asm volatile(
+  "ptrue p0.d\n"
+  "ptrue p15.d\n"
+  "add z0.d, p0/m, z0.d, z0.d\n"
+  "add z31.d, p0/m, z31.d, z31.d\n"
+  : "=w"(t)
+  :
+  : "z0", "z31", "p0", "p15");
+  // CHECK-SVE: "=w,~{z0},~{z31},~{p0},~{p15}"
+  // CHECK-ERROR: error: instruction requires: sve
+
+  return t;
+}
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -351,10 +351,19 @@
 "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", 
"d22",
 "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
 
-// Vector registers
+// Neon vector registers
 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
 "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", 
"v22",
-"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"
+"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+
+// SVE vector registers
+"z0",  "z1",  "z2",  "z3",  "z4",  "z5",  "z6",  "z7",  "z8",  "z9",  
"z10",
+"z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", 
"z21",
+"z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
+
+// SVE predicate registers
+"p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  
"p10",
+"p11", "p12", "p13", "p14", "p15"
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {


Index: clang/test/CodeGen/aarch64-sve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-inline-asm.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -target-feature +sve -o - %s | FileCheck %s -check-prefix=CHECK-SVE
+// RUN: not %clang_cc1 -triple aarch64-none-linux-gnu -S %s -o - 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR
+
+long test_sve_asm() {
+  long t;
+
+  asm volatile(
+  "ptrue p0.d\n"
+  "ptrue p15.d\n"
+  "add z0.d, p0/m, z0.d, z0.d\n"
+  "add z31.d, p0/m, z31.d, z31.d\n"
+  : "=w"(t)
+  :
+  : "z0", "z31", "p0", "p15");
+  // CHECK-SVE: "=w,~{z0},~{z31},~{p0},~{p15}"
+  // CHECK-ERROR: error: instruction requires: sve
+
+  return t;
+}
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -351,10 +351,19 @@
 "d12", "d13", "d14", "d15", "d16", "d17", "d18", "d19", "d20", "d21", "d22",
 "d23", "d24", "d25", "d26", "d27", "d28", "d29", "d30", "d31",
 
-// Vector registers
+// Neon vector registers
 "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
 "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21", "v22",
-"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31"
+"v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+
+// SVE vector registers
+"z0",  "z1",  "z2",  "z3",  "z4",  "z5",  "z6",  "z7",  "z8",  "z9",  "z10",
+"z11", "z12", "z13", "z14", "z15", "z16", "z17", "z18", "z19", "z20", "z21",
+"z22", "z23", "z24", "z25", "z26", "z27", "z28", "z29", "z30", "z31",
+
+// SVE predicate registers
+"p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  "p10",
+"p11", "p12", "p13", "p14", "p15"
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64985: [clangd] Provide a way to publish highlightings in non-racy manner

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 210823.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Group PublishFn with onMainAST


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64985/new/

https://reviews.llvm.org/D64985

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -7,10 +7,14 @@
 //===--===//
 
 #include "Annotations.h"
+#include "ClangdUnit.h"
 #include "Context.h"
+#include "Diagnostics.h"
 #include "Matchers.h"
+#include "Path.h"
 #include "TUScheduler.h"
 #include "TestFS.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -56,12 +60,17 @@
   /// in updateWithDiags.
   static std::unique_ptr captureDiags() {
 class CaptureDiags : public ParsingCallbacks {
-  void onDiagnostics(PathRef File, std::vector Diags) override {
+  void onMainAST(PathRef File, ParsedAST , PublishFn Publish) override {
+auto Diags = AST.getDiagnostics();
 auto D = Context::current().get(DiagsCallbackKey);
 if (!D)
   return;
-const_cast)> &> (
-*D)(File, Diags);
+
+Publish([&]() {
+  const_cast<
+  llvm::unique_function)> &> (*D)(
+  File, std::move(Diags));
+});
   }
 };
 return llvm::make_unique();
@@ -116,8 +125,8 @@
   S.update(Added, getInputs(Added, "x"), WantDiagnostics::No);
   EXPECT_EQ(S.getContents(Added), "x");
 
-  // Assert each operation for missing file is an error (even if it's available
-  // in VFS).
+  // Assert each operation for missing file is an error (even if it's
+  // available in VFS).
   S.runWithAST("", Missing,
[&](Expected AST) { EXPECT_ERROR(AST); });
   S.runWithPreamble(
@@ -367,8 +376,8 @@
 StringRef AllContents[] = {Contents1, Contents2, Contents3};
 const int AllContentsSize = 3;
 
-// Scheduler may run tasks asynchronously, but should propagate the context.
-// We stash a nonce in the context, and verify it in the task.
+// Scheduler may run tasks asynchronously, but should propagate the
+// context. We stash a nonce in the context, and verify it in the task.
 static Key NonceKey;
 int Nonce = 0;
 
@@ -465,8 +474,8 @@
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_EQ(BuiltASTCounter.load(), 1);
 
-  // Build two more files. Since we can retain only 2 ASTs, these should be the
-  // ones we see in the cache later.
+  // Build two more files. Since we can retain only 2 ASTs, these should be
+  // the ones we see in the cache later.
   updateWithCallback(S, Bar, SourceContents, WantDiagnostics::Yes,
  []() { ++BuiltASTCounter; });
   updateWithCallback(S, Baz, SourceContents, WantDiagnostics::Yes,
Index: clang-tools-extra/clangd/TUScheduler.h
===
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -15,6 +15,7 @@
 #include "Threading.h"
 #include "index/CanonicalIncludes.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -98,6 +99,10 @@
   virtual void onPreambleAST(PathRef Path, ASTContext ,
  std::shared_ptr PP,
  const CanonicalIncludes &) {}
+
+  /// The argument function is run under the critical section guarding against
+  /// races when closing the files.
+  using PublishFn = llvm::function_ref)>;
   /// Called on the AST built for the file itself. Note that preamble AST nodes
   /// are not deserialized and should be processed in the onPreambleAST call
   /// instead.
@@ -108,10 +113,17 @@
   /// etc. Clients are expected to process only the AST nodes from the main file
   /// in this callback (obtained via ParsedAST::getLocalTopLevelDecls) to obtain
   /// optimal performance.
-  virtual void onMainAST(PathRef Path, ParsedAST ) {}
-
-  /// Called whenever the diagnostics for \p File are produced.
-  virtual void onDiagnostics(PathRef File, std::vector Diags) {}
+  ///
+  /// When information about the file (diagnostics, syntax highlighting) is
+  /// published to clients, this should be wrapped in Publish, e.g.
+  ///   void onMainAST(...) {
+  /// Highlights = computeHighlights();
+  /// Publish([&] { notifyHighlights(Path, Highlights); });
+  ///   }
+  /// This guarantees that clients will see results in 

[PATCH] D64990: [clangd] Disable background-index on lit-tests by default

2019-07-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366575: [clangd] Disable background-index on lit-tests by 
default (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64990?vs=210820=210822#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64990/new/

https://reviews.llvm.org/D64990

Files:
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -355,8 +355,12 @@
 InputStyle = JSONStreamStyle::Delimited;
 LogLevel = Logger::Verbose;
 PrettyPrint = true;
+// Disable background index on lit tests by default to prevent disk writes.
+if (!EnableBackgroundIndex.getNumOccurrences())
+  EnableBackgroundIndex = false;
 // Ensure background index makes progress.
-BackgroundQueue::preventThreadStarvationInTests();
+else if (EnableBackgroundIndex)
+  BackgroundQueue::preventThreadStarvationInTests();
   }
   if (Test || EnableTestScheme) {
 static URISchemeRegistry::Add X(


Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -355,8 +355,12 @@
 InputStyle = JSONStreamStyle::Delimited;
 LogLevel = Logger::Verbose;
 PrettyPrint = true;
+// Disable background index on lit tests by default to prevent disk writes.
+if (!EnableBackgroundIndex.getNumOccurrences())
+  EnableBackgroundIndex = false;
 // Ensure background index makes progress.
-BackgroundQueue::preventThreadStarvationInTests();
+else if (EnableBackgroundIndex)
+  BackgroundQueue::preventThreadStarvationInTests();
   }
   if (Test || EnableTestScheme) {
 static URISchemeRegistry::Add X(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:307
+llvm::StringRef NewCode;
+std::vector DiffedLines;
+  } TestCases[]{

@hokein rightfully pointed out that mentioning all changed lines makes the 
tests unreadable.
An alternative idea we all came up with is to force people to put `^` on each 
of the changed lines inside the `NewCode`, i.e.

```
{/*Before*/ R"(
  $Var[[a]]
  $Func[[b]]
"),
 /*After*/ R"(
  $Var[[a]]
 ^$Func[[b]]
)"} // and no list of lines is needed!
```

Could we do that here?

One interesting case that we can't test this way to removing lines from the end 
of the file. But for that particular case, could we just write a separate test 
case?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64475/new/

https://reviews.llvm.org/D64475



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


[clang-tools-extra] r366575 - [clangd] Disable background-index on lit-tests by default

2019-07-19 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Fri Jul 19 06:40:30 2019
New Revision: 366575

URL: http://llvm.org/viewvc/llvm-project?rev=366575=rev
Log:
[clangd] Disable background-index on lit-tests by default

Summary:
Since background-index can perform disk writes, we don't want to turn
it on tests that won't clear it.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=366575=366574=366575=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Fri Jul 19 06:40:30 2019
@@ -355,8 +355,12 @@ int main(int argc, char *argv[]) {
 InputStyle = JSONStreamStyle::Delimited;
 LogLevel = Logger::Verbose;
 PrettyPrint = true;
+// Disable background index on lit tests by default to prevent disk writes.
+if (!EnableBackgroundIndex.getNumOccurrences())
+  EnableBackgroundIndex = false;
 // Ensure background index makes progress.
-BackgroundQueue::preventThreadStarvationInTests();
+else if (EnableBackgroundIndex)
+  BackgroundQueue::preventThreadStarvationInTests();
   }
   if (Test || EnableTestScheme) {
 static URISchemeRegistry::Add X(


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


[PATCH] D64990: [clangd] Disable background-index on lit-tests by default

2019-07-19 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:361
+  EnableBackgroundIndex = false;
 // Ensure background index makes progress.
 BackgroundQueue::preventThreadStarvationInTests();

maybe add "if enabled" here, this reads a little funny otherwise!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64990/new/

https://reviews.llvm.org/D64990



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


[PATCH] D64991: [analyzer][WIP] Implement a primitive reaching definitions analysis

2019-07-19 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, baloghadamsoftware, Charusso, 
rnkovacs, a_sidorin, dcoughlin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, whisperity, mgorny.

When I say WIP, I really mean it. This has no comments, no nothing, but follows 
this  algorithm pretty 
literally.

This analysis isn't conservative enough yet, I really should include function 
calls with non-const references into the gen set, but hey, at this point I'm 
optimistic that it can be done.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64991

Files:
  clang/include/clang/Analysis/Analyses/ReachingDefinitions.h
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/ReachingDefinitions.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/test/Analysis/dump-definitions.cpp

Index: clang/test/Analysis/dump-definitions.cpp
===
--- /dev/null
+++ clang/test/Analysis/dump-definitions.cpp
@@ -0,0 +1,176 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=debug.DumpGenSets \
+// RUN:   -analyzer-checker=debug.DumpKillSets \
+// RUN:   -analyzer-checker=debug.DumpReachingDefinitions \
+// RUN:   2>&1 | FileCheck %s
+
+
+
+int getInt();
+int *getIntPtr();
+bool coin();
+
+void single_vardecl_in_declstmt() {
+  int *ptr = getIntPtr();
+}
+
+// CHECK:  GEN sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 1 (ptr, [1, 3])
+// CHECK-NEXT: KILL sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: Reaching definition sets: blockid IN/OUT (varname [blockid, elementid])
+// CHECK-NEXT: 0 IN (ptr, [1, 3])
+// CHECK-NEXT: 1 OUT (ptr, [1, 3])
+
+void multiple_vardecl_in_declstmt() {
+  int *ptr = getIntPtr(), i;
+}
+
+// CHECK:  GEN sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 1 (i, [1, 4])
+// CHECK-NEXT: 1 (ptr, [1, 3])
+// CHECK-NEXT: KILL sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: Reaching definition sets: blockid IN/OUT (varname [blockid, elementid])
+// CHECK-NEXT: 0 IN (i, [1, 4])
+// CHECK-NEXT: 0 IN (ptr, [1, 3])
+// CHECK-NEXT: 1 OUT (i, [1, 4])
+// CHECK-NEXT: 1 OUT (ptr, [1, 3])
+
+void function_and_vardecl_in_declstmt() {
+  int *ptr = getIntPtr(), a();
+}
+
+// CHECK:  GEN sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 1 (ptr, [1, 3])
+// CHECK-NEXT: KILL sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: Reaching definition sets: blockid IN/OUT (varname [blockid, elementid])
+// CHECK-NEXT: 0 IN (ptr, [1, 3])
+// CHECK-NEXT: 1 OUT (ptr, [1, 3])
+
+void single_def_in_same_block() {
+  int *ptr = getIntPtr();
+
+  if (coin())
+ptr = 0;
+
+  if (!ptr)
+*ptr = 5;
+}
+
+// CHECK:  GEN sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 3 (ptr, [3, 3])
+// CHECK-NEXT: 4 (ptr, [4, 3])
+// CHECK-NEXT: KILL sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 3 (ptr, [4, 3])
+// CHECK-NEXT: 4 (ptr, [3, 3])
+// CHECK-NEXT: Reaching definition sets: blockid IN/OUT (varname [blockid, elementid])
+// CHECK-NEXT: 2 IN (ptr, [3, 3])
+// CHECK-NEXT: 2 IN (ptr, [4, 3])
+// CHECK-NEXT: 3 IN (ptr, [4, 3])
+// CHECK-NEXT: 3 OUT (ptr, [3, 3])
+// CHECK-NEXT: 4 OUT (ptr, [4, 3])
+
+void different_assignments() {
+  int i = getInt();
+
+  if (coin())
+i = 0;
+
+  i += 3;
+
+  if (!coin())
+i -= 2;
+
+  i *= 9;
+
+  if (i = 0)
+;
+}
+
+// CHECK:  GEN sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 2 (i, [2, 5])
+// CHECK-NEXT: 3 (i, [3, 2])
+// CHECK-NEXT: 4 (i, [4, 2])
+// CHECK-NEXT: 5 (i, [5, 2])
+// CHECK-NEXT: 6 (i, [6, 3])
+// CHECK-NEXT: KILL sets: blockid (varname [blockid, elementid])
+// CHECK-NEXT: 2 (i, [3, 2])
+// CHECK-NEXT: 2 (i, [4, 2])
+// CHECK-NEXT: 2 (i, [5, 2])
+// CHECK-NEXT: 2 (i, [6, 3])
+// CHECK-NEXT: 3 (i, [2, 5])
+// CHECK-NEXT: 3 (i, [4, 2])
+// CHECK-NEXT: 3 (i, [5, 2])
+// CHECK-NEXT: 3 (i, [6, 3])
+// CHECK-NEXT: 4 (i, [2, 5])
+// CHECK-NEXT: 4 (i, [3, 2])
+// CHECK-NEXT: 4 (i, [5, 2])
+// CHECK-NEXT: 4 (i, [6, 3])
+// CHECK-NEXT: 5 (i, [2, 5])
+// CHECK-NEXT: 5 (i, [3, 2])
+// CHECK-NEXT: 5 (i, [4, 2])
+// CHECK-NEXT: 5 (i, [6, 3])
+// CHECK-NEXT: 6 (i, [2, 5])
+// CHECK-NEXT: 6 (i, [3, 2])
+// CHECK-NEXT: 6 (i, [4, 2])
+// CHECK-NEXT: 6 (i, [5, 2])
+// CHECK-NEXT: Reaching definition sets: blockid IN/OUT (varname [blockid, elementid])
+// CHECK-NEXT: 0 IN (i, [2, 5])
+// CHECK-NEXT: 1 IN (i, [2, 5])
+// CHECK-NEXT: 2 IN (i, [3, 2])
+// CHECK-NEXT: 2 IN (i, [4, 2])
+// CHECK-NEXT: 2 OUT (i, [2, 5])
+// CHECK-NEXT: 3 IN (i, [4, 2])
+// CHECK-NEXT: 3 OUT (i, [3, 2])
+// CHECK-NEXT: 4 IN (i, [5, 2])
+// CHECK-NEXT: 4 IN (i, [6, 3])
+// CHECK-NEXT: 4 OUT (i, [4, 2])
+// CHECK-NEXT: 5 IN (i, [6, 3])
+// CHECK-NEXT: 5 OUT (i, [5, 2])
+// 

[PATCH] D64990: [clangd] Disable background-index on lit-tests by default

2019-07-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Since background-index can perform disk writes, we don't want to turn
it on tests that won't clear it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64990

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -355,6 +355,9 @@
 InputStyle = JSONStreamStyle::Delimited;
 LogLevel = Logger::Verbose;
 PrettyPrint = true;
+// Disable background index on lit tests by default to prevent disk writes.
+if (!EnableBackgroundIndex.getNumOccurrences())
+  EnableBackgroundIndex = false;
 // Ensure background index makes progress.
 BackgroundQueue::preventThreadStarvationInTests();
   }


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -355,6 +355,9 @@
 InputStyle = JSONStreamStyle::Delimited;
 LogLevel = Logger::Verbose;
 PrettyPrint = true;
+// Disable background index on lit tests by default to prevent disk writes.
+if (!EnableBackgroundIndex.getNumOccurrences())
+  EnableBackgroundIndex = false;
 // Ensure background index makes progress.
 BackgroundQueue::preventThreadStarvationInTests();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44100: [ASTImporter] Reorder fields after structure import is finished

2019-07-19 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 210813.
martong added a comment.

- Rebase to master
- Some refactor is done mostly because since D63603 
 ([ASTImporter] Propagate

error from ImportDeclContext) we may not imported successfully all decls of a
DC.

- Made the code simpler and shorter by adding a local vector to hold the decls

of the "from" DC in the original order.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D44100/new/

https://reviews.llvm.org/D44100

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -1472,7 +1472,7 @@
 }
 
 TEST_P(ASTImporterOptionSpecificTestBase,
-   DISABLED_CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
+   CXXRecordDeclFieldOrderShouldNotDependOnImportOrder) {
   Decl *From, *To;
   std::tie(From, To) = getImportedDecl(
   // The original recursive algorithm of ASTImporter first imports 'c' then
@@ -5232,5 +5232,16 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, LLDBLookupTest,
 DefaultTestValuesForRunOptions, );
 
+TEST_P(ImportDecl, ImportFieldOrder) {
+  MatchVerifier Verifier;
+  testImport("struct declToImport {"
+ "  int b = a + 2;"
+ "  int a = 5;"
+ "};",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ recordDecl(hasFieldOrder({"b", "a"})));
+}
+
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1645,7 +1645,6 @@
   bool AccumulateChildErrors = isa(FromDC);
 
   Error ChildErrors = Error::success();
-  llvm::SmallVector ImportedDecls;
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
 if (!ImportedOrErr) {
@@ -1657,6 +1656,63 @@
 }
   }
 
+  // We reorder declarations in RecordDecls because they may have another order
+  // in the "to" context than they have in the "from" context. This may happen
+  // e.g when we import a class like this:
+  //struct declToImport {
+  //int a = c + b;
+  //int b = 1;
+  //int c = 2;
+  //};
+  // During the import of `a` we import first the dependencies in sequence,
+  // thus the order would be `c`, `b`, `a`. We will get the normal order by
+  // first removing the already imported members and then adding them in the
+  // order as they apper in the "from" context.
+  //
+  // Keeping field order is vital because it determines structure layout.
+  //
+  // Here and below, we cannot call field_begin() method and its callers on
+  // ToDC if it has an external storage. Calling field_begin() will
+  // automatically load all the fields by calling
+  // LoadFieldsFromExternalStorage().  LoadFieldsFromExternalStorage() would
+  // call ASTImporter::Import(). This is because the ExternalASTSource
+  // interface in LLDB is implemented by the means of the ASTImporter. However,
+  // calling an import at this point would result in an uncontrolled import, we
+  // must avoid that.
+  const auto *FromRD = dyn_cast(FromDC);
+  if (!FromRD)
+return ChildErrors;
+  auto ToDCOrErr = Importer.ImportContext(FromDC);
+  if (!ToDCOrErr) {
+consumeError(std::move(ChildErrors));
+return ToDCOrErr.takeError();
+  }
+
+  DeclContext *ToDC = *ToDCOrErr;
+  // Remove all declarations, which may be in wrong order in the
+  // lexical DeclContext.
+  llvm::SmallVector ImportedDeclsInOriginalOrder;
+  for (auto *D : FromRD->decls()) {
+if (isa(D) || isa(D)) {
+  assert(D && "DC has a contained decl which is null?");
+  Decl *ToD = Importer.GetAlreadyImportedOrNull(D);
+  // Remove only the decls which we successfully imported.
+  if (ToD) {
+assert(ToDC == ToD->getLexicalDeclContext() && ToDC->containsDecl(ToD));
+ToDC->removeDecl(ToD);
+ImportedDeclsInOriginalOrder.push_back(ToD);
+  }
+}
+  }
+  // At this point we removed only those decls which we have imported from the
+  // FromDC. We  did not remove all the decls of ToDC. And we don't want to
+  // remove any decls which may be loaded from the external storage of ToDC
+  // (these decls are not imported btw).
+
+  // Add the declarations, but this time in the correct order.
+  for (Decl *ToD : ImportedDeclsInOriginalOrder)
+ToDC->addDeclInternal(ToD);
+
   return ChildErrors;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64638: [CrossTU] Fix plist macro expansion if macro in other file.

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

`StaticAnalyzer/Core` does not depend on `clangFrontend` now, you can see this 
by looking at `lib/StaticAnalyzer/Core/CMakeLists.txt`:

  add_clang_library(clangStaticAnalyzerCore
  ...
LINK_LIBS
clangAST
clangASTMatchers
clangAnalysis
clangBasic
clangCrossTU
clangLex
clangRewrite
)

Not a `StaticAnalyzer` expert, so I don't know whether it's acceptable to add 
this dependency to `clangStaticAnalyzerCore`, you'll have to find someone who 
owns the code to know whether this dependency is justified.
(My wild guess from looking at the names of the libraries would be that this 
dependency is not ok and the code should go into `clangStaticAnalyzerFrontend` 
instead. But again, not an expert here, just a guess).

But please add a dependency into `LINK_LIBS` inside `CMakeLists.txt` if you 
start depending on `clangFrontend`.
Most of these violations are found if you build in a `cmake 
-DBUILD_SHARED_LIBS=On` configuration.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64638/new/

https://reviews.llvm.org/D64638



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


[PATCH] D64985: [clangd] Provide a way to publish highlightings in non-racy manner

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for all the suggestions. This is ready for the next round now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64985/new/

https://reviews.llvm.org/D64985



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


[PATCH] D64985: [clangd] Provide a way to publish highlightings in non-racy manner

2019-07-19 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.

Awesome, I think this is in better shape than before highlighting was added.




Comment at: clang-tools-extra/clangd/TUScheduler.h:102
  const CanonicalIncludes &) {}
+  /// The argument function is run under the critical section guarding against
+  /// races when closing the files.

uber-nit: newline before this, as currently it's grouped with onPreambleAST 
rather than onMainAST


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64985/new/

https://reviews.llvm.org/D64985



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


[PATCH] D64985: [clangd] Provide a way to publish highlightings in non-racy manner

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 210808.
ilya-biryukov added a comment.

- Remove a leftover comment from the previous version


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64985/new/

https://reviews.llvm.org/D64985

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -7,10 +7,14 @@
 //===--===//
 
 #include "Annotations.h"
+#include "ClangdUnit.h"
 #include "Context.h"
+#include "Diagnostics.h"
 #include "Matchers.h"
+#include "Path.h"
 #include "TUScheduler.h"
 #include "TestFS.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -56,12 +60,17 @@
   /// in updateWithDiags.
   static std::unique_ptr captureDiags() {
 class CaptureDiags : public ParsingCallbacks {
-  void onDiagnostics(PathRef File, std::vector Diags) override {
+  void onMainAST(PathRef File, ParsedAST , PublishFn Publish) override {
+auto Diags = AST.getDiagnostics();
 auto D = Context::current().get(DiagsCallbackKey);
 if (!D)
   return;
-const_cast)> &> (
-*D)(File, Diags);
+
+Publish([&]() {
+  const_cast<
+  llvm::unique_function)> &> (*D)(
+  File, std::move(Diags));
+});
   }
 };
 return llvm::make_unique();
@@ -116,8 +125,8 @@
   S.update(Added, getInputs(Added, "x"), WantDiagnostics::No);
   EXPECT_EQ(S.getContents(Added), "x");
 
-  // Assert each operation for missing file is an error (even if it's available
-  // in VFS).
+  // Assert each operation for missing file is an error (even if it's
+  // available in VFS).
   S.runWithAST("", Missing,
[&](Expected AST) { EXPECT_ERROR(AST); });
   S.runWithPreamble(
@@ -367,8 +376,8 @@
 StringRef AllContents[] = {Contents1, Contents2, Contents3};
 const int AllContentsSize = 3;
 
-// Scheduler may run tasks asynchronously, but should propagate the context.
-// We stash a nonce in the context, and verify it in the task.
+// Scheduler may run tasks asynchronously, but should propagate the
+// context. We stash a nonce in the context, and verify it in the task.
 static Key NonceKey;
 int Nonce = 0;
 
@@ -465,8 +474,8 @@
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_EQ(BuiltASTCounter.load(), 1);
 
-  // Build two more files. Since we can retain only 2 ASTs, these should be the
-  // ones we see in the cache later.
+  // Build two more files. Since we can retain only 2 ASTs, these should be
+  // the ones we see in the cache later.
   updateWithCallback(S, Bar, SourceContents, WantDiagnostics::Yes,
  []() { ++BuiltASTCounter; });
   updateWithCallback(S, Baz, SourceContents, WantDiagnostics::Yes,
Index: clang-tools-extra/clangd/TUScheduler.h
===
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -15,6 +15,7 @@
 #include "Threading.h"
 #include "index/CanonicalIncludes.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -98,6 +99,10 @@
   virtual void onPreambleAST(PathRef Path, ASTContext ,
  std::shared_ptr PP,
  const CanonicalIncludes &) {}
+  /// The argument function is run under the critical section guarding against
+  /// races when closing the files.
+  using PublishFn = llvm::function_ref)>;
+
   /// Called on the AST built for the file itself. Note that preamble AST nodes
   /// are not deserialized and should be processed in the onPreambleAST call
   /// instead.
@@ -108,10 +113,17 @@
   /// etc. Clients are expected to process only the AST nodes from the main file
   /// in this callback (obtained via ParsedAST::getLocalTopLevelDecls) to obtain
   /// optimal performance.
-  virtual void onMainAST(PathRef Path, ParsedAST ) {}
-
-  /// Called whenever the diagnostics for \p File are produced.
-  virtual void onDiagnostics(PathRef File, std::vector Diags) {}
+  ///
+  /// When information about the file (diagnostics, syntax highlighting) is
+  /// published to clients, this should be wrapped in Publish, e.g.
+  ///   void onMainAST(...) {
+  /// Highlights = computeHighlights();
+  /// Publish([&] { notifyHighlights(Path, Highlights); });
+  ///   }
+  /// This guarantees that clients will see results in the correct sequence if
+  

[PATCH] D64985: [clangd] Provide a way to publish highlightings in non-racy manner

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 210807.
ilya-biryukov added a comment.

- Update usage of DiagsMu in a comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64985/new/

https://reviews.llvm.org/D64985

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -7,10 +7,14 @@
 //===--===//
 
 #include "Annotations.h"
+#include "ClangdUnit.h"
 #include "Context.h"
+#include "Diagnostics.h"
 #include "Matchers.h"
+#include "Path.h"
 #include "TUScheduler.h"
 #include "TestFS.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -56,12 +60,17 @@
   /// in updateWithDiags.
   static std::unique_ptr captureDiags() {
 class CaptureDiags : public ParsingCallbacks {
-  void onDiagnostics(PathRef File, std::vector Diags) override {
+  void onMainAST(PathRef File, ParsedAST , PublishFn Publish) override {
+auto Diags = AST.getDiagnostics();
 auto D = Context::current().get(DiagsCallbackKey);
 if (!D)
   return;
-const_cast)> &> (
-*D)(File, Diags);
+
+Publish([&]() {
+  const_cast<
+  llvm::unique_function)> &> (*D)(
+  File, std::move(Diags));
+});
   }
 };
 return llvm::make_unique();
@@ -116,8 +125,8 @@
   S.update(Added, getInputs(Added, "x"), WantDiagnostics::No);
   EXPECT_EQ(S.getContents(Added), "x");
 
-  // Assert each operation for missing file is an error (even if it's available
-  // in VFS).
+  // Assert each operation for missing file is an error (even if it's
+  // available in VFS).
   S.runWithAST("", Missing,
[&](Expected AST) { EXPECT_ERROR(AST); });
   S.runWithPreamble(
@@ -367,8 +376,8 @@
 StringRef AllContents[] = {Contents1, Contents2, Contents3};
 const int AllContentsSize = 3;
 
-// Scheduler may run tasks asynchronously, but should propagate the context.
-// We stash a nonce in the context, and verify it in the task.
+// Scheduler may run tasks asynchronously, but should propagate the
+// context. We stash a nonce in the context, and verify it in the task.
 static Key NonceKey;
 int Nonce = 0;
 
@@ -465,8 +474,8 @@
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_EQ(BuiltASTCounter.load(), 1);
 
-  // Build two more files. Since we can retain only 2 ASTs, these should be the
-  // ones we see in the cache later.
+  // Build two more files. Since we can retain only 2 ASTs, these should be
+  // the ones we see in the cache later.
   updateWithCallback(S, Bar, SourceContents, WantDiagnostics::Yes,
  []() { ++BuiltASTCounter; });
   updateWithCallback(S, Baz, SourceContents, WantDiagnostics::Yes,
Index: clang-tools-extra/clangd/TUScheduler.h
===
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -15,6 +15,7 @@
 #include "Threading.h"
 #include "index/CanonicalIncludes.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -98,6 +99,10 @@
   virtual void onPreambleAST(PathRef Path, ASTContext ,
  std::shared_ptr PP,
  const CanonicalIncludes &) {}
+  /// The argument function is run under the critical section guarding against
+  /// races when closing the files.
+  using PublishFn = llvm::function_ref)>;
+
   /// Called on the AST built for the file itself. Note that preamble AST nodes
   /// are not deserialized and should be processed in the onPreambleAST call
   /// instead.
@@ -108,10 +113,17 @@
   /// etc. Clients are expected to process only the AST nodes from the main file
   /// in this callback (obtained via ParsedAST::getLocalTopLevelDecls) to obtain
   /// optimal performance.
-  virtual void onMainAST(PathRef Path, ParsedAST ) {}
-
-  /// Called whenever the diagnostics for \p File are produced.
-  virtual void onDiagnostics(PathRef File, std::vector Diags) {}
+  ///
+  /// When information about the file (diagnostics, syntax highlighting) is
+  /// published to clients, this should be wrapped in Publish, e.g.
+  ///   void onMainAST(...) {
+  /// Highlights = computeHighlights();
+  /// Publish([&] { notifyHighlights(Path, Highlights); });
+  ///   }
+  /// This guarantees that clients will see results in the correct sequence if
+  /// the file 

[PATCH] D60456: [RISCV] Hard float ABI support

2019-07-19 Thread Alex Bradbury via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL366450: [RISCV] Hard float ABI support (authored by asb, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60456?vs=208477=210586#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60456/new/

https://reviews.llvm.org/D60456

Files:
  cfe/trunk/lib/Basic/Targets/RISCV.cpp
  cfe/trunk/lib/Basic/Targets/RISCV.h
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGen/riscv32-ilp32-ilp32f-abi.c
  cfe/trunk/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c
  cfe/trunk/test/CodeGen/riscv32-ilp32d-abi.c
  cfe/trunk/test/CodeGen/riscv32-ilp32f-abi.c
  cfe/trunk/test/CodeGen/riscv32-ilp32f-ilp32d-abi.c
  cfe/trunk/test/CodeGen/riscv64-lp64-lp64f-abi.c
  cfe/trunk/test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c
  cfe/trunk/test/CodeGen/riscv64-lp64d-abi.c
  cfe/trunk/test/CodeGen/riscv64-lp64f-lp64d-abi.c
  cfe/trunk/test/Preprocessor/riscv-target-features.c

Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -9188,25 +9188,44 @@
 namespace {
 class RISCVABIInfo : public DefaultABIInfo {
 private:
-  unsigned XLen; // Size of the integer ('x') registers in bits.
+  // Size of the integer ('x') registers in bits.
+  unsigned XLen;
+  // Size of the floating point ('f') registers in bits. Note that the target
+  // ISA might have a wider FLen than the selected ABI (e.g. an RV32IF target
+  // with soft float ABI has FLen==0).
+  unsigned FLen;
   static const int NumArgGPRs = 8;
+  static const int NumArgFPRs = 8;
+  bool detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff,
+  llvm::Type *,
+  CharUnits ,
+  llvm::Type *,
+  CharUnits ) const;
 
 public:
-  RISCVABIInfo(CodeGen::CodeGenTypes , unsigned XLen)
-  : DefaultABIInfo(CGT), XLen(XLen) {}
+  RISCVABIInfo(CodeGen::CodeGenTypes , unsigned XLen, unsigned FLen)
+  : DefaultABIInfo(CGT), XLen(XLen), FLen(FLen) {}
 
   // DefaultABIInfo's classifyReturnType and classifyArgumentType are
   // non-virtual, but computeInfo is virtual, so we overload it.
   void computeInfo(CGFunctionInfo ) const override;
 
-  ABIArgInfo classifyArgumentType(QualType Ty, bool IsFixed,
-  int ) const;
+  ABIArgInfo classifyArgumentType(QualType Ty, bool IsFixed, int ,
+  int ) const;
   ABIArgInfo classifyReturnType(QualType RetTy) const;
 
   Address EmitVAArg(CodeGenFunction , Address VAListAddr,
 QualType Ty) const override;
 
   ABIArgInfo extendType(QualType Ty) const;
+
+  bool detectFPCCEligibleStruct(QualType Ty, llvm::Type *, CharUnits ,
+llvm::Type *, CharUnits ,
+int , int ) const;
+  ABIArgInfo coerceAndExpandFPCCEligibleStruct(llvm::Type *Field1Ty,
+   CharUnits Field1Off,
+   llvm::Type *Field2Ty,
+   CharUnits Field2Off) const;
 };
 } // end anonymous namespace
 
@@ -9228,18 +9247,214 @@
   // different for variadic arguments, we must also track whether we are
   // examining a vararg or not.
   int ArgGPRsLeft = IsRetIndirect ? NumArgGPRs - 1 : NumArgGPRs;
+  int ArgFPRsLeft = FLen ? NumArgFPRs : 0;
   int NumFixedArgs = FI.getNumRequiredArgs();
 
   int ArgNum = 0;
   for (auto  : FI.arguments()) {
 bool IsFixed = ArgNum < NumFixedArgs;
-ArgInfo.info = classifyArgumentType(ArgInfo.type, IsFixed, ArgGPRsLeft);
+ArgInfo.info =
+classifyArgumentType(ArgInfo.type, IsFixed, ArgGPRsLeft, ArgFPRsLeft);
 ArgNum++;
   }
 }
 
+// Returns true if the struct is a potential candidate for the floating point
+// calling convention. If this function returns true, the caller is
+// responsible for checking that if there is only a single field then that
+// field is a float.
+bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff,
+  llvm::Type *,
+  CharUnits ,
+  llvm::Type *,
+  CharUnits ) const {
+  bool IsInt = Ty->isIntegralOrEnumerationType();
+  bool IsFloat = Ty->isRealFloatingType();
+
+  if (IsInt || IsFloat) {
+uint64_t Size = getContext().getTypeSize(Ty);
+if (IsInt && Size > XLen)
+  return false;
+// Can't be eligible if larger than the FP registers. Half precision isn't
+// currently supported on RISC-V and the ABI hasn't 

[PATCH] D64985: [clangd] Provide a way to publish highlightings in non-racy manner

2019-07-19 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 210805.
ilya-biryukov added a comment.

- Use the same mechanism for diagnostics
- Change typedef to function)>
- Update a comment
- s/PublishResults/PublishFn
- Reformat


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64985/new/

https://reviews.llvm.org/D64985

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -7,10 +7,14 @@
 //===--===//
 
 #include "Annotations.h"
+#include "ClangdUnit.h"
 #include "Context.h"
+#include "Diagnostics.h"
 #include "Matchers.h"
+#include "Path.h"
 #include "TUScheduler.h"
 #include "TestFS.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -56,12 +60,17 @@
   /// in updateWithDiags.
   static std::unique_ptr captureDiags() {
 class CaptureDiags : public ParsingCallbacks {
-  void onDiagnostics(PathRef File, std::vector Diags) override {
+  void onMainAST(PathRef File, ParsedAST , PublishFn Publish) override {
+auto Diags = AST.getDiagnostics();
 auto D = Context::current().get(DiagsCallbackKey);
 if (!D)
   return;
-const_cast)> &> (
-*D)(File, Diags);
+
+Publish([&]() {
+  const_cast<
+  llvm::unique_function)> &> (*D)(
+  File, std::move(Diags));
+});
   }
 };
 return llvm::make_unique();
@@ -116,8 +125,8 @@
   S.update(Added, getInputs(Added, "x"), WantDiagnostics::No);
   EXPECT_EQ(S.getContents(Added), "x");
 
-  // Assert each operation for missing file is an error (even if it's available
-  // in VFS).
+  // Assert each operation for missing file is an error (even if it's
+  // available in VFS).
   S.runWithAST("", Missing,
[&](Expected AST) { EXPECT_ERROR(AST); });
   S.runWithPreamble(
@@ -367,8 +376,8 @@
 StringRef AllContents[] = {Contents1, Contents2, Contents3};
 const int AllContentsSize = 3;
 
-// Scheduler may run tasks asynchronously, but should propagate the context.
-// We stash a nonce in the context, and verify it in the task.
+// Scheduler may run tasks asynchronously, but should propagate the
+// context. We stash a nonce in the context, and verify it in the task.
 static Key NonceKey;
 int Nonce = 0;
 
@@ -465,8 +474,8 @@
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   ASSERT_EQ(BuiltASTCounter.load(), 1);
 
-  // Build two more files. Since we can retain only 2 ASTs, these should be the
-  // ones we see in the cache later.
+  // Build two more files. Since we can retain only 2 ASTs, these should be
+  // the ones we see in the cache later.
   updateWithCallback(S, Bar, SourceContents, WantDiagnostics::Yes,
  []() { ++BuiltASTCounter; });
   updateWithCallback(S, Baz, SourceContents, WantDiagnostics::Yes,
Index: clang-tools-extra/clangd/TUScheduler.h
===
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -15,6 +15,7 @@
 #include "Threading.h"
 #include "index/CanonicalIncludes.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -98,6 +99,10 @@
   virtual void onPreambleAST(PathRef Path, ASTContext ,
  std::shared_ptr PP,
  const CanonicalIncludes &) {}
+  /// The argument function is run under the critical section guarding against
+  /// races when closing the files.
+  using PublishFn = llvm::function_ref)>;
+
   /// Called on the AST built for the file itself. Note that preamble AST nodes
   /// are not deserialized and should be processed in the onPreambleAST call
   /// instead.
@@ -108,10 +113,17 @@
   /// etc. Clients are expected to process only the AST nodes from the main file
   /// in this callback (obtained via ParsedAST::getLocalTopLevelDecls) to obtain
   /// optimal performance.
-  virtual void onMainAST(PathRef Path, ParsedAST ) {}
-
-  /// Called whenever the diagnostics for \p File are produced.
-  virtual void onDiagnostics(PathRef File, std::vector Diags) {}
+  ///
+  /// When information about the file (diagnostics, syntax highlighting) is
+  /// published to clients, this should be wrapped in Publish, e.g.
+  ///   void onMainAST(...) {
+  /// Highlights = computeHighlights();
+  /// Publish([&] { notifyHighlights(Path, Highlights); });
+  ///   }
+  

[PATCH] D64914: Implement P1771

2019-07-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2833-2835
   if (D->getFunctionType() &&
-  D->getFunctionType()->getReturnType()->isVoidType()) {
+  D->getFunctionType()->getReturnType()->isVoidType() &&
+  !isa(D)) {

erichkeane wrote:
> aaron.ballman wrote:
> > erichkeane wrote:
> > > aaron.ballman wrote:
> > > > I'm not certain about this -- we do not allow you to put 
> > > > `__attribute__((warn_unused_result))` on a constructor declaration, and 
> > > > neither does GCC. Do you know if they're planning to change their 
> > > > behavior as well? https://godbolt.org/z/kDZu3Q
> > > I'm unsure about GCC's intent, though they will likely be changing the 
> > > [[nodiscard]] behavior due to the vote (and I doubt they will have an "if 
> > > C++20" test either.  
> > > 
> > > Do we have a good way to exclude the alternate spellings?  
> > > isCXX11Attribute only checks syntax, not the actual spelling.  ParsedAttr 
> > > doesn't seem to even contain a way to get which namespace it is 
> > > associated with either.  Is something like that valuable to add?
> > The way we currently do this is `(isCXX11Attribute() || isC2xAttribute()) 
> > && !getScopeName()`, but I am not opposed to going with an additional 
> > member. Do you have a preference either way?
> An additional member of Spelling-Kind (vs Syntax kind) seems very valuable 
> here, though I wonder if it is valuable enough of a change for TableGen.  The 
> isCXX11Attribute && !getScopeName seems a little obtuse from a readers 
> perspective.
Yeah, I would love to solve this through the tablegen interface at some point, 
as that solves other problems we have (like the fact that we don't AST dump 
with the syntax the user wrote). Let's hold off on that for now and use the 
obtuse approach, but with a FIXME for us to come back and touch it again once 
we get tablegen to track more syntactic information along with the semantic 
attribute object.



Comment at: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp:87-88
 // expected-warning@28 {{use of the 'nodiscard' attribute is a C++17 
extension}}
+// expected-warning@66 {{use of the 'nodiscard' attribute is a C++17 
extension}}
+// expected-warning@71 {{use of the 'nodiscard' attribute is a C++17 
extension}}
 #endif

erichkeane wrote:
> aaron.ballman wrote:
> > Is Core treating this paper as a DR? I don't have a strong opinion here, 
> > but for the nodiscard with a message version, I made it a C++2a extension. 
> > I don't have a strong opinion, but I sort of prefer doing whatever Core 
> > decides.
> I am unfamiliar with what Core is treating it as, but my understanding is 
> that EWG encouraged implementers to treat it as such.  
We expose the attribute in all its glory in all language modes, so these 
changes already do what we want in effect. The only real question is whether we 
want to claim it's a C++17 extension or a C++2a extension. If a user turns on 
extension warnings, we should probably tell them when the feature was added, 
which is C++2a. It would be a bit weird to claim this is a C++17 when the 
feature test for it is `__has_attribute(nodiscard) == 201907L` (due to the 
normative wording changes).

But if Core moves it as a DR, then C++17 is fine, though I suppose SD-6 would 
need to make clear what is required for each given attribute feature test value 
to give us the answer.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64914/new/

https://reviews.llvm.org/D64914



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


[PATCH] D64717: [Clangd] Fixed ExtractVariable for MemberExprs and Assignment Exprs

2019-07-19 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah added inline comments.



Comment at: clang-tools-extra/clangd/unittests/TweakTests.cpp:427
R"cpp(void f(int a) {
 auto dummy = 1; label: [ [gsl::suppress("type")] ] for 
(;;) a = dummy;
  })cpp"},

kadircet wrote:
> I think `auto dummy = 1;` should be within the label. otherwise we might 
> break codes like(which is basically anything with labels):
> ```
> void foo() {
> goto label;
> label:
>  a = 1;
> }
> ```
> 
> I don't think it is that important though, and have no idea about the effort 
> necessary feel free to just add a FIXME if it turns out hard.
I've disabled extraction from label statements and added a fixme because the 
fix for all kinds of loops as well as if statement needs another patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64717/new/

https://reviews.llvm.org/D64717



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


[PATCH] D64914: Implement P1771

2019-07-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

I'll need to rebase this on another patch soon anyway, so I'll hold off until 
next week to update this particularly since we have some open questions.  The 
additional TableGen work is tempting to do, though I'm not completely sure 
it'll get more than just this use.

I'd also like to see how this paper goes through CWG and see what the general 
attitude is there.




Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2833-2835
   if (D->getFunctionType() &&
-  D->getFunctionType()->getReturnType()->isVoidType()) {
+  D->getFunctionType()->getReturnType()->isVoidType() &&
+  !isa(D)) {

aaron.ballman wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > I'm not certain about this -- we do not allow you to put 
> > > `__attribute__((warn_unused_result))` on a constructor declaration, and 
> > > neither does GCC. Do you know if they're planning to change their 
> > > behavior as well? https://godbolt.org/z/kDZu3Q
> > I'm unsure about GCC's intent, though they will likely be changing the 
> > [[nodiscard]] behavior due to the vote (and I doubt they will have an "if 
> > C++20" test either.  
> > 
> > Do we have a good way to exclude the alternate spellings?  isCXX11Attribute 
> > only checks syntax, not the actual spelling.  ParsedAttr doesn't seem to 
> > even contain a way to get which namespace it is associated with either.  Is 
> > something like that valuable to add?
> The way we currently do this is `(isCXX11Attribute() || isC2xAttribute()) && 
> !getScopeName()`, but I am not opposed to going with an additional member. Do 
> you have a preference either way?
An additional member of Spelling-Kind (vs Syntax kind) seems very valuable 
here, though I wonder if it is valuable enough of a change for TableGen.  The 
isCXX11Attribute && !getScopeName seems a little obtuse from a readers 
perspective.



Comment at: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp:87-88
 // expected-warning@28 {{use of the 'nodiscard' attribute is a C++17 
extension}}
+// expected-warning@66 {{use of the 'nodiscard' attribute is a C++17 
extension}}
+// expected-warning@71 {{use of the 'nodiscard' attribute is a C++17 
extension}}
 #endif

aaron.ballman wrote:
> Is Core treating this paper as a DR? I don't have a strong opinion here, but 
> for the nodiscard with a message version, I made it a C++2a extension. I 
> don't have a strong opinion, but I sort of prefer doing whatever Core decides.
I am unfamiliar with what Core is treating it as, but my understanding is that 
EWG encouraged implementers to treat it as such.  


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64914/new/

https://reviews.llvm.org/D64914



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


[PATCH] D64717: [Clangd] Fixed ExtractVariable for MemberExprs and Assignment Exprs

2019-07-19 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah updated this revision to Diff 210803.
SureYeaah marked an inline comment as done.
SureYeaah added a comment.

Added test for label


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64717/new/

https://reviews.llvm.org/D64717

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -291,18 +291,23 @@
   const char *Input = "struct ^X { int x; int y; }";
   EXPECT_THAT(getMessage(ID, Input), ::testing::HasSubstr("0 |   int x"));
 }
+
 TEST(TweakTest, ExtractVariable) {
   llvm::StringLiteral ID = "ExtractVariable";
   checkAvailable(ID, R"cpp(
-int xyz() {
+int xyz(int a = 1) {
+  struct T {
+int bar(int a = 1);
+int z;
+  } t;
   // return statement
-  return [[1]];
+  return t.b[[a]]r]](t.z)]];
 }
 void f() {
   int a = [[5 +]] [[4 * xyz]]();
   // multivariable initialization
   if(1)
-int x = [[1]], y = [[a]] + 1, a = [[1]], z = a + 1;
+int x = [[1]], y = [[a + 1]], a = [[1]], z = a + 1;
   // if without else
   if([[1]])
 a = [[1]];
@@ -316,13 +321,13 @@
 a = [[4]];
   else
 a = [[5]];
-  // for loop 
+  // for loop
   for(a = [[1]]; a > 3]] + [[4; a++)
 a = [[2]];
-  // while 
+  // while
   while(a < [[1]])
-[[a]]++;
-  // do while 
+[[a++]];
+  // do while
   do
 a = [[1]];
   while(a < [[3]]);
@@ -332,18 +337,19 @@
   checkNotAvailable(ID, R"cpp(
 template
 struct Test {
-Test(const T ) :val(^) {}
+Test(const T ) :val[[(^]]) {}
   T val;
 };
   )cpp");
   checkNotAvailable(ID, R"cpp(
 int xyz(int a = [[1]]) {
-  return 1;
-  class T {
-T(int a = [[1]]) {};
-int xyz = [[1]];
-  };
+  struct T {
+int bar(int a = [[1]]);
+int z = [[1]];
+  } t;
+  return [[t]].bar(t]].z]]);
 }
+void v() { return; }
 // function default argument
 void f(int b = [[1]]) {
   // empty selection
@@ -351,17 +357,26 @@
   // void expressions
   auto i = new int, j = new int;
   delete i]], delete j]];
+  [[v]]();
   // if
   if(1)
 int x = 1, y = a + 1, a = 1, z = [[a + 1]];
   if(int a = 1)
-if([[a]] == 4)
+if([[a + 1]] == 4)
   a = a]] +]] 1;
-  // for loop 
-  for(int a = 1, b = 2, c = 3; [[a]] > [[b + c]]; [[a]]++)
+  // for loop
+  for(int a = 1, b = 2, c = 3; a > [[b + c]]; [[a++]])
 a = [[a + 1]];
-  // lambda 
+  // lambda
   auto lamb = [&[[a]], &[[b]]](int r = [[1]]) {return 1;}
+  // assigment
+  [[a = 5]];
+  // Variable DeclRefExpr
+  a = [[b]];
+  // label statement
+  goto label;
+  label:
+a = [[1]];
 }
   )cpp");
   // vector of pairs of input and output strings
@@ -408,12 +423,30 @@
auto dummy = 3; if(1)
 LOOP(5 + dummy)
  })cpp"},
-  // label and attribute testing
+  // attribute testing
   {R"cpp(void f(int a) {
-label: [ [gsl::suppress("type")] ] for (;;) a = [[1]];
+[ [gsl::suppress("type")] ] for (;;) a = [[1]];
  })cpp",
R"cpp(void f(int a) {
-auto dummy = 1; label: [ [gsl::suppress("type")] ] for (;;) a = dummy;
+auto dummy = 1; [ [gsl::suppress("type")] ] for (;;) a = dummy;
+ })cpp"},
+  // MemberExpr
+  {R"cpp(class T {
+   T f() {
+ return [[T().f()]].f();
+   }
+ };)cpp",
+   R"cpp(class T {
+   T f() {
+ auto dummy = T().f(); return dummy.f();
+   }
+ };)cpp"},
+  // Function DeclRefExpr
+  {R"cpp(int f() {
+   return [[f]]();
+ })cpp",
+   R"cpp(int f() {
+   auto dummy = f(); return dummy;
  })cpp"},
   // FIXME: Doesn't work because bug in selection tree
   /*{R"cpp(#define PLUS(x) x++
@@ -424,9 +457,9 @@
  void f(int a) {
auto dummy = a; PLUS(dummy);
  })cpp"},*/
-  // FIXME: Doesn't work correctly for \[\[clang::uninitialized\]\] int
-  // b = [[1]]; since the attr is inside the DeclStmt and the bounds of
-  // DeclStmt don't cover the attribute
+  // FIXME: Wrong result for \[\[clang::uninitialized\]\] int b = [[1]];
+  // since the attr 

[clang-tools-extra] r366568 - [Clangd] Fixed ExtractVariable test

2019-07-19 Thread Shaurya Gupta via cfe-commits
Author: sureyeaah
Date: Fri Jul 19 05:11:04 2019
New Revision: 366568

URL: http://llvm.org/viewvc/llvm-project?rev=366568=rev
Log:
[Clangd] Fixed ExtractVariable test

Modified:
clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp?rev=366568=366567=366568=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp Fri Jul 19 05:11:04 
2019
@@ -398,17 +398,23 @@ TEST(TweakTest, ExtractVariable) {
}
  })cpp"},*/
   // ensure InsertionPoint isn't inside a macro
-  // FIXME: SelectionTree needs to be fixed for macros
-  /*{R"cpp(#define LOOP(x) while (1) {a = x;}
+  {R"cpp(#define LOOP(x) while (1) {a = x;}
  void f(int a) {
if(1)
 LOOP(5 + [[3]])
  })cpp",
- R"cpp(#define LOOP(x) while (1) {a = x;}
+   /*FIXME: It should be extracted like this. SelectionTree needs to be
+* fixed for macros.
+ R"cpp(#define LOOP(x) while (1) {a = x;}
+   void f(int a) {
+ auto dummy = 3; if(1)
+  LOOP(5 + dummy)
+   })cpp"},*/
+   R"cpp(#define LOOP(x) while (1) {a = x;}
  void f(int a) {
-   auto dummy = 3; if(1)
-LOOP(5 + dummy)
- })cpp"},*/
+   auto dummy = LOOP(5 + 3); if(1)
+dummy
+ })cpp"},
   {R"cpp(#define LOOP(x) do {x;} while(1);
  void f(int a) {
if(1)
@@ -426,15 +432,15 @@ TEST(TweakTest, ExtractVariable) {
R"cpp(void f(int a) {
 auto dummy = 1; label: [ [gsl::suppress("type")] ] for 
(;;) a = dummy;
  })cpp"},
-  // FIXME: Doesn't work because bug in selection tree
-  /*{R"cpp(#define PLUS(x) x++
+  // macro testing
+  {R"cpp(#define PLUS(x) x++
  void f(int a) {
PLUS([[a]]);
  })cpp",
R"cpp(#define PLUS(x) x++
  void f(int a) {
auto dummy = a; PLUS(dummy);
- })cpp"},*/
+ })cpp"},
   // FIXME: Doesn't work correctly for \[\[clang::uninitialized\]\] int
   // b = [[1]]; since the attr is inside the DeclStmt and the bounds of
   // DeclStmt don't cover the attribute


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


[PATCH] D64914: Implement P1771

2019-07-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2346
+// spellings.
+bool IsCXX11NoDiscard() const {
+  return this->getSemanticSpelling() == CXX11_nodiscard;

I don't think this is strictly required, but perhaps it's not a bad idea.



Comment at: clang/include/clang/Basic/AttrDocs.td:1499
+marked with ``[[nodiscard]]`` or a constructor of a type marked
+``[[nodiscard]]`` will also diagnose.
+

We should probably also talk about type conversions as well.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:2833-2835
   if (D->getFunctionType() &&
-  D->getFunctionType()->getReturnType()->isVoidType()) {
+  D->getFunctionType()->getReturnType()->isVoidType() &&
+  !isa(D)) {

erichkeane wrote:
> aaron.ballman wrote:
> > I'm not certain about this -- we do not allow you to put 
> > `__attribute__((warn_unused_result))` on a constructor declaration, and 
> > neither does GCC. Do you know if they're planning to change their behavior 
> > as well? https://godbolt.org/z/kDZu3Q
> I'm unsure about GCC's intent, though they will likely be changing the 
> [[nodiscard]] behavior due to the vote (and I doubt they will have an "if 
> C++20" test either.  
> 
> Do we have a good way to exclude the alternate spellings?  isCXX11Attribute 
> only checks syntax, not the actual spelling.  ParsedAttr doesn't seem to even 
> contain a way to get which namespace it is associated with either.  Is 
> something like that valuable to add?
The way we currently do this is `(isCXX11Attribute() || isC2xAttribute()) && 
!getScopeName()`, but I am not opposed to going with an additional member. Do 
you have a preference either way?



Comment at: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp:69
+[[gnu::warn_unused_result]] S(double);
+  };
+

I think this also needs tests for type conversions, from d1771r1.



Comment at: clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp:87-88
 // expected-warning@28 {{use of the 'nodiscard' attribute is a C++17 
extension}}
+// expected-warning@66 {{use of the 'nodiscard' attribute is a C++17 
extension}}
+// expected-warning@71 {{use of the 'nodiscard' attribute is a C++17 
extension}}
 #endif

Is Core treating this paper as a DR? I don't have a strong opinion here, but 
for the nodiscard with a message version, I made it a C++2a extension. I don't 
have a strong opinion, but I sort of prefer doing whatever Core decides.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64914/new/

https://reviews.llvm.org/D64914



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


[PATCH] D64416: [AArch64] Add support for Transactional Memory Extension (TME)

2019-07-19 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added inline comments.



Comment at: clang/test/Sema/aarch64-tme-errors.c:1
+// RUN: %clang_cc1 -triple aarch64-eabi -verify %s
+

I don't think the Sema checks need to be split over so many files. One for the 
whole of transactional seems enough. Similarly for CodeGen really.



Comment at: llvm/test/CodeGen/AArch64/tme-tcancel.ll:6
+define void @test_tcancel() #0 {
+  tail call void @llvm.aarch64.tcancel(i64 0) #1
+  ret void

Testing more values than 0 would be a good idea.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64416/new/

https://reviews.llvm.org/D64416



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


[PATCH] D64775: [Format/ObjC] Avoid breaking between unary operators and ObjC method invocations

2019-07-19 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.

Yeah, worst case we'll need to roll this back and go with the targeted fix, but 
I don't see a problem.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64775/new/

https://reviews.llvm.org/D64775



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


[PATCH] D64717: [Clangd] Fixed ExtractVariable for MemberExprs and Assignment Exprs

2019-07-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM from my side. Do you have any concerns @sammccall ?




Comment at: clang-tools-extra/clangd/unittests/TweakTests.cpp:427
R"cpp(void f(int a) {
 auto dummy = 1; label: [ [gsl::suppress("type")] ] for 
(;;) a = dummy;
  })cpp"},

kadircet wrote:
> I think `auto dummy = 1;` should be within the label. otherwise we might 
> break codes like(which is basically anything with labels):
> ```
> void foo() {
> goto label;
> label:
>  a = 1;
> }
> ```
> 
> I don't think it is that important though, and have no idea about the effort 
> necessary feel free to just add a FIXME if it turns out hard.
could you keep the previous test case within a `checkNotAvailable` block ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64717/new/

https://reviews.llvm.org/D64717



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


[PATCH] D64717: [Clangd] Fixed ExtractVariable for MemberExprs and Assignment Exprs

2019-07-19 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah updated this revision to Diff 210800.
SureYeaah marked 5 inline comments as done.
SureYeaah added a comment.

Minor changes and disabled extraction from label statement


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64717/new/

https://reviews.llvm.org/D64717

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -291,18 +291,23 @@
   const char *Input = "struct ^X { int x; int y; }";
   EXPECT_THAT(getMessage(ID, Input), ::testing::HasSubstr("0 |   int x"));
 }
+
 TEST(TweakTest, ExtractVariable) {
   llvm::StringLiteral ID = "ExtractVariable";
   checkAvailable(ID, R"cpp(
-int xyz() {
+int xyz(int a = 1) {
+  struct T {
+int bar(int a = 1);
+int z;
+  } t;
   // return statement
-  return [[1]];
+  return t.b[[a]]r]](t.z)]];
 }
 void f() {
   int a = [[5 +]] [[4 * xyz]]();
   // multivariable initialization
   if(1)
-int x = [[1]], y = [[a]] + 1, a = [[1]], z = a + 1;
+int x = [[1]], y = [[a + 1]], a = [[1]], z = a + 1;
   // if without else
   if([[1]])
 a = [[1]];
@@ -316,13 +321,13 @@
 a = [[4]];
   else
 a = [[5]];
-  // for loop 
+  // for loop
   for(a = [[1]]; a > 3]] + [[4; a++)
 a = [[2]];
-  // while 
+  // while
   while(a < [[1]])
-[[a]]++;
-  // do while 
+[[a++]];
+  // do while
   do
 a = [[1]];
   while(a < [[3]]);
@@ -332,18 +337,19 @@
   checkNotAvailable(ID, R"cpp(
 template
 struct Test {
-Test(const T ) :val(^) {}
+Test(const T ) :val[[(^]]) {}
   T val;
 };
   )cpp");
   checkNotAvailable(ID, R"cpp(
 int xyz(int a = [[1]]) {
-  return 1;
-  class T {
-T(int a = [[1]]) {};
-int xyz = [[1]];
-  };
+  struct T {
+int bar(int a = [[1]]);
+int z = [[1]];
+  } t;
+  return [[t]].bar(t]].z]]);
 }
+void v() { return; }
 // function default argument
 void f(int b = [[1]]) {
   // empty selection
@@ -351,17 +357,22 @@
   // void expressions
   auto i = new int, j = new int;
   delete i]], delete j]];
+  [[v]]();
   // if
   if(1)
 int x = 1, y = a + 1, a = 1, z = [[a + 1]];
   if(int a = 1)
-if([[a]] == 4)
+if([[a + 1]] == 4)
   a = a]] +]] 1;
-  // for loop 
-  for(int a = 1, b = 2, c = 3; [[a]] > [[b + c]]; [[a]]++)
+  // for loop
+  for(int a = 1, b = 2, c = 3; a > [[b + c]]; [[a++]])
 a = [[a + 1]];
-  // lambda 
+  // lambda
   auto lamb = [&[[a]], &[[b]]](int r = [[1]]) {return 1;}
+  // assigment
+  [[a = 5]];
+  // Variable DeclRefExpr
+  a = [[b]];
 }
   )cpp");
   // vector of pairs of input and output strings
@@ -408,12 +419,30 @@
auto dummy = 3; if(1)
 LOOP(5 + dummy)
  })cpp"},
-  // label and attribute testing
+  // attribute testing
   {R"cpp(void f(int a) {
-label: [ [gsl::suppress("type")] ] for (;;) a = [[1]];
+[ [gsl::suppress("type")] ] for (;;) a = [[1]];
  })cpp",
R"cpp(void f(int a) {
-auto dummy = 1; label: [ [gsl::suppress("type")] ] for (;;) a = dummy;
+auto dummy = 1; [ [gsl::suppress("type")] ] for (;;) a = dummy;
+ })cpp"},
+  // MemberExpr
+  {R"cpp(class T {
+   T f() {
+ return [[T().f()]].f();
+   }
+ };)cpp",
+   R"cpp(class T {
+   T f() {
+ auto dummy = T().f(); return dummy.f();
+   }
+ };)cpp"},
+  // Function DeclRefExpr
+  {R"cpp(int f() {
+   return [[f]]();
+ })cpp",
+   R"cpp(int f() {
+   auto dummy = f(); return dummy;
  })cpp"},
   // FIXME: Doesn't work because bug in selection tree
   /*{R"cpp(#define PLUS(x) x++
@@ -424,9 +453,9 @@
  void f(int a) {
auto dummy = a; PLUS(dummy);
  })cpp"},*/
-  // FIXME: Doesn't work correctly for \[\[clang::uninitialized\]\] int
-  // b = [[1]]; since the attr is inside the DeclStmt and the bounds of
-  // DeclStmt don't cover the attribute
+  // FIXME: Wrong result for \[\[clang::uninitialized\]\] int b = [[1]];
+  // since the attr is inside the DeclStmt and the bounds of

  1   2   >