[PATCH] D61508: [clang-tidy] misc-header-guard : a simple version of llvm-header-guard

2019-05-06 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Hi trixirt and thanks for the patch!

I would rather like to generalize the llvm check to allow different styles and 
then alias the general version with different configurations. Introducing this 
code duplication does not sound like a good idea to me.
The documentation fixes you make can be done in a separate patch to keep things 
clean.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61508



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


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-05-06 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

@probinson @aprantl Thanks!

@vsk Thanks for the comment! Sure, we will add that.


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

https://reviews.llvm.org/D58033



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


[PATCH] D61559: Fix the crash when formatting unsupported encodings

2019-05-06 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/clang-format/ClangFormat.cpp:273
+.StartsWith("\xFF\xFE", "UTF-16 (LE)")
+.StartsWith("\x2B\x2F\x76", "UTF-7")
+.StartsWith("\xF7\x64\x4C", "UTF-1")

Seems unlikely we'll ever see any of these other than UTF{16,32}.
I'd suggest dropping them, but up to you.



Comment at: clang/tools/clang-format/ClangFormat.cpp:276
+.StartsWith("\xDD\x73\x66\x73", "UTF-EBCDIC")
+.StartsWith("\x0E\xFE\xFF", "SDSU")
+.StartsWith("\xFB\xEE\x28", "BOCU-1")

SCSU?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61559



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


[PATCH] D61559: Fix the crash when formatting unsupported encodings

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

You might want to add a test for one of these?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61559



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


[clang-tools-extra] r360016 - [clangd] Support -fallback-style, similar to clang-format.

2019-05-06 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon May  6 01:11:59 2019
New Revision: 360016

URL: http://llvm.org/viewvc/llvm-project?rev=360016&view=rev
Log:
[clangd] Support -fallback-style, similar to clang-format.

Reviewers: kadircet

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

Tags: #clang

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

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=360016&r1=360015&r2=360016&view=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Mon May  6 01:11:59 2019
@@ -16,6 +16,7 @@
 #include "index/Background.h"
 #include "index/Serialization.h"
 #include "clang/Basic/Version.h"
+#include "clang/Format/Format.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
@@ -231,6 +232,12 @@ static llvm::cl::opt EnableClangTi
 llvm::cl::desc("Enable clang-tidy diagnostics."),
 llvm::cl::init(true));
 
