[PATCH] D77644: [clangd] Handle additional includes while parsing ASTs

2020-04-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 260228.
kadircet added a comment.

- Use PreamblePatch
- Add more tests
- Handle deleted includes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77644

Files:
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp

Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -8,6 +8,7 @@
 
 #include "Annotations.h"
 #include "Compiler.h"
+#include "Headers.h"
 #include "Preamble.h"
 #include "TestFS.h"
 #include "TestTU.h"
@@ -21,6 +22,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -30,49 +32,53 @@
 namespace clangd {
 namespace {
 
+MATCHER_P2(Distance, File, D, "") {
+  return arg.first() == File && arg.second == D;
+}
+
+std::shared_ptr
+createPreamble(llvm::StringRef Contents = "") {
+  auto TU = TestTU::withCode(Contents);
+  // ms-compatibility changes meaning of #import, make sure it is turned off.
+  TU.ExtraArgs = {"-fno-ms-compatibility"};
+  TU.Filename = "preamble.cpp";
+  auto PI = TU.inputs();
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(PI, Diags);
+  if (!CI) {
+ADD_FAILURE() << "failed to build compiler invocation";
+return nullptr;
+  }
+  if (auto Preamble = buildPreamble(TU.Filename, *CI, PI, true, nullptr))
+return Preamble;
+  ADD_FAILURE() << "failed to build preamble";
+  return nullptr;
+}
+
 // Builds a preamble for BaselineContents, patches it for ModifiedContents and
 // returns the includes in the patch.
 IncludeStructure collectPatchedIncludes(llvm::StringRef ModifiedContents,
 llvm::StringRef BaselineContents) {
-  std::string MainFile = testPath("main.cpp");
-  ParseInputs PI;
-  PI.FS = new llvm::vfs::InMemoryFileSystem;
-  MockCompilationDatabase CDB;
-  // ms-compatibility changes meaning of #import, make sure it is turned off.
-  CDB.ExtraClangFlags.push_back("-fno-ms-compatibility");
-  PI.CompileCommand = CDB.getCompileCommand(MainFile).getValue();
-  // Create invocation
-  IgnoreDiagnostics Diags;
-  auto CI = buildCompilerInvocation(PI, Diags);
-  assert(CI && "failed to create compiler invocation");
-  // Build baseline preamble.
-  PI.Contents = BaselineContents.str();
-  PI.Version = "baseline preamble";
-  auto BaselinePreamble = buildPreamble(MainFile, *CI, PI, true, nullptr);
-  assert(BaselinePreamble && "failed to build baseline preamble");
+  auto BaselinePreamble = createPreamble(BaselineContents);
   // Create the patch.
-  PI.Contents = ModifiedContents.str();
-  PI.Version = "modified contents";
-  auto PP = PreamblePatch::create(MainFile, PI, *BaselinePreamble);
+  auto TU = TestTU::withCode(ModifiedContents);
+  auto PI = TU.inputs();
+  auto PP = PreamblePatch::create(testPath(TU.Filename), PI, *BaselinePreamble);
   // Collect patch contents.
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(PI, Diags);
   PP.apply(*CI);
-  llvm::StringRef PatchContents;
-  for (const auto &Rempaped : CI->getPreprocessorOpts().RemappedFileBuffers) {
-if (Rempaped.first == testPath("__preamble_patch__.h")) {
-  PatchContents = Rempaped.second->getBuffer();
-  break;
-}
-  }
-  // Run preprocessor over the modified contents with patched Invocation to and
-  // BaselinePreamble to collect includes in the patch. We trim the input to
-  // only preamble section to not collect includes in the mainfile.
+  // Run preprocessor over the modified contents with patched Invocation. We
+  // provide a preamble and trim contents to ensure only the implicit header
+  // introduced by the patch is parsed and nothing else.
+  // We don't run PP directly over the patch cotents to test production
+  // behaviour.
   auto Bounds = Lexer::ComputePreamble(ModifiedContents, *CI->getLangOpts());
   auto Clang =
   prepareCompilerInstance(std::move(CI), &BaselinePreamble->Preamble,
   llvm::MemoryBuffer::getMemBufferCopy(
   ModifiedContents.slice(0, Bounds.Size).str()),
   PI.FS, Diags);
-  Clang->getPreprocessorOpts().ImplicitPCHInclude.clear();
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0])) {
 ADD_FAILURE() << "failed begin source file";
@@ -150,6 +156,38 @@
   Field(&Inclusion::Written, "")));
 }
 
+TEST(P

[PATCH] D77644: [clangd] Handle additional includes while parsing ASTs

2020-04-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

this is ready for review now, to explain the flow:

While creating a patch we also record remaining includes from Baseline left in 
Modified, as the new ones will be put into the patch already.
That way ParsedAST can keep track of latest state of the preamble + main file 
includes, with the patched includes ending up in the latter.

It doesn't modify include depths, as it is only used by code completion. If 
need be we can prune the tree to get rid of deleted includes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77644



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


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

2020-04-27 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rsmith, rjmccall, Eugene.Zelenko.
Herald added a project: clang.

Object of type `Compilation` now can keep a callback that is called
after each execution of `Command`. This must simplify adaptation of
clang in custom distributions and allow facilities like collection of
execution statistics.


Repository:
  rG LLVM Github Monorepo

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,30 @@
   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,30 @@
   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: cla

[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-27 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

I think we are on the right track with this but what if we are dealing with 
`tok::amp` in a context similar to `operator const FallibleTArray&();` I can 
speculate that the outcome will be `operator const FallibleTArray &();` 
which is wrong.


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

https://reviews.llvm.org/D78879



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


[PATCH] D78658: [clang][Frontend] Add missing error handling

2020-04-27 Thread LemonBoy via Phabricator via cfe-commits
LemonBoy added a comment.

Ping?


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

https://reviews.llvm.org/D78658



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


[PATCH] D78900: [HIP][AMDGPU] Enable structurizer workarounds

2020-04-27 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds created this revision.
Herald added subscribers: llvm-commits, cfe-commits, kerbowa, hiraditya, t-tye, 
tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl, arsenm.
Herald added projects: clang, LLVM.
sameerds added reviewers: yaxunl, scchan, arsenm, rampitec, dstuttard.

The StrucurizeCFG pass has two known limitations that are addressed by
the FixIrreducible pass and the UnifyLoopExits pass. These passes are
invoked by the AMDGPU backend, but currently hidden behind a
command-line option which is disabled by default.

This change enables the workaround when compiling a HIP program. The
option can now be specified multiple times. The user can thus
override the HIP default using:

  clang -mllvm --amdgpu-enable-structurizer-workarounds=false

The HIP toolchain passes all "-mllvm" options to both opt and
llc. But this particular option has no effect on the opt invocation
since it is only used by the AMDGPU target during code generation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78900

Files:
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-structurizer-workarounds.hip
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -195,7 +195,7 @@
 static cl::opt EnableStructurizerWorkarounds(
 "amdgpu-enable-structurizer-workarounds",
 cl::desc("Enable workarounds for the StructurizeCFG pass"), 
cl::init(false),
-cl::Hidden);
+cl::Hidden, cl::ZeroOrMore);
 
 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() {
   // Register the target
Index: clang/test/Driver/hip-structurizer-workarounds.hip
===
--- /dev/null
+++ clang/test/Driver/hip-structurizer-workarounds.hip
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang -### -x hip -mllvm 
--amdgpu-enable-structurizer-workarounds=false %s 2>&1 | FileCheck %s 
-check-prefix=CHECK -check-prefix=MLLVM
+
+// CHECK: "{{.*llc}}"
+// CHECK-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: "--amdgpu-enable-structurizer-workarounds"
+// MLLVM-SAME: "--amdgpu-enable-structurizer-workarounds=false"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -155,6 +155,7 @@
   LlcArgs.push_back(Args.MakeArgString("-mcpu=" + SubArchName));
   LlcArgs.push_back(
   Args.MakeArgString(Twine("-filetype=") + (OutputIsAsm ? "asm" : "obj")));
+  LlcArgs.push_back("--amdgpu-enable-structurizer-workarounds");
 
   // Extract all the -m options
   std::vector Features;


Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -195,7 +195,7 @@
 static cl::opt EnableStructurizerWorkarounds(
 "amdgpu-enable-structurizer-workarounds",
 cl::desc("Enable workarounds for the StructurizeCFG pass"), cl::init(false),
-cl::Hidden);
+cl::Hidden, cl::ZeroOrMore);
 
 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() {
   // Register the target
Index: clang/test/Driver/hip-structurizer-workarounds.hip
===
--- /dev/null
+++ clang/test/Driver/hip-structurizer-workarounds.hip
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -x hip %s 2>&1 | FileCheck %s -check-prefix=CHECK
+// RUN: %clang -### -x hip -mllvm --amdgpu-enable-structurizer-workarounds=false %s 2>&1 | FileCheck %s -check-prefix=CHECK -check-prefix=MLLVM
+
+// CHECK: "{{.*llc}}"
+// CHECK-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: "--amdgpu-enable-structurizer-workarounds"
+// MLLVM-SAME: "--amdgpu-enable-structurizer-workarounds=false"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -155,6 +155,7 @@
   LlcArgs.push_back(Args.MakeArgString("-mcpu=" + SubArchName));
   LlcArgs.push_back(
   Args.MakeArgString(Twine("-filetype=") + (OutputIsAsm ? "asm" : "obj")));
+  LlcArgs.push_back("--amdgpu-enable-structurizer-workarounds");
 
   // Extract all the -m options
   std::vector Features;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 260229.
gamesh411 added a comment.

Reword enum value


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665

Files:
  clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/CrossTU/CMakeLists.txt
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/test/Analysis/Inputs/ctu-other.c
  clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/ctu-different-triples.cpp
  clang/test/Analysis/ctu-main.c
  clang/test/Analysis/ctu-main.cpp
  clang/test/Analysis/ctu-on-demand-parsing-ambigous-compilation-database.c
  clang/test/Analysis/ctu-on-demand-parsing.c
  clang/test/Analysis/ctu-on-demand-parsing.cpp
  clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
  clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -7,10 +7,11 @@
 //===--===//
 
 #include "clang/CrossTU/CrossTranslationUnit.h"
-#include "clang/Frontend/CompilerInstance.h"
 #include "clang/AST/ASTConsumer.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -162,7 +163,7 @@
   IndexFile.os().flush();
   EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
   llvm::Expected> IndexOrErr =
-  parseCrossTUIndex(IndexFileName, "");
+  parseCrossTUIndex(IndexFileName);
   EXPECT_TRUE((bool)IndexOrErr);
   llvm::StringMap ParsedIndex = IndexOrErr.get();
   for (const auto &E : Index) {
@@ -173,25 +174,5 @@
 EXPECT_TRUE(Index.count(E.getKey()));
 }
 
-TEST(CrossTranslationUnit, CTUDirIsHandledCorrectly) {
-  llvm::StringMap Index;
-  Index["a"] = "/b/c/d";
-  std::string IndexText = createCrossTUIndexString(Index);
-
-  int IndexFD;
-  llvm::SmallString<256> IndexFileName;
-  ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("index", "txt", IndexFD,
-  IndexFileName));
-  llvm::ToolOutputFile IndexFile(IndexFileName, IndexFD);
-  IndexFile.os() << IndexText;
-  IndexFile.os().flush();
-  EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
-  llvm::Expected> IndexOrErr =
-  parseCrossTUIndex(IndexFileName, "/ctudir");
-  EXPECT_TRUE((bool)IndexOrErr);
-  llvm::StringMap ParsedIndex = IndexOrErr.get();
-  EXPECT_EQ(ParsedIndex["a"], "/ctudir/b/c/d");
-}
-
 } // end namespace cross_tu
 } // end namespace clang
Index: clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
===
--- clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
+++ clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
@@ -5,7 +5,7 @@
 // RUN: mkdir -p %t/ctudir
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
 // RUN:   -emit-pch -o %t/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
-// RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.txt %t/ctudir/externalDefMap.txt
+// RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
 // RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
Index: clang/test/Analysis/ctu-on-demand-parsing.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-on-demand-parsing.cpp
@@ -0,0 +1,102 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/ctudir
+// RUN: cp %s %t/ctu-on-demand-parsing.cpp
+// RUN: cp %S/ctu-hdr.h %t/ctu-hdr.h
+// RUN: cp %S/Inputs/ctu-chain.cpp %t/ctudir/ctu-chain.cpp
+// RUN: cp %S/Inputs/ctu-other.cpp %t/ctudir/ctu-other.cpp
+// Path substitutions on Windows platform could contain backslashes. These are escaped in the json file.
+// RUN: echo '[{"directory":"%t/ctudir","command":"clang++ -c ctu-chain.cpp","file":"ctu-chain.cpp"},{"directory":"%t/ctudir","command":"clang++ -c ctu-other.cpp","file":"ctu-other.cpp"}]' | sed -e 's/\\//g' > %t/compile_commands.json
+// RUN: cd "%t/ctudir" && %clang_extdef_map ctu-chain.cpp ctu-other.cpp > externalDefMap.txt
+// RUN

[PATCH] D78902: [Driver] Add output file to properties of Command

2020-04-27 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rjmccall, rnk, yaxunl, plotfi, mstorsjo, dlj.
Herald added subscribers: kerbowa, luismarques, apazos, sameer.abuasal, pzheng, 
s.egerton, lenary, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, MaskRay, jrtc27, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb, aheejin, jgravelle-google, sbc100, nhaehnle, jvesely, 
dylanmckay, dschuff, emaste.
Herald added a reviewer: DavidTruby.
Herald added a project: clang.

Object of class `Command` contains various properties of a command to
execute, but output file was missed from them. This change adds this
property.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78902

Files:
  clang/include/clang/Driver/Job.h
  clang/lib/Driver/Job.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/Ananas.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CrossWindows.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/DragonFly.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/InterfaceStubs.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/Minix.cpp
  clang/lib/Driver/ToolChains/Myriad.cpp
  clang/lib/Driver/ToolChains/NaCl.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/XCore.cpp
  clang/unittests/Driver/ToolChainTest.cpp

Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -285,4 +285,34 @@
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+
+TEST(ToolChainTest, CommandOutput) {
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct TestDiagnosticConsumer : public DiagnosticConsumer {};
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, new TestDiagnosticConsumer);
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  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"}));
+  const JobList &Jobs = CC->getJobs();
+
+  auto &CmdCompile = Jobs.getJobs().front();
+  auto InFile = CmdCompile->getInputFilenames().front();
+  EXPECT_STREQ(InFile, "foo.cpp");
+  auto ObjFile = CmdCompile->getOutputFilenames().front();
+  EXPECT_TRUE(StringRef(ObjFile).endswith(".o"));
+
+  auto &CmdLink = Jobs.getJobs().back();
+  auto LinkInFile = CmdLink->getInputFilenames().front();
+  EXPECT_EQ(ObjFile, LinkInFile);
+  auto ExeFile = CmdLink->getOutputFilenames().front();
+  EXPECT_EQ("a.out", ExeFile);
+}
+
 } // end anonymous namespace.
Index: clang/lib/Driver/ToolChains/XCore.cpp
===
--- clang/lib/Driver/ToolChains/XCore.cpp
+++ clang/lib/Driver/ToolChains/XCore.cpp
@@ -52,7 +52,8 @@
 CmdArgs.push_back(II.getFilename());
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
-  C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+  C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs,
+ Output));
 }
 
 void tools::XCore::Linker::ConstructJob(Compilation &C, const JobAction &JA,
@@ -80,7 +81,8 @@
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
 
   const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
-  C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs));
+  C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs,
+ Output));
 }
 
 /// XCore tool chain
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -90,7 +90,8 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
+

[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2820
+  if (Right.is(tok::star) && Left.is(TT_TemplateCloser))
+return false;
   if (Right.isOneOf(tok::star, tok::amp, tok::ampamp)) {

I'm not happy about this it feels way too general.


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

https://reviews.llvm.org/D78879



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


[PATCH] D78903: [Driver] Add option -fproc-stat-report

2020-04-27 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rsmith, rjmccall, aganea, hans.
Herald added a project: clang.
sepavloff added parent revisions: D78897: [Support] raw_fd_ostream can lock 
file before write, D78899: [Driver] Add callback to Command execution, D78901: 
[Support] Get process statistics in ExecuteAndWait and Wait, D78902: [Driver] 
Add output file to properties of Command.

The new option `-fproc-stat-info=` can be used to generate report
about used memory and execution tile of each stage of compilation.
Documentation for this option can be found in `UserManual.rst`. The
option can be used in parallel builds.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78903

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Job.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/Job.cpp
  clang/test/Driver/report-stat.c

Index: clang/test/Driver/report-stat.c
===
--- /dev/null
+++ clang/test/Driver/report-stat.c
@@ -0,0 +1,6 @@
+// RUN: %clang -c -fproc-stat-report=- %s | FileCheck %s
+// CHECK: clang{{.*}} output={{.*}}.o, total={{[0-9]+}}, user={{[0-9]+}}, mem={{[0-9]+}}
+
+// RUN: %clang -c -fproc-stat-report=%t %s
+// RUN: cat %t | FileCheck --check-prefix=CSV %s
+// CSV: clang{{.*}},"{{.*}}.o",{{[0-9]+}},{{[0-9]+}},{{[0-9]+}}
Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -370,8 +370,8 @@
 
   auto Args = llvm::toStringRefArray(Argv.data());
   return llvm::sys::ExecuteAndWait(Executable, Args, Env, Redirects,
-   /*secondsToWait*/ 0,
-   /*memoryLimit*/ 0, ErrMsg, ExecutionFailed);
+  /*secondsToWait*/ 0, /*memoryLimit*/ 0, ErrMsg, ExecutionFailed,
+  &ProcStat);
 }
 
 CC1Command::CC1Command(const Action &Source, const Tool &Creator,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -3757,11 +3757,54 @@
/*TargetDeviceOffloadKind*/ Action::OFK_None);
   }
 
-  // If we have more than one job, then disable integrated-cc1 for now.
-  if (C.getJobs().size() > 1)
+  StringRef StatReportFile;
+  if (const Arg *A = C.getArgs().getLastArg(options::OPT_fproc_stat_report_EQ))
+StatReportFile = A->getValue();
+
+  // If we have more than one job, then disable integrated-cc1 for now. Do this
+  // also when we need to report process execution statistics.
+  if (C.getJobs().size() > 1 || !StatReportFile.empty())
 for (auto &J : C.getJobs())
   J.InProcess = false;
 
+  if (!StatReportFile.empty())
+C.setPostCallback([=](const Command &Cmd, int Res) {
+  const llvm::sys::ProcessStatistics &ProcStat = Cmd.getProcessStatistics();
+  if (ProcStat.isSet()) {
+if (StatReportFile.equals("-")) {
+  // Human readable output.
+  llvm::outs() << llvm::sys::path::filename(Cmd.getExecutable()) << ": "
+   << "output=";
+  if (Cmd.getOutputFilenames().empty())
+llvm::outs() << "\"\"";
+  else
+llvm::outs() << Cmd.getOutputFilenames().front();
+  llvm::outs()
+<< ", total=" << Cmd.getProcessStatistics().TotalTime.count()
+<< ", user=" << Cmd.getProcessStatistics().UserTime.count()
+<< ", mem=" << Cmd.getProcessStatistics().PeakMemory << "\n";
+} else {
+  // CSV format.
+  std::string Buffer;
+  llvm::raw_string_ostream Out(Buffer);
+  Out << llvm::sys::path::filename(Cmd.getExecutable()) << ',';
+  if (Cmd.getOutputFilenames().empty())
+Out << "\"\"";
+  else
+Command::printArg(Out, Cmd.getOutputFilenames().front(), true);
+  Out << ','
+  << Cmd.getProcessStatistics().TotalTime.count() << ','
+  << Cmd.getProcessStatistics().UserTime.count() << ','
+  << Cmd.getProcessStatistics().PeakMemory << '\n';
+  Out.flush();
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(StatReportFile, EC, llvm::sys::fs::OF_Append);
+  if (!EC)
+OS << Buffer;
+}
+  }
+});
+
   // If the user passed -Qunused-arguments or there were errors, don't warn
   // about any unused arguments.
   if (Diags.hasErrorOccurred() ||
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1909,6 +1909,8 @@
 def ftime_trace_granularity_EQ : Joined<["-"], "ftime-trace-granularity=">, Group,
   HelpText<"Minimum time granularity (in microseconds) traced by time profiler">,
   Flags<[CC1Option, CoreOption]>;
+def fproc_stat_r

[clang] 0d69e41 - Explicitly tell Clang to output to stdout in a test that runs FileCheck

2020-04-27 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-04-27T10:13:28+02:00
New Revision: 0d69e412c4f35dfa891a6b83d94f3f76192868a7

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

LOG: Explicitly tell Clang to output to stdout in a test that runs FileCheck

Added: 


Modified: 
clang/test/Sema/builtin-amdgcn-fence-failure.cpp

Removed: 




diff  --git a/clang/test/Sema/builtin-amdgcn-fence-failure.cpp 
b/clang/test/Sema/builtin-amdgcn-fence-failure.cpp
index c0de548cc32a..651700cbb63a 100644
--- a/clang/test/Sema/builtin-amdgcn-fence-failure.cpp
+++ b/clang/test/Sema/builtin-amdgcn-fence-failure.cpp
@@ -1,6 +1,5 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: not %clang_cc1 %s -S \
-// RUN:   -triple=amdgcn-amd-amdhsa 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 %s -o - -S -triple=amdgcn-amd-amdhsa 2>&1 | FileCheck %s
 
 void test_amdgcn_fence_failure() {
 



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


[clang] 1a0d466 - [AST] Preserve the invalid initializer for auto VarDecl.

2020-04-27 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-04-27T10:25:36+02:00
New Revision: 1a0d466081318adfc356917fccc5116f9031ef7e

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

LOG: [AST] Preserve the invalid initializer for auto VarDecl.

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

Reviewers: sammccall

Tags: #clang

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/AST/ast-dump-expr-errors.cpp
clang/test/AST/ast-dump-recovery.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 99644ff4f46f..5f11038d589e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11847,10 +11847,18 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
 // be deduced based on the chosen correction if the original init contains 
a
 // TypoExpr.
 ExprResult Res = CorrectDelayedTyposInExpr(Init, VDecl);
-if (!Res.isUsable() || Res.get()->containsErrors()) {
+if (!Res.isUsable()) {
+  // There are unresolved typos in Init, just drop them.
+  // FIXME: improve the recovery strategy to preserve the Init.
   RealDecl->setInvalidDecl();
   return;
 }
+if (Res.get()->containsErrors()) {
+  // Invalidate the decl as we don't know the type for recovery-expr yet.
+  RealDecl->setInvalidDecl();
+  VDecl->setInit(Res.get());
+  return;
+}
 Init = Res.get();
 
 if (DeduceVariableDeclarationType(VDecl, DirectInit, Init))

diff  --git a/clang/test/AST/ast-dump-expr-errors.cpp 
b/clang/test/AST/ast-dump-expr-errors.cpp
index 9334b73a4354..5661a41465eb 100644
--- a/clang/test/AST/ast-dump-expr-errors.cpp
+++ b/clang/test/AST/ast-dump-expr-errors.cpp
@@ -40,10 +40,6 @@ int c = &(bar() + baz()) * 10;
 // CHECK-NEXT:| `-IntegerLiteral {{.*}} 1
 int d = static_cast(bar() + 1);
 
-// FIXME: store initializer even when 'auto' could not be deduced.
-// Expressions with errors currently do not keep initializers around.
-// CHECK: -VarDecl {{.*}} invalid e 'auto'
-auto e = bar();
 
 // Error type should result in an invalid decl.
 // CHECK: -VarDecl {{.*}} invalid f 'decltype((bar))'

diff  --git a/clang/test/AST/ast-dump-recovery.cpp 
b/clang/test/AST/ast-dump-recovery.cpp
index 86511181f0a6..f0325b32dc14 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -156,3 +156,22 @@ void InvalidInitalizer(int x) {
   // CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid'
   Bar b6 = Bar{invalid()};
 }
+void InitializerForAuto() {
+  // CHECK: `-VarDecl {{.*}} invalid a 'auto'
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   `-UnresolvedLookupExpr {{.*}} 'invalid'
+  auto a = invalid();
+
+  // CHECK: `-VarDecl {{.*}} invalid b 'auto'
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-UnresolvedLookupExpr {{.*}} 'some_func'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid'
+  auto b = some_func(invalid());
+
+  decltype(ned);
+  // very bad initailizer: there is an unresolved typo expr internally, we just
+  // drop it.
+  // CHECK: `-VarDecl {{.*}} invalid unresolved_typo 'auto'
+  auto unresolved_typo = gned.*[] {};
+}



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 260238.
gamesh411 added a comment.

Fix index error enum declaration


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665

Files:
  clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/CrossTU/CMakeLists.txt
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Analysis/Inputs/ctu-other.c
  clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/ctu-different-triples.cpp
  clang/test/Analysis/ctu-main.c
  clang/test/Analysis/ctu-main.cpp
  clang/test/Analysis/ctu-on-demand-parsing-ambigous-compilation-database.c
  clang/test/Analysis/ctu-on-demand-parsing.c
  clang/test/Analysis/ctu-on-demand-parsing.cpp
  clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
  clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -7,10 +7,11 @@
 //===--===//
 
 #include "clang/CrossTU/CrossTranslationUnit.h"
-#include "clang/Frontend/CompilerInstance.h"
 #include "clang/AST/ASTConsumer.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -162,7 +163,7 @@
   IndexFile.os().flush();
   EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
   llvm::Expected> IndexOrErr =
-  parseCrossTUIndex(IndexFileName, "");
+  parseCrossTUIndex(IndexFileName);
   EXPECT_TRUE((bool)IndexOrErr);
   llvm::StringMap ParsedIndex = IndexOrErr.get();
   for (const auto &E : Index) {
@@ -173,25 +174,5 @@
 EXPECT_TRUE(Index.count(E.getKey()));
 }
 
-TEST(CrossTranslationUnit, CTUDirIsHandledCorrectly) {
-  llvm::StringMap Index;
-  Index["a"] = "/b/c/d";
-  std::string IndexText = createCrossTUIndexString(Index);
-
-  int IndexFD;
-  llvm::SmallString<256> IndexFileName;
-  ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("index", "txt", IndexFD,
-  IndexFileName));
-  llvm::ToolOutputFile IndexFile(IndexFileName, IndexFD);
-  IndexFile.os() << IndexText;
-  IndexFile.os().flush();
-  EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
-  llvm::Expected> IndexOrErr =
-  parseCrossTUIndex(IndexFileName, "/ctudir");
-  EXPECT_TRUE((bool)IndexOrErr);
-  llvm::StringMap ParsedIndex = IndexOrErr.get();
-  EXPECT_EQ(ParsedIndex["a"], "/ctudir/b/c/d");
-}
-
 } // end namespace cross_tu
 } // end namespace clang
