[PATCH] D76451: [clangd] Enable textual fallback for go-to-definition on dependent names

2020-04-25 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG230cae89db3f: [clangd] Enable textual fallback for 
go-to-definition on dependent names (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76451

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -663,16 +663,6 @@
 int myFunction(int);
 // Not triggered for token which survived preprocessing.
 int var = m^yFunction();
-  )cpp",
-  R"cpp(// Dependent type
-struct Foo {
-  void uniqueMethodName();
-};
-template 
-void f(T t) {
-  // Not triggered for token which survived preprocessing.
-  t->u^niqueMethodName();
-}
   )cpp"};
 
   for (const char *Test : Tests) {
@@ -692,8 +682,8 @@
   ADD_FAILURE() << "No word touching point!" << Test;
   continue;
 }
-auto Results =
-locateSymbolTextually(*Word, AST, Index.get(), testPath(TU.Filename));
+auto Results = locateSymbolTextually(*Word, AST, Index.get(),
+ testPath(TU.Filename), ASTNodeKind());
 
 if (!WantDecl) {
   EXPECT_THAT(Results, IsEmpty()) << Test;
@@ -778,30 +768,36 @@
Sym("baz", T.range("StaticOverload2";
 }
 
-TEST(LocateSymbol, TextualAmbiguous) {
-  auto T = Annotations(R"cpp(
+TEST(LocateSymbol, TextualDependent) {
+  // Put the declarations in the header to make sure we are
+  // finding them via the index heuristic and not the
+  // nearby-ident heuristic.
+  Annotations Header(R"cpp(
 struct Foo {
   void $FooLoc[[uniqueMethodName]]();
 };
 struct Bar {
   void $BarLoc[[uniqueMethodName]]();
 };
-// Will call u^niqueMethodName() on t.
+)cpp");
+  Annotations Source(R"cpp(
 template 
-void f(T t);
+void f(T t) {
+  t.u^niqueMethodName();
+}
   )cpp");
-  auto TU = TestTU::withCode(T.code());
+  TestTU TU;
+  TU.Code = std::string(Source.code());
+  TU.HeaderCode = std::string(Header.code());
   auto AST = TU.build();
   auto Index = TU.index();
-  auto Word = SpelledWord::touching(
-  cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
-  AST.getTokens(), AST.getLangOpts());
-  ASSERT_TRUE(Word);
-  auto Results =
-  locateSymbolTextually(*Word, AST, Index.get(), testPath(TU.Filename));
-  EXPECT_THAT(Results,
-  UnorderedElementsAre(Sym("uniqueMethodName", T.range("FooLoc")),
-   Sym("uniqueMethodName", T.range("BarLoc";
+  // Need to use locateSymbolAt() since we are testing an
+  // interaction between locateASTReferent() and
+  // locateSymbolNamedTextuallyAt().
+  auto Results = locateSymbolAt(AST, Source.point(), Index.get());
+  EXPECT_THAT(Results, UnorderedElementsAre(
+   Sym("uniqueMethodName", Header.range("FooLoc")),
+   Sym("uniqueMethodName", Header.range("BarLoc";
 }
 
 TEST(LocateSymbol, TemplateTypedefs) {
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -19,6 +19,7 @@
 #include "SourceCode.h"
 #include "index/Index.h"
 #include "index/SymbolLocation.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Type.h"
 #include "clang/Format/Format.h"
 #include "clang/Index/IndexSymbol.h"
@@ -62,8 +63,8 @@
 // (This is for internal use by locateSymbolAt, and is exposed for testing).
 std::vector
 locateSymbolTextually(const SpelledWord , ParsedAST ,
-  const SymbolIndex *Index,
-  const std::string );
+  const SymbolIndex *Index, const std::string ,
+  ASTNodeKind NodeKind);
 
 // Try to find a proximate occurrence of `Word` as an identifier, which can be
 // used to resolve it.
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -22,6 +22,7 @@
 #include "index/Relation.h"
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Attrs.inc"
 #include "clang/AST/Decl.h"
@@ -139,17 +140,20 @@
   return Merged.CanonicalDeclaration;
 }
 
-std::vector getDeclAtPosition(ParsedAST ,
- 

[PATCH] D78870: [SourceMgr] Tidy up the SourceMgr header file to include less stuff.

2020-04-25 Thread Chris Lattner via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG919dcc7f6858: [SourceMgr] Tidy up the SourceMgr header file 
to include less stuff. (authored by lattner).

Changed prior to commit:
  https://reviews.llvm.org/D78870?vs=260140=260141#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78870

Files:
  clang/include/clang/Basic/FileManager.h
  llvm/include/llvm/Support/SourceMgr.h
  llvm/lib/Support/SourceMgr.cpp

Index: llvm/lib/Support/SourceMgr.cpp
===
--- llvm/lib/Support/SourceMgr.cpp
+++ llvm/lib/Support/SourceMgr.cpp
@@ -69,16 +69,13 @@
 }
 
 template 
-static std::vector (
-PointerUnion *, std::vector *,
- std::vector *, std::vector *> ,
-MemoryBuffer *Buffer) {
-  if (!OffsetCache.isNull())
-return *OffsetCache.get *>();
+static std::vector (void *,
+  MemoryBuffer *Buffer) {
+  if (OffsetCache)
+return *static_cast *>(OffsetCache);
 
   // Lazily fill in the offset cache.
   auto *Offsets = new std::vector();
-  OffsetCache = Offsets;
   size_t Sz = Buffer->getBufferSize();
   assert(Sz <= std::numeric_limits::max());
   StringRef S = Buffer->getBuffer();
@@ -87,6 +84,7 @@
   Offsets->push_back(static_cast(N));
   }
 
+  OffsetCache = Offsets;
   return *Offsets;
 }
 
@@ -164,15 +162,16 @@
 }
 
 SourceMgr::SrcBuffer::~SrcBuffer() {
-  if (!OffsetCache.isNull()) {
-if (OffsetCache.is *>())
-  delete OffsetCache.get *>();
-else if (OffsetCache.is *>())
-  delete OffsetCache.get *>();
-else if (OffsetCache.is *>())
-  delete OffsetCache.get *>();
+  if (OffsetCache) {
+size_t Sz = Buffer->getBufferSize();
+if (Sz <= std::numeric_limits::max())
+  delete static_cast *>(OffsetCache);
+else if (Sz <= std::numeric_limits::max())
+  delete static_cast *>(OffsetCache);
+else if (Sz <= std::numeric_limits::max())
+  delete static_cast *>(OffsetCache);
 else
-  delete OffsetCache.get *>();
+  delete static_cast *>(OffsetCache);
 OffsetCache = nullptr;
   }
 }
@@ -329,6 +328,15 @@
 }
 
 //===--===//
+// SMFixIt Implementation
+//===--===//
+
+SMFixIt::SMFixIt(SMRange R, const Twine )
+: Range(R), Text(Replacement.str()) {
+  assert(R.isValid());
+}
+
+//===--===//
 // SMDiagnostic Implementation
 //===--===//
 
Index: llvm/include/llvm/Support/SourceMgr.h
===
--- llvm/include/llvm/Support/SourceMgr.h
+++ llvm/include/llvm/Support/SourceMgr.h
@@ -15,19 +15,9 @@
 #ifndef LLVM_SUPPORT_SOURCEMGR_H
 #define LLVM_SUPPORT_SOURCEMGR_H
 
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/None.h"
-#include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SMLoc.h"
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
 
 namespace llvm {
@@ -57,21 +47,17 @@
 /// The memory buffer for the file.
 std::unique_ptr Buffer;
 
-/// Helper type for OffsetCache below: since we're storing many offsets
-/// into relatively small files (often smaller than 2^8 or 2^16 bytes),
-/// we select the offset vector element type dynamically based on the
-/// size of Buffer.
-using VariableSizeOffsets =
-PointerUnion *, std::vector *,
- std::vector *, std::vector *>;
-
 /// Vector of offsets into Buffer at which there are line-endings
 /// (lazily populated). Once populated, the '\n' that marks the end of
 /// line number N from [1..] is at Buffer[OffsetCache[N-1]]. Since
 /// these offsets are in sorted (ascending) order, they can be
 /// binary-searched for the first one after any given offset (eg. an
 /// offset corresponding to a particular SMLoc).
-mutable VariableSizeOffsets OffsetCache;
+///
+/// Since we're storing offsets into relatively small files (often smaller
+/// than 2^8 or 2^16 bytes), we select the offset vector element type
+/// dynamically based on the size of Buffer.
+mutable void *OffsetCache = nullptr;
 
 /// Look up a given \p Ptr in in the buffer, determining which line it came
 /// from.
@@ -196,14 +182,14 @@
   /// \param ShowColors Display colored messages if output is a terminal and
   /// the default error handler is used.
   void PrintMessage(raw_ostream , SMLoc Loc, DiagKind Kind, const Twine ,
-   

[PATCH] D78784: [clangd] Add some logging to explain why textual fallback navigation failed

2020-04-25 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

The intent is to be able to run a production build on a production codebase and 
see why a particular instance of navigation failed. However, it's not super 
important that this land; if you don't think it's useful for others, I can just 
run with it applied locally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78784



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


[clang-tools-extra] 230cae8 - [clangd] Enable textual fallback for go-to-definition on dependent names

2020-04-25 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-04-26T00:38:38-04:00
New Revision: 230cae89db3f8619e2b5383ae797462434f69d50

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

LOG: [clangd] Enable textual fallback for go-to-definition on dependent names

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index d17fa52bd82c..7eb3c4fcc7a3 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -22,6 +22,7 @@
 #include "index/Relation.h"
 #include "index/SymbolLocation.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Attrs.inc"
 #include "clang/AST/Decl.h"
@@ -139,17 +140,20 @@ SymbolLocation getPreferredLocation(const Location 
,
   return Merged.CanonicalDeclaration;
 }
 
-std::vector getDeclAtPosition(ParsedAST ,
- SourceLocation Pos,
- DeclRelationSet Relations) {
+std::vector
+getDeclAtPosition(ParsedAST , SourceLocation Pos, DeclRelationSet 
Relations,
+  ASTNodeKind *NodeKind = nullptr) {
   unsigned Offset = 
AST.getSourceManager().getDecomposedSpellingLoc(Pos).second;
   std::vector Result;
   SelectionTree::createEach(AST.getASTContext(), AST.getTokens(), Offset,
 Offset, [&](SelectionTree ST) {
   if (const SelectionTree::Node *N =
-  ST.commonAncestor())
+  ST.commonAncestor()) {
+if (NodeKind)
+  *NodeKind = N->ASTNode.getNodeKind();
 llvm::copy(targetDecl(N->ASTNode, Relations),
std::back_inserter(Result));
+  }
   return !Result.empty();
 });
   return Result;
@@ -221,7 +225,7 @@ locateMacroReferent(const syntax::Token , 
ParsedAST ,
 std::vector
 locateASTReferent(SourceLocation CurLoc, const syntax::Token 
*TouchedIdentifier,
   ParsedAST , llvm::StringRef MainFilePath,
-  const SymbolIndex *Index) {
+  const SymbolIndex *Index, ASTNodeKind *NodeKind) {
   const SourceManager  = AST.getSourceManager();
   // Results follow the order of Symbols.Decls.
   std::vector Result;
@@ -250,7 +254,8 @@ locateASTReferent(SourceLocation CurLoc, const 
syntax::Token *TouchedIdentifier,
   // Emit all symbol locations (declaration or definition) from AST.
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
-  for (const NamedDecl *D : getDeclAtPosition(AST, CurLoc, Relations)) {
+  for (const NamedDecl *D :
+   getDeclAtPosition(AST, CurLoc, Relations, NodeKind)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
   const InheritableAttr *Attr = D->getAttr();
@@ -332,14 +337,26 @@ llvm::StringRef sourcePrefix(SourceLocation Loc, const 
SourceManager ) {
   return Buf.substr(0, D.second);
 }
 
+bool isDependentName(ASTNodeKind NodeKind) {
+  return NodeKind.isSame(ASTNodeKind::getFromNodeKind()) ||
+ NodeKind.isSame(
+ ASTNodeKind::getFromNodeKind()) ||
+ NodeKind.isSame(
+ ASTNodeKind::getFromNodeKind());
+}
+
 } // namespace
 
 std::vector
 locateSymbolTextually(const SpelledWord , ParsedAST ,
-  const SymbolIndex *Index,
-  const std::string ) {
-  // Don't use heuristics if this is a real identifier, or not an identifier.
-  if (Word.ExpandedToken || !Word.LikelyIdentifier || !Index)
+  const SymbolIndex *Index, const std::string 
,
+  ASTNodeKind NodeKind) {
+  // Don't use heuristics if this is a real identifier, or not an
+  // identifier.
+  // Exception: dependent names, because those may have useful textual
+  // matches that AST-based heuristics cannot find.
+  if ((Word.ExpandedToken && !isDependentName(NodeKind)) ||
+  !Word.LikelyIdentifier || !Index)
 return {};
   // We don't want to handle words in string literals. It'd be nice to 
whitelist
   // comments instead, but they're not retained in TokenBuffer.
@@ -540,8 +557,9 @@ std::vector 

[clang] 919dcc7 - [SourceMgr] Tidy up the SourceMgr header file to include less stuff.

2020-04-25 Thread Chris Lattner via cfe-commits

Author: Chris Lattner
Date: 2020-04-25T21:18:59-07:00
New Revision: 919dcc7f6858cf0d9a7442673acafdf495e46c7a

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

LOG: [SourceMgr] Tidy up the SourceMgr header file to include less stuff.

Summary:
Specifically make some simple refactorings to get PointerUnion.h and
Twine.h out of the public includes.  While here, trim out a lot of
transitive includes as well.

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/FileManager.h
llvm/include/llvm/Support/SourceMgr.h
llvm/lib/Support/SourceMgr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/FileManager.h 
b/clang/include/clang/Basic/FileManager.h
index b481f5846936..089304e1d1e6 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -18,6 +18,7 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"

diff  --git a/llvm/include/llvm/Support/SourceMgr.h 
b/llvm/include/llvm/Support/SourceMgr.h
index 3255e143d56b..a0bd3ca2e0c1 100644
--- a/llvm/include/llvm/Support/SourceMgr.h
+++ b/llvm/include/llvm/Support/SourceMgr.h
@@ -15,19 +15,9 @@
 #ifndef LLVM_SUPPORT_SOURCEMGR_H
 #define LLVM_SUPPORT_SOURCEMGR_H
 
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/None.h"
-#include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SMLoc.h"
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
 
 namespace llvm {
@@ -57,21 +47,17 @@ class SourceMgr {
 /// The memory buffer for the file.
 std::unique_ptr Buffer;
 
-/// Helper type for OffsetCache below: since we're storing many offsets
-/// into relatively small files (often smaller than 2^8 or 2^16 bytes),
-/// we select the offset vector element type dynamically based on the
-/// size of Buffer.
-using VariableSizeOffsets =
-PointerUnion *, std::vector *,
- std::vector *, std::vector *>;
-
 /// Vector of offsets into Buffer at which there are line-endings
 /// (lazily populated). Once populated, the '\n' that marks the end of
 /// line number N from [1..] is at Buffer[OffsetCache[N-1]]. Since
 /// these offsets are in sorted (ascending) order, they can be
 /// binary-searched for the first one after any given offset (eg. an
 /// offset corresponding to a particular SMLoc).
-mutable VariableSizeOffsets OffsetCache;
+///
+/// Since we're storing offsets into relatively small files (often smaller
+/// than 2^8 or 2^16 bytes), we select the offset vector element type
+/// dynamically based on the size of Buffer.
+mutable void *OffsetCache = nullptr;
 
 /// Look up a given \p Ptr in in the buffer, determining which line it came
 /// from.
@@ -196,14 +182,14 @@ class SourceMgr {
   /// \param ShowColors Display colored messages if output is a terminal and
   /// the default error handler is used.
   void PrintMessage(raw_ostream , SMLoc Loc, DiagKind Kind, const Twine 
,
-ArrayRef Ranges = None,
-ArrayRef FixIts = None,
+ArrayRef Ranges = {},
+ArrayRef FixIts = {},
 bool ShowColors = true) const;
 
   /// Emits a diagnostic to llvm::errs().
   void PrintMessage(SMLoc Loc, DiagKind Kind, const Twine ,
-ArrayRef Ranges = None,
-ArrayRef FixIts = None,
+ArrayRef Ranges = {},
+ArrayRef FixIts = {},
 bool ShowColors = true) const;
 
   /// Emits a manually-constructed diagnostic to the given output stream.
@@ -219,8 +205,8 @@ class SourceMgr {
   /// \param Msg If non-null, the kind of message (e.g., "error") which is
   /// prefixed to the message.
   SMDiagnostic GetMessage(SMLoc Loc, DiagKind Kind, const Twine ,
-  ArrayRef Ranges = None,
-  ArrayRef FixIts = None) const;
+  ArrayRef Ranges = {},
+  ArrayRef FixIts = {}) const;
 
   /// Prints the names of included files and the line of the file they were
   /// included from. A diagnostic handler can use this before printing its
@@ -238,17 +224,10 @@ class SMFixIt {
   std::string Text;
 
 public:
-  // FIXME: Twine.str() is not very efficient.
-  SMFixIt(SMLoc Loc, const Twine )
-  : Range(Loc, Loc), 

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

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

This breaks building libclang on Fedora 32 with clang 10.0 and lld 10.0. Do you 
mind if I revert this tomorrow if a quick fix cannot be found? Here is the 
relevant diagnostics:

FAILED: lib64/libclang.so.11
: && /usr/bin/clang++ -fPIC -Werror=switch -stdlib=libc++ 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default 
-Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
-Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections 
-fno-common -Woverloaded-virtual -Wno-nested-anon-types -O2 -DNDEBUG  
-stdlib=libc++ -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld -Wl,--color-diagnostics 
  -Wl,-O3 -Wl,--gc-sections  
-Wl,--version-script,"/tmp/_update_lc/r/tools/clang/tools/libclang/libclang.exports"
 -shared -Wl,-soname,libclang.so.11git -o lib64/libclang.so.11 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/ARCMigrate.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/BuildSystem.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CIndex.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CIndexCXX.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CIndexCodeCompletion.cpp.o
 tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CIndexDiagnostic.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CIndexHigh.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CIndexInclusionStack.cpp.o
 tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CIndexUSRs.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CIndexer.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CXComment.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CXCursor.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CXIndexDataConsumer.cpp.o
 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CXCompilationDatabase.cpp.o
 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CXLoadedDiagnostic.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CXSourceLocation.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CXStoredDiagnostic.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CXString.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/CXType.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/Indexing.cpp.o 
tools/clang/tools/libclang/CMakeFiles/obj.libclang.dir/FatalErrorHandler.cpp.o  
-Wl,-rpath,"\$ORIGIN/../lib64"  lib64/libclangAST.a  lib64/libclangBasic.a  
lib64/libclangDriver.a  lib64/libclangFrontend.a  lib64/libclangIndex.a  
lib64/libclangLex.a  lib64/libclangSema.a  lib64/libclangSerialization.a  
lib64/libclangTooling.a  lib64/libLLVMSupport.a  lib64/libclangARCMigrate.a  
-ldl  lib64/libLLVMX86CodeGen.a  lib64/libLLVMX86AsmParser.a  
lib64/libLLVMX86Desc.a  lib64/libLLVMX86Disassembler.a  lib64/libLLVMX86Info.a  
lib64/libLLVMAArch64CodeGen.a  lib64/libLLVMAArch64AsmParser.a  
lib64/libLLVMAArch64Desc.a  lib64/libLLVMAArch64Disassembler.a  
lib64/libLLVMAArch64Info.a  lib64/libLLVMAArch64Utils.a  
lib64/libLLVMPowerPCCodeGen.a  lib64/libLLVMPowerPCAsmParser.a  
lib64/libLLVMPowerPCDesc.a  lib64/libLLVMPowerPCDisassembler.a  
lib64/libLLVMPowerPCInfo.a  lib64/libLLVMRISCVCodeGen.a  
lib64/libLLVMRISCVAsmParser.a  lib64/libLLVMRISCVDesc.a  
lib64/libLLVMRISCVDisassembler.a  lib64/libLLVMRISCVInfo.a  
lib64/libLLVMRISCVUtils.a  lib64/libLLVMCore.a  lib64/libLLVMSupport.a  
lib64/libclangFormat.a  lib64/libclangToolingInclusions.a  
lib64/libclangToolingCore.a  lib64/libclangFrontend.a  lib64/libclangDriver.a  
lib64/libLLVMOption.a  lib64/libclangParse.a  lib64/libclangSerialization.a  
lib64/libclangSema.a  lib64/libclangEdit.a  lib64/libclangRewrite.a  
lib64/libclangAnalysis.a  lib64/libclangASTMatchers.a  lib64/libclangAST.a  
lib64/libclangLex.a  lib64/libclangBasic.a  lib64/libLLVMFrontendOpenMP.a  
lib64/libLLVMCFGuard.a  lib64/libLLVMAArch64Desc.a  lib64/libLLVMAArch64Info.a  
lib64/libLLVMAArch64Utils.a  lib64/libLLVMAsmPrinter.a  
lib64/libLLVMDebugInfoDWARF.a  lib64/libLLVMGlobalISel.a  
lib64/libLLVMSelectionDAG.a  lib64/libLLVMCodeGen.a  lib64/libLLVMScalarOpts.a  
lib64/libLLVMAggressiveInstCombine.a  lib64/libLLVMInstCombine.a  
lib64/libLLVMBitWriter.a  lib64/libLLVMTransformUtils.a  lib64/libLLVMTarget.a  
lib64/libLLVMAnalysis.a  lib64/libLLVMProfileData.a  lib64/libLLVMObject.a  
lib64/libLLVMBitReader.a  lib64/libLLVMCore.a  lib64/libLLVMRemarks.a  
lib64/libLLVMBitstreamReader.a  lib64/libLLVMTextAPI.a  lib64/libLLVMMCParser.a 
 lib64/libLLVMMCDisassembler.a  lib64/libLLVMMC.a  lib64/libLLVMBinaryFormat.a  
lib64/libLLVMDebugInfoCodeView.a  lib64/libLLVMDebugInfoMSF.a  
lib64/libLLVMSupport.a  -lz  -lrt  -ldl  -ltinfo  -lpthread  -lm  
/usr/lib64/libz3.so  lib64/libLLVMDemangle.a && :

[PATCH] D78870: [SourceMgr] Tidy up the SourceMgr header file to include less stuff.

2020-04-25 Thread Chris Lattner via Phabricator via cfe-commits
lattner updated this revision to Diff 260140.
lattner added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang depended on the transitive include, update it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78870

Files:
  clang/include/clang/Basic/FileManager.h
  llvm/include/llvm/Support/SourceMgr.h
  llvm/lib/Support/SourceMgr.cpp

Index: llvm/lib/Support/SourceMgr.cpp
===
--- llvm/lib/Support/SourceMgr.cpp
+++ llvm/lib/Support/SourceMgr.cpp
@@ -69,16 +69,13 @@
 }
 
 template 
-static std::vector (
-PointerUnion *, std::vector *,
- std::vector *, std::vector *> ,
-MemoryBuffer *Buffer) {
-  if (!OffsetCache.isNull())
-return *OffsetCache.get *>();
+static std::vector (void *,
+  MemoryBuffer *Buffer) {
+  if (OffsetCache)
+return *static_cast *>(OffsetCache);
 
   // Lazily fill in the offset cache.
   auto *Offsets = new std::vector();
-  OffsetCache = Offsets;
   size_t Sz = Buffer->getBufferSize();
   assert(Sz <= std::numeric_limits::max());
   StringRef S = Buffer->getBuffer();
@@ -87,6 +84,7 @@
   Offsets->push_back(static_cast(N));
   }
 
+  OffsetCache = Offsets;
   return *Offsets;
 }
 
@@ -164,15 +162,16 @@
 }
 
 SourceMgr::SrcBuffer::~SrcBuffer() {
-  if (!OffsetCache.isNull()) {
-if (OffsetCache.is *>())
-  delete OffsetCache.get *>();
-else if (OffsetCache.is *>())
-  delete OffsetCache.get *>();
-else if (OffsetCache.is *>())
-  delete OffsetCache.get *>();
+  if (OffsetCache) {
+size_t Sz = Buffer->getBufferSize();
+if (Sz <= std::numeric_limits::max())
+  delete static_cast *>(OffsetCache);
+else if (Sz <= std::numeric_limits::max())
+  delete static_cast *>(OffsetCache);
+else if (Sz <= std::numeric_limits::max())
+  delete static_cast *>(OffsetCache);
 else
-  delete OffsetCache.get *>();
+  delete static_cast *>(OffsetCache);
 OffsetCache = nullptr;
   }
 }
@@ -328,6 +327,15 @@
   PrintMessage(errs(), Loc, Kind, Msg, Ranges, FixIts, ShowColors);
 }
 
+//===--===//
+// SMFixIt Implementation
+//===--===//
+
+SMFixIt::SMFixIt(SMRange R, const Twine )
+: Range(R), Text(Replacement.str()) {
+  assert(R.isValid());
+}
+
 //===--===//
 // SMDiagnostic Implementation
 //===--===//
Index: llvm/include/llvm/Support/SourceMgr.h
===
--- llvm/include/llvm/Support/SourceMgr.h
+++ llvm/include/llvm/Support/SourceMgr.h
@@ -15,19 +15,9 @@
 #ifndef LLVM_SUPPORT_SOURCEMGR_H
 #define LLVM_SUPPORT_SOURCEMGR_H
 
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/None.h"
-#include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SMLoc.h"
-#include 
-#include 
-#include 
-#include 
-#include 
 #include 
 
 namespace llvm {
@@ -57,21 +47,17 @@
 /// The memory buffer for the file.
 std::unique_ptr Buffer;
 
-/// Helper type for OffsetCache below: since we're storing many offsets
-/// into relatively small files (often smaller than 2^8 or 2^16 bytes),
-/// we select the offset vector element type dynamically based on the
-/// size of Buffer.
-using VariableSizeOffsets =
-PointerUnion *, std::vector *,
- std::vector *, std::vector *>;
-
 /// Vector of offsets into Buffer at which there are line-endings
 /// (lazily populated). Once populated, the '\n' that marks the end of
 /// line number N from [1..] is at Buffer[OffsetCache[N-1]]. Since
 /// these offsets are in sorted (ascending) order, they can be
 /// binary-searched for the first one after any given offset (eg. an
 /// offset corresponding to a particular SMLoc).
-mutable VariableSizeOffsets OffsetCache;
+///
+/// Since we're storing offsets into relatively small files (often smaller
+/// than 2^8 or 2^16 bytes), we select the offset vector element type
+/// dynamically based on the size of Buffer.
+mutable void *OffsetCache = nullptr;
 
 /// Look up a given \p Ptr in in the buffer, determining which line it came
 /// from.
@@ -196,14 +182,14 @@
   /// \param ShowColors Display colored messages if output is a terminal and
   /// the default error handler is used.
   void PrintMessage(raw_ostream , SMLoc Loc, DiagKind Kind, const Twine ,
-ArrayRef Ranges = None,
-ArrayRef FixIts = None,
+

[PATCH] D78163: [AVR][NFC] Move preprocessor tests to Preprocessor directory

2020-04-25 Thread Ayke via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGceba881aeac1: [AVR][NFC] Move preprocessor tests to 
Preprocessor directory (authored by aykevl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78163

Files:
  clang/test/CodeGen/avr/target-cpu-defines/atmega328p.c
  clang/test/CodeGen/avr/target-cpu-defines/attiny104.c
  clang/test/CodeGen/avr/target-cpu-defines/common.c
  clang/test/Preprocessor/avr-atmega328p.c
  clang/test/Preprocessor/avr-attiny104.c
  clang/test/Preprocessor/avr-common.c


Index: clang/test/Preprocessor/avr-common.c
===
--- clang/test/Preprocessor/avr-common.c
+++ clang/test/Preprocessor/avr-common.c
@@ -1,4 +1,3 @@
-// REQUIRES: avr-registered-target
 // RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown /dev/null | FileCheck 
-match-full-lines %s
 
 // CHECK: #define AVR 1
Index: clang/test/Preprocessor/avr-attiny104.c
===
--- clang/test/Preprocessor/avr-attiny104.c
+++ clang/test/Preprocessor/avr-attiny104.c
@@ -1,4 +1,3 @@
-// REQUIRES: avr-registered-target
 // RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu attiny104 
/dev/null | FileCheck -match-full-lines %s
 
 // CHECK: #define AVR 1
Index: clang/test/Preprocessor/avr-atmega328p.c
===
--- clang/test/Preprocessor/avr-atmega328p.c
+++ clang/test/Preprocessor/avr-atmega328p.c
@@ -1,4 +1,3 @@
-// REQUIRES: avr-registered-target
 // RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu atmega328p 
/dev/null | FileCheck -match-full-lines %s
 
 // CHECK: #define AVR 1


Index: clang/test/Preprocessor/avr-common.c
===
--- clang/test/Preprocessor/avr-common.c
+++ clang/test/Preprocessor/avr-common.c
@@ -1,4 +1,3 @@
-// REQUIRES: avr-registered-target
 // RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown /dev/null | FileCheck -match-full-lines %s
 
 // CHECK: #define AVR 1
Index: clang/test/Preprocessor/avr-attiny104.c
===
--- clang/test/Preprocessor/avr-attiny104.c
+++ clang/test/Preprocessor/avr-attiny104.c
@@ -1,4 +1,3 @@
-// REQUIRES: avr-registered-target
 // RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu attiny104 /dev/null | FileCheck -match-full-lines %s
 
 // CHECK: #define AVR 1
Index: clang/test/Preprocessor/avr-atmega328p.c
===
--- clang/test/Preprocessor/avr-atmega328p.c
+++ clang/test/Preprocessor/avr-atmega328p.c
@@ -1,4 +1,3 @@
-// REQUIRES: avr-registered-target
 // RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu atmega328p /dev/null | FileCheck -match-full-lines %s
 
 // CHECK: #define AVR 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ceba881 - [AVR][NFC] Move preprocessor tests to Preprocessor directory

2020-04-25 Thread Ayke van Laethem via cfe-commits

Author: Ayke van Laethem
Date: 2020-04-26T01:29:25+02:00
New Revision: ceba881aeac1e24dcffb1eecdc6507c0701f6865

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

LOG: [AVR][NFC] Move preprocessor tests to Preprocessor directory

These tests were placed in the CodeGen directory while they really
should have been placed in the Preprocessor directory.

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

Added: 
clang/test/Preprocessor/avr-atmega328p.c
clang/test/Preprocessor/avr-attiny104.c
clang/test/Preprocessor/avr-common.c

Modified: 


Removed: 
clang/test/CodeGen/avr/target-cpu-defines/atmega328p.c
clang/test/CodeGen/avr/target-cpu-defines/attiny104.c
clang/test/CodeGen/avr/target-cpu-defines/common.c



diff  --git a/clang/test/CodeGen/avr/target-cpu-defines/atmega328p.c 
b/clang/test/Preprocessor/avr-atmega328p.c
similarity index 88%
rename from clang/test/CodeGen/avr/target-cpu-defines/atmega328p.c
rename to clang/test/Preprocessor/avr-atmega328p.c
index 29f8fa6325ec..78db00ac9243 100644
--- a/clang/test/CodeGen/avr/target-cpu-defines/atmega328p.c
+++ b/clang/test/Preprocessor/avr-atmega328p.c
@@ -1,4 +1,3 @@
-// REQUIRES: avr-registered-target
 // RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu atmega328p 
/dev/null | FileCheck -match-full-lines %s
 
 // CHECK: #define AVR 1

diff  --git a/clang/test/CodeGen/avr/target-cpu-defines/attiny104.c 
b/clang/test/Preprocessor/avr-attiny104.c
similarity index 88%
rename from clang/test/CodeGen/avr/target-cpu-defines/attiny104.c
rename to clang/test/Preprocessor/avr-attiny104.c
index 3f3d8714591e..29caffaeb3b8 100644
--- a/clang/test/CodeGen/avr/target-cpu-defines/attiny104.c
+++ b/clang/test/Preprocessor/avr-attiny104.c
@@ -1,4 +1,3 @@
-// REQUIRES: avr-registered-target
 // RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown -target-cpu attiny104 
/dev/null | FileCheck -match-full-lines %s
 
 // CHECK: #define AVR 1

diff  --git a/clang/test/CodeGen/avr/target-cpu-defines/common.c 
b/clang/test/Preprocessor/avr-common.c
similarity index 85%
rename from clang/test/CodeGen/avr/target-cpu-defines/common.c
rename to clang/test/Preprocessor/avr-common.c
index 3f938522e7eb..8a03c1d91ab5 100644
--- a/clang/test/CodeGen/avr/target-cpu-defines/common.c
+++ b/clang/test/Preprocessor/avr-common.c
@@ -1,4 +1,3 @@
-// REQUIRES: avr-registered-target
 // RUN: %clang_cc1 -E -dM -triple avr-unknown-unknown /dev/null | FileCheck 
-match-full-lines %s
 
 // CHECK: #define AVR 1



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


[PATCH] D78853: [Sema] Fix null pointer dereference warnings [1/n]

2020-04-25 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Please don't add null checks for pointers that can't be null.  It makes the 
code slower and harder to understand.  And least one of the checks you added is 
actively breaking the code.

In some cases, the analysis is pointing to cases where the code could be made 
more clear for both humans and machines with some refactoring or assertions.  
Patches welcome, but please make sure any assertions properly explain the 
invariant. And please split the patches up a bit more; adding assertions for 
complex invariants in ten different unrelated places is more than I really want 
to review at once.

(Also, a reminder, please post patches with full context.)


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

https://reviews.llvm.org/D78853



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


[PATCH] D61756: Add a __FILE_NAME__ macro.

2020-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D61756#2003847 , @kristina wrote:

> In D61756#2003836 , @MaskRay wrote:
>
> > > @rmisth wrote: "Clang should drive the standard, not diverge from it", 
> > > and we should at least try to push for standardizing this if we think 
> > > it's worthwhile as an alternative to __FILE__.
> >
> >
> >
> > In D61756#1505296 , @kristina 
> > wrote:
> >
> > > Revised to use `llvm::sys::path::filename` to avoid issues on Windows 
> > > hosts.
> >
> >
> > Hi @kristina, have you followed up with the extension on WG14 or WG21 
> > mailing lists? There is a similar GCC feature request which you may want to 
> > comment as well https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77488
>
>
> I did try bringing this up with GCC developers at one point but the 
> overwhelming consensus was that there wasn't a need for such an extension as 
> 'it's possible to just `#define FILENAME "foo.c"`', with regards to WG14, I 
> was told it was best to get it adopted by other compiler vendors first (ie. 
> GCC). Been pretty sick recently so haven't had time to chase up a lot of 
> loose ends up, should probably get back to that, but it seems WG21 may be the 
> best bet at this point. I'll try to get back on top of everything soon, 
> sorry. Have a pretty big backlog of other things that have also accumulated 
> too.


Thanks for your prompt reply. Hope you will get better soon. I was searching 
for some unrelated things on GCC's issue tracker when I happened to find 
`Proposal for __FILENAME_ONLY__` which reminded me of this issue. Glad that 
you've brought up this to them. I just want the compiler extensions to be 
compatible if they are going to implement the similar thing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


[PATCH] D61756: Add a __FILE_NAME__ macro.

2020-04-25 Thread Kristina Brooks via Phabricator via cfe-commits
kristina added a comment.

In D61756#2003836 , @MaskRay wrote:

> > @rmisth wrote: "Clang should drive the standard, not diverge from it", and 
> > we should at least try to push for standardizing this if we think it's 
> > worthwhile as an alternative to __FILE__.
>
>
>
> In D61756#1505296 , @kristina wrote:
>
> > Revised to use `llvm::sys::path::filename` to avoid issues on Windows hosts.
>
>
> Hi @kristina, have you followed up with the extension on WG14 or WG21 mailing 
> lists? There is a similar GCC feature request which you may want to comment 
> as well https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77488


I did try bringing this up with GCC developers at one point but the 
overwhelming consensus was that there wasn't a need for such an extension as 
'it's possible to just `#define FILENAME "foo.c"`', with regards to WG14, I was 
told it was best to get it adopted by other compiler vendors first (ie. GCC). 
Been pretty sick recently so haven't had time to chase up a lot of loose ends 
up, should probably get back to that, but it seems WG21 may be the best bet at 
this point. I'll try to get back on top of everything soon, sorry. Have a 
pretty big backlog of other things that have also accumulated too.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


[PATCH] D61756: Add a __FILE_NAME__ macro.

2020-04-25 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> @rmisth wrote: "Clang should drive the standard, not diverge from it", and we 
> should at least try to push for standardizing this if we think it's 
> worthwhile as an alternative to __FILE__.



In D61756#1505296 , @kristina wrote:

> Revised to use `llvm::sys::path::filename` to avoid issues on Windows hosts.


Hi @kristina, have you followed up with the extension on WG14 or WG21 mailing 
lists? There is a similar GCC feature request which you may want to comment as 
well https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77488


Repository:
  rC Clang

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

https://reviews.llvm.org/D61756



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


[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added a comment.

In D78655#2003681 , @hliao wrote:

> I though the goal of adding HD/D attributes for lambda is to make the static 
> check easier as lambda used in device code or device lambda is sensitive to 
> captures. Invalid capture may render error accidentally without static check, 
> says we capture host variable reference in a device lambda. That makes the 
> final code invalid. Allowing regular lambda to be used in global or device 
> function is considering harmful.


Inferring a lambda function by default as `__host__ __device__` does not mean 
skipping the check for harmful captures.

If we add such checks, it does not matter whether the `__host__ __device__` 
attribute is explicit or implicit, they go through the same check.

How to infer the device/host-ness of a lambda function is a usability issue. It 
is orthogonal to the issue of missing diagnostics about captures.

Forcing users to explicitly mark a lambda function as `__device__ __host__` 
itself does not help diagnose the harmful captures if such diags do not exist.

Let's think about a lambda function which captures references to host 
variables. If it is only used in host code, as in ordinary C++ host code. 
Marking it `host device` implicitly does not change anything, since it is not 
emitted in device code. If it is used in device code, it will likely cause mem 
fault at run time since currently we do not diagnose it. Does it help if we 
force users to mark it `__device__ __host__`? I don't think so. Users will just 
reluctantly add `__device__ __host__` to it and they still end up as mem fault. 
If we add the diagnostic about the harmful captures, it does not matter whether 
the `__device__ __host__` attribute is explicit or implicit, users get the same 
diagnostic about harmful captures. So the effect is the same. However, 
usability is improved if users do not need to add `__device__ __host__` by 
themselves.

Does inferring lambda function as `__device__ __host__` by default making the 
diagnostic about harmful captures more difficult? No. It should be the same for 
lambdas with explicit `__device__ __host__`. This needs to be a deferred 
diagnostic like those we already did, which are only emitted if the function is 
really emitted. It does not matter whether the device/host attrs are implicit 
or explicit.


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

https://reviews.llvm.org/D78655



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


[PATCH] D78869: clang-format: Add ControlStatementsExceptForEachMacros option to SpaceBeforeParens

2020-04-25 Thread Daan De Meyer via Phabricator via cfe-commits
DaanDeMeyer created this revision.
DaanDeMeyer added a reviewer: clang-format.
DaanDeMeyer added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

systemd  recently added a clang-format 
file. One issue I encountered in using clang-format on systemd is that systemd 
does not add a space before the parens of their foreach macros but clang-format 
always adds a space. This does not seem to be configurable in clang-format. 
This revision adds the ControlStatementsExceptForEachMacros option to 
SpaceBeforeParens which puts a space before all control statement parens except 
ForEach macros. This drastically reduces the amount of changes when running 
clang-format on systemd's source code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78869

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  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
@@ -972,6 +972,16 @@
"  UNKNOWN_FORACH(Item * item, itemlist) {}\n"
"}");
 
+  FormatStyle Style = getLLVMStyle();
+  Style.SpaceBeforeParens =
+  FormatStyle::SBPO_ControlStatementsExceptForEachMacros;
+  verifyFormat("void f() {\n"
+   "  foreach(Item *item, itemlist) {}\n"
+   "  Q_FOREACH(Item *item, itemlist) {}\n"
+   "  BOOST_FOREACH(Item *item, itemlist) {}\n"
+   "  UNKNOWN_FORACH(Item * item, itemlist) {}\n"
+   "}", Style);
+
   // As function-like macros.
   verifyFormat("#define foreach(x, y)\n"
"#define Q_FOREACH(x, y)\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2889,6 +2889,10 @@
 if ((Left.is(tok::r_paren) && Left.is(TT_AttributeParen)) ||
 (Left.is(tok::r_square) && Left.is(TT_AttributeSquare)))
   return true;
+if (Style.SpaceBeforeParens ==
+FormatStyle::SBPO_ControlStatementsExceptForEachMacros &&
+Left.is(TT_ForEachMacro))
+  return false;
 return Line.Type == LT_ObjCDecl || Left.is(tok::semi) ||
(Style.SpaceBeforeParens != FormatStyle::SBPO_Never &&
 (Left.isOneOf(tok::pp_elif, tok::kw_for, tok::kw_while,
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -327,6 +327,8 @@
 IO.enumCase(Value, "Never", FormatStyle::SBPO_Never);
 IO.enumCase(Value, "ControlStatements",
 FormatStyle::SBPO_ControlStatements);
+IO.enumCase(Value, "ControlStatementsExceptForEachMacros",
+FormatStyle::SBPO_ControlStatementsExceptForEachMacros);
 IO.enumCase(Value, "NonEmptyParentheses",
 FormatStyle::SBPO_NonEmptyParentheses);
 IO.enumCase(Value, "Always", FormatStyle::SBPO_Always);
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1954,6 +1954,7 @@
 ///}
 /// \endcode
 SBPO_ControlStatements,
+SBPO_ControlStatementsExceptForEachMacros,
 /// Put a space before opening parentheses only if the parentheses are not
 /// empty i.e. '()'
 /// \code
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2308,6 +2308,19 @@
  }
}
 
+  * ``SBPO_ControlStatementsExceptForEachMacros`` (in configuration: 
+``ControlStatementsExceptForEachMacros``)
+Same as ``SBPO_ControlStatements`` except this option doesn't apply to
+ForEach macros.
+
+.. code-block:: c++
+
+   void f() {
+ Q_FOREACH(...) {
+   f();
+ }
+   }
+
   * ``SBPO_NonEmptyParentheses`` (in configuration: ``NonEmptyParentheses``)
 Put a space before opening parentheses only if the parentheses are not
 empty i.e. '()'


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -972,6 +972,16 @@
"  UNKNOWN_FORACH(Item * item, itemlist) {}\n"
"}");
 
+  FormatStyle Style = getLLVMStyle();
+  Style.SpaceBeforeParens =
+  FormatStyle::SBPO_ControlStatementsExceptForEachMacros;
+  verifyFormat("void f() {\n"
+   "  foreach(Item *item, itemlist) {}\n"
+  

[PATCH] D78862: [IR] Convert null-pointer-is-valid into an enum attribute

2020-04-25 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D78862#2003684 , @arsenm wrote:

> FWIW I think this attribute should be replaced with a data layout property, 
> so this would eventually be removed


Is this change planned more for the near term or the long term? I'm not really 
familiar with ongoing addrspace related work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78862



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


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

2020-04-25 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6fb80d9383e4: libclang: Add static build support for Windows 
(authored by cristian.adam, committed by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75068

Files:
  clang/include/clang-c/Platform.h
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -77,14 +77,18 @@
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC OR WIN32)
+if(LLVM_ENABLE_PIC OR NOT LIBCLANG_BUILD_STATIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
-if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32)
+if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC)
   set(ENABLE_STATIC STATIC)
 endif()
 
+if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC)
+  unset(ENABLE_STATIC)
+endif()
+
 if(WIN32)
   set(output_name "libclang")
 else()
@@ -113,6 +117,14 @@
   Support
   )
 
+if(ENABLE_STATIC)
+  foreach(name libclang obj.libclang libclang_static)
+if (TARGET ${name})
+  target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS)
+endif()
+  endforeach()
+endif()
+
 if(ENABLE_SHARED)
   if(WIN32)
 set_target_properties(libclang
Index: clang/include/clang-c/Platform.h
===
--- clang/include/clang-c/Platform.h
+++ clang/include/clang-c/Platform.h
@@ -18,14 +18,23 @@
 
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
-/* MSVC DLL import/export. */
-#ifdef _MSC_VER
-  #ifdef _CINDEX_LIB_
-#define CINDEX_LINKAGE __declspec(dllexport)
-  #else
-#define CINDEX_LINKAGE __declspec(dllimport)
+/* Windows DLL import/export. */
+#ifndef CINDEX_NO_EXPORTS
+  #define CINDEX_EXPORTS
+#endif
+#ifdef _WIN32
+  #ifdef CINDEX_EXPORTS
+#ifdef _CINDEX_LIB_
+  #define CINDEX_LINKAGE __declspec(dllexport)
+#else
+  #define CINDEX_LINKAGE __declspec(dllimport)
+#endif
   #endif
-#else
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
+  #define CINDEX_LINKAGE __attribute__((visibility("default")))
+#endif
+
+#ifndef CINDEX_LINKAGE
   #define CINDEX_LINKAGE
 #endif
 


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -77,14 +77,18 @@
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC OR WIN32)
+if(LLVM_ENABLE_PIC OR NOT LIBCLANG_BUILD_STATIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
-if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32)
+if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC)
   set(ENABLE_STATIC STATIC)
 endif()
 
+if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC)
+  unset(ENABLE_STATIC)
+endif()
+
 if(WIN32)
   set(output_name "libclang")
 else()
@@ -113,6 +117,14 @@
   Support
   )
 
+if(ENABLE_STATIC)
+  foreach(name libclang obj.libclang libclang_static)
+if (TARGET ${name})
+  target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS)
+endif()
+  endforeach()
+endif()
+
 if(ENABLE_SHARED)
   if(WIN32)
 set_target_properties(libclang
Index: clang/include/clang-c/Platform.h
===
--- clang/include/clang-c/Platform.h
+++ clang/include/clang-c/Platform.h
@@ -18,14 +18,23 @@
 
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
-/* MSVC DLL import/export. */
-#ifdef _MSC_VER
-  #ifdef _CINDEX_LIB_
-#define CINDEX_LINKAGE __declspec(dllexport)
-  #else
-#define CINDEX_LINKAGE __declspec(dllimport)
+/* Windows DLL import/export. */
+#ifndef CINDEX_NO_EXPORTS
+  #define CINDEX_EXPORTS
+#endif
+#ifdef _WIN32
+  #ifdef CINDEX_EXPORTS
+#ifdef _CINDEX_LIB_
+  #define CINDEX_LINKAGE __declspec(dllexport)
+#else
+  #define CINDEX_LINKAGE __declspec(dllimport)
+#endif
   #endif
-#else
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
+  #define CINDEX_LINKAGE __attribute__((visibility("default")))
+#endif
+
+#ifndef CINDEX_LINKAGE
   #define CINDEX_LINKAGE
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6fb80d9 - libclang: Add static build support for Windows

2020-04-25 Thread Martin Storsjö via cfe-commits

Author: Cristian Adam
Date: 2020-04-25T20:19:17+03:00
New Revision: 6fb80d9383e415c35204b62569972f70ae7dcb0a

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

LOG: libclang: Add static build support for Windows

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

Added: 


Modified: 
clang/include/clang-c/Platform.h
clang/tools/libclang/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang-c/Platform.h 
b/clang/include/clang-c/Platform.h
index 3bb66bb0df48..67c1fff8ff78 100644
--- a/clang/include/clang-c/Platform.h
+++ b/clang/include/clang-c/Platform.h
@@ -18,14 +18,23 @@
 
 LLVM_CLANG_C_EXTERN_C_BEGIN
 
-/* MSVC DLL import/export. */
-#ifdef _MSC_VER
-  #ifdef _CINDEX_LIB_
-#define CINDEX_LINKAGE __declspec(dllexport)
-  #else
-#define CINDEX_LINKAGE __declspec(dllimport)
+/* Windows DLL import/export. */
+#ifndef CINDEX_NO_EXPORTS
+  #define CINDEX_EXPORTS
+#endif
+#ifdef _WIN32
+  #ifdef CINDEX_EXPORTS
+#ifdef _CINDEX_LIB_
+  #define CINDEX_LINKAGE __declspec(dllexport)
+#else
+  #define CINDEX_LINKAGE __declspec(dllimport)
+#endif
   #endif
-#else
+#elif defined(CINDEX_EXPORTS) && defined(__GNUC__)
+  #define CINDEX_LINKAGE __attribute__((visibility("default")))
+#endif
+
+#ifndef CINDEX_LINKAGE
   #define CINDEX_LINKAGE
 #endif
 

diff  --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index bd0c945a5e12..bb2b14cc8e27 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -77,14 +77,18 @@ if(MSVC)
   set(LLVM_EXPORTED_SYMBOL_FILE)
 endif()
 
-if(LLVM_ENABLE_PIC OR WIN32)
+if(LLVM_ENABLE_PIC OR NOT LIBCLANG_BUILD_STATIC)
   set(ENABLE_SHARED SHARED)
 endif()
 
-if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32)
+if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC)
   set(ENABLE_STATIC STATIC)
 endif()
 
+if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC)
+  unset(ENABLE_STATIC)
+endif()
+
 if(WIN32)
   set(output_name "libclang")
 else()
@@ -113,6 +117,14 @@ add_clang_library(libclang ${ENABLE_SHARED} 
${ENABLE_STATIC} INSTALL_WITH_TOOLCH
   Support
   )
 
+if(ENABLE_STATIC)
+  foreach(name libclang obj.libclang libclang_static)
+if (TARGET ${name})
+  target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS)
+endif()
+  endforeach()
+endif()
+
 if(ENABLE_SHARED)
   if(WIN32)
 set_target_properties(libclang



___
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-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.

thanks, lgtm. do you have commit access?




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]);

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.


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


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

2020-04-25 Thread Adrian McCarthy via cfe-commits
I completed the bisect, and it is indeed the change in spacing between the
`>`s that triggers the problem with the visualizers.

That said, I'm still suspicious that the std::map visualizer isn't quite
right with how it uses the wild cards and the template parameter
placeholder(s), but I don't think fixing that makes up for the fact that VS
expects the spaces.

On Thu, Apr 23, 2020 at 11:21 AM Reid Kleckner via Phabricator <
revi...@reviews.llvm.org> wrote:

> rnk added a comment.
>
> Thanks David, I'm comfortable with that stance for DWARF.
>
> I know @amccarth is looking into the recent VS visualizer issue, and I
> would like him to confirm if it was this change or not when he gets a
> chance.
>
>
> 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] D74765: [compiler-rt] Addd FreeBSD arm64 sanitizer support

2020-04-25 Thread Greg V via Phabricator via cfe-commits
myfreeweb added a comment.

With TBI enabled in the system , HWASAN 
should also work, I've had it running some time ago




Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:1836
   return fsr & FSR_WRITE ? WRITE : READ;
-#elif defined(__aarch64__)
+#elif defined(__aarch64__) && SANITIZER_LINUX
   static const u64 ESR_ELx_WNR = 1U << 6;

Sooo do we just leave this `UNKNOWN`?..

Shouldn't the system [[ https://reviews.freebsd.org/D20838 | expose it ]]?

I wonder which sanitizers actually require it…


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74765



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


[PATCH] D78862: [IR] Convert null-pointer-is-valid into an enum attribute

2020-04-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D78862#2003684 , @arsenm wrote:

> FWIW I think this attribute should be replaced with a data layout property, 
> so this would eventually be removed


Also would be address space specific


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78862



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


[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-25 Thread Michael Liao via Phabricator via cfe-commits
hliao added inline comments.



Comment at: clang/test/CodeGenCUDA/lambda.cu:83
+void test_resolve(void) {
+  test_resolve_helper([&](){ overloaded();});
+}

We are allowing regular lambda to be used in the device functions. That should 
be explicitly marked by making that lambda `__device__` or `__host__ 
__device__`. Even though we may not have static checks for capture so far, that 
should be easily extended with those attributes.


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

https://reviews.llvm.org/D78655



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


[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-25 Thread Michael Liao via Phabricator via cfe-commits
hliao requested changes to this revision.
hliao added a comment.
This revision now requires changes to proceed.

In D78655#1997491 , @tra wrote:

> Summoning @rsmith as I'm sure that there are interesting corner cases in 
> lambda handling that we didn't consider.
>
> Making lambdas implicitly HD will make it easier to write the code which 
> can't be instantiated on one side of the compilation. That's probably 
> observable via SFINAE, but I can't tell whether that matters.
>  By default I'd rather err on handling lambdas the same way as we do regular 
> user-authored functions.


Marking lambda `__device__`/`__device__ __host__` should be

In D78655#1997491 , @tra wrote:

> Summoning @rsmith as I'm sure that there are interesting corner cases in 
> lambda handling that we didn't consider.
>
> Making lambdas implicitly HD will make it easier to write the code which 
> can't be instantiated on one side of the compilation. That's probably 
> observable via SFINAE, but I can't tell whether that matters.
>  By default I'd rather err on handling lambdas the same way as we do regular 
> user-authored functions.


Marking lambda with proper attributes helps check the potential harmful 
captures.

In D78655#1997491 , @tra wrote:

> Summoning @rsmith as I'm sure that there are interesting corner cases in 
> lambda handling that we didn't consider.
>
> Making lambdas implicitly HD will make it easier to write the code which 
> can't be instantiated on one side of the compilation. That's probably 
> observable via SFINAE, but I can't tell whether that matters.
>  By default I'd rather err on handling lambdas the same way as we do regular 
> user-authored functions.


I though the goal of adding HD/D attributes for lambda is to make the static 
check easier as lambda used in device code or device lambda is sensitive to 
captures. Invalid capture may render error accidentally without static check, 
says we capture host variable reference in a device lambda. That makes the 
final code invalid. Allowing regular lambda to be used in global or device 
function is considering harmful.


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

https://reviews.llvm.org/D78655



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


[PATCH] D78862: [IR] Convert null-pointer-is-valid into an enum attribute

2020-04-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

FWIW I think this attribute should be replaced with a data layout property, so 
this would eventually be removed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78862



___
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-25 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 260108.
steakhal retitled this revision from "[analyzer][Z3-refutation] Fix refutation 
BugReporterVisitor bug and refactor" to "[analyzer][Z3-refutation] Fix a 
refutation BugReporterVisitor bug".
steakhal edited the summary of this revision.
steakhal added a comment.

- fix patch summary
- fix patch title
- renamed function parameter to `OverwriteConstraintsOnExistingSyms`
- fixed `x+y` to `x+n` in the test comment


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

https://reviews.llvm.org/D78457

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp

Index: clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
===
--- clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
+++ clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -170,6 +170,54 @@
 "test.FalsePositiveGenerator:CAN_BE_TRUE\n");
 }
 
+TEST(FalsePositiveRefutationBRVisitor,
+ UnSatAtErrorNodeDueToRefinedConstraintNoReport) {
+  SKIP_WITHOUT_Z3;
+  constexpr auto Code = R"(
+void reportIfCanBeTrue(bool);
+void reachedWithNoContradiction();
+void test(unsigned x, unsigned n) {
+  if (n >= 1 && n <= 2) {
+if (x >= 3)
+  return;
+// x: [0,2] and n: [1,2]
+int y = x + n; // y: '(x+n)' Which is in approximately between 1 and 4.
+
+// Registers the symbol 'y' with the constraint [1, MAX] in the true
+// branch.
+if (y > 0) {
+  // Since the x: [0,2] and n: [1,2], the 'y' is indeed greater than
+  // zero. If we emit a warning here, the constraints on the BugPath is
+  // SAT. Therefore that report is NOT invalidated.
+  reachedWithNoContradiction(); // 'y' can be greater than zero. OK
+
+  // If we ask the analyzer whether the 'y' can be 5. It won't know,
+  // therefore, the state will be created where the 'y' expression is 5.
+  // Although, this assumption is false!
+  // 'y' can not be 5 if the maximal value of both x and n is 2.
+  // The BugPath which become UnSAT in the ErrorNode with a refined
+  // constraint, should be invalidated.
+  reportIfCanBeTrue(y == 5);
+}
+  }
+})";
+
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCodeWithArgs(
+  Code, LazyAssumeAndCrossCheckArgs, Diags));
+  EXPECT_EQ(Diags,
+"test.FalsePositiveGenerator:REACHED_WITH_NO_CONTRADICTION\n");
+  // Single warning. The second report was invalidated by the visitor.
+
+  // Without enabling the crosscheck-with-z3 both reports are displayed.
+  std::string Diags2;
+  EXPECT_TRUE(runCheckerOnCodeWithArgs(
+  Code, LazyAssumeArgs, Diags2));
+  EXPECT_EQ(Diags2,
+"test.FalsePositiveGenerator:REACHED_WITH_NO_CONTRADICTION\n"
+"test.FalsePositiveGenerator:CAN_BE_TRUE\n");
+}
+
 } // namespace
 } // namespace ento
 } // namespace clang
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2820,7 +2820,7 @@
 BugReporterContext , const ExplodedNode *EndPathNode,
 PathSensitiveBugReport ) {
   // Collect new constraints
-  VisitNode(EndPathNode, BRC, BR);
+  addConstraints(EndPathNode, /*OverwriteConstraintsOnExistingSyms=*/true);
 
   // Create a refutation manager
   llvm::SMTSolverRef RefutationSolver = llvm::CreateZ3Solver();
@@ -2831,30 +2831,30 @@
 const SymbolRef Sym = I.first;
 auto RangeIt = I.second.begin();
 
-llvm::SMTExprRef Constraints = SMTConv::getRangeExpr(
+llvm::SMTExprRef SMTConstraints = SMTConv::getRangeExpr(
 RefutationSolver, Ctx, Sym, RangeIt->From(), RangeIt->To(),
 /*InRange=*/true);
 while ((++RangeIt) != I.second.end()) {
-  Constraints = RefutationSolver->mkOr(
-  Constraints, SMTConv::getRangeExpr(RefutationSolver, Ctx, Sym,
- RangeIt->From(), RangeIt->To(),
- /*InRange=*/true));
+  SMTConstraints = RefutationSolver->mkOr(
+  SMTConstraints, SMTConv::getRangeExpr(RefutationSolver, Ctx, Sym,
+RangeIt->From(), RangeIt->To(),
+/*InRange=*/true));
 }
 
-RefutationSolver->addConstraint(Constraints);
+RefutationSolver->addConstraint(SMTConstraints);
   }
 
   // And check for satisfiability
-  Optional isSat = RefutationSolver->check();
-  if (!isSat.hasValue())
+  Optional IsSAT = 

[PATCH] D78862: [IR] Convert null-pointer-is-valid into an enum attribute

2020-04-25 Thread Nikita Popov via Phabricator via cfe-commits
nikic updated this revision to Diff 260105.
nikic added a comment.
Herald added subscribers: cfe-commits, Kayjukh, frgossen, grosul1, Joonsoo, 
liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, 
shauheen, jpienaar, rriddle, mehdi_amini, asbirlea, jfb, george.burgess.iv.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: ftynse.
Herald added a project: clang.

Update tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78862

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/delete-null-pointer-checks.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/AutoUpgrade.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Analysis/MemorySSA/cyclicphi.ll
  llvm/test/Bitcode/attributes.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Attributor/align.ll
  llvm/test/Transforms/Attributor/nocapture-1.ll
  llvm/test/Transforms/Attributor/nonnull.ll
  llvm/test/Transforms/Attributor/norecurse.ll
  llvm/test/Transforms/Attributor/undefined_behavior.ll
  llvm/test/Transforms/CorrelatedValuePropagation/non-null.ll
  llvm/test/Transforms/FunctionAttrs/nocapture.ll
  llvm/test/Transforms/FunctionAttrs/nonnull.ll
  llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-1-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-1.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-2-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-2.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-3-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-3.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-4-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-4.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-phi-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/heap-sra-phi.ll
  llvm/test/Transforms/GlobalOpt/load-store-global-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-1-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-1.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-2-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/malloc-promote-2.ll
  llvm/test/Transforms/GlobalOpt/storepointer-compare-no-null-opt.ll
  llvm/test/Transforms/GlobalOpt/storepointer-no-null-opt.ll
  llvm/test/Transforms/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Inline/attributes.ll
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/invariant.group.ll
  llvm/test/Transforms/InstCombine/invoke.ll
  llvm/test/Transforms/InstCombine/lifetime-no-null-opt.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/mem-deref-bytes.ll
  llvm/test/Transforms/InstCombine/memchr.ll
  llvm/test/Transforms/InstCombine/memcpy-addrspace.ll
  llvm/test/Transforms/InstCombine/memcpy-from-global.ll
  llvm/test/Transforms/InstCombine/memrchr.ll
  llvm/test/Transforms/InstCombine/select.ll
  llvm/test/Transforms/InstCombine/store.ll
  llvm/test/Transforms/InstCombine/strchr-1.ll
  llvm/test/Transforms/InstCombine/strcpy_chk-64.ll
  llvm/test/Transforms/InstCombine/strlen-1.ll
  llvm/test/Transforms/InstCombine/strncat-2.ll
  llvm/test/Transforms/InstCombine/strncmp-1.ll
  llvm/test/Transforms/InstCombine/strrchr-1.ll
  llvm/test/Transforms/InstCombine/strstr-1.ll
  llvm/test/Transforms/InstCombine/wcslen-1.ll
  llvm/test/Transforms/InstSimplify/compare.ll
  llvm/test/Transforms/LoopIdiom/pr28196.ll
  llvm/test/Transforms/LoopVersioning/lcssa.ll
  llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
  llvm/test/Transforms/SimplifyCFG/invoke.ll
  llvm/test/Transforms/SimplifyCFG/phi-undef-loadstore.ll
  llvm/test/Transforms/SimplifyCFG/trap-no-null-opt-debugloc.ll
  llvm/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
  llvm/test/Transforms/Util/assume-builder.ll
  mlir/test/Target/llvmir.mlir

Index: mlir/test/Target/llvmir.mlir
===
--- mlir/test/Target/llvmir.mlir
+++ mlir/test/Target/llvmir.mlir
@@ -1205,12 +1205,12 @@
 
 // CHECK-LABEL: @passthrough
 // CHECK: #[[ATTR_GROUP:[0-9]*]]
-llvm.func @passthrough() attributes {passthrough = ["noinline", ["alignstack", "4"], "null-pointer-is-valid", ["foo", "bar"]]} {
+llvm.func @passthrough() attributes {passthrough = ["noinline", ["alignstack", "4"], "null_pointer_is_valid", ["foo", "bar"]]} {
   llvm.return
 }
 
 // CHECK: attributes #[[ATTR_GROUP]] = {
 // CHECK-DAG: noinline
 // CHECK-DAG: 

[PATCH] D78704: [analyzer][NFC] Add unittest for FalsePositiveRefutationBRVisitor

2020-04-25 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 260104.
steakhal edited the summary of this revision.
steakhal added a comment.

- added `GTEST_SKIP` FIXME comment
- reformatted the summary of the patch


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

https://reviews.llvm.org/D78704

Files:
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/CheckerRegistration.h
  clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp

Index: clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp
@@ -0,0 +1,175 @@
+//===- unittests/StaticAnalyzer/FalsePositiveRefutationBRVisitorTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "CheckerRegistration.h"
+#include "Reusables.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "llvm/Config/config.h"
+#include "gtest/gtest.h"
+
+// FIXME: Use GTEST_SKIP() instead if GTest is updated to version 1.10.0
+#define SKIP_WITHOUT_Z3\
+  do   \
+if (!LLVM_WITH_Z3) \
+  return;  \
+  while (0)
+
+namespace clang {
+namespace ento {
+namespace {
+
+class FalsePositiveGenerator : public Checker {
+  using Self = FalsePositiveGenerator;
+  const BuiltinBug FalsePositiveGeneratorBug{this, "FalsePositiveGenerator"};
+  using HandlerFn = bool (Self::*)(const CallEvent ,
+   CheckerContext &) const;
+  CallDescriptionMap Callbacks = {
+  {{"reachedWithContradiction", 0}, ::reachedWithContradiction},
+  {{"reachedWithNoContradiction", 0}, ::reachedWithNoContradiction},
+  {{"reportIfCanBeTrue", 1}, ::reportIfCanBeTrue},
+  };
+
+  bool report(CheckerContext , ProgramStateRef State,
+  StringRef Description) const {
+ExplodedNode *Node = C.generateNonFatalErrorNode(State);
+if (!Node)
+  return false;
+
+auto Report = std::make_unique(
+FalsePositiveGeneratorBug, Description, Node);
+C.emitReport(std::move(Report));
+return true;
+  }
+
+  bool reachedWithNoContradiction(const CallEvent &, CheckerContext ) const {
+return report(C, C.getState(), "REACHED_WITH_NO_CONTRADICTION");
+  }
+
+  bool reachedWithContradiction(const CallEvent &, CheckerContext ) const {
+return report(C, C.getState(), "REACHED_WITH_CONTRADICTION");
+  }
+
+  // Similar to ExprInspectionChecker::analyzerEval except it emits warning only
+  // if the argument can be true. The report emits the report in the state where
+  // the assertion true.
+  bool reportIfCanBeTrue(const CallEvent , CheckerContext ) const {
+// A specific instantiation of an inlined function may have more constrained
+// values than can generally be assumed. Skip the check.
+if (C.getPredecessor()->getLocationContext()->getStackFrame()->getParent())
+  return false;
+
+SVal AssertionVal = Call.getArgSVal(0);
+if (AssertionVal.isUndef())
+  return false;
+
+ProgramStateRef State = C.getPredecessor()->getState();
+ProgramStateRef StTrue;
+std::tie(StTrue, std::ignore) =
+State->assume(AssertionVal.castAs());
+if (StTrue)
+  return report(C, StTrue, "CAN_BE_TRUE");
+return false;
+  }
+
+public:
+  bool evalCall(const CallEvent , CheckerContext ) const {
+if (const HandlerFn *Callback = Callbacks.lookup(Call))
+  return (this->*(*Callback))(Call, C);
+return false;
+  }
+};
+
+void addFalsePositiveGenerator(AnalysisASTConsumer ,
+   AnalyzerOptions ) {
+  AnOpts.CheckersAndPackages = {{"test.FalsePositiveGenerator", true},
+{"debug.ViewExplodedGraph", false}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry ) {
+Registry.addChecker(
+"test.FalsePositiveGenerator", "EmptyDescription", "EmptyDocsUri");
+  });
+}
+
+// C++20 use constexpr below.
+const std::vector LazyAssumeArgs{
+"-Xclang", "-analyzer-config", "-Xclang", 

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

2020-04-25 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks marked an inline comment as done.
aeubanks 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:
> 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?


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] D78836: [clangd] Strip /showIncludes in clangd compile commands

2020-04-25 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 260103.
aeubanks added a comment.

Handle /showIncludes:user


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78836

Files:
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  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,6 +530,62 @@
   EXPECT_TRUE(HasFlag("-w"));
 }
 
+// Check getClangStripDependencyFileAdjuster strips /showIncludes
+TEST(ClangToolTest, StripDependencyFileAdjusterShowIncludes) {
+  FixedCompilationDatabase Compilations("/", {"/showIncludes", "-c"});
+
+  ClangTool Tool(Compilations, std::vector(1, "/a.cc"));
+  Tool.mapVirtualFile("/a.cc", "void a() {}");
+
+  std::unique_ptr Action(
+  newFrontendActionFactory());
+
+  CommandLineArguments FinalArgs;
+  ArgumentsAdjuster CheckFlagsAdjuster =
+  [](const CommandLineArguments , StringRef /*unused*/) {
+FinalArgs = Args;
+return Args;
+  };
+  Tool.clearArgumentsAdjusters();
+  Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
+  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+  Tool.run(Action.get());
+
+  auto HasFlag = [](const std::string ) {
+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 =
+  [](const CommandLineArguments , StringRef /*unused*/) {
+FinalArgs = Args;
+return Args;
+  };
+  Tool.clearArgumentsAdjusters();
+  Tool.appendArgumentsAdjuster(getClangStripDependencyFileAdjuster());
+  Tool.appendArgumentsAdjuster(CheckFlagsAdjuster);
+  Tool.run(Action.get());
+
+  auto HasFlag = [](const std::string ) {
+return llvm::find(FinalArgs, Flag) != FinalArgs.end();
+  };
+  EXPECT_FALSE(HasFlag("/showIncludes:user"));
+  EXPECT_TRUE(HasFlag("-c"));
+}
+
 // Check getClangStripPluginsAdjuster strips plugin related args.
 TEST(ClangToolTest, StripPluginsAdjuster) {
   FixedCompilationDatabase Compilations(
Index: clang/lib/Tooling/ArgumentsAdjusters.cpp
===
--- clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -98,7 +98,7 @@
   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")) {
+  if (!Arg.startswith("-M") && !Arg.startswith("/showIncludes")) {
 AdjustedArgs.push_back(Args[i]);
 continue;
   }
Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -79,6 +79,20 @@
 EXPECT_THAT(Cmd, Not(Contains(Stripped)));
 }
 
+TEST(CommandMangler, StripShowIncludes) {
+  auto Mangler = CommandMangler::forTests();
+  std::vector Cmd = {"clang-cl", "/showIncludes", "foo.cc"};
+  Mangler.adjust(Cmd);
+  EXPECT_THAT(Cmd, Not(Contains("/showIncludes")));
+}
+
+TEST(CommandMangler, StripShowIncludesUser) {
+  auto Mangler = CommandMangler::forTests();
+  std::vector Cmd = {"clang-cl", "/showIncludes:user", "foo.cc"};
+  Mangler.adjust(Cmd);
+  EXPECT_THAT(Cmd, Not(Contains("/showIncludes:user")));
+}
+
 TEST(CommandMangler, ClangPath) {
   auto Mangler = CommandMangler::forTests();
   Mangler.ClangPath = testPath("fake/clang");
___
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-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet 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:
> this can also be --show-includes
and looks like there's also `/showIncludes:user` :/


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] D78655: [HIP] Let lambda be host device by default

2020-04-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added inline comments.



Comment at: clang/test/CodeGenCUDA/lambda.cu:16-26
+template
+__global__ void g(F f) { f(); }
+
+template
+void h(F f) { g<<<1,1>>>(f); }
+
+__device__ int a;

tra wrote:
> yaxunl wrote:
> > tra wrote:
> > > The test example may not be doing what it's seemingly supposed to be 
> > > doing:
> > > https://cppinsights.io/s/3a5c42ff
> > > 
> > > `h()` gets a temporary host-side object which keeps the reference to `a` 
> > > and that reference will actually point to the host-side shadow of the 
> > > actual device-side `a`. When you get to execute `g` it's `this` may not 
> > > be very usable on device side and thus `f.operator()` will probably not 
> > > work.
> > > 
> > > Alas, we currently have no diagnostics for that kind of error.
> > > 
> > > Change it to a non-capturing lambda, perhaps?
> > It works.
> > 
> > We need to think about this in device compilation. In device compilation, 
> > global variable is a device variable, the lambda is a device host function, 
> > therefore the lambda is accessing the real a, not the shadow.
> > 
> > In the host compilation, the lambda is not really called, therefore it is 
> > not emitted.
> > 
> > I will update the lit test with these checks.
> Clang manages to see through to the initializer of `a`, but I'm not sure how 
> much we can rely on this.
> In general, `f.operator()` for a capturing lambda needs to access captured 
> variables via `this` which points to a temporary objects created and passed 
> to `g` by the host. You can see it if you capture a local variable: 
> https://godbolt.org/z/99389o
> 
> Anyways, it's an issue orthogonal to this patch. My concern is that tests are 
> often used as an example of things that are OK to do, and capturing lambdas 
> are a pretty big foot-shooting gun when used with CUDA. It's very easy to do 
> wrong thing without compiler complaining about them.
> While accessing `a` does work, it appears to do so by accident, rather than 
> by design. 
> 
> I'm fairly confident that I can hide the initializer with sufficiently 
> complicated code, force clang to access `a` via `this` and make everything 
> fail at runtime. IMO, what we have here is a 'happens to work' situation. I 
> do not want to call it 'guaranteed to work' without making sure that it 
> always does.
> 
> In order to demonstrate that lambda is host/device, you do not need it to be 
> a capturing lambda. You can make it call an overloaded function with host and 
> device variants and verify that the lambda works on host and device sides.
> 
> 
I added one more test, where a lambda function calls a template function which 
is overloaded with a host version and a device version. The lambda is called in 
both host function and in kernel. Test shows correct version of template 
function are emitted in host and device compilation.

I think it is not a surprise that the lambda function is able to resolve the 
host/device-ness of the callee correctly. We are doing resolution in a host 
device function and the two candidates are same-side vs wrong-side.


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

https://reviews.llvm.org/D78655



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


[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 260094.
yaxunl added a comment.

Added more tests


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

https://reviews.llvm.org/D78655

Files:
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/SemaCUDA/lambda.cu

Index: clang/test/SemaCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/lambda.cu
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+__device__ int a;
+
+int main(void) {
+  auto lambda_kernel = [&]__global__(){ a = 1;};
+  // expected-error@-1 {{kernel function 'operator()' must be a free function or static member function}}
+  lambda_kernel<<<1, 1>>>();
+  return 0;
+}
Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// Device side kernel name.
+// HOST: @[[KERN_CAPTURE:[0-9]+]] = {{.*}} c"_Z1gIZ12test_capturevEUlvE_EvT_\00"
+// HOST: @[[KERN_RESOLVE:[0-9]+]] = {{.*}} c"_Z1gIZ12test_resolvevEUlvE_EvT_\00"
+
+// Check functions emitted for test_capture in host compilation.
+// Check lambda is not emitted in host compilation.
+// HOST-LABEL: define void @_Z12test_capturev
+// HOST:  call void @_Z19test_capture_helperIZ12test_capturevEUlvE_EvT_
+// HOST-LABEL: define internal void @_Z19test_capture_helperIZ12test_capturevEUlvE_EvT_
+// HOST:  call void @_Z16__device_stub__gIZ12test_capturevEUlvE_EvT_
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+
+// Check functions emitted for test_resolve in host compilation.
+// Check host version of template function 'overloaded' is emitted and called
+// by the lambda function.
+// HOST-LABEL: define void @_Z12test_resolvev
+// HOST:  call void @_Z19test_resolve_helperIZ12test_resolvevEUlvE_EvT_()
+// HOST-LABEL: define internal void @_Z19test_resolve_helperIZ12test_resolvevEUlvE_EvT_
+// HOST:  call void @_Z16__device_stub__gIZ12test_resolvevEUlvE_EvT_
+// HOST:  call void @_ZZ12test_resolvevENKUlvE_clEv
+// HOST-LABEL: define internal void @_ZZ12test_resolvevENKUlvE_clEv
+// HOST:  call i32 @_Z10overloadedIiET_v
+// HOST-LABEL: define linkonce_odr i32 @_Z10overloadedIiET_v
+// HOST:  ret i32 2
+
+// Check kernel is registered with correct device side kernel name.
+// HOST: @__hipRegisterFunction({{.*}}@[[KERN_CAPTURE]]
+// HOST: @__hipRegisterFunction({{.*}}@[[KERN_RESOLVE]]
+
+// DEV: @a = addrspace(1) externally_initialized global i32 0
+
+// Check functions emitted for test_capture in device compilation.
+// Check lambda is emitted in device compilation and accessing device variable.
+// DEV-LABEL: define amdgpu_kernel void @_Z1gIZ12test_capturevEUlvE_EvT_
+// DEV:  call void @_ZZ12test_capturevENKUlvE_clEv
+// DEV-LABEL: define internal void @_ZZ12test_capturevENKUlvE_clEv
+// DEV:  store i32 1, i32* addrspacecast (i32 addrspace(1)* @a to i32*)
+
+// Check functions emitted for test_resolve in device compilation.
+// Check device version of template function 'overloaded' is emitted and called
+// by the lambda function.
+// DEV-LABEL: define amdgpu_kernel void @_Z1gIZ12test_resolvevEUlvE_EvT_
+// DEV:  call void @_ZZ12test_resolvevENKUlvE_clEv
+// DEV-LABE: define internal void @_ZZ12test_resolvevENKUlvE_clEv
+// DEV:  call i32 @_Z10overloadedIiET_v
+// DEV-LABEL: define linkonce_odr i32 @_Z10overloadedIiET_v
+// DEV:  ret i32 1
+
+__device__ int a;
+
+template
+__device__ T overloaded() { return 1; }
+
+template
+__host__ T overloaded() { return 2; }
+
+template
+__global__ void g(F f) { f(); }
+
+template
+void test_capture_helper(F f) { g<<<1,1>>>(f); }
+
+template
+void test_resolve_helper(F f) { g<<<1,1>>>(f); f(); }
+
+// Test capture of device variable in lambda function.
+void test_capture(void) {
+  test_capture_helper([&](){ a = 1;});
+}
+
+// Test resolving host/device function in lambda function.
+// Callee should resolve to correct host/device function based on where
+// the lambda function is called, not where it is defined.
+void test_resolve(void) {
+  test_resolve_helper([&](){ overloaded();});
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -718,6 +718,11 @@
   FunctionDecl *CurFn = dyn_cast(CurContext);
   if (!CurFn)
 return;
+  if (getLangOpts().HIP) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
+return;
+  }
   CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
   if (Target == 

[PATCH] D77872: [AArch32] Armv8.6-a Matrix Mult Assembly + Intrinsics

2020-04-25 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson marked an inline comment as done.
LukeGeeson added inline comments.



Comment at: llvm/lib/Target/ARM/ARMInstrNEON.td:4846
+  VDOT {
+  let hasNoSchedulingInfo = 1;
+

dmgreen wrote:
> I don't think that hasNoSchedulingInfo is necessarily the best way to handle 
> this. That flag is intended for instructions that will never be scheduled, 
> like Pseudo instructions.
> 
> If you are running into "Complete Schedule" problems, they might need 
> HasMatMulInt8 added to the list of unsupported features instead.
Since there are no 8.6a cpus in llvm that support this extension, the default 
behaviour is to use Cortex-A57 scheduling - this also has no notion of 8.6a 
matmul.

This falls back to SchedMachineModel in `llvm/lib/Target/ARM/ARMScheduleA57.td` 
and in particular UnsupportedFeatures would be a candidate place to put 
unsupported features like matmul. I took issue with putting all new extensions 
here because there should be a separation of concerns between a particular 
scheduling model, and supporting new behaviour (which could go in a generic 
catch all location that might be slightly more informative ).

Did you have something in particular in mind?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77872



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


[PATCH] D78848: [clangd] Disable delayed template parsing in the main file

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

thanks, LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78848



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


[PATCH] D78833: [clangd] Disable all dependency outputs

2020-04-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG294b9d43cae7: [clangd] Disable all dependency outputs 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78833

Files:
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/test/dependency-output.test


Index: clang-tools-extra/clangd/test/dependency-output.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/dependency-output.test
@@ -0,0 +1,12 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c":
+{"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", 
"-Xclang", "--show-includes", "-Xclang", "-sys-header-deps", "foo.c"]}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"cpp","version":1,"text":"int
 a;\n#include "}}}
+#CHECK-NOT: Note: including file
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -65,6 +65,15 @@
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
+
+  // Disable any dependency outputting, we don't want to generate files or 
write
+  // to stdout/stderr.
+  CI->getDependencyOutputOpts().ShowIncludesDest =
+  ShowIncludesDestination::None;
+  CI->getDependencyOutputOpts().OutputFile.clear();
+  CI->getDependencyOutputOpts().HeaderIncludeOutputFile.clear();
+  CI->getDependencyOutputOpts().DOTOutputFile.clear();
+  CI->getDependencyOutputOpts().ModuleDependencyOutputDir.clear();
   return CI;
 }
 


Index: clang-tools-extra/clangd/test/dependency-output.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/dependency-output.test
@@ -0,0 +1,12 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c":
+{"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", "-Xclang", "--show-includes", "-Xclang", "-sys-header-deps", "foo.c"]}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"cpp","version":1,"text":"int a;\n#include "}}}
+#CHECK-NOT: Note: including file
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -65,6 +65,15 @@
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
+
+  // Disable any dependency outputting, we don't want to generate files or write
+  // to stdout/stderr.
+  CI->getDependencyOutputOpts().ShowIncludesDest =
+  ShowIncludesDestination::None;
+  CI->getDependencyOutputOpts().OutputFile.clear();
+  CI->getDependencyOutputOpts().HeaderIncludeOutputFile.clear();
+  CI->getDependencyOutputOpts().DOTOutputFile.clear();
+  CI->getDependencyOutputOpts().ModuleDependencyOutputDir.clear();
   return CI;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] a940a24 - [clangd] Disable dependency-output lit test on windows

2020-04-25 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-04-25T13:55:38+02:00
New Revision: a940a246f5e14a8fd44586f609b8a675eb949469

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

LOG: [clangd] Disable dependency-output lit test on windows

Added: 


Modified: 
clang-tools-extra/clangd/test/dependency-output.test

Removed: 




diff  --git a/clang-tools-extra/clangd/test/dependency-output.test 
b/clang-tools-extra/clangd/test/dependency-output.test
index 10b493d6611d..ed289bbcdbe4 100644
--- a/clang-tools-extra/clangd/test/dependency-output.test
+++ b/clang-tools-extra/clangd/test/dependency-output.test
@@ -1,3 +1,4 @@
+# UNSUPPORTED: windows-gnu,windows-msvc
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---



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


[clang-tools-extra] 294b9d4 - [clangd] Disable all dependency outputs

2020-04-25 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-04-25T13:51:33+02:00
New Revision: 294b9d43cae77ea15453ec82203368903db4f538

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

LOG: [clangd] Disable all dependency outputs

Summary: Fixes https://github.com/clangd/clangd/issues/322

Reviewers: sammccall

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

Tags: #clang

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

Added: 
clang-tools-extra/clangd/test/dependency-output.test

Modified: 
clang-tools-extra/clangd/Compiler.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Compiler.cpp 
b/clang-tools-extra/clangd/Compiler.cpp
index eae753b5c9b3..47cec5ae12e8 100644
--- a/clang-tools-extra/clangd/Compiler.cpp
+++ b/clang-tools-extra/clangd/Compiler.cpp
@@ -65,6 +65,15 @@ buildCompilerInvocation(const ParseInputs ,
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
+
+  // Disable any dependency outputting, we don't want to generate files or 
write
+  // to stdout/stderr.
+  CI->getDependencyOutputOpts().ShowIncludesDest =
+  ShowIncludesDestination::None;
+  CI->getDependencyOutputOpts().OutputFile.clear();
+  CI->getDependencyOutputOpts().HeaderIncludeOutputFile.clear();
+  CI->getDependencyOutputOpts().DOTOutputFile.clear();
+  CI->getDependencyOutputOpts().ModuleDependencyOutputDir.clear();
   return CI;
 }
 

diff  --git a/clang-tools-extra/clangd/test/dependency-output.test 
b/clang-tools-extra/clangd/test/dependency-output.test
new file mode 100644
index ..10b493d6611d
--- /dev/null
+++ b/clang-tools-extra/clangd/test/dependency-output.test
@@ -0,0 +1,12 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c":
+{"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", 
"-Xclang", "--show-includes", "-Xclang", "-sys-header-deps", "foo.c"]}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"cpp","version":1,"text":"int
 a;\n#include "}}}
+#CHECK-NOT: Note: including file
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}



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


[PATCH] D77872: [AArch32] Armv8.6-a Matrix Mult Assembly + Intrinsics

2020-04-25 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/lib/Target/ARM/ARMInstrNEON.td:4846
+  VDOT {
+  let hasNoSchedulingInfo = 1;
+

I don't think that hasNoSchedulingInfo is necessarily the best way to handle 
this. That flag is intended for instructions that will never be scheduled, like 
Pseudo instructions.

If you are running into "Complete Schedule" problems, they might need 
HasMatMulInt8 added to the list of unsupported features instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77872



___
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-25 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

@whisperity Thanks for the review :3




Comment at: clang/docs/analyzer/user-docs/CrossTranslationUnit.rst:111-114
+  -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-output=plist-multi-file \

whisperity wrote:
> Are these flags documented somewhere?
As with ctu-dir, these flags are only documented in analyzer options. However, 
it would indeed be beneficial to list CTU related flags here in the user 
documentation. I will create a new revision for that specifically.



Comment at: clang/docs/analyzer/user-docs/CrossTranslationUnit.rst:331-335
+  [INFO 2019-07-16 17:21] - To view results in the terminal use the 
"CodeChecker parse" command.
+  [INFO 2019-07-16 17:21] - To store results use the "CodeChecker store" 
command.
+  [INFO 2019-07-16 17:21] - See --help and the user guide for further options 
about parsing and storing the reports.
+  [INFO 2019-07-16 17:21] - =
+  [INFO 2019-07-16 17:21] - Analysis length: 0.659618854523 sec.

whisperity wrote:
> These lines could be removed, I think, they don't add anything to the 
> presentation.
Good point, i remove it from here and from the above example as well.


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-25 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 260078.
gamesh411 marked 15 inline comments as done.
gamesh411 added a comment.

Fix issues in documentation


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  : 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 

[PATCH] D69573: [clang-format] [PR36294] AlwaysBreakAfterReturnType works incorrectly for some operator functions

2020-04-25 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

FYI, in Mozilla build of clang-format, we reverted this change. 
It was causing more issues than fixes.
https://bugzilla.mozilla.org/show_bug.cgi?id=1629853


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69573



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


[PATCH] D74299: [clang-tidy] extend tests of run-clang-tidy

2020-04-25 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin added a comment.

*ping*


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

https://reviews.llvm.org/D74299



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