[PATCH] D83536: [clangd] Index refs to main-file symbols as well

2020-07-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

This will be needed to support call hierarchy


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83536

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -624,13 +624,13 @@
   EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(Symbols, "NS").ID, _;
   EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "MACRO").ID,
   HaveRanges(Main.ranges("macro");
-  // Symbols *only* in the main file (a, b, c, FUNC) had no refs collected.
-  auto MainSymbols =
-  TestTU::withHeaderCode(SymbolsOnlyInMainCode.code()).headerSymbols();
-  EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "a").ID, _;
-  EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "b").ID, _;
-  EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "c").ID, _;
-  EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "FUNC").ID, _;
+  // Symbols *only* in the main file (a, b, c) should have refs collected
+  // as well.
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "a").ID, _)));
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "b").ID, _)));
+  EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "c").ID, _)));
+  // However, references to main-file macros are not collected.
+  EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(Symbols, "FUNC").ID, _;
 }
 
 TEST_F(SymbolCollectorTest, MacroRefInHeader) {
@@ -706,12 +706,12 @@
 llvm::StringRef Main;
 llvm::StringRef TargetSymbolName;
   } TestCases[] = {
-{
-  R"cpp(
+  {
+  R"cpp(
 struct Foo;
 #define MACRO Foo
   )cpp",
-  R"cpp(
+  R"cpp(
 struct $spelled[[Foo]] {
   $spelled[[Foo]]();
   ~$spelled[[Foo]]();
@@ -719,24 +719,24 @@
 $spelled[[Foo]] Variable1;
 $implicit[[MACRO]] Variable2;
   )cpp",
-  "Foo",
-},
-{
-  R"cpp(
+  "Foo",
+  },
+  {
+  R"cpp(
 class Foo {
 public:
   Foo() = default;
 };
   )cpp",
-  R"cpp(
+  R"cpp(
 void f() { Foo $implicit[[f]]; f = $spelled[[Foo]]();}
   )cpp",
-  "Foo::Foo" /// constructor.
-},
+  "Foo::Foo" /// constructor.
+  },
   };
   CollectorOpts.RefFilter = RefKind::All;
   CollectorOpts.RefsInHeaders = false;
-  for (const auto& T : TestCases) {
+  for (const auto &T : TestCases) {
 Annotations Header(T.Header);
 Annotations Main(T.Main);
 // Reset the file system.
@@ -816,13 +816,18 @@
 $Foo[[Foo]] fo;
   }
   )");
-  // The main file is normal .cpp file, we shouldn't collect any refs of symbols
-  // which are not declared in the preamble.
+  // We should collect refs to main-file symbols in all cases:
+
+  // 1. The main file is normal .cpp file.
   TestFileName = testPath("foo.cpp");
   runSymbolCollector("", Header.code());
-  EXPECT_THAT(Refs, UnorderedElementsAre());
+  EXPECT_THAT(Refs,
+  UnorderedElementsAre(Pair(findSymbol(Symbols, "Foo").ID,
+HaveRanges(Header.ranges("Foo"))),
+   Pair(findSymbol(Symbols, "Func").ID,
+HaveRanges(Header.ranges("Func");
 
-  // Run the .h file as main file, we should collect the refs.
+  // 2. Run the .h file as main file.
   TestFileName = testPath("foo.h");
   runSymbolCollector("", Header.code(),
  /*ExtraArgs=*/{"-xobjective-c++-header"});
@@ -833,8 +838,7 @@
Pair(findSymbol(Symbols, "Func").ID,
 HaveRanges(Header.ranges("Func");
 
-  // Run the .hh file as main file (without "-x c++-header"), we should collect
-  // the refs as well.
+  // 3. Run the .hh file as main file (without "-x c++-header").
   TestFileName = testPath("foo.hh");
   runSymbolCollector("", Header.code());
   EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Foo"), QName("Func")));
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -196,7 +196,7 @@
   EXPECT_THAT(runFuzzyFind(Idx, ""),
   UnorderedElementsAre(AllOf(Named("common"), NumReferences(1U)),
  

[PATCH] D83536: [clangd] Index refs to main-file symbols as well

2020-07-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

(As per discussion in 
https://github.com/clangd/clangd/issues/162#issuecomment-648923948 onwards.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83536



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


[PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions

2020-07-10 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 276928.
martong marked an inline comment as done.
martong added a comment.

- Make Signature to be an Optional member of the Summary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83407

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX-socket-sockaddr.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c

Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -79,6 +79,22 @@
 // CHECK: Loaded summary for: int execv(const char *path, char *const argv[])
 // CHECK: Loaded summary for: int execvp(const char *file, char *const argv[])
 // CHECK: Loaded summary for: int getopt(int argc, char *const argv[], const char *optstring)
+// CHECK: Loaded summary for: int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int getsockname(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: int connect(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
+// CHECK: Loaded summary for: ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, __SOCKADDR_ARG address, socklen_t *restrict address_len)
+// CHECK: Loaded summary for: ssize_t sendto(int socket, const void *message, size_t length, int flags, __CONST_SOCKADDR_ARG dest_addr, socklen_t dest_len)
+// CHECK: Loaded summary for: int listen(int sockfd, int backlog)
+// CHECK: Loaded summary for: ssize_t recv(int sockfd, void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
+// CHECK: Loaded summary for: int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len)
+// CHECK: Loaded summary for: int getsockopt(int socket, int level, int option_name, void *restrict option_value, socklen_t *restrict option_len)
+// CHECK: Loaded summary for: ssize_t send(int sockfd, const void *buf, size_t len, int flags)
+// CHECK: Loaded summary for: int socketpair(int domain, int type, int protocol, int sv[2])
+// CHECK: Loaded summary for: int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags)
 
 long a64l(const char *str64);
 char *l64a(long value);
@@ -171,6 +187,46 @@
 int execvp(const char *file, char *const argv[]);
 int getopt(int argc, char *const argv[], const char *optstring);
 
+// In some libc implementations, sockaddr parameter is a transparent
+// union of the underlying sockaddr_ pointers instead of being a
+// pointer to struct sockaddr.
+// We match that with the joker Irrelevant type.
+struct sockaddr;
+struct sockaddr_at;
+#define __SOCKADDR_ALLTYPES\
+  __SOCKADDR_ONETYPE(sockaddr) \
+  __SOCKADDR_ONETYPE(sockaddr_at)
+#define __SOCKADDR_ONETYPE(type) struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+#define __SOCKADDR_ONETYPE(type) const struct type *__restrict __##type##__;
+typedef union {
+  __SOCKADDR_ALLTYPES
+} __CONST_SOCKADDR_ARG __attribute__((__transparent_union__));
+#undef __SOCKADDR_ONETYPE
+typedef unsigned socklen_t;
+
+int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len);
+int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int getsockname(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+int connect(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len);
+ssize_t recvfrom(int socket, void *restrict buffer, size_t length, int flags, __SOCKADDR_ARG address, socklen_t *restrict address_len);
+ssize_t sendto(int socket, const void *message, size_t length, int flags, __CONST_SOCKADDR_ARG dest_addr, socklen_t dest_len);
+
+int listen(int sockfd, int backlog);
+ssize_t recv(int sockfd, void *buf, size_t len, int flags);
+struct msghdr;
+ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
+ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
+int setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len);
+int getsockopt(int socket, int level, int option_name, void *res

[PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

> Not trying to be difficult, but I'm not sure what you mean by "dependent" in 
> #2. Informally, it means the same thing as #1. Formally, C++ defines 
> type-dependence and value-dependence for expressions, and the ABI defines 
> instantiation-dependence for expressions - AFAIK "dependent" doesn't have a 
> formal meaning.
> 
> So I'd rather say it has two definitions:
> 
> informally, it (somehow) depends on a template parameter.
>  formally (from the C++ABI), an expression is instantiation-dependent if it 
> is type-dependent or value-dependent, or it has a subexpression that is 
> type-dependent or value-dependent.
>  To preserve the linkage between these two, IMO we need to extend the formal 
> definition to errors if and only if we extend the informal definition to 
> errors. Accidentally unlinking the two is almost certain to result in subtle 
> bugs as either the implementation subtly differs from the spec, or it subtly 
> differs from the mental model.

agree! I think the mental model you described makes more sense. yeah, it is 
*important* to keep the linkage between the informal and formal definition. It 
also explains why we should set instantiation-bit. Thanks!

ok, we have an agreement on the current approach. The only remaining thing is 
to clarify comments in clang. I will do it here (rather than D83215 
), so that this discussion thread can be found 
via the commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83213



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


[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-07-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

We must check on every execution path that a specific condition on a value is 
satisfied (or: find one where the condition is not satisfied). This would be 
the most simple form of this checker. This can be done with the path sensitive 
check and `checkDeadSymbols`. If the symbol becomes dead with unsatisfied 
condition a warning is emitted. The "condition" is a syntactic-like check that 
looks for code like "`X != EOF`". This is probably done best by using 
`StmtVisitor` if a value is evaluated (at assignment or condition in `if` or 
other statements), different than the current form.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D82967: [analyzer][tests] Measure peak memory consumption for every project

2020-07-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 276944.
vsavchenko added a comment.

Add matplotlib and graphviz to requirements.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82967

Files:
  clang/utils/analyzer/Dockerfile
  clang/utils/analyzer/SATestBuild.py
  clang/utils/analyzer/SATestUtils.py
  clang/utils/analyzer/requirements.txt

Index: clang/utils/analyzer/requirements.txt
===
--- /dev/null
+++ clang/utils/analyzer/requirements.txt
@@ -0,0 +1,4 @@
+graphviz
+humanize
+matplotlib
+psutil
Index: clang/utils/analyzer/SATestUtils.py
===
--- clang/utils/analyzer/SATestUtils.py
+++ clang/utils/analyzer/SATestUtils.py
@@ -1,8 +1,9 @@
 import os
 import sys
+import time
 
 from subprocess import CalledProcessError, check_call
-from typing import List, IO, Optional
+from typing import List, IO, Optional, Tuple
 
 
 def which(command: str, paths: Optional[str] = None) -> Optional[str]:
@@ -47,6 +48,87 @@
 return ext in (".i", ".ii", ".c", ".cpp", ".m", "")
 
 
+def time_to_str(time: float) -> str:
+"""
+Convert given time in seconds into a human-readable string.
+"""
+return f"{time:.2f}s"
+
+
+def memory_to_str(memory: int) -> str:
+"""
+Convert given number of bytes into a human-readable string.
+"""
+if memory:
+try:
+import humanize
+return humanize.naturalsize(memory, gnu=True)
+except ImportError:
+# no formatter installed, let's keep it in bytes
+return f"{memory}B"
+
+# If memory is 0, we didn't succeed measuring it.
+return "N/A"
+
+
+def check_and_measure_call(*popenargs, **kwargs) -> Tuple[float, int]:
+"""
+Run command with arguments.  Wait for command to complete and measure
+execution time and peak memory consumption.
+If the exit code was zero then return, otherwise raise
+CalledProcessError.  The CalledProcessError object will have the
+return code in the returncode attribute.
+
+The arguments are the same as for the call and check_call functions.
+
+Return a tuple of execution time and peak memory.
+"""
+peak_mem = 0
+start_time = time.time()
+
+try:
+import psutil as ps
+
+def get_memory(process: ps.Process) -> int:
+mem = 0
+
+# we want to gather memory usage from all of the child processes
+descendants = list(process.children(recursive=True))
+descendants.append(process)
+
+for subprocess in descendants:
+try:
+mem += subprocess.memory_info().rss
+except (ps.NoSuchProcess, ps.AccessDenied):
+continue
+
+return mem
+
+with ps.Popen(*popenargs, **kwargs) as process:
+# while the process is running calculate resource utilization.
+while (process.is_running() and
+   process.status() != ps.STATUS_ZOMBIE):
+# track the peak utilization of the process
+peak_mem = max(peak_mem, get_memory(process))
+time.sleep(.5)
+
+if process.is_running():
+process.kill()
+
+if process.returncode != 0:
+cmd = kwargs.get("args")
+if cmd is None:
+cmd = popenargs[0]
+raise CalledProcessError(process.returncode, cmd)
+
+except ImportError:
+# back off to subprocess if we don't have psutil installed
+peak_mem = 0
+check_call(*popenargs, **kwargs)
+
+return time.time() - start_time, peak_mem
+
+
 def run_script(script_path: str, build_log_file: IO, cwd: str,
out=sys.stdout, err=sys.stderr, verbose: int = 0):
 """
Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -43,7 +43,7 @@
 variable. It should contain a comma separated list.
 """
 import CmpRuns
-import SATestUtils
+import SATestUtils as utils
 from ProjectMap import DownloadType, ProjectInfo
 
 import glob
@@ -63,7 +63,7 @@
 # and this is we can shush that false positive
 from plistlib import InvalidFileException  # type:ignore
 from subprocess import CalledProcessError, check_call
-from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING
+from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING, Tuple
 
 
 ###
@@ -115,7 +115,7 @@
 if 'CC' in os.environ:
 cc_candidate: Optional[str] = os.environ['CC']
 else:
-cc_candidate = SATestUtils.which("clang", os.environ['PATH'])
+cc_candidate = utils.which("clang", os.environ['PATH'])
 if not cc_candidate:
 st

[PATCH] D78899: [Driver] Add callback to Command execution

2020-07-10 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 276945.
sepavloff added a comment.

Rebased patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78899

Files:
  clang/include/clang/Driver/Compilation.h
  clang/lib/Driver/Compilation.cpp
  clang/unittests/Driver/ToolChainTest.cpp


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -259,4 +259,29 @@
   EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl");
   EXPECT_FALSE(Res.TargetIsValid);
 }
+
+TEST(ToolChainTest, PostCallback) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  // The executable path must not exist.
+  Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+  InMemoryFileSystem);
+  CCDriver.setCheckInputsExist(false);
+  std::unique_ptr CC(
+  CCDriver.BuildCompilation({"/home/test/bin/clang", "foo.cpp"}));
+  bool CallbackHasCalled = false;
+  CC->setPostCallback(
+  [&](const Command &C, int Ret) { CallbackHasCalled = true; });
+  const JobList &Jobs = CC->getJobs();
+  auto &CmdCompile = Jobs.getJobs().front();
+  const Command *FailingCmd = nullptr;
+  CC->ExecuteCommand(*CmdCompile, FailingCmd);
+  EXPECT_TRUE(CallbackHasCalled);
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/Compilation.cpp
===
--- clang/lib/Driver/Compilation.cpp
+++ clang/lib/Driver/Compilation.cpp
@@ -193,6 +193,8 @@
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
+  if (PostCallback)
+PostCallback(C, Res);
   if (!Error.empty()) {
 assert(Res && "Error string set with 0 result code!");
 getDriver().Diag(diag::err_drv_command_failure) << Error;
Index: clang/include/clang/Driver/Compilation.h
===
--- clang/include/clang/Driver/Compilation.h
+++ clang/include/clang/Driver/Compilation.h
@@ -115,6 +115,9 @@
   /// Optional redirection for stdin, stdout, stderr.
   std::vector> Redirects;
 
+  /// Callback called after the command has been executed.
+  std::function PostCallback;
+
   /// Whether we're compiling for diagnostic purposes.
   bool ForDiagnostics = false;
 
@@ -212,6 +215,10 @@
 return FailureResultFiles;
   }
 
+  void setPostCallback(const std::function &CB) {
+PostCallback = CB;
+  }
+
   /// Returns the sysroot path.
   StringRef getSysRoot() const;
 


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -259,4 +259,29 @@
   EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl");
   EXPECT_FALSE(Res.TargetIsValid);
 }
+
+TEST(ToolChainTest, PostCallback) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  // The executable path must not exist.
+  Driver CCDriver("/home/test/bin/clang", "arm-linux-gnueabi", Diags,
+  InMemoryFileSystem);
+  CCDriver.setCheckInputsExist(false);
+  std::unique_ptr CC(
+  CCDriver.BuildCompilation({"/home/test/bin/clang", "foo.cpp"}));
+  bool CallbackHasCalled = false;
+  CC->setPostCallback(
+  [&](const Command &C, int Ret) { CallbackHasCalled = true; });
+  const JobList &Jobs = CC->getJobs();
+  auto &CmdCompile = Jobs.getJobs().front();
+  const Command *FailingCmd = nullptr;
+  CC->ExecuteCommand(*CmdCompile, FailingCmd);
+  EXPECT_TRUE(CallbackHasCalled);
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/Compilation.cpp
===
--- clang/lib/Driver/Compilation.cpp
+++ clang/lib/Driver/Compilation.cpp
@@ -193,6 +193,8 @@
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
+  if (PostCallback)
+PostCallback(C, Res);
   if (!Error.empty()) {
 assert(Res && "Error string set with 0 result code!");
 getDriver().Diag(diag::err_drv_command_failure) << Error;
Index: clang/include/clang/Driver/Compilation.h
===
--- clang/include/clang/Driver/Compilation.h
+++ clang/include/clang/Driver/Compilation.h
@@

[PATCH] D83539: [analyzer][tests] Introduce analyzer benchmarking framework

2020-07-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, xazax.hun, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware.
Herald added a project: clang.

This commit includes a couple of changes:

- Benchmark selected projects by analyzing them multiple times
- Compare two benchmarking results and visualizing them on one chart
- Organize project build logging, so we can use the same code in benchmarks


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83539

Files:
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/SATestBenchmark.py
  clang/utils/analyzer/SATestBuild.py
  clang/utils/analyzer/SATestUpdateDiffs.py
  clang/utils/analyzer/requirements.txt

Index: clang/utils/analyzer/requirements.txt
===
--- clang/utils/analyzer/requirements.txt
+++ clang/utils/analyzer/requirements.txt
@@ -1,4 +1,6 @@
 graphviz
 humanize
 matplotlib
+pandas
 psutil
+seaborn
Index: clang/utils/analyzer/SATestUpdateDiffs.py
===
--- clang/utils/analyzer/SATestUpdateDiffs.py
+++ clang/utils/analyzer/SATestUpdateDiffs.py
@@ -21,10 +21,10 @@
 project_dir = tester.get_project_dir()
 
 tester.is_reference_build = True
-ref_results_path = os.path.join(project_dir, tester.get_output_dir())
+ref_results_path = tester.get_output_dir()
 
 tester.is_reference_build = False
-created_results_path = os.path.join(project_dir, tester.get_output_dir())
+created_results_path = tester.get_output_dir()
 
 if not os.path.exists(created_results_path):
 print("New results not found, was SATestBuild.py previously run?",
Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -87,10 +87,18 @@
 return 0
 
 
-Logger = logging.getLogger("main")
 LOCAL = threading.local()
-LOCAL.stdout = StreamToLogger(Logger, logging.INFO)
-LOCAL.stderr = StreamToLogger(Logger, logging.ERROR)
+
+
+def init_logger(name: str):
+# TODO: use debug levels for VERBOSE messages
+logger = logging.getLogger(name)
+logger.setLevel(logging.DEBUG)
+LOCAL.stdout = StreamToLogger(logger, logging.INFO)
+LOCAL.stderr = StreamToLogger(logger, logging.ERROR)
+
+
+init_logger("main")
 
 
 def stderr(message: str):
@@ -102,7 +110,6 @@
 
 
 logging.basicConfig(
-level=logging.DEBUG,
 format='%(asctime)s:%(levelname)s:%(name)s: %(message)s')
 
 
@@ -298,12 +305,13 @@
 """
 A component aggregating testing for one project.
 """
-def __init__(self, test_info: TestInfo):
+def __init__(self, test_info: TestInfo, silent: bool = False):
 self.project = test_info.project
 self.override_compiler = test_info.override_compiler
 self.extra_analyzer_config = test_info.extra_analyzer_config
 self.is_reference_build = test_info.is_reference_build
 self.strictness = test_info.strictness
+self.silent = silent
 
 def test(self) -> bool:
 """
@@ -312,20 +320,19 @@
 to the :param strictness: criteria.
 """
 if not self.project.enabled:
-stdout(f" \n\n--- Skipping disabled project {self.project.name}\n")
+self.out(
+f" \n\n--- Skipping disabled project {self.project.name}\n")
 return True
 
-stdout(f" \n\n--- Building project {self.project.name}\n")
+self.out(f" \n\n--- Building project {self.project.name}\n")
 
 start_time = time.time()
 
 project_dir = self.get_project_dir()
-if VERBOSE >= 1:
-stdout(f"  Build directory: {project_dir}.\n")
+self.vout(f"  Build directory: {project_dir}.\n")
 
 # Set the build results directory.
 output_dir = self.get_output_dir()
-output_dir = os.path.join(project_dir, output_dir)
 
 self.build(project_dir, output_dir)
 check_build(output_dir)
@@ -336,8 +343,8 @@
 else:
 passed = run_cmp_results(project_dir, self.strictness)
 
-stdout(f"Completed tests for project {self.project.name} "
-   f"(time: {time.time() - start_time:.2f}).\n")
+self.out(f"Completed tests for project {self.project.name} "
+ f"(time: {time.time() - start_time:.2f}).\n")
 
 return passed
 
@@ -346,22 +353,23 @@
 
 def get_output_dir(self) -> str:
 if self.is_reference_build:
-return REF_PREFIX + OUTPUT_DIR_NAME
+dirname = REF_PREFIX + OUTPUT_DIR_NAME
 else:
-return OUTPUT_DIR_NAME
+dirname = OUTPUT_DIR_NAME
+
+return os.path.join(self.get_project_dir(), dirname)
 
-def build(self, directory: str, output_dir: str):
+def 

[PATCH] D83536: [clangd] Index refs to main-file symbols as well

2020-07-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Thanks a lot for doing this Nathan and sorry for not replying with a concrete 
decision on the issue tracker, we were still discussing it internally, as 7% 
increase for allowing multi-level call hierarchy support (compared to ~10% 
initial cost for single-level support) seems quite high. Especially right 
before a new llvm release cut (which is due in 5 days).

I can see how this is needed for implementing the full protocol though (we've 
already cut on the multi-level callees support), so would you be so kind to 
hide this behind an option to symbol collector (`CollectRefsInMainFile`) and 
then introduce a flag to clangd for controlling it 
`--collect-refs-in-main-file` and plumb it to `BackgroundIndex` and `FileIndex` 
via `ClangdServer`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83536



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


[clang] 9c7ff0a - [analyzer][tests] Make test interruption safe

2020-07-10 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-07-10T11:31:59+03:00
New Revision: 9c7ff0a4aaef0a1efa33e9ff8a12a064087bded9

URL: 
https://github.com/llvm/llvm-project/commit/9c7ff0a4aaef0a1efa33e9ff8a12a064087bded9
DIFF: 
https://github.com/llvm/llvm-project/commit/9c7ff0a4aaef0a1efa33e9ff8a12a064087bded9.diff

LOG: [analyzer][tests] Make test interruption safe

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

Added: 


Modified: 
clang/utils/analyzer/SATest.py

Removed: 




diff  --git a/clang/utils/analyzer/SATest.py b/clang/utils/analyzer/SATest.py
index fb2e031c6ab6..16f1dce0c584 100755
--- a/clang/utils/analyzer/SATest.py
+++ b/clang/utils/analyzer/SATest.py
@@ -132,27 +132,35 @@ def docker_shell(args):
 pass
 
 finally:
-print("Please wait for docker to clean up")
-call("docker stop satest", shell=True)
+docker_cleanup()
 
 
 def docker_run(args, command, docker_args=""):
-return call("docker run --rm --name satest "
-"-v {llvm}:/llvm-project "
-"-v {build}:/build "
-"-v {clang}:/analyzer "
-"-v {scripts}:/scripts "
-"-v {projects}:/projects "
-"{docker_args} "
-"satest-image:latest {command}"
-.format(llvm=args.llvm_project_dir,
-build=args.build_dir,
-clang=args.clang_dir,
-scripts=SCRIPTS_DIR,
-projects=PROJECTS_DIR,
-docker_args=docker_args,
-command=command),
-shell=True)
+try:
+return call("docker run --rm --name satest "
+"-v {llvm}:/llvm-project "
+"-v {build}:/build "
+"-v {clang}:/analyzer "
+"-v {scripts}:/scripts "
+"-v {projects}:/projects "
+"{docker_args} "
+"satest-image:latest {command}"
+.format(llvm=args.llvm_project_dir,
+build=args.build_dir,
+clang=args.clang_dir,
+scripts=SCRIPTS_DIR,
+projects=PROJECTS_DIR,
+docker_args=docker_args,
+command=command),
+shell=True)
+
+except KeyboardInterrupt:
+docker_cleanup()
+
+
+def docker_cleanup():
+print("Please wait for docker to clean up")
+call("docker stop satest", shell=True)
 
 
 def main():



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


[clang] 00997d1 - [analyzer][tests] Fix zip unpacking

2020-07-10 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-07-10T11:32:13+03:00
New Revision: 00997d1cad9ecd40c92aeae40269f6bfb9e58d11

URL: 
https://github.com/llvm/llvm-project/commit/00997d1cad9ecd40c92aeae40269f6bfb9e58d11
DIFF: 
https://github.com/llvm/llvm-project/commit/00997d1cad9ecd40c92aeae40269f6bfb9e58d11.diff

LOG: [analyzer][tests] Fix zip unpacking

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

Added: 


Modified: 
clang/utils/analyzer/SATestBuild.py

Removed: 




diff  --git a/clang/utils/analyzer/SATestBuild.py 
b/clang/utils/analyzer/SATestBuild.py
index ee510e03cc5a..eefab869f6ef 100644
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -601,7 +601,7 @@ def _download_from_git(self, directory: str, 
build_log_file: IO):
stdout=build_log_file, shell=True)
 
 def _unpack_zip(self, directory: str, build_log_file: IO):
-zip_files = list(glob.glob(os.path.join(directory, "/*.zip")))
+zip_files = list(glob.glob(directory + "/*.zip"))
 
 if len(zip_files) == 0:
 raise ValueError(



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


[clang] 21bacc2 - [analyzer][tests] Measure peak memory consumption for every project

2020-07-10 Thread Valeriy Savchenko via cfe-commits

Author: Valeriy Savchenko
Date: 2020-07-10T11:31:41+03:00
New Revision: 21bacc215413d10df53a4690e9561e9b96698742

URL: 
https://github.com/llvm/llvm-project/commit/21bacc215413d10df53a4690e9561e9b96698742
DIFF: 
https://github.com/llvm/llvm-project/commit/21bacc215413d10df53a4690e9561e9b96698742.diff

LOG: [analyzer][tests] Measure peak memory consumption for every project

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

Added: 
clang/utils/analyzer/requirements.txt

Modified: 
clang/utils/analyzer/Dockerfile
clang/utils/analyzer/SATestBuild.py
clang/utils/analyzer/SATestUtils.py

Removed: 




diff  --git a/clang/utils/analyzer/Dockerfile b/clang/utils/analyzer/Dockerfile
index 30fb67cf93c8..21906011c7dc 100644
--- a/clang/utils/analyzer/Dockerfile
+++ b/clang/utils/analyzer/Dockerfile
@@ -54,8 +54,7 @@ ENV PATH="/analyzer/bin:${PATH}"
 
 ADD entrypoint.py /entrypoint.py
 
-# Uncomment in case of requirements
-# ADD requirements.txt /requirements.txt
-# RUN pip3 install -r /requirements.txt
+ADD requirements.txt /requirements.txt
+RUN pip3 install -r /requirements.txt
 
 ENTRYPOINT ["python", "/entrypoint.py"]

diff  --git a/clang/utils/analyzer/SATestBuild.py 
b/clang/utils/analyzer/SATestBuild.py
index 7d337632744f..ee510e03cc5a 100644
--- a/clang/utils/analyzer/SATestBuild.py
+++ b/clang/utils/analyzer/SATestBuild.py
@@ -43,7 +43,7 @@
 variable. It should contain a comma separated list.
 """
 import CmpRuns
-import SATestUtils
+import SATestUtils as utils
 from ProjectMap import DownloadType, ProjectInfo
 
 import glob
@@ -63,7 +63,7 @@
 # and this is we can shush that false positive
 from plistlib import InvalidFileException  # type:ignore
 from subprocess import CalledProcessError, check_call
-from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING
+from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING, Tuple
 
 
 ###
@@ -115,7 +115,7 @@ def stdout(message: str):
 if 'CC' in os.environ:
 cc_candidate: Optional[str] = os.environ['CC']
 else:
-cc_candidate = SATestUtils.which("clang", os.environ['PATH'])
+cc_candidate = utils.which("clang", os.environ['PATH'])
 if not cc_candidate:
 stderr("Error: cannot find 'clang' in PATH")
 sys.exit(1)
@@ -194,9 +194,9 @@ def run_cleanup_script(directory: str, build_log_file: IO):
 cwd = os.path.join(directory, PATCHED_SOURCE_DIR_NAME)
 script_path = os.path.join(directory, CLEANUP_SCRIPT)
 
-SATestUtils.run_script(script_path, build_log_file, cwd,
-   out=LOCAL.stdout, err=LOCAL.stderr,
-   verbose=VERBOSE)
+utils.run_script(script_path, build_log_file, cwd,
+ out=LOCAL.stdout, err=LOCAL.stderr,
+ verbose=VERBOSE)
 
 
 class TestInfo(NamedTuple):
@@ -351,8 +351,6 @@ def get_output_dir(self) -> str:
 return OUTPUT_DIR_NAME
 
 def build(self, directory: str, output_dir: str):
-time_start = time.time()
-
 build_log_path = get_build_log_path(output_dir)
 
 stdout(f"Log file: {build_log_path}\n")
@@ -375,19 +373,23 @@ def build(self, directory: str, output_dir: str):
 if self.project.mode == 1:
 self._download_and_patch(directory, build_log_file)
 run_cleanup_script(directory, build_log_file)
-self.scan_build(directory, output_dir, build_log_file)
+build_time, memory = self.scan_build(directory, output_dir,
+   build_log_file)
 else:
-self.analyze_preprocessed(directory, output_dir)
+build_time, memory = self.analyze_preprocessed(directory,
+   output_dir)
 
 if self.is_reference_build:
 run_cleanup_script(directory, build_log_file)
 normalize_reference_results(directory, output_dir,
 self.project.mode)
 
-stdout(f"Build complete (time: {time.time() - time_start:.2f}). "
+stdout(f"Build complete (time: {utils.time_to_str(build_time)}, "
+   f"peak memory: {utils.memory_to_str(memory)}). "
f"See the log for more details: {build_log_path}\n")
 
-def scan_build(self, directory: str, output_dir: str, build_log_file: IO):
+def scan_build(self, directory: str, output_dir: str,
+   build_log_file: IO) -> Tuple[float, int]:
 """
 Build the project with scan-build by reading in the commands and
 prefixing them with the scan-build options.
@@ -416,6 +418,10 @@ def scan_build(self, directory: str, output_dir: str, 
build_log_file: IO):
 options += "--override-compiler "
 
 extra_env: Dict[s

[PATCH] D82967: [analyzer][tests] Measure peak memory consumption for every project

2020-07-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG21bacc215413: [analyzer][tests] Measure peak memory 
consumption for every project (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82967

Files:
  clang/utils/analyzer/Dockerfile
  clang/utils/analyzer/SATestBuild.py
  clang/utils/analyzer/SATestUtils.py
  clang/utils/analyzer/requirements.txt

Index: clang/utils/analyzer/requirements.txt
===
--- /dev/null
+++ clang/utils/analyzer/requirements.txt
@@ -0,0 +1,4 @@
+graphviz
+humanize
+matplotlib
+psutil
Index: clang/utils/analyzer/SATestUtils.py
===
--- clang/utils/analyzer/SATestUtils.py
+++ clang/utils/analyzer/SATestUtils.py
@@ -1,8 +1,9 @@
 import os
 import sys
+import time
 
 from subprocess import CalledProcessError, check_call
-from typing import List, IO, Optional
+from typing import List, IO, Optional, Tuple
 
 
 def which(command: str, paths: Optional[str] = None) -> Optional[str]:
@@ -47,6 +48,87 @@
 return ext in (".i", ".ii", ".c", ".cpp", ".m", "")
 
 
+def time_to_str(time: float) -> str:
+"""
+Convert given time in seconds into a human-readable string.
+"""
+return f"{time:.2f}s"
+
+
+def memory_to_str(memory: int) -> str:
+"""
+Convert given number of bytes into a human-readable string.
+"""
+if memory:
+try:
+import humanize
+return humanize.naturalsize(memory, gnu=True)
+except ImportError:
+# no formatter installed, let's keep it in bytes
+return f"{memory}B"
+
+# If memory is 0, we didn't succeed measuring it.
+return "N/A"
+
+
+def check_and_measure_call(*popenargs, **kwargs) -> Tuple[float, int]:
+"""
+Run command with arguments.  Wait for command to complete and measure
+execution time and peak memory consumption.
+If the exit code was zero then return, otherwise raise
+CalledProcessError.  The CalledProcessError object will have the
+return code in the returncode attribute.
+
+The arguments are the same as for the call and check_call functions.
+
+Return a tuple of execution time and peak memory.
+"""
+peak_mem = 0
+start_time = time.time()
+
+try:
+import psutil as ps
+
+def get_memory(process: ps.Process) -> int:
+mem = 0
+
+# we want to gather memory usage from all of the child processes
+descendants = list(process.children(recursive=True))
+descendants.append(process)
+
+for subprocess in descendants:
+try:
+mem += subprocess.memory_info().rss
+except (ps.NoSuchProcess, ps.AccessDenied):
+continue
+
+return mem
+
+with ps.Popen(*popenargs, **kwargs) as process:
+# while the process is running calculate resource utilization.
+while (process.is_running() and
+   process.status() != ps.STATUS_ZOMBIE):
+# track the peak utilization of the process
+peak_mem = max(peak_mem, get_memory(process))
+time.sleep(.5)
+
+if process.is_running():
+process.kill()
+
+if process.returncode != 0:
+cmd = kwargs.get("args")
+if cmd is None:
+cmd = popenargs[0]
+raise CalledProcessError(process.returncode, cmd)
+
+except ImportError:
+# back off to subprocess if we don't have psutil installed
+peak_mem = 0
+check_call(*popenargs, **kwargs)
+
+return time.time() - start_time, peak_mem
+
+
 def run_script(script_path: str, build_log_file: IO, cwd: str,
out=sys.stdout, err=sys.stderr, verbose: int = 0):
 """
Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -43,7 +43,7 @@
 variable. It should contain a comma separated list.
 """
 import CmpRuns
-import SATestUtils
+import SATestUtils as utils
 from ProjectMap import DownloadType, ProjectInfo
 
 import glob
@@ -63,7 +63,7 @@
 # and this is we can shush that false positive
 from plistlib import InvalidFileException  # type:ignore
 from subprocess import CalledProcessError, check_call
-from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING
+from typing import Dict, IO, List, NamedTuple, Optional, TYPE_CHECKING, Tuple
 
 
 ###
@@ -115,7 +115,7 @@
 if 'CC' in os.environ:
 cc_candidate: Optional[str] = os.environ['CC']
 else:
-cc_candidate = SATestUtils.which("clang", os.environ['PATH'])
+cc_candida

[PATCH] D83374: [analyzer][tests] Fix zip unpacking

2020-07-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG00997d1cad9e: [analyzer][tests] Fix zip unpacking (authored 
by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83374

Files:
  clang/utils/analyzer/SATestBuild.py


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -601,7 +601,7 @@
stdout=build_log_file, shell=True)
 
 def _unpack_zip(self, directory: str, build_log_file: IO):
-zip_files = list(glob.glob(os.path.join(directory, "/*.zip")))
+zip_files = list(glob.glob(directory + "/*.zip"))
 
 if len(zip_files) == 0:
 raise ValueError(


Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -601,7 +601,7 @@
stdout=build_log_file, shell=True)
 
 def _unpack_zip(self, directory: str, build_log_file: IO):
-zip_files = list(glob.glob(os.path.join(directory, "/*.zip")))
+zip_files = list(glob.glob(directory + "/*.zip"))
 
 if len(zip_files) == 0:
 raise ValueError(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83373: [analyzer][tests] Make test interruption safe

2020-07-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c7ff0a4aaef: [analyzer][tests] Make test interruption safe 
(authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83373

Files:
  clang/utils/analyzer/SATest.py


Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -132,27 +132,35 @@
 pass
 
 finally:
-print("Please wait for docker to clean up")
-call("docker stop satest", shell=True)
+docker_cleanup()
 
 
 def docker_run(args, command, docker_args=""):
-return call("docker run --rm --name satest "
-"-v {llvm}:/llvm-project "
-"-v {build}:/build "
-"-v {clang}:/analyzer "
-"-v {scripts}:/scripts "
-"-v {projects}:/projects "
-"{docker_args} "
-"satest-image:latest {command}"
-.format(llvm=args.llvm_project_dir,
-build=args.build_dir,
-clang=args.clang_dir,
-scripts=SCRIPTS_DIR,
-projects=PROJECTS_DIR,
-docker_args=docker_args,
-command=command),
-shell=True)
+try:
+return call("docker run --rm --name satest "
+"-v {llvm}:/llvm-project "
+"-v {build}:/build "
+"-v {clang}:/analyzer "
+"-v {scripts}:/scripts "
+"-v {projects}:/projects "
+"{docker_args} "
+"satest-image:latest {command}"
+.format(llvm=args.llvm_project_dir,
+build=args.build_dir,
+clang=args.clang_dir,
+scripts=SCRIPTS_DIR,
+projects=PROJECTS_DIR,
+docker_args=docker_args,
+command=command),
+shell=True)
+
+except KeyboardInterrupt:
+docker_cleanup()
+
+
+def docker_cleanup():
+print("Please wait for docker to clean up")
+call("docker stop satest", shell=True)
 
 
 def main():


Index: clang/utils/analyzer/SATest.py
===
--- clang/utils/analyzer/SATest.py
+++ clang/utils/analyzer/SATest.py
@@ -132,27 +132,35 @@
 pass
 
 finally:
-print("Please wait for docker to clean up")
-call("docker stop satest", shell=True)
+docker_cleanup()
 
 
 def docker_run(args, command, docker_args=""):
-return call("docker run --rm --name satest "
-"-v {llvm}:/llvm-project "
-"-v {build}:/build "
-"-v {clang}:/analyzer "
-"-v {scripts}:/scripts "
-"-v {projects}:/projects "
-"{docker_args} "
-"satest-image:latest {command}"
-.format(llvm=args.llvm_project_dir,
-build=args.build_dir,
-clang=args.clang_dir,
-scripts=SCRIPTS_DIR,
-projects=PROJECTS_DIR,
-docker_args=docker_args,
-command=command),
-shell=True)
+try:
+return call("docker run --rm --name satest "
+"-v {llvm}:/llvm-project "
+"-v {build}:/build "
+"-v {clang}:/analyzer "
+"-v {scripts}:/scripts "
+"-v {projects}:/projects "
+"{docker_args} "
+"satest-image:latest {command}"
+.format(llvm=args.llvm_project_dir,
+build=args.build_dir,
+clang=args.clang_dir,
+scripts=SCRIPTS_DIR,
+projects=PROJECTS_DIR,
+docker_args=docker_args,
+command=command),
+shell=True)
+
+except KeyboardInterrupt:
+docker_cleanup()
+
+
+def docker_cleanup():
+print("Please wait for docker to clean up")
+call("docker stop satest", shell=True)
 
 
 def main():
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83539: [analyzer][tests] Introduce analyzer benchmarking framework

2020-07-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 276950.
vsavchenko added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83539

Files:
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/SATestBenchmark.py
  clang/utils/analyzer/SATestBuild.py
  clang/utils/analyzer/SATestUpdateDiffs.py
  clang/utils/analyzer/requirements.txt

Index: clang/utils/analyzer/requirements.txt
===
--- clang/utils/analyzer/requirements.txt
+++ clang/utils/analyzer/requirements.txt
@@ -1,4 +1,6 @@
 graphviz
 humanize
 matplotlib
+pandas
 psutil
+seaborn
Index: clang/utils/analyzer/SATestUpdateDiffs.py
===
--- clang/utils/analyzer/SATestUpdateDiffs.py
+++ clang/utils/analyzer/SATestUpdateDiffs.py
@@ -21,10 +21,10 @@
 project_dir = tester.get_project_dir()
 
 tester.is_reference_build = True
-ref_results_path = os.path.join(project_dir, tester.get_output_dir())
+ref_results_path = tester.get_output_dir()
 
 tester.is_reference_build = False
-created_results_path = os.path.join(project_dir, tester.get_output_dir())
+created_results_path = tester.get_output_dir()
 
 if not os.path.exists(created_results_path):
 print("New results not found, was SATestBuild.py previously run?",
Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -87,10 +87,18 @@
 return 0
 
 
-Logger = logging.getLogger("main")
 LOCAL = threading.local()
-LOCAL.stdout = StreamToLogger(Logger, logging.INFO)
-LOCAL.stderr = StreamToLogger(Logger, logging.ERROR)
+
+
+def init_logger(name: str):
+# TODO: use debug levels for VERBOSE messages
+logger = logging.getLogger(name)
+logger.setLevel(logging.DEBUG)
+LOCAL.stdout = StreamToLogger(logger, logging.INFO)
+LOCAL.stderr = StreamToLogger(logger, logging.ERROR)
+
+
+init_logger("main")
 
 
 def stderr(message: str):
@@ -102,7 +110,6 @@
 
 
 logging.basicConfig(
-level=logging.DEBUG,
 format='%(asctime)s:%(levelname)s:%(name)s: %(message)s')
 
 
@@ -298,12 +305,13 @@
 """
 A component aggregating testing for one project.
 """
-def __init__(self, test_info: TestInfo):
+def __init__(self, test_info: TestInfo, silent: bool = False):
 self.project = test_info.project
 self.override_compiler = test_info.override_compiler
 self.extra_analyzer_config = test_info.extra_analyzer_config
 self.is_reference_build = test_info.is_reference_build
 self.strictness = test_info.strictness
+self.silent = silent
 
 def test(self) -> bool:
 """
@@ -312,20 +320,19 @@
 to the :param strictness: criteria.
 """
 if not self.project.enabled:
-stdout(f" \n\n--- Skipping disabled project {self.project.name}\n")
+self.out(
+f" \n\n--- Skipping disabled project {self.project.name}\n")
 return True
 
-stdout(f" \n\n--- Building project {self.project.name}\n")
+self.out(f" \n\n--- Building project {self.project.name}\n")
 
 start_time = time.time()
 
 project_dir = self.get_project_dir()
-if VERBOSE >= 1:
-stdout(f"  Build directory: {project_dir}.\n")
+self.vout(f"  Build directory: {project_dir}.\n")
 
 # Set the build results directory.
 output_dir = self.get_output_dir()
-output_dir = os.path.join(project_dir, output_dir)
 
 self.build(project_dir, output_dir)
 check_build(output_dir)
@@ -336,8 +343,8 @@
 else:
 passed = run_cmp_results(project_dir, self.strictness)
 
-stdout(f"Completed tests for project {self.project.name} "
-   f"(time: {time.time() - start_time:.2f}).\n")
+self.out(f"Completed tests for project {self.project.name} "
+ f"(time: {time.time() - start_time:.2f}).\n")
 
 return passed
 
@@ -346,22 +353,23 @@
 
 def get_output_dir(self) -> str:
 if self.is_reference_build:
-return REF_PREFIX + OUTPUT_DIR_NAME
+dirname = REF_PREFIX + OUTPUT_DIR_NAME
 else:
-return OUTPUT_DIR_NAME
+dirname = OUTPUT_DIR_NAME
+
+return os.path.join(self.get_project_dir(), dirname)
 
-def build(self, directory: str, output_dir: str):
+def build(self, directory: str, output_dir: str) -> Tuple[float, int]:
 build_log_path = get_build_log_path(output_dir)
 
-stdout(f"Log file: {build_log_path}\n")
-stdout(f"Output directory: {output_dir}\n")
+self.out(f"Log file: {build_log_path}\n")
+self.out(f"Output directory: {output_dir}\n")
 
 remove_log_file(output_dir)
 
 

[PATCH] D83539: [analyzer][tests] Introduce analyzer benchmarking framework

2020-07-10 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Here is an example of how benchmarking chart looks like:

F12321843: plot2.png 

It has 20 runs on each of those projects.  It was the same revision of the 
analyzer, so it is still very sensitive to other stuff happening on the test 
machine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83539



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


[PATCH] D83294: [Fixed Point] Add codegen for fixed-point shifts.

2020-07-10 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan marked an inline comment as done.
ebevhan added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3857
+
+  // TODO: This misses out on the sanitizer check below.
+  if (Ops.isFixedPointOp())

leonardchan wrote:
> I don't suppose you could file a bug for this and CC me on it so we can 
> remember to do this sometime after this lands?
I could do that. I guess the issue is larger than just this; I think other ops 
do not get proper UBSan checks for fixedpoint. So the ticket would probably 
entail supporting UBSan for fixedpoint, which is maybe a bit larger in scope.



Comment at: clang/test/Frontend/fixed_point_compound.c:388-390
+  // UNSIGNED-NEXT: [[TMP7:%.*]] = icmp slt i16 [[TMP6]], 0
+  // UNSIGNED-NEXT: [[SATMIN:%.*]] = select i1 [[TMP7]], i16 0, i16 [[TMP6]]
+  // UNSIGNED-NEXT: store i16 [[SATMIN]], i16* @suf, align 2

leonardchan wrote:
> I'm assuming these checks are also a result of D82663? I don't think for the 
> padding case, we should need to do the compare and select if we're already 
> using the signed sat intrinsic. But I'm guessing it might make the 
> implementation more complicated by having to check for this.
> 
> If this codegen comes from the `EmitFixedPointConversion` at the end of 
> `EmitFixedPointBinOp`, perhaps it might be worthwhile adding a parameter in 
> `EmitFixedPointConversion` to indicate that we shouldn't emit this. I think 
> there's some cases in D82663 also where we might not need to do these checks 
> afterwards with other operations like with:
> 
> ```
> // UNSIGNED-NEXT: [[TMP25:%.*]] = call i16 @llvm.sadd.sat.i16(i16 [[TMP22]], 
> i16 32767)
> // UNSIGNED-NEXT: [[TMP26:%.*]] = icmp slt i16 [[TMP25]], 0
> // UNSIGNED-NEXT: [[SATMIN2:%.*]] = select i1 [[TMP26]], i16 0, i16 [[TMP25]]
> // UNSIGNED-NEXT: store i16 [[SATMIN2]], i16* @suf, align 2
> ```
Yes, this is correct. And it is also correct that in the case of shift (and 
other operations) it is not necessary. It was just more elegant to make the 
common semantic signed and the result semantic unsigned and get the clamp 
automatically.

I think the alternative is to handle the signedness of ops separate from the 
semantic during codegen and then emit a clamp manually per-operation instead of 
relying on the result conversion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83294



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


[PATCH] D71124: [RISCV] support clang driver to select cpu

2020-07-10 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen updated this revision to Diff 276951.
khchen added a comment.

addess asb's comment.

[RISCV][Clang] Support -mcpu option.

Summary:

1. gcc uses `-march` and `-mtune` flag to chose arch and

pipeline model, but clang does not have `-mtune` flag,
we uses `-mcpu` to chose both info.

2. Add SiFive e31 and u54 cpu which have default march

and pipeline model.

3. Specific `-mcpu` with rocket-rv[32|64] would select

pipeline model only, and use the driver's arch choosing
logic to get default arch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71124

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/riscv-cpus.c
  llvm/include/llvm/Support/RISCVTargetParser.def
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp
  llvm/lib/Target/RISCV/RISCV.td

Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -215,6 +215,16 @@
 
 def : ProcessorModel<"rocket-rv64", Rocket64Model, [Feature64Bit]>;
 
+def : ProcessorModel<"sifive-e31", Rocket32Model, [FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtC]>;
+
+def : ProcessorModel<"sifive-u54", Rocket64Model, [Feature64Bit,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC]>;
 
 //===--===//
 // Define the RISC-V target.
Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -13,6 +13,7 @@
 
 #include "llvm/Support/ARMBuildAttributes.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
@@ -208,3 +209,64 @@
   default: return {0, 0, 0};
   }
 }
+
+namespace llvm {
+namespace RISCV {
+
+struct CPUInfo {
+  StringLiteral Name;
+  CPUKind Kind;
+  unsigned Features;
+  StringLiteral DefaultMarch;
+  bool Is64Bit() const { return (Features & FK_64BIT); }
+};
+
+constexpr CPUInfo RISCVCPUInfo[] = {
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)  \
+  {NAME, CK_##ENUM, FEATURES, DEFAULT_MARCH},
+#include "llvm/Support/RISCVTargetParser.def"
+};
+
+bool checkCPUKind(CPUKind Kind, bool IsRV64) {
+  if (Kind == CK_INVALID)
+return false;
+  return RISCVCPUInfo[static_cast(Kind)].Is64Bit() == IsRV64;
+}
+
+CPUKind parseCPUKind(StringRef CPU) {
+  return llvm::StringSwitch(CPU)
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) .Case(NAME, CK_##ENUM)
+#include "llvm/Support/RISCVTargetParser.def"
+  .Default(CK_INVALID);
+}
+
+StringRef getMArchFromMcpu(StringRef CPU) {
+  CPUKind Kind = parseCPUKind(CPU);
+  return RISCVCPUInfo[static_cast(Kind)].DefaultMarch;
+}
+
+void fillValidCPUArchList(SmallVectorImpl &Values, bool IsRV64) {
+  for (const auto &C : RISCVCPUInfo) {
+if (IsRV64 == C.Is64Bit())
+  Values.emplace_back(C.Name);
+  }
+}
+
+// Get all features except standard extension feature
+bool getCPUFeaturesExceptStdExt(CPUKind Kind,
+std::vector &Features) {
+  unsigned features = RISCVCPUInfo[static_cast(Kind)].Features;
+
+  if (features == FK_INVALID)
+return false;
+
+  if (features & FK_64BIT)
+Features.push_back("+64bit");
+  else
+Features.push_back("-64bit");
+
+  return true;
+}
+
+} // namespace RISCV
+} // namespace llvm
Index: llvm/include/llvm/Support/TargetParser.h
===
--- llvm/include/llvm/Support/TargetParser.h
+++ llvm/include/llvm/Support/TargetParser.h
@@ -130,6 +130,32 @@
 
 } // namespace AMDGPU
 
+namespace RISCV {
+
+enum CPUKind : unsigned {
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
+#include "RISCVTargetParser.def"
+};
+
+enum FeatureKind : unsigned {
+  FK_INVALID = 0,
+  FK_NONE = 1,
+  FK_STDEXTM = 1 << 2,
+  FK_STDEXTA = 1 << 3,
+  FK_STDEXTF = 1 << 4,
+  FK_STDEXTD = 1 << 5,
+  FK_STDEXTC = 1 << 6,
+  FK_64BIT = 1 << 7,
+};
+
+bool checkCPUKind(CPUKind kind, bool IsRV64);
+CPUKind parseCPUKind(StringRef CPU);
+StringRef getMArchFromMcpu(StringRef CPU);
+void fillValidCPUArchList(SmallVectorImpl &Values, bool IsRV64);
+bool getCPUFeaturesExceptStdExt(CPUKi

[PATCH] D83055: [clang][Driver] Fix tool path priority test failures

2020-07-10 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett updated this revision to Diff 276952.
DavidSpickett added a comment.

- mv with stderr redirected instead of using non standard file -E flag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83055

Files:
  clang/test/Driver/program-path-priority.c
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -46,6 +46,8 @@
 config.substitutions.append(
 ('%src_include_dir', config.clang_src_dir + '/include'))
 
+config.substitutions.append(
+('%target_triple', config.target_triple))
 
 # Propagate path to symbolizer for ASan/MSan.
 llvm_config.with_system_environment(
Index: clang/test/Driver/program-path-priority.c
===
--- clang/test/Driver/program-path-priority.c
+++ clang/test/Driver/program-path-priority.c
@@ -13,6 +13,11 @@
 /// so only name priority is accounted for, unless we fail to find
 /// anything at all in the prefix.
 
+/// Note: All matches are expected to be at the end of file paths.
+/// So we match " on the end to account for build systems that
+/// put the name of the compiler in the build path.
+/// E.g. /build/gcc_X.Y.Z/0/...
+
 /// Symlink clang to a new dir which will be its
 /// "program path" for these tests
 // RUN: rm -rf %t && mkdir -p %t
@@ -21,14 +26,18 @@
 /// No gccs at all, nothing is found
 // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NO_NOTREAL_GCC %s
-// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc
-// NO_NOTREAL_GCC-NOT: /gcc
+// NO_NOTREAL_GCC-NOT: notreal-none-elf-gcc"
+/// Some systems will have "gcc-x.y.z" so for this first check
+/// make sure we don't find "gcc" or "gcc-x.y.z". If we do find either
+/// then there is no point continuing as this copy of clang is not
+/// isolated as we expected.
+// NO_NOTREAL_GCC-NOT: {{/gcc[^/]*"}}
 
 /// -gcc in program path is found
 // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc
 // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=PROG_PATH_NOTREAL_GCC %s
-// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc
+// PROG_PATH_NOTREAL_GCC: notreal-none-elf-gcc"
 
 /// -gcc on the PATH is found
 // RUN: mkdir -p %t/env
@@ -36,74 +45,87 @@
 // RUN: touch %t/env/notreal-none-elf-gcc && chmod +x %t/env/notreal-none-elf-gcc
 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=ENV_PATH_NOTREAL_GCC %s
-// ENV_PATH_NOTREAL_GCC: env/notreal-none-elf-gcc
+// ENV_PATH_NOTREAL_GCC: env/notreal-none-elf-gcc"
 
 /// -gcc in program path is preferred to one on the PATH
 // RUN: touch %t/notreal-none-elf-gcc && chmod +x %t/notreal-none-elf-gcc
 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=BOTH_NOTREAL_GCC %s
-// BOTH_NOTREAL_GCC: notreal-none-elf-gcc
-// BOTH_NOTREAL_GCC-NOT: env/notreal-none-elf-gcc
+// BOTH_NOTREAL_GCC: notreal-none-elf-gcc"
+// BOTH_NOTREAL_GCC-NOT: env/notreal-none-elf-gcc"
 
 /// On program path, -gcc is preferred to plain gcc
 // RUN: touch %t/gcc && chmod +x %t/gcc
 // RUN: env "PATH=" %t/clang -### -target notreal-none-elf %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NOTREAL_GCC_PREFERRED %s
-// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc
-// NOTREAL_GCC_PREFERRED-NOT: /gcc
+// NOTREAL_GCC_PREFERRED: notreal-none-elf-gcc"
+// NOTREAL_GCC_PREFERRED-NOT: /gcc"
 
 /// -gcc on the PATH is preferred to gcc in program path
 // RUN: rm %t/notreal-none-elf-gcc
 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PROG %s
-// NOTREAL_PATH_OVER_GCC_PROG: env/notreal-none-elf-gcc
-// NOTREAL_PATH_OVER_GCC_PROG-NOT: /gcc
+// NOTREAL_PATH_OVER_GCC_PROG: env/notreal-none-elf-gcc"
+// NOTREAL_PATH_OVER_GCC_PROG-NOT: /gcc"
 
 /// -gcc on the PATH is preferred to gcc on the PATH
 // RUN: rm %t/gcc
 // RUN: touch %t/env/gcc && chmod +x %t/env/gcc
 // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NOTREAL_PATH_OVER_GCC_PATH %s
-// NOTREAL_PATH_OVER_GCC_PATH: env/notreal-none-elf-gcc
-// NOTREAL_PATH_OVER_GCC_PATH-NOT: /gcc
+// NOTREAL_PATH_OVER_GCC_PATH: env/notreal-none-elf-gcc"
+// NOTREAL_PATH_OVER_GCC_PATH-NOT: /gcc"
+
+/// We cannot trust clang --version, or cmake's LLVM_DEFAULT_TARGET_TRIPLE
+/// to give us the one and only default triple.
+/// Can't trust cmake because on Darwin, triples have a verison appended to them.
+/// (and clang uses the versioned string to search)
+/// Can't trust --version because it will pad 3 item triples to 4 e.g.
+/// powerpc64le-linux-gnu -> powerpc64le-unknown-linux-gnu
+/// (and clang uses the former to search)
+///

[PATCH] D83013: [LPM] Port CGProfilePass from NPM to LPM

2020-07-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.

Still lgtm. For what it's worth, I think you could have just re-committed with 
the fixes rather than uploading for review again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83013



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


[PATCH] D82574: Merge TableGen files used for clang options

2020-07-10 Thread Stephan Herhut via Phabricator via cfe-commits
herhut added a comment.

Could you add the normalization back? This is in line with the comment to make 
sure the old and new files align.




Comment at: clang/include/clang/Driver/Options.td:3455
+  HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
+  MarshallingInfoString<"TargetOpts->Triple", 
"llvm::sys::getDefaultTargetTriple()", "std::string">,
+  AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;

There is some explicit normalization missing here. In CC1Options.td this is

```
def triple : Separate<["-"], "triple">,
  HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
  MarshallingInfoString<"TargetOpts->Triple", 
"llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">,
  AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;
```

It seems the normalizer does not apply to the defaults and we now see a failure 
in `clang/unittests/Frontend/CompilerInvocationTest.cpp` for powerpc targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82574



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


[PATCH] D83055: [clang][Driver] Fix tool path priority test failures

2020-07-10 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett marked 2 inline comments as done.
DavidSpickett added inline comments.



Comment at: clang/test/Driver/program-path-priority.c:117
+/// Check file exists first in case $DEFAULT_TRIPLE == %target_triple
+// RUN: file -E %t/$DEFAULT_TRIPLE-gcc 2>&1 > /dev/null && \
+// RUN:   mv %t/$DEFAULT_TRIPLE-gcc  %t/prefix || true

stevewan wrote:
> Maybe I'm not seeing something obvious here, but I'm not aware of the `file 
> -E` usage, and on Linux I got `file: invalid option -- 'E'`.
I was looking for a way to mimic [! -f ], which worked on the command 
line but not in a test. From my system's file:
-E  On filesystem errors (file not found etc), instead of handling the 
error as regu‐
 lar output as POSIX mandates and keep going, issue an error 
message and exit.

I didn't realise it was non-standard, so I've switched to mv || true with the 
error redirected so it won't confuse the verbose output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83055



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


[PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor.

2020-07-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

thanks for doing this! but i believe these look like bugs that should be 
addressed in other components, rather than worked around in hover.

the first example is likely a bug in selection tree, file location corresponds 
to a macro body that's never expanded, which resides inside a namespace (who's 
declaration contains everything within it's braces), hence selection tree 
attributes the selection to the namespace because there's no fine-grained 
children around the cursor.

the second one is likely a bug in ast-traversal logic, i suppose the function 
doesn't get a `TypeSourceInfo` when it is `invalid`, hence we don't get to 
traverse its parameters(children) and therefore assume all the declaration 
belongs to function itself.

---

As for your workaround in hover, it is surprising that no other tests has 
regressed, but in theory `D->getLocation` only corresponds to the main token in 
a declaration (e.g. name of a function), and hover can refer to declarations 
whose names are away from the cursor, e.g. if you are on (closing) parens of a 
function/ctor call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83508



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


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-07-10 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Numbers for the new patch: 
https://llvm-compile-time-tracker.com/compare.php?from=c0308fd154f9a945608bd42630dc81dce5edfb40&to=e6e3534e77961cfa65d36828de5c75f36a25d009&stat=instructions

The regression is definitely smaller now, but still fairly large. E.g. > 2% on 
mafft.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341



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


[PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor.

2020-07-10 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added a comment.

@kadircet Thanks for your reply.

Think that you are right, because the same problem appears in GTD (with the 
same test cases). And as for GTD the similar workaround also does not break any 
regression tests except override/final.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83508



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


[PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 276959.
hokein added a comment.

Clarify the documentation for dependence-bits, and extend it to error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83213

Files:
  clang/include/clang/AST/DependenceFlags.h
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/Sema/SemaExpr.cpp

Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19210,9 +19210,6 @@
 
 ExprResult Sema::CreateRecoveryExpr(SourceLocation Begin, SourceLocation End,
 ArrayRef SubExprs, QualType T) {
-  // FIXME: enable it for C++, RecoveryExpr is type-dependent to suppress
-  // bogus diagnostics and this trick does not work in C.
-  // FIXME: use containsErrors() to suppress unwanted diags in C.
   if (!Context.getLangOpts().RecoveryAST)
 return ExprError();
 
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -495,11 +495,11 @@
 }
 
 ExprDependence clang::computeDependence(RecoveryExpr *E) {
-  // Mark the expression as value- and instantiation- dependent to reuse
-  // existing suppressions for dependent code, e.g. avoiding
-  // constant-evaluation.
-  // FIXME: drop type+value+instantiation once Error is sufficient to suppress
-  // bogus dianostics.
+  // RecoveryExpr is
+  //   - always value-dependent, instantiation-dependent and contains-errors;
+  //   - type-dependent if we don't know the type (fallback to an opequa
+  // dependent type), or the type is known and dependent, or it has
+  // type-dependent subexpressions;
   auto D = toExprDependence(E->getType()->getDependence()) |
ExprDependence::ValueInstantiation | ExprDependence::Error;
   for (auto *S : E->subExpressions())
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -157,9 +157,11 @@
 return static_cast(ExprBits.Dependent);
   }
 
-  /// isValueDependent - Determines whether this expression is
-  /// value-dependent (C++ [temp.dep.constexpr]). For example, the
-  /// array bound of "Chars" in the following example is
+  /// Determines whether the value of this expression depends on
+  ///   - a template parameter (C++ [temp.dep.constexpr])
+  ///   - or an error
+  ///
+  /// For example, the array bound of "Chars" in the following example is
   /// value-dependent.
   /// @code
   /// template struct meta_string;
@@ -168,10 +170,12 @@
 return static_cast(getDependence() & ExprDependence::Value);
   }
 
-  /// isTypeDependent - Determines whether this expression is
-  /// type-dependent (C++ [temp.dep.expr]), which means that its type
-  /// could change from one template instantiation to the next. For
-  /// example, the expressions "x" and "x + y" are type-dependent in
+  /// Determines whether the type of this expression depends on
+  ///   - a template paramter (C++ [temp.dep.expr], which means that its type
+  /// could change from one template instantiation to the next)
+  ///   - or an error
+  ///
+  /// For example, the expressions "x" and "x + y" are type-dependent in
   /// the following code, but "y" is not type-dependent:
   /// @code
   /// template
@@ -184,8 +188,10 @@
   }
 
   /// Whether this expression is instantiation-dependent, meaning that
-  /// it depends in some way on a template parameter, even if neither its type
-  /// nor (constant) value can change due to the template instantiation.
+  /// it depends in some way on
+  ///- a template parameter (even if neither its type nor (constant) value
+  ///  can change due to the template instantiation)
+  ///- or an error
   ///
   /// In the following example, the expression \c sizeof(sizeof(T() + T())) is
   /// instantiation-dependent (since it involves a template parameter \c T), but
@@ -200,6 +206,12 @@
   /// }
   /// \endcode
   ///
+  /// \code
+  /// void func(int) {
+  ///   func(); // the expression is instantiation-dependent, because it depends
+  ///   // on an error.
+  /// }
+  /// \endcode
   bool isInstantiationDependent() const {
 return static_cast(getDependence() & ExprDependence::Instantiation);
   }
@@ -6212,19 +6224,22 @@
 /// subexpressions of some expression that we could not construct and source
 /// range covered by the expression.
 ///
-/// By default, RecoveryExpr is type-, value- and instantiation-dependent to
-/// take advantage of existing machinery to deal with dependent code in C++,
-/// e.g. RecoveryExpr is preserved in `decltype()` as part of the
-/// `DependentDecltypeType`. In addition to that, clang does not report most
-/// errors on 

[PATCH] D82157: Fix crash on `user defined literals`

2020-07-10 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 276960.
eduucaldas added a comment.

- Add comment explaining complication on LOK_Raw and LOK_Template
- Use FileRange::text instead of Lexer::getSpelling


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -1184,20 +1184,139 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, IntegerLiteral) {
+TEST_P(SyntaxTreeTest, UserDefinedLiteral) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
+typedef decltype(sizeof(void *)) size_t;
+
+unsigned operator "" _i(unsigned long long);
+unsigned operator "" _f(long double);
+unsigned operator "" _c(char);
+unsigned operator "" _s(const char*, size_t);
+unsigned operator "" _r(const char*);
+template 
+unsigned operator "" _t();
+
 void test() {
-  12;
-  12u;
-  12l;
-  12ul;
-  014;
-  0XC;
+  12_i;   // call: operator "" _i(12uLL)  | kind: integer
+  1.2_f;  // call: operator "" _f(1.2L)   | kind: float
+  '2'_c;  // call: operator "" _c('2')| kind: char
+  "12"_s; // call: operator "" _s("12")   | kind: string
+
+  12_r;   // call: operator "" _r("12")   | kind: integer
+  1.2_r;  // call: operator "" _i("1.2")  | kind: float
+  12_t;   // call: operator<'1', '2'> "" _x() | kind: integer
+  1.2_t;  // call: operator<'1', '2'> "" _x() | kind: float
 }
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
+|-SimpleDeclaration
+| |-typedef
+| |-decltype
+| |-(
+| |-UnknownExpression
+| | |-sizeof
+| | |-(
+| | |-void
+| | |-*
+| | `-)
+| |-)
+| |-SimpleDeclarator
+| | `-size_t
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_i
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-unsigned
+| |   | |-long
+| |   | `-long
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_f
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-long
+| |   | `-double
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_c
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | `-char
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_s
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-const
+| |   | |-char
+| |   | `-SimpleDeclarator
+| |   |   `-*
+| |   |-,
+| |   |-SimpleDeclaration
+| |   | `-size_t
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_r
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-const
+| |   | |-char
+| |   | `-SimpleDeclarator
+| |   |   `-*
+| |   `-)
+| `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-SimpleDeclaration
+| | `-char
+| |-...
+| |->
+| `-SimpleDeclaration
+|   |-unsigned
+|   |-SimpleDeclarator
+|   | |-operator
+|   | |-""
+|   | |-_t
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   `-)
+|   `-;
 `-SimpleDeclaration
   |-void
   |-SimpleDeclarator
@@ -1208,28 +1327,36 @@
   `-CompoundStatement
 |-{
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12
+| |-IntegerUserDefinedLiteralExpression
+| | `-12_i
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12u
+| |-FloatUserDefinedLiteralExpression
+| | `-1.2_f
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12l
+| |-CharUserDefinedLiteralExpression
+| | `-'2'_c
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12ul
+| |-StringUserDefinedLiteralExpression
+| | `-"12"_s
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-014
+| |-IntegerUserDefinedLiteralExpression
+| | `-12_r
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-0XC
+| |-FloatUserDefinedLiteralExpression
+| | `-1.2_r
+| `-;
+|-ExpressionStatement
+| |-IntegerUserDefinedLiteralExpression
+| | `-12_t
+| `-;
+|-ExpressionStatement
+| |-FloatUserDefinedLiteralExpression
+| | `-1.2_t
 | `-;
 `-}
 )txt"));
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -32,6 +32,14 @@
 return OS << "BoolLiteralExpression";
   case NodeKind::C

[PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 276961.
hokein added a comment.

more tweaks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83213

Files:
  clang/include/clang/AST/DependenceFlags.h
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/Sema/SemaExpr.cpp

Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19210,9 +19210,6 @@
 
 ExprResult Sema::CreateRecoveryExpr(SourceLocation Begin, SourceLocation End,
 ArrayRef SubExprs, QualType T) {
-  // FIXME: enable it for C++, RecoveryExpr is type-dependent to suppress
-  // bogus diagnostics and this trick does not work in C.
-  // FIXME: use containsErrors() to suppress unwanted diags in C.
   if (!Context.getLangOpts().RecoveryAST)
 return ExprError();
 
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -495,11 +495,11 @@
 }
 
 ExprDependence clang::computeDependence(RecoveryExpr *E) {
-  // Mark the expression as value- and instantiation- dependent to reuse
-  // existing suppressions for dependent code, e.g. avoiding
-  // constant-evaluation.
-  // FIXME: drop type+value+instantiation once Error is sufficient to suppress
-  // bogus dianostics.
+  // RecoveryExpr is
+  //   - always value-dependent, instantiation-dependent and contains-errors
+  //   - type-dependent if we don't know the type (fallback to an opequa
+  // dependent type), or the type is known and dependent, or it has
+  // type-dependent subexpressions
   auto D = toExprDependence(E->getType()->getDependence()) |
ExprDependence::ValueInstantiation | ExprDependence::Error;
   for (auto *S : E->subExpressions())
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -157,9 +157,11 @@
 return static_cast(ExprBits.Dependent);
   }
 
-  /// isValueDependent - Determines whether this expression is
-  /// value-dependent (C++ [temp.dep.constexpr]). For example, the
-  /// array bound of "Chars" in the following example is
+  /// Determines whether the value of this expression depends on
+  ///   - a template parameter (C++ [temp.dep.constexpr])
+  ///   - or an error
+  ///
+  /// For example, the array bound of "Chars" in the following example is
   /// value-dependent.
   /// @code
   /// template struct meta_string;
@@ -168,10 +170,12 @@
 return static_cast(getDependence() & ExprDependence::Value);
   }
 
-  /// isTypeDependent - Determines whether this expression is
-  /// type-dependent (C++ [temp.dep.expr]), which means that its type
-  /// could change from one template instantiation to the next. For
-  /// example, the expressions "x" and "x + y" are type-dependent in
+  /// Determines whether the type of this expression depends on
+  ///   - a template paramter (C++ [temp.dep.expr], which means that its type
+  /// could change from one template instantiation to the next)
+  ///   - or an error
+  ///
+  /// For example, the expressions "x" and "x + y" are type-dependent in
   /// the following code, but "y" is not type-dependent:
   /// @code
   /// template
@@ -184,8 +188,10 @@
   }
 
   /// Whether this expression is instantiation-dependent, meaning that
-  /// it depends in some way on a template parameter, even if neither its type
-  /// nor (constant) value can change due to the template instantiation.
+  /// it depends in some way on
+  ///- a template parameter (even if neither its type nor (constant) value
+  ///  can change due to the template instantiation)
+  ///- or an error
   ///
   /// In the following example, the expression \c sizeof(sizeof(T() + T())) is
   /// instantiation-dependent (since it involves a template parameter \c T), but
@@ -200,6 +206,12 @@
   /// }
   /// \endcode
   ///
+  /// \code
+  /// void func(int) {
+  ///   func(); // the expression is instantiation-dependent, because it depends
+  ///   // on an error.
+  /// }
+  /// \endcode
   bool isInstantiationDependent() const {
 return static_cast(getDependence() & ExprDependence::Instantiation);
   }
@@ -6212,19 +6224,22 @@
 /// subexpressions of some expression that we could not construct and source
 /// range covered by the expression.
 ///
-/// By default, RecoveryExpr is type-, value- and instantiation-dependent to
-/// take advantage of existing machinery to deal with dependent code in C++,
-/// e.g. RecoveryExpr is preserved in `decltype()` as part of the
-/// `DependentDecltypeType`. In addition to that, clang does not report most
-/// errors on dependent expressions, so we get rid of bogus errors for fre

[PATCH] D83215: [AST][RecoveryExpr] Clarify the documentation of RecoveryExpr.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein abandoned this revision.
hokein added a comment.

closing this in favor of D83213 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83215



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


[PATCH] D83301: [clang-tidy] More strict on matching the standard memset function in memset-usage check.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

thanks for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83301



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


[PATCH] D83301: [clang-tidy] More strict on matching the standard memset function in memset-usage check.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5f41ca48d1c4: [clang-tidy] More strict on matching the 
standard memset function in memset… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83301

Files:
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
@@ -75,3 +75,8 @@
   // despite v == 0.
   memset(p, -1, v);
 }
+
+void *memset(int);
+void NoCrash() {
+  memset(1);
+}
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
@@ -20,11 +20,19 @@
 namespace bugprone {
 
 void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
-  // Note: void *memset(void *buffer, int fill_char, size_t byte_count);
+  // Match the standard memset:
+  // void *memset(void *buffer, int fill_char, size_t byte_count);
+  auto MemsetDecl =
+  functionDecl(hasName("::memset"),
+   parameterCountIs(3),
+   hasParameter(0, hasType(pointerType(pointee(voidType(),
+   hasParameter(1, hasType(isInteger())),
+   hasParameter(2, hasType(isInteger(;
+
   // Look for memset(x, '0', z). Probably memset(x, 0, z) was intended.
   Finder->addMatcher(
   callExpr(
-  callee(functionDecl(hasName("::memset"))),
+  callee(MemsetDecl),
   hasArgument(1, characterLiteral(equals(static_cast('0')))
  .bind("char-zero-fill")),
   unless(
@@ -36,14 +44,14 @@
 
   // Look for memset with an integer literal in its fill_char argument.
   // Will check if it gets truncated.
-  Finder->addMatcher(callExpr(callee(functionDecl(hasName("::memset"))),
+  Finder->addMatcher(callExpr(callee(MemsetDecl),
   hasArgument(1, 
integerLiteral().bind("num-fill")),
   unless(isInTemplateInstantiation())),
  this);
 
   // Look for memset(x, y, 0) as that is most likely an argument swap.
   Finder->addMatcher(
-  callExpr(callee(functionDecl(hasName("::memset"))),
+  callExpr(callee(MemsetDecl),
unless(hasArgument(1, anyOf(characterLiteral(equals(
static_cast('0'))),
integerLiteral(,


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
@@ -75,3 +75,8 @@
   // despite v == 0.
   memset(p, -1, v);
 }
+
+void *memset(int);
+void NoCrash() {
+  memset(1);
+}
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
@@ -20,11 +20,19 @@
 namespace bugprone {
 
 void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
-  // Note: void *memset(void *buffer, int fill_char, size_t byte_count);
+  // Match the standard memset:
+  // void *memset(void *buffer, int fill_char, size_t byte_count);
+  auto MemsetDecl =
+  functionDecl(hasName("::memset"),
+   parameterCountIs(3),
+   hasParameter(0, hasType(pointerType(pointee(voidType(),
+   hasParameter(1, hasType(isInteger())),
+   hasParameter(2, hasType(isInteger(;
+
   // Look for memset(x, '0', z). Probably memset(x, 0, z) was intended.
   Finder->addMatcher(
   callExpr(
-  callee(functionDecl(hasName("::memset"))),
+  callee(MemsetDecl),
   hasArgument(1, characterLiteral(equals(static_cast('0')))
  .bind("char-zero-fill")),
   unless(
@@ -36,14 +44,14 @@
 
   // Look for memset with an integer literal in its fill_char argument.
   // Will check if it gets truncated.
-  Finder->addMatcher(callExpr(callee(functionDecl(hasName("::memset"))),
+  Finder->addMatcher(callExpr(callee(MemsetDecl),
   hasArgument(1, 

[clang-tools-extra] 5f41ca4 - [clang-tidy] More strict on matching the standard memset function in memset-usage check.

2020-07-10 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-07-10T11:42:35+02:00
New Revision: 5f41ca48d1c46fc78958d47c0edfb2dbcde47217

URL: 
https://github.com/llvm/llvm-project/commit/5f41ca48d1c46fc78958d47c0edfb2dbcde47217
DIFF: 
https://github.com/llvm/llvm-project/commit/5f41ca48d1c46fc78958d47c0edfb2dbcde47217.diff

LOG: [clang-tidy] More strict on matching the standard memset function in 
memset-usage check.

The check assumed the matched function call has 3 arguments, but the
matcher didn't guaranteed that.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
index 9f98316984ed..37748d9fa8cc 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
@@ -20,11 +20,19 @@ namespace tidy {
 namespace bugprone {
 
 void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
-  // Note: void *memset(void *buffer, int fill_char, size_t byte_count);
+  // Match the standard memset:
+  // void *memset(void *buffer, int fill_char, size_t byte_count);
+  auto MemsetDecl =
+  functionDecl(hasName("::memset"),
+   parameterCountIs(3),
+   hasParameter(0, hasType(pointerType(pointee(voidType(),
+   hasParameter(1, hasType(isInteger())),
+   hasParameter(2, hasType(isInteger(;
+
   // Look for memset(x, '0', z). Probably memset(x, 0, z) was intended.
   Finder->addMatcher(
   callExpr(
-  callee(functionDecl(hasName("::memset"))),
+  callee(MemsetDecl),
   hasArgument(1, characterLiteral(equals(static_cast('0')))
  .bind("char-zero-fill")),
   unless(
@@ -36,14 +44,14 @@ void 
SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
 
   // Look for memset with an integer literal in its fill_char argument.
   // Will check if it gets truncated.
-  Finder->addMatcher(callExpr(callee(functionDecl(hasName("::memset"))),
+  Finder->addMatcher(callExpr(callee(MemsetDecl),
   hasArgument(1, 
integerLiteral().bind("num-fill")),
   unless(isInTemplateInstantiation())),
  this);
 
   // Look for memset(x, y, 0) as that is most likely an argument swap.
   Finder->addMatcher(
-  callExpr(callee(functionDecl(hasName("::memset"))),
+  callExpr(callee(MemsetDecl),
unless(hasArgument(1, anyOf(characterLiteral(equals(
static_cast('0'))),
integerLiteral(,

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
index f33ae5ae10a8..9a7e423f4012 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memset-usage.cpp
@@ -75,3 +75,8 @@ void foo(int xsize, int ysize) {
   // despite v == 0.
   memset(p, -1, v);
 }
+
+void *memset(int);
+void NoCrash() {
+  memset(1);
+}



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


[PATCH] D83508: [clangd][Hover] Don't use Decl if it is not related with tokens under cursor.

2020-07-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Yeah SelectionTree is the right place to solve this but it's a harder problem 
there.

In general we *don't* only want to trigger on the single token returned by 
getLocation().
The strategy SelectionTree uses is to attribute tokens to an outer node unless 
they're associated with an inner node or ignored.

Your test cases show two problems with this strategy:

- we ignore comments and semicolons, but not preprocessor directives (or 
disabled preprocessor regions). I think we can fix this by asking TokenBuffer 
if a spelled token is part of a region that maps to no (PP-)expanded tokens.
- in the case of syntax errors, tokens are emitted by the preprocessor but then 
no AST node is built from them, and we associate them with the parent by 
default. Maybe we don't need to fix this case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83508



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


[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-07-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D72705#2143405 , @balazske wrote:

> We must check on every execution path that a specific condition on a value is 
> satisfied (or: find one where the condition is not satisfied). This would be 
> the most simple form of this checker. This can be done with the path 
> sensitive check and `checkDeadSymbols`. If the symbol becomes dead with 
> unsatisfied condition a warning is emitted. The "condition" is a 
> syntactic-like check that looks for code like "`X != EOF`". This is probably 
> done best by using `StmtVisitor` if a value is evaluated (at assignment or 
> condition in `if` or other statements), different than the current form.


Pathsensitivity is about checking **one** specific path of execution with 
rather great precision, we really need dataflow to argue about **all** paths. 
Syntactic checking and pathsensitive analysis fundamentally lacks a lot of 
information that dataflow by design has. With that said, asking whether a 
symbol is dead is a part of liveness analysis which is a dataflow algorithm, 
but what that interface lacks is //why// a symbol is live/dead. I think what 
you need here is a set of reads reachable from the return value point. For this 
example, you are interested in which reads are reachable from b9, and you could 
analyze them one-by-one (which could be done syntactically at that point):

  c = fgetc(fd); // [b9]
  if (c == '+' || c == '*' || c == '|' || c == '>' || c == '@' || c == EOF || c 
== '\n') { [b1] }
  //[b8][b7][b6][b5][b4]   [b3] 
[b2] 
  // [b0 (EXIT)]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM

2020-07-10 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 276977.
LukeGeeson marked 3 inline comments as done.
LukeGeeson added a comment.

- Addresses dmgreens comments
  - reordered CPUs in the right places
  - added code/tests in all files that exist in the a77 patch

made minor adjustments including:

- adding FeatureRCPC to the missing CPUs

Please let me know if there is anything else


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

https://reviews.llvm.org/D83206

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -262,6 +262,18 @@
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
  ARM::AEK_RAS | ARM::AEK_DOTPROD,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_DOTPROD | 
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_RAS | ARM::AEK_DOTPROD |
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
   EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
@@ -310,7 +322,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 87;
+static constexpr unsigned NumARMCPUArchs = 89;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -865,6 +877,20 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC | AArch64::AEK_SSBS, "8.2-A"));
   EXPECT_TRUE(testAArch64CPU(
+  "cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO  | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
   EXPECT_TRUE(testAArch64CPU(
@@ -1002,7 +1028,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 40;
+static constexpr unsigned NumAArch64CPUArchs = 42;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -5,6 +5,8 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a65ae --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a75 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a77 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a78 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileChec

[PATCH] D83502: Change behavior with zero-sized static array extents

2020-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked an inline comment as done.
aaron.ballman added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2515
+} else {
+  AI->addAttr(llvm::Attribute::NonNull);
+}

rjmccall wrote:
> Isn't the old logic still correct?  If the element size is static and the 
> element count is positive, the argument is dereferenceable out to their 
> product; otherwise it's nonnull if null is the zero value and we aren't 
> semantically allowing that to be a valid pointer.
I was questioning this -- I didn't think the old logic was correct because it 
checks that the array is in address space 0, but the nonnull-ness should apply 
regardless of address space (I think). The point about valid null pointers 
still stands, though. Am I misunderstanding the intended address space behavior?


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

https://reviews.llvm.org/D83502



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


[PATCH] D83120: [Analyzer][StreamChecker] Using BugType::SuppressOnSink at resource leak report.

2020-07-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a reviewer: NoQ.
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

LGTM! Though, the test file change is interesting. You could add a test that 
behaves differently from the previous implementation:

  {
FILE *f = fopen(...);
  } // leak here
  
  10 / 0; // sink

Unless this `SuppressOnSink` behaves differently on sink //error// nodes -- I 
honestly don't know :^)




Comment at: clang/test/Analysis/stream.c:274-284
 // Check that "location uniqueing" works.
 // This results in reporting only one occurence of resource leak for a stream.
 void check_leak_noreturn_2() {
   FILE *F1 = tmpfile();
   if (!F1)
 return;
   if (Test == 1) {

Why did this change? Is there a sink in the return branch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83120



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


[PATCH] D82845: [Analyzer][StreamChecker] Report every leak, clean up state.

2020-07-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

I'd prefer if you moved `f_leak_2` to `stream-notes.c`. Otherwise, LGTM.




Comment at: clang/test/Analysis/stream.c:147-150
+  FILE *p1 = fopen("foo1.c", "r");
+  if (!p1)
+return;
+  FILE *p2 = fopen("foo2.c", "r");

I'd prefer to see notes from D81407 here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82845



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


[clang-tools-extra] a25487f - [clang-tidy] Use Options priority in enum options where it was missing

2020-07-10 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-07-10T12:27:08+01:00
New Revision: a25487fd8cb91f99cfc1db1d4159184ac2a816a9

URL: 
https://github.com/llvm/llvm-project/commit/a25487fd8cb91f99cfc1db1d4159184ac2a816a9
DIFF: 
https://github.com/llvm/llvm-project/commit/a25487fd8cb91f99cfc1db1d4159184ac2a816a9.diff

LOG: [clang-tidy] Use Options priority in enum options where it was missing

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 7ddf054a21a9..780a3569afdb 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -76,16 +76,25 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const 
{
   return llvm::make_error((NamePrefix + LocalName).str());
 }
 
+static ClangTidyOptions::OptionMap::const_iterator
+findPriorityOption(const ClangTidyOptions::OptionMap &Options, StringRef 
NamePrefix,
+  StringRef LocalName) {
+  auto IterLocal = Options.find((NamePrefix + LocalName).str());
+  auto IterGlobal = Options.find(LocalName.str());
+  if (IterLocal == Options.end())
+return IterGlobal;
+  if (IterGlobal == Options.end())
+return IterLocal;
+  if (IterLocal->second.Priority >= IterGlobal->second.Priority)
+return IterLocal;
+  return IterGlobal;
+}
+
 llvm::Expected
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
-  auto IterLocal = CheckOptions.find(NamePrefix + LocalName.str());
-  auto IterGlobal = CheckOptions.find(LocalName.str());
-  if (IterLocal != CheckOptions.end() &&
-  (IterGlobal == CheckOptions.end() ||
-   IterLocal->second.Priority >= IterGlobal->second.Priority))
-return IterLocal->second.Value;
-  if (IterGlobal != CheckOptions.end())
-return IterGlobal->second.Value;
+  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
+  if (Iter != CheckOptions.end())
+return Iter->second.Value;
   return llvm::make_error((NamePrefix + LocalName).str());
 }
 
@@ -124,14 +133,9 @@ bool ClangTidyCheck::OptionsView::get(StringRef 
LocalName,
 template <>
 llvm::Expected
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const 
{
-  auto IterLocal = CheckOptions.find(NamePrefix + LocalName.str());
-  auto IterGlobal = CheckOptions.find(LocalName.str());
-  if (IterLocal != CheckOptions.end() &&
-  (IterGlobal == CheckOptions.end() ||
-   IterLocal->second.Priority >= IterGlobal->second.Priority))
-return getAsBool(IterLocal->second.Value, NamePrefix + LocalName);
-  if (IterGlobal != CheckOptions.end())
-return getAsBool(IterGlobal->second.Value, llvm::Twine(LocalName));
+  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
+  if (Iter != CheckOptions.end())
+return getAsBool(Iter->second.Value, Iter->first);
   return llvm::make_error((NamePrefix + LocalName).str());
 }
 
@@ -160,9 +164,8 @@ void 
ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
 llvm::Expected ClangTidyCheck::OptionsView::getEnumInt(
 StringRef LocalName, ArrayRef> Mapping,
 bool CheckGlobal, bool IgnoreCase) {
-  auto Iter = CheckOptions.find((NamePrefix + LocalName).str());
-  if (CheckGlobal && Iter == CheckOptions.end())
-Iter = CheckOptions.find(LocalName.str());
+  auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix, 
LocalName)
+  : CheckOptions.find((NamePrefix + LocalName).str());
   if (Iter == CheckOptions.end())
 return llvm::make_error((NamePrefix + 
LocalName).str());
 



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


[PATCH] D83115: [Analyzer] Report every bug if only uniqueing location differs.

2020-07-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added reviewers: NoQ, vsavchenko, xazax.hun, martong.
Szelethus added a subscriber: NoQ.
Szelethus added inline comments.



Comment at: clang/lib/Analysis/PathDiagnostic.cpp:1136-1137
   ID.Add(getLocation());
+  ID.Add(getUniqueingLoc());
+  ID.AddPointer(getUniqueingLoc().isValid() ? getUniqueingDecl() : nullptr);
   ID.AddString(BugType);

This looks a bit odd -- why do we need both of these?

Also, didn't we use uniqueing location in the `BugReportEquivClass` or whatever 
its called? Why do we need to add this here as well? I would like some 
technical explanation.



Comment at: clang/test/Analysis/malloc.c:793
   int *p = malloc(12);
   p = malloc(12);
+} // expected-warning {{Potential leak of memory pointed to by}}\

On an unrelated note, shouldn't one of the notes be here? @NoQ, is this the 
same issue as the one you raised with zombie symbols? 
http://lists.llvm.org/pipermail/cfe-dev/2016-March/047922.html



Comment at: clang/test/Analysis/pr22954.c:346-356
   struct JJ J0 = {{{1, 2, 0}, {3, 4, 0}, {5, 6, 0}}, 0};
   J0.s2 = strdup("hello");
   J0.s1[0].s2 = strdup("hello");
   J0.s1[1].s2 = strdup("hi");
   J0.s1[2].s2 = strdup("world");
   char input[2] = {'a', 'b'};
   memcpy(J0.s1[i].s1, input, 2);

What a god awful test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83115



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


[PATCH] D81061: [Analyzer][VLASizeChecker] Fix problem with zero index assumption.

2020-07-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I don't have much to say here, this goes a bit outside my expertise. @NoQ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81061



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


[PATCH] D78280: [Analyzer][StreamChecker] Track streams that were not found to be opened.

2020-07-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Its a bit hard to judge this. Have you tested this on open source projects?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78280



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


[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D83174#2137133 , @rsmith wrote:

> @aaron.ballman We will need to do something like this in general, but I'm not 
> sure it's going to be as easy as just inheriting the attribute in the general 
> case. What do you think?


I agree that we're going to need a more general solution at some point. We do 
this automatically in `mergeDeclAttributes()` with:

  else if (Attr->shouldInheritEvenIfAlreadyPresent() || !DeclHasAttr(D, Attr))
NewAttr = cast(Attr->clone(S.Context));

for the general case (and similar for merging parameter attributes in 
`mergeParamDeclAttributes()`, but we have custom merging logic for the other 
cases. However, the custom merging logic is usually for diagnosing bad 
combinations of attributes, which I don't think we need to handle in this case, 
do we?




Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3544
+const auto *IA =
+dyn_cast(Previous->getAttr());
+

Don't do `hasAttr` followed by `getAttr` (that duplicates work); also, you 
don't need to `dyn_cast<>` the call to `getAttr`. How about:
```
const auto *IA = Previous->getAttr();
if (IA && Previous->hasAttr()) {
  ...
}
```



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3546
+
+NewAttr = new (Context) MSInheritanceAttr(
+IA->getRange(), Context, IA->getBestCase(), 
IA->getSpellingListIndex());

Rather than do it this way, how about: `NewAttr = 
cast(IA->clone(Context));`



Comment at: clang/test/Modules/Inputs/inherit-attribute/a.h:11
+#endif
\ No newline at end of file


Please add a newline to the end of the file. (Same for the other files.)


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

https://reviews.llvm.org/D83174



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-07-10 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 276991.
Xiangling_L marked 6 inline comments as done.
Xiangling_L added a comment.

Set `Handled...` = true for non-AIX power alignment;
Addressed other comments;


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

https://reviews.llvm.org/D79719

Files:
  clang/include/clang/AST/RecordLayout.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/test/Layout/aix-Wpacked-expecting-diagnostics.cpp
  clang/test/Layout/aix-Wpacked-no-diagnostics.cpp
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-no-unique-address-with-double.cpp
  clang/test/Layout/aix-pack-attr-on-base.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

Index: clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc64-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+namespace test1 {
+struct A {
+  double d1;
+  virtual void boo() {}
+};
+
+struct B {
+  double d2;
+  A a;
+};
+
+struct C : public A {
+  double d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::A
+// CHECK-NEXT:0 |   (A vtable pointer)
+// CHECK32-NEXT:  4 |   double d1
+// CHECK32-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 |   double d1
+// CHECK64-NEXT:| [sizeof=16, dsize=16, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::B
+// CHECK-NEXT:0 |   double d2
+// CHECK-NEXT:8 |   struct test1::A a
+// CHECK-NEXT:8 | (A vtable pointer)
+// CHECK32-NEXT: 12 | double d1
+// CHECK32-NEXT:| [sizeof=24, dsize=20, align=4, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=8]
+// CHECK64-NEXT: 16 | double d1
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::C
+// CHECK-NEXT:0 |   struct test1::A (primary base)
+// CHECK-NEXT:0 | (A vtable pointer)
+// CHECK32-NEXT:  4 | double d1
+// CHECK32-NEXT: 12 |   double d3
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 | double d1
+// CHECK64-NEXT: 16 |   double d3
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+} // namespace test1
+
+namespace test2 {
+struct A {
+  long long l1;
+};
+
+struct B : public virtual A {
+  double d2;
+};
+
+#pragma pack(2)
+struct C : public virtual A {
+  double __attribute__((aligned(4))) d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::A
+// CHECK-NEXT:0 |   long long l1
+// CHECK-NEXT:  | [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK-NEXT:  |  nvsize=8, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::B
+// CHECK-NEXT:0 |   (B vtable pointer)
+// CHECK32-NEXT:  4 |   double d2
+// CHECK64-NEXT:  8 |   double d2
+// CHECK-NEXT:   16 |   struct test2::A (virtual base)
+// CHECK-NEXT:   16 | long long l1
+// CHECK-NEXT:  | [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::C
+// CHECK-NEXT:0 |   (C vtable pointer)
+// CHECK32-NEXT:  4 |   double d3
+// CHECK32-NEXT: 12 |   struct test2:

[PATCH] D83213: [AST][RecoveryExpr] Don't set the instantiation-bit.

2020-07-10 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/include/clang/AST/DependenceFlags.h:22
+// cause instantiation to fail
+//   - or an error (usually in a non-template context)
+//

nit: I'd weaken usually->often



Comment at: clang/include/clang/AST/DependenceFlags.h:25
+// Note that C++ standard doesn't define the instantiation-dependent term,
+// we follow the formal definition coming from the Itanium C++ ABI.
 Instantiation = 2,

Maybe add ", and extend it to errors"



Comment at: clang/include/clang/AST/DependenceFlags.h:55
+/// Whether this type somehow involves
+///   - a template parameter, evenif the resolution of the type does not
+/// depend on a template parameter.

evenif > even if



Comment at: clang/include/clang/AST/DependenceFlags.h:62
+///   - or it somehow involves an error, e.g. denoted by
+/// decltype(recovery-expr) where recovery-expr is contains-errors
 Dependent = 4,

nit: i'd just say "e.g. decltype(expr-with-errors)"



Comment at: clang/include/clang/AST/DependenceFlags.h:112
 UnexpandedPack = 1,
 // Uses a template parameter, even if it doesn't affect the result.
+// Validity depends on the template parameter, or an error.

I'd rephrase as "Depends on a template parameter or error in some way. Validity 
depends on how the template is instantiated or the error is resolved."



Comment at: clang/include/clang/AST/Expr.h:162
+  ///   - a template parameter (C++ [temp.dep.constexpr])
+  ///   - or an error
+  ///

maybe "or an error, whose resolution is unknown"

This hints at the connection between template and error dependency, and also is 
more accurate for type-dependence (where sometimes we're not type dependent 
because the type depends on an error but we've guessed at what the resolution 
is)



Comment at: clang/include/clang/AST/Expr.h:6233
+/// unlike other dependent expressions, RecoveryExpr can be produced in
+/// non-template contexts. In addition, we will preserve the type in
+/// RecoveryExpr when the type is known, e.g. preserving the return type for a

I'm not sure why this "in addition" is part of the same paragraph, it seems 
unrelated.

I'd move to a separate paragraph and drop "in addition".



Comment at: clang/include/clang/AST/Expr.h:6236
+/// broken non-overloaded function call, a overloaded call where all candidates
+/// have the same return type.
 ///

maybe "In this case, the expression is not type-dependent (unless the known 
type is itself dependent)"



Comment at: clang/lib/AST/ComputeDependence.cpp:499
+  // RecoveryExpr is
+  //   - always value-dependent, instantiation-dependent and contains-errors
+  //   - type-dependent if we don't know the type (fallback to an opequa

nit: I'd say "always value-dependent, and therefore instantiation dependent"
and make "contains-errors" a separate bullet at the end like "- contains errors 
(ExprDependence::Error), by definition"



Comment at: clang/lib/AST/ComputeDependence.cpp:500
+  //   - always value-dependent, instantiation-dependent and contains-errors
+  //   - type-dependent if we don't know the type (fallback to an opequa
+  // dependent type), or the type is known and dependent, or it has

opaque



Comment at: clang/lib/AST/ComputeDependence.cpp:502
+  // dependent type), or the type is known and dependent, or it has
+  // type-dependent subexpressions
   auto D = toExprDependence(E->getType()->getDependence()) |

hmm, I'd missed the type-dependent subexpressions question.
If there are type-dependent subexpressions, but a non-dependent type was 
specified for the RecoveryExpr, is the expr type-dependent?

This is the part that I think we have discretion over.
The definition of type-dependent does say "any type-dependent subexpression" 
but then lays out a list of exceptions such as casts, which are not 
type-dependent even if their argument is. What these have in common is that the 
type is known.

So I think this comes down to whether it's the caller's job to work this out, 
or we want to conservatively call these expressions dependent.

I think the former is probably better - marking the expression as 
type-dependent but not having its actual type be dependent doesn't serve any 
purpose I'm aware of. It's also inconsistent with the informal definition of 
type-dependence described earlier in this patch.

So the comment should describe the current state, but maybe a FIXME to remove 
the type-dependent subexpressions clause?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAS

[clang] 4c5a93b - [ABI] Handle C++20 [[no_unique_address]] attribute

2020-07-10 Thread Ulrich Weigand via cfe-commits

Author: Ulrich Weigand
Date: 2020-07-10T14:01:05+02:00
New Revision: 4c5a93bd58bad70e91ac525b0e020bd5119a321a

URL: 
https://github.com/llvm/llvm-project/commit/4c5a93bd58bad70e91ac525b0e020bd5119a321a
DIFF: 
https://github.com/llvm/llvm-project/commit/4c5a93bd58bad70e91ac525b0e020bd5119a321a.diff

LOG: [ABI] Handle C++20 [[no_unique_address]] attribute

Many platform ABIs have special support for passing aggregates that
either just contain a single member of floatint-point type, or else
a homogeneous set of members of the same floating-point type.

When making this determination, any extra "empty" members of the
aggregate type will typically be ignored.  However, in C++ (at least
in all prior versions), no data member would actually count as empty,
even if it's type is an empty record -- it would still be considered
to take up at least one byte of space, and therefore make those ABI
special cases not apply.

This is now changing in C++20, which introduced the [[no_unique_address]]
attribute.  Members of empty record type, if they also carry this
attribute, now do *not* take up any space in the type, and therefore
the ABI special cases for single-element or homogeneous aggregates
should apply.

The C++ Itanium ABI has been updated accordingly, and GCC 10 has
added support for this new case.  This patch now adds support to
LLVM.  This is cross-platform; it affects all platforms that use
the single-element or homogeneous aggregate ABI special case and
implement this using any of the following common subroutines
in lib/CodeGen/TargetInfo.cpp:
  isEmptyField
  isEmptyRecord
  isSingleElementStruct
  isHomogeneousAggregate

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/systemz-abi.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index b83267dec6f0..9cd63ebe29ee 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -499,11 +499,15 @@ static bool isEmptyField(ASTContext &Context, const 
FieldDecl *FD,
 
   // Constant arrays of empty records count as empty, strip them off.
   // Constant arrays of zero length always count as empty.
+  bool WasArray = false;
   if (AllowArrays)
 while (const ConstantArrayType *AT = Context.getAsConstantArrayType(FT)) {
   if (AT->getSize() == 0)
 return true;
   FT = AT->getElementType();
+  // The [[no_unique_address]] special case below does not apply to
+  // arrays of C++ empty records, so we need to remember this fact.
+  WasArray = true;
 }
 
   const RecordType *RT = FT->getAs();
@@ -514,7 +518,14 @@ static bool isEmptyField(ASTContext &Context, const 
FieldDecl *FD,
   //
   // FIXME: We should use a predicate for whether this behavior is true in the
   // current ABI.
-  if (isa(RT->getDecl()))
+  //
+  // The exception to the above rule are fields marked with the
+  // [[no_unique_address]] attribute (since C++20).  Those do count as empty
+  // according to the Itanium ABI.  The exception applies only to records,
+  // not arrays of records, so we must also check whether we stripped off an
+  // array type above.
+  if (isa(RT->getDecl()) &&
+  (WasArray || !FD->hasAttr()))
 return false;
 
   return isEmptyRecord(Context, FT, AllowArrays);
@@ -7236,6 +7247,10 @@ QualType SystemZABIInfo::GetSingleElementType(QualType 
Ty) const {
   if (getContext().getLangOpts().CPlusPlus &&
   FD->isZeroLengthBitField(getContext()))
 continue;
+  // Like isSingleElementStruct(), ignore C++20 empty data members.
+  if (FD->hasAttr() &&
+  isEmptyRecord(getContext(), FD->getType(), true))
+continue;
 
   // Unlike isSingleElementStruct(), arrays do not count.
   // Nested structures still do though.

diff  --git a/clang/test/CodeGen/systemz-abi.cpp 
b/clang/test/CodeGen/systemz-abi.cpp
index 7604dea41dde..a91cb72ae33e 100644
--- a/clang/test/CodeGen/systemz-abi.cpp
+++ b/clang/test/CodeGen/systemz-abi.cpp
@@ -23,3 +23,37 @@ struct agg_float_cpp pass_agg_float_cpp(struct agg_float_cpp 
arg) { return arg;
 // CHECK-LABEL: define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, float %{{.*}})
 // SOFT-FLOAT-LABEL:  define void 
@_Z18pass_agg_float_cpp13agg_float_cpp(%struct.agg_float_cpp* noalias sret 
align 4 %{{.*}}, i32 %{{.*}})
 
+
+// A field member of empty class type in C++ makes the record nonhomogeneous,
+// unless it is marked as [[no_unique_address]].  This does not apply to 
arrays.
+struct empty { };
+struct agg_nofloat_empty { float a; empty dummy; };
+struct agg_nofloat_empty pass_agg_nofloat_empty(struct agg_nofloat_empty arg) 
{ return arg; }
+// CHECK-LABEL: define void 
@_Z22pass_agg_nofloat_empty17agg_nofloat_empty(%struct.agg_nofloat_empty* 
noalias sret align 4 %{{.*}}, i64 %{{.*}})
+// SOFT-FLOAT-LABEL:  define void 

[PATCH] D83546: [clangd] Fix hover crash on InitListExpr.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Fixes https://github.com/clangd/clangd/issues/455


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83546

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -801,6 +801,20 @@
  HI.LocalScope = "Foo::";
  HI.Type = "int";
  HI.AccessSpecifier = "public";
+   }},
+   {R"cpp(
+  struct Foo {
+int a[10];
+  };
+  constexpr Foo k2 = {
+^[[{]]1} // FIXME: why the hover range is 1 character?
+  };
+ )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Kind = index::SymbolKind::Unknown;
+ HI.Type = "int [10]";
+ HI.Value = "{1}";
}}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -336,6 +336,15 @@
   if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() ||
   T->isFunctionReferenceType())
 return llvm::None;
+  // InitListExpr has two forms, syntactic and semantic. They are the same 
thing
+  // (refer to a same AST node) in most cases.
+  // When they are different, RAV returns the syntacic form, and we should feed
+  // the semantic form to EvaluateAsRValue.
+  if (const auto *ILE = llvm::dyn_cast(E)) {
+if (!ILE->isSemanticForm())
+  E = ILE->getSemanticForm();
+  }
+
   // Attempt to evaluate. If expr is dependent, evaluation crashes!
   if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) ||
   // Disable printing for record-types, as they are usually confusing and


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -801,6 +801,20 @@
  HI.LocalScope = "Foo::";
  HI.Type = "int";
  HI.AccessSpecifier = "public";
+   }},
+   {R"cpp(
+  struct Foo {
+int a[10];
+  };
+  constexpr Foo k2 = {
+^[[{]]1} // FIXME: why the hover range is 1 character?
+  };
+ )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Kind = index::SymbolKind::Unknown;
+ HI.Type = "int [10]";
+ HI.Value = "{1}";
}}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -336,6 +336,15 @@
   if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() ||
   T->isFunctionReferenceType())
 return llvm::None;
+  // InitListExpr has two forms, syntactic and semantic. They are the same thing
+  // (refer to a same AST node) in most cases.
+  // When they are different, RAV returns the syntacic form, and we should feed
+  // the semantic form to EvaluateAsRValue.
+  if (const auto *ILE = llvm::dyn_cast(E)) {
+if (!ILE->isSemanticForm())
+  E = ILE->getSemanticForm();
+  }
+
   // Attempt to evaluate. If expr is dependent, evaluation crashes!
   if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) ||
   // Disable printing for record-types, as they are usually confusing and
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions

2020-07-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added a comment.

I'm yet to go over line-by-line, but the overall logic looks great.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:328-329
   struct Signature {
-const ArgTypes ArgTys;
-const QualType RetTy;
+ArgTypes ArgTys;
+QualType RetTy;
 Signature(ArgTypes ArgTys, QualType RetTy) : ArgTys(ArgTys), RetTy(RetTy) {

Ah right, because we need to copy this. Shame that `Optional` can't just 
inplace construct the object with a copy constructor or something.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1746
+if (StructSockaddrPtrRestrictTy && Socklen_tPtrRestrictTy) {
+  auto Accept = Summary(NoEvalCall)
+.ArgConstraint(ArgumentCondition(0, WithinRange,

`AcceptSummary`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83407



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


[PATCH] D81583: Update SystemZ ABI to handle C++20 [[no_unique_address]] attribute

2020-07-10 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand closed this revision.
uweigand added a comment.

Committed as 4c5a93bd58bad70e91ac525b0e020bd5119a321a 
.


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

https://reviews.llvm.org/D81583



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


[PATCH] D83511: [clangd] Config: If.PathExclude

2020-07-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added a comment.

BTW I'm **not** planning to add Suffix/SuffixExclude in the immediate future, 
at least for clangd 11 people will have to use `PathMatch: '.*\.h'` or so. 
Sound OK?




Comment at: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:73
+  Frag.If.PathMatch.emplace_back("b.*");
+  Frag.If.PathExclude.emplace_back(".*r");
+  EXPECT_FALSE(compileAndApply());

hokein wrote:
> IIUC the semantic is: we only process the file `if (PathMatch("bar", "b.*") 
> && !PathExclude("bar", ".*r"))`, PathExclude is true here, so we won't 
> process the file.
Exactly. Added a small message to the assertion to clarify the intent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83511



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


[clang-tools-extra] 86f1313 - [clangd] Config: If.PathExclude

2020-07-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-07-10T14:31:02+02:00
New Revision: 86f1313424fb578b0fd6c950d3ce7cb241f326ea

URL: 
https://github.com/llvm/llvm-project/commit/86f1313424fb578b0fd6c950d3ce7cb241f326ea
DIFF: 
https://github.com/llvm/llvm-project/commit/86f1313424fb578b0fd6c950d3ce7cb241f326ea.diff

LOG: [clangd] Config: If.PathExclude

Reviewers: hokein

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/ConfigFragment.h
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 63c1681ceb0b..04c0df88bbf7 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -103,6 +103,22 @@ struct FragmentCompiler {
 });
   });
 }
+
+auto PathExclude = std::make_unique>();
+for (auto &Entry : F.PathExclude) {
+  if (auto RE = compileRegex(Entry))
+PathExclude->push_back(std::move(*RE));
+}
+if (!PathExclude->empty()) {
+  Out.Conditions.push_back(
+  [PathExclude(std::move(PathExclude))](const Params &P) {
+if (P.Path.empty())
+  return false;
+return llvm::none_of(*PathExclude, [&](const llvm::Regex &RE) {
+  return RE.match(P.Path);
+});
+  });
+}
   }
 
   void compile(Fragment::CompileFlagsBlock &&F) {

diff  --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index be5bd5edc188..42f9ec2edc72 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -108,6 +108,9 @@ struct Fragment {
   struct IfBlock {
 /// The file being processed must fully match a regular expression.
 std::vector> PathMatch;
+/// The file being processed must *not* fully match a regular expression.
+std::vector> PathExclude;
+
 /// An unrecognized key was found while parsing the condition.
 /// The condition will evaluate to false.
 bool HasUnrecognizedCondition = false;

diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index 0674c6030903..ef6003b02439 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -50,6 +50,10 @@ class Parser {
   if (auto Values = scalarValues(N))
 F.PathMatch = std::move(*Values);
 });
+Dict.handle("PathExclude", [&](Node &N) {
+  if (auto Values = scalarValues(N))
+F.PathExclude = std::move(*Values);
+});
 Dict.parse(N);
   }
 

diff  --git a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
index 17db87afecfd..825d6878727d 100644
--- a/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -67,6 +67,13 @@ TEST_F(ConfigCompileTests, Condition) {
   EXPECT_TRUE(compileAndApply());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
 
+  // Excluded regex.
+  Frag = {};
+  Frag.If.PathMatch.emplace_back("b.*");
+  Frag.If.PathExclude.emplace_back(".*r");
+  EXPECT_FALSE(compileAndApply()) << "Included but also excluded";
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+
   // Invalid regex.
   Frag = {};
   Frag.If.PathMatch.emplace_back("**]@theu");



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


[PATCH] D83511: [clangd] Config: If.PathExclude

2020-07-10 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG86f1313424fb: [clangd] Config: If.PathExclude (authored by 
sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D83511?vs=276839&id=277000#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83511

Files:
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp


Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -67,6 +67,13 @@
   EXPECT_TRUE(compileAndApply());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
 
+  // Excluded regex.
+  Frag = {};
+  Frag.If.PathMatch.emplace_back("b.*");
+  Frag.If.PathExclude.emplace_back(".*r");
+  EXPECT_FALSE(compileAndApply()) << "Included but also excluded";
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+
   // Invalid regex.
   Frag = {};
   Frag.If.PathMatch.emplace_back("**]@theu");
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -50,6 +50,10 @@
   if (auto Values = scalarValues(N))
 F.PathMatch = std::move(*Values);
 });
+Dict.handle("PathExclude", [&](Node &N) {
+  if (auto Values = scalarValues(N))
+F.PathExclude = std::move(*Values);
+});
 Dict.parse(N);
   }
 
Index: clang-tools-extra/clangd/ConfigFragment.h
===
--- clang-tools-extra/clangd/ConfigFragment.h
+++ clang-tools-extra/clangd/ConfigFragment.h
@@ -108,6 +108,9 @@
   struct IfBlock {
 /// The file being processed must fully match a regular expression.
 std::vector> PathMatch;
+/// The file being processed must *not* fully match a regular expression.
+std::vector> PathExclude;
+
 /// An unrecognized key was found while parsing the condition.
 /// The condition will evaluate to false.
 bool HasUnrecognizedCondition = false;
Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -103,6 +103,22 @@
 });
   });
 }
+
+auto PathExclude = std::make_unique>();
+for (auto &Entry : F.PathExclude) {
+  if (auto RE = compileRegex(Entry))
+PathExclude->push_back(std::move(*RE));
+}
+if (!PathExclude->empty()) {
+  Out.Conditions.push_back(
+  [PathExclude(std::move(PathExclude))](const Params &P) {
+if (P.Path.empty())
+  return false;
+return llvm::none_of(*PathExclude, [&](const llvm::Regex &RE) {
+  return RE.match(P.Path);
+});
+  });
+}
   }
 
   void compile(Fragment::CompileFlagsBlock &&F) {


Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -67,6 +67,13 @@
   EXPECT_TRUE(compileAndApply());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
 
+  // Excluded regex.
+  Frag = {};
+  Frag.If.PathMatch.emplace_back("b.*");
+  Frag.If.PathExclude.emplace_back(".*r");
+  EXPECT_FALSE(compileAndApply()) << "Included but also excluded";
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+
   // Invalid regex.
   Frag = {};
   Frag.If.PathMatch.emplace_back("**]@theu");
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -50,6 +50,10 @@
   if (auto Values = scalarValues(N))
 F.PathMatch = std::move(*Values);
 });
+Dict.handle("PathExclude", [&](Node &N) {
+  if (auto Values = scalarValues(N))
+F.PathExclude = std::move(*Values);
+});
 Dict.parse(N);
   }
 
Index: clang-tools-extra/clangd/ConfigFragment.h
===
--- clang-tools-extra/clangd/ConfigFragment.h
+++ clang-tools-extra/clangd/ConfigFragment.h
@@ -108,6 +108,9 @@
   struct IfBlock {
 /// The file being processed must fully match a regular expression.
 std::vector> PathMatch;
+/// The file being processed must *not* fully match a regular expression.
+std::vector> PathExclude;
+
 /// An unrecognized key was found while parsing the condition.
 /// The condition will evaluate to false.
 bool 

[PATCH] D82574: Merge TableGen files used for clang options

2020-07-10 Thread Daniel Grumberg via Phabricator via cfe-commits
dang marked an inline comment as done.
dang added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3455
+  HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
+  MarshallingInfoString<"TargetOpts->Triple", 
"llvm::sys::getDefaultTargetTriple()", "std::string">,
+  AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;

herhut wrote:
> There is some explicit normalization missing here. In CC1Options.td this is
> 
> ```
> def triple : Separate<["-"], "triple">,
>   HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
>   MarshallingInfoString<"TargetOpts->Triple", 
> "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", 
> "std::string">,
>   AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;
> ```
> 
> It seems the normalizer does not apply to the defaults and we now see a 
> failure in `clang/unittests/Frontend/CompilerInvocationTest.cpp` for powerpc 
> targets.
Of course, I must have lost it at some point. Can you link me to the failure 
for reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82574



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


[clang] d4ce862 - Reland "[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support."

2020-07-10 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-10T08:49:45-04:00
New Revision: d4ce862f2aa8b7e4b11462bd72014b08ab9468b3

URL: 
https://github.com/llvm/llvm-project/commit/d4ce862f2aa8b7e4b11462bd72014b08ab9468b3
DIFF: 
https://github.com/llvm/llvm-project/commit/d4ce862f2aa8b7e4b11462bd72014b08ab9468b3.diff

LOG: Reland "[FPEnv][Clang][Driver] Disable constrained floating point on 
targets lacking support."

We currently have strict floating point/constrained floating point enabled
for all targets. Constrained SDAG nodes get converted to the regular ones
before reaching the target layer. In theory this should be fine.

However, the changes are exposed to users through multiple clang options
already in use in the field, and the changes are _completely_ _untested_
on almost all of our targets. Bugs have already been found, like
"https://bugs.llvm.org/show_bug.cgi?id=45274";.

This patch disables constrained floating point options in clang everywhere
except X86 and SystemZ. A warning will be printed when this happens.

Use the new -fexperimental-strict-floating-point flag to force allowing
strict floating point on hosts that aren't already marked as supporting
it (X86 and SystemZ).

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

Added: 
clang/test/CodeGen/fp-strictfp-exp.cpp
clang/test/CodeGen/fp-strictfp.cpp

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/X86.h
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/aarch64-neon-misc-constrained.c
clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
clang/test/CodeGen/arm64-vrnd-constrained.c
clang/test/CodeGen/builtins-ppc-fpconstrained.c
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 0b56b7ac4206..1613c8e45318 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -818,6 +818,10 @@ Discard value names in LLVM IR
 
 Enables an experimental new pass manager in LLVM.
 
+.. option:: -fexperimental-strict-floating-point
+
+Enables the use of non-default rounding modes and non-default exception 
handling on targets that are not currently ready.
+
 .. option:: -ffine-grained-bitfield-accesses, 
-fno-fine-grained-bitfield-accesses
 
 Use separate accesses for consecutive bitfield runs with legal widths and 
alignments.

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index d465e00d4c70..67c0b4203420 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -58,6 +58,8 @@ CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM 
IR passes to get
  ///< frontend.
 CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
 CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with 
optnone at O0
+CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0) ///< Enables the new, 
experimental
+  ///< strict floating point.
 CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental
  ///< pass manager.
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new

diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index ceb24bce5978..b202d2abffa0 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -37,6 +37,12 @@ def note_fe_backend_plugin: Note<"%0">, BackendInfo;
 def warn_fe_override_module : Warning<
 "overriding the module target triple with %0">,
 InGroup>;
+def warn_fe_backend_unsupported_fp_rounding : Warning<
+"overriding currently unsupported rounding mode on this target">,
+InGroup;
+def warn_fe_backend_unsupported_fp_exceptions : Warning<
+"overriding currently unsupported use of floating point exceptions "
+"on this target">, InGroup;
 
 def remark_fe_backend_optimization_remark : Remark<"%0">, Backen

[PATCH] D83548: [clangd] Fix tests build for GCC5

2020-07-10 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Build log:

  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member 
function ‘virtual void 
clang::clangd::{anonymous}::PreamblePatchTest_Define_Test::TestBody()’:
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: 
error: could not convert ‘(const char*)"\012#define BAR\012
[[BAR]]"’ from ‘const char*’ to ‘llvm::StringLitera ’
 };
 ^
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: 
error: could not convert ‘(const char*)"#line 0 \".*main.cpp\"\012#line 
2\012#define BAR\012"’ from ‘const char*’ to ‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: 
error: could not convert ‘(const char*)"\012#define BAR \\\012\012  
  [[BAR]]"’ from ‘const char*’ to ‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: 
error: could not convert ‘(const char*)"#line 0 \".*main.cpp\"\012#line 
2\012#define BAR\012"’ from ‘const char*’ to ‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: 
error: could not convert ‘(const char*)"\012#define \\\012  
  BAR\012[[BAR]]"’ from ‘const char*’ to ‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:267:3: 
error: could not convert ‘(const char*)"#line 0 \".*main.cpp\"\012#line 
3\012#define BAR\012"’ from ‘const char*’ to ‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member 
function ‘virtual void 
clang::clangd::{anonymous}::PreamblePatchTest_LocateMacroAtWorks_Test::TestBody()’:
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)""’ from ‘const char*’ to 
‘llvm::StringLiteral’
 };
 ^
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)"\012#define $def^FOO\012
$use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)""’ from ‘const char*’ to 
‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)"\012#define $def^FOO\012
#undef $use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)""’ from ‘const char*’ to 
‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)"\012#define $def^FOO\012
#undef FOO\012$use^FOO"’ from ‘const char*’ to 
‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)""’ from ‘const char*’ to 
‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)"\012#define \\\012  
$def^FOO\012$use^FOO"’ from ‘const char*’ to 
‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)""’ from ‘const char*’ to 
‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)"\012#\\\012  
define /* FOO */\\\012  /* FOO */ $def^FOO\012
$use^FOO"’ from ‘const char*’ to ‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)"#define FOO"’ from ‘const char*’ to 
‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:357:3: 
error: could not convert ‘(const char*)"\012#define BAR\012 
   #define $def^FOO\012$use^FOO"’ from ‘const char*’ to 
‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp: In member 
function ‘virtual void 
clang::clangd::{anonymous}::PreamblePatchTest_RefsToMacros_Test::TestBody()’:
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: 
error: could not convert ‘(const char*)""’ from ‘const char*’ to 
‘llvm::StringLiteral’
 };
 ^
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:3: 
error: could not convert ‘(const char*)"\012#define ^FOO\012
^[[FOO]]"’ from ‘const char*’ to ‘llvm::StringLiteral’
  llvm-project/clang-tools-extra/clangd/unittests/PreambleTests.cpp:445:

[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-10 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4ce862f2aa8: Reland "[FPEnv][Clang][Driver] Disable 
constrained floating point on targets… (authored by kpn).
Herald added a reviewer: dang.

Changed prior to commit:
  https://reviews.llvm.org/D80952?vs=276166&id=277004#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80952

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aarch64-neon-misc-constrained.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
  clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
  clang/test/CodeGen/arm64-vrnd-constrained.c
  clang/test/CodeGen/builtins-ppc-fpconstrained.c
  clang/test/CodeGen/fp-strictfp-exp.cpp
  clang/test/CodeGen/fp-strictfp.cpp
  clang/test/CodeGen/fpconstrained-cmp-double.c
  clang/test/CodeGen/fpconstrained-cmp-float.c
  clang/test/CodeGen/fpconstrained.c
  clang/test/CodeGen/fpconstrained.cpp

Index: clang/test/CodeGen/fpconstrained.cpp
===
--- clang/test/CodeGen/fpconstrained.cpp
+++ clang/test/CodeGen/fpconstrained.cpp
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -x c++ -ffp-contract=fast -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
-// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
-// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=maytrap -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+
 float f0, f1, f2;
 
   template 
Index: clang/test/CodeGen/fpconstrained.c
===
--- clang/test/CodeGen/fpconstrained.c
+++ clang/test/CodeGen/fpconstrained.c
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -ffast-math -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
-// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
-// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc1 

[PATCH] D83511: [clangd] Config: If.PathExclude

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D83511#2143803 , @sammccall wrote:

> BTW I'm **not** planning to add Suffix/SuffixExclude in the immediate future, 
> at least for clangd 11 people will have to use `PathMatch: '.*\.h'` or so. 
> Sound OK?


yeah, that sounds good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83511



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


[clang] 0555db0 - Normalize default value for -triple correctly

2020-07-10 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2020-07-10T13:58:48+01:00
New Revision: 0555db0a5df4d669ce4c2125668ec7a8a42fcd9d

URL: 
https://github.com/llvm/llvm-project/commit/0555db0a5df4d669ce4c2125668ec7a8a42fcd9d
DIFF: 
https://github.com/llvm/llvm-project/commit/0555db0a5df4d669ce4c2125668ec7a8a42fcd9d.diff

LOG: Normalize default value for -triple correctly

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e24914e9e4b6..042d66a1b61a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3456,7 +3456,7 @@ def target_feature : Separate<["-"], "target-feature">,
   HelpText<"Target specific attributes">;
 def triple : Separate<["-"], "triple">,
   HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
-  MarshallingInfoString<"TargetOpts->Triple", 
"llvm::sys::getDefaultTargetTriple()", "std::string">,
+  MarshallingInfoString<"TargetOpts->Triple", 
"llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">,
   AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;
 def target_abi : Separate<["-"], "target-abi">,
   HelpText<"Target a particular ABI type">;



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


[PATCH] D83550: [PATCH 1/4][Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute

2020-07-10 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes created this revision.
c-rhodes added reviewers: sdesmalen, rsandifo-arm, efriedma, ctetreau, 
cameron.mcinally.
Herald added subscribers: danielkiss, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a reviewer: aaron.ballman.
Herald added a project: clang.

This patch implements parsing support for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE, version 00bet5,
section 3.7.3) for SVE [1].

The purpose of this attribute is to define fixed-length (VLST) versions
of existing sizeless types (VLAT). For example:

  #if __ARM_FEATURE_SVE_BITS==512
  typedef svint32_t fixed_svint32_t __attribute__((arm_sve_vector_bits(512)));
  #endif

Creates a type 'fixed_svint32_t' that is a fixed-length version of
'svint32_t' that is normal-sized (rather than sizeless) and contains
exactly 512 bits. Unlike 'svint32_t', this type can be used in places
such as structs and arrays where sizeless types can't.

Implemented in this patch is the following:

- Defined and tested attribute taking single argument.
- Checks the argument is an integer constant expression.
- Attribute can only be attached to a single SVE vector or predicate type, 
excluding tuple types such as svint32x4_t.
- Validates N == __ARM_FEATURE_SVE_BITS, where N is the number of bits passed 
to the attribute.
- Basic validation of the __ARM_FEATURE_SVE_BITS macro.

The __ARM_FEATURE_SVE_BITS macro will be enabled by the
-msve-vector-bits= flag in the final patch of the series.

[1] https://developer.arm.com/documentation/100987/latest


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83550

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/arm-feature-sve-bits-macro.c
  clang/test/Sema/attr-arm-sve-vector-bits.c

Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- /dev/null
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -D__ARM_FEATURE_SVE_BITS=128 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -D__ARM_FEATURE_SVE_BITS=256 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -D__ARM_FEATURE_SVE_BITS=512 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -D__ARM_FEATURE_SVE_BITS=1024 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -D__ARM_FEATURE_SVE_BITS=2048 -fallow-half-arguments-and-returns %s
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+
+// Define valid fixed-width SVE types
+typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint16_t fixed_int16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint32_t fixed_int32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint64_t fixed_int64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svuint8_t fixed_uint8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint16_t fixed_uint16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint32_t fixed_uint32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint64_t fixed_uint64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svfloat16_t fixed_float16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat32_t fixed_float32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat64_t fixed_float64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbfloat16_t fixed_bfloat16_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
+
+// Attribute must have a single argument
+typedef svint8_t no_argument __attribute__((arm_sve_vector_bits)); // expected-error {{'arm_sve_vector_bits' attribute takes one argument}}
+typedef svint8_t two_arguments __attribute__((arm_sve_vector_bits(2, 4))); // expected-error {{'arm_sve_vector_bits' attribute takes one argument}}
+
+// The number of SVE vector bits must be an integer constant expression
+typedef svint8_t non_int_size1 __attribute__((arm_sve_vector_bits(2.0)));   // expected-error {{'arm_sve_vector_bits' attribute requires an integer constant}}
+typedef svint8_t non_int_size2 __attribute__((arm_sve_vector_bits("256"))); // expected-error {{'arm_sve_vector_bits' attribute requires an integer constant}}
+
+// Attribute must be attached to a single SVE vector or predicate type.
+typedef void *badtype1 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' att

[PATCH] D82574: Merge TableGen files used for clang options

2020-07-10 Thread Daniel Grumberg via Phabricator via cfe-commits
dang marked 2 inline comments as done.
dang added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3455
+  HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
+  MarshallingInfoString<"TargetOpts->Triple", 
"llvm::sys::getDefaultTargetTriple()", "std::string">,
+  AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;

dang wrote:
> herhut wrote:
> > There is some explicit normalization missing here. In CC1Options.td this is
> > 
> > ```
> > def triple : Separate<["-"], "triple">,
> >   HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
> >   MarshallingInfoString<"TargetOpts->Triple", 
> > "llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", 
> > "std::string">,
> >   AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;
> > ```
> > 
> > It seems the normalizer does not apply to the defaults and we now see a 
> > failure in `clang/unittests/Frontend/CompilerInvocationTest.cpp` for 
> > powerpc targets.
> Of course, I must have lost it at some point. Can you link me to the failure 
> for reference.
Done in 0555db0a5df4 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82574



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


[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp:129
+  S &s1 = f({}, 0, 0.0); // expected-error {{no matching 
function}} \
+  expected-error {{non-const 
lvalue reference to type 'S' cannot bind to a value of 
unrelated type 'int'}}
 }

the secondary diagnostic is technically correct, but I don't quite like it, it 
is confusing, ok to leave it as-is? or fix that before landing this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82657



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-10 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.
Herald added a subscriber: dexonsmith.



Comment at: clang/include/clang/Driver/Options.td:1246
   HelpText<"Enables an experimental new pass manager in LLVM.">;
+def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
+  Group, Flags<[CC1Option]>,

A bit late to the party, but can you mark this as 
`MarshallingInfoFlag<"LangOpts->ExpStrictFP", "false>` so that `if 
(Args.hasArg(OPT_fexperimental_strict_floating_point)) Opts.ExpStrictFP = 
true;` in CompilerInvocation.cpp gets generated automatically, we also get 
serializing the option for free this way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80952



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


[PATCH] D83551: [PATCH 2/4][Sema][AArch64] Add semantics for arm_sve_vector_bits attribute

2020-07-10 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes created this revision.
c-rhodes added reviewers: sdesmalen, rsandifo-arm, efriedma, cameron.mcinally, 
ctetreau.
Herald added subscribers: danielkiss, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a reviewer: aaron.ballman.
Herald added a project: clang.

This patch implements semantics for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE) for SVE [1].
The purpose of this attribute is to define fixed-length (VLST) versions
of existing sizeless types (VLAT).

Implemented in this patch is the the behaviour described in section 3.7.3.2
and minimal parts of sections 3.7.3.3 and 3.7.3.4, this includes:

- Defining VLST globals, structs, unions, and local variables
- Implicit casting between VLAT <=> VLST.
- Diagnosis of ill-formed conditional expressions of the form:

  C ?  E1 : E2

  where E1 is a VLAT type and E2 is a VLST, or vice-versa. This avoids any 
ambiguity about the nature of the result type (i.e is it sized or sizeless).
- For vectors:
  - sizeof(VLST) == N/8
  - alignof(VLST) == 16
- For predicates:
  - sizeof(VLST) == N/64
  - alignof(VLST) == 2

VLSTs have the same representation as VLATs in the AST but are wrapped
with a TypeAttribute. Scalable types are currently emitted in the IR for
uses such as globals and structs which don't support these types, this
is addressed in the next patch with codegen, where VLSTs are lowered to
sized arrays for globals, structs / unions and arrays.

Not implemented in this patch is the behaviour guarded by the feature
macros:

- __ARM_FEATURE_SVE_VECTOR_OPERATORS
- __ARM_FEATURE_SVE_PREDICATE_OPERATORS

As such, the GNU __attribute__((vector_size)) extension is not available
and operators such as binary '+' are not supported for VLSTs. Support
for this is intended to be addressed by later patches.

[1] https://developer.arm.com/documentation/100987/latest


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83551

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/attr-arm-sve-vector-bits.c

Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -41,3 +41,194 @@
 typedef float badtype3 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'float'}}
 typedef svint8x2_t badtype4 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'svint8x2_t' (aka '__clang_svint8x2_t')}}
 typedef svfloat32x3_t badtype5 __attribute__((arm_sve_vector_bits(N))); // expected-error {{'arm_sve_vector_bits' attribute applied to non-SVE type 'svfloat32x3_t' (aka '__clang_svfloat32x3_t')}}
+
+fixed_int8_t global_int8;
+fixed_bfloat16_t global_bfloat16;
+fixed_bool_t global_bool;
+
+extern fixed_int8_t extern_int8;
+extern fixed_bfloat16_t extern_bfloat16;
+extern fixed_bool_t extern_bool;
+
+static fixed_int8_t static_int8;
+static fixed_bfloat16_t static_bfloat16;
+static fixed_bool_t static_bool;
+
+fixed_int8_t* global_int8_ptr;
+extern fixed_int8_t* extern_int8_ptr;
+static fixed_int8_t* static_int8_ptr;
+__thread fixed_int8_t thread_int8;
+
+typedef fixed_int8_t int8_typedef;
+typedef fixed_int8_t *int8_ptr_typedef;
+
+int sizeof_int8 = sizeof(global_int8);
+int sizeof_int8_var = sizeof(*global_int8_ptr);
+int sizeof_int8_var_ptr = sizeof(global_int8_ptr);
+
+extern fixed_int8_t *extern_int8_ptr;
+
+int alignof_int8 = __alignof__(extern_int8);
+int alignof_int8_var = __alignof__(*extern_int8_ptr);
+int alignof_int8_var_ptr = __alignof__(extern_int8_ptr);
+
+void f(bool c) {
+  fixed_int8_t fs8;
+  svint8_t ss8;
+
+  void *sel __attribute__((unused));
+  sel = c ? ss8 : fs8; // expected-error {{incompatible operand types ('svint8_t' (aka '__SVInt8_t') and 'fixed_int8_t' (aka '__SVInt8_t'))}}
+  sel = c ? fs8 : ss8; // expected-error {{incompatible operand types ('fixed_int8_t' (aka '__SVInt8_t') and 'svint8_t' (aka '__SVInt8_t'))}}
+}
+
+// --//
+// Sizeof
+
+#define VECTOR_SIZE ((N / 8))
+#define PRED_SIZE ((N / 64))
+
+_Static_assert(sizeof(fixed_int8_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_int16_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_int32_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_int64_t) == VECTOR_SIZE, "");
+
+_Static_assert(sizeof(fixed_uint8_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_uint16_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_uint32_t) == VECTOR_SIZE, "");
+_Static_assert(sizeof(fixed_uint64_t) == VECTOR_SIZE, ""

[PATCH] D83546: [clangd] Fix hover crash on InitListExpr.

2020-07-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:345
+if (!ILE->isSemanticForm())
+  E = ILE->getSemanticForm();
+  }

shouldn't we put this before `QualType T = E->getType();` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83546



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


[PATCH] D83553: [PATCH 3/4][Sema][AArch64] Add codegen for arm_sve_vector_bits attribute

2020-07-10 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes created this revision.
c-rhodes added reviewers: sdesmalen, rsandifo-arm, efriedma, cameron.mcinally, 
ctetreau.
Herald added subscribers: danielkiss, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.

This patch implements codegen for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE) for SVE [1].
The purpose of this attribute is to define fixed-length (VLST) versions
of existing sizeless types (VLAT).

Implemented in this patch is the lowering of VLSTs to valid types.
VLSTs (unlike VLATs) can be used in globals, members of structs
and unions, and arrays. To support this in this patch we lower VLSTs to
arrays. For example, in the following C code:

  #if __ARM_FEATURE_SVE_BITS==512
  typedef svint32_t fixed_svint32_t __attribute__((arm_sve_vector_bits(512)));
  struct struct_int32 {
fixed_int32_t x;
  } struct_int32;
  #endif

the struct is lowered to:

  %struct.struct_int32 = type { [16 x i32] }

where the member 'x' is a fixed-length variant of 'svint32_t' that
contains exactly 512 bits.

When loading from a VLST to a VLAT, or when storing a VLAT to a VLST,
the address is bitcasted, e.g.

  bitcast [N x i8]* %addr.ptr to *

[1] https://developer.arm.com/documentation/100987/latest


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83553

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/test/Sema/attr-arm-sve-vector-bits-bitcast.c
  clang/test/Sema/attr-arm-sve-vector-bits-call.c
  clang/test/Sema/attr-arm-sve-vector-bits-cast.c
  clang/test/Sema/attr-arm-sve-vector-bits-codegen.c
  clang/test/Sema/attr-arm-sve-vector-bits-globals.c
  clang/test/Sema/attr-arm-sve-vector-bits-types.c

Index: clang/test/Sema/attr-arm-sve-vector-bits-types.c
===
--- /dev/null
+++ clang/test/Sema/attr-arm-sve-vector-bits-types.c
@@ -0,0 +1,525 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=128 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-128
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=256 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-256
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=512 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-512
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=1024 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-1024
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=2048 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-2048
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+
+typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint16_t fixed_int16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint32_t fixed_int32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint64_t fixed_int64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svuint8_t fixed_uint8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint16_t fixed_uint16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint32_t fixed_uint32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint64_t fixed_uint64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svfloat16_t fixed_float16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat32_t fixed_float32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat64_t fixed_float64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbfloat16_t fixed_bfloat16_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
+
+//===--===//
+// Structs and unions
+//===--===//
+#define DEFINE_STRUCT(ty) \
+  struct struct_##ty {\
+fixed_##ty##_t x; \
+  } struct_##ty;
+
+#define DEFINE_UNION(ty) \
+  union union_##ty { \
+fixed_##ty##_t x;\
+  } union_##ty;
+
+DEFINE_STRUCT(int8)
+DEFINE_STRUCT(int16)
+DEFINE_STRUCT(int32)
+DEFINE_STRUCT(int64)
+DEFINE_STRUCT(uint8)
+DEFINE_STRUCT(uint16)
+DEFINE_STRUCT(uint32)
+DEFINE_STRUCT(uint64)
+DEFINE_STRUCT(float16)
+DEFINE_STRUCT(float32)
+DEFINE_STRUCT(float64)
+DEFINE_STRUCT(bfloat16)
+DEFINE_STRUCT(bool)
+
+DEFINE_UNION(int8)
+DEFINE_UNIO

[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-10 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked an inline comment as done.
kpn added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1246
   HelpText<"Enables an experimental new pass manager in LLVM.">;
+def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
+  Group, Flags<[CC1Option]>,

dang wrote:
> A bit late to the party, but can you mark this as 
> `MarshallingInfoFlag<"LangOpts->ExpStrictFP", "false>` so that `if 
> (Args.hasArg(OPT_fexperimental_strict_floating_point)) Opts.ExpStrictFP = 
> true;` in CompilerInvocation.cpp gets generated automatically, we also get 
> serializing the option for free this way.
Assuming this patch makes it to the afternoon, how about I open a new review 
for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80952



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


[PATCH] D83546: [clangd] Fix hover crash on InitListExpr.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 277016.
hokein marked 2 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83546

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -801,6 +801,21 @@
  HI.LocalScope = "Foo::";
  HI.Type = "int";
  HI.AccessSpecifier = "public";
+   }},
+   {// No crash on InitListExpr.
+R"cpp(
+  struct Foo {
+int a[10];
+  };
+  constexpr Foo k2 = {
+^[[{]]1} // FIXME: why the hover range is 1 character?
+  };
+ )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Kind = index::SymbolKind::Unknown;
+ HI.Type = "int [10]";
+ HI.Value = "{1}";
}}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -329,13 +329,23 @@
 
 llvm::Optional printExprValue(const Expr *E,
const ASTContext &Ctx) {
-  Expr::EvalResult Constant;
+  // InitListExpr has two forms, syntactic and semantic. They are the same 
thing
+  // (refer to a same AST node) in most cases.
+  // When they are different, RAV returns the syntacic form, and we should feed
+  // the semantic form to EvaluateAsRValue.
+  if (const auto *ILE = llvm::dyn_cast(E)) {
+if (!ILE->isSemanticForm())
+  E = ILE->getSemanticForm();
+  }
+
   // Evaluating [[foo]]() as "&foo" isn't useful, and prevents us walking up
   // to the enclosing call.
   QualType T = E->getType();
   if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() ||
   T->isFunctionReferenceType())
 return llvm::None;
+
+  Expr::EvalResult Constant;
   // Attempt to evaluate. If expr is dependent, evaluation crashes!
   if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) ||
   // Disable printing for record-types, as they are usually confusing and


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -801,6 +801,21 @@
  HI.LocalScope = "Foo::";
  HI.Type = "int";
  HI.AccessSpecifier = "public";
+   }},
+   {// No crash on InitListExpr.
+R"cpp(
+  struct Foo {
+int a[10];
+  };
+  constexpr Foo k2 = {
+^[[{]]1} // FIXME: why the hover range is 1 character?
+  };
+ )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Kind = index::SymbolKind::Unknown;
+ HI.Type = "int [10]";
+ HI.Value = "{1}";
}}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -329,13 +329,23 @@
 
 llvm::Optional printExprValue(const Expr *E,
const ASTContext &Ctx) {
-  Expr::EvalResult Constant;
+  // InitListExpr has two forms, syntactic and semantic. They are the same thing
+  // (refer to a same AST node) in most cases.
+  // When they are different, RAV returns the syntacic form, and we should feed
+  // the semantic form to EvaluateAsRValue.
+  if (const auto *ILE = llvm::dyn_cast(E)) {
+if (!ILE->isSemanticForm())
+  E = ILE->getSemanticForm();
+  }
+
   // Evaluating [[foo]]() as "&foo" isn't useful, and prevents us walking up
   // to the enclosing call.
   QualType T = E->getType();
   if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() ||
   T->isFunctionReferenceType())
 return llvm::None;
+
+  Expr::EvalResult Constant;
   // Attempt to evaluate. If expr is dependent, evaluation crashes!
   if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) ||
   // Disable printing for record-types, as they are usually confusing and
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83546: [clangd] Fix hover crash on InitListExpr.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:345
+if (!ILE->isSemanticForm())
+  E = ILE->getSemanticForm();
+  }

kadircet wrote:
> shouldn't we put this before `QualType T = E->getType();` ?
ah, I think you're right. put it there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83546



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


[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-10 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1246
   HelpText<"Enables an experimental new pass manager in LLVM.">;
+def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
+  Group, Flags<[CC1Option]>,

kpn wrote:
> dang wrote:
> > A bit late to the party, but can you mark this as 
> > `MarshallingInfoFlag<"LangOpts->ExpStrictFP", "false>` so that `if 
> > (Args.hasArg(OPT_fexperimental_strict_floating_point)) Opts.ExpStrictFP = 
> > true;` in CompilerInvocation.cpp gets generated automatically, we also get 
> > serializing the option for free this way.
> Assuming this patch makes it to the afternoon, how about I open a new review 
> for this?
Sure no problem


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80952



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


[PATCH] D83548: [clangd] Fix tests build for GCC5

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

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83548



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


[PATCH] D83546: [clangd] Fix hover crash on InitListExpr.

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

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83546



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


[PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM

2020-07-10 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 277019.
LukeGeeson added a comment.

- Added FP16 to Cortex-X1 set of features


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

https://reviews.llvm.org/D83206

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -262,6 +262,18 @@
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
  ARM::AEK_RAS | ARM::AEK_DOTPROD,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_DOTPROD | 
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_DOTPROD |
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
   EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
@@ -310,7 +322,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 87;
+static constexpr unsigned NumARMCPUArchs = 89;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -865,6 +877,20 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC | AArch64::AEK_SSBS, "8.2-A"));
   EXPECT_TRUE(testAArch64CPU(
+  "cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO  | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
   EXPECT_TRUE(testAArch64CPU(
@@ -1002,7 +1028,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 40;
+static constexpr unsigned NumAArch64CPUArchs = 42;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -5,6 +5,8 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a65ae --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a75 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a77 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a78 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
 
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
@@ -3,6 +3,

[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked an inline comment as done.
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:88-92
+  if (const auto *ID = dyn_cast(D)) {
+if (const auto *IMD = ID->getImplementation())
+  return IMD;
+return ID->getDefinition();
+  }

sammccall wrote:
> dgoldman wrote:
> > Let me know if there's a better way to handle this multi-"definition" 
> > support
> I think there might be (what you've done seems reasonable in isolation but 
> I'm not sure it'll yield the best behavior).
> 
> Consider this code:
> ```
> int foo(); // A
> int foo(); // B
> int foo(){} // C
> ```
> We have 3 declarations. A will be chosen as the canonical declaration 
> (because it's first, though things get more complicated when the index is 
> involved). C is the definition. So go-to-definition will land on C, and then 
> triggering it again will take you to A, and then back to C. go-to-declaration 
> is the opposite. B is basically just a reference for our purposes, we won't 
> navigate you there (except by find-refs).
> 
> Now let's look at your example again:
> ```
> @class MyClass; // A
> @interface MyClass ... @end // B
> @implementation MyClass ... @end // C
> ```
> Thinking about where you might want to navigate to, A is certainly the least 
> important of these, right?
> It seems clear we want B to be considered the canonical declaration and C the 
> definition.
> 
> So I think:
>  - we should only return the implementation here if it exists, and otherwise 
> nullptr rather than the inferface.
>  - getCanonicalDecl in AddResultDecl should special case ObjCInterfaceDecl to 
> get the definition (i.e. @interface) if possible
>  - we need to convince other parts of clangd that these are the same symbol:
>- targetDecl should resolve any reference to an ObjCImplDecl to the 
> corresponding ObjCInterfaceDecl instead
>- the indexer (`SymbolCollector`) also needs to handle this (the 
> ObjCImplDecl should end up being the stored Definition under the 
> ObjCInterfaceDecl's SymbolID)
> 
> Some code will only see the forward declaration and that's OK. The index's 
> merge rules are that a candidate "canonical declaration" which has an 
> associated definition is preferred over one that doesn't. Since the 
> implementation can always see the interface, the interface will end up being 
> the canonical declaration after merge.
Thanks, that makes sense - I agree that B should be the actual canonical 
declaration for our case (even though Clang picks A) and C is the definition. I 
think that part was confusing me, since Clang seems to use the forward 
declaration as the canonical one when it exists, but it seems like that's 
intentional/OK and shouldn't change (e.g. for `ReferenceFinder` in the same 
file). 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


[PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM

2020-07-10 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/include/llvm/Support/AArch64TargetParser.def:135
+ (AArch64::AEK_FP16 | AArch64::AEK_DOTPROD | AArch64::AEK_RCPC 
|
+  AArch64::AEK_SSBS | AArch64::AEK_RAS))
 AARCH64_CPU_NAME("neoverse-e1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,

AEK_RAS will be included in ARMV8_2A, I believe.



Comment at: llvm/include/llvm/Support/ARMTargetParser.def:298
+ARM_CPU_NAME("cortex-a78",ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (ARM::AEK_RAS | ARM::AEK_DOTPROD))
+ARM_CPU_NAME("cortex-x1", ARMV8_2A, FK_CRYPTO_NEON_FP_ARMV8, false,

This one too I think.


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

https://reviews.llvm.org/D83206



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


[PATCH] D83174: Teach AttachPreviousImpl to inherit MSInheritanceAttr attribute

2020-07-10 Thread Vaibhav Garg via Phabricator via cfe-commits
gargvaibhav64 updated this revision to Diff 277022.
gargvaibhav64 marked 3 inline comments as done.
gargvaibhav64 added a comment.

Incorporated the changes


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

https://reviews.llvm.org/D83174

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/Inputs/inherit-attribute/a.h
  clang/test/Modules/Inputs/inherit-attribute/b.h
  clang/test/Modules/Inputs/inherit-attribute/c.h
  clang/test/Modules/Inputs/inherit-attribute/module.modulemap
  clang/test/Modules/inherit-attribute.cpp

Index: clang/test/Modules/inherit-attribute.cpp
===
--- /dev/null
+++ clang/test/Modules/inherit-attribute.cpp
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -ast-dump -I%S/Inputs/inherit-attribute -fmodules-cache-path=%t -fimplicit-module-maps -verify %s -fmodules-local-submodule-visibility
+
+#include "b.h"
+#include "c.h"
+
+class Foo;
+
+Foo f;
+// expected-no-diagnostics
Index: clang/test/Modules/Inputs/inherit-attribute/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/module.modulemap
@@ -0,0 +1,3 @@
+module "b" { header "b.h" }
+
+module "c" { header "c.h" }
Index: clang/test/Modules/Inputs/inherit-attribute/c.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/c.h
@@ -0,0 +1,7 @@
+#include "a.h"
+
+class Foo;
+class C {
+public:
+  C();
+};
Index: clang/test/Modules/Inputs/inherit-attribute/b.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/b.h
@@ -0,0 +1,12 @@
+#include "a.h"
+
+class Foo;
+
+void bar() {
+  &Foo::step;
+}
+
+class B {
+public:
+  B();
+};
Index: clang/test/Modules/Inputs/inherit-attribute/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/inherit-attribute/a.h
@@ -0,0 +1,10 @@
+#ifndef FOO
+#define FOO
+
+class Foo {
+public:
+  void step(int v);
+  Foo();
+};
+
+#endif
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -281,6 +281,9 @@
 static Decl *getMostRecentDeclImpl(...);
 static Decl *getMostRecentDecl(Decl *D);
 
+static void mergeInheritableAttributes(ASTReader &Reader, Decl *D,
+   Decl *Previous);
+
 template 
 static void attachPreviousDeclImpl(ASTReader &Reader,
Redeclarable *D, Decl *Previous,
@@ -3531,6 +3534,19 @@
   return ASTDeclReader::getMostRecentDecl(D->getCanonicalDecl());
 }
 
+void ASTDeclReader::mergeInheritableAttributes(ASTReader &Reader, Decl *D,
+   Decl *Previous) {
+  InheritableAttr *NewAttr = nullptr;
+  ASTContext &Context = Reader.getContext();
+  const auto *IA = Previous->getAttr();
+
+  if (IA && Previous->hasAttr()) {
+NewAttr = cast(IA->clone(Context));
+NewAttr->setInherited(true);
+D->addAttr(NewAttr);
+  }
+}
+
 template
 void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader,
Redeclarable *D,
@@ -3689,6 +3705,12 @@
   if (auto *TD = dyn_cast(D))
 inheritDefaultTemplateArguments(Reader.getContext(),
 cast(Previous), TD);
+
+  // If any of the declaration in the chain contains an Inheritable attribute,
+  // it needs to be added to all the declarations in the redeclarable chain.
+  // FIXME: Only the logic of merging MSInheritableAttr is present, it should
+  // be extended for all inheritable attributes.
+  mergeInheritableAttributes(Reader, D, Previous);
 }
 
 template
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83120: [Analyzer][StreamChecker] Using BugType::SuppressOnSink at resource leak report.

2020-07-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added inline comments.



Comment at: clang/test/Analysis/stream.c:274-284
 // Check that "location uniqueing" works.
 // This results in reporting only one occurence of resource leak for a stream.
 void check_leak_noreturn_2() {
   FILE *F1 = tmpfile();
   if (!F1)
 return;
   if (Test == 1) {

Szelethus wrote:
> Why did this change? Is there a sink in the return branch?
The change is probably because D83115. Because the "uniqueing" one resource 
leak is reported from the two possible, and the order changes somehow (probably 
not the shortest is found first).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83120



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 277026.
dgoldman added a comment.

Fixes for getDefinition/getCanonicalDecl for ObjC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501

Files:
  clang-tools-extra/clangd/XRefs.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
@@ -688,7 +688,14 @@
 
   R"objc(//objc
 @class $decl[[Foo]];
-@interface $def[[Foo]]
+Fo^o * getFoo() {
+  return 0;
+}
+  )objc",
+
+  R"objc(//objc
+@class Foo;
+@interface $decl[[Foo]]
 @end
 Fo^o * getFoo() {
   return 0;
@@ -696,8 +703,8 @@
   )objc",
 
   R"objc(//objc
-@class $decl[[Foo]];
-@interface Foo
+@class Foo;
+@interface $decl[[Foo]]
 @end
 @implementation $def[[Foo]]
 @end
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -80,16 +80,8 @@
 return FD->getDefinition();
   if (const auto *PD = dyn_cast(D))
 return PD->getDefinition();
-  // Objective-C classes can have three types of declarations:
-  //
-  // - forward declaration: @class MyClass;
-  // - definition declaration: @interface MyClass ... @end
-  // - implementation: @implementation MyClass ... @end
-  if (const auto *ID = dyn_cast(D)) {
-if (const auto *IMD = ID->getImplementation())
-  return IMD;
-return ID->getDefinition();
-  }
+  if (const auto *ID = dyn_cast(D))
+return ID->getImplementation();
   // Only a single declaration is allowed.
   if (isa(D) || isa(D) ||
   isa(D)) // except cases above
@@ -235,6 +227,30 @@
   return llvm::None;
 }
 
+// A wrapper around `Decl::getCanonicalDecl` to support cases where Clang's
+// definition of a canonical declaration doesn't match up to what a programmer
+// would expect. For example, Objective-C classes can have three types of
+// declarations:
+//
+// - forward declaration(s): @class MyClass;
+// - definition declaration: @interface MyClass ... @end
+// - implementation: @implementation MyClass ... @end
+//
+// Clang will consider the forward declaration to be the canonical declaration
+// because it is first, but we actually want the class definition if it is
+// available since that is what a programmer would consider the real definition
+// to be.
+const NamedDecl *getNonStandardCanonicalDecl(const NamedDecl *D) {
+  D = llvm::cast(D->getCanonicalDecl());
+
+  // Prefer Objective-C class definitions over the forward declaration.
+  if (const auto *ID = dyn_cast(D))
+if (const auto *DefinitionID = ID->getDefinition())
+  return DefinitionID;
+
+  return D;
+}
+
 // Decls are more complicated.
 // The AST contains at least a declaration, maybe a definition.
 // These are up-to-date, and so generally preferred over index results.
@@ -250,7 +266,7 @@
   llvm::DenseMap ResultIndex;
 
   auto AddResultDecl = [&](const NamedDecl *D) {
-D = llvm::cast(D->getCanonicalDecl());
+D = getNonStandardCanonicalDecl(D);
 auto Loc =
 makeLocation(AST.getASTContext(), nameLocation(*D, SM), MainFilePath);
 if (!Loc)


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -688,7 +688,14 @@
 
   R"objc(//objc
 @class $decl[[Foo]];
-@interface $def[[Foo]]
+Fo^o * getFoo() {
+  return 0;
+}
+  )objc",
+
+  R"objc(//objc
+@class Foo;
+@interface $decl[[Foo]]
 @end
 Fo^o * getFoo() {
   return 0;
@@ -696,8 +703,8 @@
   )objc",
 
   R"objc(//objc
-@class $decl[[Foo]];
-@interface Foo
+@class Foo;
+@interface $decl[[Foo]]
 @end
 @implementation $def[[Foo]]
 @end
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -80,16 +80,8 @@
 return FD->getDefinition();
   if (const auto *PD = dyn_cast(D))
 return PD->getDefinition();
-  // Objective-C classes can have three types of declarations:
-  //
-  // - forward declaration: @class MyClass;
-  // - definition declaration: @interface MyClass ... @end
-  // - implementation: @implementation MyClass ... @end
-  if (const auto *ID = dyn_cast(D)) {
-if (const auto *IMD = ID->getImplementation())
-  return IMD;
-return ID->getDefinition();
-  

[PATCH] D83556: [clangd] Update semanticTokens support to reflect latest LSP draft

2020-07-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Mostly a few methods and message names have been renamed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83556

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test

Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -13,7 +13,7 @@
 }}}
 ---
 # Non-incremental token request.
-{"jsonrpc":"2.0","id":1,"method":"textDocument/semanticTokens","params":{"textDocument":{"uri":"test:///foo.cpp"}}}
+{"jsonrpc":"2.0","id":1,"method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"test:///foo.cpp"}}}
 # CHECK:   "id": 1,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": {
@@ -34,7 +34,7 @@
 }}
 ---
 # Incremental token request, based on previous response.
-{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/edits","params":{
+{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/full/delta","params":{
   "textDocument": {"uri":"test:///foo.cpp"},
   "previousResultId": "1"
 }}
@@ -60,7 +60,7 @@
 # CHECK-NEXT:  }
 ---
 # Incremental token request with incorrect baseline => full tokens list.
-{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/edits","params":{
+{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/full/delta","params":{
   "textDocument": {"uri":"test:///foo.cpp"},
   "previousResultId": "bogus"
 }}
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -42,8 +42,8 @@
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "selectionRangeProvider": true,
 # CHECK-NEXT:  "semanticTokensProvider": {
-# CHECK-NEXT:"documentProvider": {
-# CHECK-NEXT:  "edits": true
+# CHECK-NEXT:"full": {
+# CHECK-NEXT:  "delta": true
 # CHECK-NEXT:},
 # CHECK-NEXT:"legend": {
 # CHECK-NEXT:  "tokenModifiers": [],
@@ -51,7 +51,7 @@
 # CHECK-NEXT:"variable",
 # CHECK:   ]
 # CHECK-NEXT:},
-# CHECK-NEXT:"rangeProvider": false
+# CHECK-NEXT:"range": false
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1384,27 +1384,27 @@
   // send a delta.
   std::string resultId;
 
-  /// The actual tokens. For a detailed description about how the data is
-  /// structured pls see
-  /// https://github.com/microsoft/vscode-extension-samples/blob/5ae1f7787122812dcc84e37427ca90af5ee09f14/semantic-tokens-sample/vscode.proposed.d.ts#L71
-  std::vector tokens;
+  /// The actual tokens.
+  std::vector tokens; // encoded as a flat integer array.
 };
 llvm::json::Value toJSON(const SemanticTokens &);
 
+/// Body of textDocument/semanticTokens/full request.
 struct SemanticTokensParams {
   /// The text document.
   TextDocumentIdentifier textDocument;
 };
 bool fromJSON(const llvm::json::Value &, SemanticTokensParams &);
 
+/// Body of textDocument/semanticTokens/full/delta request.
 /// Requests the changes in semantic tokens since a previous response.
-struct SemanticTokensEditsParams {
+struct SemanticTokensDeltaParams {
   /// The text document.
   TextDocumentIdentifier textDocument;
   /// The previous result id.
   std::string previousResultId;
 };
-bool fromJSON(const llvm::json::Value &Params, SemanticTokensEditsParams &R);
+bool fromJSON(const llvm::json::Value &Params, SemanticTokensDeltaParams &R);
 
 /// Describes a a replacement of a contiguous range of semanticTokens.
 struct SemanticTokensEdit {
@@ -1413,20 +1413,20 @@
   // We use token counts instead, and translate when serializing this struct.
   unsigned startToken = 0;
   unsigned deleteTokens = 0;
-  std::vector tokens;
+  std::vector tokens; // encoded as a flat integer array
 };
 llvm::json::Value toJSON(const SemanticTokensEdit &);
 
-/// This models LSP SemanticTokensEdits | SemanticTokens, which is the result of
-/// textDocument/semanticTokens/edits.
-struct SemanticTokensOrEdits {
+/// This models LSP SemanticTokensDelta | SemanticTokens, which is the result of
+/// textDocument/semanticTokens/full/delta.
+st

[PATCH] D83546: [clangd] Fix hover crash on InitListExpr.

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG015a0faa5e9e: [clangd] Fix hover crash on InitListExpr. 
(authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D83546?vs=277016&id=277031#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83546

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -801,6 +801,21 @@
  HI.LocalScope = "Foo::";
  HI.Type = "int";
  HI.AccessSpecifier = "public";
+   }},
+   {// No crash on InitListExpr.
+R"cpp(
+  struct Foo {
+int a[10];
+  };
+  constexpr Foo k2 = {
+^[[{]]1} // FIXME: why the hover range is 1 character?
+  };
+ )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Kind = index::SymbolKind::Unknown;
+ HI.Type = "int [10]";
+ HI.Value = "{1}";
}}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -329,13 +329,23 @@
 
 llvm::Optional printExprValue(const Expr *E,
const ASTContext &Ctx) {
-  Expr::EvalResult Constant;
+  // InitListExpr has two forms, syntactic and semantic. They are the same 
thing
+  // (refer to a same AST node) in most cases.
+  // When they are different, RAV returns the syntactic form, and we should 
feed
+  // the semantic form to EvaluateAsRValue.
+  if (const auto *ILE = llvm::dyn_cast(E)) {
+if (!ILE->isSemanticForm())
+  E = ILE->getSemanticForm();
+  }
+
   // Evaluating [[foo]]() as "&foo" isn't useful, and prevents us walking up
   // to the enclosing call.
   QualType T = E->getType();
   if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() ||
   T->isFunctionReferenceType())
 return llvm::None;
+
+  Expr::EvalResult Constant;
   // Attempt to evaluate. If expr is dependent, evaluation crashes!
   if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) ||
   // Disable printing for record-types, as they are usually confusing and


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -801,6 +801,21 @@
  HI.LocalScope = "Foo::";
  HI.Type = "int";
  HI.AccessSpecifier = "public";
+   }},
+   {// No crash on InitListExpr.
+R"cpp(
+  struct Foo {
+int a[10];
+  };
+  constexpr Foo k2 = {
+^[[{]]1} // FIXME: why the hover range is 1 character?
+  };
+ )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Kind = index::SymbolKind::Unknown;
+ HI.Type = "int [10]";
+ HI.Value = "{1}";
}}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -329,13 +329,23 @@
 
 llvm::Optional printExprValue(const Expr *E,
const ASTContext &Ctx) {
-  Expr::EvalResult Constant;
+  // InitListExpr has two forms, syntactic and semantic. They are the same thing
+  // (refer to a same AST node) in most cases.
+  // When they are different, RAV returns the syntactic form, and we should feed
+  // the semantic form to EvaluateAsRValue.
+  if (const auto *ILE = llvm::dyn_cast(E)) {
+if (!ILE->isSemanticForm())
+  E = ILE->getSemanticForm();
+  }
+
   // Evaluating [[foo]]() as "&foo" isn't useful, and prevents us walking up
   // to the enclosing call.
   QualType T = E->getType();
   if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() ||
   T->isFunctionReferenceType())
 return llvm::None;
+
+  Expr::EvalResult Constant;
   // Attempt to evaluate. If expr is dependent, evaluation crashes!
   if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) ||
   // Disable printing for record-types, as they are usually confusing and
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 015a0fa - [clangd] Fix hover crash on InitListExpr.

2020-07-10 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-07-10T16:18:16+02:00
New Revision: 015a0faa5e9ef3095d521e1daf03fab9683ba028

URL: 
https://github.com/llvm/llvm-project/commit/015a0faa5e9ef3095d521e1daf03fab9683ba028
DIFF: 
https://github.com/llvm/llvm-project/commit/015a0faa5e9ef3095d521e1daf03fab9683ba028.diff

LOG: [clangd] Fix hover crash on InitListExpr.

Fixes https://github.com/clangd/clangd/issues/455

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index cba933508fd5..8305a4724035 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -329,13 +329,23 @@ void fillFunctionTypeAndParams(HoverInfo &HI, const Decl 
*D,
 
 llvm::Optional printExprValue(const Expr *E,
const ASTContext &Ctx) {
-  Expr::EvalResult Constant;
+  // InitListExpr has two forms, syntactic and semantic. They are the same 
thing
+  // (refer to a same AST node) in most cases.
+  // When they are 
diff erent, RAV returns the syntactic form, and we should feed
+  // the semantic form to EvaluateAsRValue.
+  if (const auto *ILE = llvm::dyn_cast(E)) {
+if (!ILE->isSemanticForm())
+  E = ILE->getSemanticForm();
+  }
+
   // Evaluating [[foo]]() as "&foo" isn't useful, and prevents us walking up
   // to the enclosing call.
   QualType T = E->getType();
   if (T.isNull() || T->isFunctionType() || T->isFunctionPointerType() ||
   T->isFunctionReferenceType())
 return llvm::None;
+
+  Expr::EvalResult Constant;
   // Attempt to evaluate. If expr is dependent, evaluation crashes!
   if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx) ||
   // Disable printing for record-types, as they are usually confusing and

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 43f1e7142550..19ab6d63947b 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -801,6 +801,21 @@ class Foo {})cpp";
  HI.LocalScope = "Foo::";
  HI.Type = "int";
  HI.AccessSpecifier = "public";
+   }},
+   {// No crash on InitListExpr.
+R"cpp(
+  struct Foo {
+int a[10];
+  };
+  constexpr Foo k2 = {
+^[[{]]1} // FIXME: why the hover range is 1 character?
+  };
+ )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Kind = index::SymbolKind::Unknown;
+ HI.Type = "int [10]";
+ HI.Value = "{1}";
}}};
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);



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


[PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM

2020-07-10 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 277032.
LukeGeeson added a comment.

- removed RAS as it's in 8.2a


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

https://reviews.llvm.org/D83206

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -262,6 +262,18 @@
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
  ARM::AEK_RAS | ARM::AEK_DOTPROD,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_DOTPROD | 
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_DOTPROD |
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
   EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
@@ -310,7 +322,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 87;
+static constexpr unsigned NumARMCPUArchs = 89;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -865,6 +877,20 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC | AArch64::AEK_SSBS, "8.2-A"));
   EXPECT_TRUE(testAArch64CPU(
+  "cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO  | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
   EXPECT_TRUE(testAArch64CPU(
@@ -1002,7 +1028,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 40;
+static constexpr unsigned NumAArch64CPUArchs = 42;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -5,6 +5,8 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a65ae --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a75 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a77 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a78 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
 
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
@@ -3,6 +3,8 @@
 // RUN

[PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM

2020-07-10 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 277033.
LukeGeeson marked an inline comment as done.
LukeGeeson added a comment.

- removed missed RAS


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

https://reviews.llvm.org/D83206

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -262,6 +262,18 @@
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
  ARM::AEK_RAS | ARM::AEK_DOTPROD,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_DOTPROD | 
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_DOTPROD |
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
   EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
@@ -310,7 +322,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 87;
+static constexpr unsigned NumARMCPUArchs = 89;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -865,6 +877,20 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC | AArch64::AEK_SSBS, "8.2-A"));
   EXPECT_TRUE(testAArch64CPU(
+  "cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO  | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
   EXPECT_TRUE(testAArch64CPU(
@@ -1002,7 +1028,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 40;
+static constexpr unsigned NumAArch64CPUArchs = 42;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -5,6 +5,8 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a65ae --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a75 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a77 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a78 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
 
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-d

[PATCH] D83206: [PATCH] [ARM] Add Cortex-A78 and Cortex-X1 Support for Clang and LLVM

2020-07-10 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 277036.
LukeGeeson added a comment.

- Added FP16 to ARM a78


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

https://reviews.llvm.org/D83206

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -262,6 +262,18 @@
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
  ARM::AEK_RAS | ARM::AEK_DOTPROD,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_DOTPROD | ARM::AEK_FP16 |
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_RAS | ARM::AEK_FP16 | ARM::AEK_DOTPROD |
+ ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
+ ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS,
+ "8.2-A"));
   EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
@@ -310,7 +322,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 87;
+static constexpr unsigned NumARMCPUArchs = 89;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -865,6 +877,20 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC | AArch64::AEK_SSBS, "8.2-A"));
   EXPECT_TRUE(testAArch64CPU(
+  "cortex-a78", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO  | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "cortex-x1", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS,
+  "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
   EXPECT_TRUE(testAArch64CPU(
@@ -1002,7 +1028,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 40;
+static constexpr unsigned NumAArch64CPUArchs = 42;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -5,6 +5,8 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a65ae --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a75 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a77 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a78 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
 
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
@@ -3,6 +3,8 @

[PATCH] D83556: [clangd] Update semanticTokens support to reflect latest LSP draft

2020-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83556



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


[PATCH] D83407: [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions

2020-07-10 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:328-329
   struct Signature {
-const ArgTypes ArgTys;
-const QualType RetTy;
+ArgTypes ArgTys;
+QualType RetTy;
 Signature(ArgTypes ArgTys, QualType RetTy) : ArgTys(ArgTys), RetTy(RetTy) {

Szelethus wrote:
> Ah right, because we need to copy this. Shame that `Optional` can't just 
> inplace construct the object with a copy constructor or something.
The problem is rather with the copy assignment. I think, copy construction 
could be implemented if we keep the `const`, but assignment is not.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1746
+if (StructSockaddrPtrRestrictTy && Socklen_tPtrRestrictTy) {
+  auto Accept = Summary(NoEvalCall)
+.ArgConstraint(ArgumentCondition(0, WithinRange,

Szelethus wrote:
> `AcceptSummary`?
I prefer simply `Accept` because right after the `=` sign we have the `Summary` 
string :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83407



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


[clang] 523a851 - [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support."

2020-07-10 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-10T10:34:15-04:00
New Revision: 523a8513f8ba4d6b111496c541b9ba9f4d5f0261

URL: 
https://github.com/llvm/llvm-project/commit/523a8513f8ba4d6b111496c541b9ba9f4d5f0261
DIFF: 
https://github.com/llvm/llvm-project/commit/523a8513f8ba4d6b111496c541b9ba9f4d5f0261.diff

LOG: [FPEnv][Clang][Driver] Disable constrained floating point on targets 
lacking support."

Use the new -fexperimental-strict-floating-point flag in more cases to
fix the arm and aarch64 bots.

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

Added: 


Modified: 
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c

Removed: 




diff  --git a/clang/test/CodeGen/fpconstrained-cmp-double.c 
b/clang/test/CodeGen/fpconstrained-cmp-double.c
index 6f19db2099db..335b7e49b01d 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-double.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-double.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK -check-prefix=FCMP
 // RUN: %clang_cc1 -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -ffp-exception-behavior=maytrap 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=MAYTRAP
-// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE
+// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=IGNORE
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=MAYTRAP
 

diff  --git a/clang/test/CodeGen/fpconstrained-cmp-float.c 
b/clang/test/CodeGen/fpconstrained-cmp-float.c
index bca0cdb7eda4..e9667904122b 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-float.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-float.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK -check-prefix=FCMP
+// RUN: %clang_cc1 -ffp-exception-behavior=ignore 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=FCMP
 // RUN: %clang_cc1 -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -ffp-exception-behavior=maytrap 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=MAYTRAP
-// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE
+// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=IGNORE
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=MAYTRAP
 



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


[PATCH] D82574: Merge TableGen files used for clang options

2020-07-10 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

I think that 'clang/include/clang/Driver/CC1Options.td' should also be removed ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82574



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I think without index changes this will still give the wrong answer for 
go-to-definition if the @implementation is in a different file.
Do you want to include those too or will that work ok in a separate patch?
(I'm not 100% sure of the interactions here, possible it'll seem a bit glitchy)




Comment at: clang-tools-extra/clangd/XRefs.cpp:241
+// because it is first, but we actually want the class definition if it is
+// available since that is what a programmer would consider the real definition
+// to be.

nit: real definition -> primary declaration



Comment at: clang-tools-extra/clangd/XRefs.cpp:243
+// to be.
+const NamedDecl *getNonStandardCanonicalDecl(const NamedDecl *D) {
+  D = llvm::cast(D->getCanonicalDecl());

I'd consider getPreferredDecl here.
We may consider moving this to AST.h someday.



Comment at: clang-tools-extra/clangd/XRefs.cpp:88-92
+  if (const auto *ID = dyn_cast(D)) {
+if (const auto *IMD = ID->getImplementation())
+  return IMD;
+return ID->getDefinition();
+  }

dgoldman wrote:
> sammccall wrote:
> > dgoldman wrote:
> > > Let me know if there's a better way to handle this multi-"definition" 
> > > support
> > I think there might be (what you've done seems reasonable in isolation but 
> > I'm not sure it'll yield the best behavior).
> > 
> > Consider this code:
> > ```
> > int foo(); // A
> > int foo(); // B
> > int foo(){} // C
> > ```
> > We have 3 declarations. A will be chosen as the canonical declaration 
> > (because it's first, though things get more complicated when the index is 
> > involved). C is the definition. So go-to-definition will land on C, and 
> > then triggering it again will take you to A, and then back to C. 
> > go-to-declaration is the opposite. B is basically just a reference for our 
> > purposes, we won't navigate you there (except by find-refs).
> > 
> > Now let's look at your example again:
> > ```
> > @class MyClass; // A
> > @interface MyClass ... @end // B
> > @implementation MyClass ... @end // C
> > ```
> > Thinking about where you might want to navigate to, A is certainly the 
> > least important of these, right?
> > It seems clear we want B to be considered the canonical declaration and C 
> > the definition.
> > 
> > So I think:
> >  - we should only return the implementation here if it exists, and 
> > otherwise nullptr rather than the inferface.
> >  - getCanonicalDecl in AddResultDecl should special case ObjCInterfaceDecl 
> > to get the definition (i.e. @interface) if possible
> >  - we need to convince other parts of clangd that these are the same symbol:
> >- targetDecl should resolve any reference to an ObjCImplDecl to the 
> > corresponding ObjCInterfaceDecl instead
> >- the indexer (`SymbolCollector`) also needs to handle this (the 
> > ObjCImplDecl should end up being the stored Definition under the 
> > ObjCInterfaceDecl's SymbolID)
> > 
> > Some code will only see the forward declaration and that's OK. The index's 
> > merge rules are that a candidate "canonical declaration" which has an 
> > associated definition is preferred over one that doesn't. Since the 
> > implementation can always see the interface, the interface will end up 
> > being the canonical declaration after merge.
> Thanks, that makes sense - I agree that B should be the actual canonical 
> declaration for our case (even though Clang picks A) and C is the definition. 
> I think that part was confusing me, since Clang seems to use the forward 
> declaration as the canonical one when it exists, but it seems like that's 
> intentional/OK and shouldn't change (e.g. for `ReferenceFinder` in the same 
> file). 
> Clang seems to use the forward declaration as the canonical one when it exists

This is **super** confusing.

Clang has a concept of canonical declaration that's basically arbitrary: you 
pick one so that e.g. if you have canonical decls you can compare their 
pointers. It picks the first one seen, which is nice because it's stable over 
the life of the parse.

Clangd has a concept of canonical declaration that's not arbitrary: it's meant 
to be the declaration the user wants to see.

And yet, clangd's canonical is initialized to clang's canonical by default, 
because we've got to pick something.
There is some more logic (e.g. a class's canonical decl is its def, if that's 
in a header file) but it mostly exists in the indexer, so it's not really 
obvious.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


[clang-tools-extra] 5fea54b - [clangd] Update semanticTokens support to reflect latest LSP draft

2020-07-10 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-07-10T16:52:57+02:00
New Revision: 5fea54bc05a71e81e843fd9284d258cd38d7fe23

URL: 
https://github.com/llvm/llvm-project/commit/5fea54bc05a71e81e843fd9284d258cd38d7fe23
DIFF: 
https://github.com/llvm/llvm-project/commit/5fea54bc05a71e81e843fd9284d258cd38d7fe23.diff

LOG: [clangd] Update semanticTokens support to reflect latest LSP draft

Summary: Mostly a few methods and message names have been renamed.

Reviewers: hokein

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/test/semantic-tokens.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 1d794b1898c7..b0aba886edbe 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -599,8 +599,8 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
  }},
 {"semanticTokensProvider",
  llvm::json::Object{
- {"documentProvider", llvm::json::Object{{"edits", true}}},
- {"rangeProvider", false},
+ {"full", llvm::json::Object{{"delta", true}}},
+ {"range", false},
  {"legend",
   llvm::json::Object{{"tokenTypes", semanticTokenTypes()},
  {"tokenModifiers", llvm::json::Array()}}},
@@ -1311,9 +1311,9 @@ void ClangdLSPServer::onSemanticTokens(const 
SemanticTokensParams &Params,
   });
 }
 
-void ClangdLSPServer::onSemanticTokensEdits(
-const SemanticTokensEditsParams &Params,
-Callback CB) {
+void ClangdLSPServer::onSemanticTokensDelta(
+const SemanticTokensDeltaParams &Params,
+Callback CB) {
   Server->semanticHighlights(
   Params.textDocument.uri.file(),
   [this, PrevResultID(Params.previousResultId),
@@ -1323,7 +1323,7 @@ void ClangdLSPServer::onSemanticTokensEdits(
   return CB(HT.takeError());
 std::vector Toks = toSemanticTokens(*HT);
 
-SemanticTokensOrEdits Result;
+SemanticTokensOrDelta Result;
 {
   std::lock_guard Lock(SemanticTokensMutex);
   auto &Last = LastSemanticTokens[File];
@@ -1331,8 +1331,8 @@ void ClangdLSPServer::onSemanticTokensEdits(
   if (PrevResultID == Last.resultId) {
 Result.edits = 
diff Tokens(Last.tokens, Toks);
   } else {
-vlog("semanticTokens/edits: wanted edits vs {0} but last result "
- "had ID {1}. Returning full token list.",
+vlog("semanticTokens/full/delta: wanted edits vs {0} but last "
+ "result had ID {1}. Returning full token list.",
  PrevResultID, Last.resultId);
 Result.tokens = Toks;
   }
@@ -1393,8 +1393,8 @@ ClangdLSPServer::ClangdLSPServer(
   MsgHandler->bind("typeHierarchy/resolve", 
&ClangdLSPServer::onResolveTypeHierarchy);
   MsgHandler->bind("textDocument/selectionRange", 
&ClangdLSPServer::onSelectionRange);
   MsgHandler->bind("textDocument/documentLink", 
&ClangdLSPServer::onDocumentLink);
-  MsgHandler->bind("textDocument/semanticTokens", 
&ClangdLSPServer::onSemanticTokens);
-  MsgHandler->bind("textDocument/semanticTokens/edits", 
&ClangdLSPServer::onSemanticTokensEdits);
+  MsgHandler->bind("textDocument/semanticTokens/full", 
&ClangdLSPServer::onSemanticTokens);
+  MsgHandler->bind("textDocument/semanticTokens/full/delta", 
&ClangdLSPServer::onSemanticTokensDelta);
   // clang-format on
 }
 

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 6ccef9500679..a779e9036c4a 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -121,8 +121,8 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
   void onDocumentLink(const DocumentLinkParams &,
   Callback>);
   void onSemanticTokens(const SemanticTokensParams &, 
Callback);
-  void onSemanticTokensEdits(const SemanticTokensEditsParams &,
- Callback);
+  void onSemanticTokensDelta(const SemanticTokensDeltaParams &,
+ Callback);
 
   std::vector getFixes(StringRef File, const clangd::Diagnostic &D);
 

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index ecae65336e5b..239603715785 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -1029,7 +1029,7 @@ llvm::

[PATCH] D83556: [clangd] Update semanticTokens support to reflect latest LSP draft

2020-07-10 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5fea54bc05a7: [clangd] Update semanticTokens support to 
reflect latest LSP draft (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83556

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test

Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -13,7 +13,7 @@
 }}}
 ---
 # Non-incremental token request.
-{"jsonrpc":"2.0","id":1,"method":"textDocument/semanticTokens","params":{"textDocument":{"uri":"test:///foo.cpp"}}}
+{"jsonrpc":"2.0","id":1,"method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"test:///foo.cpp"}}}
 # CHECK:   "id": 1,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": {
@@ -34,7 +34,7 @@
 }}
 ---
 # Incremental token request, based on previous response.
-{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/edits","params":{
+{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/full/delta","params":{
   "textDocument": {"uri":"test:///foo.cpp"},
   "previousResultId": "1"
 }}
@@ -60,7 +60,7 @@
 # CHECK-NEXT:  }
 ---
 # Incremental token request with incorrect baseline => full tokens list.
-{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/edits","params":{
+{"jsonrpc":"2.0","id":2,"method":"textDocument/semanticTokens/full/delta","params":{
   "textDocument": {"uri":"test:///foo.cpp"},
   "previousResultId": "bogus"
 }}
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -42,8 +42,8 @@
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "selectionRangeProvider": true,
 # CHECK-NEXT:  "semanticTokensProvider": {
-# CHECK-NEXT:"documentProvider": {
-# CHECK-NEXT:  "edits": true
+# CHECK-NEXT:"full": {
+# CHECK-NEXT:  "delta": true
 # CHECK-NEXT:},
 # CHECK-NEXT:"legend": {
 # CHECK-NEXT:  "tokenModifiers": [],
@@ -51,7 +51,7 @@
 # CHECK-NEXT:"variable",
 # CHECK:   ]
 # CHECK-NEXT:},
-# CHECK-NEXT:"rangeProvider": false
+# CHECK-NEXT:"range": false
 # CHECK-NEXT:  },
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1384,27 +1384,27 @@
   // send a delta.
   std::string resultId;
 
-  /// The actual tokens. For a detailed description about how the data is
-  /// structured pls see
-  /// https://github.com/microsoft/vscode-extension-samples/blob/5ae1f7787122812dcc84e37427ca90af5ee09f14/semantic-tokens-sample/vscode.proposed.d.ts#L71
-  std::vector tokens;
+  /// The actual tokens.
+  std::vector tokens; // encoded as a flat integer array.
 };
 llvm::json::Value toJSON(const SemanticTokens &);
 
+/// Body of textDocument/semanticTokens/full request.
 struct SemanticTokensParams {
   /// The text document.
   TextDocumentIdentifier textDocument;
 };
 bool fromJSON(const llvm::json::Value &, SemanticTokensParams &);
 
+/// Body of textDocument/semanticTokens/full/delta request.
 /// Requests the changes in semantic tokens since a previous response.
-struct SemanticTokensEditsParams {
+struct SemanticTokensDeltaParams {
   /// The text document.
   TextDocumentIdentifier textDocument;
   /// The previous result id.
   std::string previousResultId;
 };
-bool fromJSON(const llvm::json::Value &Params, SemanticTokensEditsParams &R);
+bool fromJSON(const llvm::json::Value &Params, SemanticTokensDeltaParams &R);
 
 /// Describes a a replacement of a contiguous range of semanticTokens.
 struct SemanticTokensEdit {
@@ -1413,20 +1413,20 @@
   // We use token counts instead, and translate when serializing this struct.
   unsigned startToken = 0;
   unsigned deleteTokens = 0;
-  std::vector tokens;
+  std::vector tokens; // encoded as a flat integer array
 };
 llvm::json::Value toJSON(const SemanticTokensEdit &);
 
-/// This models LSP SemanticTokensEdits | SemanticTokens, which is the result of
-/// textDocument/semanticTokens/edits.
-struct SemanticTokensOrEdits {
+/// This models LSP SemanticTokensDelta | SemanticTokens, which is the result of
+/// textDocument/semanticTokens/full/delta.
+

[PATCH] D71124: [RISCV] support clang driver to select cpu

2020-07-10 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen updated this revision to Diff 277042.
khchen added a comment.

fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71124

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/riscv-cpus.c
  llvm/include/llvm/Support/RISCVTargetParser.def
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp
  llvm/lib/Target/RISCV/RISCV.td

Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -215,6 +215,16 @@
 
 def : ProcessorModel<"rocket-rv64", Rocket64Model, [Feature64Bit]>;
 
+def : ProcessorModel<"sifive-e31", Rocket32Model, [FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtC]>;
+
+def : ProcessorModel<"sifive-u54", Rocket64Model, [Feature64Bit,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC]>;
 
 //===--===//
 // Define the RISC-V target.
Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -13,6 +13,7 @@
 
 #include "llvm/Support/ARMBuildAttributes.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
@@ -208,3 +209,64 @@
   default: return {0, 0, 0};
   }
 }
+
+namespace llvm {
+namespace RISCV {
+
+struct CPUInfo {
+  StringLiteral Name;
+  CPUKind Kind;
+  unsigned Features;
+  StringLiteral DefaultMarch;
+  bool Is64Bit() const { return (Features & FK_64BIT); }
+};
+
+constexpr CPUInfo RISCVCPUInfo[] = {
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)  \
+  {NAME, CK_##ENUM, FEATURES, DEFAULT_MARCH},
+#include "llvm/Support/RISCVTargetParser.def"
+};
+
+bool checkCPUKind(CPUKind Kind, bool IsRV64) {
+  if (Kind == CK_INVALID)
+return false;
+  return RISCVCPUInfo[static_cast(Kind)].Is64Bit() == IsRV64;
+}
+
+CPUKind parseCPUKind(StringRef CPU) {
+  return llvm::StringSwitch(CPU)
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) .Case(NAME, CK_##ENUM)
+#include "llvm/Support/RISCVTargetParser.def"
+  .Default(CK_INVALID);
+}
+
+StringRef getMArchFromMcpu(StringRef CPU) {
+  CPUKind Kind = parseCPUKind(CPU);
+  return RISCVCPUInfo[static_cast(Kind)].DefaultMarch;
+}
+
+void fillValidCPUArchList(SmallVectorImpl &Values, bool IsRV64) {
+  for (const auto &C : RISCVCPUInfo) {
+if (IsRV64 == C.Is64Bit())
+  Values.emplace_back(C.Name);
+  }
+}
+
+// Get all features except standard extension feature
+bool getCPUFeaturesExceptStdExt(CPUKind Kind,
+std::vector &Features) {
+  unsigned features = RISCVCPUInfo[static_cast(Kind)].Features;
+
+  if (features == FK_INVALID)
+return false;
+
+  if (features & FK_64BIT)
+Features.push_back("+64bit");
+  else
+Features.push_back("-64bit");
+
+  return true;
+}
+
+} // namespace RISCV
+} // namespace llvm
Index: llvm/include/llvm/Support/TargetParser.h
===
--- llvm/include/llvm/Support/TargetParser.h
+++ llvm/include/llvm/Support/TargetParser.h
@@ -130,6 +130,32 @@
 
 } // namespace AMDGPU
 
+namespace RISCV {
+
+enum CPUKind : unsigned {
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) CK_##ENUM,
+#include "RISCVTargetParser.def"
+};
+
+enum FeatureKind : unsigned {
+  FK_INVALID = 0,
+  FK_NONE = 1,
+  FK_STDEXTM = 1 << 2,
+  FK_STDEXTA = 1 << 3,
+  FK_STDEXTF = 1 << 4,
+  FK_STDEXTD = 1 << 5,
+  FK_STDEXTC = 1 << 6,
+  FK_64BIT = 1 << 7,
+};
+
+bool checkCPUKind(CPUKind kind, bool IsRV64);
+CPUKind parseCPUKind(StringRef CPU);
+StringRef getMArchFromMcpu(StringRef CPU);
+void fillValidCPUArchList(SmallVectorImpl &Values, bool IsRV64);
+bool getCPUFeaturesExceptStdExt(CPUKind kind, std::vector &Features);
+
+} // namespace RISCV
+
 } // namespace llvm
 
 #endif
Index: llvm/include/llvm/Support/RISCVTargetParser.def
===
--- /dev/null
+++ llvm/include/llvm/Support/RISCVTargetParser.def
@@ -0,0 +1,13 @@
+#ifndef PROC
+#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)
+#endif
+
+PROC(INVALID, {"invalid"}, FK_INVALID, {""})
+PROC(GENER

[PATCH] D82157: Fix crash on `user defined literals`

2020-07-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:749
+  else
+return new (allocator()) syntax::FloatUserDefinedLiteralExpression;
+}

`... else { assert(Literal.isFloatingLiteral()); return new ... }`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82157



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


[PATCH] D83553: [PATCH 3/4][Sema][AArch64] Add codegen for arm_sve_vector_bits attribute

2020-07-10 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 277043.
c-rhodes added a comment.

Changes:

- Use fixed-length instead of fixed-width in naming.


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

https://reviews.llvm.org/D83553

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/test/Sema/attr-arm-sve-vector-bits-bitcast.c
  clang/test/Sema/attr-arm-sve-vector-bits-call.c
  clang/test/Sema/attr-arm-sve-vector-bits-cast.c
  clang/test/Sema/attr-arm-sve-vector-bits-codegen.c
  clang/test/Sema/attr-arm-sve-vector-bits-globals.c
  clang/test/Sema/attr-arm-sve-vector-bits-types.c

Index: clang/test/Sema/attr-arm-sve-vector-bits-types.c
===
--- /dev/null
+++ clang/test/Sema/attr-arm-sve-vector-bits-types.c
@@ -0,0 +1,525 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=128 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-128
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=256 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-256
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=512 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-512
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=1024 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-1024
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -D__ARM_FEATURE_SVE_BITS=2048 -fallow-half-arguments-and-returns -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-2048
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+
+typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint16_t fixed_int16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint32_t fixed_int32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint64_t fixed_int64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svuint8_t fixed_uint8_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint16_t fixed_uint16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint32_t fixed_uint32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svuint64_t fixed_uint64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svfloat16_t fixed_float16_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat32_t fixed_float32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svfloat64_t fixed_float64_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbfloat16_t fixed_bfloat16_t __attribute__((arm_sve_vector_bits(N)));
+
+typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
+
+//===--===//
+// Structs and unions
+//===--===//
+#define DEFINE_STRUCT(ty) \
+  struct struct_##ty {\
+fixed_##ty##_t x; \
+  } struct_##ty;
+
+#define DEFINE_UNION(ty) \
+  union union_##ty { \
+fixed_##ty##_t x;\
+  } union_##ty;
+
+DEFINE_STRUCT(int8)
+DEFINE_STRUCT(int16)
+DEFINE_STRUCT(int32)
+DEFINE_STRUCT(int64)
+DEFINE_STRUCT(uint8)
+DEFINE_STRUCT(uint16)
+DEFINE_STRUCT(uint32)
+DEFINE_STRUCT(uint64)
+DEFINE_STRUCT(float16)
+DEFINE_STRUCT(float32)
+DEFINE_STRUCT(float64)
+DEFINE_STRUCT(bfloat16)
+DEFINE_STRUCT(bool)
+
+DEFINE_UNION(int8)
+DEFINE_UNION(int16)
+DEFINE_UNION(int32)
+DEFINE_UNION(int64)
+DEFINE_UNION(uint8)
+DEFINE_UNION(uint16)
+DEFINE_UNION(uint32)
+DEFINE_UNION(uint64)
+DEFINE_UNION(float16)
+DEFINE_UNION(float32)
+DEFINE_UNION(float64)
+DEFINE_UNION(bfloat16)
+DEFINE_UNION(bool)
+
+//===--===//
+// Global variables
+//===--===//
+fixed_int8_t global_i8;
+fixed_int16_t global_i16;
+fixed_int32_t global_i32;
+fixed_int64_t global_i64;
+
+fixed_uint8_t global_u8;
+fixed_uint16_t global_u16;
+fixed_uint32_t global_u32;
+fixed_uint64_t global_u64;
+
+fixed_float16_t global_f16;
+fixed_float32_t global_f32;
+fixed_float64_t global_f64;
+
+fixed_bfloat16_t global_bf16;
+
+fixed_bool_t global_bool;
+
+//===--===//
+// Global arrays
+//===--===//
+fixed_int8_t global_arr_i8[3];
+fixed_int16_t global_arr_i16[3];
+fixed_int32_t global_arr_i32[3];
+fixed_int64_t global_arr_i64[3];
+
+fixed

[PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations.

2020-07-10 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

In D82663#2142426 , @rjmccall wrote:

> Would it be sensible to use a technical design more like what the matrix 
> folks are doing, where LLVM provides a small interface for emitting 
> operations with various semantics?  FixedPointSemantics would move to that 
> header, and Clang would just call into it.  That way you get a lot more 
> flexibility in how you generate code, and the Clang IRGen logic is still 
> transparently correct.  If you want to add intrinsics or otherwise change the 
> IR patterns used for various operations, you don't have to rewrite a bunch of 
> Clang IRGen logic every time, you just have to update the tests.  It'd then 
> be pretty straightforward to have internal helper functions in that interface 
> for computing things like whether you should use signed or unsigned 
> intrinsics given the desired FixedPointSemantics.


This seems like a reasonable thing to do for other reasons as well. Also moving 
the actual APFixedPoint class to LLVM would make it easier to reuse the 
fixedpoint calculation code for constant folding in LLVM, for example.

> My interest here is mainly in (1) keeping IRGen's logic as obviously correct 
> as possible, (2) not hard-coding a bunch of things that really feel like 
> workarounds for backend limitations, and (3) not complicating core 
> abstractions like FixedPointSemantics with unnecessary extra rules for 
> appropriate use, like having to pass an extra "for codegen" flag to get 
> optimal codegen.  If IRGen can just pass down the high-level semantics it 
> wants to some library that will make intelligent decisions about how to emit 
> IR, that seems best.

Just to clarify something here; would the interface in LLVM still emit signed 
operations for unsigned with padding?  If so, why does dealing with the padding 
bit detail in LLVM rather than Clang make more sense? The regular IRBuilder is 
relatively straightforward in its behavior.  I suspect that if anything, LLVM 
would be equally unwilling to take to take IRBuilder patches that emitted 
signed intrinsics for certain unsigned operations only due to a detail in 
Embedded-C's implementation of fixedpoint support.

I could remove the special behavior from FixedPointSemantics and only deal with 
it in EmitFixedPointBinOp instead. I agree that the FixedPointSemantics 
interface is muddied by the extra parameter.
Unless I alter the semantics object it might make EmitFixedPointBinOp rather 
messy, though.

---

Regarding backend limitations, I guess I could propose an alternate solution. 
If we change FixedPointSemantics to strip the padding bit for both saturating 
and nonsaturating operations, it may be possible to detect in isel that the 
corresponding signed operation could be used instead when we promote the type 
of an unsigned one. For example, if we emit i15 umul.fix scale 15, we could 
tell in lowering that i16 smul.fix scale 15 is legal and use that instead. Same 
for all the other intrinsics, including the non-fixedpoint uadd.sat/usub.sat.

The issue with this approach (which is why I didn't really want to do it) is 
that it's not testable. No upstream target has these intrinsics marked as 
legal. I doubt anyone would accept a patch with no tests.
It may also be less efficient than just emitting the signed operations in the 
first place, because we are forced to trunc and zext in IR before and after 
every operation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82663



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 277054.
dgoldman marked 2 inline comments as done.
dgoldman added a comment.

Add support for categories + fix tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501

Files:
  clang-tools-extra/clangd/XRefs.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
@@ -676,7 +676,7 @@
 };
   )cpp",
 
-  R"objc(//objc
+  R"objc(
 @protocol $decl[[Dog]];
 @protocol $def[[Dog]]
 - (void)bark;
@@ -686,14 +686,25 @@
 }
   )objc",
 
-  R"objc(//objc
+  R"objc(
+@interface Cat
+@end
+@interface $decl[[Ca^t]] (Extension)
+- (void)meow;
+@end
+@implementation $def[[Cat]] (Extension)
+- (void)meow {}
+@end
+  )objc",
+
+  R"objc(
 @class $decl[[Foo]];
 Fo^o * getFoo() {
   return 0;
 }
   )objc",
 
-  R"objc(//objc
+  R"objc(
 @class Foo;
 @interface $decl[[Foo]]
 @end
@@ -702,7 +713,7 @@
 }
   )objc",
 
-  R"objc(//objc
+  R"objc(
 @class Foo;
 @interface $decl[[Foo]]
 @end
@@ -726,14 +737,10 @@
 TestTU TU;
 TU.Code = std::string(T.code());
 
-std::string ObjcPrefix = "//objc";
-if (strncmp(Test, ObjcPrefix.c_str(), ObjcPrefix.size()) == 0) {
-  TU.Filename = "TestTU.m";
-}
-
 // FIXME: Auto-completion in a template requires disabling delayed template
 // parsing.
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+TU.ExtraArgs.push_back("-xobjective-c++");
 
 auto AST = TU.build();
 auto Results = locateSymbolAt(AST, T.point());
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -82,6 +82,8 @@
 return PD->getDefinition();
   if (const auto *ID = dyn_cast(D))
 return ID->getImplementation();
+  if (const auto *CD = dyn_cast(D))
+return CD->getImplementation();
   // Only a single declaration is allowed.
   if (isa(D) || isa(D) ||
   isa(D)) // except cases above


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -676,7 +676,7 @@
 };
   )cpp",
 
-  R"objc(//objc
+  R"objc(
 @protocol $decl[[Dog]];
 @protocol $def[[Dog]]
 - (void)bark;
@@ -686,14 +686,25 @@
 }
   )objc",
 
-  R"objc(//objc
+  R"objc(
+@interface Cat
+@end
+@interface $decl[[Ca^t]] (Extension)
+- (void)meow;
+@end
+@implementation $def[[Cat]] (Extension)
+- (void)meow {}
+@end
+  )objc",
+
+  R"objc(
 @class $decl[[Foo]];
 Fo^o * getFoo() {
   return 0;
 }
   )objc",
 
-  R"objc(//objc
+  R"objc(
 @class Foo;
 @interface $decl[[Foo]]
 @end
@@ -702,7 +713,7 @@
 }
   )objc",
 
-  R"objc(//objc
+  R"objc(
 @class Foo;
 @interface $decl[[Foo]]
 @end
@@ -726,14 +737,10 @@
 TestTU TU;
 TU.Code = std::string(T.code());
 
-std::string ObjcPrefix = "//objc";
-if (strncmp(Test, ObjcPrefix.c_str(), ObjcPrefix.size()) == 0) {
-  TU.Filename = "TestTU.m";
-}
-
 // FIXME: Auto-completion in a template requires disabling delayed template
 // parsing.
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+TU.ExtraArgs.push_back("-xobjective-c++");
 
 auto AST = TU.build();
 auto Results = locateSymbolAt(AST, T.point());
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -82,6 +82,8 @@
 return PD->getDefinition();
   if (const auto *ID = dyn_cast(D))
 return ID->getImplementation();
+  if (const auto *CD = dyn_cast(D))
+return CD->getImplementation();
   // Only a single declaration is allowed.
   if (isa(D) || isa(D) ||
   isa(D)) // except cases above
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-07-10 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

Please update this patch to remove the instruction defs and MC tests. Also, you 
can update the patch to put your backend llc tests in the file I've introduced 
in: https://reviews.llvm.org/D82467




Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:14
 
-#include 
+#include "altivec.h"
 

unintended change?



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:14165
+  // The width of the narrow type becomes an operand of the LXVRZX node
+  SDValue Width = ;
+  SDValue LoadOps[] = {LD->getChain(), LD->getBasePtr(), 
DAG.getIntPtrConstant(MemoryType.getScalarSizeInBits(), dl)};

You did not assign anything here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82502



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


[PATCH] D82157: Fix crash on `user defined literals`

2020-07-10 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 277060.
eduucaldas marked an inline comment as done.
eduucaldas added a comment.

Add assert


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82157

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -1184,20 +1184,139 @@
 )txt"));
 }
 
-TEST_P(SyntaxTreeTest, IntegerLiteral) {
+TEST_P(SyntaxTreeTest, UserDefinedLiteral) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
   EXPECT_TRUE(treeDumpEqual(
   R"cpp(
+typedef decltype(sizeof(void *)) size_t;
+
+unsigned operator "" _i(unsigned long long);
+unsigned operator "" _f(long double);
+unsigned operator "" _c(char);
+unsigned operator "" _s(const char*, size_t);
+unsigned operator "" _r(const char*);
+template 
+unsigned operator "" _t();
+
 void test() {
-  12;
-  12u;
-  12l;
-  12ul;
-  014;
-  0XC;
+  12_i;   // call: operator "" _i(12uLL)  | kind: integer
+  1.2_f;  // call: operator "" _f(1.2L)   | kind: float
+  '2'_c;  // call: operator "" _c('2')| kind: char
+  "12"_s; // call: operator "" _s("12")   | kind: string
+
+  12_r;   // call: operator "" _r("12")   | kind: integer
+  1.2_r;  // call: operator "" _i("1.2")  | kind: float
+  12_t;   // call: operator<'1', '2'> "" _x() | kind: integer
+  1.2_t;  // call: operator<'1', '2'> "" _x() | kind: float
 }
-)cpp",
+)cpp",
   R"txt(
 *: TranslationUnit
+|-SimpleDeclaration
+| |-typedef
+| |-decltype
+| |-(
+| |-UnknownExpression
+| | |-sizeof
+| | |-(
+| | |-void
+| | |-*
+| | `-)
+| |-)
+| |-SimpleDeclarator
+| | `-size_t
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_i
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-unsigned
+| |   | |-long
+| |   | `-long
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_f
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-long
+| |   | `-double
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_c
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | `-char
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_s
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-const
+| |   | |-char
+| |   | `-SimpleDeclarator
+| |   |   `-*
+| |   |-,
+| |   |-SimpleDeclaration
+| |   | `-size_t
+| |   `-)
+| `-;
+|-SimpleDeclaration
+| |-unsigned
+| |-SimpleDeclarator
+| | |-operator
+| | |-""
+| | |-_r
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   |-SimpleDeclaration
+| |   | |-const
+| |   | |-char
+| |   | `-SimpleDeclarator
+| |   |   `-*
+| |   `-)
+| `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-SimpleDeclaration
+| | `-char
+| |-...
+| |->
+| `-SimpleDeclaration
+|   |-unsigned
+|   |-SimpleDeclarator
+|   | |-operator
+|   | |-""
+|   | |-_t
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   `-)
+|   `-;
 `-SimpleDeclaration
   |-void
   |-SimpleDeclarator
@@ -1208,28 +1327,36 @@
   `-CompoundStatement
 |-{
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12
+| |-IntegerUserDefinedLiteralExpression
+| | `-12_i
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12u
+| |-FloatUserDefinedLiteralExpression
+| | `-1.2_f
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12l
+| |-CharUserDefinedLiteralExpression
+| | `-'2'_c
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-12ul
+| |-StringUserDefinedLiteralExpression
+| | `-"12"_s
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-014
+| |-IntegerUserDefinedLiteralExpression
+| | `-12_r
 | `-;
 |-ExpressionStatement
-| |-IntegerLiteralExpression
-| | `-0XC
+| |-FloatUserDefinedLiteralExpression
+| | `-1.2_r
+| `-;
+|-ExpressionStatement
+| |-IntegerUserDefinedLiteralExpression
+| | `-12_t
+| `-;
+|-ExpressionStatement
+| |-FloatUserDefinedLiteralExpression
+| | `-1.2_t
 | `-;
 `-}
 )txt"));
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -32,6 +32,14 @@
 return OS << "BoolLiteralExpression";
   case NodeKind::CxxNullPtrExpression:
 return OS << "CxxNullPtrExpression";

[PATCH] D83536: [clangd] Index refs to main-file symbols as well

2020-07-10 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D83536#2143436 , @kadircet wrote:

> I can see how this is needed for implementing the full protocol though (we've 
> already cut on the multi-level callees support), so would you be so kind to 
> hide this behind an option to symbol collector (`CollectRefsInMainFile`) and 
> then introduce a flag to clangd for controlling it 
> `--collect-refs-in-main-file` and plumb it to `BackgroundIndex` and 
> `FileIndex` via `ClangdServer`?


I can do that.

Another thing we could consider, if the space increase is a concern, is to 
limit which references we store, e.g. to functions only (not variables or 
classes).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83536



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


[PATCH] D83501: [clangd][ObjC] Improve xrefs for protocols and classes

2020-07-10 Thread David Goldman via Phabricator via cfe-commits
dgoldman marked an inline comment as done.
dgoldman added a comment.

In D83501#2144144 , @sammccall wrote:

> I think without index changes this will still give the wrong answer for 
> go-to-definition if the @implementation is in a different file.
>  Do you want to include those too or will that work ok in a separate patch?
>  (I'm not 100% sure of the interactions here, possible it'll seem a bit 
> glitchy)


I'll look into the index changes as well in this change, just wanted to get the 
base functionality down for xrefs first. If it seems large I'll probably send a 
follow up diff.




Comment at: clang-tools-extra/clangd/XRefs.cpp:276
getDeclAtPosition(AST, CurLoc, Relations, NodeKind)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {

sammccall wrote:
> dgoldman wrote:
> > Think it would make sense to special case ObjCInterfaceDecl here to get at 
> > both the interface definition + implementation if available?
> Rather than returning both results, I think it's more consistent to return 
> them as a declaration/definition pair.
> 
> (This means special-casing ObjCImplDecl in namedDecl or at least 
> getDeclAsPosition, so you always end up with the ObjCInterfaceDecl instead)
Whoops, meant to comment here but it was lost. I'm not sure what you meant 
here. Should this be done here inside the for loop or in getDeclAtPosition?

Are you saying that given:

```
@interface Foo // A
@end
@implementation Foo // B
@end
```
B --> A here

and similarly

```
@interface Foo // A
@end
@interface Foo (Ext) // B
@end
@implementation Foo (Ext) // C
@end
```
B --> A
C --> B (and A? it's unclear how this should map over, e.g. maybe Foo loc --> 
A, Ext --> B)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83501



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


  1   2   3   >