Index: clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
===
--- clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
+++ clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
@@ -5,7 +5,7 @@
 // RUN: mkdir -p %t/ctudir
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
 // RUN:   -emit-pch -o %t/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
-// RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.txt %t/ctudir/externalDefMap.txt
+// RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
 // RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
Index: clang/test/Analysis/ctu-on-demand-parsing.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-on-demand-parsing.cpp
@@ -0,0 +1,102 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/ctudir
+// RUN: cp %s %t/ctu-on-demand-parsing.cpp
+// RUN: cp %S/ctu-hdr.h %t/ctu-hdr.h
+// RUN: cp %S/Inputs/ctu-chain.cpp %t/ctudir/ctu-chain.cpp
+// RUN: cp %S/Inputs/ctu-other.cpp %t/ctudir/ctu-other.cpp
+// Path substitutions on Windows platform could contain backslashes. These are escaped in the json file.
+// RUN: echo '[{"directory":"%t/ctudir","command":"clang++ -c ctu-chain.cpp","file":"ctu-chain.cpp"},{"directory":"%t/ctudir","command":"clang++ -c ctu-other.cpp","file":"ctu-other.cpp"}]' | sed -e 's/\\//g' > %t/compile_commands.json
+// RUN: cd "%t/ctudir" && %clang_extdef_map ctu-chain.cpp ctu-other.cpp > externalDefMap.txt
+// RUN: cd "%t" && %clang_analyze_cc1

[PATCH] D78365: [AST] Preserve the invalid initializer for auto VarDecl.

2020-04-27 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1a0d46608131: [AST] Preserve the invalid initializer for 
auto VarDecl. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D78365?vs=258309&id=260241#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78365

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-expr-errors.cpp
  clang/test/AST/ast-dump-recovery.cpp


Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -156,3 +156,22 @@
   // CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid'
   Bar b6 = Bar{invalid()};
 }
+void InitializerForAuto() {
+  // CHECK: `-VarDecl {{.*}} invalid a 'auto'
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   `-UnresolvedLookupExpr {{.*}} 'invalid'
+  auto a = invalid();
+
+  // CHECK: `-VarDecl {{.*}} invalid b 'auto'
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-UnresolvedLookupExpr {{.*}} 'some_func'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid'
+  auto b = some_func(invalid());
+
+  decltype(ned);
+  // very bad initailizer: there is an unresolved typo expr internally, we just
+  // drop it.
+  // CHECK: `-VarDecl {{.*}} invalid unresolved_typo 'auto'
+  auto unresolved_typo = gned.*[] {};
+}
Index: clang/test/AST/ast-dump-expr-errors.cpp
===
--- clang/test/AST/ast-dump-expr-errors.cpp
+++ clang/test/AST/ast-dump-expr-errors.cpp
@@ -40,10 +40,6 @@
 // CHECK-NEXT:| `-IntegerLiteral {{.*}} 1
 int d = static_cast(bar() + 1);
 
-// FIXME: store initializer even when 'auto' could not be deduced.
-// Expressions with errors currently do not keep initializers around.
-// CHECK: -VarDecl {{.*}} invalid e 'auto'
-auto e = bar();
 
 // Error type should result in an invalid decl.
 // CHECK: -VarDecl {{.*}} invalid f 'decltype((bar))'
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11847,10 +11847,18 @@
 // be deduced based on the chosen correction if the original init contains 
a
 // TypoExpr.
 ExprResult Res = CorrectDelayedTyposInExpr(Init, VDecl);
-if (!Res.isUsable() || Res.get()->containsErrors()) {
+if (!Res.isUsable()) {
+  // There are unresolved typos in Init, just drop them.
+  // FIXME: improve the recovery strategy to preserve the Init.
   RealDecl->setInvalidDecl();
   return;
 }
+if (Res.get()->containsErrors()) {
+  // Invalidate the decl as we don't know the type for recovery-expr yet.
+  RealDecl->setInvalidDecl();
+  VDecl->setInit(Res.get());
+  return;
+}
 Init = Res.get();
 
 if (DeduceVariableDeclarationType(VDecl, DirectInit, Init))


Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -156,3 +156,22 @@
   // CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid'
   Bar b6 = Bar{invalid()};
 }
+void InitializerForAuto() {
+  // CHECK: `-VarDecl {{.*}} invalid a 'auto'
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   `-UnresolvedLookupExpr {{.*}} 'invalid'
+  auto a = invalid();
+
+  // CHECK: `-VarDecl {{.*}} invalid b 'auto'
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-UnresolvedLookupExpr {{.*}} 'some_func'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid'
+  auto b = some_func(invalid());
+
+  decltype(ned);
+  // very bad initailizer: there is an unresolved typo expr internally, we just
+  // drop it.
+  // CHECK: `-VarDecl {{.*}} invalid unresolved_typo 'auto'
+  auto unresolved_typo = gned.*[] {};
+}
Index: clang/test/AST/ast-dump-expr-errors.cpp
===
--- clang/test/AST/ast-dump-expr-errors.cpp
+++ clang/test/AST/ast-dump-expr-errors.cpp
@@ -40,10 +40,6 @@
 // CHECK-NEXT:| `-IntegerLiteral {{.*}} 1
 int d = static_cast(bar() + 1);
 
-// FIXME: store initializer even when 'auto' could not be deduced.
-// Expressions with errors currently do not keep initializers around.
-// CHECK: -VarDecl {{.*}} invalid e 'auto'
-auto e = bar();
 
 // Error type should result in an invalid decl.
 // CHECK: -VarDecl {{.*}} invalid f 'decltype((bar))'
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.c

[PATCH] D78457: [analyzer][Z3-refutation] Fix a refutation BugReporterVisitor bug

2020-04-27 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

LGTM! Thanks for addressing the comments!


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

https://reviews.llvm.org/D78457



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


[PATCH] D78904: [clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.

2020-04-27 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas added a comment.

I run the check both on LibreOffice and LLVM codebase but did not find any 
catch. I expect that it's not a frequent use case.
I added this extension only to fully cover the CERT rule. If this patch is 
accepted I can add a cert alias for this check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78904



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


[PATCH] D78904: [clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.

2020-04-27 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
ztamas added a reviewer: aaron.ballman.
ztamas added a comment.
ztamas updated this revision to Diff 260243.

I run the check both on LibreOffice and LLVM codebase but did not find any 
catch. I expect that it's not a frequent use case.
I added this extension only to fully cover the CERT rule. If this patch is 
accepted I can add a cert alias for this check.


ztamas added a comment.

Fix typo


To cover STR34-C rule's second use case, where ``signed char`` is
used for array subscript after an integer conversion. In the case
of non-ASCII character a ``signed char`` will result in a value
in excess of UCHAR_MAX because of integer promotion.

There is another clang-tidy check which catches these cases.
cppcoreguidelines-pro-bounds-constant-array-index catches any
indexing which is not integer constant. I think this check is
very strict about the index (e.g. constant), so it's still useful
to cover the ``signed char`` use case in this check, so we
can provide a way to catch the SEI cert rule's use cases on a
codebase, where this CPP guideline is not used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78904

Files:
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
@@ -3,6 +3,16 @@
 ///
 /// Test cases correctly caught by the check.
 
+typedef __SIZE_TYPE__ size_t;
+
+namespace std {
+template 
+struct array {
+  T &operator[](size_t n);
+  T &at(size_t n);
+};
+} // namespace std
+
 int SimpleVarDeclaration() {
   signed char CCharacter = -5;
   int NCharacter = CCharacter;
@@ -90,6 +100,16 @@
   return 0;
 }
 
+int SignedCharCArraySubscript(signed char SCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(SCharacter)]; // CHECK-MESSAGES: [[@LINE]]:42: warning: 'signed char' to 'unsigned int' conversion in array subscript; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse]
+}
+
+int SignedCharSTDArraySubscript(std::array Array, signed char SCharacter) {
+  return Array[static_cast(SCharacter)]; // CHECK-MESSAGES: [[@LINE]]:42: warning: 'signed char' to 'unsigned int' conversion in array subscript; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse]
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -207,3 +227,23 @@
 return 1;
   return 0;
 }
+
+int UnsignedCharCArraySubscript(unsigned char USCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(USCharacter)];
+}
+
+int CastedCArraySubscript(signed char SCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(SCharacter)];
+}
+
+int UnsignedCharSTDArraySubscript(std::array Array, unsigned char USCharacter) {
+  return Array[static_cast(USCharacter)];
+}
+
+int CastedSTDArraySubscript(std::array Array, signed char SCharacter) {
+  return Array[static_cast(SCharacter)];
+}
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
@@ -31,11 +31,10 @@
 by default and so it is caught by this check or not. To change the default behavior
 you can use ``-funsigned-char`` and ``-fsigned-char`` compilation options.
 
-Currently, this check is limited to assignments and variable declarations,
-where a ``signed char`` is assigned to an integer variable and to
-equality/inequality comparisons between ``signed char`` and ``unsigned char``.
-There are other use cases where the unexpected value ranges might lead to
-similar bogus behavior.
+Currently, this check warns in the following cases:
+- ``signed char`` is assigned to an integer variable
+- ``signed char`` and ``unsigned char`` are compared with equality/unequality operator
+- ``signed char`` is converted to integer before array subscript
 
 See also:
 `STR34-C. Cast characters to unsigned char before converting to larger integer sizes
Index: clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
@@ -102,11 +102,31 @@
   .bind("co

[PATCH] D78904: [clang-tidy] extend bugprone-signed-char-misuse check with array subscript case.

2020-04-27 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas updated this revision to Diff 260243.
ztamas added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78904

Files:
  clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
  clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signed-char-misuse.cpp
@@ -3,6 +3,16 @@
 ///
 /// Test cases correctly caught by the check.
 
+typedef __SIZE_TYPE__ size_t;
+
+namespace std {
+template 
+struct array {
+  T &operator[](size_t n);
+  T &at(size_t n);
+};
+} // namespace std
+
 int SimpleVarDeclaration() {
   signed char CCharacter = -5;
   int NCharacter = CCharacter;
@@ -90,6 +100,16 @@
   return 0;
 }
 
+int SignedCharCArraySubscript(signed char SCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(SCharacter)]; // CHECK-MESSAGES: [[@LINE]]:42: warning: 'signed char' to 'unsigned int' conversion in array subscript; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse]
+}
+
+int SignedCharSTDArraySubscript(std::array Array, signed char SCharacter) {
+  return Array[static_cast(SCharacter)]; // CHECK-MESSAGES: [[@LINE]]:42: warning: 'signed char' to 'unsigned int' conversion in array subscript; consider casting to 'unsigned char' first. [bugprone-signed-char-misuse]
+}
+
 ///
 /// Test cases correctly ignored by the check.
 
@@ -207,3 +227,23 @@
 return 1;
   return 0;
 }
+
+int UnsignedCharCArraySubscript(unsigned char USCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(USCharacter)];
+}
+
+int CastedCArraySubscript(signed char SCharacter) {
+  int Array[3] = {1, 2, 3};
+
+  return Array[static_cast(SCharacter)];
+}
+
+int UnsignedCharSTDArraySubscript(std::array Array, unsigned char USCharacter) {
+  return Array[static_cast(USCharacter)];
+}
+
+int CastedSTDArraySubscript(std::array Array, signed char SCharacter) {
+  return Array[static_cast(SCharacter)];
+}
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-signed-char-misuse.rst
@@ -31,11 +31,10 @@
 by default and so it is caught by this check or not. To change the default behavior
 you can use ``-funsigned-char`` and ``-fsigned-char`` compilation options.
 
-Currently, this check is limited to assignments and variable declarations,
-where a ``signed char`` is assigned to an integer variable and to
-equality/inequality comparisons between ``signed char`` and ``unsigned char``.
-There are other use cases where the unexpected value ranges might lead to
-similar bogus behavior.
+Currently, this check warns in the following cases:
+- ``signed char`` is assigned to an integer variable
+- ``signed char`` and ``unsigned char`` are compared with equality/unequality operator
+- ``signed char`` is converted to integer before array subscript
 
 See also:
 `STR34-C. Cast characters to unsigned char before converting to larger integer sizes
Index: clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp
@@ -102,11 +102,31 @@
   .bind("comparison");
 
   Finder->addMatcher(CompareOperator, this);