+static llvm::cl::opt
+FallbackStyle("fallback-style",
+  llvm::cl::desc("clang-format style to apply by default when "
+ "no .clang-format file is found"),
+  llvm::cl::init(clang::format::DefaultFallbackStyle));
+
 static llvm::cl::opt SuggestMissingIncludes(
 "suggest-missing-includes",
 llvm::cl::desc("Attempts to fix diagnostic errors caused by missing "
@@ -352,6 +359,8 @@ int main(int argc, char *argv[]) {
   llvm::errs() << "Ignoring -j because -run-synchronously is set.\n";
 WorkerThreadsCount = 0;
   }
+  if (FallbackStyle.getNumOccurrences())
+clang::format::DefaultFallbackStyle = FallbackStyle.c_str();
 
   // Validate command line arguments.
   llvm::Optional InputMirrorStream;


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


[PATCH] D61519: [clangd] Support -fallback-style, similar to clang-format.

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360016: [clangd] Support -fallback-style, similar to 
clang-format. (authored by sammccall, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61519

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
@@ -16,6 +16,7 @@
 #include "index/Background.h"
 #include "index/Serialization.h"
 #include "clang/Basic/Version.h"
+#include "clang/Format/Format.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
@@ -231,6 +232,12 @@
 llvm::cl::desc("Enable clang-tidy diagnostics."),
 llvm::cl::init(true));
 
+static llvm::cl::opt
+FallbackStyle("fallback-style",
+  llvm::cl::desc("clang-format style to apply by default when "
+ "no .clang-format file is found"),
+  llvm::cl::init(clang::format::DefaultFallbackStyle));
+
 static llvm::cl::opt SuggestMissingIncludes(
 "suggest-missing-includes",
 llvm::cl::desc("Attempts to fix diagnostic errors caused by missing "
@@ -352,6 +359,8 @@
   llvm::errs() << "Ignoring -j because -run-synchronously is set.\n";
 WorkerThreadsCount = 0;
   }
+  if (FallbackStyle.getNumOccurrences())
+clang::format::DefaultFallbackStyle = FallbackStyle.c_str();
 
   // Validate command line arguments.
   llvm::Optional InputMirrorStream;


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
@@ -16,6 +16,7 @@
 #include "index/Background.h"
 #include "index/Serialization.h"
 #include "clang/Basic/Version.h"
+#include "clang/Format/Format.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
@@ -231,6 +232,12 @@
 llvm::cl::desc("Enable clang-tidy diagnostics."),
 llvm::cl::init(true));
 
+static llvm::cl::opt
+FallbackStyle("fallback-style",
+  llvm::cl::desc("clang-format style to apply by default when "
+ "no .clang-format file is found"),
+  llvm::cl::init(clang::format::DefaultFallbackStyle));
+
 static llvm::cl::opt SuggestMissingIncludes(
 "suggest-missing-includes",
 llvm::cl::desc("Attempts to fix diagnostic errors caused by missing "
@@ -352,6 +359,8 @@
   llvm::errs() << "Ignoring -j because -run-synchronously is set.\n";
 WorkerThreadsCount = 0;
   }
+  if (FallbackStyle.getNumOccurrences())
+clang::format::DefaultFallbackStyle = FallbackStyle.c_str();
 
   // Validate command line arguments.
   llvm::Optional InputMirrorStream;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61472: [X86FixupLEAs] Turn optIncDec into a generic two address LEA optimizer. Support LEA64_32r properly.

2019-05-06 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Where did all the clang diffs come from?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61472



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


[PATCH] D59464: [analyzer] Add an example plugin for checker dependency handling

2019-05-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ping^2


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

https://reviews.llvm.org/D59464



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


[PATCH] D57858: [analyzer] Add a new frontend flag to display all checker options

2019-05-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ping^4


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

https://reviews.llvm.org/D57858



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


[PATCH] D57860: [analyzer] Validate checker option names and values

2019-05-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ping^4


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

https://reviews.llvm.org/D57860



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


[PATCH] D59465: [analyzer] Add a test plugin for checker option handling

2019-05-06 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ping


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

https://reviews.llvm.org/D59465



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


[PATCH] D60552: [X86] Enable intrinsics of AVX512_BF16, which are supported for BFLOAT16 in Cooper Lake

2019-05-06 Thread LuoYuanke via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360018: Enable intrinsics of AVX512_BF16, which are 
supported for BFLOAT16 in Cooper… (authored by LuoYuanke, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60552?vs=198168&id=198233#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60552

Files:
  cfe/trunk/docs/ClangCommandLineReference.rst
  cfe/trunk/include/clang/Basic/BuiltinsX86.def
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/Targets/X86.cpp
  cfe/trunk/lib/Basic/Targets/X86.h
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/Headers/CMakeLists.txt
  cfe/trunk/lib/Headers/cpuid.h
  cfe/trunk/lib/Headers/immintrin.h
  cfe/trunk/test/CodeGen/attr-target-x86.c
  cfe/trunk/test/Driver/x86-target-features.c
  cfe/trunk/test/Preprocessor/x86_target_features.c
  monorepo-root/trunk/lib/Headers/avx512bf16intrin.h
  monorepo-root/trunk/lib/Headers/avx512vlbf16intrin.h
  monorepo-root/trunk/test/CodeGen/avx512bf16-builtins.c
  monorepo-root/trunk/test/CodeGen/avx512vlbf16-builtins.c

Index: cfe/trunk/docs/ClangCommandLineReference.rst
===
--- cfe/trunk/docs/ClangCommandLineReference.rst
+++ cfe/trunk/docs/ClangCommandLineReference.rst
@@ -2610,6 +2610,8 @@
 
 .. option:: -mavx512bitalg, -mno-avx512bitalg
 
+.. option:: -mavx512bf16, -mno-avx512bf16
+
 .. option:: -mavx512bw, -mno-avx512bw
 
 .. option:: -mavx512cd, -mno-avx512cd
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2854,6 +2854,8 @@
 def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
 def mavx512f : Flag<["-"], "mavx512f">, Group;
 def mno_avx512f : Flag<["-"], "mno-avx512f">, Group;
+def mavx512bf16 : Flag<["-"], "mavx512bf16">, Group;
+def mno_avx512bf16 : Flag<["-"], "mno-avx512bf16">, Group;
 def mavx512bitalg : Flag<["-"], "mavx512bitalg">, Group;
 def mno_avx512bitalg : Flag<["-"], "mno-avx512bitalg">, Group;
 def mavx512bw : Flag<["-"], "mavx512bw">, Group;
Index: cfe/trunk/include/clang/Basic/BuiltinsX86.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def
@@ -1831,6 +1831,24 @@
 TARGET_BUILTIN(__builtin_ia32_vpmultishiftqb512, "V64cV64cV64c", "ncV:512:", "avx512vbmi")
 TARGET_BUILTIN(__builtin_ia32_vpmultishiftqb128, "V16cV16cV16c", "ncV:128:", "avx512vbmi,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpmultishiftqb256, "V32cV32cV32c", "ncV:256:", "avx512vbmi,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtne2ps2bf16_128, "V8sV4fV4f", "ncV:128:",
+ "avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtne2ps2bf16_256, "V16sV8fV8f", "ncV:256:",
+ "avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtne2ps2bf16_512, "V32sV16fV16f", "ncV:512:",
+ "avx512bf16")
+TARGET_BUILTIN(__builtin_ia32_cvtneps2bf16_128_mask, "V8sV4fV8sUc", "ncV:128:",
+"avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtneps2bf16_256, "V8sV8f", "ncV:256:",
+"avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtneps2bf16_512, "V16sV16f", "ncV:512:",
+"avx512bf16")
+TARGET_BUILTIN(__builtin_ia32_dpbf16ps_128, "V4fV4fV4iV4i", "ncV:128:",
+"avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_dpbf16ps_256, "V8fV8fV8iV8i", "ncV:256:",
+"avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_dpbf16ps_512, "V16fV16fV16iV16i", "ncV:512:",
+"avx512bf16")
 
 // generic select intrinsics
 TARGET_BUILTIN(__builtin_ia32_selectb_128, "V16cUsV16cV16c", "ncV:128:", "avx512bw,avx512vl")
Index: cfe/trunk/test/CodeGen/attr-target-x86.c
===
--- cfe/trunk/test/CodeGen/attr-target-x86.c
+++ cfe/trunk/test/CodeGen/attr-target-x86.c
@@ -50,9 +50,9 @@
 // CHECK: use_before_def{{.*}} #7
 // CHECK: #0 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87"
 // CHECK: #1 = {{.*}}"target-cpu"="ivybridge" "target-features"="+avx,+cx16,+cx8,+f16c,+fsgsbase,+fxsr,+mmx,+pclmul,+popcnt,+rdrnd,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
-// CHECK: #2 = {{.*}}"target-cpu"="i686" "target-features"="+cx8,+x87,-aes,-avx,-avx2,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx

[clang-tools-extra] r360020 - [clangd] Always call getFormatStyleForFile().

2019-05-06 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon May  6 01:39:17 2019
New Revision: 360020

URL: http://llvm.org/viewvc/llvm-project?rev=360020&view=rev
Log:
[clangd] Always call getFormatStyleForFile().

This means "format" will no longer return an error if the -fallback-style flag
is invalid, it will log and use LLVM style. This doesn't really matter.

Also document the dependence on global variables. (This patch is a
compromise - it's probably not worth actually avoiding the globals).

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/SourceCode.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=360020&r1=360019&r2=360020&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon May  6 01:39:17 2019
@@ -496,20 +496,16 @@ llvm::Expected
 ClangdServer::formatCode(llvm::StringRef Code, PathRef File,
  llvm::ArrayRef Ranges) {
   // Call clang-format.
-  auto FS = FSProvider.getFileSystem();
-  auto Style = format::getStyle(format::DefaultFormatStyle, File,
-format::DefaultFallbackStyle, Code, FS.get());
-  if (!Style)
-return Style.takeError();
-
+  format::FormatStyle Style =
+  getFormatStyleForFile(File, Code, FSProvider.getFileSystem().get());
   tooling::Replacements IncludeReplaces =
-  format::sortIncludes(*Style, Code, Ranges, File);
+  format::sortIncludes(Style, Code, Ranges, File);
   auto Changed = tooling::applyAllReplacements(Code, IncludeReplaces);
   if (!Changed)
 return Changed.takeError();
 
   return IncludeReplaces.merge(format::reformat(
-  Style.get(), *Changed,
+  Style, *Changed,
   tooling::calculateRangesAfterReplacements(IncludeReplaces, Ranges),
   File));
 }

Modified: clang-tools-extra/trunk/clangd/SourceCode.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SourceCode.h?rev=360020&r1=360019&r2=360020&view=diff
==
--- clang-tools-extra/trunk/clangd/SourceCode.h (original)
+++ clang-tools-extra/trunk/clangd/SourceCode.h Mon May  6 01:39:17 2019
@@ -147,6 +147,11 @@ llvm::Optional getCanonical
 
 bool isRangeConsecutive(const Range &Left, const Range &Right);
 
+/// Choose the clang-format style we should apply to a certain file.
+/// This will usually use FS to look for .clang-format directories.
+/// FIXME: should we be caching the .clang-format file search?
+/// This uses format::DefaultFormatStyle and format::DefaultFallbackStyle,
+/// though the latter may have been overridden in main()!
 format::FormatStyle getFormatStyleForFile(llvm::StringRef File,
   llvm::StringRef Content,
   llvm::vfs::FileSystem *FS);


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


[PATCH] D61537: [clangd] Boost code completion results that were named in the last few lines.

2019-05-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Nice! Looking at the numbers, the improvements look worthwhile.

The stopwords don't seem to be in the patch anymore, but they do seem like a 
good idea. Specifically, we might want to remove all keywords - the intuition 
is that they don't provide much value, because users **have** to put them.




Comment at: clangd/unittests/CodeCompleteTests.cpp:25
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/Support/AtomicOrdering.h"
 #include "llvm/Support/Error.h"

This included was probably added accidentally. Remove?



Comment at: clangd/unittests/CodeCompleteTests.cpp:29
 #include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock-generated-matchers.h"
 #include "gmock/gmock.h"

This include is redundant, maybe remove it? (added by clangd for sure)



Comment at: clangd/unittests/SourceCodeTests.cpp:25
 using llvm::HasValue;
+using testing::UnorderedElementsAreArray;
 

NIT: use `::testing` to be consistent with the rest of the code in clangd?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61537



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


r360022 - [X86] Move files to correct directories after D60552

2019-05-06 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Mon May  6 02:24:36 2019
New Revision: 360022

URL: http://llvm.org/viewvc/llvm-project?rev=360022&view=rev
Log:
[X86] Move files to correct directories after D60552

Added:
cfe/trunk/lib/Headers/avx512bf16intrin.h
cfe/trunk/lib/Headers/avx512vlbf16intrin.h
cfe/trunk/test/CodeGen/avx512bf16-builtins.c
cfe/trunk/test/CodeGen/avx512vlbf16-builtins.c

Added: cfe/trunk/lib/Headers/avx512bf16intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bf16intrin.h?rev=360022&view=auto
==
--- cfe/trunk/lib/Headers/avx512bf16intrin.h (added)
+++ cfe/trunk/lib/Headers/avx512bf16intrin.h Mon May  6 02:24:36 2019
@@ -0,0 +1,212 @@
+/*=== avx512bf16intrin.h - AVX512_BF16 intrinsics --===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  
instead."
+#endif
+
+#ifndef __AVX512BF16INTRIN_H
+#define __AVX512BF16INTRIN_H
+
+typedef short __m512bh __attribute__((__vector_size__(64), __aligned__(64)));
+typedef short __m256bh __attribute__((__vector_size__(32), __aligned__(32)));
+
+#define __DEFAULT_FN_ATTRS512 \
+  __attribute__((__always_inline__, __nodebug__, __target__("avx512bf16"), \
+ __min_vector_width__(512)))
+
+/// Convert Two Packed Single Data to One Packed BF16 Data.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  VCVTNE2PS2BF16  instructions.
+///
+/// \param __A
+///A 512-bit vector of [16 x float].
+/// \param __B
+///A 512-bit vector of [16 x float].
+/// \returns A 512-bit vector of [32 x bfloat] whose lower 256 bits come from
+///convertion of src2, and higher 256 bits come from conversion of src1.
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_cvtne2ps_pbh(__m512 __A, __m512 __B) {
+  return (__m512bh)__builtin_ia32_cvtne2ps2bf16_512((__v16sf) __A,
+(__v16sf) __B);
+}
+
+/// Convert Two Packed Single Data to One Packed BF16 Data.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  VCVTNE2PS2BF16  instructions.
+///
+/// \param __A
+///A 512-bit vector of [16 x float].
+/// \param __B
+///A 512-bit vector of [16 x float].
+/// \param __W
+///A 512-bit vector of [32 x bfloat].
+/// \param __U
+///An immediate value containing an 32-bit value specifying which element
+///is choosed. 1 means __A or __B, 0 means __W.
+/// \returns A 512-bit vector of [32 x bfloat] whose lower 256 bits come from
+///convertion of src2, and higher 256 bits come from conversion of src1.
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_mask_cvtne2ps_pbh(__m512bh __W, __mmask32 __U, __m512 __A, __m512 __B) {
+  return (__m512bh)__builtin_ia32_selectw_512((__mmask32)__U,
+(__v32hi)_mm512_cvtne2ps_pbh(__A, __B),
+(__v32hi)__W);
+}
+
+/// Convert Two Packed Single Data to One Packed BF16 Data.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  VCVTNE2PS2BF16  instructions.
+///
+/// \param __A
+///A 512-bit vector of [16 x float].
+/// \param __B
+///A 512-bit vector of [16 x float].
+/// \param __U
+///An immediate value containing an 32-bit value specifying which element
+///is choosed. 1 means __A or __B, 0 means zero.
+/// \returns A 512-bit vector of [32 x bfloat] whose lower 256 bits come from
+///convertion of src2, and higher 256 bits come from conversion of src1.
+static __inline__ __m512bh __DEFAULT_FN_ATTRS512
+_mm512_maskz_cvtne2ps_pbh(__mmask32 __U, __m512 __A, __m512 __B) {
+  return (__m512bh)__builtin_ia32_selectw_512((__mmask32)__U,
+(__v32hi)_mm512_cvtne2ps_pbh(__A, __B),
+(__v32hi)_mm512_setzero_si512());
+}
+
+/// Convert Packed Single Data to Packed BF16 Data.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  VCVTNEPS2BF16  instructions.
+///
+/// \param __A
+///A 512-bit vector of [16 x float].
+/// \returns A 256-bit vector of [16 x bfloat] come from convertion of src
+static __inline__ __m256bh __DEFAULT_FN_ATTRS512
+_mm512_cvtneps_pbh(__m512 __A) {
+  return (__m256bh)__builtin_ia32_cvtneps2bf16_512((__v16sf) __A);
+}
+
+/// Convert Packed Single Data to Packed BF16 Data.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  VCVTNEPS2BF16  instructions.
+///
+/// \param __A
+///A 512-bit vector of [16 x float].
+/// \param __W
+///A 256-bit vector of [16 x bfloat].
+/// \param __U
+///An immediate value containing an 16-bit value specifying which eleme

Re: r359949 - [clang] adding explicit(bool) from c++2a

2019-05-06 Thread Hans Wennborg via cfe-commits
On Sat, May 4, 2019 at 2:06 AM Nicolas Lesser via cfe-commits
 wrote:
>
> Author: rakete
> Date: Fri May  3 17:09:00 2019
> New Revision: 359949
>
> URL: http://llvm.org/viewvc/llvm-project?rev=359949&view=rev
> Log:
> [clang] adding explicit(bool) from c++2a
>
> this patch adds support for the explicit bool specifier.
>
> Changes:
> - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp.
> - The storage of the explicit specifier was changed. the explicit specifier 
> was stored as a boolean value in the FunctionDeclBitfields and in the 
> DeclSpec class. now it is stored as a PointerIntPair with a flag 
> and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, 
> CXXConversionDecl and in the DeclSpec class.
> - Following the AST change, Serialization, ASTMatchers, ASTComparator and 
> ASTPrinter were adapted.
> - Template instantiation was adapted to instantiate the potential expressions 
> of the explicit(bool) specifier When instantiating their associated 
> declaration.
> - The Add*Candidate functions were adapted, they now take a Boolean 
> indicating if the context allowing explicit constructor or conversion 
> function and this boolean is used to remove invalid overloads that required 
> template instantiation to be detected.
> - Test for Semantic and Serialization were added.
>
> This patch is not yet complete. I still need to check that interaction with 
> CTAD and deduction guides is correct. and add more tests for AST operations. 
> But I wanted first feedback.
> Perhaps this patch should be spited in smaller patches, but making each patch 
> testable as a standalone may be tricky.
>
> Patch by Tyker
>
> Differential Revision: https://reviews.llvm.org/D60934

This broke the Chromium (and we got a separate report about V8 too)
builds, causing compile failures pretty early in the build. Here's a
reduced test case:

struct S {
  template  explicit S();
};

struct T : S {};

struct U : T {
  U();
};
U::U() {}

$ clang -c /tmp/x.cc
/tmp/x.cc:10:4: error: call to implicitly-deleted default constructor of 'T'
U::U() {}
   ^
/tmp/x.cc:5:12: note: default constructor of 'T' is implicitly deleted
because base class 'S' has no default constructor
struct T : S {};
   ^
1 error generated.


Based on the commit message, it sounds like this change was not intentional?

I don't know if the error message actually makes sense or whether the
code should be legal. Note that de-templatizing S::S(), or making U
inherit directly from S instead of T, makes the error go away.

If it turns out the code is in fact illegal and Clang was right to
error here, it would be good if we could get some heads up to fix our
code first.

I've reverted this change in r360024 until it's cleared up whether the
new compile error is intentional.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r360026 - [clangd] Qualify uses of ::testing everywhere. NFC

2019-05-06 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon May  6 03:08:47 2019
New Revision: 360026

URL: http://llvm.org/viewvc/llvm-project?rev=360026&view=rev
Log:
[clangd] Qualify uses of ::testing everywhere. NFC

Add an initial '::' qualifier to all usages of 'testing' namespace that
did not have one.

The goal is to make our code style in tests more consistent.

Modified:
clang-tools-extra/trunk/clangd/unittests/BackgroundIndexTests.cpp
clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp
clang-tools-extra/trunk/clangd/unittests/DexTests.cpp
clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp
clang-tools-extra/trunk/clangd/unittests/FileIndexTests.cpp
clang-tools-extra/trunk/clangd/unittests/FindSymbolsTests.cpp
clang-tools-extra/trunk/clangd/unittests/FuzzyMatchTests.cpp
clang-tools-extra/trunk/clangd/unittests/IndexActionTests.cpp
clang-tools-extra/trunk/clangd/unittests/IndexTests.cpp
clang-tools-extra/trunk/clangd/unittests/PrintASTTests.cpp
clang-tools-extra/trunk/clangd/unittests/SerializationTests.cpp
clang-tools-extra/trunk/clangd/unittests/SymbolCollectorTests.cpp
clang-tools-extra/trunk/clangd/unittests/SymbolInfoTests.cpp
clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp
clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/BackgroundIndexTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/BackgroundIndexTests.cpp?rev=360026&r1=360025&r2=360026&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/BackgroundIndexTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/BackgroundIndexTests.cpp Mon May  
6 03:08:47 2019
@@ -7,12 +7,12 @@
 #include "gtest/gtest.h"
 #include 
 
-using testing::_;
-using testing::AllOf;
-using testing::Contains;
-using testing::ElementsAre;
-using testing::Not;
-using testing::UnorderedElementsAre;
+using ::testing::_;
+using ::testing::AllOf;
+using ::testing::Contains;
+using ::testing::ElementsAre;
+using ::testing::Not;
+using ::testing::UnorderedElementsAre;
 
 namespace clang {
 namespace clangd {
@@ -23,9 +23,9 @@ MATCHER(Declared, "") {
 }
 MATCHER(Defined, "") { return !StringRef(arg.Definition.FileURI).empty(); }
 MATCHER_P(FileURI, F, "") { return StringRef(arg.Location.FileURI) == F; }
-testing::Matcher
-RefsAre(std::vector> Matchers) {
-  return ElementsAre(testing::Pair(_, UnorderedElementsAreArray(Matchers)));
+::testing::Matcher
+RefsAre(std::vector<::testing::Matcher> Matchers) {
+  return ElementsAre(::testing::Pair(_, UnorderedElementsAreArray(Matchers)));
 }
 // URI cannot be empty since it references keys in the IncludeGraph.
 MATCHER(EmptyIncludeNode, "") {

Modified: clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp?rev=360026&r1=360025&r2=360026&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp Mon May  6 
03:08:47 2019
@@ -18,7 +18,7 @@ namespace clang {
 namespace clangd {
 namespace {
 
-using testing::ElementsAre;
+using ::testing::ElementsAre;
 
 TEST(ClangdUnitTest, GetBeginningOfIdentifier) {
   std::string Preamble = R"cpp(

Modified: clang-tools-extra/trunk/clangd/unittests/DexTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/DexTests.cpp?rev=360026&r1=360025&r2=360026&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/DexTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/DexTests.cpp Mon May  6 03:08:47 
2019
@@ -352,16 +352,16 @@ TEST(DexIterators, Optimizations) {
 // Search token tests.
 
//===--===//
 
-testing::Matcher>
+::testing::Matcher>
 tokensAre(std::initializer_list Strings, Token::Kind Kind) {
   std::vector Tokens;
   for (const auto &TokenData : Strings) {
 Tokens.push_back(Token(Kind, TokenData));
   }
-  return testing::UnorderedElementsAreArray(Tokens);
+  return ::testing::UnorderedElementsAreArray(Tokens);
 }
 
-testing::Matcher>
+::testing::Matcher>
 trigramsAre(std::initializer_list Trigrams) {
   return tokensAre(Trigrams, Token::Kind::Trigram);
 }

Modified: clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp?rev=360026&r1=360025&r2=360026&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/DiagnosticsTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/Diagno

[PATCH] D61537: [clangd] Boost code completion results that were named in the last few lines.

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 198242.
sammccall added a comment.

address comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61537

Files:
  clangd/CodeComplete.cpp
  clangd/FindSymbols.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/test/completion-auto-trigger.test
  clangd/unittests/CodeCompleteTests.cpp
  clangd/unittests/QualityTests.cpp
  clangd/unittests/SourceCodeTests.cpp

Index: clangd/unittests/SourceCodeTests.cpp
===
--- clangd/unittests/SourceCodeTests.cpp
+++ clangd/unittests/SourceCodeTests.cpp
@@ -22,6 +22,7 @@
 
 using llvm::Failed;
 using llvm::HasValue;
+using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P2(Pos, Line, Col, "") {
   return arg.line == int(Line) && arg.character == int(Col);
@@ -322,6 +323,19 @@
   EXPECT_EQ(IDs["foo"], 2u);
 }
 
+TEST(SourceCodeTests, CollectWords) {
+  auto Words = collectWords(R"cpp(
+  #define FIZZ_BUZZ
+  // this is a comment
+  std::string getSomeText() { return "magic word"; }
+  )cpp");
+  std::set ActualWords(Words.keys().begin(), Words.keys().end());
+  std::set ExpectedWords = {"define",  "fizz","buzz",  "this",
+ "comment", "string", "some", "text",
+ "return",  "magic",  "word"};
+  EXPECT_EQ(ActualWords, ExpectedWords);
+}
+
 TEST(SourceCodeTests, VisibleNamespaces) {
   std::vector>> Cases = {
   {
Index: clangd/unittests/QualityTests.cpp
===
--- clangd/unittests/QualityTests.cpp
+++ clangd/unittests/QualityTests.cpp
@@ -292,6 +292,16 @@
   SymbolRelevanceSignals InBaseClass;
   InBaseClass.InBaseClass = true;
   EXPECT_LT(InBaseClass.evaluate(), Default.evaluate());
+
+  llvm::StringSet<> Words = {"one", "two", "three"};
+  SymbolRelevanceSignals WithoutMatchingWord;
+  WithoutMatchingWord.ContextWords = &Words;
+  WithoutMatchingWord.Name = "four";
+  EXPECT_EQ(WithoutMatchingWord.evaluate(), Default.evaluate());
+  SymbolRelevanceSignals WithMatchingWord;
+  WithMatchingWord.ContextWords = &Words;
+  WithMatchingWord.Name = "TheTwoTowers";
+  EXPECT_GT(WithMatchingWord.evaluate(), Default.evaluate());
 }
 
 TEST(QualityTests, ScopeProximity) {
Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -174,6 +174,7 @@
   int BBB();
   int CCC();
 };
+
 int main() { ClassWithMembers().^ }
   )cpp",
  /*IndexSymbols=*/{}, Opts);
@@ -324,7 +325,7 @@
   }
 }
 
-TEST(CompletionTest, Priorities) {
+TEST(CompletionTest, Accessible) {
   auto Internal = completions(R"cpp(
   class Foo {
 public: void pub();
@@ -334,7 +335,7 @@
   void Foo::pub() { this->^ }
   )cpp");
   EXPECT_THAT(Internal.Completions,
-  HasSubsequence(Named("priv"), Named("prot"), Named("pub")));
+  AllOf(Has("priv"), Has("prot"), Has("pub")));
 
   auto External = completions(R"cpp(
   class Foo {
@@ -502,6 +503,21 @@
   HasSubsequence(Named("absl"), Named("absb")));
 }
 
+TEST(CompletionTest, ContextWords) {
+  auto Results = completions(R"cpp(
+  enum class Color { RED, YELLOW, BLUE };
+
+  // (blank lines so the definition above isn't "context")
+
+  // "It was a yellow car," he said. "Big yellow car, new."
+  auto Finish = Color::^
+  )cpp");
+  // Yellow would normally sort last (alphabetic).
+  // But the recent mention shuold bump it up.
+  ASSERT_THAT(Results.Completions,
+  HasSubsequence(Named("YELLOW"), Named("BLUE")));
+}
+
 TEST(CompletionTest, GlobalQualified) {
   auto Results = completions(
   R"cpp(
Index: clangd/test/completion-auto-trigger.test
===
--- clangd/test/completion-auto-trigger.test
+++ clangd/test/completion-auto-trigger.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
-# CHECK-NEXT:"sortText": "3eacsize",
+# CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
 # CHECK-NEXT:  "range": {
@@ -45,7 +45,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # CHECK-NEXT: "kind": 10,
 # CHECK-NEXT: "label": " default_capacity",
-# CHECK-NEXT: "sortText": "3fd70a3ddefault_capacity",
+# CHECK-NEXT: "sortText": "{{.*}}default_capacity",
 # CHECK-NEXT: "textEdit": {
 # CHECK-NEXT:   "newText": "default_capacity",
 # CHECK-NEXT:   "range": {
@@ -84,7 +84,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 6,
 # CHECK-NEXT:   

[clang-tools-extra] r360030 - [clangd] Boost code completion results that were named in the last few lines.

2019-05-06 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon May  6 03:25:10 2019
New Revision: 360030

URL: http://llvm.org/viewvc/llvm-project?rev=360030&view=rev
Log:
[clangd] Boost code completion results that were named in the last few lines.

Summary:
The hope is this will catch a few patterns with repetition:

  SomeClass* S = ^SomeClass::Create()

  int getFrobnicator() { return ^frobnicator_; }

  // discard the factory, it's no longer valid.
  ^MyFactory.reset();

Without triggering antipatterns too often:

  return Point(x.first, x.^second);

I'm going to gather some data on whether this turns out to be a win overall.

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/FindSymbols.cpp
clang-tools-extra/trunk/clangd/Quality.cpp
clang-tools-extra/trunk/clangd/Quality.h
clang-tools-extra/trunk/clangd/SourceCode.cpp
clang-tools-extra/trunk/clangd/SourceCode.h
clang-tools-extra/trunk/clangd/test/completion-auto-trigger.test
clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/trunk/clangd/unittests/QualityTests.cpp
clang-tools-extra/trunk/clangd/unittests/SourceCodeTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=360030&r1=360029&r2=360030&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Mon May  6 03:25:10 2019
@@ -54,7 +54,9 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -1215,6 +1217,7 @@ class CodeCompleteFlow {
   llvm::Optional PreferredType; // Initialized once Sema runs.
   // Whether to query symbols from any scope. Initialized once Sema runs.
   bool AllScopes = false;
+  llvm::StringSet<> ContextWords;
   // Include-insertion and proximity scoring rely on the include structure.
   // This is available after Sema has run.
   llvm::Optional Inserter;  // Available during runWithSema.
@@ -1237,6 +1240,7 @@ public:
 trace::Span Tracer("CodeCompleteFlow");
 HeuristicPrefix =
 guessCompletionPrefix(SemaCCInput.Contents, SemaCCInput.Offset);
+populateContextWords(SemaCCInput.Contents);
 if (Opts.Index && SpecFuzzyFind && SpecFuzzyFind->CachedReq.hasValue()) {
   assert(!SpecFuzzyFind->Result.valid());
   SpecReq = speculativeFuzzyFindRequestForCompletion(
@@ -1323,6 +1327,7 @@ public:
 trace::Span Tracer("CodeCompleteWithoutSema");
 // Fill in fields normally set by runWithSema()
 HeuristicPrefix = guessCompletionPrefix(Content, Offset);
+populateContextWords(Content);
 CCContextKind = CodeCompletionContext::CCC_Recovery;
 Filter = FuzzyMatcher(HeuristicPrefix.Name);
 auto Pos = offsetToPosition(Content, Offset);
@@ -1380,6 +1385,24 @@ public:
   }
 
 private:
+  void populateContextWords(llvm::StringRef Content) {
+// Take last 3 lines before the completion point.
+unsigned RangeEnd = HeuristicPrefix.Qualifier.begin() - Content.data(),
+ RangeBegin = RangeEnd;
+for (size_t I = 0; I < 3 && RangeBegin > 0; ++I) {
+  auto PrevNL = Content.rfind('\n', RangeBegin - 1);
+  if (PrevNL == StringRef::npos) {
+RangeBegin = 0;
+break;
+  }
+  RangeBegin = PrevNL + 1;
+}
+
+ContextWords = collectWords(Content.slice(RangeBegin, RangeEnd));
+dlog("Completion context words: {0}",
+ llvm::join(ContextWords.keys(), ", "));
+  }
+
   // This is called by run() once Sema code completion is done, but before the
   // Sema data structures are torn down. It does all the real work.
   CodeCompleteResult runWithSema() {
@@ -1563,12 +1586,14 @@ private:
 SymbolQualitySignals Quality;
 SymbolRelevanceSignals Relevance;
 Relevance.Context = CCContextKind;
+Relevance.Name = Bundle.front().Name;
 Relevance.Query = SymbolRelevanceSignals::CodeComplete;
 Relevance.FileProximityMatch = FileProximity.getPointer();
 if (ScopeProximity)
   Relevance.ScopeProximityMatch = ScopeProximity.getPointer();
 if (PreferredType)
   Relevance.HadContextType = true;
+Relevance.ContextWords = &ContextWords;
 
 auto &First = Bundle.front();
 if (auto FuzzyScore = fuzzyScore(First))

Modified: clang-tools-extra/trunk/clangd/FindSymbols.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FindSymbols.cpp?rev=360030&r1=360029&r2=360030&view=diff
==

[PATCH] D61537: [clangd] Boost code completion results that were named in the last few lines.

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 198243.
sammccall marked 3 inline comments as done.
sammccall added a comment.

Comment about keywords


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61537

Files:
  clangd/CodeComplete.cpp
  clangd/FindSymbols.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/test/completion-auto-trigger.test
  clangd/unittests/CodeCompleteTests.cpp
  clangd/unittests/QualityTests.cpp
  clangd/unittests/SourceCodeTests.cpp

Index: clangd/unittests/SourceCodeTests.cpp
===
--- clangd/unittests/SourceCodeTests.cpp
+++ clangd/unittests/SourceCodeTests.cpp
@@ -22,6 +22,7 @@
 
 using llvm::Failed;
 using llvm::HasValue;
+using ::testing::UnorderedElementsAreArray;
 
 MATCHER_P2(Pos, Line, Col, "") {
   return arg.line == int(Line) && arg.character == int(Col);
@@ -322,6 +323,19 @@
   EXPECT_EQ(IDs["foo"], 2u);
 }
 
+TEST(SourceCodeTests, CollectWords) {
+  auto Words = collectWords(R"cpp(
+  #define FIZZ_BUZZ
+  // this is a comment
+  std::string getSomeText() { return "magic word"; }
+  )cpp");
+  std::set ActualWords(Words.keys().begin(), Words.keys().end());
+  std::set ExpectedWords = {"define",  "fizz","buzz",  "this",
+ "comment", "string", "some", "text",
+ "return",  "magic",  "word"};
+  EXPECT_EQ(ActualWords, ExpectedWords);
+}
+
 TEST(SourceCodeTests, VisibleNamespaces) {
   std::vector>> Cases = {
   {
Index: clangd/unittests/QualityTests.cpp
===
--- clangd/unittests/QualityTests.cpp
+++ clangd/unittests/QualityTests.cpp
@@ -292,6 +292,16 @@
   SymbolRelevanceSignals InBaseClass;
   InBaseClass.InBaseClass = true;
   EXPECT_LT(InBaseClass.evaluate(), Default.evaluate());
+
+  llvm::StringSet<> Words = {"one", "two", "three"};
+  SymbolRelevanceSignals WithoutMatchingWord;
+  WithoutMatchingWord.ContextWords = &Words;
+  WithoutMatchingWord.Name = "four";
+  EXPECT_EQ(WithoutMatchingWord.evaluate(), Default.evaluate());
+  SymbolRelevanceSignals WithMatchingWord;
+  WithMatchingWord.ContextWords = &Words;
+  WithMatchingWord.Name = "TheTwoTowers";
+  EXPECT_GT(WithMatchingWord.evaluate(), Default.evaluate());
 }
 
 TEST(QualityTests, ScopeProximity) {
Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -174,6 +174,7 @@
   int BBB();
   int CCC();
 };
+
 int main() { ClassWithMembers().^ }
   )cpp",
  /*IndexSymbols=*/{}, Opts);
@@ -324,7 +325,7 @@
   }
 }
 
-TEST(CompletionTest, Priorities) {
+TEST(CompletionTest, Accessible) {
   auto Internal = completions(R"cpp(
   class Foo {
 public: void pub();
@@ -334,7 +335,7 @@
   void Foo::pub() { this->^ }
   )cpp");
   EXPECT_THAT(Internal.Completions,
-  HasSubsequence(Named("priv"), Named("prot"), Named("pub")));
+  AllOf(Has("priv"), Has("prot"), Has("pub")));
 
   auto External = completions(R"cpp(
   class Foo {
@@ -502,6 +503,21 @@
   HasSubsequence(Named("absl"), Named("absb")));
 }
 
+TEST(CompletionTest, ContextWords) {
+  auto Results = completions(R"cpp(
+  enum class Color { RED, YELLOW, BLUE };
+
+  // (blank lines so the definition above isn't "context")
+
+  // "It was a yellow car," he said. "Big yellow car, new."
+  auto Finish = Color::^
+  )cpp");
+  // Yellow would normally sort last (alphabetic).
+  // But the recent mention shuold bump it up.
+  ASSERT_THAT(Results.Completions,
+  HasSubsequence(Named("YELLOW"), Named("BLUE")));
+}
+
 TEST(CompletionTest, GlobalQualified) {
   auto Results = completions(
   R"cpp(
Index: clangd/test/completion-auto-trigger.test
===
--- clangd/test/completion-auto-trigger.test
+++ clangd/test/completion-auto-trigger.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
-# CHECK-NEXT:"sortText": "3eacsize",
+# CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
 # CHECK-NEXT:  "range": {
@@ -45,7 +45,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # CHECK-NEXT: "kind": 10,
 # CHECK-NEXT: "label": " default_capacity",
-# CHECK-NEXT: "sortText": "3fd70a3ddefault_capacity",
+# CHECK-NEXT: "sortText": "{{.*}}default_capacity",
 # CHECK-NEXT: "textEdit": {
 # CHECK-NEXT:   "newText": "default_capacity",
 # CHECK-NEXT:   "range": {
@@ -84,7 +84,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,

[PATCH] D61537: [clangd] Boost code completion results that were named in the last few lines.

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D61537#1491649 , @ilya-biryukov 
wrote:

> Nice! Looking at the numbers, the improvements look worthwhile.
>
> The stopwords don't seem to be in the patch anymore, but they do seem like a 
> good idea. Specifically, we might want to remove all keywords - the intuition 
> is that they don't provide much value, because users **have** to put them.


The simplest versions of this didn't show any actual numerical benefit. There 
may be gains to be had by running the real lexer, will leave that for future 
work.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61537



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


[PATCH] D61537: [clangd] Boost code completion results that were named in the last few lines.

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE360030: [clangd] Boost code completion results that were 
named in the last few lines. (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61537?vs=198243&id=198244#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61537

Files:
  clangd/CodeComplete.cpp
  clangd/FindSymbols.cpp
  clangd/Quality.cpp
  clangd/Quality.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/test/completion-auto-trigger.test
  clangd/unittests/CodeCompleteTests.cpp
  clangd/unittests/QualityTests.cpp
  clangd/unittests/SourceCodeTests.cpp

Index: clangd/test/completion-auto-trigger.test
===
--- clangd/test/completion-auto-trigger.test
+++ clangd/test/completion-auto-trigger.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 5,
 # CHECK-NEXT:"label": " size",
-# CHECK-NEXT:"sortText": "3eacsize",
+# CHECK-NEXT:"sortText": "{{.*}}size",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "size",
 # CHECK-NEXT:  "range": {
@@ -45,7 +45,7 @@
 # CHECK-NEXT: "insertTextFormat": 1,
 # CHECK-NEXT: "kind": 10,
 # CHECK-NEXT: "label": " default_capacity",
-# CHECK-NEXT: "sortText": "3fd70a3ddefault_capacity",
+# CHECK-NEXT: "sortText": "{{.*}}default_capacity",
 # CHECK-NEXT: "textEdit": {
 # CHECK-NEXT:   "newText": "default_capacity",
 # CHECK-NEXT:   "range": {
@@ -84,7 +84,7 @@
 # CHECK-NEXT:"insertTextFormat": 1,
 # CHECK-NEXT:"kind": 6,
 # CHECK-NEXT:"label": " ns_member",
-# CHECK-NEXT:"sortText": "3f2cns_member",
+# CHECK-NEXT:"sortText": "{{.*}}ns_member",
 # CHECK-NEXT:"textEdit": {
 # CHECK-NEXT:  "newText": "ns_member",
 # CHECK-NEXT:  "range": {
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -54,7 +54,9 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -1215,6 +1217,7 @@
   llvm::Optional PreferredType; // Initialized once Sema runs.
   // Whether to query symbols from any scope. Initialized once Sema runs.
   bool AllScopes = false;
+  llvm::StringSet<> ContextWords;
   // Include-insertion and proximity scoring rely on the include structure.
   // This is available after Sema has run.
   llvm::Optional Inserter;  // Available during runWithSema.
@@ -1237,6 +1240,7 @@
 trace::Span Tracer("CodeCompleteFlow");
 HeuristicPrefix =
 guessCompletionPrefix(SemaCCInput.Contents, SemaCCInput.Offset);
+populateContextWords(SemaCCInput.Contents);
 if (Opts.Index && SpecFuzzyFind && SpecFuzzyFind->CachedReq.hasValue()) {
   assert(!SpecFuzzyFind->Result.valid());
   SpecReq = speculativeFuzzyFindRequestForCompletion(
@@ -1323,6 +1327,7 @@
 trace::Span Tracer("CodeCompleteWithoutSema");
 // Fill in fields normally set by runWithSema()
 HeuristicPrefix = guessCompletionPrefix(Content, Offset);
+populateContextWords(Content);
 CCContextKind = CodeCompletionContext::CCC_Recovery;
 Filter = FuzzyMatcher(HeuristicPrefix.Name);
 auto Pos = offsetToPosition(Content, Offset);
@@ -1380,6 +1385,24 @@
   }
 
 private:
+  void populateContextWords(llvm::StringRef Content) {
+// Take last 3 lines before the completion point.
+unsigned RangeEnd = HeuristicPrefix.Qualifier.begin() - Content.data(),
+ RangeBegin = RangeEnd;
+for (size_t I = 0; I < 3 && RangeBegin > 0; ++I) {
+  auto PrevNL = Content.rfind('\n', RangeBegin - 1);
+  if (PrevNL == StringRef::npos) {
+RangeBegin = 0;
+break;
+  }
+  RangeBegin = PrevNL + 1;
+}
+
+ContextWords = collectWords(Content.slice(RangeBegin, RangeEnd));
+dlog("Completion context words: {0}",
+ llvm::join(ContextWords.keys(), ", "));
+  }
+
   // This is called by run() once Sema code completion is done, but before the
   // Sema data structures are torn down. It does all the real work.
   CodeCompleteResult runWithSema() {
@@ -1563,12 +1586,14 @@
 SymbolQualitySignals Quality;
 SymbolRelevanceSignals Relevance;
 Relevance.Context = CCContextKind;
+Relevance.Name = Bundle.front().Name;
 Relevance.Query = SymbolRelevanceSignals::CodeComplete;
 Relevance.FileProximityMatch = FileProximity.getPointer();

[PATCH] D61537: [clangd] Boost code completion results that were named in the last few lines.

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(doh, sorry - I thought this was accepted. Happy to revert, or try the lexer 
soon if you think it's important. Case-sensitive matching was still slightly 
negative within the noise)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61537



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


[PATCH] D61422: [clang-tidy] Extend bugprone-sizeof-expression check to detect sizeof misuse in pointer arithmetic

2019-05-06 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE360032: [clang-tidy] Extend bugprone-sizeof-expression 
check to detect sizeof misuse in… (authored by baloghadamsoftware, committed by 
).

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61422

Files:
  clang-tidy/bugprone/SizeofExpressionCheck.cpp
  test/clang-tidy/bugprone-sizeof-expression.cpp

Index: clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -84,8 +84,11 @@
   const auto IntegerCallExpr = expr(ignoringParenImpCasts(
   callExpr(anyOf(hasType(isInteger()), hasType(enumType())),
unless(isInTemplateInstantiation();
-  const auto SizeOfExpr =
-  expr(anyOf(sizeOfExpr(has(type())), sizeOfExpr(has(expr();
+  const auto SizeOfExpr = expr(anyOf(
+  sizeOfExpr(
+  has(hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type",
+  sizeOfExpr(has(expr(hasType(
+  hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type";
   const auto SizeOfZero = expr(
   sizeOfExpr(has(ignoringParenImpCasts(expr(integerLiteral(equals(0)));
 
@@ -209,6 +212,36 @@
hasSizeOfDescendant(8, expr(SizeOfExpr, unless(SizeOfZero
   .bind("sizeof-sizeof-expr"),
   this);
+
+  // Detect sizeof in pointer aritmetic like: N * sizeof(S) == P1 - P2 or
+  // (P1 - P2) / sizeof(S) where P1 and P2 are pointers to type S.
+  const auto PtrDiffExpr = binaryOperator(
+  hasOperatorName("-"),
+  hasLHS(expr(hasType(hasUnqualifiedDesugaredType(pointerType(pointee(
+  hasUnqualifiedDesugaredType(type().bind("left-ptr-type",
+  hasRHS(expr(hasType(hasUnqualifiedDesugaredType(pointerType(pointee(
+  hasUnqualifiedDesugaredType(type().bind("right-ptr-type");
+
+  Finder->addMatcher(
+  binaryOperator(
+  anyOf(hasOperatorName("=="), hasOperatorName("!="),
+hasOperatorName("<"), hasOperatorName("<="),
+hasOperatorName(">"), hasOperatorName(">="),
+hasOperatorName("+"), hasOperatorName("-")),
+  hasEitherOperand(expr(anyOf(
+  ignoringParenImpCasts(SizeOfExpr),
+  ignoringParenImpCasts(binaryOperator(
+  hasOperatorName("*"),
+  hasEitherOperand(ignoringParenImpCasts(SizeOfExpr))),
+  hasEitherOperand(ignoringParenImpCasts(PtrDiffExpr)))
+  .bind("sizeof-in-ptr-arithmetic-mul"),
+  this);
+
+  Finder->addMatcher(binaryOperator(hasOperatorName("/"),
+hasLHS(ignoringParenImpCasts(PtrDiffExpr)),
+hasRHS(ignoringParenImpCasts(SizeOfExpr)))
+ .bind("sizeof-in-ptr-arithmetic-div"),
+ this);
 }
 
 void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
@@ -275,6 +308,26 @@
   } else if (const auto *E =
  Result.Nodes.getNodeAs("sizeof-multiply-sizeof")) {
 diag(E->getBeginLoc(), "suspicious 'sizeof' by 'sizeof' multiplication");
+  } else if (const auto *E =
+ Result.Nodes.getNodeAs("sizeof-in-ptr-arithmetic-mul")) {
+const auto *LPtrTy = Result.Nodes.getNodeAs("left-ptr-type");
+const auto *RPtrTy = Result.Nodes.getNodeAs("right-ptr-type");
+const auto *SizeofArgTy = Result.Nodes.getNodeAs("sizeof-arg-type");
+
+if ((LPtrTy == RPtrTy) && (LPtrTy == SizeofArgTy)) {
+  diag(E->getBeginLoc(), "suspicious usage of 'sizeof(...)' in "
+  "pointer arithmetic");
+}
+  } else if (const auto *E =
+ Result.Nodes.getNodeAs("sizeof-in-ptr-arithmetic-div")) {
+const auto *LPtrTy = Result.Nodes.getNodeAs("left-ptr-type");
+const auto *RPtrTy = Result.Nodes.getNodeAs("right-ptr-type");
+const auto *SizeofArgTy = Result.Nodes.getNodeAs("sizeof-arg-type");
+
+if ((LPtrTy == RPtrTy) && (LPtrTy == SizeofArgTy)) {
+  diag(E->getBeginLoc(), "suspicious usage of 'sizeof(...)' in "
+  "pointer arithmetic");
+}
   }
 }
 
Index: test/clang-tidy/bugprone-sizeof-expression.cpp
===
--- test/clang-tidy/bugprone-sizeof-expression.cpp
+++ test/clang-tidy/bugprone-sizeof-expression.cpp
@@ -231,6 +231,35 @@
   return sum;
 }
 
+int Test6() {
+  int sum = 0;
+
+  struct S A = AsStruct(), B = AsStruct();
+  struct S *P = &A, *Q = &B;
+  sum += sizeof(struct S) == P - Q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)' in pointer arithmetic
+  sum += 5 * sizeof(S) != P - Q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)' in pointer arithmet

[clang-tools-extra] r360032 - [clang-tidy] Extend bugprone-sizeof-expression check to detect sizeof misuse in pointer arithmetic

2019-05-06 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Mon May  6 03:41:37 2019
New Revision: 360032

URL: http://llvm.org/viewvc/llvm-project?rev=360032&view=rev
Log:
[clang-tidy] Extend bugprone-sizeof-expression check to detect sizeof misuse in 
pointer arithmetic

Some programmers tend to forget that subtracting two pointers results in the
difference between them in number of elements of the pointee type instead of
bytes. This leads to codes such as `size_t size = (p - q) / sizeof(int)` where
`p` and `q` are of type `int*`. Or similarily, `if (p - q < buffer_size *
sizeof(int)) { ... }`. This patch extends `bugprone-sizeof-expression` to
detect such cases.

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


Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/SizeofExpressionCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-sizeof-expression.cpp

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/SizeofExpressionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/SizeofExpressionCheck.cpp?rev=360032&r1=360031&r2=360032&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/SizeofExpressionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/SizeofExpressionCheck.cpp Mon 
May  6 03:41:37 2019
@@ -84,8 +84,11 @@ void SizeofExpressionCheck::registerMatc
   const auto IntegerCallExpr = expr(ignoringParenImpCasts(
   callExpr(anyOf(hasType(isInteger()), hasType(enumType())),
unless(isInTemplateInstantiation();
-  const auto SizeOfExpr =
-  expr(anyOf(sizeOfExpr(has(type())), sizeOfExpr(has(expr();
+  const auto SizeOfExpr = expr(anyOf(
+  sizeOfExpr(
+  has(hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type",
+  sizeOfExpr(has(expr(hasType(
+  hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type";
   const auto SizeOfZero = expr(
   sizeOfExpr(has(ignoringParenImpCasts(expr(integerLiteral(equals(0)));
 
@@ -209,6 +212,36 @@ void SizeofExpressionCheck::registerMatc
hasSizeOfDescendant(8, expr(SizeOfExpr, 
unless(SizeOfZero
   .bind("sizeof-sizeof-expr"),
   this);
+
+  // Detect sizeof in pointer aritmetic like: N * sizeof(S) == P1 - P2 or
+  // (P1 - P2) / sizeof(S) where P1 and P2 are pointers to type S.
+  const auto PtrDiffExpr = binaryOperator(
+  hasOperatorName("-"),
+  hasLHS(expr(hasType(hasUnqualifiedDesugaredType(pointerType(pointee(
+  hasUnqualifiedDesugaredType(type().bind("left-ptr-type",
+  hasRHS(expr(hasType(hasUnqualifiedDesugaredType(pointerType(pointee(
+  hasUnqualifiedDesugaredType(type().bind("right-ptr-type");
+
+  Finder->addMatcher(
+  binaryOperator(
+  anyOf(hasOperatorName("=="), hasOperatorName("!="),
+hasOperatorName("<"), hasOperatorName("<="),
+hasOperatorName(">"), hasOperatorName(">="),
+hasOperatorName("+"), hasOperatorName("-")),
+  hasEitherOperand(expr(anyOf(
+  ignoringParenImpCasts(SizeOfExpr),
+  ignoringParenImpCasts(binaryOperator(
+  hasOperatorName("*"),
+  hasEitherOperand(ignoringParenImpCasts(SizeOfExpr))),
+  hasEitherOperand(ignoringParenImpCasts(PtrDiffExpr)))
+  .bind("sizeof-in-ptr-arithmetic-mul"),
+  this);
+
+  Finder->addMatcher(binaryOperator(hasOperatorName("/"),
+hasLHS(ignoringParenImpCasts(PtrDiffExpr)),
+hasRHS(ignoringParenImpCasts(SizeOfExpr)))
+ .bind("sizeof-in-ptr-arithmetic-div"),
+ this);
 }
 
 void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {
@@ -275,6 +308,26 @@ void SizeofExpressionCheck::check(const
   } else if (const auto *E =
  Result.Nodes.getNodeAs("sizeof-multiply-sizeof")) {
 diag(E->getBeginLoc(), "suspicious 'sizeof' by 'sizeof' multiplication");
+  } else if (const auto *E =
+ Result.Nodes.getNodeAs("sizeof-in-ptr-arithmetic-mul")) 
{
+const auto *LPtrTy = Result.Nodes.getNodeAs("left-ptr-type");
+const auto *RPtrTy = Result.Nodes.getNodeAs("right-ptr-type");
+const auto *SizeofArgTy = Result.Nodes.getNodeAs("sizeof-arg-type");
+
+if ((LPtrTy == RPtrTy) && (LPtrTy == SizeofArgTy)) {
+  diag(E->getBeginLoc(), "suspicious usage of 'sizeof(...)' in "
+  "pointer arithmetic");
+}
+  } else if (const auto *E =
+ Result.Nodes.getNodeAs("sizeof-in-ptr-arithmetic-div")) 
{
+const auto *LPtrTy = Result.Nodes.getNodeAs("left-ptr-type");
+const auto *RPtrTy = Result.Nodes.getNodeAs("right-ptr-type");
+const auto *SizeofArgTy = Result.Nodes.getNodeAs("sizeof-arg-type");
+
+if ((LPtrTy == RPtrTy) && (LPtrTy == SizeofArgTy)) {

[PATCH] D61588: [clangd] Expose whether no-compile completion was used.

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Embedding clients want to experiment with showing such results in e.g. a 
different color.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D61588

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/unittests/CodeCompleteTests.cpp


Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -235,6 +235,7 @@
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. The only items that must be present in after-dot
   // completion.
   EXPECT_THAT(Results.Completions,
@@ -284,6 +285,7 @@
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. Should never be present in global completions.
   EXPECT_THAT(Results.Completions,
   Not(AnyOf(Has("method"), Has("method()"), Has("field";
@@ -2459,6 +2461,7 @@
   ^
 }
   )cpp");
+  EXPECT_FALSE(Results.RanParser);
   EXPECT_THAT(Results.Completions,
   UnorderedElementsAre(Named("void"), Named("func"), Named("int"),
Named("xyz"), Named("abc")));
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -207,6 +207,9 @@
   std::vector Completions;
   bool HasMore = false;
   CodeCompletionContext::Kind Context = CodeCompletionContext::CCC_Other;
+  // Usually the source will be parsed with a real C++ parser.
+  // But heuristics may be used instead if e.g. the preamble is not ready.
+  bool RanParser = true;
 };
 raw_ostream &operator<<(raw_ostream &, const CodeCompleteResult &);
 
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1380,6 +1380,7 @@
 
 CodeCompleteResult Output = toCodeCompleteResult(mergeResults(
 /*SemaResults=*/{}, IndexResults, IdentifierResults));
+Output.RanParser = false;
 logResults(Output, Tracer);
 return Output;
   }


Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -235,6 +235,7 @@
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. The only items that must be present in after-dot
   // completion.
   EXPECT_THAT(Results.Completions,
@@ -284,6 +285,7 @@
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. Should never be present in global completions.
   EXPECT_THAT(Results.Completions,
   Not(AnyOf(Has("method"), Has("method()"), Has("field";
@@ -2459,6 +2461,7 @@
   ^
 }
   )cpp");
+  EXPECT_FALSE(Results.RanParser);
   EXPECT_THAT(Results.Completions,
   UnorderedElementsAre(Named("void"), Named("func"), Named("int"),
Named("xyz"), Named("abc")));
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -207,6 +207,9 @@
   std::vector Completions;
   bool HasMore = false;
   CodeCompletionContext::Kind Context = CodeCompletionContext::CCC_Other;
+  // Usually the source will be parsed with a real C++ parser.
+  // But heuristics may be used instead if e.g. the preamble is not ready.
+  bool RanParser = true;
 };
 raw_ostream &operator<<(raw_ostream &, const CodeCompleteResult &);
 
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1380,6 +1380,7 @@
 
 CodeCompleteResult Output = toCodeCompleteResult(mergeResults(
 /*SemaResults=*/{}, IndexResults, IdentifierResults));
+Output.RanParser = false;
 logResults(Output, Tracer);
 return Output;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61537: [clangd] Boost code completion results that were named in the last few lines.

2019-05-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Nah, it's ok. LGTM


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61537



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


[PATCH] D61588: [clangd] Expose whether no-compile completion was used.

2019-05-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

We already have `CodeCompletion::Origin` which is (at least should be)set to 
`Identifier` in those cases. Is there a reason for not using it?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61588



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


[PATCH] D60934: [clang] adding explicit(bool) from c++2a

2019-05-06 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

@Tyker This broke the Chromium build, could you investigate please? 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190506/270340.html


Repository:
  rC Clang

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

https://reviews.llvm.org/D60934



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


[PATCH] D60934: [clang] adding explicit(bool) from c++2a

2019-05-06 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

yes i am on it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60934



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


r360018 - Enable intrinsics of AVX512_BF16, which are supported for BFLOAT16 in Cooper Lake

2019-05-06 Thread via cfe-commits
Author: luoyuanke
Date: Mon May  6 01:25:11 2019
New Revision: 360018

URL: http://llvm.org/viewvc/llvm-project?rev=360018&view=rev
Log:
Enable intrinsics of AVX512_BF16, which are supported for BFLOAT16 in Cooper 
Lake

Summary:
1. Enable infrastructure of AVX512_BF16, which is supported for BFLOAT16 in 
Cooper Lake;
2. Enable intrinsics for VCVTNE2PS2BF16, VCVTNEPS2BF16 and DPBF16PS 
instructions, which are Vector Neural Network Instructions supporting BFLOAT16 
inputs and conversion instructions from IEEE single precision.
For more details about BF16 intrinsic, please refer to the latest ISE document: 
https://software.intel.com/en-us/download/intel-architecture-instruction-set-extensions-programming-reference

Patch by LiuTianle

Reviewers: craig.topper, smaslov, LuoYuanke, wxiao3, annita.zhang, spatel, 
RKSimon

Reviewed By: craig.topper

Subscribers: mgorny, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/X86.cpp
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/cpuid.h
cfe/trunk/lib/Headers/immintrin.h
cfe/trunk/test/CodeGen/attr-target-x86.c
cfe/trunk/test/Driver/x86-target-features.c
cfe/trunk/test/Preprocessor/x86_target_features.c

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=360018&r1=360017&r2=360018&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Mon May  6 01:25:11 2019
@@ -2610,6 +2610,8 @@ X86
 
 .. option:: -mavx512bitalg, -mno-avx512bitalg
 
+.. option:: -mavx512bf16, -mno-avx512bf16
+
 .. option:: -mavx512bw, -mno-avx512bw
 
 .. option:: -mavx512cd, -mno-avx512cd

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=360018&r1=360017&r2=360018&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon May  6 01:25:11 2019
@@ -1831,6 +1831,24 @@ TARGET_BUILTIN(__builtin_ia32_cvtusi2ss3
 TARGET_BUILTIN(__builtin_ia32_vpmultishiftqb512, "V64cV64cV64c", "ncV:512:", 
"avx512vbmi")
 TARGET_BUILTIN(__builtin_ia32_vpmultishiftqb128, "V16cV16cV16c", "ncV:128:", 
"avx512vbmi,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpmultishiftqb256, "V32cV32cV32c", "ncV:256:", 
"avx512vbmi,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtne2ps2bf16_128, "V8sV4fV4f", "ncV:128:",
+ "avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtne2ps2bf16_256, "V16sV8fV8f", "ncV:256:",
+ "avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtne2ps2bf16_512, "V32sV16fV16f", "ncV:512:",
+ "avx512bf16")
+TARGET_BUILTIN(__builtin_ia32_cvtneps2bf16_128_mask, "V8sV4fV8sUc", "ncV:128:",
+"avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtneps2bf16_256, "V8sV8f", "ncV:256:",
+"avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtneps2bf16_512, "V16sV16f", "ncV:512:",
+"avx512bf16")
+TARGET_BUILTIN(__builtin_ia32_dpbf16ps_128, "V4fV4fV4iV4i", "ncV:128:",
+"avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_dpbf16ps_256, "V8fV8fV8iV8i", "ncV:256:",
+"avx512bf16,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_dpbf16ps_512, "V16fV16fV16iV16i", "ncV:512:",
+"avx512bf16")
 
 // generic select intrinsics
 TARGET_BUILTIN(__builtin_ia32_selectb_128, "V16cUsV16cV16c", "ncV:128:", 
"avx512bw,avx512vl")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=360018&r1=360017&r2=360018&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon May  6 01:25:11 2019
@@ -2854,6 +2854,8 @@ def mavx2 : Flag<["-"], "mavx2">, Group<
 def mno_avx2 : Flag<["-"], "mno-avx2">, Group;
 def mavx512f : Flag<["-"], "mavx512f">, Group;
 def mno_avx512f : Flag<["-"], "mno-avx512f">, Group;
+def mavx512bf16 : Flag<["-"], "mavx512bf16">, Group;
+def mno_avx512bf16 : Flag<["-"], "mno-avx512bf16">, 
Group;
 def mavx512bit

[PATCH] D61566: Fix for bug 41747: AST Printer doesn't print nested name specifier for out of scope record definitions

2019-05-06 Thread Stepan Dyatkovskiy via Phabricator via cfe-commits
dyatkovskiy added a comment.

@jdenny ? @sepavloff ?
ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D61566



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


[PATCH] D61588: [clangd] Expose whether no-compile completion was used.

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D61588#1491728 , @kadircet wrote:

> We already have `CodeCompletion::Origin` which is (at least should be)set to 
> `Identifier` in those cases. Is there a reason for not using it?


I'd forgotten about that. A couple I can think of:

- it's for each result, they want a result-set level flag (including when there 
are no results, possibly *because* we didn't parse)
- identifier completion doesn't inherently mean we didn't parse, that's just 
the case today. I think we're going to want to offer identifiers inside 
comments, e.g. https://github.com/clangd/clangd/issues/44


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61588



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


[PATCH] D61588: [clangd] Expose whether no-compile completion was used.

2019-05-06 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 for the info. LGTM


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61588



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


[clang-tools-extra] r360039 - [clangd] Expose whether no-compile completion was used.

2019-05-06 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Mon May  6 05:03:26 2019
New Revision: 360039

URL: http://llvm.org/viewvc/llvm-project?rev=360039&view=rev
Log:
[clangd] Expose whether no-compile completion was used.

Summary: Embedding clients want to experiment with showing such results in e.g. 
a different color.

Reviewers: kadircet

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=360039&r1=360038&r2=360039&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Mon May  6 05:03:26 2019
@@ -1380,6 +1380,7 @@ public:
 
 CodeCompleteResult Output = toCodeCompleteResult(mergeResults(
 /*SemaResults=*/{}, IndexResults, IdentifierResults));
+Output.RanParser = false;
 logResults(Output, Tracer);
 return Output;
   }

Modified: clang-tools-extra/trunk/clangd/CodeComplete.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.h?rev=360039&r1=360038&r2=360039&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.h (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.h Mon May  6 05:03:26 2019
@@ -207,6 +207,9 @@ struct CodeCompleteResult {
   std::vector Completions;
   bool HasMore = false;
   CodeCompletionContext::Kind Context = CodeCompletionContext::CCC_Other;
+  // Usually the source will be parsed with a real C++ parser.
+  // But heuristics may be used instead if e.g. the preamble is not ready.
+  bool RanParser = true;
 };
 raw_ostream &operator<<(raw_ostream &, const CodeCompleteResult &);
 

Modified: clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp?rev=360039&r1=360038&r2=360039&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp Mon May  6 
05:03:26 2019
@@ -235,6 +235,7 @@ void TestAfterDotCompletion(clangd::Code
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. The only items that must be present in after-dot
   // completion.
   EXPECT_THAT(Results.Completions,
@@ -284,6 +285,7 @@ void TestGlobalScopeCompletion(clangd::C
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. Should never be present in global completions.
   EXPECT_THAT(Results.Completions,
   Not(AnyOf(Has("method"), Has("method()"), Has("field";
@@ -2459,6 +2461,7 @@ TEST(NoCompileCompletionTest, Basic) {
   ^
 }
   )cpp");
+  EXPECT_FALSE(Results.RanParser);
   EXPECT_THAT(Results.Completions,
   UnorderedElementsAre(Named("void"), Named("func"), Named("int"),
Named("xyz"), Named("abc")));


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


[PATCH] D61588: [clangd] Expose whether no-compile completion was used.

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE360039: [clangd] Expose whether no-compile completion was 
used. (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61588?vs=198246&id=198251#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61588

Files:
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/unittests/CodeCompleteTests.cpp


Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -235,6 +235,7 @@
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. The only items that must be present in after-dot
   // completion.
   EXPECT_THAT(Results.Completions,
@@ -284,6 +285,7 @@
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. Should never be present in global completions.
   EXPECT_THAT(Results.Completions,
   Not(AnyOf(Has("method"), Has("method()"), Has("field";
@@ -2459,6 +2461,7 @@
   ^
 }
   )cpp");
+  EXPECT_FALSE(Results.RanParser);
   EXPECT_THAT(Results.Completions,
   UnorderedElementsAre(Named("void"), Named("func"), Named("int"),
Named("xyz"), Named("abc")));
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -207,6 +207,9 @@
   std::vector Completions;
   bool HasMore = false;
   CodeCompletionContext::Kind Context = CodeCompletionContext::CCC_Other;
+  // Usually the source will be parsed with a real C++ parser.
+  // But heuristics may be used instead if e.g. the preamble is not ready.
+  bool RanParser = true;
 };
 raw_ostream &operator<<(raw_ostream &, const CodeCompleteResult &);
 
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1380,6 +1380,7 @@
 
 CodeCompleteResult Output = toCodeCompleteResult(mergeResults(
 /*SemaResults=*/{}, IndexResults, IdentifierResults));
+Output.RanParser = false;
 logResults(Output, Tracer);
 return Output;
   }


Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -235,6 +235,7 @@
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. The only items that must be present in after-dot
   // completion.
   EXPECT_THAT(Results.Completions,
@@ -284,6 +285,7 @@
   )cpp",
   {cls("IndexClass"), var("index_var"), func("index_func")}, Opts);
 
+  EXPECT_TRUE(Results.RanParser);
   // Class members. Should never be present in global completions.
   EXPECT_THAT(Results.Completions,
   Not(AnyOf(Has("method"), Has("method()"), Has("field";
@@ -2459,6 +2461,7 @@
   ^
 }
   )cpp");
+  EXPECT_FALSE(Results.RanParser);
   EXPECT_THAT(Results.Completions,
   UnorderedElementsAre(Named("void"), Named("func"), Named("int"),
Named("xyz"), Named("abc")));
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -207,6 +207,9 @@
   std::vector Completions;
   bool HasMore = false;
   CodeCompletionContext::Kind Context = CodeCompletionContext::CCC_Other;
+  // Usually the source will be parsed with a real C++ parser.
+  // But heuristics may be used instead if e.g. the preamble is not ready.
+  bool RanParser = true;
 };
 raw_ostream &operator<<(raw_ostream &, const CodeCompleteResult &);
 
Index: clangd/CodeComplete.cpp
===
--- clangd/CodeComplete.cpp
+++ clangd/CodeComplete.cpp
@@ -1380,6 +1380,7 @@
 
 CodeCompleteResult Output = toCodeCompleteResult(mergeResults(
 /*SemaResults=*/{}, IndexResults, IdentifierResults));
+Output.RanParser = false;
 logResults(Output, Tracer);
 return Output;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61589: [CodeComplete] Add a trailing semicolons to some pattern completions

2019-05-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: gribozavr.
Herald added a project: clang.

Where semicolon is required in any case. Here's a list of completions
that now have a semicolon:

- namespace  = ;
- using namespace ;
- using ::;
- continue;
- break;
- goto ;
- return;
- return ;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61589

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -21,7 +21,7 @@
   // CHECK-CC1-NEXT: COMPLETION: float
   // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo()
   // CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
-  // CHECK-CC1: COMPLETION: Pattern : goto <#label#>
+  // CHECK-CC1: COMPLETION: Pattern : goto <#label#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
   // CHECK-CC1: COMPLETION: int
   // CHECK-CC1-NEXT: COMPLETION: long
@@ -29,7 +29,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type#>[<#size#>](<#expressions#>)
   // CHECK-CC1-NEXT: COMPLETION: operator
   // CHECK-CC1-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>)
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : return
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : return;
   // CHECK-CC1-NEXT: COMPLETION: short
   // CHECK-CC1-NEXT: COMPLETION: signed
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
@@ -49,7 +49,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
   // CHECK-CC1-NEXT: COMPLETION: wchar_t
@@ -72,7 +72,7 @@
   // CHECK-CC2-NEXT: COMPLETION: int
   // CHECK-CC2-NEXT: COMPLETION: long
   // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#>{<#declarations#>
-  // CHECK-CC2: COMPLETION: Pattern : namespace <#name#> = <#namespace#>
+  // CHECK-CC2: COMPLETION: Pattern : namespace <#name#> = <#namespace#>;
   // CHECK-CC2-NEXT: COMPLETION: operator
   // CHECK-CC2-NEXT: COMPLETION: short
   // CHECK-CC2-NEXT: COMPLETION: signed
@@ -88,8 +88,8 @@
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
   // CHECK-CC2-NEXT: COMPLETION: wchar_t
@@ -125,7 +125,7 @@
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
-  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -190,7 +190,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: float
   // CHECK-NO-RTTI-NEXT: COMPLETION: foo : [#void#]foo()
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
-  // CHECK-NO-RTTI: COMPLETION: Pattern : goto <#label#>
+  // CHECK-NO-RTTI: COMPLETION: Pattern : goto <#label#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
   // CHECK-NO-RTTI: COMPLETION: int
   // CHECK-NO-RTTI-NEXT: COMPLETION: long
@@ -198,7 +198,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : new <#type#>[<#size#>](<#expressions#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: operator
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>)
-  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : return
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : return;
   // CHECK-NO-RTTI-NEXT: COMPLETION: short
   // CHECK-NO-RTTI-NEXT: COMPLETION: signed
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
@@ -218,7 +218,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
-  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identif

[PATCH] D61589: [CodeComplete] Add a trailing semicolons to some pattern completions

2019-05-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 198254.
ilya-biryukov added a comment.

- Add tests for 'continue;' and 'break;' completions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61589

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp
  clang/test/CodeCompletion/patterns.cpp

Index: clang/test/CodeCompletion/patterns.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/patterns.cpp
@@ -0,0 +1,39 @@
+void loops() {
+  while (true) {
+// line 3
+  }
+  for (;;) {
+// line 6
+  }
+  do {
+// line 9
+  } while (true);
+  // line 11
+}
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:3:1 %s -o - | FileCheck -check-prefix=LOOP %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:6:1 %s -o - | FileCheck -check-prefix=LOOP %s
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:9:1 %s -o - | FileCheck -check-prefix=LOOP %s
+// LOOP: COMPLETION: Pattern : break;{{$}}
+// LOOP: COMPLETION: Pattern : continue;{{$}}
+// LOOP: COMPLETION: Pattern : goto <#label#>;{{$}}
+// LOOP: COMPLETION: Pattern : return;{{$}}
+//
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:11:1 %s -o - | FileCheck -check-prefix=OUTSIDE-LOOP %s
+// OUTSIDE-LOOP-NOT: COMPLETION: Pattern : break;{{$}}
+// OUTSIDE-LOOP-NOT: COMPLETION: Pattern : continue;{{$}}
+// OUTSIDE-LOOP: COMPLETION: Pattern : goto <#label#>;{{$}}
+// OUTSIDE-LOOP: COMPLETION: Pattern : return;{{$}}
+
+int value_return() {
+  // line 28
+}
+void void_return() {
+  // line 31
+}
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:28:1 %s -o - | FileCheck -check-prefix=RETURN-VAL %s
+// RETURN-VAL-NOT: COMPLETION: Pattern : return;{{$}}
+// RETURN-VAL: COMPLETION: Pattern : return <#expression#>;{{$}}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:31:1 %s -o - | FileCheck -check-prefix=RETURN-VOID %s
+// RETURN-VOID-NOT: COMPLETION: Pattern : return <#expression#>;{{$}}
+// RETURN-VOID: COMPLETION: Pattern : return;{{$}}
Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -21,7 +21,7 @@
   // CHECK-CC1-NEXT: COMPLETION: float
   // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo()
   // CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
-  // CHECK-CC1: COMPLETION: Pattern : goto <#label#>
+  // CHECK-CC1: COMPLETION: Pattern : goto <#label#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
   // CHECK-CC1: COMPLETION: int
   // CHECK-CC1-NEXT: COMPLETION: long
@@ -29,7 +29,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type#>[<#size#>](<#expressions#>)
   // CHECK-CC1-NEXT: COMPLETION: operator
   // CHECK-CC1-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>)
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : return
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : return;
   // CHECK-CC1-NEXT: COMPLETION: short
   // CHECK-CC1-NEXT: COMPLETION: signed
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
@@ -49,7 +49,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
   // CHECK-CC1-NEXT: COMPLETION: wchar_t
@@ -72,7 +72,7 @@
   // CHECK-CC2-NEXT: COMPLETION: int
   // CHECK-CC2-NEXT: COMPLETION: long
   // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#>{<#declarations#>
-  // CHECK-CC2: COMPLETION: Pattern : namespace <#name#> = <#namespace#>
+  // CHECK-CC2: COMPLETION: Pattern : namespace <#name#> = <#namespace#>;
   // CHECK-CC2-NEXT: COMPLETION: operator
   // CHECK-CC2-NEXT: COMPLETION: short
   // CHECK-CC2-NEXT: COMPLETION: signed
@@ -88,8 +88,8 @@
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
   // CHECK-CC2-NEXT: COMPLETION:

[PATCH] D61591: [MinGW] Use SEH by default on AArch64

2019-05-06 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, efriedma, mgrang, ssijaric.
Herald added subscribers: kristof.beyls, javed.absar.
Herald added a project: clang.

The implementation of SEH is pretty mature at this point.


Repository:
  rC Clang

https://reviews.llvm.org/D61591

Files:
  lib/Driver/ToolChains/MinGW.cpp
  test/Driver/windows-exceptions.cpp


Index: test/Driver/windows-exceptions.cpp
===
--- test/Driver/windows-exceptions.cpp
+++ test/Driver/windows-exceptions.cpp
@@ -2,8 +2,8 @@
 // RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck 
-check-prefix=MSVC %s
 // RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-DWARF %s
 // RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-SEH %s
-// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-DWARF %s
-// RUN: %clang -target aarch64-windows-gnu -fseh-exceptions -c %s -### 2>&1 | 
FileCheck -check-prefix=MINGW-SEH %s
+// RUN: %clang -target aarch64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 
| FileCheck -check-prefix=MINGW-DWARF %s
+// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-SEH %s
 
 MSVC-NOT: -fdwarf-exceptions
 MSVC-NOT: -fseh-exceptions
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -442,7 +442,8 @@
   if (ExceptionArg &&
   ExceptionArg->getOption().matches(options::OPT_fseh_exceptions))
 return true;
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPICDefault() const {
@@ -457,7 +458,7 @@
 
 llvm::ExceptionHandling
 toolchains::MinGW::GetExceptionModel(const ArgList &Args) const {
-  if (getArch() == llvm::Triple::x86_64)
+  if (getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::aarch64)
 return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::DwarfCFI;
 }


Index: test/Driver/windows-exceptions.cpp
===
--- test/Driver/windows-exceptions.cpp
+++ test/Driver/windows-exceptions.cpp
@@ -2,8 +2,8 @@
 // RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck -check-prefix=MSVC %s
 // RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-DWARF %s
 // RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-SEH %s
-// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-DWARF %s
-// RUN: %clang -target aarch64-windows-gnu -fseh-exceptions -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-SEH %s
+// RUN: %clang -target aarch64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-DWARF %s
+// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-SEH %s
 
 MSVC-NOT: -fdwarf-exceptions
 MSVC-NOT: -fseh-exceptions
Index: lib/Driver/ToolChains/MinGW.cpp
===
--- lib/Driver/ToolChains/MinGW.cpp
+++ lib/Driver/ToolChains/MinGW.cpp
@@ -442,7 +442,8 @@
   if (ExceptionArg &&
   ExceptionArg->getOption().matches(options::OPT_fseh_exceptions))
 return true;
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPICDefault() const {
@@ -457,7 +458,7 @@
 
 llvm::ExceptionHandling
 toolchains::MinGW::GetExceptionModel(const ArgList &Args) const {
-  if (getArch() == llvm::Triple::x86_64)
+  if (getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::aarch64)
 return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::DwarfCFI;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360042 - [CodeComplete] Add a trailing semicolons to some pattern completions

2019-05-06 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon May  6 06:18:00 2019
New Revision: 360042

URL: http://llvm.org/viewvc/llvm-project?rev=360042&view=rev
Log:
[CodeComplete] Add a trailing semicolons to some pattern completions

Summary:
Where semicolon is required in any case. Here's a list of completions
that now have a semicolon:
  - namespace  = ;
  - using namespace ;
  - using ::;
  - continue;
  - break;
  - goto ;
  - return;
  - return ;

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeCompletion/patterns.cpp
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
cfe/trunk/test/CodeCompletion/ordinary-name.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=360042&r1=360041&r2=360042&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Mon May  6 06:18:00 2019
@@ -1923,6 +1923,7 @@ static void AddOrdinaryNameResults(Sema:
   Builder.AddPlaceholderChunk("name");
   Builder.AddChunk(CodeCompletionString::CK_Equal);
   Builder.AddPlaceholderChunk("namespace");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 
   // Using directives
@@ -1931,6 +1932,7 @@ static void AddOrdinaryNameResults(Sema:
   Builder.AddTextChunk("namespace");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("identifier");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 
   // asm(string-literal)
@@ -1965,6 +1967,7 @@ static void AddOrdinaryNameResults(Sema:
   Builder.AddPlaceholderChunk("qualifier");
   Builder.AddTextChunk("::");
   Builder.AddPlaceholderChunk("name");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 
   // using typename qualifier::name (only in a dependent context)
@@ -1976,6 +1979,7 @@ static void AddOrdinaryNameResults(Sema:
 Builder.AddPlaceholderChunk("qualifier");
 Builder.AddTextChunk("::");
 Builder.AddPlaceholderChunk("name");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
 Results.AddResult(Result(Builder.TakeString()));
   }
 
@@ -2165,12 +2169,14 @@ static void AddOrdinaryNameResults(Sema:
 if (S->getContinueParent()) {
   // continue ;
   Builder.AddTypedTextChunk("continue");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 }
 
 if (S->getBreakParent()) {
   // break ;
   Builder.AddTypedTextChunk("break");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 }
 
@@ -2189,12 +2195,14 @@ static void AddOrdinaryNameResults(Sema:
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("expression");
 }
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
 Results.AddResult(Result(Builder.TakeString()));
 
 // goto identifier ;
 Builder.AddTypedTextChunk("goto");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("label");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
 Results.AddResult(Result(Builder.TakeString()));
 
 // Using directives
@@ -2203,6 +2211,7 @@ static void AddOrdinaryNameResults(Sema:
 Builder.AddTextChunk("namespace");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("identifier");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
 Results.AddResult(Result(Builder.TakeString()));
 
 AddStaticAssertResult(Builder, Results, SemaRef.getLangOpts());

Modified: cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp?rev=360042&r1=360041&r2=360042&view=diff
==
--- cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp (original)
+++ cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp Mon May  6 06:18:00 
2019
@@ -23,7 +23,7 @@ void foo() {
   // CHECK-CC1-NEXT: COMPLETION: float
   // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo()
   // CHECK-CC1-NEXT: COMPLETION: Pattern : 
for(<#init-statement#>;<#condition#>;<#inc-expression#>){
-  // CHECK-CC1: COMPLETION: Pattern : goto <#label#>
+  // CHECK-CC1: COMPLETION: Pattern : goto <#label#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
   // CHECK-CC

[PATCH] D61592: [AArch64] Add __builtin_sponentry, for calling setjmp in MinGW

2019-05-06 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, efriedma, mgrang, ssijaric.
Herald added subscribers: kristina, kristof.beyls, javed.absar.
Herald added a project: clang.

In MinGW, setjmp isn't expanded as a builtin in the compiler (like it is for 
MSVC), but manually hooked up as calls to the right underlying functions in 
headers. Using the actual CRT's real setjmp/longjmp functions requires this 
intrinsic. (Currently this is worked around by using MinGW specific 
reimplementations of setjmp/longjmp on aarch64.)


Repository:
  rC Clang

https://reviews.llvm.org/D61592

Files:
  include/clang/Basic/BuiltinsAArch64.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtin-sponentry.c


Index: test/CodeGen/builtin-sponentry.c
===
--- /dev/null
+++ test/CodeGen/builtin-sponentry.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple aarch64-windows-gnu -Oz -emit-llvm %s -o - | 
FileCheck %s
+
+void *test_sponentry() {
+  return __builtin_sponentry();
+}
+// CHECK-LABEL: define dso_local i8* @test_sponentry()
+// CHECK: = tail call i8* @llvm.sponentry()
+// CHECK: ret i8*
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7233,6 +7233,11 @@
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI__builtin_sponentry) {
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::sponentry);
+return Builder.CreateCall(F);
+  }
+
   // Find out if any arguments are required to be integer constant
   // expressions.
   unsigned ICEArguments = 0;
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -86,6 +86,9 @@
 LANGBUILTIN(__sev,   "v", "",   ALL_MS_LANGUAGES)
 LANGBUILTIN(__sevl,  "v", "",   ALL_MS_LANGUAGES)
 
+// Misc
+BUILTIN(__builtin_sponentry, "v*", "c")
+
 TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanReverse, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")


Index: test/CodeGen/builtin-sponentry.c
===
--- /dev/null
+++ test/CodeGen/builtin-sponentry.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple aarch64-windows-gnu -Oz -emit-llvm %s -o - | FileCheck %s
+
+void *test_sponentry() {
+  return __builtin_sponentry();
+}
+// CHECK-LABEL: define dso_local i8* @test_sponentry()
+// CHECK: = tail call i8* @llvm.sponentry()
+// CHECK: ret i8*
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7233,6 +7233,11 @@
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI__builtin_sponentry) {
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::sponentry);
+return Builder.CreateCall(F);
+  }
+
   // Find out if any arguments are required to be integer constant
   // expressions.
   unsigned ICEArguments = 0;
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -86,6 +86,9 @@
 LANGBUILTIN(__sev,   "v", "",   ALL_MS_LANGUAGES)
 LANGBUILTIN(__sevl,  "v", "",   ALL_MS_LANGUAGES)
 
+// Misc
+BUILTIN(__builtin_sponentry, "v*", "c")
+
 TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanReverse, "UcUNi*UNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61589: [CodeComplete] Add a trailing semicolons to some pattern completions

2019-05-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360042: [CodeComplete] Add a trailing semicolons to some 
pattern completions (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61589?vs=198254&id=198259#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61589

Files:
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
  cfe/trunk/test/CodeCompletion/ordinary-name.cpp
  cfe/trunk/test/CodeCompletion/patterns.cpp

Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -1923,6 +1923,7 @@
   Builder.AddPlaceholderChunk("name");
   Builder.AddChunk(CodeCompletionString::CK_Equal);
   Builder.AddPlaceholderChunk("namespace");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 
   // Using directives
@@ -1931,6 +1932,7 @@
   Builder.AddTextChunk("namespace");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("identifier");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 
   // asm(string-literal)
@@ -1965,6 +1967,7 @@
   Builder.AddPlaceholderChunk("qualifier");
   Builder.AddTextChunk("::");
   Builder.AddPlaceholderChunk("name");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 
   // using typename qualifier::name (only in a dependent context)
@@ -1976,6 +1979,7 @@
 Builder.AddPlaceholderChunk("qualifier");
 Builder.AddTextChunk("::");
 Builder.AddPlaceholderChunk("name");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
 Results.AddResult(Result(Builder.TakeString()));
   }
 
@@ -2165,12 +2169,14 @@
 if (S->getContinueParent()) {
   // continue ;
   Builder.AddTypedTextChunk("continue");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 }
 
 if (S->getBreakParent()) {
   // break ;
   Builder.AddTypedTextChunk("break");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 }
 
@@ -2189,12 +2195,14 @@
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("expression");
 }
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
 Results.AddResult(Result(Builder.TakeString()));
 
 // goto identifier ;
 Builder.AddTypedTextChunk("goto");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("label");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
 Results.AddResult(Result(Builder.TakeString()));
 
 // Using directives
@@ -2203,6 +2211,7 @@
 Builder.AddTextChunk("namespace");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
 Builder.AddPlaceholderChunk("identifier");
+Builder.AddChunk(CodeCompletionString::CK_SemiColon);
 Results.AddResult(Result(Builder.TakeString()));
 
 AddStaticAssertResult(Builder, Results, SemaRef.getLangOpts());
Index: cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
===
--- cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -23,7 +23,7 @@
   // CHECK-CC1-NEXT: COMPLETION: float
   // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo()
   // CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){
-  // CHECK-CC1: COMPLETION: Pattern : goto <#label#>
+  // CHECK-CC1: COMPLETION: Pattern : goto <#label#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#>
   // CHECK-CC1: COMPLETION: int
   // CHECK-CC1-NEXT: COMPLETION: long
@@ -33,7 +33,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::nullptr_t#]nullptr
   // CHECK-CC1-NEXT: COMPLETION: operator
   // CHECK-CC1-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type#>>(<#expression#>)
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : return
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : return;
   // CHECK-CC1-NEXT: COMPLETION: short
   // CHECK-CC1-NEXT: COMPLETION: signed
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#size_t#]sizeof(<#expression-or-type#>)
@@ -56,7 +56,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespa

[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-05-06 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added a comment.

In D61046#1486850 , @rnk wrote:

> The only remaining change I find questionable is the R600 backend change


creduce'd and reported here: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63477#c4 - it is still present 
with GCC 9.1


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

https://reviews.llvm.org/D61046



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


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-05-06 Thread Alexandre Ganea via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360044: Fix compilation warnings when compiling with GCC 7.3 
(authored by aganea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61046?vs=196655&id=198265#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61046

Files:
  llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
  llvm/trunk/unittests/IR/ConstantRangeTest.cpp
  llvm/trunk/unittests/Support/TypeTraitsTest.cpp
  llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
  llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
===
--- llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
+++ llvm/trunk/lib/Target/AMDGPU/R600ISelLowering.cpp
@@ -1714,6 +1714,12 @@
 
 if (NewBldVec[i].isUndef())
   continue;
+// Fix spurious warning with gcc 7.3 -O3
+//warning: array subscript is above array bounds [-Warray-bounds]
+//if (NewBldVec[i] == NewBldVec[j]) {
+//~~~^
+if (i >= 4)
+  continue;
 for (unsigned j = 0; j < i; j++) {
   if (NewBldVec[i] == NewBldVec[j]) {
 NewBldVec[i] = DAG.getUNDEF(NewBldVec[i].getValueType());
Index: llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
===
--- llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
+++ llvm/trunk/unittests/Transforms/Scalar/CMakeLists.txt
@@ -10,3 +10,8 @@
 add_llvm_unittest(ScalarTests
   LoopPassManagerTest.cpp
   )
+
+# Workaround for the gcc 6.1 bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80916.
+if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
+  set_source_files_properties(LoopPassManagerTest.cpp PROPERTIES COMPILE_FLAGS -Wno-unused-function)
+endif()
Index: llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/trunk/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -20,19 +20,9 @@
 #include "llvm/IR/PassManager.h"
 #include "llvm/Support/SourceMgr.h"
 
-// Workaround for the gcc 6.1 bug PR80916.
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic push
-#  pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
-#if defined(__GNUC__) && __GNUC__ > 5
-#  pragma GCC diagnostic pop
-#endif
-
 using namespace llvm;
 
 namespace {
Index: llvm/trunk/unittests/Support/TypeTraitsTest.cpp
===
--- llvm/trunk/unittests/Support/TypeTraitsTest.cpp
+++ llvm/trunk/unittests/Support/TypeTraitsTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "llvm/Support/type_traits.h"
+#include "gtest/gtest.h"
 
 namespace {
 
@@ -71,6 +72,26 @@
 template void TrivialityTester();
 template void TrivialityTester();
 
+TEST(Triviality, Tester) {
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+  TrivialityTester();
+}
+
 } // namespace triviality
 
 } // end anonymous namespace
Index: llvm/trunk/unittests/IR/ConstantRangeTest.cpp
===
--- llvm/trunk/unittests/IR/ConstantRangeTest.cpp
+++ llvm/trunk/unittests/IR/ConstantRangeTest.cpp
@@ -459,6 +459,7 @@
   }
 }
 
+(void)HaveInterrupt3;
 assert(!HaveInterrupt3 && "Should have at most three ranges");
 
 ConstantRange SmallestCR = OpFn(CR1, CR2, ConstantRange::Smallest);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61496: Fixed tests where grep was not matching the linefeed

2019-05-06 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea marked an inline comment as done.
aganea added inline comments.



Comment at: clang/trunk/test/Preprocessor/indent_macro.c:1-2
-// RUN: %clang_cc1 -E %s | grep '^   zzap$'
+// RUN: %clang_cc1 -E %s | FileCheck %s --match-full-lines --strict-whitespace
+// CHECK:   zzap
 

lebedev.ri wrote:
> Separate with newline
What do you mean? Between RUN and CHECK? There's already a newline a L3.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61496



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


[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

2019-05-06 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D61509#1491537 , @lebedev.ri wrote:

> In D61509#1491397 , @jdenny wrote:
>
> > In D61509#1491209 , @ABataev wrote:
> >
> > > In D61509#1491204 , @lebedev.ri 
> > > wrote:
> > >
> > > > In D61509#1491158 , @jdenny 
> > > > wrote:
> > > >
> > > > > In D61509#1491119 , 
> > > > > @lebedev.ri wrote:
> > > > >
> > > > > > I recommend to split this into two parts - changing 
> > > > > > `PragmaIntroducerKind Introducer` to
> > > > > >  `struct NameMe { PragmaIntroducerKind Kind; SourceLocation Loc};`, 
> > > > > > and the actual openmp change.
> > > > >
> > > > >
> > > > > Sure, I'll work on that.  What about NameMe = PragmaIntroducer?
> > > >
> > > >
> > > > Could work. And then move `PragmaIntroducerKind` into it.
> > > >  I believe this part of the refactoring is completely uncontroversial.
> > > >
> > > > >> For that change, just basing off the clang-tidy diff, neither 
> > > > >> variant is ideal,
> > > > > 
> > > > > Do you mean that it's better for diagnostics that point to a pragma 
> > > > > not to include the `#pragma` in their locations?  If so, why is that?
> > > >
> > > > I'm not sure either one is better than the other one.
> > > >
> > > > I have two concerns:
> > > >
> > > > - I fear this would result in inconsistency with other pragmas, since 
> > > > this will only change openmp-ones. I don't know if it will be accepted 
> > > > to migrate the rest of them in the same way.
> > > > - This use-case requires having the location of `#pragma`, so the 
> > > > entire AST is migrating to store it. But the current location will no 
> > > > longer be accessible from AST.
> > > >
> > > >   I see two paths forward:
> > > > - Mail cfe-dev, and suggest to do this change for *all* pragmas. Either 
> > > > this is ok for all of them, or none of them.
> > > > - Moar abstractions - how about **not** changing the startloc of openmp 
> > > > directives,
> > >
> >
> >
> > My alternative proposal was exactly that.  A difficulty is how to pass the 
> > `#pragma` location to the OpenMP AST node constructors.  
> > `PragmaOpenMPHandler::HandlePragma` passes locations via the 
> > `tok::annot_pragma_openmp` and `tok::annot_pragma_openmp_end` tokens, so 
> > where do we pass this new location?  I proposed creating a third token, and 
> > Alexey was concerned over the parsing problems that would create.
> >
> > >>   but instead add some baseclass to `OMPDirective` class (& every other 
> > >> class that is created from pragma), that would record the 
> > >> `PragmaIntroducer`?
> >
> > I agree that a base class would be a nice way to extend all pragma classes 
> > with the `PragmaIntroducer`.
> >
> > > I'm against this solution. I don't see any reasons why we should do this. 
> > > Instead, we're getting a lot of pain with parsing and maintenance.
> >
> > One way to avoid creating an extra token would be to widen the `Token` 
> > class to store the additional location.  The `Token` documentation says 
> > it's not intended to be space efficient.  How does that sound to people?
>
>
> That was my proposal, yes.


@ABataev : Does that address your concerns?


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

https://reviews.llvm.org/D61509



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


[PATCH] D61596: [clangd] Move Rename into its own file, and add unit test. NFC

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, jfb, arphaman, jkorous, MaskRay, 
ilya-biryukov, mgorny.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D61596

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/refactor/Rename.cpp
  clangd/refactor/Rename.h
  clangd/unittests/CMakeLists.txt
  clangd/unittests/RenameTests.cpp

Index: clangd/unittests/RenameTests.cpp
===
--- /dev/null
+++ clangd/unittests/RenameTests.cpp
@@ -0,0 +1,47 @@
+//===-- RenameTests.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "TestFS.h"
+#include "TestTU.h"
+#include "refactor/Rename.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "gtest/gtest.h"
+#include "gmock/gmock.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TEST(RenameTest, SingleFile) {
+  Annotations Code(R"cpp(
+void foo() {
+  fo^o();
+}
+  )cpp");
+  auto TU = TestTU::withCode(Code.code());
+  TU.HeaderCode = "void foo();"; // outside main file, will not be touched.
+
+  auto AST = TU.build();
+  auto RenameResult =
+  renameWithinFile(AST, testPath(TU.Filename), Code.point(), "abcde");
+  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
+  auto ApplyResult = tooling::applyAllReplacements(Code.code(), *RenameResult);
+  ASSERT_TRUE(bool(ApplyResult)) << ApplyResult.takeError();
+
+  const char* Want = R"cpp(
+void abcde() {
+  abcde();
+}
+  )cpp";
+  EXPECT_EQ(Want, *ApplyResult);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clangd/unittests/CMakeLists.txt
===
--- clangd/unittests/CMakeLists.txt
+++ clangd/unittests/CMakeLists.txt
@@ -48,6 +48,7 @@
   JSONTransportTests.cpp
   PrintASTTests.cpp
   QualityTests.cpp
+  RenameTests.cpp
   RIFFTests.cpp
   SelectionTests.cpp
   SerializationTests.cpp
Index: clangd/refactor/Rename.h
===
--- /dev/null
+++ clangd/refactor/Rename.h
@@ -0,0 +1,24 @@
+//===--- Rename.h - Symbol-rename refactorings ---*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ClangdUnit.h"
+#include "llvm/Support/Error.h"
+#include "clang/Tooling/Core/Replacement.h"
+
+namespace clang {
+namespace clangd {
+
+/// Renames all occurrences of the symbol at \p Pos to \p NewName.
+/// Occurrences outside the current file are not modified.
+llvm::Expected renameWithinFile(ParsedAST &AST,
+   llvm::StringRef File,
+   Position Pos,
+   llvm::StringRef NewName);
+
+} // namespace clangd
+} // namespace clang
Index: clangd/refactor/Rename.cpp
===
--- /dev/null
+++ clangd/refactor/Rename.cpp
@@ -0,0 +1,79 @@
+#include "refactor/Rename.h"
+#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
+#include "clang/Tooling/Refactoring/Rename/RenamingAction.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+class RefactoringResultCollector final
+: public tooling::RefactoringResultConsumer {
+public:
+  void handleError(llvm::Error Err) override {
+assert(!Result.hasValue());
+Result = std::move(Err);
+  }
+
+  // Using the handle(SymbolOccurrences) from parent class.
+  using tooling::RefactoringResultConsumer::handle;
+
+  void handle(tooling::AtomicChanges SourceReplacements) override {
+assert(!Result.hasValue());
+Result = std::move(SourceReplacements);
+  }
+
+  llvm::Optional> Result;
+};
+
+// Expand a DiagnosticError to make it print-friendly (print the detailed
+// message, rather than "clang diagnostic").
+llvm::Error expandDiagnostics(llvm::Error Err, DiagnosticsEngine &DE) {
+  if (auto Diag = DiagnosticError::take(Err)) {
+llvm::cantFail(std::move(Err));
+SmallVector DiagMessage;
+Diag->second.EmitToString(DE, DiagMessage);
+return llvm::make_error(DiagMessage,
+   llvm::inconvertibleErrorCode());
+  }
+  return Err;
+}
+
+} // namespace
+
+llvm::Expected
+renameWithinFile(Pa

[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

2019-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D61509#1491397 , @jdenny wrote:

> In D61509#1491209 , @ABataev wrote:
>
> > In D61509#1491204 , @lebedev.ri 
> > wrote:
> >
> > > In D61509#1491158 , @jdenny 
> > > wrote:
> > >
> > > > In D61509#1491119 , 
> > > > @lebedev.ri wrote:
> > > >
> > > > > I recommend to split this into two parts - changing 
> > > > > `PragmaIntroducerKind Introducer` to
> > > > >  `struct NameMe { PragmaIntroducerKind Kind; SourceLocation Loc};`, 
> > > > > and the actual openmp change.
> > > >
> > > >
> > > > Sure, I'll work on that.  What about NameMe = PragmaIntroducer?
> > >
> > >
> > > Could work. And then move `PragmaIntroducerKind` into it.
> > >  I believe this part of the refactoring is completely uncontroversial.
> > >
> > > >> For that change, just basing off the clang-tidy diff, neither variant 
> > > >> is ideal,
> > > > 
> > > > Do you mean that it's better for diagnostics that point to a pragma not 
> > > > to include the `#pragma` in their locations?  If so, why is that?
> > >
> > > I'm not sure either one is better than the other one.
> > >
> > > I have two concerns:
> > >
> > > - I fear this would result in inconsistency with other pragmas, since 
> > > this will only change openmp-ones. I don't know if it will be accepted to 
> > > migrate the rest of them in the same way.
> > > - This use-case requires having the location of `#pragma`, so the entire 
> > > AST is migrating to store it. But the current location will no longer be 
> > > accessible from AST.
> > >
> > >   I see two paths forward:
> > > - Mail cfe-dev, and suggest to do this change for *all* pragmas. Either 
> > > this is ok for all of them, or none of them.
> > > - Moar abstractions - how about **not** changing the startloc of openmp 
> > > directives,
> >
>
>
> My alternative proposal was exactly that.  A difficulty is how to pass the 
> `#pragma` location to the OpenMP AST node constructors.  
> `PragmaOpenMPHandler::HandlePragma` passes locations via the 
> `tok::annot_pragma_openmp` and `tok::annot_pragma_openmp_end` tokens, so 
> where do we pass this new location?  I proposed creating a third token, and 
> Alexey was concerned over the parsing problems that would create.
>
> >>   but instead add some baseclass to `OMPDirective` class (& every other 
> >> class that is created from pragma), that would record the 
> >> `PragmaIntroducer`?
>
> I agree that a base class would be a nice way to extend all pragma classes 
> with the `PragmaIntroducer`.
>
> > I'm against this solution. I don't see any reasons why we should do this. 
> > Instead, we're getting a lot of pain with parsing and maintenance.
>
> One way to avoid creating an extra token would be to widen the `Token` class 
> to store the additional location.  The `Token` documentation says it's not 
> intended to be space efficient.  How does that sound to people?


Again, I don't see a single point why would we need this. I don't think there 
is a big difference between the location of pragma keyword and `omp` keyword.

In D61509#1491882 , @jdenny wrote:

> In D61509#1491537 , @lebedev.ri 
> wrote:
>
> > In D61509#1491397 , @jdenny wrote:
> >
> > > In D61509#1491209 , @ABataev 
> > > wrote:
> > >
> > > > In D61509#1491204 , 
> > > > @lebedev.ri wrote:
> > > >
> > > > > In D61509#1491158 , @jdenny 
> > > > > wrote:
> > > > >
> > > > > > In D61509#1491119 , 
> > > > > > @lebedev.ri wrote:
> > > > > >
> > > > > > > I recommend to split this into two parts - changing 
> > > > > > > `PragmaIntroducerKind Introducer` to
> > > > > > >  `struct NameMe { PragmaIntroducerKind Kind; SourceLocation 
> > > > > > > Loc};`, and the actual openmp change.
> > > > > >
> > > > > >
> > > > > > Sure, I'll work on that.  What about NameMe = PragmaIntroducer?
> > > > >
> > > > >
> > > > > Could work. And then move `PragmaIntroducerKind` into it.
> > > > >  I believe this part of the refactoring is completely uncontroversial.
> > > > >
> > > > > >> For that change, just basing off the clang-tidy diff, neither 
> > > > > >> variant is ideal,
> > > > > > 
> > > > > > Do you mean that it's better for diagnostics that point to a pragma 
> > > > > > not to include the `#pragma` in their locations?  If so, why is 
> > > > > > that?
> > > > >
> > > > > I'm not sure either one is better than the other one.
> > > > >
> > > > > I have two concerns:
> > > > >
> > > > > - I fear this would result in inconsistency with other pragmas, since 
> > > > > this will only change openmp-ones. I don't know if it will 

[PATCH] D61497: [clangd] Introduce a structured hover response

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Layering and such looks good. This should compose well with D58547 





Comment at: clang-tools-extra/clangd/XRefs.h:52
+struct HoverInfo {
+  LocatedSymbol Sym;
+  /// Name of the context containing the symbol.

I'm not sure about reuse of LocatedSymbol - do we want to commit to returning 
decl/def locations?
Name might be enough here.



Comment at: clang-tools-extra/clangd/XRefs.h:54
+  /// Name of the context containing the symbol.
+  std::string ContainerName;
+  index::SymbolInfo SI;

This comes from LSP, and within the scope of C++ I think we might want stronger 
semantics here.
I think it's likely we actually want to show namespace vs class scope 
differently, too - maybe these should be separate fields?



Comment at: clang-tools-extra/clangd/XRefs.h:55
+  std::string ContainerName;
+  index::SymbolInfo SI;
+  /// Includes all the qualifiers.

SymbolInfo is a bit of a mess. Maybe we just want SymbolInfo::Kind? (LSP 
SymbolKind is tempting but loses a lot of info for C++).

I do think we'll need to extend SymbolInfo::Kind or eventually use our own 
enum, e.g. lambdas may need their own kind (they're variables, but don't have a 
printable type and need to be displayed more like functions)



Comment at: clang-tools-extra/clangd/XRefs.h:57
+  /// Includes all the qualifiers.
+  std::string Type;
+  /// Empty for non-functions. First element is the return type.

I think we probably want a struct to represent types, so we can annotate it 
with links later on if needed. (because type can be e.g. `mytemplate`). 
This wouldn't matter except we should probably reuse it...



Comment at: clang-tools-extra/clangd/XRefs.h:57
+  /// Includes all the qualifiers.
+  std::string Type;
+  /// Empty for non-functions. First element is the return type.

sammccall wrote:
> I think we probably want a struct to represent types, so we can annotate it 
> with links later on if needed. (because type can be e.g. 
> `mytemplate`). This wouldn't matter except we should probably reuse 
> it...
we may want ReturnType too (unless you want to overload Type for that - I'd 
suggest against it because of e.g. lambdas)



Comment at: clang-tools-extra/clangd/XRefs.h:59
+  /// Empty for non-functions. First element is the return type.
+  std::vector Signature;
+  std::string Documentation;

maybe `vector` params, where param is `struct { string name; Type type 
}`?

We might render as:

***
**Parameters**:
  - **value**: `std::string`
  -  **size**: `int` (default = `0`)



Comment at: clang-tools-extra/clangd/XRefs.h:63
+  std::string Definition;
+  std::string TemplateArgs;
+};

TemplateArgs might want to follow the same structure as params?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61497



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:10364
+  if (const auto *FD = dyn_cast(D)) {
+if (OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(FD)) {
+  HasEmittedDeclareTargetRegion = true;

gtbercea wrote:
> ABataev wrote:
> > ABataev wrote:
> > > No need for the braces
> > What if `declare target` is used only for variabes but not for the 
> > functions?
> Even more reason to error in that case since it may contain clauses like link 
> or to which need for requires directives to be used consistently.
But I don't see that your patch works in this situation. Currently, it will 
emit the error only if the declare target function is found, no?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D61596: [clangd] Move Rename into its own file, and add unit test. NFC

2019-05-06 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.

LGTM




Comment at: clangd/ClangdServer.cpp:264
   Callback> CB) {
-  auto Action = [Pos](Path File, std::string NewName,
+  auto Action = [Pos](std::string File, std::string NewName,
   Callback> CB,

Why change Path to std::string ?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61596



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


r360048 - [CodeComplete] Update python tests after r360042

2019-05-06 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon May  6 07:56:24 2019
New Revision: 360048

URL: http://llvm.org/viewvc/llvm-project?rev=360048&view=rev
Log:
[CodeComplete] Update python tests after r360042

Modified:
cfe/trunk/bindings/python/tests/cindex/test_code_completion.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_code_completion.py?rev=360048&r1=360047&r2=360048&view=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py Mon May  6 
07:56:24 2019
@@ -41,7 +41,7 @@ void f() {
 expected = [
   "{'int', ResultType} | {'test1', TypedText} || Priority: 50 || 
Availability: Available || Brief comment: Aaa.",
   "{'void', ResultType} | {'test2', TypedText} | {'(', LeftParen} | 
{')', RightParen} || Priority: 50 || Availability: Available || Brief comment: 
Bbb.",
-  "{'return', TypedText} || Priority: 40 || Availability: Available || 
Brief comment: None"
+  "{'return', TypedText} | {';', SemiColon} || Priority: 40 || 
Availability: Available || Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 
@@ -67,7 +67,7 @@ void f() {
 expected = [
   "{'int', ResultType} | {'test1', TypedText} || Priority: 50 || 
Availability: Available || Brief comment: Aaa.",
   "{'void', ResultType} | {'test2', TypedText} | {'(', LeftParen} | 
{')', RightParen} || Priority: 50 || Availability: Available || Brief comment: 
Bbb.",
-  "{'return', TypedText} || Priority: 40 || Availability: Available || 
Brief comment: None"
+  "{'return', TypedText} | {';', SemiColon} || Priority: 40 || 
Availability: Available || Brief comment: None"
 ]
 self.check_completion_results(cr, expected)
 


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


[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

2019-05-06 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D61509#1491898 , @ABataev wrote:

> Again, I don't see a single point why would we need this. I don't think there 
> is a big difference between the location of pragma keyword and `omp` keyword.


@lebedev.ri : You said you're not sure changing the current start location 
would matter for diagnostics, but do you believe we need to be concerned about 
backward compatibility here for `Rewriter` users?

> Annotation tokens already have extra locations. Do you need the third one?

Some pragmas already use that extra location.  Roman suggested consistency 
among all pragmas, and it would be nice if they stored the `#pragma` location 
in a consistent manner.

> Plus, how you're going to store this location in the AST? We don't need any 
> extra base classes. If you want to store this in AST nodes, add a new field 
> to the existing classes and extended constructors/Create/(de-)serialization 
> functions.

If we're just adjusting OpenMP, I agree.  However, Roman suggested consistency 
among all pragmas, and I thought the base clase would make that easier.


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

https://reviews.llvm.org/D61509



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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Headers/__clang_cuda_cmath.h:54
 __DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); }
+#ifndef _OPENMP
 __DEVICE__ int fpclassify(float __x) {

Why we have this guard here? It does not work for OpenMP? Why?



Comment at: lib/Headers/__clang_cuda_device_functions.h:49
+#if defined(__cplusplus)
 __DEVICE__ void __brkpt(int __a) { __brkpt(); }
+#endif

Can we do anything with this in С mode? I mean, to allow it in C.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399



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


[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

2019-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D61509#1491979 , @jdenny wrote:

> In D61509#1491898 , @ABataev wrote:
>
> > Again, I don't see a single point why would we need this. I don't think 
> > there is a big difference between the location of pragma keyword and `omp` 
> > keyword.
>
>
> @lebedev.ri : You said you're not sure changing the current start location 
> would matter for diagnostics, but do you believe we need to be concerned 
> about backward compatibility here for `Rewriter` users?


For diagnostics, we don't use the location of `#pragma` or `omp` keywords 
often. If the diagnostic must be emitted for the whole pragma, it would be 
better to emit it for `#pragma` keyword, not `omp` keyword. I don't think there 
any rewriter users for OpenMP. Plus, if the problem exist (we point to `omp` 
keyword rather tan `#pragma`) better to fix this, if you can.

> 
> 
>> Annotation tokens already have extra locations. Do you need the third one?
> 
> Some pragmas already use that extra location.  Roman suggested consistency 
> among all pragmas, and it would be nice if they stored the `#pragma` location 
> in a consistent manner.

That was just a suggestion. YOu'd better to dicuss this with @rsmith.

>> Plus, how you're going to store this location in the AST? We don't need any 
>> extra base classes. If you want to store this in AST nodes, add a new field 
>> to the existing classes and extended constructors/Create/(de-)serialization 
>> functions.
> 
> If we're just adjusting OpenMP, I agree.  However, Roman suggested 
> consistency among all pragmas, and I thought the base clase would make that 
> easier.

Handling of other pragmas is completely different story. From OpenMP 
implementation point of view, we'll ned to store this extra location somewhere 
in the AST nodes for OpenMP. And you will need to do this for all the OpenMP 
pragmas (executable and declarative). If you're ging to store this location in 
AST nodes for OpenMP pragmas, I suggest not to add the new base class, but just 
extend the existing classes with the new data member for the location of the 
`#pragma` keyword.


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

https://reviews.llvm.org/D61509



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


[PATCH] D60605: [clangd] Revamp textDocument/onTypeFormatting.

2019-05-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Sorry for the delay, I'll make sure to take a close look at the change tomorrow.

As mentioned in offline discussions, doing this through `clang-format` seems 
like the right approach. At the same the markers we put into the files to drive 
formatting seem fragile, giving results we don't want.
The biggest issue that I can see is that it's super-hard to predict what 
`clang-format` is going to do in each case and even harder to certify that this 
should work in general case.

Intuitively, moving the logic to `clang-format` seems like the right thing to 
do in the long run (e.g. introducing a special cursor marker into clang-format, 
similar a code completion marker used by clang or something similar).
OTOH, it's hard for me to asses the amount of work needed to do this inside 
`clang-format` itself (not a `clang-format` expert), and the patch is 
definitely an improvement to what we had before (I've been using it for awhile 
now). The problems do get fixed, so I'm totally happy with it landing as is if 
we commit to fixing those nasty cases until we run out of them.

PS. In the meantime, I've found another case where newline gets eaten:

  class SyntaxTreeTest {
  public:
^ 
  };

**Expected:** newline is added.
**Actual:** does not let to add a newline (the added newline is removed).


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D60605



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


[PATCH] D58547: [clangd] Introduce intermediate representation of formatted text

2019-05-06 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

As discussed, it probably makes sense to split into two patches, adding this 
abstraction and using it.
(All together is also fine but should have the tests for the new behavior, 
which probably means renderForTests() too)

Generally looks good. I think we'll run into the limitations as soon as we want 
to add lists, but that's OK.




Comment at: clang-tools-extra/clangd/FormattedString.cpp:71
+  // start and end the code block with more.
+  unsigned MaxBackticks = 0;
+  for (llvm::StringRef Left = Input;;) {

```
backticks = "```"
while (Input.contains(backticks))
  backticks.push_back("`")
```

I don't think we care about DOS here?



Comment at: clang-tools-extra/clangd/FormattedString.cpp:90
+void FormattedString::appendText(std::string Text) {
+  if (Chunks.empty() || Chunks.back().Kind != ChunkKind::PlainText) {
+Chunk C;

comment for this merge?



Comment at: clang-tools-extra/clangd/FormattedString.cpp:107
+void FormattedString::appendInlineCode(std::string Code) {
+  assert(!llvm::StringRef(Code).contains("\n"));
+

I'm not sure we're realistically going to be able to enforce this very well, 
we're going to use this for types. Maybe translate into ' ' instead? (or at 
least in production mode)



Comment at: clang-tools-extra/clangd/FormattedString.cpp:140
+
+static bool IsWhitespace(char C) {
+  return llvm::StringLiteral(" \t\n").contains(C);

(we could also use the version in CharInfo)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58547



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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-06 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked 2 inline comments as done.
gtbercea added inline comments.



Comment at: lib/Headers/__clang_cuda_cmath.h:54
 __DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); }
+#ifndef _OPENMP
 __DEVICE__ int fpclassify(float __x) {

ABataev wrote:
> Why we have this guard here? It does not work for OpenMP? Why?
Because all the FP_XXX macros are defined in cmath and for OpenMP we can't 
include it yet because we don't support variant yet.



Comment at: lib/Headers/__clang_cuda_device_functions.h:49
+#if defined(__cplusplus)
 __DEVICE__ void __brkpt(int __a) { __brkpt(); }
+#endif

ABataev wrote:
> Can we do anything with this in С mode? I mean, to allow it in C.
We can if we rename the function.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399



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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Headers/__clang_cuda_cmath.h:54
 __DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); }
+#ifndef _OPENMP
 __DEVICE__ int fpclassify(float __x) {

gtbercea wrote:
> ABataev wrote:
> > Why we have this guard here? It does not work for OpenMP? Why?
> Because all the FP_XXX macros are defined in cmath and for OpenMP we can't 
> include it yet because we don't support variant yet.
The better to add TODO or FIXME to fix this once `variant` construct in 
supported.



Comment at: lib/Headers/__clang_cuda_device_functions.h:49
+#if defined(__cplusplus)
 __DEVICE__ void __brkpt(int __a) { __brkpt(); }
+#endif

gtbercea wrote:
> ABataev wrote:
> > Can we do anything with this in С mode? I mean, to allow it in C.
> We can if we rename the function.
Take a look here, probably it will solve the problem:
https://clang.llvm.org/docs/AttributeReference.html#overloadable


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399



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


Re: [PATCH] D61464: [RiscV] Typo in register aliases

2019-05-06 Thread Eric Christopher via cfe-commits
I'll get it.

On Sat, May 4, 2019 at 3:47 AM John LLVM via Phabricator
 wrote:
>
> JohnLLVM added a comment.
>
> What should I do now? I do not have rights to commit.
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D61464/new/
>
> https://reviews.llvm.org/D61464
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61396: [hip] Fix ambiguity from `>>>` of CUDA.

2019-05-06 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

@rsmith Do you have the chance to review this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61396



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


[PATCH] D61497: [clangd] Introduce a structured hover response

2019-05-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 198295.
kadircet marked 8 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61497

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1185,7 +1185,9 @@
 auto AST = TU.build();
 if (auto H = getHover(AST, T.point())) {
   EXPECT_NE("", Test.ExpectedHover) << Test.Input;
-  EXPECT_EQ(H->contents.value, Test.ExpectedHover.str()) << Test.Input;
+  EXPECT_EQ(H->render().contents.value, Test.ExpectedHover.str())
+  << Test.Input << '\n'
+  << H;
 } else
   EXPECT_EQ("", Test.ExpectedHover.str()) << Test.Input;
   }
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -16,7 +16,10 @@
 #include "ClangdUnit.h"
 #include "Protocol.h"
 #include "index/Index.h"
+#include "index/SymbolLocation.h"
+#include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 
 namespace clang {
@@ -46,8 +49,37 @@
 std::vector findDocumentHighlights(ParsedAST &AST,
   Position Pos);
 
+struct HoverInfo {
+  using Type = std::string;
+  struct Param {
+Type T;
+std::string Name;
+std::string Default;
+  };
+
+  LocatedSymbol Sym;
+  /// Fully qualiffied name for the scope containing the Sym.
+  std::string Scope;
+  std::string ParentScope;
+  SymbolKind Kind;
+  std::string Documentation;
+  /// Line containing the definition of the symbol.
+  std::string Definition;
+
+  /// T and ReturnType are mutually exclusive.
+  llvm::Optional T;
+  llvm::Optional ReturnType;
+  llvm::Optional> Parameters;
+  llvm::Optional> TemplateParameters;
+
+  /// Lower to LSP struct.
+  Hover render() const;
+};
+llvm::raw_ostream &operator<<(llvm::raw_ostream &, const HoverInfo::Param &);
+llvm::raw_ostream &operator<<(llvm::raw_ostream &, const HoverInfo &);
+
 /// Get the hover information when hovering at \p Pos.
-llvm::Optional getHover(ParsedAST &AST, Position Pos);
+llvm::Optional getHover(ParsedAST &AST, Position Pos);
 
 /// Returns reference locations of the symbol at a specified \p Pos.
 /// \p Limit limits the number of results returned (0 means no limit).
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -7,21 +7,32 @@
 //===--===//
 #include "XRefs.h"
 #include "AST.h"
+#include "CodeCompletionStrings.h"
 #include "FindSymbols.h"
 #include "Logger.h"
+#include "Protocol.h"
 #include "SourceCode.h"
 #include "URI.h"
 #include "index/Merge.h"
 #include "index/SymbolCollector.h"
 #include "index/SymbolLocation.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexSymbol.h"
 #include "clang/Index/IndexingAction.h"
 #include "clang/Index/USRGeneration.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace clang {
 namespace clangd {
@@ -241,17 +252,17 @@
   return {DeclMacrosFinder.getFoundDecls(), DeclMacrosFinder.takeMacroInfos()};
 }
 
-Range getTokenRange(ParsedAST &AST, SourceLocation TokLoc) {
-  const SourceManager &SourceMgr = AST.getASTContext().getSourceManager();
-  SourceLocation LocEnd = Lexer::getLocForEndOfToken(
-  TokLoc, 0, SourceMgr, AST.getASTContext().getLangOpts());
+Range getTokenRange(ASTContext &AST, SourceLocation TokLoc) {
+  const SourceManager &SourceMgr = AST.getSourceManager();
+  SourceLocation LocEnd =
+  Lexer::getLocForEndOfToken(TokLoc, 0, SourceMgr, AST.getLangOpts());
   return {sourceLocToPosition(SourceMgr, TokLoc),
   sourceLocToPosition(SourceMgr, LocEnd)};
 }
 
-llvm::Optional makeLocation(ParsedAST &AST, SourceLocation TokLoc,
+llvm::Optional makeLocation(ASTContext &AST, SourceLocation TokLoc,
   

[PATCH] D61472: [X86FixupLEAs] Turn optIncDec into a generic two address LEA optimizer. Support LEA64_32r properly.

2019-05-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Not sure. I'll fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61472



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


[PATCH] D47109: LWG 2969 "polymorphic_allocator::construct() shouldn't pass resource()"

2019-05-06 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.
Herald added subscribers: libcxx-commits, ldionne.

We also need to mark this off in the status. I can do that in D58879 
 or create a separate patch.


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D47109



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-06 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D60974#1490358 , @rupprecht wrote:

> I didn't follow the technical details, but I don't see anything wrong with 
> moving forward on this patch. I think this seems like an interesting idea 
> worth experimenting with.
>
> In D60974#1488563 , @jakehehrlich 
> wrote:
>
> > > Jake, I am still not sure what you would prefer for moving forward. The 
> > > current patch can output the yaml format I originally proposed or the one 
> > > that looks similar to the one you proposed. What I need to know is:
> > > 
> > > Do you want the merging if the "ifo" files to happen inside of 
> > > llvm-elfabi?
> > >  Do you care if we upstream the yaml we proposed as a first step (which 
> > > is really a distilled version of that yaml2obj can consume anyways. this 
> > > right now functions actually) ???
> > >  Or, would you rather the ifo files be merged by a different separate 
> > > tool (something maybe called llvm-ifsogen)???
> >
> > This is my proposal:
> >
> > 1. We should plan on adding the code ofr merging these files inside of 
> > `llvm/tools/llvm-elfabi` but will it be a separate tool from `llvm-elfabi`. 
> > You can create "separate" tools in the same directory using the symlink 
> > trick. See llvm-ar and friends or llvm-objcopy and llvm-strip. The tool 
> > name can be discussed in review.
>
>
> The symlink trick is usually used when the new frontend tool is just a thin 
> layer over the underlying tool. Is that going to be the case here?
>
> For example,
>
> - `llvm-ranlib` is equivalent to `llvm-ar s`
> - `llvm-readelf` is equivalent to `llvm-readobj --elf-output-style=GNU`
> - `llvm-addr2line` is equivalent to `llvm-symbolizer --output-style=GNU`
> - `llvm-strip` is equivalent to `llvm-objcopy --strip-all` (maybe not exactly)
>
>   In other words, is `llvm-mergeifo` (placeholder name) going to be roughly 
> equivalent to `llvm-elfabi --merge-ifo` (again, placeholder flag name)? And 
> if so, it doesn't seem like a symlink is strictly necessary -- users can just 
> call `llvm-elfabi --merge-ifo`. Am I missing something?


@rupprecht
I was looking into this. I think it could work to just have a secondary path 
for loading tbe files and merging them. I modified the tbe schema to include an 
"Endian" field (which I would like to emit from clang).

>> 2. The yaml proposed thus far is not acceptable IMO for reasons already 
>> outlined but this can be discussed in code review. Before adding sections a 
>> clear reason for needing them is required which hasn't been given yet. 
>> Things can evolve and change later as needed but we should start with the 
>> minimum and add as needed later; not start with extra and remove later. 
>> Support for the new format should be added into TextAPI and in the review 
>> for that process we should discuss the format. After we add support for this 
>> new format into TextAPI we can add support for emitting this format into 
>> clang (well actually you can write the code whenever but I'm using "after" 
>> in a different sense here).
> 
> What if we named it experimental for now? i.e. `--experimental-emit-ifo` for 
> the clang flag name and `!experimental-ifo-elf-v1` for the yaml id? That 
> would allow those working on this patch to play around with more features, 
> but still give sufficient warning to anyone that fields they depend on may be 
> removed.
> 
> In fact, if we label it experimental (or maybe even if we don't), I don't see 
> any reason this couldn't land now, even without a consumer of it. So what if 
> a tool produces a yaml file that we don't haven't finished the yaml parser 
> for? Does anything break?

@rupprecht I like this idea a lot, and I think it's a good compromise. I think 
in the long run there are multiple formats that could be output from 
clang-emit-interface-stubs so I went ahead and added an additional 
-interface-stubs-version= flag (because why limit the output format to a 
specific version of tbe or elf?). My current diff can generate either tbe (that 
can be consumed by llvm-elfabi) by default or yaml that can be consumed by 
yaml2obj (when passing -interface-stubs-version=experimental-ifo-elf-v1). The 
default output pretty much produces the exact tbe that llvm-elfabi consumes so 
its not really a new yaml schema here (-interface-stubs-version=tapi-tbe or the 
default will do this), on the other hand 
-interface-stubs-version=experimental-ifo-elf-v1 can be used to give us freedom 
to target the internal yaml2obj tool if we needed to. I still need to go back 
and change all the references to either "ifso" or "ifo" to "interface stub" or 
"ifs" for consistency. I hope this is a reasonable compromise and can land with 
close to what I have here. @jakehehrlich  @compnerd thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



__

[PATCH] D58547: [clangd] Introduce intermediate representation of formatted text

2019-05-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 198298.
ilya-biryukov marked 7 inline comments as done.
ilya-biryukov added a comment.

- Use isWhitespace from CharInfo.
- Add a comment for merging text blocks together.
- Remove assertion that inline code block does not contain newlines.
- Simplify how the max number of backticks is computed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58547

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1185,7 +1185,9 @@
 auto AST = TU.build();
 if (auto H = getHover(AST, T.point())) {
   EXPECT_NE("", Test.ExpectedHover) << Test.Input;
-  EXPECT_EQ(H->contents.value, Test.ExpectedHover.str()) << Test.Input;
+  // FIXME: add renderForTests() and use it here.
+  EXPECT_EQ(H->Content.renderAsPlainText(), Test.ExpectedHover.str())
+  << Test.Input;
 } else
   EXPECT_EQ("", Test.ExpectedHover.str()) << Test.Input;
   }
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -0,0 +1,156 @@
+//===-- FormattedStringTests.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "FormattedString.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/StringRef.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TEST(FormattedString, Basic) {
+  FormattedString S;
+  EXPECT_EQ(S.renderAsPlainText(), "");
+  EXPECT_EQ(S.renderAsMarkdown(), "");
+
+  S.appendText("foobar");
+  EXPECT_EQ(S.renderAsPlainText(), "foobar");
+  EXPECT_EQ(S.renderAsMarkdown(), "foobar");
+
+  S = FormattedString();
+  S.appendInlineCode("foobar");
+  EXPECT_EQ(S.renderAsPlainText(), "foobar");
+  EXPECT_EQ(S.renderAsMarkdown(), "`foobar`");
+
+  S = FormattedString();
+  S.appendCodeBlock("foobar");
+  EXPECT_EQ(S.renderAsPlainText(), "foobar");
+  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
+  "foobar\n"
+  "```\n");
+}
+
+TEST(FormattedString, CodeBlocks) {
+  FormattedString S;
+  S.appendCodeBlock("foobar");
+  S.appendCodeBlock("bazqux", "javascript");
+
+  EXPECT_EQ(S.renderAsPlainText(), "foobar\n\n\nbazqux");
+  std::string ExpectedMarkdown = R"md(```cpp
+foobar
+```
+```javascript
+bazqux
+```
+)md";
+  EXPECT_EQ(S.renderAsMarkdown(), ExpectedMarkdown);
+
+  S = FormattedString();
+  S.appendInlineCode("foobar");
+  S.appendInlineCode("bazqux");
+  EXPECT_EQ(S.renderAsPlainText(), "foobar bazqux");
+  EXPECT_EQ(S.renderAsMarkdown(), "`foobar` `bazqux`");
+
+  S = FormattedString();
+  S.appendText("foo");
+  S.appendInlineCode("bar");
+  S.appendText("baz");
+
+  EXPECT_EQ(S.renderAsPlainText(), "foo bar baz");
+  EXPECT_EQ(S.renderAsMarkdown(), "foo`bar`baz");
+}
+
+TEST(FormattedString, Escaping) {
+  // Check some ASCII punctuation
+  FormattedString S;
+  S.appendText("*!`");
+  EXPECT_EQ(S.renderAsMarkdown(), "\\*\\!\\`");
+
+  // Check all ASCII punctuation.
+  S = FormattedString();
+  std::string Punctuation = R"txt(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)txt";
+  // Same text, with each character escaped.
+  std::string EscapedPunctuation;
+  EscapedPunctuation.reserve(2 * Punctuation.size());
+  for (char C : Punctuation)
+EscapedPunctuation += std::string("\\") + C;
+  S.appendText(Punctuation);
+  EXPECT_EQ(S.renderAsMarkdown(), EscapedPunctuation);
+
+  // In code blocks we don't need to escape ASCII punctuation.
+  S = FormattedString();
+  S.appendInlineCode("* foo !+ bar * baz");
+  EXPECT_EQ(S.renderAsMarkdown(), "`* foo !+ bar * baz`");
+  S = FormattedString();
+  S.appendCodeBlock("#define FOO\n* foo !+ bar * baz");
+  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
+  

[PATCH] D58547: [clangd] Introduce intermediate representation of formatted text

2019-05-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/FormattedString.cpp:71
+  // start and end the code block with more.
+  unsigned MaxBackticks = 0;
+  for (llvm::StringRef Left = Input;;) {

sammccall wrote:
> ```
> backticks = "```"
> while (Input.contains(backticks))
>   backticks.push_back("`")
> ```
> 
> I don't think we care about DOS here?
I'd like to keep this linear anyway.
Simplified the algorithm a bit, let me know if it still looks too complicated.



Comment at: clang-tools-extra/clangd/FormattedString.cpp:107
+void FormattedString::appendInlineCode(std::string Code) {
+  assert(!llvm::StringRef(Code).contains("\n"));
+

sammccall wrote:
> I'm not sure we're realistically going to be able to enforce this very well, 
> we're going to use this for types. Maybe translate into ' ' instead? (or at 
> least in production mode)
Actually, the [[ https://spec.commonmark.org/0.29/#code-spans | CommonMark 
specification ]] allows newline in the inline code blocks.
The renderers should replace newlines with spaces.
Removed the assertion.



Comment at: clang-tools-extra/clangd/FormattedString.cpp:140
+
+static bool IsWhitespace(char C) {
+  return llvm::StringLiteral(" \t\n").contains(C);

sammccall wrote:
> (we could also use the version in CharInfo)
Thanks! I knew there should be a helper like this somewhere in LLVM...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58547



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


[PATCH] D58547: [clangd] Introduce intermediate representation of formatted text

2019-05-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 198300.
ilya-biryukov added a comment.

- Remove hover-related bits, they will go into a separate revision


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58547

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp

Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -0,0 +1,156 @@
+//===-- FormattedStringTests.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "FormattedString.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/StringRef.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TEST(FormattedString, Basic) {
+  FormattedString S;
+  EXPECT_EQ(S.renderAsPlainText(), "");
+  EXPECT_EQ(S.renderAsMarkdown(), "");
+
+  S.appendText("foobar");
+  EXPECT_EQ(S.renderAsPlainText(), "foobar");
+  EXPECT_EQ(S.renderAsMarkdown(), "foobar");
+
+  S = FormattedString();
+  S.appendInlineCode("foobar");
+  EXPECT_EQ(S.renderAsPlainText(), "foobar");
+  EXPECT_EQ(S.renderAsMarkdown(), "`foobar`");
+
+  S = FormattedString();
+  S.appendCodeBlock("foobar");
+  EXPECT_EQ(S.renderAsPlainText(), "foobar");
+  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
+  "foobar\n"
+  "```\n");
+}
+
+TEST(FormattedString, CodeBlocks) {
+  FormattedString S;
+  S.appendCodeBlock("foobar");
+  S.appendCodeBlock("bazqux", "javascript");
+
+  EXPECT_EQ(S.renderAsPlainText(), "foobar\n\n\nbazqux");
+  std::string ExpectedMarkdown = R"md(```cpp
+foobar
+```
+```javascript
+bazqux
+```
+)md";
+  EXPECT_EQ(S.renderAsMarkdown(), ExpectedMarkdown);
+
+  S = FormattedString();
+  S.appendInlineCode("foobar");
+  S.appendInlineCode("bazqux");
+  EXPECT_EQ(S.renderAsPlainText(), "foobar bazqux");
+  EXPECT_EQ(S.renderAsMarkdown(), "`foobar` `bazqux`");
+
+  S = FormattedString();
+  S.appendText("foo");
+  S.appendInlineCode("bar");
+  S.appendText("baz");
+
+  EXPECT_EQ(S.renderAsPlainText(), "foo bar baz");
+  EXPECT_EQ(S.renderAsMarkdown(), "foo`bar`baz");
+}
+
+TEST(FormattedString, Escaping) {
+  // Check some ASCII punctuation
+  FormattedString S;
+  S.appendText("*!`");
+  EXPECT_EQ(S.renderAsMarkdown(), "\\*\\!\\`");
+
+  // Check all ASCII punctuation.
+  S = FormattedString();
+  std::string Punctuation = R"txt(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)txt";
+  // Same text, with each character escaped.
+  std::string EscapedPunctuation;
+  EscapedPunctuation.reserve(2 * Punctuation.size());
+  for (char C : Punctuation)
+EscapedPunctuation += std::string("\\") + C;
+  S.appendText(Punctuation);
+  EXPECT_EQ(S.renderAsMarkdown(), EscapedPunctuation);
+
+  // In code blocks we don't need to escape ASCII punctuation.
+  S = FormattedString();
+  S.appendInlineCode("* foo !+ bar * baz");
+  EXPECT_EQ(S.renderAsMarkdown(), "`* foo !+ bar * baz`");
+  S = FormattedString();
+  S.appendCodeBlock("#define FOO\n* foo !+ bar * baz");
+  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
+  "#define FOO\n* foo !+ bar * baz\n"
+  "```\n");
+
+  // But we have to escape the backticks.
+  S = FormattedString();
+  S.appendInlineCode("foo`bar`baz");
+  EXPECT_EQ(S.renderAsMarkdown(), "`foo``bar``baz`");
+
+  S = FormattedString();
+  S.appendCodeBlock("foo`bar`baz");
+  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
+  "foo`bar`baz\n"
+  "```\n");
+
+  // Inline code blocks starting or ending with backticks should add spaces.
+  S = FormattedString();
+  S.appendInlineCode("`foo");
+  EXPECT_EQ(S.renderAsMarkdown(), "` ``foo `");
+  S = FormattedString();
+  S.appendInlineCode("foo`");
+  EXPECT_EQ(S.renderAsMarkdown(), "` foo`` `");
+  S = FormattedString();
+  S.appendInlineCode("`foo`");
+  EXPECT_EQ(S.renderAsMarkdown(), "` ``foo`` `");
+
+  // Should also add extra spaces if the block stars and ends with spaces.
+  S = FormattedString();
+  S.appendInlineCode(" foo ");
+  EXPECT_EQ(S.renderAsMarkdown(), "`  foo  `");
+  S = FormattedString();
+  S.appendInlineCode("foo ");
+  EXPECT_EQ(S.renderAsMarkdown(), "`foo `");
+  S = FormattedString();
+  S.appendInlineCode(" foo");
+  EXPECT_EQ(S.renderAsMarkdown(), "` foo`");
+
+

[PATCH] D54881: [clang-format] Prevent Clang-Format from editing leading whitespace on lines outside of the format range

2019-05-06 Thread Russell McClellan via Phabricator via cfe-commits
russellmcc added a comment.

Hey, still motivated to land this, but definitely don't want to break any 
existing workflows.

In particular,

> but this afaict (unless I'm missing something :) will also affect the 
> workflow where the provided range is 0-length range

I'm curious how to do this - as I mentioned, I know how to trigger a format on 
a 1-length range, but I don't understand how to trigger a 0-length range.


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

https://reviews.llvm.org/D54881



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


[PATCH] D61497: [clangd] Introduce a structured hover response

2019-05-06 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.h:52
+struct HoverInfo {
+  LocatedSymbol Sym;
+  /// Name of the context containing the symbol.

sammccall wrote:
> I'm not sure about reuse of LocatedSymbol - do we want to commit to returning 
> decl/def locations?
> Name might be enough here.
It might be nice to provide editors with enough info to jump to definition(it 
was brought up during last meeting). But happy to reduce it to just name.



Comment at: clang-tools-extra/clangd/XRefs.h:55
+  std::string ContainerName;
+  index::SymbolInfo SI;
+  /// Includes all the qualifiers.

sammccall wrote:
> SymbolInfo is a bit of a mess. Maybe we just want SymbolInfo::Kind? (LSP 
> SymbolKind is tempting but loses a lot of info for C++).
> 
> I do think we'll need to extend SymbolInfo::Kind or eventually use our own 
> enum, e.g. lambdas may need their own kind (they're variables, but don't have 
> a printable type and need to be displayed more like functions)
As you mentioned we might need to extend LSP's enum, but switching to it 
anyway. Currently it doesn't support "macro" kind exactly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61497



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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-06 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 198301.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_libdevice_declares.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h
  test/Driver/openmp-offload-gpu.c
  test/Headers/Inputs/include/cmath
  test/Headers/Inputs/include/limits
  test/Headers/Inputs/include/math.h
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp

Index: test/Headers/nvptx_device_math_functions.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_math_functions.c
===
--- /dev/null
+++ test/Headers/nvptx_device_math_functions.c
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions.c
===
--- /dev/null
+++ test/Headers/nvptx_device_cmath_functions.c
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+

[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Headers/__clang_cuda_cmath.h:444
 using ::roundf;
+#ifndef _OPENMP
 using ::scalblnf;

I see that the same guard is used 
`lib/Headers/__clang_cuda_device_functions.h`, but for different set of 
functions. Is this ok?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399



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


[PATCH] D61472: [X86FixupLEAs] Turn optIncDec into a generic two address LEA optimizer. Support LEA64_32r properly.

2019-05-06 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 198303.
craig.topper added a comment.

Get rid of clang stuff.


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

https://reviews.llvm.org/D61472

Files:
  llvm/lib/Target/X86/X86FixupLEAs.cpp
  llvm/test/CodeGen/X86/GlobalISel/add-ext.ll
  llvm/test/CodeGen/X86/GlobalISel/callingconv.ll
  llvm/test/CodeGen/X86/GlobalISel/gep.ll
  llvm/test/CodeGen/X86/GlobalISel/memop-scalar.ll
  llvm/test/CodeGen/X86/MergeConsecutiveStores.ll
  llvm/test/CodeGen/X86/atomic-unordered.ll
  llvm/test/CodeGen/X86/avx512vl-intrinsics-upgrade.ll
  llvm/test/CodeGen/X86/bitreverse.ll
  llvm/test/CodeGen/X86/bswap_tree2.ll
  llvm/test/CodeGen/X86/bypass-slow-division-32.ll
  llvm/test/CodeGen/X86/combine-srem.ll
  llvm/test/CodeGen/X86/dagcombine-shifts.ll
  llvm/test/CodeGen/X86/fixup-bw-copy.ll
  llvm/test/CodeGen/X86/fixup-lea.ll
  llvm/test/CodeGen/X86/imul.ll
  llvm/test/CodeGen/X86/leaFixup32.mir
  llvm/test/CodeGen/X86/leaFixup64.mir
  llvm/test/CodeGen/X86/mul-constant-i16.ll
  llvm/test/CodeGen/X86/mul-constant-i32.ll
  llvm/test/CodeGen/X86/mul-constant-i64.ll
  llvm/test/CodeGen/X86/mul-constant-i8.ll
  llvm/test/CodeGen/X86/popcnt.ll
  llvm/test/CodeGen/X86/reverse_branches.ll
  llvm/test/CodeGen/X86/rotate-extract.ll
  llvm/test/CodeGen/X86/sat-add.ll
  llvm/test/CodeGen/X86/twoaddr-lea.ll
  llvm/test/CodeGen/X86/vector-bitreverse.ll
  llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
  llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll

Index: llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll
===
--- llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll
+++ llvm/test/Transforms/LoopStrengthReduce/X86/ivchain-X86.ll
@@ -243,14 +243,14 @@
 ; X32-NEXT:# =>This Inner Loop Header: Depth=1
 ; X32-NEXT:movl (%ebx,%esi), %ebp
 ; X32-NEXT:addl (%ebx), %ebp
-; X32-NEXT:leal (%ebx,%esi), %ebx
+; X32-NEXT:addl %esi, %ebx
 ; X32-NEXT:addl (%esi,%ebx), %ebp
-; X32-NEXT:leal (%ebx,%esi), %ebx
+; X32-NEXT:addl %esi, %ebx
 ; X32-NEXT:addl (%esi,%ebx), %ebp
-; X32-NEXT:leal (%ebx,%esi), %ebx
+; X32-NEXT:addl %esi, %ebx
 ; X32-NEXT:addl (%esi,%ebx), %ebp
 ; X32-NEXT:movl %ebp, (%edx)
-; X32-NEXT:leal (%ebx,%esi), %ebx
+; X32-NEXT:addl %esi, %ebx
 ; X32-NEXT:addl %edi, %ebx
 ; X32-NEXT:addl %ecx, %edx
 ; X32-NEXT:decl %eax
Index: llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
===
--- llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
+++ llvm/test/CodeGen/X86/win_coreclr_chkstk.ll
@@ -21,7 +21,7 @@
 ; WIN_X64:# %bb.1:
 ; WIN_X64:	andq	$-4096, %rdx
 ; WIN_X64:.LBB0_2:
-; WIN_X64:	leaq	-4096(%rcx), %rcx
+; WIN_X64:	addq	$-4096, %rcx
 ; WIN_X64:	movb	$0, (%rcx)
 ; WIN_X64:	cmpq	%rcx, %rdx
 ; WIN_X64:	jne	.LBB0_2
Index: llvm/test/CodeGen/X86/vector-bitreverse.ll
===
--- llvm/test/CodeGen/X86/vector-bitreverse.ll
+++ llvm/test/CodeGen/X86/vector-bitreverse.ll
@@ -27,7 +27,7 @@
 ; SSE-NEXT:addb %al, %al
 ; SSE-NEXT:andb $-86, %dil
 ; SSE-NEXT:shrb %dil
-; SSE-NEXT:leal (%rdi,%rax), %eax
+; SSE-NEXT:addl %edi, %eax
 ; SSE-NEXT:# kill: def $al killed $al killed $eax
 ; SSE-NEXT:retq
 ;
@@ -46,7 +46,7 @@
 ; AVX-NEXT:addb %al, %al
 ; AVX-NEXT:andb $-86, %dil
 ; AVX-NEXT:shrb %dil
-; AVX-NEXT:leal (%rdi,%rax), %eax
+; AVX-NEXT:addl %edi, %eax
 ; AVX-NEXT:# kill: def $al killed $al killed $eax
 ; AVX-NEXT:retq
 ;
Index: llvm/test/CodeGen/X86/twoaddr-lea.ll
===
--- llvm/test/CodeGen/X86/twoaddr-lea.ll
+++ llvm/test/CodeGen/X86/twoaddr-lea.ll
@@ -69,7 +69,7 @@
 
 bb3:
 ; CHECK: subl %e[[REG0:[a-z0-9]+]],
-; CHECK: leaq 4({{%[a-z0-9]+}}), %r[[REG0]]
+; CHECK: addq $4, %r[[REG0]]
   %tmp14 = phi i64 [ %tmp15, %bb5 ], [ 0, %bb1 ]
   %tmp15 = add nuw i64 %tmp14, 4
   %tmp16 = trunc i64 %tmp14 to i32
Index: llvm/test/CodeGen/X86/sat-add.ll
===
--- llvm/test/CodeGen/X86/sat-add.ll
+++ llvm/test/CodeGen/X86/sat-add.ll
@@ -236,7 +236,7 @@
 ; ANY-NEXT:notl %eax
 ; ANY-NEXT:cmpw %ax, %di
 ; ANY-NEXT:cmovbl %edi, %eax
-; ANY-NEXT:leal (%rax,%rsi), %eax
+; ANY-NEXT:addl %esi, %eax
 ; ANY-NEXT:# kill: def $ax killed $ax killed $eax
 ; ANY-NEXT:retq
   %noty = xor i16 %y, -1
@@ -287,7 +287,7 @@
 ; ANY-NEXT:notl %eax
 ; ANY-NEXT:cmpl %eax, %edi
 ; ANY-NEXT:cmovbl %edi, %eax
-; ANY-NEXT:leal (%rax,%rsi), %eax
+; ANY-NEXT:addl %esi, %eax
 ; ANY-NEXT:retq
   %noty = xor i32 %y, -1
   %c = icmp ult i32 %x, %noty
@@ -334,7 +334,7 @@
 ; ANY-NEXT:notq %rax
 ; ANY-NEXT:cmpq %rax, %rdi
 ; ANY-NEXT:cmovbq %rdi, %rax
-; ANY-NEXT:leaq (%rax,%rsi), %rax
+; ANY-NEXT:addq %rsi, %rax
 ; ANY-NEXT:retq

[PATCH] D61509: [PragmaHandler][OpenMP] Expose `#pragma` location

2019-05-06 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

Thanks for everyone's responses so far.

At this point, I'm going to follow the uncontroversial suggestions from 
@lebedev.ri: create a `struct PragmaIntroducer`, and split the OpenMP work into 
a second patch.  That will hopefully make it easier for @rsmith or others to 
consider what we have now and what should be done for other pragmas now, if 
anything.


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

https://reviews.llvm.org/D61509



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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

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



Comment at: lib/Headers/__clang_cuda_cmath.h:444
 using ::roundf;
+#ifndef _OPENMP
 using ::scalblnf;

ABataev wrote:
> I see that the same guard is used 
> `lib/Headers/__clang_cuda_device_functions.h`, but for different set of 
> functions. Is this ok?
Yep, it's intentional. Again the variant issue.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399



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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-06 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with a nit.




Comment at: lib/Headers/__clang_cuda_cmath.h:444
 using ::roundf;
+#ifndef _OPENMP
 using ::scalblnf;

gtbercea wrote:
> ABataev wrote:
> > I see that the same guard is used 
> > `lib/Headers/__clang_cuda_device_functions.h`, but for different set of 
> > functions. Is this ok?
> Yep, it's intentional. Again the variant issue.
Then again, add TODO or FIXME


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399



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


r360061 - [OPENMP]Fix PR41768: check DSA for globals with `default(none)` clauses.

2019-05-06 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May  6 10:49:22 2019
New Revision: 360061

URL: http://llvm.org/viewvc/llvm-project?rev=360061&view=rev
Log:
[OPENMP]Fix PR41768: check DSA for globals with `default(none)` clauses.

If the `default(none)` was specified for the construct, we might miss
diagnostic for the globals without explicitly specified data-sharing
attributes. Patch fixes this problem.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/parallel_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_default_messages.cpp
cfe/trunk/test/OpenMP/parallel_sections_messages.cpp
cfe/trunk/test/OpenMP/report_default_DSA.cpp
cfe/trunk/test/OpenMP/target_parallel_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/target_teams_default_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_default_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/target_teams_messages.cpp
cfe/trunk/test/OpenMP/task_default_messages.cpp
cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/task_messages.cpp
cfe/trunk/test/OpenMP/teams_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_default_messages.cpp
cfe/trunk/test/OpenMP/teams_distribute_simd_messages.cpp
cfe/trunk/test/OpenMP/teams_messages.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=360061&r1=360060&r2=360061&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May  6 10:49:22 
2019
@@ -8792,6 +8792,8 @@ def err_omp_threadprivate_incomplete_typ
   "threadprivate variable with incomplete type %0">;
 def err_omp_no_dsa_for_variable : Error<
   "variable %0 must have explicitly specified data sharing attributes">;
+def note_omp_default_dsa_none : Note<
+  "explicit data sharing attribute requested here">;
 def err_omp_wrong_dsa : Error<
   "%0 variable cannot be %1">;
 def err_omp_variably_modified_type_not_supported : Error<

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=360061&r1=360060&r2=360061&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon May  6 10:49:22 2019
@@ -1777,10 +1777,15 @@ VarDecl *Sema::isOpenMPCapturedDecl(Valu
 DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode());
 if (DVarPrivate.CKind != OMPC_unknown && 
isOpenMPPrivate(DVarPrivate.CKind))
   return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());
+if (VD && DSAStack->getDefaultDSA() == DSA_none)
+  return VD;
 DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate,
[](OpenMPDirectiveKind) { return true; },
DSAStack->isClauseParsingMode());
-if (DVarPrivate.CKind != OMPC_unknown)
+// The variable is not private or it is the variable in the directive with
+// default(none) clause and not used in any clause.
+if (DVarPrivate.CKind != OMPC_unknown ||
+(VD && DSAStack->getDefaultDSA() == DSA_none))
   return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());

Re: r360061 - [OPENMP]Fix PR41768: check DSA for globals with `default(none)` clauses.

2019-05-06 Thread Roman Lebedev via cfe-commits
Thank you!

On Mon, May 6, 2019 at 8:46 PM Alexey Bataev via cfe-commits
 wrote:
>
> Author: abataev
> Date: Mon May  6 10:49:22 2019
> New Revision: 360061
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360061&view=rev
> Log:
> [OPENMP]Fix PR41768: check DSA for globals with `default(none)` clauses.
>
> If the `default(none)` was specified for the construct, we might miss
> diagnostic for the globals without explicitly specified data-sharing
> attributes. Patch fixes this problem.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/test/OpenMP/distribute_parallel_for_default_messages.cpp
> cfe/trunk/test/OpenMP/distribute_parallel_for_messages.cpp
> cfe/trunk/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
> cfe/trunk/test/OpenMP/parallel_default_messages.cpp
> cfe/trunk/test/OpenMP/parallel_for_default_messages.cpp
> cfe/trunk/test/OpenMP/parallel_for_messages.cpp
> cfe/trunk/test/OpenMP/parallel_for_simd_default_messages.cpp
> cfe/trunk/test/OpenMP/parallel_for_simd_messages.cpp
> cfe/trunk/test/OpenMP/parallel_messages.cpp
> cfe/trunk/test/OpenMP/parallel_sections_default_messages.cpp
> cfe/trunk/test/OpenMP/parallel_sections_messages.cpp
> cfe/trunk/test/OpenMP/report_default_DSA.cpp
> cfe/trunk/test/OpenMP/target_parallel_default_messages.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_default_messages.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_messages.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_simd_default_messages.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_simd_messages.cpp
> cfe/trunk/test/OpenMP/target_teams_default_messages.cpp
> cfe/trunk/test/OpenMP/target_teams_distribute_default_messages.cpp
> cfe/trunk/test/OpenMP/target_teams_distribute_messages.cpp
> 
> cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
> cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_messages.cpp
> 
> cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
> 
> cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_messages.cpp
> cfe/trunk/test/OpenMP/target_teams_messages.cpp
> cfe/trunk/test/OpenMP/task_default_messages.cpp
> cfe/trunk/test/OpenMP/task_firstprivate_messages.cpp
> cfe/trunk/test/OpenMP/task_messages.cpp
> cfe/trunk/test/OpenMP/teams_default_messages.cpp
> cfe/trunk/test/OpenMP/teams_distribute_default_messages.cpp
> cfe/trunk/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
> cfe/trunk/test/OpenMP/teams_distribute_parallel_for_messages.cpp
> 
> cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
> cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
> cfe/trunk/test/OpenMP/teams_distribute_simd_default_messages.cpp
> cfe/trunk/test/OpenMP/teams_distribute_simd_messages.cpp
> cfe/trunk/test/OpenMP/teams_messages.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=360061&r1=360060&r2=360061&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon May  6 10:49:22 
> 2019
> @@ -8792,6 +8792,8 @@ def err_omp_threadprivate_incomplete_typ
>"threadprivate variable with incomplete type %0">;
>  def err_omp_no_dsa_for_variable : Error<
>"variable %0 must have explicitly specified data sharing attributes">;
> +def note_omp_default_dsa_none : Note<
> +  "explicit data sharing attribute requested here">;
>  def err_omp_wrong_dsa : Error<
>"%0 variable cannot be %1">;
>  def err_omp_variably_modified_type_not_supported : Error<
>
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=360061&r1=360060&r2=360061&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon May  6 10:49:22 2019
> @@ -1777,10 +1777,15 @@ VarDecl *Sema::isOpenMPCapturedDecl(Valu
>  DSAStack->getTopDSA(D, DSAStack->isClauseParsingMode());
>  if (DVarPrivate.CKind != OMPC_unknown && 
> isOpenMPPrivate(DVarPrivate.CKind))
>return VD ? VD : cast(DVarPrivate.PrivateCopy->getDecl());
> +if (VD && DSAStack->getDefaultDSA() == DSA_none)
> +  return VD;
>  DVarPrivate = DSAStack->hasDSA(D, isOpenMPPrivate,
> [](OpenMPDirectiveKind) { return true; },
> DSAStack->isClauseParsingMode());
> -if (DVarPrivate.CKind != OMPC_unknown)
> +// The variable is not private or it 

[PATCH] D61591: [MinGW] Use SEH by default on AArch64

2019-05-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D61591



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


[PATCH] D61601: [clangd] Represent Hover result using FormattedString

2019-05-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61601

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -580,7 +580,10 @@
   int test1 = bonjour;
 }
   )cpp",
-  "Declared in function main\n\nint bonjour",
+  "text[Declared in]code[function main]\n"
+  "codeblock(cpp) [\n"
+  "int bonjour\n"
+  "]",
   },
   {
   R"cpp(// Local variable in method
@@ -591,7 +594,10 @@
   }
 };
   )cpp",
-  "Declared in function s::method\n\nint bonjour",
+  "text[Declared in]code[function s::method]\n"
+  "codeblock(cpp) [\n"
+  "int bonjour\n"
+  "]",
   },
   {
   R"cpp(// Struct
@@ -602,7 +608,10 @@
   ns1::My^Class* Params;
 }
   )cpp",
-  "Declared in namespace ns1\n\nstruct MyClass {}",
+  "text[Declared in]code[namespace ns1]\n"
+  "codeblock(cpp) [\n"
+  "struct MyClass {}\n"
+  "]",
   },
   {
   R"cpp(// Class
@@ -613,7 +622,10 @@
   ns1::My^Class* Params;
 }
   )cpp",
-  "Declared in namespace ns1\n\nclass MyClass {}",
+  "text[Declared in]code[namespace ns1]\n"
+  "codeblock(cpp) [\n"
+  "class MyClass {}\n"
+  "]",
   },
   {
   R"cpp(// Union
@@ -624,7 +636,10 @@
   ns1::My^Union Params;
 }
   )cpp",
-  "Declared in namespace ns1\n\nunion MyUnion {}",
+  "text[Declared in]code[namespace ns1]\n"
+  "codeblock(cpp) [\n"
+  "union MyUnion {}\n"
+  "]",
   },
   {
   R"cpp(// Function definition via pointer
@@ -633,7 +648,10 @@
   auto *X = &^foo;
 }
   )cpp",
-  "Declared in global namespace\n\nint foo(int)",
+  "text[Declared in]code[global namespace]\n"
+  "codeblock(cpp) [\n"
+  "int foo(int)\n"
+  "]",
   },
   {
   R"cpp(// Function declaration via call
@@ -642,7 +660,10 @@
   return ^foo(42);
 }
   )cpp",
-  "Declared in global namespace\n\nint foo(int)",
+  "text[Declared in]code[global namespace]\n"
+  "codeblock(cpp) [\n"
+  "int foo(int)\n"
+  "]",
   },
   {
   R"cpp(// Field
@@ -652,7 +673,10 @@
   bar.^x;
 }
   )cpp",
-  "Declared in struct Foo\n\nint x",
+  "text[Declared in]code[struct Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Field with initialization
@@ -662,7 +686,10 @@
   bar.^x;
 }
   )cpp",
-  "Declared in struct Foo\n\nint x = 5",
+  "text[Declared in]code[struct Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x = 5\n"
+  "]",
   },
   {
   R"cpp(// Static field
@@ -671,7 +698,10 @@
   Foo::^x;
 }
   )cpp",
-  "Declared in struct Foo\n\nstatic int x",
+  "text[Declared in]code[struct Foo]\n"
+  "codeblock(cpp) [\n"
+  "static int x\n"
+  "]",
   },
   {
   R"cpp(// Field, member initializer
@@ -680,7 +710,10 @@
   Foo() : ^x(0) {}
 };
   )cpp",
-  "Declared in struct Foo\n\nint x",
+  "text[Declared in]code[struct Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Field, GNU old-style field designator
@@ -689,7 +722,10 @@
   Foo bar = { ^x : 1 };
 }
   )cpp",
-  "Declared in struct Foo\n\nint x",
+  "text[Declared in]code[struct Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Field, field designator
@@ -698,7 +734,10 @@
   Foo bar = { .^x = 2 };
 }
   )cpp",
-  "Declared in struct Foo\n\nint x",

[PATCH] D61592: [AArch64] Add __builtin_sponentry, for calling setjmp in MinGW

2019-05-06 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D61592



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


[PATCH] D61508: [clang-tidy] misc-header-guard : a simple version of llvm-header-guard

2019-05-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D61508#1491570 , @JonasToth wrote:

> Hi trixirt and thanks for the patch!
>
> I would rather like to generalize the llvm check to allow different styles 
> and then alias the general version with different configurations. Introducing 
> this code duplication does not sound like a good idea to me.
>  The documentation fixes you make can be done in a separate patch to keep 
> things clean.


I'd probably reverse that -- have bugprone (not misc) carry a general check for 
header guards with configuration options, and have the llvm check defer to the 
general check with specific configuration options.




Comment at: clang-tidy/misc/HeaderGuardCheck.cpp:25-26
+  std::string Guard = llvm::sys::path::filename(Filename);
+  std::replace(Guard.begin(), Guard.end(), '.', '_');
+  std::replace(Guard.begin(), Guard.end(), '-', '_');
+  return StringRef(Guard).upper();

This replacement may generate a header guard that exhibits UB. Consider a 
filename like `foo-.cpp`, which will become `foo__cpp`


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61508



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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-06 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 198311.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_libdevice_declares.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h
  test/Driver/openmp-offload-gpu.c
  test/Headers/Inputs/include/cmath
  test/Headers/Inputs/include/limits
  test/Headers/Inputs/include/math.h
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp

Index: test/Headers/nvptx_device_math_functions.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_math_functions.cpp
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -internal-isystem %S/Inputs/include -include stdlib.h -include limits -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_math_functions.c
===
--- /dev/null
+++ test/Headers/nvptx_device_math_functions.c
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- /dev/null
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions.c
===
--- /dev/null
+++ test/Headers/nvptx_device_cmath_functions.c
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+

[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-06 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360063: [OpenMP][Clang] Support for target math functions 
(authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61399?vs=198311&id=198314#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61399

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_libdevice_declares.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h
  test/Driver/openmp-offload-gpu.c
  test/Headers/Inputs/include/cmath
  test/Headers/Inputs/include/limits
  test/Headers/Inputs/include/math.h
  test/Headers/nvptx_device_cmath_functions.c
  test/Headers/nvptx_device_cmath_functions.cpp
  test/Headers/nvptx_device_math_functions.c
  test/Headers/nvptx_device_math_functions.cpp

Index: test/Headers/nvptx_device_cmath_functions.cpp
===
--- test/Headers/nvptx_device_cmath_functions.cpp
+++ test/Headers/nvptx_device_cmath_functions.cpp
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -x c++ -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -internal-isystem %S/Inputs/include -include stdlib.h -x c++ -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_math_functions.c
===
--- test/Headers/nvptx_device_math_functions.c
+++ test/Headers/nvptx_device_math_functions.c
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include math.h -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include math.h -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/nvptx_device_cmath_functions.c
===
--- test/Headers/nvptx_device_cmath_functions.c
+++ test/Headers/nvptx_device_cmath_functions.c
@@ -0,0 +1,21 @@
+// Test calling of device math functions.
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -include cmath -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include cmath -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck -check-prefix CHECK-YES %s
+
+#include 
+
+void test_sqrt(double a1) {
+  #pragma omp target
+  {
+// CHECK-YES: call double @__nv_sqrt(double
+double l1 = sqrt(a1);
+// CHECK-YES: call double @__nv_pow(double
+double l2 = pow(a1, a1);
+// CHECK-YES: call double @__nv_modf(double
+double l3 = modf(a1 + 3.5, &a1);
+  }
+}
Index: test/Headers/Inputs/include/math.h
===
--- test/Headers/Inpu

r360063 - [OpenMP][Clang] Support for target math functions

2019-05-06 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Mon May  6 11:19:15 2019
New Revision: 360063

URL: http://llvm.org/viewvc/llvm-project?rev=360063&view=rev
Log:
[OpenMP][Clang] Support for target math functions

Summary:
In this patch we propose a temporary solution to resolving math functions for 
the NVPTX toolchain, temporary until OpenMP variant is supported by Clang.

We intercept the inclusion of math.h and cmath headers and if we are in the 
OpenMP-NVPTX case, we re-use CUDA's math function resolution mechanism.

Authors:
@gtbercea
@jdoerfert

Reviewers: hfinkel, caomhin, ABataev, tra

Reviewed By: hfinkel, ABataev, tra

Subscribers: mgorny, guansong, cfe-commits, jdoerfert

Tags: #clang

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

Added:
cfe/trunk/lib/Headers/openmp_wrappers/
cfe/trunk/lib/Headers/openmp_wrappers/__clang_openmp_math.h
cfe/trunk/lib/Headers/openmp_wrappers/cmath
cfe/trunk/lib/Headers/openmp_wrappers/math.h
cfe/trunk/test/Headers/Inputs/include/cmath
cfe/trunk/test/Headers/Inputs/include/limits
cfe/trunk/test/Headers/nvptx_device_cmath_functions.c
cfe/trunk/test/Headers/nvptx_device_cmath_functions.cpp
cfe/trunk/test/Headers/nvptx_device_math_functions.c
cfe/trunk/test/Headers/nvptx_device_math_functions.cpp
Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/__clang_cuda_cmath.h
cfe/trunk/lib/Headers/__clang_cuda_device_functions.h
cfe/trunk/lib/Headers/__clang_cuda_libdevice_declares.h
cfe/trunk/lib/Headers/__clang_cuda_math_forward_declares.h
cfe/trunk/test/Driver/openmp-offload-gpu.c
cfe/trunk/test/Headers/Inputs/include/math.h

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=360063&r1=360062&r2=360063&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon May  6 11:19:15 2019
@@ -1151,6 +1151,21 @@ void Clang::AddPreprocessingOptions(Comp
   if (JA.isOffloading(Action::OFK_Cuda))
 getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 
+  // If we are offloading to a target via OpenMP we need to include the
+  // openmp_wrappers folder which contains alternative system headers.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP) &&
+  getToolChain().getTriple().isNVPTX()){
+if (!Args.hasArg(options::OPT_nobuiltininc)) {
+  // Add openmp_wrappers/* to our system include path.  This lets us wrap
+  // standard library headers.
+  SmallString<128> P(D.ResourceDir);
+  llvm::sys::path::append(P, "include");
+  llvm::sys::path::append(P, "openmp_wrappers");
+  CmdArgs.push_back("-internal-isystem");
+  CmdArgs.push_back(Args.MakeArgString(P));
+}
+  }
+
   // Add -i* options, and automatically translate to
   // -include-pch/-include-pth for transparent PCH support. It's
   // wonky, but we include looking for .gch so we can support seamless

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=360063&r1=360062&r2=360063&view=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Mon May  6 11:19:15 2019
@@ -33,6 +33,9 @@ set(files
   avxintrin.h
   bmi2intrin.h
   bmiintrin.h
+  openmp_wrappers/math.h
+  openmp_wrappers/cmath
+  openmp_wrappers/__clang_openmp_math.h
   __clang_cuda_builtin_vars.h
   __clang_cuda_cmath.h
   __clang_cuda_complex_builtins.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_cmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_cmath.h?rev=360063&r1=360062&r2=360063&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_cmath.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_cmath.h Mon May  6 11:19:15 2019
@@ -30,7 +30,11 @@
 // implementation.  Declaring in the global namespace and pulling into 
namespace
 // std covers all of the known knowns.
 
+#ifdef _OPENMP
+#define __DEVICE__ static __attribute__((always_inline))
+#else
 #define __DEVICE__ static __device__ __inline__ __attribute__((always_inline))
+#endif
 
 __DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
 __DEVICE__ long abs(long __n) { return ::labs(__n); }
@@ -47,6 +51,8 @@ __DEVICE__ float exp(float __x) { return
 __DEVICE__ float fabs(float __x) { return ::fabsf(__x); }
 __DEVICE__ float floor(float __x) { return ::floorf(__x); }
 __DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); }
+// TODO: remove when variant is supported
+#ifndef _OPENMP
 __DEVICE__ int fpclassify(float __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
  

[PATCH] D61260: [clang-tidy] Extend bugprone-sizeof-expression to check sizeof(pointers to structures)

2019-05-06 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!


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

https://reviews.llvm.org/D61260



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


[PATCH] D33841: [clang-tidy] redundant keyword check

2019-05-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/clang-tidy/readability-redundant-extern.cpp:37
+
+void another_file_scope(int _extern);

koldaniel wrote:
> aaron.ballman wrote:
> > More tests that I figured out:
> > ```
> > namespace {
> > extern void f(); // 'extern' is not redundant
> > }
> > 
> > namespace a {
> > namespace {
> > namespace b {
> > extern void f(); // 'extern' is not redundant
> > }
> > }
> > }
> > 
> > // Note, the above are consequences of http://eel.is/c++draft/basic.link#6
> > 
> > #define FOO_EXTERN extern
> > typedef int extern_int;
> > 
> > extern_int FOO_EXTERN foo(); // 'extern' is redundant, but hopefully we 
> > don't try to fixit this to be '_int FOO_EXTERN foo();'
> > 
> > // The above is a weird consequence of how specifiers are parsed in C and 
> > C++
> > ```
> In the first two examples extern is redundant:
> 
> "An unnamed namespace or a namespace declared directly or indirectly within 
> an unnamed namespace has internal linkage. All other namespaces have external 
> linkage."
> 
> Also, based on the examples in http://eel.is/c++draft/basic.link#8 , the 
> extern keyword has no effect in case of unnamed namespaces. In case of 'C' 
> linkage defined by an extern keyword the checker does not warn.
> 
> In the first two examples extern is redundant:

The `extern` keyword there isn't redundant, it's useless. When I hear 
"redundant", I read it as "you can remove this keyword because the declaration 
is already `extern`" but that's not the case there.

You are correct that the declarations retain internal linkage -- that's why I 
think the `extern` keyword isn't redundant so much as it is confusing. We 
already issue a diagnostic for this in the frontend, so I think we may just 
want to silence the diagnostic here entirely. https://godbolt.org/z/WE6Fkd

WDYT?


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

https://reviews.llvm.org/D33841



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


[PATCH] D60507: [clang-tidy] new check: bugprone-unhandled-self-assignment

2019-05-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D60507#1491095 , @ztamas wrote:

> Ping.
>  Is it good to go or is there anything else I need to include in this patch?


Sorry for the delay, I was gone for WG14 meetings last week, which made 
reviewing more involved patches somewhat difficult. I'm back now and starting 
to dig out from under the mountain of emails.

> Among the lots of idea, I'm not sure which is just brainstorming and which is 
> a change request.

Generally speaking, all feedback is a bit of a mixture of the two. They're 
change requests, but we can definitely brainstorm whether the request makes 
sense, how to do it, whether there are better changes to make instead, etc. We 
usually say something explicit like "but I don't insist" when we're just 
spitballing ideas. That said, I'm sorry if I was unclear on what changes I was 
insisting on.

I definitely want to see the diagnostic text changed away from "might be" -- 
that's too noncommittal for my tastes. I'd also like to see the additional test 
case (I suspect it will just work out of the box, but if it doesn't, it would 
be good to know about it). The CERT alias is a bit more of a grey area -- I'd 
like to insist on it being added because it's trivial, it improves the behavior 
of this check by introducing an option some users will want, and checks 
conforming to coding standards are always more compelling than one-off checks. 
However, you seem very resistant to that and I don't want to add to your work 
load if you are opposed to doing it, so I don't insist on the change.

> The check seems to work (has useful catches and does not produce too many 
> false positives), however, it does not conform with the corresponding cert 
> rule. I expect that a cert alias with an option can be added in a follow-up 
> patch (option to ignore ThisHasSuspiciousField pattern). The bugprone-* check 
> would have the same default behavior as it has now in this patch. So adding 
> the cert alias would not change this behavior, right? In this case, this code 
> change can be added in a separate patch I guess.

Agreed.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp:82
+  diag(MatchedDecl->getLocation(),
+   "operator=() might not handle self-assignment properly");
+}

ztamas wrote:
> aaron.ballman wrote:
> > ztamas wrote:
> > > aaron.ballman wrote:
> > > > Hmm, the "might not" seems a bit flat to me. How about: `'operator=()' 
> > > > does not properly test for self-assignment`?
> > > > 
> > > > Also, do we want to have a fix-it to insert a check for self assignment 
> > > > at the start of the function?
> > > I don't think "test for self-assignment" will be good, because it's only 
> > > one way to make the operator self assignment safe. In case of 
> > > copy-and-swap and copy-and-move there is no testing of self assignment, 
> > > but swaping/moving works in all cases without explicit self check.
> > > 
> > > A fix-it can be a good idea for a follow-up patch.
> > Good point on the use of "test" in the diagnostic. My concern is more with 
> > it sounding like we don't actually know -- the "might" is what's bothering 
> > me. I think if we switch it to "does not", it'd be a bit better.
> We don't actually know. We check only some patterns, but there might be other 
> operator=() implementations which are self assignment safe (see false 
> positive test cases).
I understand that we're using a heuristic, but that doesn't mean we use 
language like "might not" in the resulting diagnostic. Either we think the code 
is correct (we don't diagnose) or the code doesn't do what it needs to do to 
pass our check (we diagnose). That's why I recommended "does not" -- the 
operator=() does not handle self-assignment properly according to your check. I 
couldn't find any existing diagnostics saying the code "might not" do something 
properly.



Comment at: 
clang-tools-extra/test/clang-tidy/bugprone-unhandled-self-assignment.cpp:214
+};
+
+///

Does the check diagnose code like this?
```
template 
class C {
  Ty *Ptr1;
  Uy *Ptr2;

public:
  C& operator=(const C &RHS) {
Ptr1 = RHS.getUy();
Ptr2 = RHS.getTy();
return *this;
  }

  Ty *getTy() const { return Ptr1; }
  Uy *getUy() const { return Ptr2; }
};
```
I'm hoping we don't consider it a copy assignment operator and thus don't 
diagnose (note that the template argument order is reversed in the assignment 
operator parameter type).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60507



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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2019-05-06 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: lib/Sema/SemaType.cpp:4913-4916
+ExpectNoDerefChunk = false;
+  }
+
+  ExpectNoDerefChunk = state.didParseNoDeref();

Pointed out in PR41774 there's a dead store to ExpectNoDerefChunk here.

Should line 4913 be removed (& then the two if conditions can be collapsed 
together)?


Repository:
  rC Clang

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

https://reviews.llvm.org/D49511



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


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-06 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Gentle ping...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


r360073 - [OPENMP]Fix PR41767: diagnose DSA for variables in clauses with

2019-05-06 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May  6 13:07:20 2019
New Revision: 360073

URL: http://llvm.org/viewvc/llvm-project?rev=360073&view=rev
Log:
[OPENMP]Fix PR41767: diagnose DSA for variables in clauses with
default(none).

If the combined directive has default(none) clause and has clauses for
inner directive that reference some variables, for which data-sharing
attributes are not specified, the error messages should be emitted for
such variables.

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/parallel_for_schedule_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_if_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=360073&r1=360072&r2=360073&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon May  6 13:07:20 2019
@@ -750,7 +750,8 @@ bool isImplicitTaskingRegion(OpenMPDirec
 }
 
 bool isImplicitOrExplicitTaskingRegion(OpenMPDirectiveKind DKind) {
-  return isImplicitTaskingRegion(DKind) || isOpenMPTaskingDirective(DKind) || 
DKind == OMPD_unknown;
+  return isImplicitTaskingRegion(DKind) || isOpenMPTaskingDirective(DKind) ||
+ DKind == OMPD_unknown;
 }
 
 } // namespace
@@ -2560,9 +2561,17 @@ public:
 E->containsUnexpandedParameterPack() || E->isInstantiationDependent())
   return;
 if (auto *VD = dyn_cast(E->getDecl())) {
+  // Check the datasharing rules for the expressions in the clauses.
+  if (!CS) {
+if (auto *CED = dyn_cast(VD))
+  if (!CED->hasAttr()) {
+Visit(CED->getInit());
+return;
+  }
+  }
   VD = VD->getCanonicalDecl();
   // Skip internally declared variables.
-  if (VD->hasLocalStorage() && !CS->capturesVariable(VD))
+  if (VD->hasLocalStorage() && CS && !CS->capturesVariable(VD))
 return;
 
   DSAStackTy::DSAVarData DVar = Stack->getTopDSA(VD, /*FromParent=*/false);
@@ -2573,7 +2582,7 @@ public:
   // Skip internally declared static variables.
   llvm::Optional Res =
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
-  if (VD->hasGlobalStorage() && !CS->capturesVariable(VD) &&
+  if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) &&
   (!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
 return;
 
@@ -4186,6 +4195,90 @@ StmtResult Sema::ActOnOpenMPExecutableDi
 
   ErrorFound = Res.isInvalid() || ErrorFound;
 
+  // Check variables in the clauses if default(none) was specified.
+  if (DSAStack->getDefaultDSA() == DSA_none) {
+DSAAttrChecker DSAChecker(DSAStack, *this, nullptr);
+for (OMPClause *C : Clauses) {
+  switch (C->getClauseKind()) {
+  case OMPC_num_threads:
+  case OMPC_dist_schedule:
+// Do not analyse if no parent teams directive.
+if (isOpenMPTeamsDirective(DSAStack->getCurrentDirective()))
+  break;
+continue;
+  case OMPC_if:
+if ((isOpenMPTeamsDirective(DSAStack->getCurrentDirective()) &&
+ cast(C)->getNameModifier() != OMPD_target) ||
+isOpenMPParallelDirective(DSAStack->getCurrentDirective()))
+  break;
+continue;
+  case OMPC_schedule:
+break;
+  case OMPC_ordered:
+  case OMPC_device:
+  case OMPC_num_teams:
+  case OMPC_thread_limit:
+  case OMPC_priority:
+  case OMPC_grainsize:
+  case OMPC_num_tasks:
+  case OMPC_hint:
+  case OMPC_collapse:
+  case OMPC_safelen:
+  case OMPC_simdlen:
+  case OMPC_final:
+  case OMPC_default:
+  case OMPC_proc_bind:
+  case OMPC_private:
+  case OMPC_firstprivate:
+  case OMPC_lastprivate:
+  case OMPC_shared:
+  case OMPC_reduction:
+  case OMPC_task_reduction:
+  case OMPC_in_reduction:
+  case OMPC_linear:
+  case OMPC_aligned:
+  case OMPC_copyin:
+  case OMPC_copyprivate:
+  case OMPC_nowait:
+  case OMPC_untied:
+  case OMPC_mergeable:
+  case OMPC_allocate:
+  case OMPC_read:
+  case OMPC_write:
+  case OMPC_update:
+  case OMPC_capture:
+  case OMPC_seq_cst:
+  case OMPC_depend:
+  case OMPC_threads:
+  case OMPC_simd:
+  case OMPC_map:
+  case OMPC_nogroup:
+  case OMPC_defaultmap:
+  case OMPC_to:
+  case OMPC_from:
+  case OMPC_use_device_ptr:
+  case OMPC_is_device_ptr:
+continue;
+  case OMPC_allocator:
+  case OMPC_flush:
+  case OMPC_threadprivate:
+  case OMPC_uniform:
+   

Re: r360073 - [OPENMP]Fix PR41767: diagnose DSA for variables in clauses with

2019-05-06 Thread Roman Lebedev via cfe-commits
Thank you!

On Mon, May 6, 2019 at 11:05 PM Alexey Bataev via cfe-commits
 wrote:
>
> Author: abataev
> Date: Mon May  6 13:07:20 2019
> New Revision: 360073
>
> URL: http://llvm.org/viewvc/llvm-project?rev=360073&view=rev
> Log:
> [OPENMP]Fix PR41767: diagnose DSA for variables in clauses with
> default(none).
>
> If the combined directive has default(none) clause and has clauses for
> inner directive that reference some variables, for which data-sharing
> attributes are not specified, the error messages should be emitted for
> such variables.
>
> Modified:
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/test/OpenMP/distribute_parallel_for_ast_print.cpp
> cfe/trunk/test/OpenMP/distribute_parallel_for_simd_ast_print.cpp
> cfe/trunk/test/OpenMP/parallel_for_ast_print.cpp
> cfe/trunk/test/OpenMP/parallel_for_schedule_messages.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_ast_print.cpp
> cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
> cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_if_messages.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=360073&r1=360072&r2=360073&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon May  6 13:07:20 2019
> @@ -750,7 +750,8 @@ bool isImplicitTaskingRegion(OpenMPDirec
>  }
>
>  bool isImplicitOrExplicitTaskingRegion(OpenMPDirectiveKind DKind) {
> -  return isImplicitTaskingRegion(DKind) || isOpenMPTaskingDirective(DKind) 
> || DKind == OMPD_unknown;
> +  return isImplicitTaskingRegion(DKind) || isOpenMPTaskingDirective(DKind) ||
> + DKind == OMPD_unknown;
>  }
>
>  } // namespace
> @@ -2560,9 +2561,17 @@ public:
>  E->containsUnexpandedParameterPack() || 
> E->isInstantiationDependent())
>return;
>  if (auto *VD = dyn_cast(E->getDecl())) {
> +  // Check the datasharing rules for the expressions in the clauses.
> +  if (!CS) {
> +if (auto *CED = dyn_cast(VD))
> +  if (!CED->hasAttr()) {
> +Visit(CED->getInit());
> +return;
> +  }
> +  }
>VD = VD->getCanonicalDecl();
>// Skip internally declared variables.
> -  if (VD->hasLocalStorage() && !CS->capturesVariable(VD))
> +  if (VD->hasLocalStorage() && CS && !CS->capturesVariable(VD))
>  return;
>
>DSAStackTy::DSAVarData DVar = Stack->getTopDSA(VD, 
> /*FromParent=*/false);
> @@ -2573,7 +2582,7 @@ public:
>// Skip internally declared static variables.
>llvm::Optional Res =
>OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(VD);
> -  if (VD->hasGlobalStorage() && !CS->capturesVariable(VD) &&
> +  if (VD->hasGlobalStorage() && CS && !CS->capturesVariable(VD) &&
>(!Res || *Res != OMPDeclareTargetDeclAttr::MT_Link))
>  return;
>
> @@ -4186,6 +4195,90 @@ StmtResult Sema::ActOnOpenMPExecutableDi
>
>ErrorFound = Res.isInvalid() || ErrorFound;
>
> +  // Check variables in the clauses if default(none) was specified.
> +  if (DSAStack->getDefaultDSA() == DSA_none) {
> +DSAAttrChecker DSAChecker(DSAStack, *this, nullptr);
> +for (OMPClause *C : Clauses) {
> +  switch (C->getClauseKind()) {
> +  case OMPC_num_threads:
> +  case OMPC_dist_schedule:
> +// Do not analyse if no parent teams directive.
> +if (isOpenMPTeamsDirective(DSAStack->getCurrentDirective()))
> +  break;
> +continue;
> +  case OMPC_if:
> +if ((isOpenMPTeamsDirective(DSAStack->getCurrentDirective()) &&
> + cast(C)->getNameModifier() != OMPD_target) ||
> +isOpenMPParallelDirective(DSAStack->getCurrentDirective()))
> +  break;
> +continue;
> +  case OMPC_schedule:
> +break;
> +  case OMPC_ordered:
> +  case OMPC_device:
> +  case OMPC_num_teams:
> +  case OMPC_thread_limit:
> +  case OMPC_priority:
> +  case OMPC_grainsize:
> +  case OMPC_num_tasks:
> +  case OMPC_hint:
> +  case OMPC_collapse:
> +  case OMPC_safelen:
> +  case OMPC_simdlen:
> +  case OMPC_final:
> +  case OMPC_default:
> +  case OMPC_proc_bind:
> +  case OMPC_private:
> +  case OMPC_firstprivate:
> +  case OMPC_lastprivate:
> +  case OMPC_shared:
> +  case OMPC_reduction:
> +  case OMPC_task_reduction:
> +  case OMPC_in_reduction:
> +  case OMPC_linear:
> +  case OMPC_aligned:
> +  case OMPC_copyin:
> +  case OMPC_copyprivate:
> +  case OMPC_nowait:
> +  case OMPC_untied:
> +  case OMPC_mergeable:
> +  case OMPC_allocate:
> +  case OMPC_read:
> +  case OMPC_write:
> +  case OMPC_update:
> +  case OMPC_capture:
> +  case OMPC_seq_cst:
> +  case OMPC_depend:
> +  case OMPC_threads:
> +  cas

[PATCH] D60934: [clang] adding explicit(bool) from c++2a

2019-05-06 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith reopened this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:373-374
+ ExplicitSpecifier ES, FunctionDecl *New) {
+  if (!ES.getExpr() || ES.getKind() != ExplicitSpecKind::Unresolved)
+return ES;
+  Expr *OldCond = ES.getExpr();

This is incorrect: you still need to substitute into an //explicit-specifier// 
even if you've already resolved it, at least if it's instantiation-dependent. 
(Substitution could fail, and if it does, you need to produce the error.) For 
example:

```
template struct A {
  explicit(sizeof(sizeof(T::error)) == sizeof(sizeof(int))) A();
};
```

Here, the expression in the //explicit-specifier// is neither type-dependent 
nor value-dependent, but it is instantiation-dependent, and substitution into 
it should fail when, say, `T` is `int`. (Instantiating `A` should fail 
with an error.)


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

https://reviews.llvm.org/D60934



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


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return-type check

2019-05-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp:85-87
+if (TL.getQualifierLoc())
+  if (!TraverseNestedNameSpecifierLoc(TL.getQualifierLoc()))
+return false;

You can combine these.



Comment at: clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp:88-90
+if (!TraverseTypeLoc(TL.getNamedTypeLoc(), true))
+  return false;
+return true;

And this can become `return TraverseTypeLoc(...);`



Comment at: clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp:95-98
+if (!S->getQualifierLoc() && Name.isIdentifier() &&
+VisitUnqualName(Name.getAsIdentifierInfo()->getName()))
+  return false;
+return true;

This can also be simplified into a single return statement rather than an `if`, 
but it's less clear to me whether that's an improvement. WDYT?



Comment at: clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp:203
+  if (ContainsQualifiers + ContainsSpecifiers + ContainsSomethingElse > 1)
+return {};
+

This should return `llvm::None`



Comment at: clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp:234
+  diag(F.getLocation(), Message);
+  return {};
+}

`llvm::None`



Comment at: clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp:246
+  diag(F.getLocation(), Message);
+  return {};
+}

`llvm::None`


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

https://reviews.llvm.org/D56160



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


[PATCH] D33841: [clang-tidy] redundant keyword check

2019-05-06 Thread Daniel Kolozsvari via Phabricator via cfe-commits
koldaniel marked an inline comment as done.
koldaniel added inline comments.



Comment at: test/clang-tidy/readability-redundant-extern.cpp:37
+
+void another_file_scope(int _extern);

aaron.ballman wrote:
> koldaniel wrote:
> > aaron.ballman wrote:
> > > More tests that I figured out:
> > > ```
> > > namespace {
> > > extern void f(); // 'extern' is not redundant
> > > }
> > > 
> > > namespace a {
> > > namespace {
> > > namespace b {
> > > extern void f(); // 'extern' is not redundant
> > > }
> > > }
> > > }
> > > 
> > > // Note, the above are consequences of http://eel.is/c++draft/basic.link#6
> > > 
> > > #define FOO_EXTERN extern
> > > typedef int extern_int;
> > > 
> > > extern_int FOO_EXTERN foo(); // 'extern' is redundant, but hopefully we 
> > > don't try to fixit this to be '_int FOO_EXTERN foo();'
> > > 
> > > // The above is a weird consequence of how specifiers are parsed in C and 
> > > C++
> > > ```
> > In the first two examples extern is redundant:
> > 
> > "An unnamed namespace or a namespace declared directly or indirectly within 
> > an unnamed namespace has internal linkage. All other namespaces have 
> > external linkage."
> > 
> > Also, based on the examples in http://eel.is/c++draft/basic.link#8 , the 
> > extern keyword has no effect in case of unnamed namespaces. In case of 'C' 
> > linkage defined by an extern keyword the checker does not warn.
> > 
> > In the first two examples extern is redundant:
> 
> The `extern` keyword there isn't redundant, it's useless. When I hear 
> "redundant", I read it as "you can remove this keyword because the 
> declaration is already `extern`" but that's not the case there.
> 
> You are correct that the declarations retain internal linkage -- that's why I 
> think the `extern` keyword isn't redundant so much as it is confusing. We 
> already issue a diagnostic for this in the frontend, so I think we may just 
> want to silence the diagnostic here entirely. https://godbolt.org/z/WE6Fkd
> 
> WDYT?
I see, you are right, calling it redundant is not the best way to describe the 
situation. What I wanted to achieve here  is that I wanted this checker to warn 
on every occurrence of the keyword extern when it seems to be useless 
(redundant, unnecessary, etc.). If there are other checkers which warn in 
situations like that (i.e. when extern has no effect), we could silence these 
warnings (or we could handle this checker as a more generic one which warns not 
on redundant but on unnecessary uses of extern).


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

https://reviews.llvm.org/D33841



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


[PATCH] D61592: [AArch64] Add __builtin_sponentry, for calling setjmp in MinGW

2019-05-06 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC360082: [AArch64] Add __builtin_sponentry, for calling 
setjmp in MinGW (authored by mstorsjo, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D61592

Files:
  include/clang/Basic/BuiltinsAArch64.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtin-sponentry.c


Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7233,6 +7233,11 @@
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI__builtin_sponentry) {
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::sponentry);
+return Builder.CreateCall(F);
+  }
+
   // Find out if any arguments are required to be integer constant
   // expressions.
   unsigned ICEArguments = 0;
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -86,6 +86,9 @@
 LANGBUILTIN(__sev,   "v", "",   ALL_MS_LANGUAGES)
 LANGBUILTIN(__sevl,  "v", "",   ALL_MS_LANGUAGES)
 
+// Misc
+BUILTIN(__builtin_sponentry, "v*", "c")
+
 TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanReverse, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
Index: test/CodeGen/builtin-sponentry.c
===
--- test/CodeGen/builtin-sponentry.c
+++ test/CodeGen/builtin-sponentry.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple aarch64-windows-gnu -Oz -emit-llvm %s -o - | 
FileCheck %s
+
+void *test_sponentry() {
+  return __builtin_sponentry();
+}
+// CHECK-LABEL: define dso_local i8* @test_sponentry()
+// CHECK: = tail call i8* @llvm.sponentry()
+// CHECK: ret i8*


Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -7233,6 +7233,11 @@
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI__builtin_sponentry) {
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::sponentry);
+return Builder.CreateCall(F);
+  }
+
   // Find out if any arguments are required to be integer constant
   // expressions.
   unsigned ICEArguments = 0;
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -86,6 +86,9 @@
 LANGBUILTIN(__sev,   "v", "",   ALL_MS_LANGUAGES)
 LANGBUILTIN(__sevl,  "v", "",   ALL_MS_LANGUAGES)
 
+// Misc
+BUILTIN(__builtin_sponentry, "v*", "c")
+
 TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanReverse, "UcUNi*UNi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "")
Index: test/CodeGen/builtin-sponentry.c
===
--- test/CodeGen/builtin-sponentry.c
+++ test/CodeGen/builtin-sponentry.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple aarch64-windows-gnu -Oz -emit-llvm %s -o - | FileCheck %s
+
+void *test_sponentry() {
+  return __builtin_sponentry();
+}
+// CHECK-LABEL: define dso_local i8* @test_sponentry()
+// CHECK: = tail call i8* @llvm.sponentry()
+// CHECK: ret i8*
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r360082 - [AArch64] Add __builtin_sponentry, for calling setjmp in MinGW

2019-05-06 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon May  6 14:19:07 2019
New Revision: 360082

URL: http://llvm.org/viewvc/llvm-project?rev=360082&view=rev
Log:
[AArch64] Add __builtin_sponentry, for calling setjmp in MinGW

In MinGW, setjmp isn't expanded as a builtin in the compiler (like it
is for MSVC), but manually hooked up as calls to the right underlying
functions in headers. Using the actual CRT's real setjmp/longjmp
functions requires this intrinsic. (Currently this is worked around by
using MinGW specific reimplementations of setjmp/longjmp on aarch64.)

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

Added:
cfe/trunk/test/CodeGen/builtin-sponentry.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsAArch64.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAArch64.def?rev=360082&r1=360081&r2=360082&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAArch64.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAArch64.def Mon May  6 14:19:07 2019
@@ -86,6 +86,9 @@ LANGBUILTIN(__wfi,   "v", "",   ALL_MS_L
 LANGBUILTIN(__sev,   "v", "",   ALL_MS_LANGUAGES)
 LANGBUILTIN(__sevl,  "v", "",   ALL_MS_LANGUAGES)
 
+// Misc
+BUILTIN(__builtin_sponentry, "v*", "c")
+
 TARGET_HEADER_BUILTIN(_BitScanForward, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanReverse, "UcUNi*UNi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")
 TARGET_HEADER_BUILTIN(_BitScanForward64, "UcUNi*ULLi", "nh", "intrin.h", 
ALL_MS_LANGUAGES, "")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=360082&r1=360081&r2=360082&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon May  6 14:19:07 2019
@@ -7233,6 +7233,11 @@ Value *CodeGenFunction::EmitAArch64Built
 return Builder.CreateCall(F);
   }
 
+  if (BuiltinID == AArch64::BI__builtin_sponentry) {
+llvm::Function *F = CGM.getIntrinsic(Intrinsic::sponentry);
+return Builder.CreateCall(F);
+  }
+
   // Find out if any arguments are required to be integer constant
   // expressions.
   unsigned ICEArguments = 0;

Added: cfe/trunk/test/CodeGen/builtin-sponentry.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-sponentry.c?rev=360082&view=auto
==
--- cfe/trunk/test/CodeGen/builtin-sponentry.c (added)
+++ cfe/trunk/test/CodeGen/builtin-sponentry.c Mon May  6 14:19:07 2019
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple aarch64-windows-gnu -Oz -emit-llvm %s -o - | 
FileCheck %s
+
+void *test_sponentry() {
+  return __builtin_sponentry();
+}
+// CHECK-LABEL: define dso_local i8* @test_sponentry()
+// CHECK: = tail call i8* @llvm.sponentry()
+// CHECK: ret i8*


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


[PATCH] D61591: [MinGW] Use SEH by default on AArch64

2019-05-06 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360081: [MinGW] Use SEH by default on AArch64 (authored by 
mstorsjo, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61591?vs=198256&id=198339#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61591

Files:
  cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
  cfe/trunk/test/Driver/windows-exceptions.cpp


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -436,7 +436,8 @@
   if (ExceptionArg &&
   ExceptionArg->getOption().matches(options::OPT_fseh_exceptions))
 return true;
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPICDefault() const {
@@ -451,7 +452,7 @@
 
 llvm::ExceptionHandling
 toolchains::MinGW::GetExceptionModel(const ArgList &Args) const {
-  if (getArch() == llvm::Triple::x86_64)
+  if (getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::aarch64)
 return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::DwarfCFI;
 }
Index: cfe/trunk/test/Driver/windows-exceptions.cpp
===
--- cfe/trunk/test/Driver/windows-exceptions.cpp
+++ cfe/trunk/test/Driver/windows-exceptions.cpp
@@ -2,8 +2,8 @@
 // RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck 
-check-prefix=MSVC %s
 // RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-DWARF %s
 // RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-SEH %s
-// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-DWARF %s
-// RUN: %clang -target aarch64-windows-gnu -fseh-exceptions -c %s -### 2>&1 | 
FileCheck -check-prefix=MINGW-SEH %s
+// RUN: %clang -target aarch64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 
| FileCheck -check-prefix=MINGW-DWARF %s
+// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-SEH %s
 
 MSVC-NOT: -fdwarf-exceptions
 MSVC-NOT: -fseh-exceptions


Index: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
@@ -436,7 +436,8 @@
   if (ExceptionArg &&
   ExceptionArg->getOption().matches(options::OPT_fseh_exceptions))
 return true;
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPICDefault() const {
@@ -451,7 +452,7 @@
 
 llvm::ExceptionHandling
 toolchains::MinGW::GetExceptionModel(const ArgList &Args) const {
-  if (getArch() == llvm::Triple::x86_64)
+  if (getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::aarch64)
 return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::DwarfCFI;
 }
Index: cfe/trunk/test/Driver/windows-exceptions.cpp
===
--- cfe/trunk/test/Driver/windows-exceptions.cpp
+++ cfe/trunk/test/Driver/windows-exceptions.cpp
@@ -2,8 +2,8 @@
 // RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck -check-prefix=MSVC %s
 // RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-DWARF %s
 // RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-SEH %s
-// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-DWARF %s
-// RUN: %clang -target aarch64-windows-gnu -fseh-exceptions -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-SEH %s
+// RUN: %clang -target aarch64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-DWARF %s
+// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck -check-prefix=MINGW-SEH %s
 
 MSVC-NOT: -fdwarf-exceptions
 MSVC-NOT: -fseh-exceptions
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47109: LWG 2969 "polymorphic_allocator::construct() shouldn't pass resource()"

2019-05-06 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

> We also need to mark this off in the status. I can do that in D58879 
>  or create a separate patch.

Good catch! Either is fine with me but I bet a separate patch would be more 
appropriate.


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D47109



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


r360081 - [MinGW] Use SEH by default on AArch64

2019-05-06 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Mon May  6 14:19:01 2019
New Revision: 360081

URL: http://llvm.org/viewvc/llvm-project?rev=360081&view=rev
Log:
[MinGW] Use SEH by default on AArch64

The implementation of SEH is pretty mature at this point.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
cfe/trunk/test/Driver/windows-exceptions.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=360081&r1=360080&r2=360081&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Mon May  6 14:19:01 2019
@@ -436,7 +436,8 @@ bool toolchains::MinGW::IsUnwindTablesDe
   if (ExceptionArg &&
   ExceptionArg->getOption().matches(options::OPT_fseh_exceptions))
 return true;
-  return getArch() == llvm::Triple::x86_64;
+  return getArch() == llvm::Triple::x86_64 ||
+ getArch() == llvm::Triple::aarch64;
 }
 
 bool toolchains::MinGW::isPICDefault() const {
@@ -451,7 +452,7 @@ bool toolchains::MinGW::isPICDefaultForc
 
 llvm::ExceptionHandling
 toolchains::MinGW::GetExceptionModel(const ArgList &Args) const {
-  if (getArch() == llvm::Triple::x86_64)
+  if (getArch() == llvm::Triple::x86_64 || getArch() == llvm::Triple::aarch64)
 return llvm::ExceptionHandling::WinEH;
   return llvm::ExceptionHandling::DwarfCFI;
 }

Modified: cfe/trunk/test/Driver/windows-exceptions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/windows-exceptions.cpp?rev=360081&r1=360080&r2=360081&view=diff
==
--- cfe/trunk/test/Driver/windows-exceptions.cpp (original)
+++ cfe/trunk/test/Driver/windows-exceptions.cpp Mon May  6 14:19:01 2019
@@ -2,8 +2,8 @@
 // RUN: %clang -target x86_64-windows-msvc -c %s -### 2>&1 | FileCheck 
-check-prefix=MSVC %s
 // RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-DWARF %s
 // RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-SEH %s
-// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-DWARF %s
-// RUN: %clang -target aarch64-windows-gnu -fseh-exceptions -c %s -### 2>&1 | 
FileCheck -check-prefix=MINGW-SEH %s
+// RUN: %clang -target aarch64-windows-gnu -fdwarf-exceptions -c %s -### 2>&1 
| FileCheck -check-prefix=MINGW-DWARF %s
+// RUN: %clang -target aarch64-windows-gnu -c %s -### 2>&1 | FileCheck 
-check-prefix=MINGW-SEH %s
 
 MSVC-NOT: -fdwarf-exceptions
 MSVC-NOT: -fseh-exceptions


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


  1   2   >