+
+  // Catch array subscripts with singed char -> integer conversion.
+  // Matcher for C arrays.
+  const auto CArraySubscript =
+  arraySubscriptExpr(hasIndex(SignedCharCastExpr)).bind("arraySubscript");
+
+  Finder->addMatcher(CArraySubscript, this);
+
+  // Matcher for std arrays.
+  const auto STDArraySubscript =
+  cxxOperatorCallExpr(
+  hasOverloadedOperatorName("[]"),
+  hasArgument(0, hasType(cxxRecordDecl(hasName("::std::array",
+  hasArgument(1, SignedCharCastExpr))
+  .bind("arraySubscript");
+
+  Finder->addMatcher(STDArraySubscript, this);
 }
 
 void SignedCharMisuseCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *SignedCastExpression =
   Result.Nodes.getNodeAs("signedCastExpression");
+  const auto *IntegerType = Result.Nodes.getNodeAs("integerType");
+  assert(SignedCastExpression);
+  assert(IntegerType);
 
   // Ignore the match if we know that the signed char's value is n

[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@sylvestre.ledru

I'm taking a quick look at formatting the original bug in gecko and whilst the 
last windows snapshot (Feb 2020) shows the bug

  $ clang-format --version
  clang-format version 11.0.0
  
  nsTArray.h:939:29: warning: code should be clang-formatted 
[-Wclang-format-violations]
operator const nsTArray&() {
  ^
  nsTArray.h:946:35: warning: code should be clang-formatted 
[-Wclang-format-violations]
operator const FallibleTArray&() {
^
  nsTArray.h:1147:59: warning: code should be clang-formatted 
[-Wclang-format-violations]
[[nodiscard]] operator const nsTArray_Impl&() const& {
^
  nsTArray.h:1151:43: warning: code should be clang-formatted 
[-Wclang-format-violations]
[[nodiscard]] operator const nsTArray&() const& {
^
  nsTArray.h:1154:49: warning: code should be clang-formatted 
[-Wclang-format-violations]
[[nodiscard]] operator const FallibleTArray&() const& {

The current trunk does not

  $ clang-format --version
  clang-format version 11.0.0 (https://github.com/llvm/llvm-project 
1956a8a7cb79e94dbe073e36eba2d6b003f91046)
  
  clang-format -n nsTArray.h

Is Mozilla toolchain using LLVM from the v10 branch?

I think this is fixed by D76850: clang-format: Fix pointer alignment for 
overloaded operators (PR45107) 


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

https://reviews.llvm.org/D78879



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 closed this revision.
gamesh411 added a comment.

I am landing this. Thanks for the reviews @martong @balazske @xazax.hun 
@whisperity !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[clang] 811c0c9 - [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Endre Fülöp via cfe-commits

Author: Endre Fülöp
Date: 2020-04-27T11:20:35+02:00
New Revision: 811c0c9eb462d1fef6ab6908aab7881e5c4f5fbf

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

LOG: [analyzer] On-demand parsing capability for CTU

Summary:
Add an option to enable on-demand parsing of needed ASTs during CTU analysis.
Two options are introduced. CTUOnDemandParsing enables the feature, and
CTUOnDemandParsingDatabase specifies the path to a compilation database, which
has all the necessary information to generate the ASTs.

Reviewers: martong, balazske, Szelethus, xazax.hun

Subscribers: ormris, mgorny, whisperity, xazax.hun, baloghadamsoftware, szepet, 
rnkovacs, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, 
steakhal, cfe-commits

Tags: #clang

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

Added: 
clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.ast-dump.txt
clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt
clang/test/Analysis/ctu-on-demand-parsing-ambigous-compilation-database.c
clang/test/Analysis/ctu-on-demand-parsing.c
clang/test/Analysis/ctu-on-demand-parsing.cpp

Modified: 
clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
clang/lib/CrossTU/CMakeLists.txt
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Analysis/Inputs/ctu-other.c
clang/test/Analysis/analyzer-config.c
clang/test/Analysis/ctu-different-triples.cpp
clang/test/Analysis/ctu-main.c
clang/test/Analysis/ctu-main.cpp
clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Removed: 
clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt



diff  --git a/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst 
b/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
index 86f972b63e31..1a7ac1c71f21 100644
--- a/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
+++ b/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
@@ -3,14 +3,33 @@ Cross Translation Unit (CTU) Analysis
 =
 
 Normally, static analysis works in the boundary of one translation unit (TU).
-However, with additional steps and configuration we can enable the analysis to 
inline the definition of a function from another TU.
+However, with additional steps and configuration we can enable the analysis to 
inline the definition of a function from
+another TU.
 
 .. contents::
:local:
 
-Manual CTU Analysis

+Overview
+
+CTU analysis can be used in a variety of ways. The importing of external TU 
definitions can work with pre-dumped PCH
+files or generating the necessary AST structure on-demand, during the analysis 
of the main TU. Driving the static
+analysis can also be implemented in multiple ways. The most direct way is to 
specify the necessary commandline options
+of the Clang frontend manually (and generate the prerequisite dependencies of 
the specific import method by hand). This
+process can be automated by other tools, like `CodeChecker 
`_ and scan-build-py
+(preference for the former).
+
+PCH-based analysis
+__
+The analysis needs the PCH dumps of all the translations units used in the 
project.
+These can be generated by the Clang Frontend itself, and must be arranged in a 
specific way in the filesystem.
+The index, which maps symbols' USR names to PCH dumps containing them must 
also be generated by the
+`clang-extdef-mapping`. This tool uses a :doc:`compilation database 
<../../JSONCompilationDatabase>` to
+determine the compilation flags used.
+The analysis invocation must be provided with the directory which contains the 
dumps and the mapping files.
+
 
+Manual CTU Analysis
+###
 Let's consider these source files in our minimal example:
 
 .. code-block:: cpp
@@ -47,7 +66,8 @@ And a compilation database:
   ]
 
 We'd like to analyze `main.cpp` and discover the division by zero bug.
-In order to be able to inline the definition of `foo` from `foo.cpp` first we 
have to generate the `AST` (or `PCH`) file of `foo.cpp`:
+In order to be able to inline the definition of `foo` from `foo.cpp` first we 
have to generate the `AST` (or `PCH`) file
+of `foo.cpp`:
 
 .. code-block:: bash
 
@@ -58,7 +78,8 @@ In order to be able to inline the definition of `foo` from 
`foo.cpp` first we ha
   compile_commands.json  foo.cpp.ast  foo.cpp  main.cpp
   $
 
-The next step is to create a CTU index file which holds the `USR` name and 
locati

[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-27 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

In D78879#2004724 , @MyDeveloperDay 
wrote:

> @sylvestre.ledru
>
> I'm taking a quick look at formatting the original bug in gecko and whilst 
> the last windows snapshot (Feb 2020) shows the bug
>
>   $ clang-format --version
>   clang-format version 11.0.0
>  
>   nsTArray.h:939:29: warning: code should be clang-formatted 
> [-Wclang-format-violations]
> operator const nsTArray&() {
>   ^
>   nsTArray.h:946:35: warning: code should be clang-formatted 
> [-Wclang-format-violations]
> operator const FallibleTArray&() {
> ^
>   nsTArray.h:1147:59: warning: code should be clang-formatted 
> [-Wclang-format-violations]
> [[nodiscard]] operator const nsTArray_Impl&() const& {
> ^
>   nsTArray.h:1151:43: warning: code should be clang-formatted 
> [-Wclang-format-violations]
> [[nodiscard]] operator const nsTArray&() const& {
> ^
>   nsTArray.h:1154:49: warning: code should be clang-formatted 
> [-Wclang-format-violations]
> [[nodiscard]] operator const FallibleTArray&() const& {
>
>
> The current trunk does not
>
>   $ clang-format --version
>   clang-format version 11.0.0 (https://github.com/llvm/llvm-project 
> 1956a8a7cb79e94dbe073e36eba2d6b003f91046)
>  
>   clang-format -n nsTArray.h
>
>
> Is Mozilla toolchain using LLVM from the v10 branch?
>
> I think this is fixed by D76850: clang-format: Fix pointer alignment for 
> overloaded operators (PR45107) 


Yes, we are using the clang tooling 10.


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

https://reviews.llvm.org/D78879



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


[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a subscriber: hans.
MyDeveloperDay added a comment.

So for the Mozilla case mentioned in the bug report we either need to ask @hans 
 if D76850: clang-format: Fix pointer alignment for overloaded operators 
(PR45107)  can go into the v10 branch, or 
perhaps they can apply that path rather than the revert patch

However I believe for @sylvestre.ledru bug ( is somewhat different and needs 
additional changes)


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

https://reviews.llvm.org/D78879



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


[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-27 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

I've cherry-picked D76850  to 10.x and see if 
this fixes the issue.


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

https://reviews.llvm.org/D78879



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


[PATCH] D78457: [analyzer][Z3-refutation] Fix a refutation BugReporterVisitor bug

2020-04-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I'm planning to measure how impactful this patch is using the CodeChecker.
Stay tuned if you are interested!


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

https://reviews.llvm.org/D78457



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


[PATCH] D62368: Add support for Hygon Dhyana processor

2020-04-27 Thread Jinke Fan via Phabricator via cfe-commits
fanjinke marked an inline comment as done.
fanjinke added inline comments.



Comment at: compiler-rt/lib/scudo/scudo_utils.cpp:85
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;

craig.topper wrote:
> What's the rationale for the vendor check here anyway? Why isn't the bit in 
> ecx sufficient?
Using the cpuid instruction to get the vendor id will return the ASCII code of 
the vendor id, which is stored in the ebx,ecx,edx registers.
The ASCII code in the Hygon CPU is "HygonGenuine",  the ecx = "eniu".
For better differentiation from other cpus in the future,  by following 
AMD/Intel way, we use full ASCII code to identify Hygon CPU.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D78909: [clang-format] NFC clang-format the clang-format sources

2020-04-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: mitchell-stellar, sylvestre.ledru, 
Abpostelnicu, Wawha, jbcoe.
MyDeveloperDay added projects: clang, clang-format.
Herald added a subscriber: cfe-commits.

In recent patches the clang-format code has become un-formatted, correct this 
before making additional changes


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78909

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1726,7 +1726,7 @@
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
-  
+
   // FIXME: Once we have an expression parser in the UnwrappedLineParser,
   // replace this by using parseAssigmentExpression() inside.
   do {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -395,7 +395,7 @@
 
 if (!AttrTok)
   return false;
-
+
 // Allow an attribute to be the only content of a file.
 AttrTok = AttrTok->Next;
 if (!AttrTok)
@@ -2837,9 +2837,10 @@
 //   operator std::Foo*()
 //   operator C::D*()
 // dependent on PointerAlignment style.
-if (Previous && (Previous->endsSequence(tok::kw_operator) ||
-   Previous->endsSequence(tok::kw_const, tok::kw_operator) ||
-   Previous->endsSequence(tok::kw_volatile, tok::kw_operator)))
+if (Previous &&
+(Previous->endsSequence(tok::kw_operator) ||
+ Previous->endsSequence(tok::kw_const, tok::kw_operator) ||
+ Previous->endsSequence(tok::kw_volatile, tok::kw_operator)))
   return (Style.PointerAlignment != FormatStyle::PAS_Left);
   }
   const auto SpaceRequiredForArrayInitializerLSquare =
@@ -3325,22 +3326,20 @@
   if (Tok.Children.size() != 1)
 return false;
   FormatToken *curElt = Tok.Children[0]->First;
-while (curElt) {
-  if (curElt->MustBreakBefore)
-return false;
-  curElt = curElt->Next;
-}
+  while (curElt) {
+if (curElt->MustBreakBefore)
+  return false;
+curElt = curElt->Next;
+  }
   return true;
 }
-static bool
-isAllmanLambdaBrace(const FormatToken &Tok) {
+static bool isAllmanLambdaBrace(const FormatToken &Tok) {
   return (Tok.is(tok::l_brace) && Tok.BlockKind == BK_Block &&
-  !Tok.isOneOf(TT_ObjCBlockLBrace, TT_DictLiteral));
+  !Tok.isOneOf(TT_ObjCBlockLBrace, TT_DictLiteral));
 }
 
-static bool
-isAllmanBraceIncludedBreakableLambda(const FormatToken &Tok,
-FormatStyle::ShortLambdaStyle ShortLambdaOption) {
+static bool isAllmanBraceIncludedBreakableLambda(
+const FormatToken &Tok, FormatStyle::ShortLambdaStyle ShortLambdaOption) {
   if (!isAllmanLambdaBrace(Tok))
 return false;
 
@@ -3497,7 +3496,7 @@
   if (Style.BraceWrapping.BeforeLambdaBody &&
   (isAllmanBraceIncludedBreakableLambda(Left, ShortLambdaOption) ||
isAllmanBraceIncludedBreakableLambda(Right, ShortLambdaOption))) {
-  return true;
+return true;
   }
 
   if (isAllmanBrace(Left) || isAllmanBrace(Right))
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1466,10 +1466,11 @@
   ParenState(&Current, NewIndent, LastSpace, AvoidBinPacking, 
NoLineBreak));
   State.Stack.back().NestedBlockIndent = NestedBlockIndent;
   State.Stack.back().BreakBeforeParameter = BreakBeforeParameter;
-  State.Stack.back().HasMultipleNestedBlocks = (Current.BlockParameterCount > 
1);
+  State.Stack.back().HasMultipleNestedBlocks =
+  (Current.BlockParameterCount > 1);
 
-  if (Style.BraceWrapping.BeforeLambdaBody &&
-  Current.Next != nullptr && Current.Tok.is(tok::l_paren)) {
+  if (Style.BraceWrapping.BeforeLambdaBody && Current.Next != nullptr &&
+  Current.Tok.is(tok::l_paren)) {
 // Search for any parameter that is a lambda
 FormatToken const *next = Current.Next;
 while (next != nullptr) {


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1726,7 +1726,7 @@
 bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
   tok::TokenKind ClosingBraceKind) {
   bool HasError = false;
-  
+
   // FIXME: Once we have an expression parser in the UnwrappedLineParser,
   // replace this by using parseAssigmentExpression() inside.
   do

[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 260261.
MyDeveloperDay added a comment.

@sylvestre.ledru , @Abpostelnicu

I believe to fix your original request you need a combination of D76850: 
clang-format: Fix pointer alignment for overloaded operators (PR45107) 
 and this fix (this fix will handle the `* *` 
issue in `gecko-dev/ipc/mscom/Ptr.h`

I've run this  new binary over `gecko-dev/ipc/mscom` and `gecko-dev/xpcom/ds` 
and it shows now clang-format warnings

I hope this helps


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

https://reviews.llvm.org/D78879

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6279,7 +6279,17 @@
"void\n"
"A::operator[]() {}\n"
"void\n"
-   "A::operator!() {}\n",
+   "A::operator!() {}\n"
+   "void\n"
+   "A::operator**() {}\n"
+   "void\n"
+   "A::operator*() {}\n"
+   "void\n"
+   "A::operator**() {}\n"
+   "void\n"
+   "A::operator&() {}\n"
+   "void\n"
+   "A::operator void **() {}\n",
Style);
   verifyFormat("constexpr auto\n"
"operator()() const -> reference {}\n"
@@ -6296,6 +6306,10 @@
"constexpr auto\n"
"operator void *() const -> reference {}\n"
"constexpr auto\n"
+   "operator void **() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator void *() const -> reference {}\n"
+   "constexpr auto\n"
"operator void &() const -> reference {}\n"
"constexpr auto\n"
"operator void &&() const -> reference {}\n"
@@ -15628,9 +15642,20 @@
   Style.PointerAlignment = FormatStyle::PAS_Right;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void *();", Style);
+  verifyFormat("Foo::operator void **();", Style);
   verifyFormat("Foo::operator()(void *);", Style);
   verifyFormat("Foo::operator*(void *);", Style);
   verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator**();", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator *();", Style);
+  verifyFormat("Foo::operator *();", Style);
+  verifyFormat("Foo::operator **();", Style);
+  verifyFormat("Foo::operator **();", Style);
+  verifyFormat("Foo::operator &();", Style);
+  verifyFormat("Foo::operator &();", Style);
+  verifyFormat("Foo::operator &&();", Style);
+  verifyFormat("Foo::operator &&();", Style);
   verifyFormat("operator*(int (*)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&();", Style);
@@ -15641,21 +15666,39 @@
   verifyFormat("operator&(int (&)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator**();", Style);
   verifyFormat("Foo::operator void &&();", Style);
   verifyFormat("Foo::operator()(void &&);", Style);
   verifyFormat("Foo::operator&&(void &&);", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator const nsTArrayRight &()", Style);
+  verifyFormat("[[nodiscard]] operator const nsTArrayRight &()",
+   Style);
+  verifyFormat("operator void **()", Style);
+  verifyFormat("operator const FooRight &()", Style);
+  verifyFormat("operator const FooRight *()", Style);
+  verifyFormat("operator const FooRight **()", Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator**();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator void**();", Style);
   verifyFormat("Foo::operator/*comment*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator**();", Style);
+  verifyFormat("Foo::operator**();", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator*(int (*)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&();", Style);
@@ -15677,9 +15720,17 @@
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator&&(int(&

[clang] 3b9b3d5 - [Analyzer] Include typedef statements in CFG build.

2020-04-27 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2020-04-27T12:36:26+02:00
New Revision: 3b9b3d56efaa6f611458899d5a1cdc74f36d72a4

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

LOG: [Analyzer] Include typedef statements in CFG build.

Summary:
Array size expressions in typedef statements with a VLA
(variable-length array) are handled from now as in plain
(non-typedef) VLA declarations.
Type-aliases with VLA are handled too
(but main focus is on C code).

Reviewers: Szelethus, aaron.ballman, NoQ, xazax.hun

Reviewed By: aaron.ballman, xazax.hun

Subscribers: rnkovacs, NoQ, efriedma, xazax.hun, baloghadamsoftware, szepet, 
a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, gamesh411, Charusso, 
martong, ASDenysPetrov, cfe-commits

Tags: #clang

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

Added: 
clang/test/Analysis/cfg.c

Modified: 
clang/lib/Analysis/CFG.cpp
clang/test/Analysis/cfg.cpp

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 8091625703bc..bedc8455366f 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -2839,11 +2839,30 @@ CFGBlock *CFGBuilder::VisitDeclStmt(DeclStmt *DS) {
 /// DeclStmts and initializers in them.
 CFGBlock *CFGBuilder::VisitDeclSubExpr(DeclStmt *DS) {
   assert(DS->isSingleDecl() && "Can handle single declarations only.");
+
+  if (const auto *TND = dyn_cast(DS->getSingleDecl())) {
+// If we encounter a VLA, process its size expressions.
+const Type *T = TND->getUnderlyingType().getTypePtr();
+if (!T->isVariablyModifiedType())
+  return Block;
+
+autoCreateBlock();
+appendStmt(Block, DS);
+
+CFGBlock *LastBlock = Block;
+for (const VariableArrayType *VA = FindVA(T); VA != nullptr;
+ VA = FindVA(VA->getElementType().getTypePtr())) {
+  if (CFGBlock *NewBlock = addStmt(VA->getSizeExpr()))
+LastBlock = NewBlock;
+}
+return LastBlock;
+  }
+
   VarDecl *VD = dyn_cast(DS->getSingleDecl());
 
   if (!VD) {
-// Of everything that can be declared in a DeclStmt, only VarDecls impact
-// runtime semantics.
+// Of everything that can be declared in a DeclStmt, only VarDecls and the
+// exceptions above impact runtime semantics.
 return Block;
   }
 
@@ -2905,6 +2924,8 @@ CFGBlock *CFGBuilder::VisitDeclSubExpr(DeclStmt *DS) {
   }
 
   // If the type of VD is a VLA, then we must process its size expressions.
+  // FIXME: This does not find the VLA if it is embedded in other types,
+  // like here: `int (*p_vla)[x];`
   for (const VariableArrayType* VA = FindVA(VD->getType().getTypePtr());
VA != nullptr; VA = FindVA(VA->getElementType().getTypePtr())) {
 if (CFGBlock *newBlock = addStmt(VA->getSizeExpr()))
@@ -3997,6 +4018,11 @@ CFGBlock 
*CFGBuilder::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E,
   }
 
   // VLA types have expressions that must be evaluated.
+  // Evaluation is done only for `sizeof`.
+
+  if (E->getKind() != UETT_SizeOf)
+return Block;
+
   CFGBlock *lastBlock = Block;
 
   if (E->isArgumentType()) {

diff  --git a/clang/test/Analysis/cfg.c b/clang/test/Analysis/cfg.c
new file mode 100644
index ..3494dd6ac2a3
--- /dev/null
+++ b/clang/test/Analysis/cfg.c
@@ -0,0 +1,120 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple 
x86_64-apple-darwin12 -fheinous-gnu-extensions %s > %t 2>&1
+// RUN: FileCheck --input-file=%t -check-prefixes=CHECK,WARNINGS %s
+
+// This file is the C version of cfg.cpp.
+// Tests that are C-specific should go into this file.
+
+// CHECK-LABEL: void checkWrap(int i)
+// CHECK: ENTRY
+// CHECK-NEXT: Succs (1): B1
+// CHECK: [B1]
+// CHECK: Succs (21): B2 B3 B4 B5 B6 B7 B8 B9
+// CHECK: B10 B11 B12 B13 B14 B15 B16 B17 B18 B19
+// CHECK: B20 B21 B0
+// CHECK: [B0 (EXIT)]
+// CHECK-NEXT: Preds (21): B2 B3 B4 B5 B6 B7 B8 B9
+// CHECK-NEXT: B10 B11 B12 B13 B14 B15 B16 B17 B18 B19
+// CHECK-NEXT: B20 B21 B1
+void checkWrap(int i) {
+  switch(i) {
+case 0: break;
+case 1: break;
+case 2: break;
+case 3: break;
+case 4: break;
+case 5: break;
+case 6: break;
+case 7: break;
+case 8: break;
+case 9: break;
+case 10: break;
+case 11: break;
+case 12: break;
+case 13: break;
+case 14: break;
+case 15: break;
+case 16: break;
+case 17: break;
+case 18: break;
+case 19: break;
+  }
+}
+
+// CHECK-LABEL: void checkGCCAsmRValueOutput()
+// CHECK: [B2 (ENTRY)]
+// CHECK-NEXT: Succs (1): B1
+// CHECK: [B1]
+// CHECK-NEXT:   1: int arg
+// CHECK-NEXT:   2: arg
+// CHECK-NEXT:   3: (int)[B1.2] (CStyleCastExpr, NoOp, int)
+// CHECK-NEXT:   4: asm ("" : "=r" ([B1.3]));
+// CHECK-NEXT:   5: arg
+// CHECK-NEXT:   6: asm ("" : "=r" ([B1.5]));
+void checkGCCAsmRValue

[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 260265.
baloghadamsoftware added a comment.

All regions of parameters are `ParamRegions`, type stored explicitly, no 
crashes but 130 of 550 analyzer tests failing.


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

https://reviews.llvm.org/D77229

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Analysis/iterator-modeling.cpp
  clang/test/Analysis/temporaries.cpp

Index: clang/test/Analysis/temporaries.cpp
===
--- clang/test/Analysis/temporaries.cpp
+++ clang/test/Analysis/temporaries.cpp
@@ -890,12 +890,9 @@
 public:
   ~C() {
 glob = 1;
-// FIXME: Why is destructor not inlined in C++17
 clang_analyzer_checkInlined(true);
 #ifdef TEMPORARY_DTORS
-#if __cplusplus < 201703L
-// expected-warning@-3{{TRUE}}
-#endif
+// expected-warning@-2{{TRUE}}
 #endif
   }
 };
@@ -914,16 +911,11 @@
   // temporaries returned from functions, so we took the wrong branch.
   coin && is(get()); // no-crash
   if (coin) {
-// FIXME: Why is destructor not inlined in C++17
 clang_analyzer_eval(glob);
 #ifdef TEMPORARY_DTORS
-#if __cplusplus < 201703L
-// expected-warning@-3{{TRUE}}
-#else
-// expected-warning@-5{{UNKNOWN}}
-#endif
+// expected-warning@-2{{TRUE}}
 #else
-// expected-warning@-8{{UNKNOWN}}
+// expected-warning@-4{{UNKNOWN}}
 #endif
   } else {
 // The destructor is not called on this branch.
Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1862,7 +1862,7 @@
 void clang_analyzer_printState();
 
 void print_state(std::vector &V) {
-  const auto i0 = V.cbegin();
+  auto i0 = V.cbegin();
   clang_analyzer_printState();
 
 // CHECK:  "checker_messages": [
@@ -1871,7 +1871,8 @@
 // CHECK-NEXT: "i0 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
 // CHECK-NEXT:   ]}
 
-  const auto i1 = V.cend();
+  ++i0;
+  auto i1 = V.cend();
   clang_analyzer_printState();
   
 // CHECK:  "checker_messages": [
@@ -1879,4 +1880,6 @@
 // CHECK-NEXT: "Iterator Positions :",
 // CHECK-NEXT: "i1 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
 // CHECK-NEXT:   ]}
+
+  --i1;
 }
Index: clang/test/Analysis/explain-svals.cpp
===
--- clang/test/Analysis/explain-svals.cpp
+++ clang/test/Analysis/explain-svals.cpp
@@ -93,6 +93,6 @@
 } // end of anonymous namespace
 
 void test_6() {
-  clang_analyzer_explain(conjure_S()); // expected-warning-re^lazily frozen compound value of temporary object constructed at statement 'conjure_S\(\)'$
+  clang_analyzer_explain(conjure_S()); // expected-warning-re^lazily frozen compound value of parameter 0 of function 'clang_analyzer_explain\(\)'$
   clang_analyzer_explain(conjure_S().z); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure_S\(\)'\) for field 'z' of temporary object constructed at statement 'conjure_S\(\)'$
 }
Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -17,7 +17,7 @@
 void clang_analyzer_warnIfReached();
 
 void begin(const std::vector &V) {
-  V.begin();
+  const auto i0 = V.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_express(clang_analyzer_container_begin

[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 260266.
MyDeveloperDay added a comment.

Need to skip over the template or we won't see this as needing to break on the 
return type


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

https://reviews.llvm.org/D78879

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6279,7 +6279,17 @@
"void\n"
"A::operator[]() {}\n"
"void\n"
-   "A::operator!() {}\n",
+   "A::operator!() {}\n"
+   "void\n"
+   "A::operator**() {}\n"
+   "void\n"
+   "A::operator *() {}\n"
+   "void\n"
+   "A::operator **() {}\n"
+   "void\n"
+   "A::operator &() {}\n"
+   "void\n"
+   "A::operator void **() {}\n",
Style);
   verifyFormat("constexpr auto\n"
"operator()() const -> reference {}\n"
@@ -6296,6 +6306,10 @@
"constexpr auto\n"
"operator void *() const -> reference {}\n"
"constexpr auto\n"
+   "operator void **() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator void *() const -> reference {}\n"
+   "constexpr auto\n"
"operator void &() const -> reference {}\n"
"constexpr auto\n"
"operator void &&() const -> reference {}\n"
@@ -15628,9 +15642,20 @@
   Style.PointerAlignment = FormatStyle::PAS_Right;
   verifyFormat("Foo::operator*();", Style);
   verifyFormat("Foo::operator void *();", Style);
+  verifyFormat("Foo::operator void **();", Style);
   verifyFormat("Foo::operator()(void *);", Style);
   verifyFormat("Foo::operator*(void *);", Style);
   verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator**();", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator *();", Style);
+  verifyFormat("Foo::operator *();", Style);
+  verifyFormat("Foo::operator **();", Style);
+  verifyFormat("Foo::operator **();", Style);
+  verifyFormat("Foo::operator &();", Style);
+  verifyFormat("Foo::operator &();", Style);
+  verifyFormat("Foo::operator &&();", Style);
+  verifyFormat("Foo::operator &&();", Style);
   verifyFormat("operator*(int (*)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&();", Style);
@@ -15641,21 +15666,39 @@
   verifyFormat("operator&(int (&)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator**();", Style);
   verifyFormat("Foo::operator void &&();", Style);
   verifyFormat("Foo::operator()(void &&);", Style);
   verifyFormat("Foo::operator&&(void &&);", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator const nsTArrayRight &()", Style);
+  verifyFormat("[[nodiscard]] operator const nsTArrayRight &()",
+   Style);
+  verifyFormat("operator void **()", Style);
+  verifyFormat("operator const FooRight &()", Style);
+  verifyFormat("operator const FooRight *()", Style);
+  verifyFormat("operator const FooRight **()", Style);
 
   Style.PointerAlignment = FormatStyle::PAS_Left;
   verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator**();", Style);
   verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator void**();", Style);
   verifyFormat("Foo::operator/*comment*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ const /*b*/ void*();", Style);
   verifyFormat("Foo::operator/*a*/ volatile /*b*/ void*();", Style);
   verifyFormat("Foo::operator()(void*);", Style);
   verifyFormat("Foo::operator*(void*);", Style);
   verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator**();", Style);
+  verifyFormat("Foo::operator**();", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator*(int (*)(), class Foo);", Style);
 
   verifyFormat("Foo::operator&();", Style);
@@ -15677,9 +15720,17 @@
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+  verifyFormat("operator const nsTArrayLeft&()", Style);
+  verifyFormat("[[nodiscard]] operator const nsTArrayLeft&()",
+   Style);
+  verifyFormat("operator void**()", Style);
+  verifyFormat("operator const FooLeft&()", Style);
+  verifyFormat("operator const FooLeft*()", Style);
+  verifyFormat

[PATCH] D77644: [clangd] Handle additional includes while parsing ASTs

2020-04-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Preamble.h:115
+  /// mutate include depths.
+  void patchPreambleIncludes(IncludeStructure &BaselineIncludes) const;
+

i am not happy about this interface. I was thinking about a 
`std::vector remainingBaselineIncludes() const` but didn't go for it 
to keep the concept of `patching`.

I suppose the former is more intuitive though, WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77644



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/lib/CrossTU/CMakeLists.txt:13
   clangIndex
+  clangTooling
+  clangSerialization

We've been very careful to make clang (the compiler binary) only depend on 
clangToolingCore and not on the much bigger clangTooling library. Since clang 
depends on the CrossTU library, this breaks that. Can you reorganize things so 
that we don't need a dependency from clang-the-compiler-binary on clangTooling?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D77809: [Analyzer] Include typedef statements in CFG build.

2020-04-27 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3b9b3d56efaa: [Analyzer] Include typedef statements in CFG 
build. (authored by balazske).

Changed prior to commit:
  https://reviews.llvm.org/D77809?vs=259820&id=260269#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77809

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/Analysis/cfg.c
  clang/test/Analysis/cfg.cpp

Index: clang/test/Analysis/cfg.cpp
===
--- clang/test/Analysis/cfg.cpp
+++ clang/test/Analysis/cfg.cpp
@@ -12,42 +12,6 @@
 // off. Feel free to add tests that test only one of the CFG flavors if you're
 // not sure how the other flavor is supposed to work in your case.
 
-// CHECK-LABEL: void checkWrap(int i)
-// CHECK: ENTRY
-// CHECK-NEXT: Succs (1): B1
-// CHECK: [B1]
-// CHECK: Succs (21): B2 B3 B4 B5 B6 B7 B8 B9
-// CHECK: B10 B11 B12 B13 B14 B15 B16 B17 B18 B19
-// CHECK: B20 B21 B0
-// CHECK: [B0 (EXIT)]
-// CHECK-NEXT: Preds (21): B2 B3 B4 B5 B6 B7 B8 B9
-// CHECK-NEXT: B10 B11 B12 B13 B14 B15 B16 B17 B18 B19
-// CHECK-NEXT: B20 B21 B1
-void checkWrap(int i) {
-  switch(i) {
-case 0: break;
-case 1: break;
-case 2: break;
-case 3: break;
-case 4: break;
-case 5: break;
-case 6: break;
-case 7: break;
-case 8: break;
-case 9: break;
-case 10: break;
-case 11: break;
-case 12: break;
-case 13: break;
-case 14: break;
-case 15: break;
-case 16: break;
-case 17: break;
-case 18: break;
-case 19: break;
-  }
-}
-
 // CHECK-LABEL: void checkDeclStmts()
 // CHECK: ENTRY
 // CHECK-NEXT: Succs (1): B1
@@ -84,24 +48,6 @@
   static_assert(1, "abc");
 }
 
-
-// CHECK-LABEL: void checkGCCAsmRValueOutput()
-// CHECK: [B2 (ENTRY)]
-// CHECK-NEXT: Succs (1): B1
-// CHECK: [B1]
-// CHECK-NEXT:   1: int arg
-// CHECK-NEXT:   2: arg
-// CHECK-NEXT:   3: (int)[B1.2] (CStyleCastExpr, NoOp, int)
-// CHECK-NEXT:   4: asm ("" : "=r" ([B1.3]));
-// CHECK-NEXT:   5: arg
-// CHECK-NEXT:   6: asm ("" : "=r" ([B1.5]));
-void checkGCCAsmRValueOutput() {
-  int arg;
-  __asm__("" : "=r"((int)arg));  // rvalue output operand
-  __asm__("" : "=r"(arg));   // lvalue output operand
-}
-
-
 // CHECK-LABEL: void F(EmptyE e)
 // CHECK: ENTRY
 // CHECK-NEXT: Succs (1): B1
@@ -136,7 +82,6 @@
   (void)__builtin_object_size(dummy(), 0);
 }
 
-
 class A {
 public:
   A() {}
@@ -355,7 +300,6 @@
   return x;
 }
 
-
 // CHECK-LABEL: void test_placement_new()
 // CHECK:  [B2 (ENTRY)]
 // CHECK-NEXT:  Succs (1): B1
@@ -547,25 +491,88 @@
 }
 } // namespace statement_expression_in_return
 
-// CHECK-LABEL: int overlap_compare(int x)
-// CHECK: [B2]
-// CHECK-NEXT:   1: 1
-// CHECK-NEXT:   2: return [B2.1];
-// CHECK-NEXT:   Preds (1): B3(Unreachable)
-// CHECK-NEXT:   Succs (1): B0
-// CHECK: [B3]
+// CHECK-LABEL: void vla_simple(int x)
+// CHECK: [B1]
 // CHECK-NEXT:   1: x
-// CHECK-NEXT:   2: [B3.1] (ImplicitCastExpr, LValueToRValue, int)
-// CHECK-NEXT:   3: 5
-// CHECK-NEXT:   4: [B3.2] > [B3.3]
-// CHECK-NEXT:   T: if [B4.5] && [B3.4]
-// CHECK-NEXT:   Preds (1): B4
-// CHECK-NEXT:   Succs (2): B2(Unreachable) B1
-int overlap_compare(int x) {
-  if (x == -1 && x > 5)
-return 1;
-
-  return 2;
+// CHECK-NEXT:   2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   3: int vla[x];
+void vla_simple(int x) {
+  int vla[x];
+}
+
+// CHECK-LABEL: void vla_typedef(int x)
+// CHECK: [B1]
+// CHECK-NEXT:   1: x
+// CHECK-NEXT:   2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   3: typedef int VLA[x];
+void vla_typedef(int x) {
+  typedef int VLA[x];
+}
+
+// CHECK-LABEL: void vla_typealias(int x)
+// CHECK: [B1]
+// CHECK-NEXT:   1: x
+// CHECK-NEXT:   2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   3: using VLA = int [x];
+void vla_typealias(int x) {
+  using VLA = int[x];
+}
+
+// CHECK-LABEL: void vla_typedef_multi(int x, int y)
+// CHECK:  [B1]
+// CHECK-NEXT:   1: y
+// CHECK-NEXT:   2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   3: x
+// CHECK-NEXT:   4: [B1.3] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   5: typedef int VLA[x][y];
+void vla_typedef_multi(int x, int y) {
+  typedef int VLA[x][y];
+}
+
+// CHECK-LABEL: void vla_typedefname_multi(int x, int y)
+// CHECK:  [B1]
+// CHECK-NEXT:   1: x
+// CHECK-NEXT:   2: [B1.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   3: typedef int VLA[x];
+// CHECK-NEXT:   4: y
+// CHECK-NEXT:   5: [B1.4] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   6: typedef VLA VLA1[y];
+// CHECK-NEXT:   7: 3
+// CHECK-NEXT:   8: using VLA2 = VLA1 [3];
+// CHECK-NEXT:   9: 4
+// CHECK-NEXT:  10: VLA2 vla[4];
+void vla_typedefname_multi(int x, int y) {
+  typedef int VLA[x];
+  typedef VLA VLA1[y];
+  using VLA2 = VLA1[3];
+  VLA2 vla[4];
+}
+
+// CHECK-LABEL: int vla_evalu

[PATCH] D75068: libclang: Add static build support for Windows

2020-04-27 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added a comment.

In D75068#2004072 , @davezarzycki 
wrote:

> Rather than wholly reverting this, I committed a fix: 
> 665471907a5c072c6653a38c35f35e5d54cef220 
> 
>
> The problem is that "NOT LIBCLANG_BUILD_STATIC" does not imply PIC, so there 
> is no point in trying to build the SHARED version. Please let me know if I 
> somehow missed something. Thanks!


@thakis  has a use case at https://reviews.llvm.org/D74907 building a SHARED 
libclang with `LLVM_ENABLE_PIC` set to `OFF`.

Would the variant `if(LLVM_ENABLE_PIC OR (WIN32 AND NOT 
LIBCLANG_BUILD_STATIC))`  work for the Fedora case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75068



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


[clang] 03f419f - [SveEmitter] IsInsertOp1SVALL and builtins for svqdec[bhwd] and svqinc[bhwd]

2020-04-27 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-04-27T11:45:10+01:00
New Revision: 03f419f3eb0c426a0a555be9abf7255a89b131cd

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

LOG: [SveEmitter] IsInsertOp1SVALL and builtins for svqdec[bhwd] and 
svqinc[bhwd]

Some ACLE builtins leave out the argument to specify the predicate
pattern, which is expected to be expanded to an SV_ALL pattern.

This patch adds the flag IsInsertOp1SVALL to insert SV_ALL as the
second operand.

Reviewers: efriedma, SjoerdMeijer

Reviewed By: SjoerdMeijer

Tags: #clang

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecd.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecw.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincd.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecd.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecw.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qincb.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qincd.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qinch.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qincw.c

Modified: 
clang/include/clang/Basic/TargetBuiltins.h
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdech.c
clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdech.c
clang/utils/TableGen/SveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index 8d25dedfef7f..0a06ba3e5ecc 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -241,6 +241,7 @@ namespace clang {
 bool isPrefetch() const { return Flags & IsPrefetch; }
 bool isReverseCompare() const { return Flags & ReverseCompare; }
 bool isAppendSVALL() const { return Flags & IsAppendSVALL; }
+bool isInsertOp1SVALL() const { return Flags & IsInsertOp1SVALL; }
 
 uint64_t getBits() const { return Flags; }
 bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }

diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index af6c971000f4..a5cacd2103a8 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -64,6 +64,7 @@
 // d: default
 // c: const pointer type
 // P: predicate type
+// s: scalar of element type
 // a: scalar of element type (splat to vector type)
 // e: 1/2 width unsigned elements, 2x element count
 // h: 1/2 width elements, 2x element count
@@ -182,6 +183,7 @@ def IsOverloadCvt : FlagType<0x0080>; // 
Use {typeof(operand0),
 def OverloadKindMask  : FlagType<0x00E0>; // When the masked 
values are all '0', the default type is used as overload type.
 def IsByteIndexed : FlagType<0x0100>;
 def IsAppendSVALL : FlagType<0x0200>; // Appends SV_ALL as the 
last operand.
+def IsInsertOp1SVALL  : FlagType<0x0400>; // Inserts SV_ALL as the 
second operand.
 def IsPrefetch: FlagType<0x0800>; // Contiguous prefetches.
 def ReverseCompare: FlagType<0x2000>; // Compare operands must 
be swapped.
 
@@ -827,11 +829,6 @@ def SVCVTXNT_F32: SInst<"svcvtxnt_f32[_f64]", "MMPd", 
"d", MergeOp1, "aarch6
 def SVCADD_M : SInst<"svcadd[_{d}]", "dPddi",  "hfd", MergeOp1,  
"aarch64_sve_fcadd", [], [ImmCheck<3, ImmCheckComplexRot90_270>]>;
 def SVCMLA_M : SInst<"svcmla[_{d}]", "dPdddi", "hfd", MergeOp1,  
"aarch64_sve_fcmla", [], [ImmCheck<4, ImmCheckComplexRotAll90>]>;
 
-
-// Saturating scalar arithmetic
-def SVQDECH_S : SInst<"svqdech_pat[_{d}]",   "ddIi", "s", MergeNone, 
"aarch64_sve_sqdech", [], [ImmCheck<2, ImmCheck1_16>]>;
-def SVQDECH_U : SInst<"svqdech_pat[_{d}]",   "ddIi", "Us", MergeNone, 
"aarch64_sve_uqdech", [], [ImmCheck<2, ImmCheck1_16>]>;
-
 
 

 // Predicate creation
@@ -853,6 +850,55 @@ def SVCNTB : SInst<"svcntb", "n", "", MergeNone, 
"aarch64_sve_cntb", [IsAppendSV
 def SVCNTH : SInst<"svcnth", "n", "", MergeNone, "aarch64_sve_cnth", 
[IsAppendSVALL, IsOverloadNone]>;
 def SVCNTW : SInst<"svcntw", "n", "",

[PATCH] D78909: [clang-format] NFC clang-format the clang-format sources

2020-04-27 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe accepted this revision.
jbcoe 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/D78909/new/

https://reviews.llvm.org/D78909



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


[PATCH] D78401: [SveEmitter] IsInsertOp1SVALL and builtins for svqdec[bhwd] and svqinc[bhwd]

2020-04-27 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG03f419f3eb0c: [SveEmitter] IsInsertOp1SVALL and builtins for 
svqdec[bhwd] and svqinc[bhwd] (authored by sdesmalen).

Changed prior to commit:
  https://reviews.llvm.org/D78401?vs=259554&id=260274#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78401

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdech.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdecw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qinch.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qincw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdech.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdecw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qincb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qincd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qinch.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qincw.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -505,6 +505,7 @@
 Bitwidth = 16;
 ElementBitwidth = 1;
 break;
+  case 's':
   case 'a':
 Bitwidth = ElementBitwidth;
 NumVectors = 0;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qincw.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qincw.c
@@ -0,0 +1,155 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify %s
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+#include 
+
+int32_t test_svqincw_n_s32(int32_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw,_n_s32,,)(op, 0);
+}
+
+int32_t test_svqincw_n_s32_1(int32_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw,_n_s32,,)(op, 17);
+}
+
+int64_t test_svqincw_n_s64(int64_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw,_n_s64,,)(op, 0);
+}
+
+int64_t test_svqincw_n_s64_1(int64_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw,_n_s64,,)(op, 17);
+}
+
+uint32_t test_svqincw_n_u32(uint32_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw,_n_u32,,)(op, 0);
+}
+
+uint32_t test_svqincw_n_u32_1(uint32_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw,_n_u32,,)(op, 17);
+}
+
+uint64_t test_svqincw_n_u64(uint64_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw,_n_u64,,)(op, 0);
+}
+
+uint64_t test_svqincw_n_u64_1(uint64_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw,_n_u64,,)(op, 17);
+}
+
+int32_t test_svqincw_pat_n_s32(int32_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw_pat,_n_s32,,)(op, SV_POW2, 0);
+}
+
+int32_t test_svqincw_pat_n_s32_1(int32_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw_pat,_n_s32,,)(op, SV_VL1, 17);
+}
+
+int64_t test_svqincw_pat_n_s64(int64_t op)
+{
+  // expected-error-re@+1 {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+  return SVE_ACLE_FUNC(svqincw_pat,_n_s64,,)(op, SV_VL2, 0);
+}
+
+int64_t test_svqincw_p

[PATCH] D75068: libclang: Add static build support for Windows

2020-04-27 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

In D75068#2004885 , @cristian.adam 
wrote:

> In D75068#2004072 , @davezarzycki 
> wrote:
>
> > Rather than wholly reverting this, I committed a fix: 
> > 665471907a5c072c6653a38c35f35e5d54cef220 
> > 
> >
> > The problem is that "NOT LIBCLANG_BUILD_STATIC" does not imply PIC, so 
> > there is no point in trying to build the SHARED version. Please let me know 
> > if I somehow missed something. Thanks!
>
>
> @thakis  has a use case at https://reviews.llvm.org/D74907 building a SHARED 
> libclang with `LLVM_ENABLE_PIC` set to `OFF`.
>
> Would the variant `if(LLVM_ENABLE_PIC OR (WIN32 AND NOT 
> LIBCLANG_BUILD_STATIC))`  work for the Fedora case?


Fedora is not WIN32, so sure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75068



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


[PATCH] D78915: [clang-format] Improved parser for C# properties

2020-04-27 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added reviewers: krasimir, MyDeveloperDay.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Added some examples of properties from Microsoft documentation as test cases.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties

Configuration support will be added in a follow up patch to address whether 
automatic properties are formatted as

  Type MyType { get; set }

or

  Type MyType 
  { get; set }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78915

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -611,6 +611,64 @@
 public string Name {
   get => _name;
   set => _name = value;
+})",
+   Style);
+
+  // Examples taken from
+  // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
+  verifyFormat(R"(
+// Expression body definitions
+public class SaleItem {
+  public decimal Price {
+get => _cost;
+set => _cost = value;
+  }
+})",
+   Style);
+
+  verifyFormat(R"(
+// Properties with backing fields
+class TimePeriod {
+  public double Hours {
+get { return _seconds / 3600; }
+set {
+  if (value < 0 || value > 24)
+throw new ArgumentOutOfRangeException(
+$"{nameof(value)} must be between 0 and 24.");
+  _seconds = value * 3600;
+}
+  }
+})",
+   Style);
+
+  verifyFormat(R"(
+// Auto-implemented properties
+public class SaleItem {
+  public decimal Price { get; set; }
+})",
+   Style);
+
+  // Add column limit to wrap long lines.
+  Style.ColumnLimit = 100;
+
+  // Examples with assignment to default value.
+  verifyFormat(R"(
+// Long assignment to default value
+class MyClass {
+  public override VeryLongNamedTypeIndeed VeryLongNamedValue { get; set } =
+  VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, DefaultSecondArgument,
+ DefaultThirdArgument);
+})",
+   Style);
+
+  verifyFormat(R"(
+// Long assignment to default value with expression body
+class MyClass {
+  public override VeryLongNamedTypeIndeed VeryLongNamedValue {
+get => veryLongNamedField;
+set => veryLongNamedField = value;
+  } = VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, DefaultSecondArgument,
+ DefaultThirdArgument);
 })",
Style);
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "UnwrappedLineParser.h"
+#include "FormatToken.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -1495,9 +1496,7 @@
   if (FormatTok->Previous->isNot(tok::identifier))
 return false;
 
-  // Try to parse the property accessor braces and contents:
-  // `{ get; set; } = new MyType(defaultValue);`
-  //  ^
+  // See if we are inside a property accessor.
   //
   // Record the current tokenPosition so that we can advance and
   // reset the current token. `Next` is not set yet so we need
@@ -1506,19 +1505,20 @@
   FormatToken *Tok = Tokens->getNextToken();
 
   bool HasGetOrSet = false;
+  bool IsTrivialPropertyAccessor = true;
   while (!eof()) {
 if (Tok->isOneOf(tok::semi, tok::kw_public, tok::kw_private,
  tok::kw_protected, Keywords.kw_internal, Keywords.kw_get,
  Keywords.kw_set)) {
-  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_set))
+  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_set)) {
 HasGetOrSet = true;
+  }
   Tok = Tokens->getNextToken();
   continue;
 }
-if (Tok->is(tok::r_brace))
-  break;
-Tokens->setPosition(StoredPosition);
-return false;
+if(Tok->isNot(tok::r_brace))
+  IsTrivialPropertyAccessor = false;
+break;
   }
 
   if (!HasGetOrSet) {
@@ -1526,33 +1526,52 @@
 return false;
   }
 
-  Tokens->setPosition(StoredPosition);
-  while (FormatTok->isNot(tok::r_brace)) {
-nextToken();
-  }
-
-  // Try to parse (optional) assignment to default value:
+  // Try to parse the property accessor:
   // `{ get; set; } = new MyType(defaultValue);`
-  //^^^
-  // There may be some very complicated expressions inside default value
-  // assignment, the simple parse block below will not handle them.
-  // The parse block below would need extending to handle opening parens etc.
-  Store

[clang] 9f1e81f - [ASTImporter] Also import overwritten file buffers

2020-04-27 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-04-27T13:16:08+02:00
New Revision: 9f1e81f1c0ac40f81e2f398148f09d1852226240

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

LOG: [ASTImporter] Also import overwritten file buffers

Summary:
Overwritten file buffers are at the moment ignored when importing and
instead only the underlying file buffer is imported.

This patch fixes this by not going to the underlying file entry if the file has
an overwritten buffer.

Reviewers: martong, a.sidorin, shafik

Reviewed By: martong, shafik

Subscribers: rnkovacs

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

Added: 


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

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index ecb5ce85c204..477c035d8a59 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -8560,7 +8560,7 @@ Expected ASTImporter::Import(FileID FromID, bool 
IsBuiltin) {
   } else {
 const SrcMgr::ContentCache *Cache = FromSLoc.getFile().getContentCache();
 
-if (!IsBuiltin) {
+if (!IsBuiltin && !Cache->BufferOverridden) {
   // Include location of this file.
   ExpectedSLoc ToIncludeLoc = Import(FromSLoc.getFile().getIncludeLoc());
   if (!ToIncludeLoc)

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 8ed6c487cb53..a390b49d1641 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -12,6 +12,7 @@
 
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/SmallVectorMemoryBuffer.h"
 
 #include "clang/AST/DeclContextInternals.h"
 #include "gtest/gtest.h"
@@ -5896,6 +5897,61 @@ TEST_P(ImportSourceLocations, 
PreserveFileIDTreeStructure) {
   EXPECT_FALSE(ToSM.isBeforeInTranslationUnit(Location2, Location1));
 }
 
+TEST_P(ImportSourceLocations, NormalFileBuffer) {
+  // Test importing normal file buffers.
+
+  std::string Path = "input0.c";
+  std::string Source = "int X;";
+  TranslationUnitDecl *FromTU = getTuDecl(Source, Lang_C, Path);
+
+  SourceLocation ImportedLoc;
+  {
+// Import the VarDecl to trigger the importing of the FileID.
+auto Pattern = varDecl(hasName("X"));
+VarDecl *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+ImportedLoc = Import(FromD, Lang_C)->getLocation();
+  }
+
+  // Make sure the imported buffer has the original contents.
+  SourceManager &ToSM = ToAST->getSourceManager();
+  FileID ImportedID = ToSM.getFileID(ImportedLoc);
+  EXPECT_EQ(Source, ToSM.getBuffer(ImportedID, SourceLocation())->getBuffer());
+}
+
+TEST_P(ImportSourceLocations, OverwrittenFileBuffer) {
+  // Test importing overwritten file buffers.
+
+  std::string Path = "input0.c";
+  TranslationUnitDecl *FromTU = getTuDecl("int X;", Lang_C, Path);
+
+  // Overwrite the file buffer for our input file with new content.
+  const std::string Contents = "overwritten contents";
+  SourceLocation ImportedLoc;
+  {
+SourceManager &FromSM = FromTU->getASTContext().getSourceManager();
+clang::FileManager &FM = FromSM.getFileManager();
+const clang::FileEntry &FE =
+*FM.getVirtualFile(Path, static_cast(Contents.size()), 0);
+
+llvm::SmallVector Buffer;
+Buffer.append(Contents.begin(), Contents.end());
+auto FileContents =
+std::make_unique(std::move(Buffer), 
Path);
+FromSM.overrideFileContents(&FE, std::move(FileContents));
+
+// Import the VarDecl to trigger the importing of the FileID.
+auto Pattern = varDecl(hasName("X"));
+VarDecl *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+ImportedLoc = Import(FromD, Lang_C)->getLocation();
+  }
+
+  // Make sure the imported buffer has the overwritten contents.
+  SourceManager &ToSM = ToAST->getSourceManager();
+  FileID ImportedID = ToSM.getFileID(ImportedLoc);
+  EXPECT_EQ(Contents,
+ToSM.getBuffer(ImportedID, SourceLocation())->getBuffer());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportExprOfAlignmentAttr) {
   // Test if import of these packed and aligned attributes does not trigger an
   // error situation where source location from 'From' context is referenced in



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


[PATCH] D78882: [IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand().

2020-04-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added a reviewer: dblaikie.
Herald added subscribers: lldb-commits, cfe-commits, Kayjukh, frgossen, 
grosul1, dantrushin, Joonsoo, kerbowa, liufengdb, lucyrfox, mgester, 
arpith-jacob, csigg, nicolasvasilache, antiagainst, shauheen, jpienaar, 
rriddle, mehdi_amini, asbirlea, dexonsmith, steven_wu, george.burgess.iv, 
kbarton, aheejin, hiraditya, jgravelle-google, sbc100, nhaehnle, jvesely, 
nemanjai, dschuff, arsenm, jholewinski.
Herald added a reviewer: deadalnix.
Herald added a reviewer: ftynse.
Herald added projects: clang, LLDB, LLVM.

This method has been commented as deprecated for a while. Remove
it and replace all uses with the equivalent getCalledOperand().

I also made a few cleanups in here. For example, to removes use
of getElementType on a pointer when we could just use getFunctionType
from the call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78882

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  lldb/source/Expression/IRInterpreter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/CodeGen/FastISel.h
  llvm/include/llvm/IR/AbstractCallSite.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/Analysis/AliasAnalysisEvaluator.cpp
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/Lint.cpp
  llvm/lib/Analysis/MemorySSA.cpp
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
  llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/CodeGen/WasmEHPrepare.cpp
  llvm/lib/CodeGen/WinEHPrepare.cpp
  llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64PromoteConstant.cpp
  llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp
  llvm/lib/Target/AMDGPU/AMDGPUFixFunctionBitcasts.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/ARM/ARMFastISel.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86WinEHState.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/IPO/CalledValuePropagation.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/IPO/PruneEH.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/lib/Transforms/Instrumentation/ValueProfilePlugins.inc
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
  llvm/lib/Transforms/Utils/Evaluator.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/lib/Transforms/Utils/LowerInvoke.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/LTO/X86/type-mapping-bug3.ll
  llvm/tools/llvm-diff/DiffConsumer.cpp
  llvm/tools/llvm-diff/DifferenceEngine.cpp
  mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp

Index: mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
===
--- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -720,7 +720,7 @@
   op = b.create(loc, tys, b.getSymbolRefAttr(callee->getName()),
 ops);
 } else {
-  Value calledValue = processValue(ci->getCalledValue());
+  Value calledValue = processValue(ci->getCalledOperand());
   if (!calledValue)
 return failure();
   ops.insert(ops.begin(), calledValue);
@@ -766,7 +766,7 @@
   ops, blocks[ii->getNormalDest()], normalArgs,
   blocks[ii->getUnwindDest()], unwindArgs);
 } else {
-  ops.i

[PATCH] D78882: [IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand().

2020-04-27 Thread Alex Zinenko via Phabricator via cfe-commits
ftynse accepted this revision.
ftynse added a comment.
This revision is now accepted and ready to land.

LGTM for MLIR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78882



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I spent some time on thinking about this during the weekend. It is no wonder 
that the tests fail. It seems that many parts of the Analyzer core exploit the 
fact that the `MemRegion`s of parameters are `VarRegion`s.  This is no wonder 
because all `ParamVarDecl` are `VarDecl` and in an inlined function parameters 
behave like variables. This is the correct behavior which I think should not be 
changed. Even if I put weeks or months of work into it the code will be worse 
at the end because there will be lots of branches upon the nature of the 
variable and alternative ways for reaching the `Decl` from their regions. This 
is not the proper way, `MemRegion`s for parameters in inlined functions should 
remain `VarRegion`s because parameters **are** variables inside. On the other 
hand, from outside it does not matter what kind of regions they are. We mainly 
need the region there to use it as key for `GDM` maps. That is why 
`ParamRegion`s should only be created for functions that are not inlined. If 
they have no definition then they cannot be inlined so a `ParamRegion` is OK 
for them. However, if they have a definition then there is no problem finding 
the same `Decl` because the definition is that same `Decl` that we use 
everywhere so it can and should remain a `VarRegion`.


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

https://reviews.llvm.org/D77229



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this also breaks tests on Windows and Mac, eg 
http://45.33.8.238/win/13902/step_7.txt

It probably makes sense to revert while you investigate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a subscriber: tstellar.
hans added a comment.

In D78879#2004751 , @MyDeveloperDay 
wrote:

> So for the Mozilla case mentioned in the bug report we either need to ask 
> @hans  if D76850: clang-format: Fix pointer alignment for overloaded 
> operators (PR45107)  can go into the v10 
> branch, or perhaps they can apply that path rather than the revert patch


Forwarding to @tstellar who manages the 10.0.1 release.


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

https://reviews.llvm.org/D78879



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


[PATCH] D78086: [ASTImporter] Also import overwritten file buffers

2020-04-27 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f1e81f1c0ac: [ASTImporter] Also import overwritten file 
buffers (authored by teemperor).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78086

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -12,6 +12,7 @@
 
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/SmallVectorMemoryBuffer.h"
 
 #include "clang/AST/DeclContextInternals.h"
 #include "gtest/gtest.h"
@@ -5896,6 +5897,61 @@
   EXPECT_FALSE(ToSM.isBeforeInTranslationUnit(Location2, Location1));
 }
 
+TEST_P(ImportSourceLocations, NormalFileBuffer) {
+  // Test importing normal file buffers.
+
+  std::string Path = "input0.c";
+  std::string Source = "int X;";
+  TranslationUnitDecl *FromTU = getTuDecl(Source, Lang_C, Path);
+
+  SourceLocation ImportedLoc;
+  {
+// Import the VarDecl to trigger the importing of the FileID.
+auto Pattern = varDecl(hasName("X"));
+VarDecl *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+ImportedLoc = Import(FromD, Lang_C)->getLocation();
+  }
+
+  // Make sure the imported buffer has the original contents.
+  SourceManager &ToSM = ToAST->getSourceManager();
+  FileID ImportedID = ToSM.getFileID(ImportedLoc);
+  EXPECT_EQ(Source, ToSM.getBuffer(ImportedID, SourceLocation())->getBuffer());
+}
+
+TEST_P(ImportSourceLocations, OverwrittenFileBuffer) {
+  // Test importing overwritten file buffers.
+
+  std::string Path = "input0.c";
+  TranslationUnitDecl *FromTU = getTuDecl("int X;", Lang_C, Path);
+
+  // Overwrite the file buffer for our input file with new content.
+  const std::string Contents = "overwritten contents";
+  SourceLocation ImportedLoc;
+  {
+SourceManager &FromSM = FromTU->getASTContext().getSourceManager();
+clang::FileManager &FM = FromSM.getFileManager();
+const clang::FileEntry &FE =
+*FM.getVirtualFile(Path, static_cast(Contents.size()), 0);
+
+llvm::SmallVector Buffer;
+Buffer.append(Contents.begin(), Contents.end());
+auto FileContents =
+std::make_unique(std::move(Buffer), 
Path);
+FromSM.overrideFileContents(&FE, std::move(FileContents));
+
+// Import the VarDecl to trigger the importing of the FileID.
+auto Pattern = varDecl(hasName("X"));
+VarDecl *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+ImportedLoc = Import(FromD, Lang_C)->getLocation();
+  }
+
+  // Make sure the imported buffer has the overwritten contents.
+  SourceManager &ToSM = ToAST->getSourceManager();
+  FileID ImportedID = ToSM.getFileID(ImportedLoc);
+  EXPECT_EQ(Contents,
+ToSM.getBuffer(ImportedID, SourceLocation())->getBuffer());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, ImportExprOfAlignmentAttr) {
   // Test if import of these packed and aligned attributes does not trigger an
   // error situation where source location from 'From' context is referenced in
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -8560,7 +8560,7 @@
   } else {
 const SrcMgr::ContentCache *Cache = FromSLoc.getFile().getContentCache();
 
-if (!IsBuiltin) {
+if (!IsBuiltin && !Cache->BufferOverridden) {
   // Include location of this file.
   ExpectedSLoc ToIncludeLoc = Import(FromSLoc.getFile().getIncludeLoc());
   if (!ToIncludeLoc)


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -12,6 +12,7 @@
 
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/SmallVectorMemoryBuffer.h"
 
 #include "clang/AST/DeclContextInternals.h"
 #include "gtest/gtest.h"
@@ -5896,6 +5897,61 @@
   EXPECT_FALSE(ToSM.isBeforeInTranslationUnit(Location2, Location1));
 }
 
+TEST_P(ImportSourceLocations, NormalFileBuffer) {
+  // Test importing normal file buffers.
+
+  std::string Path = "input0.c";
+  std::string Source = "int X;";
+  TranslationUnitDecl *FromTU = getTuDecl(Source, Lang_C, Path);
+
+  SourceLocation ImportedLoc;
+  {
+// Import the VarDecl to trigger the importing of the FileID.
+auto Pattern = varDecl(hasName("X"));
+VarDecl *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+ImportedLoc = Import(FromD, Lang_C)->getLocation();
+  }
+
+  // Make sure the imported buffer has the original contents.
+  SourceManager &ToSM = ToAST->getSourceManager();
+  FileID Im

[clang] f181f1b - [clang] Remove NFC overload in ASTImporterTest

2020-04-27 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-04-27T14:10:43+02:00
New Revision: f181f1b7f73e643fb5d10a6d07832c1a2fb34c0b

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

LOG: [clang] Remove NFC overload in ASTImporterTest

This overload is just an artifact from the original version of the patch, but
doesn't have any functional purpose.

Added: 


Modified: 
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index a390b49d1641..36003957d2e1 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -6023,10 +6023,6 @@ struct SourceWithCompletedTagList : 
clang::ExternalASTSource {
 Record->completeDefinition();
 CompletedTags.push_back(Tag);
   }
-  void
-  FindExternalLexicalDecls(const DeclContext *DC,
-   llvm::function_ref IsKindWeWant,
-   SmallVectorImpl &Result) override {}
 };
 
 TEST_P(ImportWithExternalSource, CompleteRecordBeforeImporting) {



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> no crashes but 130 of 550 analyzer tests failing.

You most likely need to fill in the reachibility and liveness code with the 
behavior of the new region. I don't seem to see it in your current code but 
their default behavior is clearly incorrect; instead, they should behave 
exactly like the old region used to.


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

https://reviews.llvm.org/D77229



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> How do we calculate the type then?

Argument expression type + account for value kind (lvalue argument expression 
means reference parameter, xvalue argument expression mean rvalue reference 
parameter).

Note that for C-style variadic functions, parameter declarations for variadic 
arguments are also not available. It doesn't mean that we will never be able to 
analyze them. We can analyze everything: after all, we can CodeGen everything 
from the AST. On the contrary, the solution you're implementing now would work 
for C-style variadic functions as well, finally allowing us to inline them.


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

https://reviews.llvm.org/D77229



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D77229#2004964 , 
@baloghadamsoftware wrote:

> Even if I put weeks or months of work into it the code will be worse at the 
> end because there will be lots of branches upon the nature of the variable 
> and alternative ways for reaching the `Decl` from their regions.


What specifically do you want from the `Decl`? Is it the type? We have it. Is 
it the very fact that it's a parameter? We have it. Is it the index of the 
parameter? We have it. Is it the name of the parameter? It's so irrelevant that 
it's not even necessarily consistent across redeclarations, but if you really 
need it you may try to obtain the `Decl` whenever it's available, as the amount 
of cases when the `Decl` is available hasn't changed. What else does a `Decl` 
have to offer?


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

https://reviews.llvm.org/D77229



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


[clang] 145dcef - [clang-tidy] modernize-use-using: Fix broken fixit with InjectedClassName

2020-04-27 Thread Matthias Gehre via cfe-commits

Author: Matthias Gehre
Date: 2020-04-27T14:23:23+02:00
New Revision: 145dcef8bdf9da9684c9c4e34a8e6c45baafab74

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

LOG: [clang-tidy] modernize-use-using: Fix broken fixit with InjectedClassName

Summary:
Before this PR, `modernize-use-using` would transform the typedef in
```
template 
struct InjectedClassName {
  typedef InjectedClassName b;
};
```
into `using b = InjectedClassName;` and
```
template 
struct InjectedClassNameWithUnnamedArgument {
  typedef InjectedClassNameWithUnnamedArgument b;
};
```
into `using b = InjectedClassNameWithUnnamedArgument<>;`.
The first fixit is surprising because its different than the code
before, but the second fixit doesn't even compile.

This PR adds an option to the TypePrinter to print InjectedClassNameType without
template parameters (i.e. as written).

Reviewers: aaron.ballman, alexfh, hokein, njames93

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
clang/include/clang/AST/PrettyPrinter.h
clang/lib/AST/TypePrinter.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index f352374d4b91..f6dc5c044a7a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -58,6 +58,7 @@ void UseUsingCheck::check(const MatchFinder::MatchResult 
&Result) {
   printPolicy.SuppressScope = true;
   printPolicy.ConstantArraySizeAsWritten = true;
   printPolicy.UseVoidForZeroParams = false;
+  printPolicy.PrintInjectedClassNameWithArguments = false;
 
   std::string Type = MatchedDecl->getUnderlyingType().getAsString(printPolicy);
   std::string Name = MatchedDecl->getNameAsString();

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
index 8d25dbb95658..b74e67a17f86 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
@@ -289,3 +289,16 @@ typedef enum { ea2, eb2 } 
EnumT2_CheckTypedefImpactFromAnotherFile;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using EnumT2_CheckTypedefImpactFromAnotherFile = enum { ea2, 
eb2 };
 
+template 
+struct InjectedClassName {
+  typedef InjectedClassName b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using b = InjectedClassName;
+};
+
+template 
+struct InjectedClassNameWithUnnamedArgument {
+  typedef InjectedClassNameWithUnnamedArgument b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using b = InjectedClassNameWithUnnamedArgument;
+};

diff  --git a/clang/include/clang/AST/PrettyPrinter.h 
b/clang/include/clang/AST/PrettyPrinter.h
index 21e5ca94f6c4..65c7e2385677 100644
--- a/clang/include/clang/AST/PrettyPrinter.h
+++ b/clang/include/clang/AST/PrettyPrinter.h
@@ -63,7 +63,7 @@ struct PrintingPolicy {
 MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
 MSVCFormatting(false), ConstantsAsWritten(false),
 SuppressImplicitBase(false), FullyQualifiedName(false),
-PrintCanonicalTypes(false) {}
+PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true) 
{}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -244,6 +244,11 @@ struct PrintingPolicy {
   /// Whether to print types as written or canonically.
   unsigned PrintCanonicalTypes : 1;
 
+  /// Whether to print an InjectedClassNameType with template arguments or as
+  /// written. When a template argument is unnamed, printing it results in
+  /// invalid C++ code.
+  unsigned PrintInjectedClassNameWithArguments : 1;
+
   /// Callbacks to use to allow the behavior of printing to be customized.
   const PrintingCallbacks *Callbacks = nullptr;
 };

diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index f000e1f6c932..cf82d1a26156 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1329,7 +1329,12 @@ void TypePrinter::printTemplateSpecializationAfter(
 
 void TypePrinter::printInjectedClassNameBefore(const InjectedClassNameType *T,
raw_ostream &OS) {
-  printTemplateSpecializationBefore(T->getInjectedTST(), OS);
+  if (Policy.PrintInj

[clang] 9671712 - Revert "[analyzer] On-demand parsing capability for CTU"

2020-04-27 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-04-27T14:27:04+02:00
New Revision: 96717125e852d1c6ddf41c22dd2d556f4f5aa34d

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

LOG: Revert "[analyzer] On-demand parsing capability for CTU"

This reverts commit 811c0c9eb462d1fef6ab6908aab7881e5c4f5fbf. It broke
multiple buildbots.

Added: 
clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt

Modified: 
clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
clang/lib/CrossTU/CMakeLists.txt
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Analysis/Inputs/ctu-other.c
clang/test/Analysis/analyzer-config.c
clang/test/Analysis/ctu-different-triples.cpp
clang/test/Analysis/ctu-main.c
clang/test/Analysis/ctu-main.cpp
clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Removed: 
clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.ast-dump.txt
clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt
clang/test/Analysis/ctu-on-demand-parsing-ambigous-compilation-database.c
clang/test/Analysis/ctu-on-demand-parsing.c
clang/test/Analysis/ctu-on-demand-parsing.cpp



diff  --git a/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst 
b/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
index 1a7ac1c71f21..86f972b63e31 100644
--- a/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
+++ b/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
@@ -3,33 +3,14 @@ Cross Translation Unit (CTU) Analysis
 =
 
 Normally, static analysis works in the boundary of one translation unit (TU).
-However, with additional steps and configuration we can enable the analysis to 
inline the definition of a function from
-another TU.
+However, with additional steps and configuration we can enable the analysis to 
inline the definition of a function from another TU.
 
 .. contents::
:local:
 
-Overview
-
-CTU analysis can be used in a variety of ways. The importing of external TU 
definitions can work with pre-dumped PCH
-files or generating the necessary AST structure on-demand, during the analysis 
of the main TU. Driving the static
-analysis can also be implemented in multiple ways. The most direct way is to 
specify the necessary commandline options
-of the Clang frontend manually (and generate the prerequisite dependencies of 
the specific import method by hand). This
-process can be automated by other tools, like `CodeChecker 
`_ and scan-build-py
-(preference for the former).
-
-PCH-based analysis
-__
-The analysis needs the PCH dumps of all the translations units used in the 
project.
-These can be generated by the Clang Frontend itself, and must be arranged in a 
specific way in the filesystem.
-The index, which maps symbols' USR names to PCH dumps containing them must 
also be generated by the
-`clang-extdef-mapping`. This tool uses a :doc:`compilation database 
<../../JSONCompilationDatabase>` to
-determine the compilation flags used.
-The analysis invocation must be provided with the directory which contains the 
dumps and the mapping files.
-
-
 Manual CTU Analysis
-###
+---
+
 Let's consider these source files in our minimal example:
 
 .. code-block:: cpp
@@ -66,8 +47,7 @@ And a compilation database:
   ]
 
 We'd like to analyze `main.cpp` and discover the division by zero bug.
-In order to be able to inline the definition of `foo` from `foo.cpp` first we 
have to generate the `AST` (or `PCH`) file
-of `foo.cpp`:
+In order to be able to inline the definition of `foo` from `foo.cpp` first we 
have to generate the `AST` (or `PCH`) file of `foo.cpp`:
 
 .. code-block:: bash
 
@@ -78,8 +58,7 @@ of `foo.cpp`:
   compile_commands.json  foo.cpp.ast  foo.cpp  main.cpp
   $
 
-The next step is to create a CTU index file which holds the `USR` name and 
location of external definitions in the
-source files:
+The next step is to create a CTU index file which holds the `USR` name and 
location of external definitions in the source files:
 
 .. code-block:: bash
 
@@ -106,34 +85,47 @@ We have to feed Clang with CTU specific extra arguments:
 
   $ pwd
   /path/to/your/project
-  $ clang++ --analyze \
-  -Xclang -analyzer-config -Xclang 
experimental-enable-naive-ctu-analysis=true \
-  -Xclang -analyzer-config -Xclang ctu-dir=. \
-  -Xclang -analyzer-config -Xclang ctu-on-demand-parsing=false \
-  -Xclang -analyzer-outp

[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Sorry, this change broke a couple bots that are in the official CI, at least 
http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64/builds/7566 and 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/66618.
 I'm reverting this change -- feel free to reland after fixing the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Reverted in 
https://github.com/llvm/llvm-project/commit/96717125e852d1c6ddf41c22dd2d556f4f5aa34d.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D77979: [clang-tidy] modernize-use-using: Fix broken fixit with InjectedClassName

2020-04-27 Thread Matthias Gehre via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG145dcef8bdf9: [clang-tidy] modernize-use-using: Fix broken 
fixit with InjectedClassName (authored by mgehre).

Changed prior to commit:
  https://reviews.llvm.org/D77979?vs=256872&id=260294#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77979

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
  clang/include/clang/AST/PrettyPrinter.h
  clang/lib/AST/TypePrinter.cpp


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1329,7 +1329,12 @@
 
 void TypePrinter::printInjectedClassNameBefore(const InjectedClassNameType *T,
raw_ostream &OS) {
-  printTemplateSpecializationBefore(T->getInjectedTST(), OS);
+  if (Policy.PrintInjectedClassNameWithArguments)
+return printTemplateSpecializationBefore(T->getInjectedTST(), OS);
+
+  IncludeStrongLifetimeRAII Strong(Policy);
+  T->getTemplateName().print(OS, Policy);
+  spaceBeforePlaceHolder(OS);
 }
 
 void TypePrinter::printInjectedClassNameAfter(const InjectedClassNameType *T,
Index: clang/include/clang/AST/PrettyPrinter.h
===
--- clang/include/clang/AST/PrettyPrinter.h
+++ clang/include/clang/AST/PrettyPrinter.h
@@ -63,7 +63,7 @@
 MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
 MSVCFormatting(false), ConstantsAsWritten(false),
 SuppressImplicitBase(false), FullyQualifiedName(false),
-PrintCanonicalTypes(false) {}
+PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true) 
{}
 
   /// Adjust this printing policy for cases where it's known that we're
   /// printing C++ code (for instance, if AST dumping reaches a C++-only
@@ -244,6 +244,11 @@
   /// Whether to print types as written or canonically.
   unsigned PrintCanonicalTypes : 1;
 
+  /// Whether to print an InjectedClassNameType with template arguments or as
+  /// written. When a template argument is unnamed, printing it results in
+  /// invalid C++ code.
+  unsigned PrintInjectedClassNameWithArguments : 1;
+
   /// Callbacks to use to allow the behavior of printing to be customized.
   const PrintingCallbacks *Callbacks = nullptr;
 };
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
@@ -289,3 +289,16 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
 // CHECK-FIXES: using EnumT2_CheckTypedefImpactFromAnotherFile = enum { ea2, 
eb2 };
 
+template 
+struct InjectedClassName {
+  typedef InjectedClassName b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using b = InjectedClassName;
+};
+
+template 
+struct InjectedClassNameWithUnnamedArgument {
+  typedef InjectedClassNameWithUnnamedArgument b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using b = InjectedClassNameWithUnnamedArgument;
+};
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -58,6 +58,7 @@
   printPolicy.SuppressScope = true;
   printPolicy.ConstantArraySizeAsWritten = true;
   printPolicy.UseVoidForZeroParams = false;
+  printPolicy.PrintInjectedClassNameWithArguments = false;
 
   std::string Type = MatchedDecl->getUnderlyingType().getAsString(printPolicy);
   std::string Name = MatchedDecl->getNameAsString();


Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1329,7 +1329,12 @@
 
 void TypePrinter::printInjectedClassNameBefore(const InjectedClassNameType *T,
raw_ostream &OS) {
-  printTemplateSpecializationBefore(T->getInjectedTST(), OS);
+  if (Policy.PrintInjectedClassNameWithArguments)
+return printTemplateSpecializationBefore(T->getInjectedTST(), OS);
+
+  IncludeStrongLifetimeRAII Strong(Policy);
+  T->getTemplateName().print(OS, Policy);
+  spaceBeforePlaceHolder(OS);
 }
 
 void TypePrinter::printInjectedClassNameAfter(const InjectedClassNameType *T,
Index: clang/include/clang/AST/PrettyPrinter.h
===
--- clang/include/clang/AST/PrettyPrinter.h
+++ clang/include/clang

[PATCH] D78785: Fix x86/x86_64 calling convention for _ExtInt

2020-04-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2980
 
-return (Ty->isPromotableIntegerType() ? ABIArgInfo::getExtend(Ty)
-  : ABIArgInfo::getDirect());
+if (!Ty->isExtIntType())
+  return (Ty->isPromotableIntegerType() ? ABIArgInfo::getExtend(Ty)

rjmccall wrote:
> erichkeane wrote:
> > rjmccall wrote:
> > > Presumably *some* `ExtInt` types should be returned directly.
> > Right, and they are.  This is only for cases where we request an 'indirect 
> > result', so cases where we've already decided that it cannot be passed 
> > direct.
> > 
> > At this point, the 'classify' step has already been done, which would have 
> > decided that <=128 bit values are passed 'direct', and we've requested an 
> > indirect.  At least as far as I can tell from this code/debugging.
> Oh, I see.  So the current code is intentionally using a direct IR return in 
> some cases and then allowing LLVM to lower it as an indirect return?  I 
> didn't think we ever did that, and I'm really not sure it's a good idea, so I 
> definitely agree with not doing it for ExtInt types.
Right, exactly :)  FWIW, this is my 3rd time looking into this TargetInfo code, 
and it is particularly convoluted. If I understood the calling conventions 
sufficiently, I'd take a run at trying to figure out how to make this not so 
messy.


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

https://reviews.llvm.org/D78785



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


[PATCH] D78508: [Clang] Allow long as size_t printf argument on 32-bit Windows platforms.

2020-04-27 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

Ping, @rnk?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78508



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 reopened this revision.
gamesh411 added a comment.
This revision is now accepted and ready to land.

Non-linux buildbots were utterly broken :( . Trying to fix them...

Thanks for reverting this for me :)
Also I will investigate the possibility to not depend on Tooling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D77229#2005042 , @NoQ wrote:

> > no crashes but 130 of 550 analyzer tests failing.
>
> You most likely need to fill in the reachibility and liveness code with the 
> behavior of the new region. I don't seem to see it in your current code but 
> their default behavior is clearly incorrect; instead, they should behave 
> exactly like the old region used to.


That sound a lot of code duplication for me.


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

https://reviews.llvm.org/D77229



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


[PATCH] D78350: [AST] Build recovery expressions by default for C++.

2020-04-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 260306.
hokein added a comment.

rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78350

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_namespace_1.cpp
  clang/test/CXX/class.access/p4.cpp
  clang/test/CXX/special/class.ctor/p5-0x.cpp
  clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constructor-initializer.cpp
  clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/for-range-dereference.cpp
  clang/test/SemaCXX/recovery-default-init.cpp
  clang/test/SemaCXX/recovery-initializer.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaCXX/virtual-base-used.cpp
  clang/test/SemaObjCXX/arc-0x.mm
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-init.cpp

Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -108,7 +108,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -11,7 +11,7 @@
 int bar(const unsigned int &i);
 
 void foo() {
-  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
 
 // Test addr space conversion with nested pointers
Index: clang/test/SemaObjCXX/arc-0x.mm
===
--- clang/test/SemaObjCXX/arc-0x.mm
+++ clang/test/SemaObjCXX/arc-0x.mm
@@ -116,13 +116,13 @@
   // Implicitly-declared special functions of a union are deleted by default if
   // ARC is enabled and the union has an ObjC pointer field.
   union U0 {
-id f0; // expected-note 7 {{'U0' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+id f0; // expected-note 6 {{'U0' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
   };
 
   union U1 {
-__weak id f0; // expected-note 13 {{'U1' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+__weak id f0; // expected-note 12 {{'U1' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
 U1() = default; // expected-warning {{explicitly defaulted default constructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
-~U1() = default; // expected-warning {{explicitly defaulted destructor is implicitly deleted}} expected-note 2{{explicitly defaulted function was implicitly deleted here}}
+~U1() = default; // expected-warning {{explicitly defaulted destructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
 U1(const U1 &) = default; // expected-warning {{explicitly defaulted copy constructor is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
 U1(U1 &&) = default; // expected-warning {{explicitly defaulted move constructor is implicitly deleted}}
 U1 & operator=(const U1 &) = default; // expected-warning {{explicitly defaulted copy assignment operator is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
@@ -154,15 +154,15 @@
   // functions of the containing class.
   struct S0 {
 union {
-  id f0; // expected-note 7 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  id f0; // expected-note 6 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
   char f1;
 };
   }

[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D77229#2005042 , @NoQ wrote:

> > no crashes but 130 of 550 analyzer tests failing.
>
> You most likely need to fill in the reachibility and liveness code with the 
> behavior of the new region. I don't seem to see it in your current code but 
> their default behavior is clearly incorrect; instead, they should behave 
> exactly like the old region used to.


Do you mean the `getBinding...()` function of `RegionStore` and the 
`isLive...()` functions of `SymbolManager`?


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

https://reviews.llvm.org/D77229



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 260310.
gamesh411 added a comment.

[NFC] Fix arcanist double commit revisioning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665

Files:
  clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/CrossTU/CMakeLists.txt
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Analysis/Inputs/ctu-other.c
  clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/ctu-different-triples.cpp
  clang/test/Analysis/ctu-main.c
  clang/test/Analysis/ctu-main.cpp
  clang/test/Analysis/ctu-on-demand-parsing-ambigous-compilation-database.c
  clang/test/Analysis/ctu-on-demand-parsing.c
  clang/test/Analysis/ctu-on-demand-parsing.cpp
  clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
  clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -7,10 +7,11 @@
 //===--===//
 
 #include "clang/CrossTU/CrossTranslationUnit.h"
-#include "clang/Frontend/CompilerInstance.h"
 #include "clang/AST/ASTConsumer.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -162,7 +163,7 @@
   IndexFile.os().flush();
   EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
   llvm::Expected> IndexOrErr =
-  parseCrossTUIndex(IndexFileName, "");
+  parseCrossTUIndex(IndexFileName);
   EXPECT_TRUE((bool)IndexOrErr);
   llvm::StringMap ParsedIndex = IndexOrErr.get();
   for (const auto &E : Index) {
@@ -173,25 +174,5 @@
 EXPECT_TRUE(Index.count(E.getKey()));
 }
 
-TEST(CrossTranslationUnit, CTUDirIsHandledCorrectly) {
-  llvm::StringMap Index;
-  Index["a"] = "/b/c/d";
-  std::string IndexText = createCrossTUIndexString(Index);
-
-  int IndexFD;
-  llvm::SmallString<256> IndexFileName;
-  ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("index", "txt", IndexFD,
-  IndexFileName));
-  llvm::ToolOutputFile IndexFile(IndexFileName, IndexFD);
-  IndexFile.os() << IndexText;
-  IndexFile.os().flush();
-  EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
-  llvm::Expected> IndexOrErr =
-  parseCrossTUIndex(IndexFileName, "/ctudir");
-  EXPECT_TRUE((bool)IndexOrErr);
-  llvm::StringMap ParsedIndex = IndexOrErr.get();
-  EXPECT_EQ(ParsedIndex["a"], "/ctudir/b/c/d");
-}
-
 } // end namespace cross_tu
 } // end namespace clang
Index: clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
===
--- clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
+++ clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
@@ -5,7 +5,7 @@
 // RUN: mkdir -p %t/ctudir
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
 // RUN:   -emit-pch -o %t/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
-// RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.txt %t/ctudir/externalDefMap.txt
+// RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
 // RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
Index: clang/test/Analysis/ctu-on-demand-parsing.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-on-demand-parsing.cpp
@@ -0,0 +1,102 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/ctudir
+// RUN: cp %s %t/ctu-on-demand-parsing.cpp
+// RUN: cp %S/ctu-hdr.h %t/ctu-hdr.h
+// RUN: cp %S/Inputs/ctu-chain.cpp %t/ctudir/ctu-chain.cpp
+// RUN: cp %S/Inputs/ctu-other.cpp %t/ctudir/ctu-other.cpp
+// Path substitutions on Windows platform could contain backslashes. These are escaped in the json file.
+// RUN: echo '[{"directory":"%t/ctudir","command":"clang++ -c ctu-chain.cpp","file":"ctu-chain.cpp"},{"directory":"%t/ctudir","command":"clang++ -c ctu-other.cpp","file":"ctu-other.cpp"}]' | sed -e 's/\\//g' > %t/compile_commands.json
+// RUN: cd "%t/ctudir" && %clang_extdef_map ctu-chain.cpp ctu-other.cpp > externalDefMap.txt
+// RUN: cd "%t" && %clang

[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 260308.
gamesh411 added a comment.

Remove platform constraint from test file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665

Files:
  clang/test/Analysis/ctu-on-demand-parsing.c
  clang/test/Analysis/ctu-on-demand-parsing.cpp


Index: clang/test/Analysis/ctu-on-demand-parsing.cpp
===
--- clang/test/Analysis/ctu-on-demand-parsing.cpp
+++ clang/test/Analysis/ctu-on-demand-parsing.cpp
@@ -7,7 +7,7 @@
 // Path substitutions on Windows platform could contain backslashes. These are 
escaped in the json file.
 // RUN: echo '[{"directory":"%t/ctudir","command":"clang++ -c 
ctu-chain.cpp","file":"ctu-chain.cpp"},{"directory":"%t/ctudir","command":"clang++
 -c ctu-other.cpp","file":"ctu-other.cpp"}]' | sed -e 's/\\//g' > 
%t/compile_commands.json
 // RUN: cd "%t/ctudir" && %clang_extdef_map ctu-chain.cpp ctu-other.cpp > 
externalDefMap.txt
-// RUN: cd "%t" && %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN: cd "%t" && %clang_analyze_cc1 \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
 // RUN:   -analyzer-config ctu-dir=ctudir \
Index: clang/test/Analysis/ctu-on-demand-parsing.c
===
--- clang/test/Analysis/ctu-on-demand-parsing.c
+++ clang/test/Analysis/ctu-on-demand-parsing.c
@@ -5,7 +5,7 @@
 // Path substitutions on Windows platform could contain backslashes. These are 
escaped in the json file.
 // RUN: echo '[{"directory":"%t","command":"gcc -c -std=c89 -Wno-visibility 
ctu-other.c","file":"ctu-other.c"}]' | sed -e 's/\\//g' > 
%t/compile_commands.json
 // RUN: cd "%t" && %clang_extdef_map ctu-other.c > externalDefMap.txt
-// RUN: cd "%t" && %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only 
-std=c89 -analyze \
+// RUN: cd "%t" && %clang_cc1 -fsyntax-only -std=c89 -analyze \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
 // RUN:   -analyzer-config ctu-dir=. \


Index: clang/test/Analysis/ctu-on-demand-parsing.cpp
===
--- clang/test/Analysis/ctu-on-demand-parsing.cpp
+++ clang/test/Analysis/ctu-on-demand-parsing.cpp
@@ -7,7 +7,7 @@
 // Path substitutions on Windows platform could contain backslashes. These are escaped in the json file.
 // RUN: echo '[{"directory":"%t/ctudir","command":"clang++ -c ctu-chain.cpp","file":"ctu-chain.cpp"},{"directory":"%t/ctudir","command":"clang++ -c ctu-other.cpp","file":"ctu-other.cpp"}]' | sed -e 's/\\//g' > %t/compile_commands.json
 // RUN: cd "%t/ctudir" && %clang_extdef_map ctu-chain.cpp ctu-other.cpp > externalDefMap.txt
-// RUN: cd "%t" && %clang_analyze_cc1 -triple x86_64-pc-linux-gnu \
+// RUN: cd "%t" && %clang_analyze_cc1 \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
 // RUN:   -analyzer-config ctu-dir=ctudir \
Index: clang/test/Analysis/ctu-on-demand-parsing.c
===
--- clang/test/Analysis/ctu-on-demand-parsing.c
+++ clang/test/Analysis/ctu-on-demand-parsing.c
@@ -5,7 +5,7 @@
 // Path substitutions on Windows platform could contain backslashes. These are escaped in the json file.
 // RUN: echo '[{"directory":"%t","command":"gcc -c -std=c89 -Wno-visibility ctu-other.c","file":"ctu-other.c"}]' | sed -e 's/\\//g' > %t/compile_commands.json
 // RUN: cd "%t" && %clang_extdef_map ctu-other.c > externalDefMap.txt
-// RUN: cd "%t" && %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -std=c89 -analyze \
+// RUN: cd "%t" && %clang_cc1 -fsyntax-only -std=c89 -analyze \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
 // RUN:   -analyzer-config ctu-dir=. \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78915: [clang-format] Improved parser for C# properties

2020-04-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added a comment.
This revision now requires changes to proceed.

Can you please clang-format the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78915



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


[PATCH] D72326: [clang-format] Rebased on master: Add option to specify explicit config file

2020-04-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Were you able to rerun these tests?


Repository:
  rC Clang

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

https://reviews.llvm.org/D72326



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


[PATCH] D76801: [AST] Print a> without extra spaces in C++11 or later.

2020-04-27 Thread Pavel Labath via Phabricator via cfe-commits
labath added a comment.

In D76801#1997451 , @dblaikie wrote:

> Yeah, points all taken - as for this actual issue... I'm kind of inclined to 
> say "hey, our template names already diverge somewhat - and this divergence 
> is in the realm of acceptable by gdb (without an index) so... *thumbs 
> up*/let's stick with it"


Another interesting aspect here is that the DW_AT_name outputs depend on the 
c++ standard versions used. This means we could get mismatches even with the 
same compiler if some compile units use `-std=c++98`, and others `-std>=c++11` 
(hardly a recommended practice but it does work if one knows what he is doing). 
Compatibility with another compiler is one thing, but maybe self-compatibility 
is more important (and easier to achieve) ?

One way to  achieve that would be by printing all type names in c++98 mode, 
which (IIUC) is the same thing as what the windows folks are requesting..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76801



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


[PATCH] D78915: [clang-format] Improved parser for C# properties

2020-04-27 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 260316.
jbcoe added a comment.

Format patch.


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

https://reviews.llvm.org/D78915

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -611,6 +611,64 @@
 public string Name {
   get => _name;
   set => _name = value;
+})",
+   Style);
+
+  // Examples taken from
+  // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
+  verifyFormat(R"(
+// Expression body definitions
+public class SaleItem {
+  public decimal Price {
+get => _cost;
+set => _cost = value;
+  }
+})",
+   Style);
+
+  verifyFormat(R"(
+// Properties with backing fields
+class TimePeriod {
+  public double Hours {
+get { return _seconds / 3600; }
+set {
+  if (value < 0 || value > 24)
+throw new ArgumentOutOfRangeException(
+$"{nameof(value)} must be between 0 and 24.");
+  _seconds = value * 3600;
+}
+  }
+})",
+   Style);
+
+  verifyFormat(R"(
+// Auto-implemented properties
+public class SaleItem {
+  public decimal Price { get; set; }
+})",
+   Style);
+
+  // Add column limit to wrap long lines.
+  Style.ColumnLimit = 100;
+
+  // Examples with assignment to default value.
+  verifyFormat(R"(
+// Long assignment to default value
+class MyClass {
+  public override VeryLongNamedTypeIndeed VeryLongNamedValue { get; set } =
+  VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, DefaultSecondArgument,
+ DefaultThirdArgument);
+})",
+   Style);
+
+  verifyFormat(R"(
+// Long assignment to default value with expression body
+class MyClass {
+  public override VeryLongNamedTypeIndeed VeryLongNamedValue {
+get => veryLongNamedField;
+set => veryLongNamedField = value;
+  } = VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, DefaultSecondArgument,
+ DefaultThirdArgument);
 })",
Style);
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "UnwrappedLineParser.h"
+#include "FormatToken.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -1495,9 +1496,7 @@
   if (FormatTok->Previous->isNot(tok::identifier))
 return false;
 
-  // Try to parse the property accessor braces and contents:
-  // `{ get; set; } = new MyType(defaultValue);`
-  //  ^
+  // See if we are inside a property accessor.
   //
   // Record the current tokenPosition so that we can advance and
   // reset the current token. `Next` is not set yet so we need
@@ -1506,19 +1505,20 @@
   FormatToken *Tok = Tokens->getNextToken();
 
   bool HasGetOrSet = false;
+  bool IsTrivialPropertyAccessor = true;
   while (!eof()) {
 if (Tok->isOneOf(tok::semi, tok::kw_public, tok::kw_private,
  tok::kw_protected, Keywords.kw_internal, Keywords.kw_get,
  Keywords.kw_set)) {
-  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_set))
+  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_set)) {
 HasGetOrSet = true;
+  }
   Tok = Tokens->getNextToken();
   continue;
 }
-if (Tok->is(tok::r_brace))
-  break;
-Tokens->setPosition(StoredPosition);
-return false;
+if (Tok->isNot(tok::r_brace))
+  IsTrivialPropertyAccessor = false;
+break;
   }
 
   if (!HasGetOrSet) {
@@ -1526,33 +1526,53 @@
 return false;
   }
 
-  Tokens->setPosition(StoredPosition);
-  while (FormatTok->isNot(tok::r_brace)) {
-nextToken();
-  }
-
-  // Try to parse (optional) assignment to default value:
+  // Try to parse the property accessor:
   // `{ get; set; } = new MyType(defaultValue);`
-  //^^^
-  // There may be some very complicated expressions inside default value
-  // assignment, the simple parse block below will not handle them.
-  // The parse block below would need extending to handle opening parens etc.
-  StoredPosition = Tokens->getPosition();
-  Tok = Tokens->getNextToken();
-  bool NextTokenIsEqual = Tok->is(tok::equal);
   Tokens->setPosition(StoredPosition);
-
-  if (NextTokenIsEqual) {
-do {
+  nextToken();
+  do {
+switch (FormatTok->Tok.getKind()) {
+case tok::r_brace:
   nextToken();
-  if (FormatTok->is(tok::semi))
+  if (FormatTok->is(tok::equal)) {
+while (!eof() && FormatTok->isNot(tok::se

[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-27 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 marked an inline comment as done.
gamesh411 added inline comments.



Comment at: clang/lib/CrossTU/CMakeLists.txt:13
   clangIndex
+  clangTooling
+  clangSerialization

thakis wrote:
> We've been very careful to make clang (the compiler binary) only depend on 
> clangToolingCore and not on the much bigger clangTooling library. Since clang 
> depends on the CrossTU library, this breaks that. Can you reorganize things 
> so that we don't need a dependency from clang-the-compiler-binary on 
> clangTooling?
I have gone, and investigated where the main functionality of on-demand AST 
loading comes from. (Only after wishfully thinking changing the dependency from 
`clangTooling` to `clangToolingCore` would work, which of course didnt't )

It seems that this functionality used the major components of `clangTooling`, 
namely `JSONCompilationDatabase::loadFromFile`, `ClangTool ctor/dtor`, 
`ClangTool::buildAST`.
In order to circumvent the dependency and the reimplementation of handling 
compilation databases, a call to an external tool could be used, or the 
clangTooling library would need to be refactored in a way which is not a very 
tasteful refactoring. IMHO. I would like to know which of the aforementioned 
way is deemed to be best.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D77229#2004964 , 
@baloghadamsoftware wrote:

> This is not the proper way, `MemRegion`s for parameters in inlined functions 
> should remain `VarRegion`s because parameters **are** variables inside. On 
> the other hand, from outside it does not matter what kind of regions they 
> are. We mainly need the region there to use it as key for `GDM` maps. That is 
> why `ParamRegion`s should only be created for functions that are not inlined. 
> If they have no definition then they cannot be inlined so a `ParamRegion` is 
> OK for them. However, if they have a definition then there is no problem 
> finding the same `Decl` because the definition is that same `Decl` that we 
> use everywhere so it can and should remain a `VarRegion`.


I'm not opposed to this solution. I'm not sure it's actually easier; i agree 
that it may even be less code but because i already tried to do this and 
failed, i'm worried that the tail of regressions may actually be longer.

That said, as of now you cannot know in advance whether the function will be 
inlined or not. "Having a definition" is probably the best approximation that 
you'll ever get.

Also it complicates the construction of the region, given that in order to 
figure out whether we have a definition you suddenly need access to the 
`Environment` (in case of inlined calls by function pointers you cannot figure 
out from the AST whether we have a definition or not) which is a fairly 
unfortunate layering violation. Is such information always available in all the 
places in which we want to reconstruct the region? Will it always be available? 
How will you ensure that?

Also please check if the following example behaves correctly:

  class C { ... };
  
  void foo(C, int) {}
  
  int set_foo_ptr(void (**func)(C, int)) {
*func = foo;
return 0;
  }
  
  void bar() {
void (*func)(C, int);
func(C(), set_foo_ptr(&func));
  }

What's the evaluation order here? Do we actually invoke `foo()` from `bar()` 
here or do we read from the `func` variable before assigning into it thus 
causing a call to uninitialized pointer? In the former case your plan is doomed 
because you need a region into which `C()` lands earlier than you get to know 
any `Decl` at all.


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

https://reviews.llvm.org/D77229



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


[clang] 8c8aae8 - Revert "recommit c77a4078e01033aa2206c31a579d217c8a07569b"

2020-04-27 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-04-27T16:41:35+02:00
New Revision: 8c8aae852b5e60929156054808af941fc0745d46

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

LOG: Revert "recommit c77a4078e01033aa2206c31a579d217c8a07569b"

This reverts commit b46b1a916d44216f0c70de55ae2123eb9de69027. It broke
overload resolution for operator 'new' -- see reproducer in
https://reviews.llvm.org/D77954.

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCUDA/function-overload.cu

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index ecc4e7ee19fb..a32bc0c84c70 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9374,22 +9374,16 @@ static Comparison compareEnableIfAttrs(const Sema &S, 
const FunctionDecl *Cand1,
   return Comparison::Equal;
 }
 
-static Comparison
-isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
-  const OverloadCandidate &Cand2) {
+static bool isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
+  const OverloadCandidate &Cand2) {
   if (!Cand1.Function || !Cand1.Function->isMultiVersion() || !Cand2.Function 
||
   !Cand2.Function->isMultiVersion())
-return Comparison::Equal;
+return false;
 
-  // If both are invalid, they are equal. If one of them is invalid, the other
-  // is better.
-  if (Cand1.Function->isInvalidDecl()) {
-if (Cand2.Function->isInvalidDecl())
-  return Comparison::Equal;
-return Comparison::Worse;
-  }
-  if (Cand2.Function->isInvalidDecl())
-return Comparison::Better;
+  // If Cand1 is invalid, it cannot be a better match, if Cand2 is invalid, 
this
+  // is obviously better.
+  if (Cand1.Function->isInvalidDecl()) return false;
+  if (Cand2.Function->isInvalidDecl()) return true;
 
   // If this is a cpu_dispatch/cpu_specific multiversion situation, prefer
   // cpu_dispatch, else arbitrarily based on the identifiers.
@@ -9399,18 +9393,16 @@ isBetterMultiversionCandidate(const OverloadCandidate 
&Cand1,
   const auto *Cand2CPUSpec = Cand2.Function->getAttr();
 
   if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
-return Comparison::Equal;
+return false;
 
   if (Cand1CPUDisp && !Cand2CPUDisp)
-return Comparison::Better;
+return true;
   if (Cand2CPUDisp && !Cand1CPUDisp)
-return Comparison::Worse;
+return false;
 
   if (Cand1CPUSpec && Cand2CPUSpec) {
 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
-  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
- ? Comparison::Better
- : Comparison::Worse;
+  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size();
 
 std::pair
 FirstDiff = std::mismatch(
@@ -9423,9 +9415,7 @@ isBetterMultiversionCandidate(const OverloadCandidate 
&Cand1,
 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
"Two 
diff erent cpu-specific versions should not have the same "
"identifier list, otherwise they'd be the same decl!");
-return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
-   ? Comparison::Better
-   : Comparison::Worse;
+return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName();
   }
   llvm_unreachable("No way to get here unless both had cpu_dispatch");
 }
@@ -9485,50 +9475,6 @@ bool clang::isBetterOverloadCandidate(
   else if (!Cand1.Viable)
 return false;
 
-  // [CUDA] A function with 'never' preference is marked not viable, therefore
-  // is never shown up here. The worst preference shown up here is 'wrong 
side',
-  // e.g. a host function called by a device host function in device
-  // compilation. This is valid AST as long as the host device function is not
-  // emitted, e.g. it is an inline function which is called only by a host
-  // function. A deferred diagnostic will be triggered if it is emitted.
-  // However a wrong-sided function is still a viable candidate here.
-  //
-  // If Cand1 can be emitted and Cand2 cannot be emitted in the current
-  // context, Cand1 is better than Cand2. If Cand1 can not be emitted and Cand2
-  // can be emitted, Cand1 is not better than Cand2. This rule should have
-  // precedence over other rules.
-  //
-  // If both Cand1 and Cand2 can be emitted, or neither can be emitted, then
-  // other rules should be used to determine which is better. This is because
-  // host/device based overloading resolution is mostly for determining
-  // viability of a function. If two functions are both viable, other factors
-  // should take precedence in preference, e.g. the standard-defined 
preferences
-  // like argument conversion ranks or e

[PATCH] D78546: Enable bugprone-argument-comments check in llvm.

2020-04-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

> LLVM code style encourages this

Not very strongly, it just says it can be helpful (and tells you how to do it 
if you do it). So I'm wary of making it mandatory in cases where it isn't a 
clear readability win.

Had a look at this on clangd code:

- the basic no-options functionality (wrong name for comment) looks good - some 
of them don't matter much, but didn't find any where the fix made it worse
- the single-argument cases were almost all false positives, that flag should 
be flipped
  - but it seems to count parameters rather than arguments so `foo.substr(1)` 
still fires
- this is no good for standard library functions, because (at least with 
libstdc++):
  - there are leading underscores in the names, these are ignored for matching 
but included in suggestions
  - the standard doesn't really define the names (at least implementations 
don't match cppreference) so the check results aren't portable
  - e.g. it fired on basic_string(/*Repeat=*/..., 'x') and wanted Repeat 
replaced with `__n`.
- things of the form `range(0, foo.size())` => `range(/*Start=*/0, foo.size())` 
seem unhelpful

I think this would be a better check if we **increased the arg threshold to 3** 
and **excluded functions in namespace std**.
As it is I'm not sure whether it does more good than harm. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78546



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D77229#2005218 , 
@baloghadamsoftware wrote:

> In D77229#2005042 , @NoQ wrote:
>
> > > no crashes but 130 of 550 analyzer tests failing.
> >
> > You most likely need to fill in the reachibility and liveness code with the 
> > behavior of the new region. I don't seem to see it in your current code but 
> > their default behavior is clearly incorrect; instead, they should behave 
> > exactly like the old region used to.
>
>
> Do you mean the `getBinding...()` function of `RegionStore` and the 
> `isLive...()` functions of `SymbolManager`?


Yup, you're right, i should have mentioned basically the whole RegionStore's 
load/store process instead of just the escape/invalidation process that relies 
on reachibility.


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

https://reviews.llvm.org/D77229



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


[PATCH] D77954: [CUDA][HIP] Fix host/device based overload resolution

2020-04-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Sorry -- this change broke overload resolution for `operator new`, as it is 
declared in system headers. I'm reverting the patch.

  $ cat /tmp/in.cu.cc
  #define __device__ __attribute__((device))
  void* operator new(__SIZE_TYPE__ size);
  __device__ void *operator new(__SIZE_TYPE__ size);
  void *x = new int;
  $ clang -fsyntax-only --cuda-device-only --target=x86_64-grtev4-linux-gnu -x 
cuda -nocudalib -nocudainc -std=gnu++17 /tmp/in.cu.cc
  /tmp/in.cu.cc:4:11: error: call to 'operator new' is ambiguous
  void *x = new int;
^
  /tmp/in.cu.cc:2:7: note: candidate function
  void* operator new(__SIZE_TYPE__ size);
^
  /tmp/in.cu.cc:3:18: note: candidate function
  __device__ void *operator new(__SIZE_TYPE__ size);
   ^
  1 error generated when compiling for sm_20.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77954



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


[clang] 334ac81 - Fix the check for regparm in FunctionType::ExtInfo

2020-04-27 Thread Momchil Velikov via cfe-commits

Author: Momchil Velikov
Date: 2020-04-27T16:01:07+01:00
New Revision: 334ac81054018c3ae6058a0bf12e9c9363bd50ad

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

LOG: Fix the check for regparm in FunctionType::ExtInfo

`getHasRegParm()` was working under the assumption that the RegParm
bits are the last field, which is no longer true, after adding the
`NoCfCheck` and `CmseNSCall` fields.

This causes a spurious "regparm 0" attribute to appear when a function
type is declared with either `__attribute__((nocf_check))` or
`__attribute__((cmse_nonsecure_call))`.

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

Added: 
clang/test/AST/spurious-regparm.c

Modified: 
clang/include/clang/AST/Type.h

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index cf746d9b947a..08522a670c99 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3518,13 +3518,12 @@ class FunctionType : public Type {
 enum { NoReturnMask = 0x20 };
 enum { ProducesResultMask = 0x40 };
 enum { NoCallerSavedRegsMask = 0x80 };
-enum { NoCfCheckMask = 0x800 };
-enum { CmseNSCallMask = 0x1000 };
 enum {
-  RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask |
-  NoCallerSavedRegsMask | NoCfCheckMask | CmseNSCallMask),
+  RegParmMask =  0x700,
   RegParmOffset = 8
-}; // Assumed to be the last field
+};
+enum { NoCfCheckMask = 0x800 };
+enum { CmseNSCallMask = 0x1000 };
 uint16_t Bits = CC_C;
 
 ExtInfo(unsigned Bits) : Bits(static_cast(Bits)) {}
@@ -3557,7 +3556,7 @@ class FunctionType : public Type {
 bool getCmseNSCall() const { return Bits & CmseNSCallMask; }
 bool getNoCallerSavedRegs() const { return Bits & NoCallerSavedRegsMask; }
 bool getNoCfCheck() const { return Bits & NoCfCheckMask; }
-bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; }
+bool getHasRegParm() const { return ((Bits & RegParmMask) >> 
RegParmOffset) != 0; }
 
 unsigned getRegParm() const {
   unsigned RegParm = (Bits & RegParmMask) >> RegParmOffset;

diff  --git a/clang/test/AST/spurious-regparm.c 
b/clang/test/AST/spurious-regparm.c
new file mode 100644
index ..4ae23f017241
--- /dev/null
+++ b/clang/test/AST/spurious-regparm.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple armv8.1m.main-eabi -mcmse -fsyntax-only %s 
-ast-dump | FileCheck %s
+// REQUIRES: arm-registered-target
+typedef int (*fn_t)(int) __attribute__((cmse_nonsecure_call));
+// CHECK-NOT: regparm 0



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


[PATCH] D78508: [Clang] Allow long as size_t printf argument on 32-bit Windows platforms.

2020-04-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Personally, I don't consider those to be useless casts. They appropriately 
ensure that the types match between the arguments and the format specifiers, 
rather than relying on underlying details of what SIZE_T expands to for a given 
target. I would expect these to at least use the 
`warn_format_conversion_argument_type_mismatch_confusion` diagnostic rather 
than be silenced entirely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78508



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


[PATCH] D78190: Add Bfloat IR type

2020-04-27 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 260326.
stuij added a comment.

addressed comments: throughout the patch changed the string `Bfloat` to 
`BFloat`, expanded description of bfloat in the documentation, addressed misc 
comments.

also added `Type *getBFloatTy()` to IRBuilder.h

thanks for the comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78190

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/ADT/APFloat.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/MIRParser/MILexer.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/LLVMContextImpl.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Type.cpp
  llvm/lib/Support/APFloat.cpp
  llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/Assembler/bfloat.ll
  llvm/tools/llvm-c-test/echo.cpp

Index: llvm/tools/llvm-c-test/echo.cpp
===
--- llvm/tools/llvm-c-test/echo.cpp
+++ llvm/tools/llvm-c-test/echo.cpp
@@ -72,6 +72,8 @@
 return LLVMVoidTypeInContext(Ctx);
   case LLVMHalfTypeKind:
 return LLVMHalfTypeInContext(Ctx);
+  case LLVMBFloatTypeKind:
+return LLVMHalfTypeInContext(Ctx);
   case LLVMFloatTypeKind:
 return LLVMFloatTypeInContext(Ctx);
   case LLVMDoubleTypeKind:
Index: llvm/test/Assembler/bfloat.ll
===
--- /dev/null
+++ llvm/test/Assembler/bfloat.ll
@@ -0,0 +1,26 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s --check-prefix=ASSEM-DISASS
+; RUN: opt < %s -O3 -S | FileCheck %s --check-prefix=OPT
+; RUN: verify-uselistorder %s
+; Basic smoke tests for bfloat type.
+
+define bfloat @check_bfloat(bfloat %A) {
+; ASSEM-DISASS: ret bfloat %A
+ret bfloat %A
+}
+
+define bfloat @check_bfloat_literal() {
+; ASSEM-DISASS: ret bfloat 0xR3149
+ret bfloat 0xR3149
+}
+
+define bfloat @check_bfloat_constprop() {
+  %tmp = fadd bfloat 0xR40C0, 0xR40C0
+; OPT: 0xR4140
+  ret bfloat %tmp
+}
+
+define float @check_bfloat_convert() {
+  %tmp = fpext bfloat 0xR4C8D to float
+; OPT: 0x4191A000
+  ret float %tmp
+}
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -11460,8 +11460,9 @@
   MVT LogicVT = VT;
   if (EltVT == MVT::f32 || EltVT == MVT::f64) {
 Zero = DAG.getConstantFP(0.0, DL, EltVT);
-AllOnes = DAG.getConstantFP(
-APFloat::getAllOnesValue(EltVT.getSizeInBits(), true), DL, EltVT);
+APFloat AllOnesValue = APFloat::getAllOnesValue(
+SelectionDAG::EVTToAPFloatSemantics(EltVT), EltVT.getSizeInBits());
+AllOnes = DAG.getConstantFP(AllOnesValue, DL, EltVT);
 LogicVT =
 MVT::getVectorVT(EltVT == MVT::f64 ? MVT::i64 : MVT::i32, Mask.size());
   } else {
Index: llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
===
--- llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
+++ llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
@@ -323,6 +323,7 @@
   }
   case Type::FunctionTyID:
   case Type::VoidTyID:
+  case Type::BFloatTyID:
   case Type::X86_FP80TyID:
   case Type::FP128TyID:
   case Type::PPC_FP128TyID:
Index: llvm/lib/Support/APFloat.cpp
===
--- llvm/lib/Support/APFloat.cpp
+++ llvm/lib/Support/APFloat.cpp
@@ -69,6 +69,7 @@
   };
 
   static const fltSemantics semIEEEhalf = {15, -14, 11, 16};
+  static const fltSemantics semBFloat = {127, -126, 8, 16};
   static const fltSemantics semIEEEsingle = {127, -126, 24, 32};
   static const fltSemantics semIEEEdouble = {1023, -1022, 53, 64};
   static const fltSemantics semIEEEquad = {16383, -16382, 113, 128};
@@ -117,6 +118,8 @@
 switch (S) {
 case S_IEEEhalf:
   return IEEEhalf();
+case S_BFloat:
+  return BFloat();
 case S_IEEEsingle:
   return IEEEsingle();
 case S_IEEEdouble:
@@ -135,6 +138,8 @@
   APFloatBase::SemanticsToEnum(const llvm::fltSemantics &Sem) {
 if (&Sem == &llvm::APFloat::IEEEhalf())
   return S_IEEEhalf;
+else if (&Sem == &llvm::APFloat::BFloat())
+  return S_BFloat;
 else if (&Sem == &llvm::APFloat::IEEEsingle())
   return S_IEEEsingle;
 else if (&Sem == &llvm::APFloat::IEEEdouble())
@@ -152,6 +157,

[PATCH] D78933: RangeConstraintManager optimizations in comparison expressions

2020-04-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: NoQ, baloghadamsoftware, steakhal, xazax.hun.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, martong, Charusso, rnkovacs.

I got an idea how to make RangeConstraintManager​ more sofisticated.
I want you speak out, share your vision about this idea.

The idea came to me as a thing which resolves this bug PR13426 
.
Let's consider the next snippet:

  int foo(int y, int x) {
  int x;
  if (y == z) {
  x = 0;
  }
  if (y != z) {
  x = 1;
  }
  return x;
  }

Obviously that `x` will be initialized, but CSA reports next:

  warning: Undefined or garbage value returned to caller
[core.uninitialized.UndefReturn]
  return x;

It happenes because CSA does not take into account that `y == z` and `y != z` 
are just two **opposites**, as if it was:

  if (y == z) {
  x = 0;
  } else {
  x = 1;
  }

So my improvments is in handling case above and similar ones.
This patch covers next:

- Consider comparisons such as `x > y` and `y < x` as **reversed** copy and 
generates a //true// branch only. Applies to `< > <= >= == !=`.
- Consider comparisons such as `x > y` and `x < y`, `x <= y`, `x == y`,  `y > 
x`,  `y >= x`,  `y == x` as **opposites** and generates a //false// branch 
only. Applies to `< > <= >= == !=`.

As a result of processing an example below, we have F11810767: before.html 
 and F11810762: after.html 
 exploded graphs.

  void foo(int y, int x) {
  int z;
  if (x > y) {
  if (y > x) {
  z = 1;
  }
  if (y >= x) {
  z = 2;
  }
  if (y == x) {
  z = 3;
  }
  }
  else{
  if (y > x) {
  z = 1;
  }
  if (y >= x) {
  z = 2;
  }
  if (y == x) {
  z = 3;
  }
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78933

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint_manager_conditions.cpp

Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- /dev/null
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -0,0 +1,109 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+//reversed
+
+void comparison_reversed_gt(int x, int y) {
+  if (x > y)
+clang_analyzer_eval(y < x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y < x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_ge(int x, int y) {
+  if (x >= y)
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_lt(int x, int y) {
+  if (x < y)
+clang_analyzer_eval(y > x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_le(int x, int y) {
+  if (x <= y)
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_eq(int x, int y) {
+  if (x == y)
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_ne(int x, int y) {
+  if (x != y)
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
+}
+
+//opposite
+
+void comparison_opposite_gt(int x, int y) {
+  if (x > y) {
+clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
+  } else {
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+  }
+}
+
+void comparison_opposite_ge(int x, int y) {
+  if (x >= y) {
+clang_analyzer_eval(x < y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
+  } else {
+clang_analyzer_eval(x < y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y > x); // expected-warning{{TRUE}}
+  }
+}
+
+void comparison_opposite_lt(int x, int y) {
+  if (x < y) {
+clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
+  } else {
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+  }
+}
+
+void comparison_opposite_le(int x, int y) {
+  if (x <= y) {
+clang_analyzer_eval(x > y); // expected-warning{{FALSE}}
+clang_an

[PATCH] D78933: RangeConstraintManager optimizations in comparison expressions

2020-04-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 260331.

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

https://reviews.llvm.org/D78933

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint_manager_conditions.cpp

Index: clang/test/Analysis/constraint_manager_conditions.cpp
===
--- /dev/null
+++ clang/test/Analysis/constraint_manager_conditions.cpp
@@ -0,0 +1,133 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+//reversed
+
+void comparison_reversed_gt(int x, int y) {
+  if (x > y)
+clang_analyzer_eval(y < x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y < x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_ge(int x, int y) {
+  if (x >= y)
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_lt(int x, int y) {
+  if (x < y)
+clang_analyzer_eval(y > x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_le(int x, int y) {
+  if (x <= y)
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_eq(int x, int y) {
+  if (x == y)
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+}
+
+void comparison_reversed_ne(int x, int y) {
+  if (x != y)
+clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
+}
+
+//opposite
+
+void comparison_opposite_gt(int x, int y) {
+  if (x > y) {
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+  } else {
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}}
+  }
+}
+
+void comparison_opposite_ge(int x, int y) {
+  if (x >= y) {
+clang_analyzer_eval(x < y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
+  } else {
+clang_analyzer_eval(x < y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y > x); // expected-warning{{TRUE}}
+  }
+}
+
+void comparison_opposite_lt(int x, int y) {
+  if (x < y) {
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
+clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
+  } else {
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
+clang_analyzer_eval(x == y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y == x); // expected-warning{{TRUE}}
+  }
+}
+
+void comparison_opposite_le(int x, int y) {
+  if (x <= y) {
+clang_analyzer_eval(x > y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x); // expected-warning{{FALSE}}
+  } else {
+clang_analyzer_eval(x > y); // expected-warning{{TRUE}}
+clang_analyzer_eval(y < x); // expected-warning{{TRUE}}
+  }
+}
+
+void comparison_opposite_eq(int x, int y) {
+  if (x == y) {
+clang_analyzer_eval(x > y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y < x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x < y);  // expected-warning{{FALSE}}
+clang_analyzer_eval(y > x);  // expected-warning{{FALSE}}
+clang_analyzer_eval(x != y); // expected-warning{{FALSE}}
+clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
+  } else {
+clang_analyzer_eval(x > y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y < x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x < y);  // expected-warning{{TRUE}}
+clang_analyzer_eval(y > x);  // expected-warning{{TRUE}}
+clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
+clang

[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata

2020-04-27 Thread Nigel Perks via Phabricator via cfe-commits
nigelp-xmos added a comment.

This patches fixes two Clang tests which are failing for XCore target on 
2020-04-27 with "unexpected null value" assert failures:

CodeGen/2003-12-14-ExternInlineSupport.c
CoverageMapping/unused_names.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77068



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


[PATCH] D77270: Fix the check for regparm in FunctionType::ExtInfo

2020-04-27 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG334ac8105401: Fix the check for regparm in 
FunctionType::ExtInfo (authored by chill).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77270

Files:
  clang/include/clang/AST/Type.h
  clang/test/AST/spurious-regparm.c


Index: clang/test/AST/spurious-regparm.c
===
--- /dev/null
+++ clang/test/AST/spurious-regparm.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple armv8.1m.main-eabi -mcmse -fsyntax-only %s 
-ast-dump | FileCheck %s
+// REQUIRES: arm-registered-target
+typedef int (*fn_t)(int) __attribute__((cmse_nonsecure_call));
+// CHECK-NOT: regparm 0
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -3518,13 +3518,12 @@
 enum { NoReturnMask = 0x20 };
 enum { ProducesResultMask = 0x40 };
 enum { NoCallerSavedRegsMask = 0x80 };
-enum { NoCfCheckMask = 0x800 };
-enum { CmseNSCallMask = 0x1000 };
 enum {
-  RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask |
-  NoCallerSavedRegsMask | NoCfCheckMask | CmseNSCallMask),
+  RegParmMask =  0x700,
   RegParmOffset = 8
-}; // Assumed to be the last field
+};
+enum { NoCfCheckMask = 0x800 };
+enum { CmseNSCallMask = 0x1000 };
 uint16_t Bits = CC_C;
 
 ExtInfo(unsigned Bits) : Bits(static_cast(Bits)) {}
@@ -3557,7 +3556,7 @@
 bool getCmseNSCall() const { return Bits & CmseNSCallMask; }
 bool getNoCallerSavedRegs() const { return Bits & NoCallerSavedRegsMask; }
 bool getNoCfCheck() const { return Bits & NoCfCheckMask; }
-bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; }
+bool getHasRegParm() const { return ((Bits & RegParmMask) >> 
RegParmOffset) != 0; }
 
 unsigned getRegParm() const {
   unsigned RegParm = (Bits & RegParmMask) >> RegParmOffset;


Index: clang/test/AST/spurious-regparm.c
===
--- /dev/null
+++ clang/test/AST/spurious-regparm.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple armv8.1m.main-eabi -mcmse -fsyntax-only %s -ast-dump | FileCheck %s
+// REQUIRES: arm-registered-target
+typedef int (*fn_t)(int) __attribute__((cmse_nonsecure_call));
+// CHECK-NOT: regparm 0
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -3518,13 +3518,12 @@
 enum { NoReturnMask = 0x20 };
 enum { ProducesResultMask = 0x40 };
 enum { NoCallerSavedRegsMask = 0x80 };
-enum { NoCfCheckMask = 0x800 };
-enum { CmseNSCallMask = 0x1000 };
 enum {
-  RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask |
-  NoCallerSavedRegsMask | NoCfCheckMask | CmseNSCallMask),
+  RegParmMask =  0x700,
   RegParmOffset = 8
-}; // Assumed to be the last field
+};
+enum { NoCfCheckMask = 0x800 };
+enum { CmseNSCallMask = 0x1000 };
 uint16_t Bits = CC_C;
 
 ExtInfo(unsigned Bits) : Bits(static_cast(Bits)) {}
@@ -3557,7 +3556,7 @@
 bool getCmseNSCall() const { return Bits & CmseNSCallMask; }
 bool getNoCallerSavedRegs() const { return Bits & NoCallerSavedRegsMask; }
 bool getNoCfCheck() const { return Bits & NoCfCheckMask; }
-bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; }
+bool getHasRegParm() const { return ((Bits & RegParmMask) >> RegParmOffset) != 0; }
 
 unsigned getRegParm() const {
   unsigned RegParm = (Bits & RegParmMask) >> RegParmOffset;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78762: build: use `find_package(Python3)` if available

2020-04-27 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.

In D78762#2002305 , @JDevlieghere 
wrote:

> My suggestion is to have 4 new CMake variable that abstract over this: 
> `LLVM_PYTHON_EXECUTABLE`, `LLVM_PYTHON_LIBRARIES`, `LLVM_PYTHON_INCLUDE_DIRS` 
> and finally `LLVM_PYTHON_HINT`.  We can then populate the first three 
> depending on what machinery we want to use, i.e. the old CMake way of finding 
> Python (until we bump the requirement across llvm), as well as the new 
> `FindPython3` and `FindPython2`. Similarly for the `HINT` variable, having 
> our own abstraction means we don't clobber any of the variables used 
> internally by CMake.
>
> What do you think?


This is not better IMHO since it assumes that all subprojects are using the 
`LLVM_meow` variable to refer to the Python executable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78762



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Furthermore, there are also problems with `CXXNewExpr`:

  llvm-project/clang/include/clang/AST/ExprCXX.h:2239: clang::Expr* 
clang::CXXNewExpr::getPlacementArg(unsigned int): Assertion `(I < 
getNumPlacementArgs()) && "Index out of range!"' failed.


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

https://reviews.llvm.org/D77229



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

And this one:

  'Assume' not implemented for this NonLoc
  UNREACHABLE executed at 
/home/edmbalo/llvm-project/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp:67!


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

https://reviews.llvm.org/D77229



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


[PATCH] D78190: Add Bfloat IR type

2020-04-27 Thread Ties Stuij via Phabricator via cfe-commits
stuij marked 8 inline comments as done.
stuij added inline comments.



Comment at: llvm/include/llvm-c/Core.h:149
   LLVMHalfTypeKind,/**< 16 bit floating point type */
+  LLVMBfloatTypeKind,  /**< 16 bit brain floating point type */
   LLVMFloatTypeKind,   /**< 32 bit floating point type */

scanon wrote:
> Throughout this, I think `BFloat` would be more consistent with other types 
> than `Bfloat` is.
Agreed. I continued the convention of the bfloat C type patch, but it did 
subconsciously grate a bit. I capitalized it everywhere where the B is 
capitalized.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78190



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D77229#2005033 , @NoQ wrote:

> > How do we calculate the type then?
>
> Argument expression type + account for value kind (lvalue argument expression 
> means reference parameter, xvalue argument expression mean rvalue reference 
> parameter).


OK, I reid this piece of code instead of storing the type explicitly:

  QualType ParamRegion::getValueType() const {
const Expr *Arg = nullptr;
if (const auto *CE = dyn_cast(OriginExpr)) {
  Arg = CE->getArg(Index);
} else if (const auto *CCE = dyn_cast(OriginExpr)) {
  Arg = CCE->getArg(Index);
} else if (const auto *OCME = dyn_cast(OriginExpr)) {
  Arg = OCME->getArg(Index);
} else if (const auto *CNE = dyn_cast(OriginExpr)) {
  Arg = CNE->getPlacementArg(Index);
} else {
  // FIXME: Any other kind of `Expr`?
  llvm_unreachable("Maybe we forgot something...");
}
  
assert(Arg);
  
switch (Arg->getValueKind()) {
case VK_RValue:
  return Arg->getType();
case VK_LValue:
  return getContext().getLValueReferenceType(Arg->getType());
case VK_XValue:
  return getContext().getRValueReferenceType(Arg->getType());
default:
  llvm_unreachable("Invalid value kind.");
}
  }

This results in the following assertion:

  llvm-project/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:333: 
clang::ento::ProgramStateRef 
clang::ento::ExprEngine::createTemporaryRegionIfNeeded(clang::ento::ProgramStateRef,
 const clang::LocationContext*, const clang::Expr*, const clang::Expr*, const 
clang::ento::SubRegion**): Assertion `!InitValWithAdjustments.getAs() || 
Loc::isLocType(Result->getType()) || Result->getType()->isMemberPointerType()' 
failed.


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

https://reviews.llvm.org/D77229



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


[PATCH] D78836: [clangd] Strip /showIncludes in clangd compile commands

2020-04-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/lib/Tooling/ArgumentsAdjusters.cpp:101
   // -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD.
-  if (!Arg.startswith("-M")) {
+  if (!Arg.startswith("-M") && Arg != "/showIncludes") {
 AdjustedArgs.push_back(Args[i]);

kadircet wrote:
> aeubanks wrote:
> > kadircet wrote:
> > > kadircet wrote:
> > > > this can also be --show-includes
> > > and looks like there's also `/showIncludes:user` :/
> > Handled `/showIncludes:user`, thanks for catching that. I don't see 
> > `--show-includes` though, clang-cl and clang both don't like the option?
> ah sorry, that one is a frontend option rather than a driver one. so nvm that 
> one.
clang-cl suports both /foo and -foo style flags. See the top of 
clang/include/clang/Driver/CLCompatOptions.td

You probably want to add the -showIncludes prefix here too. Ideally this 
probably wouldn't do its own commandline parsing here (?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78836



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


[PATCH] D78762: build: use `find_package(Python3)` if available

2020-04-27 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

In D78762#2002390 , @compnerd wrote:

> @JDevlieghere I think that adding another mechanism for finding the python 
> executable is not the right approach.  You already have the variables that 
> you are talking about, you just need to specify it in triplicate if you want 
> compatibility across all the versions, but specifying `-DPython3_EXECUTABLE=` 
> gives you the control over the executable for python3.  If you want to use 
> python2, `-DPython3_EXECUTABLE=` and `-DPython2_EXECUTABLE=` will ensure that 
> python2 is always used.  If you are using an older CMake, specifying 
> `-DPython3_EXECUTABLE=`, `-DPython2_EXECUTABLE=` and `-DPYTHON_EXECUTABLE=` 
> will ensure that the specified version is used.  I'm not sure what the 
> scenario is that you believe will be made more difficult with this approach.


It only //works// because you're setting Python3_EXECUTABLE to 
Python2_EXECUTABLE.

  set(Python3_EXECUTABLE ${Python2_EXECUTABLE})

This will be completely opaque to lldb and we'll have to struggle again to 
reverse engineer which Python is used, leaving us in the same situation as 
today. How are we going to choose between Python 2 and Python 3 based on that 
variable? What I envision is to find Python once, like we do with other 
dependencies in the LLVM project, and then use that (interpreter, libraries, 
include paths) in LLDB. This has to work for in-tree-builds as well as 
out-of-tree builds (I'm not a fan but hey they're still supported).

In D78762#2005407 , @ldionne wrote:

> In D78762#2002305 , @JDevlieghere 
> wrote:
>
> > My suggestion is to have 4 new CMake variable that abstract over this: 
> > `LLVM_PYTHON_EXECUTABLE`, `LLVM_PYTHON_LIBRARIES`, 
> > `LLVM_PYTHON_INCLUDE_DIRS` and finally `LLVM_PYTHON_HINT`.  We can then 
> > populate the first three depending on what machinery we want to use, i.e. 
> > the old CMake way of finding Python (until we bump the requirement across 
> > llvm), as well as the new `FindPython3` and `FindPython2`. Similarly for 
> > the `HINT` variable, having our own abstraction means we don't clobber any 
> > of the variables used internally by CMake.
> >
> > What do you think?
>
>
> This is not better IMHO since it assumes that all subprojects are using the 
> `LLVM_meow` variable to refer to the Python executable.


This patch is already changing the variable. How is this different/worse from 
using `Python3_EXECUTABLE` and having it **maybe** point to a Python 2 
interpreter?




Comment at: clang/CMakeLists.txt:154
+message(WARNING "Python3 not found, using python2 as a fallback")
+find_package(Python3 COMPONENTS Interpreter REQUIRED)
+if(Python2_VERSION VERSION_LESS 2.7)

Python2?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78762



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


[PATCH] D62368: Add support for Hygon Dhyana processor

2020-04-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: compiler-rt/lib/scudo/scudo_utils.cpp:85
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;

fanjinke wrote:
> craig.topper wrote:
> > What's the rationale for the vendor check here anyway? Why isn't the bit in 
> > ecx sufficient?
> Using the cpuid instruction to get the vendor id will return the ASCII code 
> of the vendor id, which is stored in the ebx,ecx,edx registers.
> The ASCII code in the Hygon CPU is "HygonGenuine",  the ecx = "eniu".
> For better differentiation from other cpus in the future,  by following 
> AMD/Intel way, we use full ASCII code to identify Hygon CPU.
> 
Sorry, my question was about why this was restricted to Intel/AMD in the first 
place. Why should this code need to be updated every time a new vendor comes 
along? Why isn’t checking for sse4.2 regardless of vendor sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-27 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D77229#2005419 , 
@baloghadamsoftware wrote:

> Furthermore, there are also problems with `CXXNewExpr`:
>
>   llvm-project/clang/include/clang/AST/ExprCXX.h:2239: clang::Expr* 
> clang::CXXNewExpr::getPlacementArg(unsigned int): Assertion `(I < 
> getNumPlacementArgs()) && "Index out of range!"' failed.
>


This one seems to be resolved by subtracting `1` from `Index` since the first 
argument is not a placement argument but the size.


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

https://reviews.llvm.org/D77229



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


[clang] 5c03bee - clang: Allow backend unsupported warnings

2020-04-27 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-04-27T12:14:51-04:00
New Revision: 5c03beefa720bddb3e3f53c595a76bce7ad50f37

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

LOG: clang: Allow backend unsupported warnings

Currently this asserts on anything other than errors. In one
workaround scenario, AMDGPU emits DiagnosticInfoUnsupported as a
warning for functions that can't be correctly codegened, but should
never be executed.

Added: 
clang/test/CodeGenOpenCL/backend-unsupported-warning.ll

Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/lib/CodeGen/CodeGenAction.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 87fdfc89c634..9df3e79d183f 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -61,6 +61,7 @@ def note_fe_backend_invalid_loc : Note<"could "
   "not determine the original source location for %0:%1:%2">, BackendInfo;
 
 def err_fe_backend_unsupported : Error<"%0">, BackendInfo;
+def warn_fe_backend_unsupported : Warning<"%0">, BackendInfo;
 
 def err_fe_invalid_code_complete_file : Error<
 "cannot locate code-completion file %0">, DefaultFatal;

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index 81946b194495..b8ffe343db22 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -633,8 +633,9 @@ const FullSourceLoc 
BackendConsumer::getBestLocationFromDebugLoc(
 
 void BackendConsumer::UnsupportedDiagHandler(
 const llvm::DiagnosticInfoUnsupported &D) {
-  // We only support errors.
-  assert(D.getSeverity() == llvm::DS_Error);
+  // We only support warnings or errors.
+  assert(D.getSeverity() == llvm::DS_Error ||
+ D.getSeverity() == llvm::DS_Warning);
 
   StringRef Filename;
   unsigned Line, Column;
@@ -652,7 +653,11 @@ void BackendConsumer::UnsupportedDiagHandler(
 DiagnosticPrinterRawOStream DP(MsgStream);
 D.print(DP);
   }
-  Diags.Report(Loc, diag::err_fe_backend_unsupported) << MsgStream.str();
+
+  auto DiagType = D.getSeverity() == llvm::DS_Error
+  ? diag::err_fe_backend_unsupported
+  : diag::warn_fe_backend_unsupported;
+  Diags.Report(Loc, DiagType) << MsgStream.str();
 
   if (BadDebugInfo)
 // If we were not able to translate the file:line:col information

diff  --git a/clang/test/CodeGenOpenCL/backend-unsupported-warning.ll 
b/clang/test/CodeGenOpenCL/backend-unsupported-warning.ll
new file mode 100644
index ..82df1261c1ae
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/backend-unsupported-warning.ll
@@ -0,0 +1,30 @@
+; RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -S -o - %s 2>&1 | FileCheck %s
+
+; Check that a DiagnosticUnsupported reported as a warning works
+; correctly, and is not emitted as an error.
+
+; CHECK: warning: test.c:2:20: in function use_lds_global_in_func i32 (): 
local memory global used by non-kernel function
+
+target triple = "amdgcn-amd-amdhsa"
+
+@lds = external addrspace(3) global i32, align 4
+
+define i32 @use_lds_global_in_func() !dbg !5 {
+  %load = load i32, i32 addrspace(3)* @lds, !dbg !9
+  ret i32 %load, !dbg !10
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang 
version 3.9.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, 
enums: !2)
+!1 = !DIFile(filename: "test.c", directory: "")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: 
!6, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!6 = !DISubroutineType(types: !7)
+!7 = !{!8}
+!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!9 = !DILocation(line: 2, column: 20, scope: !5)
+!10 = !DILocation(line: 2, column: 13, scope: !5)



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


[PATCH] D78938: Fixing all comparisons for C++20 compilation.

2020-04-27 Thread Barry Revzin via Phabricator via cfe-commits
BRevzin created this revision.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, hiraditya, 
MatzeB.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.

Part of the <=> changes in C++20 make certain patterns of writing equality 
operators ambiguous with themselves (sorry!). This review goes through and 
adjusts all the comparison oeprators such that they should work in both C++17 
and C++20 modes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78938

Files:
  clang/include/clang/AST/StmtIterator.h
  clang/lib/Parse/ParseOpenMP.cpp
  llvm/include/llvm/ADT/AllocatorList.h
  llvm/include/llvm/ADT/DenseMap.h
  llvm/include/llvm/ADT/DenseSet.h
  llvm/include/llvm/ADT/DirectedGraph.h
  llvm/include/llvm/ADT/STLExtras.h
  llvm/include/llvm/ADT/StringMap.h
  llvm/include/llvm/ADT/iterator.h
  llvm/include/llvm/CodeGen/LiveInterval.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/Support/BinaryStreamRef.h
  llvm/lib/CodeGen/MachineOutliner.cpp
  llvm/lib/CodeGen/PeepholeOptimizer.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/lib/Transforms/Scalar/GVNHoist.cpp

Index: llvm/lib/Transforms/Scalar/GVNHoist.cpp
===
--- llvm/lib/Transforms/Scalar/GVNHoist.cpp
+++ llvm/lib/Transforms/Scalar/GVNHoist.cpp
@@ -149,8 +149,8 @@
   // The instruction (VN) which uses the values flowing out of CHI.
   Instruction *I;
 
-  bool operator==(const CHIArg &A) { return VN == A.VN; }
-  bool operator!=(const CHIArg &A) { return !(*this == A); }
+  bool operator==(const CHIArg &A) const { return VN == A.VN; }
+  bool operator!=(const CHIArg &A) const { return !(*this == A); }
 };
 
 using CHIIt = SmallVectorImpl::iterator;
Index: llvm/lib/IR/DebugInfo.cpp
===
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -665,7 +665,7 @@
   if (auto *T = dyn_cast_or_null(Attachment.second))
 for (unsigned N = 0; N < T->getNumOperands(); ++N)
   if (auto *Loc = dyn_cast_or_null(T->getOperand(N)))
-if (Loc != DebugLoc())
+if (Loc != DebugLoc().get())
   T->replaceOperandWith(N, remapDebugLoc(Loc));
   }
 }
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -1729,7 +1729,7 @@
   return Alignment != 0;
 }
 
-bool AttrBuilder::operator==(const AttrBuilder &B) {
+bool AttrBuilder::operator==(const AttrBuilder &B) const {
   if (Attrs != B.Attrs)
 return false;
 
Index: llvm/lib/CodeGen/PeepholeOptimizer.cpp
===
--- llvm/lib/CodeGen/PeepholeOptimizer.cpp
+++ llvm/lib/CodeGen/PeepholeOptimizer.cpp
@@ -330,7 +330,7 @@
   return RegSrcs[Idx].SubReg;
 }
 
-bool operator==(const ValueTrackerResult &Other) {
+bool operator==(const ValueTrackerResult &Other) const {
   if (Other.getInst() != getInst())
 return false;
 
Index: llvm/lib/CodeGen/MachineOutliner.cpp
===
--- llvm/lib/CodeGen/MachineOutliner.cpp
+++ llvm/lib/CodeGen/MachineOutliner.cpp
@@ -590,10 +590,10 @@
   return It;
 }
 
-bool operator==(const RepeatedSubstringIterator &Other) {
+bool operator==(const RepeatedSubstringIterator &Other) const {
   return N == Other.N;
 }
-bool operator!=(const RepeatedSubstringIterator &Other) {
+bool operator!=(const RepeatedSubstringIterator &Other) const {
   return !(*this == Other);
 }
 
Index: llvm/include/llvm/Support/BinaryStreamRef.h
===
--- llvm/include/llvm/Support/BinaryStreamRef.h
+++ llvm/include/llvm/Support/BinaryStreamRef.h
@@ -121,12 +121,12 @@
 
   bool valid() const { return BorrowedImpl != nullptr; }
 
-  bool operator==(const RefType &Other) const {
-if (BorrowedImpl != Other.BorrowedImpl)
+  friend bool operator==(const RefType &Self, const RefType &Other) {
+if (Self.BorrowedImpl != Other.BorrowedImpl)
   return false;
-if (ViewOffset != Other.ViewOffset)
+if (Self.ViewOffset != Other.ViewOffset)
   return false;
-if (Length != Other.Length)
+if (Self.Length != Other.Length)
   return false;
 return true;
   }
Index: llvm/include/llvm/ProfileData/InstrProfReader.h
===
--- llvm/include/llvm/ProfileData/InstrProfReader.h
+++ llvm/include/llvm/ProfileData/InstrProfReader.h
@@ -50,8 +50,12 @@
   InstrProfIterator(InstrProfReader *Reader) : Reader(Reader) { Increment(); }
 
   InstrProfIterator &operator++() { Increment(); return *this; }
-  bool oper

[PATCH] D78190: Add Bfloat IR type

2020-04-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: llvm/docs/LangRef.rst:2896
+   * - ``bfloat``
+ - 16-bit brain floating-point value (8-bit mantissa)
+

rjmccall wrote:
> scanon wrote:
> > bfloat and fp128 should agree w.r.t. whether or not the implicit bit 
> > counts. Either 7 and 112 or 8 and 113. Also, we should use "significand" 
> > instead of "mantissa". "Mantissa" has slipped in in a bunch of places, but 
> > "significand" is the IEEE 754 terminology, and we should follow it.
> I agree with Steve.  In general, there's no reason for these descriptions to 
> be as terse as they are, especially for the non-standard formats.  Someone 
> reading IR and seeing `bfloat` for the first time is going to come here and 
> not be any wiser unless they figure out the right web search.
Hmm, now this reads more like a rationale than documentation.  I would suggest:

> 16-bit "brain" floating-point value (7-bit significand).  Provides the same 
> number of exponent bits as ``float``, so that it matches its dynamic range, 
> just with greatly reduced precision.  Used in Intel's AVX-512 BF16 extensions 
> and ARM's ARMv8.6-A extensions, among others.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78190



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


[PATCH] D78762: build: use `find_package(Python3)` if available

2020-04-27 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

@JDevlieghere I think that for LLDB, which this patch does not touch, the 
proper thing to do is to have 2 different paths with the ability to explicitly 
opt into the path, i.e. `LLDB_USE_PYTHON2:BOOL` and `LLDB_USE_PYTHON3:BOOL` 
with `CMakeDependentOption` to prevent the two from being set to `TRUE` 
simultaneously.  If two paths need to be supported, then you must have two 
paths.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78762



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


[PATCH] D78941: [OPENMP]Allow cancellation constructs in target parallel regions.

2020-04-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.

omp cancellation point parallel and omp cancel parallel directives are
allowed in target paralle regions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78941

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/target_parallel_ast_print.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_messages.cpp

Index: clang/test/OpenMP/target_parallel_messages.cpp
===
--- clang/test/OpenMP/target_parallel_messages.cpp
+++ clang/test/OpenMP/target_parallel_messages.cpp
@@ -76,6 +76,20 @@
   #pragma omp target parallel copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp target parallel'}}
   foo();
 
+  #pragma omp target parallel
+  {
+#pragma omp cancel // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+#pragma omp cancellation point // expected-error {{one of 'for', 'parallel', 'sections' or 'taskgroup' is expected}}
+#pragma omp cancel for // expected-error {{region cannot be closely nested inside 'target parallel' region}}
+#pragma omp cancellation point for // expected-error {{region cannot be closely nested inside 'target parallel' region}}
+#pragma omp cancel sections // expected-error {{region cannot be closely nested inside 'target parallel' region}}
+#pragma omp cancellation point sections // expected-error {{region cannot be closely nested inside 'target parallel' region}}
+#pragma omp cancel taskgroup // expected-error {{region cannot be closely nested inside 'target parallel' region}}
+#pragma omp cancellation point taskgroup // expected-error {{region cannot be closely nested inside 'target parallel' region}}
+#pragma omp cancel parallel
+#pragma omp cancellation point parallel
+  }
+
   return 0;
 }
 
Index: clang/test/OpenMP/target_parallel_codegen.cpp
===
--- clang/test/OpenMP/target_parallel_codegen.cpp
+++ clang/test/OpenMP/target_parallel_codegen.cpp
@@ -134,6 +134,7 @@
   #pragma omp target parallel if(target: 1)
   {
 aa += 1;
+#pragma omp cancel parallel
   }
 
   // CHECK:   [[IF:%.+]] = icmp sgt i32 {{[^,]+}}, 10
@@ -360,6 +361,12 @@
 // CHECK:   store i[[SZ]] %{{.+}}, i[[SZ]]* [[AA_ADDR]], align
 // CHECK:   [[AA_CADDR:%.+]] = bitcast i[[SZ]]* [[AA_ADDR]] to i16*
 // CHECK:   [[AA:%.+]] = load i16, i16* [[AA_CADDR]], align
+// CHECK:   [[IS_CANCEL:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* @{{.+}}, i32 %{{.+}}, i32 1)
+// CHECK:   [[CMP:%.+]] = icmp ne i32 [[IS_CANCEL]], 0
+// CHECK:   br i1 [[CMP]], label %[[EXIT:.+]], label %[[CONTINUE:[^,]+]]
+// CHECK:   [[EXIT]]:
+// CHECK:   br label %[[CONTINUE]]
+// CHECK:   [[CONTINUE]]:
 // CHECK:   ret void
 // CHECK-NEXT:  }
 
Index: clang/test/OpenMP/target_parallel_ast_print.cpp
===
--- clang/test/OpenMP/target_parallel_ast_print.cpp
+++ clang/test/OpenMP/target_parallel_ast_print.cpp
@@ -225,8 +225,16 @@
 
 #pragma omp target parallel defaultmap(tofrom: scalar)
 // CHECK-NEXT: #pragma omp target parallel defaultmap(tofrom: scalar)
+  {
   foo();
+#pragma omp cancellation point parallel
+#pragma omp cancel parallel
+  }
+// CHECK-NEXT: {
 // CHECK-NEXT: foo();
+// CHECK-NEXT: #pragma omp cancellation point parallel
+// CHECK-NEXT: #pragma omp cancel parallel
+// CHECK-NEXT: }
 
   return tmain(argc, &argc) + tmain(argv[0][0], argv[0]);
 }
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2336,6 +2336,7 @@
   VisitStmt(D);
   Record.push_back(D->getNumClauses());
   VisitOMPExecutableDirective(D);
+  Record.writeBool(D->hasCancel());
   Code = serialization::STMT_OMP_TARGET_PARALLEL_DIRECTIVE;
 }
 
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2489,6 +2489,7 @@
   VisitStmt(D);
   Record.skipInts(1);
   VisitOMPExecutableDirective(D);
+  D->setHasCancel(Record.readBool());
 }
 
 void ASTStmtReader::VisitOMPTargetParallelForDirective(
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -9889,7 +9889,7 @@
   setFunctionHasBranchProtectedScope();
 
   return OMPTargetParallelDirective::Cre

[PATCH] D78817: clang: Allow backend unsupported warnings

2020-04-27 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

5c03beefa720bddb3e3f53c595a76bce7ad50f37 



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

https://reviews.llvm.org/D78817



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


[PATCH] D78939: Strip -showIncludes in getClangStripDependencyFileAdjuster()

2020-04-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
aeubanks added a reviewer: thakis.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Follow-up to https://reviews.llvm.org/D78836.

Also consolidate some test cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78939

Files:
  clang/lib/Tooling/ArgumentsAdjusters.cpp
  clang/unittests/Tooling/ToolingTest.cpp


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -530,9 +530,11 @@
   EXPECT_TRUE(HasFlag("-w"));
 }
 
-// Check getClangStripDependencyFileAdjuster strips /showIncludes
+// Check getClangStripDependencyFileAdjuster strips /showIncludes and variants
 TEST(ClangToolTest, StripDependencyFileAdjusterShowIncludes) {
-  FixedCompilationDatabase Compilations("/", {"/showIncludes", "-c"});
+  FixedCompilationDatabase Compilations(
+  "/", {"/showIncludes", "/showIncludes:user", "-showIncludes",
+"-showIncludes:user", "-c"});
 
   ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
   Tool.mapVirtualFile("/a.cc", "void a() {}");
@@ -555,34 +557,9 @@
 return llvm::find(FinalArgs, Flag) != FinalArgs.end();
   };
   EXPECT_FALSE(HasFlag("/showIncludes"));
-  EXPECT_TRUE(HasFlag("-c"));
-}
-
-// Check getClangStripDependencyFileAdjuster strips /showIncludes:user
-TEST(ClangToolTest, StripDependencyFileAdjusterShowIncludesUser) {
-  FixedCompilationDatabase Compilations("/", {"/showIncludes:user", "-c"});
-
-  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
-  Tool.mapVirtualFile("/a.cc", "void a() {}");
-
-  std::unique_ptr Action(
-  newFrontendActionFactory());
-
-  CommandLineArguments FinalArgs;
-  ArgumentsAdjuster CheckFlagsAdjuster =
-  [&FinalArgs](const CommandLineArguments &Args, StringRef /*unused*/) {
-FinalArgs = Args;
-return Args;
-  };
-  Tool.clearArgumentsAdjusters();
-  Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
-  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
-  Tool.run(Action.get());
-
-  auto HasFlag = [&FinalArgs](const std::string &Flag) {
-return llvm::find(FinalArgs, Flag) != FinalArgs.end();
-  };
   EXPECT_FALSE(HasFlag("/showIncludes:user"));
+  EXPECT_FALSE(HasFlag("-showIncludes"));
+  EXPECT_FALSE(HasFlag("-showIncludes:user"));
   EXPECT_TRUE(HasFlag("-c"));
 }
 
Index: clang/lib/Tooling/ArgumentsAdjusters.cpp
===
--- clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -98,7 +98,8 @@
   StringRef Arg = Args[i];
   // All dependency-file options begin with -M. These include -MM,
   // -MF, -MG, -MP, -MT, -MQ, -MD, and -MMD.
-  if (!Arg.startswith("-M") && !Arg.startswith("/showIncludes")) {
+  if (!Arg.startswith("-M") && !Arg.startswith("/showIncludes") &&
+  !Arg.startswith("-showIncludes")) {
 AdjustedArgs.push_back(Args[i]);
 continue;
   }


Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -530,9 +530,11 @@
   EXPECT_TRUE(HasFlag("-w"));
 }
 
-// Check getClangStripDependencyFileAdjuster strips /showIncludes
+// Check getClangStripDependencyFileAdjuster strips /showIncludes and variants
 TEST(ClangToolTest, StripDependencyFileAdjusterShowIncludes) {
-  FixedCompilationDatabase Compilations("/", {"/showIncludes", "-c"});
+  FixedCompilationDatabase Compilations(
+  "/", {"/showIncludes", "/showIncludes:user", "-showIncludes",
+"-showIncludes:user", "-c"});
 
   ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
   Tool.mapVirtualFile("/a.cc", "void a() {}");
@@ -555,34 +557,9 @@
 return llvm::find(FinalArgs, Flag) != FinalArgs.end();
   };
   EXPECT_FALSE(HasFlag("/showIncludes"));
-  EXPECT_TRUE(HasFlag("-c"));
-}
-
-// Check getClangStripDependencyFileAdjuster strips /showIncludes:user
-TEST(ClangToolTest, StripDependencyFileAdjusterShowIncludesUser) {
-  FixedCompilationDatabase Compilations("/", {"/showIncludes:user", "-c"});
-
-  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
-  Tool.mapVirtualFile("/a.cc", "void a() {}");
-
-  std::unique_ptr Action(
-  newFrontendActionFactory());
-
-  CommandLineArguments FinalArgs;
-  ArgumentsAdjuster CheckFlagsAdjuster =
-  [&FinalArgs](const CommandLineArguments &Args, StringRef /*unused*/) {
-FinalArgs = Args;
-return Args;
-  };
-  Tool.clearArgumentsAdjusters();
-  Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
-  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
-  Tool.run(Action.get());
-
-  auto HasFlag = [&FinalArgs](const std::string &Flag) {
-return llvm::find(FinalArgs, Flag) != FinalArgs.end();
-  };
   EXPECT_FALSE

[clang] 7363ffe - [Matrix] Add draft specification for matrix support in Clang.

2020-04-27 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-04-27T18:00:23+01:00
New Revision: 7363ffe95f0a32b5cf11affe844577aa7ba6f0f4

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

LOG: [Matrix] Add draft specification for matrix support in Clang.

This patch documents the planned matrix support in Clang, based on the
draft specification discussed on cfe-dev in the 'Matrix Support in
Clang' thread.

Latest draft spec sent to cfe-dev: 
http://lists.llvm.org/pipermail/cfe-dev/2020-February/064742.html
Discussion thread January: 
http://lists.llvm.org/pipermail/cfe-dev/2020-January/064206.html
Discussion thread March: 
http://lists.llvm.org/pipermail/cfe-dev/2020-March/064834.html

Reviewers: rsmith, anemet, Bigcheese, dexonsmith, rjmccall

Reviewed By: rjmccall

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

Added: 
clang/docs/MatrixTypes.rst

Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index f1b7c79db6d6..4e82a6e5 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -13,6 +13,7 @@ Clang Language Extensions
BlockLanguageSpec
Block-ABI-Apple
AutomaticReferenceCounting
+   MatrixTypes
 
 Introduction
 
@@ -492,6 +493,24 @@ See also :ref:`langext-__builtin_shufflevector`, 
:ref:`langext-__builtin_convert
   'select', they operate somewhat 
diff erently. OpenCL selects based on signedness of
   the condition operands, but GCC vectors use normal bool conversions (that 
is, != 0).
 
+Matrix Types
+
+
+Clang provides an extension for matrix types, which is currently being
+implemented. See :ref:`the draft specification ` for more details.
+
+For example, the code below uses the matrix types extension to multiply two 4x4
+float matrices and add the result to a third 4x4 matrix.
+
+.. code-block:: c++
+
+  typedef float m4x4_t __attribute__((matrix_type(4, 4)));
+
+  m4x4_t f(m4x4_t a, m4x4_t b, m4x4_t c) {
+return a + b * c;
+  }
+
+
 Half-Precision Floating Point
 =
 

diff  --git a/clang/docs/MatrixTypes.rst b/clang/docs/MatrixTypes.rst
new file mode 100644
index ..54099e5aae93
--- /dev/null
+++ b/clang/docs/MatrixTypes.rst
@@ -0,0 +1,285 @@
+==
+Matrix Types
+==
+
+.. contents::
+   :local:
+
+.. _matrixtypes:
+
+Clang provides a C/C++ language extension that allows users to directly express
+fixed-size 2-dimensional matrices as language values and perform arithmetic on
+them.
+
+This feature is currently experimental, and both its design and its
+implementation are in flux.
+
+Draft Specification
+===
+
+Matrix Type
+---
+
+A matrix type is a scalar type with an underlying *element type*, a constant
+number of *rows*, and a constant number of *columns*. Matrix types with the 
same
+element type, rows, and columns are the same type. A value of a matrix type
+includes storage for ``rows * columns`` values of the *element type*. The
+internal layout, overall size and alignment are implementation-defined.
+
+The maximum of the product of the number of rows and columns is
+implementation-defined. If that implementation-defined limit is exceeded, the
+program is ill-formed.
+
+Currently, the element type of a matrix is only permitted to be one of the
+following types:
+
+* an integer type (as in C2x 6.2.5p19), but excluding enumerated types and 
``_Bool``
+* the standard floating types ``float`` or ``double``
+* a half-precision floating point type, if one is supported on the target
+
+Other types may be supported in the future.
+
+Matrix Type Attribute
+-
+
+Matrix types can be declared by adding the ``matrix_type`` attribute to the
+declaration of a *typedef* (or a C++ alias declaration). The underlying type
+of the *typedef* must be a valid matrix element type. The
+attribute takes two arguments, both of which must be integer constant
+expressions that evaluate to a value greater than zero. The first specifies the
+number of rows, and the second specifies the number of columns. The underlying
+type of the *typedef* becomes a matrix type with the given dimensions and an
+element type of the former underlying type.
+
+If a declaration of a *typedef-name* has a ``matrix_type`` attribute, then all
+declaration of that *typedef-name* shall have a matrix_type attribute with the
+same element type, number of rows, and number of columns.
+
+Standard Conversions
+
+
+The standard conversions are extended as follows. Note that these conversions
+are intentionally not listed as satisfying the constraints for assignment,
+which is to say, they are only permitted as explicit casts, not as implicit
+co

[PATCH] D78190: Add Bfloat IR type

2020-04-27 Thread Steve Canon via Phabricator via cfe-commits
scanon added inline comments.



Comment at: llvm/docs/LangRef.rst:2896
+   * - ``bfloat``
+ - 16-bit brain floating-point value (8-bit mantissa)
+

rjmccall wrote:
> rjmccall wrote:
> > scanon wrote:
> > > bfloat and fp128 should agree w.r.t. whether or not the implicit bit 
> > > counts. Either 7 and 112 or 8 and 113. Also, we should use "significand" 
> > > instead of "mantissa". "Mantissa" has slipped in in a bunch of places, 
> > > but "significand" is the IEEE 754 terminology, and we should follow it.
> > I agree with Steve.  In general, there's no reason for these descriptions 
> > to be as terse as they are, especially for the non-standard formats.  
> > Someone reading IR and seeing `bfloat` for the first time is going to come 
> > here and not be any wiser unless they figure out the right web search.
> Hmm, now this reads more like a rationale than documentation.  I would 
> suggest:
> 
> > 16-bit "brain" floating-point value (7-bit significand).  Provides the same 
> > number of exponent bits as ``float``, so that it matches its dynamic range, 
> > just with greatly reduced precision.  Used in Intel's AVX-512 BF16 
> > extensions and ARM's ARMv8.6-A extensions, among others.
Yup, I agree. The important thing here is that someone can figure out what it 
is (the top half of a float); it's ok for them to have to do some reading to 
figure out *why* it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78190



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


[PATCH] D78944: [libc++][test] Disable test for extension that's unsupportable in C++20

2020-04-27 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.
CaseyCarter added reviewers: ldionne, EricWF, mclow.lists.
Herald added subscribers: libcxx-commits, broadwaylamb, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Defining the nested types `reference` and `iterator_concept` of 
`reverse_iterator` necessarily requires `I` to be complete in C++20. These 
tests that verify that `std::map::reverse_iterator` can be instantiated 
when `X` is incomplete are going to have a bad time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78944

Files:
  libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
  
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp


Index: 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
===
--- 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
+++ 
libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
@@ -21,12 +21,13 @@
 std::multimap m;
 std::multimap::iterator i;
 std::multimap::const_iterator ci;
+#if TEST_STD_VER <= 17
 std::multimap::reverse_iterator ri;
 std::multimap::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
 int main(int, char**)
 {
-
-  return 0;
+return 0;
 }
Index: 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
===
--- 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
+++ 
libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -21,12 +21,13 @@
 std::map m;
 std::map::iterator i;
 std::map::const_iterator ci;
+#if TEST_STD_VER <= 17
 std::map::reverse_iterator ri;
 std::map::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
 int main(int, char**)
 {
-
-  return 0;
+return 0;
 }


Index: libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
===
--- libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
+++ libcxx/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp
@@ -21,12 +21,13 @@
 std::multimap m;
 std::multimap::iterator i;
 std::multimap::const_iterator ci;
+#if TEST_STD_VER <= 17
 std::multimap::reverse_iterator ri;
 std::multimap::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
 int main(int, char**)
 {
-
-  return 0;
+return 0;
 }
Index: libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
===
--- libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
+++ libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -21,12 +21,13 @@
 std::map m;
 std::map::iterator i;
 std::map::const_iterator ci;
+#if TEST_STD_VER <= 17
 std::map::reverse_iterator ri;
 std::map::const_reverse_iterator cri;
+#endif // TEST_STD_VER <= 17
 };
 
 int main(int, char**)
 {
-
-  return 0;
+return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >