[PATCH] D56644: [clang-tidy] readability-container-size-empty handle std::string length()

2019-01-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D56644#1355436 , @Quolyk wrote:

> For now, I just added tests. I have several questions, as I'm beginner 
> (`ContainerSizeEmptyCheck.cpp`).
>
> 1. Do I have to extend `ValidContainer`, so it recognises `::std::string` 
> with `length()` method  as valid container too or we can assume 
> `::std::string` as valid container by default?
> 2. If `::std::string` is valid container, I just add one more expression to 
> match. Is it correct way?


https://github.com/llvm-mirror/clang-tools-extra/blob/27011d1db0ee4955bab595ab51ebe264e160ed89/clang-tidy/readability/ContainerSizeEmptyCheck.cpp#L40
i think you want to change `ValidContainer` to not only check for `size`, but 
for `size` or `lenght`.
I.e. replace `hasName("lenght"),` with `anyOf(hasName("size"), 
hasName("lenght")),`.
And then adjust the diags to dynamically get the actual method name.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56644



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


[PATCH] D56644: [clang-tidy] readability-container-size-empty handle std::string length()

2019-01-12 Thread Dmitry Venikov via Phabricator via cfe-commits
Quolyk added a comment.

In D56644#1355434 , @lebedev.ri wrote:

> Either this is a NFC change with just tests, or the actual fix is missing.


Right, it's WIP for now.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56644



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


[PATCH] D56644: [clang-tidy] readability-container-size-empty handle std::string length()

2019-01-12 Thread Dmitry Venikov via Phabricator via cfe-commits
Quolyk added a comment.

For now, I just added tests. I have several questions, as I'm beginner 
(`ContainerSizeEmptyCheck.cpp`).

1. Do I have to extend `ValidContainer`, so it recognises `::std::string` with 
`length()` method  as valid container too or we can assume `::std::string` as 
valid container by default?
2. If `::std::string` is valid container, I just add one more expression to 
match. Is it correct way?




Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56644



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


[PATCH] D56644: [clang-tidy] readability-container-size-empty handle std::string length()

2019-01-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Either this is a NFC change with just tests, or the actual fix is missing.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56644



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


[PATCH] D56644: [clang-tidy] readability-container-size-empty handle std::string length()

2019-01-12 Thread Dmitry Venikov via Phabricator via cfe-commits
Quolyk created this revision.
Quolyk added reviewers: Eugene.Zelenko, omtcyfz, aaron.ballman, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.

Extends readability-container-size-empty to check std::string length() similar 
to size().
Motivation: https://bugs.llvm.org/show_bug.cgi?id=38255.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56644

Files:
  test/clang-tidy/readability-container-size-empty.cpp


Index: test/clang-tidy/readability-container-size-empty.cpp
===
--- test/clang-tidy/readability-container-size-empty.cpp
+++ test/clang-tidy/readability-container-size-empty.cpp
@@ -17,6 +17,7 @@
   bool operator!=(const char *) const;
   basic_string operator+(const basic_string& other) const;
   unsigned long size() const;
+  unsigned long length() const;
   bool empty() const;
 };
 
@@ -106,9 +107,13 @@
   std::string str2;
   std::wstring wstr;
   (void)(str.size() + 0);
+  (void)(str.length() + 0);
   (void)(str.size() - 0);
+  (void)(str.length() - 0);
   (void)(0 + str.size());
+  (void)(0 + str.length());
   (void)(0 - str.size());
+  (void)(0 - str.length());
   if (intSet.size() == 0)
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be 
used to check for emptiness instead of 'size' [readability-container-size-empty]
@@ -125,10 +130,14 @@
   // CHECK-FIXES: {{^  }}if (s_func().empty()){{$}}
   if (str.size() == 0)
 ;
+  if (str.length() == 0)
+;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (str.empty()){{$}}
   if ((str + str2).size() == 0)
 ;
+  if ((str + str2).length() == 0)
+;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if ((str + str2).empty()){{$}}
   if (str == "")
@@ -141,6 +150,8 @@
   // CHECK-FIXES: {{^  }}if ((str + str2).empty()){{$}}
   if (wstr.size() == 0)
 ;
+  if (wstr.length() == 0)
+;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (wstr.empty()){{$}}
   if (wstr == "")


Index: test/clang-tidy/readability-container-size-empty.cpp
===
--- test/clang-tidy/readability-container-size-empty.cpp
+++ test/clang-tidy/readability-container-size-empty.cpp
@@ -17,6 +17,7 @@
   bool operator!=(const char *) const;
   basic_string operator+(const basic_string& other) const;
   unsigned long size() const;
+  unsigned long length() const;
   bool empty() const;
 };
 
@@ -106,9 +107,13 @@
   std::string str2;
   std::wstring wstr;
   (void)(str.size() + 0);
+  (void)(str.length() + 0);
   (void)(str.size() - 0);
+  (void)(str.length() - 0);
   (void)(0 + str.size());
+  (void)(0 + str.length());
   (void)(0 - str.size());
+  (void)(0 - str.length());
   if (intSet.size() == 0)
 ;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
@@ -125,10 +130,14 @@
   // CHECK-FIXES: {{^  }}if (s_func().empty()){{$}}
   if (str.size() == 0)
 ;
+  if (str.length() == 0)
+;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (str.empty()){{$}}
   if ((str + str2).size() == 0)
 ;
+  if ((str + str2).length() == 0)
+;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if ((str + str2).empty()){{$}}
   if (str == "")
@@ -141,6 +150,8 @@
   // CHECK-FIXES: {{^  }}if ((str + str2).empty()){{$}}
   if (wstr.size() == 0)
 ;
+  if (wstr.length() == 0)
+;
   // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: the 'empty' method should be used
   // CHECK-FIXES: {{^  }}if (wstr.empty()){{$}}
   if (wstr == "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-01-12 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn accepted this revision.
Lekensteyn added a comment.
This revision is now accepted and ready to land.

Tests pass here, using it on a large CMake project with a 
CMAKE_BUILD_TYPE=Debug and c/cxxflags `-ffile-prefix-map=$builddir= 
-ffile-prefix-map=$srcdir/= -fuse-ld=lld` successfully strips all traces of 
`$builddir` and `$srcdir`.

If you could take care of the previous comment (undo the rename or rename 
debug-prefix.map.c), then I've no further comments.

If @joerg or someone else could give the final review/pass, that would be great 
:)




Comment at: lib/Driver/ToolChains/Clang.cpp:612
+if (Map.find('=') == StringRef::npos)
+  D.Diag(diag::err_drv_invalid_argument_to_fdebug_prefix_map) << Map;
+else

joerg wrote:
> I'd prefer the bailout style here, i.e. `if (...) { D.diag(...); continue }`
Wouldn't using `if (...) { D.diag(...); continue; }` also skip the `A->claim()` 
call? Presumably that could result in spurious errors as well about unused 
arguments?


Repository:
  rC Clang

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

https://reviews.llvm.org/D49466



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


[PATCH] D56643: NFC: Move Decl node handling to TextNodeDumper

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D56643

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -13,11 +13,42 @@
 
 #include "clang/AST/TextNodeDumper.h"
 
+#include "clang/AST/DeclFriend.h"
+#include "clang/AST/DeclOpenMP.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/LocInfoType.h"
 
 using namespace clang;
 
+static void dumpPreviousDeclImpl(raw_ostream , ...) {}
+
+template 
+static void dumpPreviousDeclImpl(raw_ostream , const Mergeable *D) {
+  const T *First = D->getFirstDecl();
+  if (First != D)
+OS << " first " << First;
+}
+
+template 
+static void dumpPreviousDeclImpl(raw_ostream , const Redeclarable *D) {
+  const T *Prev = D->getPreviousDecl();
+  if (Prev)
+OS << " prev " << Prev;
+}
+
+/// Dump the previous declaration in the redeclaration chain for a declaration,
+/// if any.
+static void dumpPreviousDecl(raw_ostream , const Decl *D) {
+  switch (D->getKind()) {
+#define DECL(DERIVED, BASE)\
+  case Decl::DERIVED:  \
+return dumpPreviousDeclImpl(OS, cast(D));
+#define ABSTRACT_DECL(DECL)
+#include "clang/AST/DeclNodes.inc"
+  }
+  llvm_unreachable("Decl that isn't part of DeclNodes.inc!");
+}
+
 TextNodeDumper::TextNodeDumper(raw_ostream , bool ShowColors,
const SourceManager *SM,
const PrintingPolicy ,
@@ -183,6 +214,48 @@
   OS << " " << T.split().Quals.getAsString();
 }
 
+void TextNodeDumper::Visit(const Decl *D) {
+  if (!D) {
+ColorScope Color(OS, ShowColors, NullColor);
+OS << "<<>>";
+return;
+  }
+
+  {
+ColorScope Color(OS, ShowColors, DeclKindNameColor);
+OS << D->getDeclKindName() << "Decl";
+  }
+  dumpPointer(D);
+  if (D->getLexicalDeclContext() != D->getDeclContext())
+OS << " parent " << cast(D->getDeclContext());
+  dumpPreviousDecl(OS, D);
+  dumpSourceRange(D->getSourceRange());
+  OS << ' ';
+  dumpLocation(D->getLocation());
+  if (D->isFromASTFile())
+OS << " imported";
+  if (Module *M = D->getOwningModule())
+OS << " in " << M->getFullModuleName();
+  if (auto *ND = dyn_cast(D))
+for (Module *M : D->getASTContext().getModulesWithMergedDefinition(
+ const_cast(ND)))
+  AddChild([=] { OS << "also in " << M->getFullModuleName(); });
+  if (const NamedDecl *ND = dyn_cast(D))
+if (ND->isHidden())
+  OS << " hidden";
+  if (D->isImplicit())
+OS << " implicit";
+  if (D->isUsed())
+OS << " used";
+  else if (D->isThisDeclarationReferenced())
+OS << " referenced";
+  if (D->isInvalidDecl())
+OS << " invalid";
+  if (const FunctionDecl *FD = dyn_cast(D))
+if (FD->isConstexpr())
+  OS << " constexpr";
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -442,35 +442,6 @@
   });
 }
 
-static void dumpPreviousDeclImpl(raw_ostream , ...) {}
-
-template
-static void dumpPreviousDeclImpl(raw_ostream , const Mergeable *D) {
-  const T *First = D->getFirstDecl();
-  if (First != D)
-OS << " first " << First;
-}
-
-template
-static void dumpPreviousDeclImpl(raw_ostream , const Redeclarable *D) {
-  const T *Prev = D->getPreviousDecl();
-  if (Prev)
-OS << " prev " << Prev;
-}
-
-/// Dump the previous declaration in the redeclaration chain for a declaration,
-/// if any.
-static void dumpPreviousDecl(raw_ostream , const Decl *D) {
-  switch (D->getKind()) {
-#define DECL(DERIVED, BASE) \
-  case Decl::DERIVED: \
-return dumpPreviousDeclImpl(OS, cast(D));
-#define ABSTRACT_DECL(DECL)
-#include "clang/AST/DeclNodes.inc"
-  }
-  llvm_unreachable("Decl that isn't part of DeclNodes.inc!");
-}
-
 //===--===//
 //  C++ Utilities
 //===--===//
@@ -543,47 +514,11 @@
 
 void ASTDumper::dumpDecl(const Decl *D) {
   dumpChild([=] {
+NodeDumper.Visit(D);
 if (!D) {
-  ColorScope Color(OS, ShowColors, NullColor);
-  OS << "<<>>";
   return;
 }
 
-{
-  ColorScope Color(OS, ShowColors, DeclKindNameColor);
-  OS << D->getDeclKindName() << "Decl";
-}
-NodeDumper.dumpPointer(D);
-if (D->getLexicalDeclContext() != D->getDeclContext())
-  OS << " parent " << cast(D->getDeclContext());
-dumpPreviousDecl(OS, D);
-NodeDumper.dumpSourceRange(D->getSourceRange());
-

[PATCH] D55394: Re-order type param children of ObjC nodes

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: test/AST/ast-dump-decl.m:90
 // CHECK-NEXT:   -ObjCProtocol {{.+}} 'P'
+// CHECK-NEXT:   -ObjCTypeParamDecl {{.+}}  col:33 T 'id':'id'
 

aaron.ballman wrote:
> It seems strange to me to print out the type parameter after the superclass 
> information given the source order. My understanding of the AST dumping order 
> is that we try to keep the order of nodes in source order whenever possible.
That is not really a possible thing to try to do, because the AST dump doesn't 
relate to a single language. It should be seen as language independent.

The principle I'm follow is that nodes dump themselves in entirety before 
starting to dump their child nodes. That is a principle already followed by 
most nodes. Changing this seems to be low cost, low impact and high benefit to 
the code.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55394



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


[PATCH] D55250: [clangd] Enhance macro hover to see full definition

2019-01-12 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle marked 2 inline comments as done.
malaperle added inline comments.



Comment at: clangd/XRefs.cpp:572
+
+  // Try to get the full definition, not just the name
+  SourceLocation StartLoc = Decl.Info->getDefinitionLoc();

simark wrote:
> hokein wrote:
> > if this is a complicated macro (like `AST_MATCHER`), do we still want to 
> > return all the content? they might be less useful than the simple macros.
> I think it would be hard to decide here what constitutes a complicated or 
> not-complicated macro (one for which we want to return all the content or 
> not).  Also, I think it's fine to return the whole content, since frontends 
> generally have good ways to present large contents in popups (hover popups 
> that can be scrolled).
> 
> If we realize later we need to limit the size, then we can add an option 
> where the frontend can specify a size limit.
I think it's OK if the client displays it as it sees fit (scrollbar or trimmed).



Comment at: clangd/XRefs.cpp:578
+bool Invalid;
+StringRef Buffer = SM.getBufferData(SM.getFileID(StartLoc), );
+if (!Invalid) {

ilya-biryukov wrote:
> Unfortunately we can't get the buffer here, because for the preamble macros 
> the files might change on disk after we build the preamble and we can end up 
> reading a different version of the file. Which can in turn lead to crashes as 
> the offsets obtained from the source locations can point outside the buffer 
> for the corresponding file.
> 
> This is really annoying and generally the solution is to try find a different 
> way to obtain the same information, e.g. by looking at what `MacroInfo` has 
> available.
> However, I don't know of a good workaround for this. Happy to look into ways 
> of providing something close to a macro definition from `MacroInfo` or other 
> sources, can scout for this tomorrow.
I tried to do something like MacroInfo::dump. One problem is that we don't 
always have enough information about literals. For example:

```
#define MACRO 0
int main() { return MACRO; }
```
Becomes:
```
#define MACRO numeric_constant
```

I poked around the Token code and I didn't find a way to retrieve the literal 
without going through the buffer (Preprocessor::getSpelling for example).

What you mention is only a problem when you use the option of storing preambles 
on disk, right? So something would need to modify the preamble files on disk, 
which are stored in some temp folder. It doesn't sound like that could happen 
frequently. There is also bounds checking in the code above so it shouldn't 
crash, right? Even if the bounds are incorrect, it will be no different than 
the Range we return to the client for document/definition, i.e. the client can 
use the range on a newly modified header and get it wrong. I also tested 
renaming the pch file and then editing the source file and it results in an 
invalid AST. So either way modifying the pch would be bad news not for just 
macro hover.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55250



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


[PATCH] D55340: NFC: Move dump of individual Stmts to TextNodeDumper

2019-01-12 Thread عوض خاتم المالكي via Phabricator via cfe-commits
ham99922 reopened this revision.
ham99922 added a comment.
This revision is now accepted and ready to land.

https://accounts.snapchat.com/accounts/login?continue=https%3A%2F%2Faccounts.snapchat.com%2Faccounts%2Fchang{F7814861}


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55340



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


[PATCH] D56581: [ASTImporter] Set the described template if not set

2019-01-12 Thread Aleksei Sidorin via Phabricator via cfe-commits
a_sidorin added a comment.

Hello Gabor,

This looks good, but as Shafik mentioned, adding a test would be nice.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56581



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


[PATCH] D56642: NFC: Move dump of type nodes to NodeDumper

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 181452.
steveire added a comment.

Format


Repository:
  rC Clang

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

https://reviews.llvm.org/D56642

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -13,6 +13,7 @@
 
 #include "clang/AST/TextNodeDumper.h"
 
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/LocInfoType.h"
 
 using namespace clang;
@@ -170,6 +171,8 @@
 OS << " contains_unexpanded_pack";
   if (T->isFromAST())
 OS << " imported";
+
+  TypeVisitor::Visit(T);
 }
 
 void TextNodeDumper::Visit(QualType T) {
@@ -886,3 +889,161 @@
 void TextNodeDumper::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node) {
   OS << " " << (Node->getValue() ? "__objc_yes" : "__objc_no");
 }
+
+void TextNodeDumper::VisitRValueReferenceType(const ReferenceType *T) {
+  if (T->isSpelledAsLValue())
+OS << " written as lvalue reference";
+}
+
+void TextNodeDumper::VisitArrayType(const ArrayType *T) {
+  switch (T->getSizeModifier()) {
+  case ArrayType::Normal:
+break;
+  case ArrayType::Static:
+OS << " static";
+break;
+  case ArrayType::Star:
+OS << " *";
+break;
+  }
+  OS << " " << T->getIndexTypeQualifiers().getAsString();
+}
+
+void TextNodeDumper::VisitConstantArrayType(const ConstantArrayType *T) {
+  OS << " " << T->getSize();
+  VisitArrayType(T);
+}
+
+void TextNodeDumper::VisitVariableArrayType(const VariableArrayType *T) {
+  OS << " ";
+  dumpSourceRange(T->getBracketsRange());
+  VisitArrayType(T);
+}
+
+void TextNodeDumper::VisitDependentSizedArrayType(
+const DependentSizedArrayType *T) {
+  VisitArrayType(T);
+  OS << " ";
+  dumpSourceRange(T->getBracketsRange());
+}
+
+void TextNodeDumper::VisitDependentSizedExtVectorType(
+const DependentSizedExtVectorType *T) {
+  OS << " ";
+  dumpLocation(T->getAttributeLoc());
+}
+
+void TextNodeDumper::VisitVectorType(const VectorType *T) {
+  switch (T->getVectorKind()) {
+  case VectorType::GenericVector:
+break;
+  case VectorType::AltiVecVector:
+OS << " altivec";
+break;
+  case VectorType::AltiVecPixel:
+OS << " altivec pixel";
+break;
+  case VectorType::AltiVecBool:
+OS << " altivec bool";
+break;
+  case VectorType::NeonVector:
+OS << " neon";
+break;
+  case VectorType::NeonPolyVector:
+OS << " neon poly";
+break;
+  }
+  OS << " " << T->getNumElements();
+}
+
+void TextNodeDumper::VisitFunctionType(const FunctionType *T) {
+  auto EI = T->getExtInfo();
+  if (EI.getNoReturn())
+OS << " noreturn";
+  if (EI.getProducesResult())
+OS << " produces_result";
+  if (EI.getHasRegParm())
+OS << " regparm " << EI.getRegParm();
+  OS << " " << FunctionType::getNameForCallConv(EI.getCC());
+}
+
+void TextNodeDumper::VisitFunctionProtoType(const FunctionProtoType *T) {
+  auto EPI = T->getExtProtoInfo();
+  if (EPI.HasTrailingReturn)
+OS << " trailing_return";
+  if (T->isConst())
+OS << " const";
+  if (T->isVolatile())
+OS << " volatile";
+  if (T->isRestrict())
+OS << " restrict";
+  switch (EPI.RefQualifier) {
+  case RQ_None:
+break;
+  case RQ_LValue:
+OS << " &";
+break;
+  case RQ_RValue:
+OS << " &&";
+break;
+  }
+  // FIXME: Exception specification.
+  // FIXME: Consumed parameters.
+  VisitFunctionType(T);
+}
+
+void TextNodeDumper::VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitTypedefType(const TypedefType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitUnaryTransformType(const UnaryTransformType *T) {
+  switch (T->getUTTKind()) {
+  case UnaryTransformType::EnumUnderlyingType:
+OS << " underlying_type";
+break;
+  }
+}
+
+void TextNodeDumper::VisitTagType(const TagType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
+  OS << " depth " << T->getDepth() << " index " << T->getIndex();
+  if (T->isParameterPack())
+OS << " pack";
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitAutoType(const AutoType *T) {
+  if (T->isDecltypeAuto())
+OS << " decltype(auto)";
+  if (!T->isDeduced())
+OS << " undeduced";
+}
+
+void TextNodeDumper::VisitTemplateSpecializationType(
+const TemplateSpecializationType *T) {
+  if (T->isTypeAlias())
+OS << " alias";
+  OS << " ";
+  T->getTemplateName().dump(OS);
+}
+
+void TextNodeDumper::VisitInjectedClassNameType(
+const InjectedClassNameType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitPackExpansionType(const PackExpansionType *T) {
+  if (auto N = T->getNumExpansions())
+ 

[PATCH] D56642: NFC: Move dump of type nodes to NodeDumper

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D56642

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -13,6 +13,7 @@
 
 #include "clang/AST/TextNodeDumper.h"
 
+#include "clang/AST/DeclTemplate.h"
 #include "clang/AST/LocInfoType.h"
 
 using namespace clang;
@@ -170,6 +171,8 @@
 OS << " contains_unexpanded_pack";
   if (T->isFromAST())
 OS << " imported";
+
+  TypeVisitor::Visit(T);
 }
 
 void TextNodeDumper::Visit(QualType T) {
@@ -886,3 +889,161 @@
 void TextNodeDumper::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node) {
   OS << " " << (Node->getValue() ? "__objc_yes" : "__objc_no");
 }
+
+void TextNodeDumper::VisitRValueReferenceType(const ReferenceType *T) {
+  if (T->isSpelledAsLValue())
+OS << " written as lvalue reference";
+}
+
+void TextNodeDumper::VisitArrayType(const ArrayType *T) {
+  switch (T->getSizeModifier()) {
+  case ArrayType::Normal:
+break;
+  case ArrayType::Static:
+OS << " static";
+break;
+  case ArrayType::Star:
+OS << " *";
+break;
+  }
+  OS << " " << T->getIndexTypeQualifiers().getAsString();
+}
+
+void TextNodeDumper::VisitConstantArrayType(const ConstantArrayType *T) {
+  OS << " " << T->getSize();
+  VisitArrayType(T);
+}
+
+void TextNodeDumper::VisitVariableArrayType(const VariableArrayType *T) {
+  OS << " ";
+  dumpSourceRange(T->getBracketsRange());
+  VisitArrayType(T);
+}
+
+void TextNodeDumper::VisitDependentSizedArrayType(
+const DependentSizedArrayType *T) {
+  VisitArrayType(T);
+  OS << " ";
+  dumpSourceRange(T->getBracketsRange());
+}
+
+void TextNodeDumper::VisitDependentSizedExtVectorType(
+const DependentSizedExtVectorType *T) {
+  OS << " ";
+  dumpLocation(T->getAttributeLoc());
+}
+
+void TextNodeDumper::VisitVectorType(const VectorType *T) {
+  switch (T->getVectorKind()) {
+  case VectorType::GenericVector:
+break;
+  case VectorType::AltiVecVector:
+OS << " altivec";
+break;
+  case VectorType::AltiVecPixel:
+OS << " altivec pixel";
+break;
+  case VectorType::AltiVecBool:
+OS << " altivec bool";
+break;
+  case VectorType::NeonVector:
+OS << " neon";
+break;
+  case VectorType::NeonPolyVector:
+OS << " neon poly";
+break;
+  }
+  OS << " " << T->getNumElements();
+}
+
+void TextNodeDumper::VisitFunctionType(const FunctionType *T) {
+  auto EI = T->getExtInfo();
+  if (EI.getNoReturn())
+OS << " noreturn";
+  if (EI.getProducesResult())
+OS << " produces_result";
+  if (EI.getHasRegParm())
+OS << " regparm " << EI.getRegParm();
+  OS << " " << FunctionType::getNameForCallConv(EI.getCC());
+}
+
+void TextNodeDumper::VisitFunctionProtoType(const FunctionProtoType *T) {
+  auto EPI = T->getExtProtoInfo();
+  if (EPI.HasTrailingReturn)
+OS << " trailing_return";
+  if (T->isConst())
+OS << " const";
+  if (T->isVolatile())
+OS << " volatile";
+  if (T->isRestrict())
+OS << " restrict";
+  switch (EPI.RefQualifier) {
+  case RQ_None:
+break;
+  case RQ_LValue:
+OS << " &";
+break;
+  case RQ_RValue:
+OS << " &&";
+break;
+  }
+  // FIXME: Exception specification.
+  // FIXME: Consumed parameters.
+  VisitFunctionType(T);
+}
+
+void TextNodeDumper::VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitTypedefType(const TypedefType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitUnaryTransformType(const UnaryTransformType *T) {
+  switch (T->getUTTKind()) {
+  case UnaryTransformType::EnumUnderlyingType:
+OS << " underlying_type";
+break;
+  }
+}
+
+void TextNodeDumper::VisitTagType(const TagType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
+  OS << " depth " << T->getDepth() << " index " << T->getIndex();
+  if (T->isParameterPack())
+OS << " pack";
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitAutoType(const AutoType *T) {
+  if (T->isDecltypeAuto())
+OS << " decltype(auto)";
+  if (!T->isDeduced())
+OS << " undeduced";
+}
+
+void TextNodeDumper::VisitTemplateSpecializationType(
+const TemplateSpecializationType *T) {
+  if (T->isTypeAlias())
+OS << " alias";
+  OS << " ";
+  T->getTemplateName().dump(OS);
+}
+
+void TextNodeDumper::VisitInjectedClassNameType(
+const InjectedClassNameType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
+  dumpDeclRef(T->getDecl());
+}
+
+void TextNodeDumper::VisitPackExpansionType(const PackExpansionType *T) {
+  if (auto N = T->getNumExpansions())
+OS << " expansions " << *N;
+}

[PATCH] D56640: NFC: Canonicalize handling of TypeLocInfo

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

No need to avoid the Visit method.


Repository:
  rC Clang

https://reviews.llvm.org/D56640

Files:
  lib/AST/ASTDumper.cpp


Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -122,6 +122,9 @@
 void VisitComplexType(const ComplexType *T) {
   dumpTypeAsChild(T->getElementType());
 }
+void VisitLocInfoType(const LocInfoType *T) {
+  dumpTypeAsChild(T->getTypeSourceInfo()->getType());
+}
 void VisitPointerType(const PointerType *T) {
   dumpTypeAsChild(T->getPointeeType());
 }
@@ -434,10 +437,6 @@
 if (!T) {
   return;
 }
-if (const LocInfoType *LIT = llvm::dyn_cast(T)) {
-  dumpTypeAsChild(LIT->getTypeSourceInfo()->getType());
-  return;
-}
 TypeVisitor::Visit(T);
 
 QualType SingleStepDesugar =


Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -122,6 +122,9 @@
 void VisitComplexType(const ComplexType *T) {
   dumpTypeAsChild(T->getElementType());
 }
+void VisitLocInfoType(const LocInfoType *T) {
+  dumpTypeAsChild(T->getTypeSourceInfo()->getType());
+}
 void VisitPointerType(const PointerType *T) {
   dumpTypeAsChild(T->getPointeeType());
 }
@@ -434,10 +437,6 @@
 if (!T) {
   return;
 }
-if (const LocInfoType *LIT = llvm::dyn_cast(T)) {
-  dumpTypeAsChild(LIT->getTypeSourceInfo()->getType());
-  return;
-}
 TypeVisitor::Visit(T);
 
 QualType SingleStepDesugar =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56641: NFC: Move dumping of QualType node to TextNodeDumper

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D56641

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp


Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -172,6 +172,14 @@
 OS << " imported";
 }
 
+void TextNodeDumper::Visit(QualType T) {
+  OS << "QualType";
+  dumpPointer(T.getAsOpaquePtr());
+  OS << " ";
+  dumpBareType(T, false);
+  OS << " " << T.split().Quals.getAsString();
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -422,11 +422,7 @@
 return dumpTypeAsChild(SQT.Ty);
 
   dumpChild([=] {
-OS << "QualType";
-NodeDumper.dumpPointer(T.getAsOpaquePtr());
-OS << " ";
-NodeDumper.dumpBareType(T, false);
-OS << " " << T.split().Quals.getAsString();
+NodeDumper.Visit(T);
 dumpTypeAsChild(T.split().Ty);
   });
 }
Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -161,6 +161,8 @@
 
   void Visit(const Type *T);
 
+  void Visit(QualType T);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);


Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -172,6 +172,14 @@
 OS << " imported";
 }
 
+void TextNodeDumper::Visit(QualType T) {
+  OS << "QualType";
+  dumpPointer(T.getAsOpaquePtr());
+  OS << " ";
+  dumpBareType(T, false);
+  OS << " " << T.split().Quals.getAsString();
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -422,11 +422,7 @@
 return dumpTypeAsChild(SQT.Ty);
 
   dumpChild([=] {
-OS << "QualType";
-NodeDumper.dumpPointer(T.getAsOpaquePtr());
-OS << " ";
-NodeDumper.dumpBareType(T, false);
-OS << " " << T.split().Quals.getAsString();
+NodeDumper.Visit(T);
 dumpTypeAsChild(T.split().Ty);
   });
 }
Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -161,6 +161,8 @@
 
   void Visit(const Type *T);
 
+  void Visit(QualType T);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56639: NFC: Move Type Visit implementation to TextNodeDumper

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D56639

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -13,6 +13,8 @@
 
 #include "clang/AST/TextNodeDumper.h"
 
+#include "clang/AST/LocInfoType.h"
+
 using namespace clang;
 
 TextNodeDumper::TextNodeDumper(raw_ostream , bool ShowColors,
@@ -131,6 +133,45 @@
   ConstStmtVisitor::Visit(Node);
 }
 
+void TextNodeDumper::Visit(const Type *T) {
+  if (!T) {
+ColorScope Color(OS, ShowColors, NullColor);
+OS << "<<>>";
+return;
+  }
+  if (llvm::isa(T)) {
+{
+  ColorScope Color(OS, ShowColors, TypeColor);
+  OS << "LocInfo Type";
+}
+dumpPointer(T);
+return;
+  }
+
+  {
+ColorScope Color(OS, ShowColors, TypeColor);
+OS << T->getTypeClassName() << "Type";
+  }
+  dumpPointer(T);
+  OS << " ";
+  dumpBareType(QualType(T, 0), false);
+
+  QualType SingleStepDesugar =
+  T->getLocallyUnqualifiedSingleStepDesugaredType();
+  if (SingleStepDesugar != QualType(T, 0))
+OS << " sugar";
+  if (T->isDependentType())
+OS << " dependent";
+  else if (T->isInstantiationDependentType())
+OS << " instantiation_dependent";
+  if (T->isVariablyModifiedType())
+OS << " variably_modified";
+  if (T->containsUnexpandedParameterPack())
+OS << " contains_unexpanded_pack";
+  if (T->isFromAST())
+OS << " imported";
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -430,46 +430,18 @@
 
 void ASTDumper::dumpTypeAsChild(const Type *T) {
   dumpChild([=] {
+NodeDumper.Visit(T);
 if (!T) {
-  ColorScope Color(OS, ShowColors, NullColor);
-  OS << "<<>>";
   return;
 }
 if (const LocInfoType *LIT = llvm::dyn_cast(T)) {
-  {
-ColorScope Color(OS, ShowColors, TypeColor);
-OS << "LocInfo Type";
-  }
-  NodeDumper.dumpPointer(T);
   dumpTypeAsChild(LIT->getTypeSourceInfo()->getType());
   return;
 }
-
-{
-  ColorScope Color(OS, ShowColors, TypeColor);
-  OS << T->getTypeClassName() << "Type";
-}
-NodeDumper.dumpPointer(T);
-OS << " ";
-NodeDumper.dumpBareType(QualType(T, 0), false);
+TypeVisitor::Visit(T);
 
 QualType SingleStepDesugar =
 T->getLocallyUnqualifiedSingleStepDesugaredType();
-if (SingleStepDesugar != QualType(T, 0))
-  OS << " sugar";
-if (T->isDependentType())
-  OS << " dependent";
-else if (T->isInstantiationDependentType())
-  OS << " instantiation_dependent";
-if (T->isVariablyModifiedType())
-  OS << " variably_modified";
-if (T->containsUnexpandedParameterPack())
-  OS << " contains_unexpanded_pack";
-if (T->isFromAST())
-  OS << " imported";
-
-TypeVisitor::Visit(T);
-
 if (SingleStepDesugar != QualType(T, 0))
   dumpTypeAsChild(SingleStepDesugar);
   });
Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -159,6 +159,8 @@
 
   void Visit(const Stmt *Node);
 
+  void Visit(const Type *T);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r351015 - NFC: Make utility private

2019-01-12 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 12 09:07:05 2019
New Revision: 351015

URL: http://llvm.org/viewvc/llvm-project?rev=351015=rev
Log:
NFC: Make utility private

No callers are external to the class anymore.

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351015=351014=351015=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Sat Jan 12 09:07:05 2019
@@ -167,7 +167,6 @@ public:
   void dumpBareDeclRef(const Decl *D);
   void dumpName(const NamedDecl *ND);
   void dumpAccessSpecifier(AccessSpecifier AS);
-  void dumpCXXTemporary(const CXXTemporary *Temporary);
 
   void dumpDeclRef(const Decl *D, StringRef Label = {});
 
@@ -255,6 +254,9 @@ public:
   void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node);
   void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node);
   void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node);
+
+private:
+  void dumpCXXTemporary(const CXXTemporary *Temporary);
 };
 
 } // namespace clang


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


[PATCH] D55340: NFC: Move dump of individual Stmts to TextNodeDumper

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351014: [ASTDump] NFC: Move dump of individual Stmts to 
TextNodeDumper (authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55340?vs=176871=181447#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55340

Files:
  cfe/trunk/include/clang/AST/TextNodeDumper.h
  cfe/trunk/lib/AST/ASTDumper.cpp
  cfe/trunk/lib/AST/TextNodeDumper.cpp

Index: cfe/trunk/include/clang/AST/TextNodeDumper.h
===
--- cfe/trunk/include/clang/AST/TextNodeDumper.h
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h
@@ -20,6 +20,7 @@
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/StmtVisitor.h"
 #include "clang/AST/TemplateArgumentVisitor.h"
 
 namespace clang {
@@ -125,7 +126,8 @@
   public comments::ConstCommentVisitor,
   public ConstAttrVisitor,
-  public ConstTemplateArgumentVisitor {
+  public ConstTemplateArgumentVisitor,
+  public ConstStmtVisitor {
   raw_ostream 
   const bool ShowColors;
 
@@ -155,6 +157,8 @@
   void Visit(const TemplateArgument , SourceRange R,
  const Decl *From = nullptr, StringRef Label = {});
 
+  void Visit(const Stmt *Node);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);
@@ -201,6 +205,56 @@
   void VisitTemplateExpansionTemplateArgument(const TemplateArgument );
   void VisitExpressionTemplateArgument(const TemplateArgument );
   void VisitPackTemplateArgument(const TemplateArgument );
+
+  void VisitIfStmt(const IfStmt *Node);
+  void VisitSwitchStmt(const SwitchStmt *Node);
+  void VisitWhileStmt(const WhileStmt *Node);
+  void VisitLabelStmt(const LabelStmt *Node);
+  void VisitGotoStmt(const GotoStmt *Node);
+  void VisitCaseStmt(const CaseStmt *Node);
+  void VisitCallExpr(const CallExpr *Node);
+  void VisitCastExpr(const CastExpr *Node);
+  void VisitImplicitCastExpr(const ImplicitCastExpr *Node);
+  void VisitDeclRefExpr(const DeclRefExpr *Node);
+  void VisitPredefinedExpr(const PredefinedExpr *Node);
+  void VisitCharacterLiteral(const CharacterLiteral *Node);
+  void VisitIntegerLiteral(const IntegerLiteral *Node);
+  void VisitFixedPointLiteral(const FixedPointLiteral *Node);
+  void VisitFloatingLiteral(const FloatingLiteral *Node);
+  void VisitStringLiteral(const StringLiteral *Str);
+  void VisitInitListExpr(const InitListExpr *ILE);
+  void VisitUnaryOperator(const UnaryOperator *Node);
+  void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node);
+  void VisitMemberExpr(const MemberExpr *Node);
+  void VisitExtVectorElementExpr(const ExtVectorElementExpr *Node);
+  void VisitBinaryOperator(const BinaryOperator *Node);
+  void VisitCompoundAssignOperator(const CompoundAssignOperator *Node);
+  void VisitAddrLabelExpr(const AddrLabelExpr *Node);
+  void VisitCXXNamedCastExpr(const CXXNamedCastExpr *Node);
+  void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node);
+  void VisitCXXThisExpr(const CXXThisExpr *Node);
+  void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node);
+  void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *Node);
+  void VisitCXXConstructExpr(const CXXConstructExpr *Node);
+  void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node);
+  void VisitCXXNewExpr(const CXXNewExpr *Node);
+  void VisitCXXDeleteExpr(const CXXDeleteExpr *Node);
+  void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node);
+  void VisitExprWithCleanups(const ExprWithCleanups *Node);
+  void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node);
+  void VisitSizeOfPackExpr(const SizeOfPackExpr *Node);
+  void
+  VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *Node);
+  void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node);
+  void VisitObjCEncodeExpr(const ObjCEncodeExpr *Node);
+  void VisitObjCMessageExpr(const ObjCMessageExpr *Node);
+  void VisitObjCBoxedExpr(const ObjCBoxedExpr *Node);
+  void VisitObjCSelectorExpr(const ObjCSelectorExpr *Node);
+  void VisitObjCProtocolExpr(const ObjCProtocolExpr *Node);
+  void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Node);
+  void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node);
+  void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node);
+  void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node);
 };
 
 } // namespace clang
Index: cfe/trunk/lib/AST/ASTDumper.cpp
===
--- cfe/trunk/lib/AST/ASTDumper.cpp
+++ cfe/trunk/lib/AST/ASTDumper.cpp
@@ -372,72 +372,26 @@
 // Stmts.
 void VisitDeclStmt(const DeclStmt *Node);
 void VisitAttributedStmt(const AttributedStmt 

r351014 - [ASTDump] NFC: Move dump of individual Stmts to TextNodeDumper

2019-01-12 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 12 08:53:27 2019
New Revision: 351014

URL: http://llvm.org/viewvc/llvm-project?rev=351014=rev
Log:
[ASTDump] NFC: Move dump of individual Stmts to TextNodeDumper

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351014=351013=351014=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Sat Jan 12 08:53:27 2019
@@ -20,6 +20,7 @@
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/StmtVisitor.h"
 #include "clang/AST/TemplateArgumentVisitor.h"
 
 namespace clang {
@@ -125,7 +126,8 @@ class TextNodeDumper
   public comments::ConstCommentVisitor,
   public ConstAttrVisitor,
-  public ConstTemplateArgumentVisitor {
+  public ConstTemplateArgumentVisitor,
+  public ConstStmtVisitor {
   raw_ostream 
   const bool ShowColors;
 
@@ -155,6 +157,8 @@ public:
   void Visit(const TemplateArgument , SourceRange R,
  const Decl *From = nullptr, StringRef Label = {});
 
+  void Visit(const Stmt *Node);
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void dumpSourceRange(SourceRange R);
@@ -201,6 +205,56 @@ public:
   void VisitTemplateExpansionTemplateArgument(const TemplateArgument );
   void VisitExpressionTemplateArgument(const TemplateArgument );
   void VisitPackTemplateArgument(const TemplateArgument );
+
+  void VisitIfStmt(const IfStmt *Node);
+  void VisitSwitchStmt(const SwitchStmt *Node);
+  void VisitWhileStmt(const WhileStmt *Node);
+  void VisitLabelStmt(const LabelStmt *Node);
+  void VisitGotoStmt(const GotoStmt *Node);
+  void VisitCaseStmt(const CaseStmt *Node);
+  void VisitCallExpr(const CallExpr *Node);
+  void VisitCastExpr(const CastExpr *Node);
+  void VisitImplicitCastExpr(const ImplicitCastExpr *Node);
+  void VisitDeclRefExpr(const DeclRefExpr *Node);
+  void VisitPredefinedExpr(const PredefinedExpr *Node);
+  void VisitCharacterLiteral(const CharacterLiteral *Node);
+  void VisitIntegerLiteral(const IntegerLiteral *Node);
+  void VisitFixedPointLiteral(const FixedPointLiteral *Node);
+  void VisitFloatingLiteral(const FloatingLiteral *Node);
+  void VisitStringLiteral(const StringLiteral *Str);
+  void VisitInitListExpr(const InitListExpr *ILE);
+  void VisitUnaryOperator(const UnaryOperator *Node);
+  void VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *Node);
+  void VisitMemberExpr(const MemberExpr *Node);
+  void VisitExtVectorElementExpr(const ExtVectorElementExpr *Node);
+  void VisitBinaryOperator(const BinaryOperator *Node);
+  void VisitCompoundAssignOperator(const CompoundAssignOperator *Node);
+  void VisitAddrLabelExpr(const AddrLabelExpr *Node);
+  void VisitCXXNamedCastExpr(const CXXNamedCastExpr *Node);
+  void VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *Node);
+  void VisitCXXThisExpr(const CXXThisExpr *Node);
+  void VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *Node);
+  void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *Node);
+  void VisitCXXConstructExpr(const CXXConstructExpr *Node);
+  void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node);
+  void VisitCXXNewExpr(const CXXNewExpr *Node);
+  void VisitCXXDeleteExpr(const CXXDeleteExpr *Node);
+  void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node);
+  void VisitExprWithCleanups(const ExprWithCleanups *Node);
+  void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node);
+  void VisitSizeOfPackExpr(const SizeOfPackExpr *Node);
+  void
+  VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *Node);
+  void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *Node);
+  void VisitObjCEncodeExpr(const ObjCEncodeExpr *Node);
+  void VisitObjCMessageExpr(const ObjCMessageExpr *Node);
+  void VisitObjCBoxedExpr(const ObjCBoxedExpr *Node);
+  void VisitObjCSelectorExpr(const ObjCSelectorExpr *Node);
+  void VisitObjCProtocolExpr(const ObjCProtocolExpr *Node);
+  void VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *Node);
+  void VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *Node);
+  void VisitObjCIvarRefExpr(const ObjCIvarRefExpr *Node);
+  void VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *Node);
 };
 
 } // namespace clang

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351014=351013=351014=diff
==
--- 

[PATCH] D55491: Implement TemplateArgument dumping in terms of Visitor

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351012: Implement TemplateArgument dumping in terms of 
Visitor (authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55491?vs=181395=181446#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55491

Files:
  cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h
  cfe/trunk/include/clang/AST/TextNodeDumper.h
  cfe/trunk/lib/AST/ASTDumper.cpp
  cfe/trunk/lib/AST/TextNodeDumper.cpp

Index: cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h
===
--- cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h
+++ cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h
@@ -0,0 +1,99 @@
+//===- TemplateArgumentVisitor.h - Visitor for TArg subclasses --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines the TemplateArgumentVisitor interface.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
+#define LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
+
+#include "clang/AST/TemplateBase.h"
+
+namespace clang {
+
+namespace templateargumentvisitor {
+
+/// A simple visitor class that helps create template argument visitors.
+template  class Ref, typename ImplClass,
+  typename RetTy = void, typename... ParamTys>
+class Base {
+public:
+#define REF(CLASS) typename Ref::type
+#define DISPATCH(NAME) \
+  case TemplateArgument::NAME: \
+return static_cast(this)->Visit##NAME##TemplateArgument(  \
+TA, std::forward(P)...)
+
+  RetTy Visit(REF(TemplateArgument) TA, ParamTys... P) {
+switch (TA.getKind()) {
+  DISPATCH(Null);
+  DISPATCH(Type);
+  DISPATCH(Declaration);
+  DISPATCH(NullPtr);
+  DISPATCH(Integral);
+  DISPATCH(Template);
+  DISPATCH(TemplateExpansion);
+  DISPATCH(Expression);
+  DISPATCH(Pack);
+}
+llvm_unreachable("TemplateArgument is not covered in switch!");
+  }
+
+  // If the implementation chooses not to implement a certain visit
+  // method, fall back to the parent.
+
+#define VISIT_METHOD(CATEGORY) \
+  RetTy Visit##CATEGORY##TemplateArgument(REF(TemplateArgument) TA,\
+  ParamTys... P) { \
+return VisitTemplateArgument(TA, std::forward(P)...);\
+  }
+
+  VISIT_METHOD(Null);
+  VISIT_METHOD(Type);
+  VISIT_METHOD(Declaration);
+  VISIT_METHOD(NullPtr);
+  VISIT_METHOD(Integral);
+  VISIT_METHOD(Template);
+  VISIT_METHOD(TemplateExpansion);
+  VISIT_METHOD(Expression);
+  VISIT_METHOD(Pack);
+
+  RetTy VisitTemplateArgument(REF(TemplateArgument), ParamTys...) {
+return RetTy();
+  }
+
+#undef REF
+#undef DISPATCH
+#undef VISIT_METHOD
+};
+
+} // namespace templateargumentvisitor
+
+/// A simple visitor class that helps create template argument visitors.
+///
+/// This class does not preserve constness of TemplateArgument references (see
+/// also ConstTemplateArgumentVisitor).
+template 
+class TemplateArgumentVisitor
+: public templateargumentvisitor::Base {};
+
+/// A simple visitor class that helps create template argument visitors.
+///
+/// This class preserves constness of TemplateArgument references (see also
+/// TemplateArgumentVisitor).
+template 
+class ConstTemplateArgumentVisitor
+: public templateargumentvisitor::Base {};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
Index: cfe/trunk/include/clang/AST/TextNodeDumper.h
===
--- cfe/trunk/include/clang/AST/TextNodeDumper.h
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h
@@ -20,6 +20,7 @@
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/TemplateArgumentVisitor.h"
 
 namespace clang {
 
@@ -123,7 +124,8 @@
 : public TextTreeStructure,
   public comments::ConstCommentVisitor,
-  public ConstAttrVisitor {
+  public ConstAttrVisitor,
+  public ConstTemplateArgumentVisitor {
   raw_ostream 
   const bool ShowColors;
 
@@ -150,6 +152,9 @@
 
   void Visit(const Attr *A);
 
+  void Visit(const TemplateArgument , SourceRange R,
+ const Decl *From = nullptr, StringRef Label = {});
+
   void dumpPointer(const void *Ptr);
   void dumpLocation(SourceLocation Loc);
   void 

r351012 - Implement TemplateArgument dumping in terms of Visitor

2019-01-12 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 12 08:35:37 2019
New Revision: 351012

URL: http://llvm.org/viewvc/llvm-project?rev=351012=rev
Log:
Implement TemplateArgument dumping in terms of Visitor

Summary: Split the output streaming from the traversal to other AST nodes.

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Added:
cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h
Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/TextNodeDumper.cpp

Added: cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h?rev=351012=auto
==
--- cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h (added)
+++ cfe/trunk/include/clang/AST/TemplateArgumentVisitor.h Sat Jan 12 08:35:37 
2019
@@ -0,0 +1,99 @@
+//===- TemplateArgumentVisitor.h - Visitor for TArg subclasses --*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This file defines the TemplateArgumentVisitor interface.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
+#define LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H
+
+#include "clang/AST/TemplateBase.h"
+
+namespace clang {
+
+namespace templateargumentvisitor {
+
+/// A simple visitor class that helps create template argument visitors.
+template  class Ref, typename ImplClass,
+  typename RetTy = void, typename... ParamTys>
+class Base {
+public:
+#define REF(CLASS) typename Ref::type
+#define DISPATCH(NAME) 
\
+  case TemplateArgument::NAME: 
\
+return static_cast(this)->Visit##NAME##TemplateArgument(  
\
+TA, std::forward(P)...)
+
+  RetTy Visit(REF(TemplateArgument) TA, ParamTys... P) {
+switch (TA.getKind()) {
+  DISPATCH(Null);
+  DISPATCH(Type);
+  DISPATCH(Declaration);
+  DISPATCH(NullPtr);
+  DISPATCH(Integral);
+  DISPATCH(Template);
+  DISPATCH(TemplateExpansion);
+  DISPATCH(Expression);
+  DISPATCH(Pack);
+}
+llvm_unreachable("TemplateArgument is not covered in switch!");
+  }
+
+  // If the implementation chooses not to implement a certain visit
+  // method, fall back to the parent.
+
+#define VISIT_METHOD(CATEGORY) 
\
+  RetTy Visit##CATEGORY##TemplateArgument(REF(TemplateArgument) TA,
\
+  ParamTys... P) { 
\
+return VisitTemplateArgument(TA, std::forward(P)...);
\
+  }
+
+  VISIT_METHOD(Null);
+  VISIT_METHOD(Type);
+  VISIT_METHOD(Declaration);
+  VISIT_METHOD(NullPtr);
+  VISIT_METHOD(Integral);
+  VISIT_METHOD(Template);
+  VISIT_METHOD(TemplateExpansion);
+  VISIT_METHOD(Expression);
+  VISIT_METHOD(Pack);
+
+  RetTy VisitTemplateArgument(REF(TemplateArgument), ParamTys...) {
+return RetTy();
+  }
+
+#undef REF
+#undef DISPATCH
+#undef VISIT_METHOD
+};
+
+} // namespace templateargumentvisitor
+
+/// A simple visitor class that helps create template argument visitors.
+///
+/// This class does not preserve constness of TemplateArgument references (see
+/// also ConstTemplateArgumentVisitor).
+template 
+class TemplateArgumentVisitor
+: public templateargumentvisitor::Base {};
+
+/// A simple visitor class that helps create template argument visitors.
+///
+/// This class preserves constness of TemplateArgument references (see also
+/// TemplateArgumentVisitor).
+template 
+class ConstTemplateArgumentVisitor
+: public templateargumentvisitor::Base {};
+
+} // namespace clang
+
+#endif // LLVM_CLANG_AST_TEMPLATEARGUMENTVISITOR_H

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351012=351011=351012=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Sat Jan 12 08:35:37 2019
@@ -20,6 +20,7 @@
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/CommentVisitor.h"
 #include "clang/AST/ExprCXX.h"
+#include "clang/AST/TemplateArgumentVisitor.h"
 
 namespace clang {
 
@@ -123,7 +124,8 @@ class TextNodeDumper
 : public TextTreeStructure,
   public comments::ConstCommentVisitor,
-  public ConstAttrVisitor {
+  public ConstAttrVisitor,
+  public ConstTemplateArgumentVisitor {
   raw_ostream 
   const bool 

r351011 - [ASTDump] Change parameter to StringRef

2019-01-12 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sat Jan 12 07:45:05 2019
New Revision: 351011

URL: http://llvm.org/viewvc/llvm-project?rev=351011=rev
Log:
[ASTDump] Change parameter to StringRef

Modified:
cfe/trunk/include/clang/AST/TextNodeDumper.h
cfe/trunk/lib/AST/TextNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/TextNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/TextNodeDumper.h?rev=351011=351010=351011=diff
==
--- cfe/trunk/include/clang/AST/TextNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/TextNodeDumper.h Sat Jan 12 07:45:05 2019
@@ -160,7 +160,7 @@ public:
   void dumpAccessSpecifier(AccessSpecifier AS);
   void dumpCXXTemporary(const CXXTemporary *Temporary);
 
-  void dumpDeclRef(const Decl *D, const char *Label = nullptr);
+  void dumpDeclRef(const Decl *D, StringRef Label = {});
 
   void visitTextComment(const comments::TextComment *C,
 const comments::FullComment *);

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=351011=351010=351011=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Sat Jan 12 07:45:05 2019
@@ -184,12 +184,12 @@ void TextNodeDumper::dumpCXXTemporary(co
   OS << ")";
 }
 
-void TextNodeDumper::dumpDeclRef(const Decl *D, const char *Label) {
+void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef Label) {
   if (!D)
 return;
 
   AddChild([=] {
-if (Label)
+if (!Label.empty())
   OS << Label << ' ';
 dumpBareDeclRef(D);
   });


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


[PATCH] D55491: Implement TemplateArgument dumping in terms of Visitor

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: include/clang/AST/TemplateArgumentVisitor.h:24
+/// A simple visitor class that helps create template argument visitors.
+template  class Ref, typename ImplClass,
+  typename RetTy = void, typename... ParamTys>

aaron.ballman wrote:
> Missed a `typename` in there.
If you're talking about the TTP, class must be used until C++17. See 
https://en.cppreference.com/w/cpp/language/template_parameters


Repository:
  rC Clang

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

https://reviews.llvm.org/D55491



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


[PATCH] D55491: Implement TemplateArgument dumping in terms of Visitor

2019-01-12 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

In D55491#1355105 , @thakis wrote:

> Out of interest, what's the motivation for this? It seems to add way more 
> code than it removes, so there must be some other advantage, but the patch 
> description doesn't say.


The reason for this is to split the output streaming from the traversal to 
other AST nodes.

This is a step as part of a larger refactoring with the aim of a class 
extracted from ASTDumper which does traversal but no streaming. That way, we 
can dump other output formats and do other things with the traversal.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55491



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


r351007 - [analyzer] Fix unused variable warnings in Release builds

2019-01-12 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sat Jan 12 04:43:53 2019
New Revision: 351007

URL: http://llvm.org/viewvc/llvm-project?rev=351007=rev
Log:
[analyzer] Fix unused variable warnings in Release builds

This was just an inlined version of isa. NFC.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=351007=351006=351007=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Sat Jan 12 04:43:53 2019
@@ -1372,12 +1372,9 @@ CallEventManager::getCaller(const StackF
 if (CallEventRef<> Out = getCall(CallSite, State, CallerCtx))
   return Out;
 
-Stmt::StmtClass SC = CallSite->getStmtClass();
-
 // All other cases are handled by getCall.
-assert(SC == Stmt::CXXConstructExprClass ||
-   SC == Stmt::CXXTemporaryObjectExprClass &&
-   "This is not an inlineable statement");
+assert(isa(CallSite) &&
+   "This is not an inlineable statement");
 
 SValBuilder  = State->getStateManager().getSValBuilder();
 const auto *Ctor = cast(CalleeCtx->getDecl());


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


[PATCH] D56607: [clang] [NetBSD] Enable additional sanitizer types

2019-01-12 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL351002: [NetBSD] Enable additional sanitizer types (authored 
by mgorny, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56607?vs=181356=181433#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56607

Files:
  cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
  cfe/trunk/test/Driver/fsanitize.c


Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -709,28 +709,67 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+
+
+// * NetBSD; please keep ordered as in Sanitizers.def *
+
 // RUN: %clang -target i386--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
 // ADDRESS-NETBSD: "-fsanitize=address"
 
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-address %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-ADDRESS-NETBSD
+// KERNEL-ADDRESS-NETBSD: "-fsanitize=kernel-address"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=hwaddress %s -### 2>&1 | 
FileCheck %s -check-prefix=HWADDRESS-NETBSD
+// HWADDRESS-NETBSD: "-fsanitize=hwaddress"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-hwaddress %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-HWADDRESS-NETBSD
+// KERNEL-HWADDRESS-NETBSD: "-fsanitize=kernel-hwaddress"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=memory %s -### 2>&1 | 
FileCheck %s -check-prefix=MEMORY-NETBSD
+// MEMORY-NETBSD: "-fsanitize=memory"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-memory %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-MEMORY-NETBSD
+// KERNEL-MEMORY-NETBSD: "-fsanitize=kernel-memory"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=thread %s -### 2>&1 | 
FileCheck %s -check-prefix=THREAD-NETBSD
+// THREAD-NETBSD: "-fsanitize=thread"
+
+// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// LEAK-NETBSD: "-fsanitize=leak"
+
+// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// FUNCTION-NETBSD: "-fsanitize=function"
+
 // RUN: %clang -target i386--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
 // VPTR-NETBSD: "-fsanitize=vptr"
 
+// RUN: %clang -target x86_64--netbsd -fsanitize=dataflow %s -### 2>&1 | 
FileCheck %s -check-prefix=DATAFLOW-NETBSD
+// DATAFLOW-NETBSD: "-fsanitize=dataflow"
+
+// RUN: %clang -target i386--netbsd -fsanitize=cfi %s -### 2>&1 | FileCheck %s 
-check-prefix=CFI-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=cfi %s -### 2>&1 | FileCheck 
%s -check-prefix=CFI-NETBSD
+// CFI-NETBSD: 
"-fsanitize=cfi-derived-cast,cfi-icall,cfi-mfcall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall"
+
 // RUN: %clang -target i386--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
 // SAFESTACK-NETBSD: "-fsanitize=safe-stack"
 
-// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
-// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
-// FUNCTION-NETBSD: "-fsanitize=function"
+// RUN: %clang -target x86_64--netbsd -fsanitize=shadow-call-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SHADOW-CALL-STACK-NETBSD
+// SHADOW-CALL-STACK-NETBSD: "-fsanitize=shadow-call-stack"
+
+// RUN: %clang -target i386--netbsd -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s -check-prefix=UNDEFINED-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s -check-prefix=UNDEFINED-NETBSD
+// UNDEFINED-NETBSD: "-fsanitize={{.*}}
+
+// RUN: %clang -target i386--netbsd -fsanitize=scudo %s -### 2>&1 | FileCheck 
%s -check-prefix=SCUDO-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=scudo %s -### 2>&1 | 
FileCheck %s -check-prefix=SCUDO-NETBSD
+// SCUDO-NETBSD: "-fsanitize=scudo"
 
-// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
-// RUN: %clang -target 

r351002 - [NetBSD] Enable additional sanitizer types

2019-01-12 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Sat Jan 12 03:18:35 2019
New Revision: 351002

URL: http://llvm.org/viewvc/llvm-project?rev=351002=rev
Log:
[NetBSD] Enable additional sanitizer types

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

Modified:
cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp?rev=351002=351001=351002=diff
==
--- cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp Sat Jan 12 03:18:35 2019
@@ -448,10 +448,14 @@ SanitizerMask NetBSD::getSupportedSaniti
 Res |= SanitizerKind::Vptr;
   }
   if (IsX86_64) {
+Res |= SanitizerKind::DataFlow;
 Res |= SanitizerKind::Efficiency;
 Res |= SanitizerKind::Fuzzer;
 Res |= SanitizerKind::FuzzerNoLink;
+Res |= SanitizerKind::HWAddress;
 Res |= SanitizerKind::KernelAddress;
+Res |= SanitizerKind::KernelHWAddress;
+Res |= SanitizerKind::KernelMemory;
 Res |= SanitizerKind::Memory;
 Res |= SanitizerKind::Thread;
   }

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=351002=351001=351002=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Sat Jan 12 03:18:35 2019
@@ -709,28 +709,67 @@
 // RUN: %clang -target x86_64-unknown-cloudabi -fsanitize=safe-stack %s -### 
2>&1 | FileCheck %s -check-prefix=SAFESTACK-CLOUDABI
 // SAFESTACK-CLOUDABI: "-fsanitize=safe-stack"
 
+
+
+// * NetBSD; please keep ordered as in Sanitizers.def *
+
 // RUN: %clang -target i386--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=address %s -### 2>&1 | 
FileCheck %s -check-prefix=ADDRESS-NETBSD
 // ADDRESS-NETBSD: "-fsanitize=address"
 
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-address %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-ADDRESS-NETBSD
+// KERNEL-ADDRESS-NETBSD: "-fsanitize=kernel-address"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=hwaddress %s -### 2>&1 | 
FileCheck %s -check-prefix=HWADDRESS-NETBSD
+// HWADDRESS-NETBSD: "-fsanitize=hwaddress"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-hwaddress %s -### 2>&1 
| FileCheck %s -check-prefix=KERNEL-HWADDRESS-NETBSD
+// KERNEL-HWADDRESS-NETBSD: "-fsanitize=kernel-hwaddress"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=memory %s -### 2>&1 | 
FileCheck %s -check-prefix=MEMORY-NETBSD
+// MEMORY-NETBSD: "-fsanitize=memory"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=kernel-memory %s -### 2>&1 | 
FileCheck %s -check-prefix=KERNEL-MEMORY-NETBSD
+// KERNEL-MEMORY-NETBSD: "-fsanitize=kernel-memory"
+
+// RUN: %clang -target x86_64--netbsd -fsanitize=thread %s -### 2>&1 | 
FileCheck %s -check-prefix=THREAD-NETBSD
+// THREAD-NETBSD: "-fsanitize=thread"
+
+// RUN: %clang -target i386--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=leak %s -### 2>&1 | FileCheck 
%s -check-prefix=LEAK-NETBSD
+// LEAK-NETBSD: "-fsanitize=leak"
+
+// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
+// FUNCTION-NETBSD: "-fsanitize=function"
+
 // RUN: %clang -target i386--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=vptr %s -### 2>&1 | FileCheck 
%s -check-prefix=VPTR-NETBSD
 // VPTR-NETBSD: "-fsanitize=vptr"
 
+// RUN: %clang -target x86_64--netbsd -fsanitize=dataflow %s -### 2>&1 | 
FileCheck %s -check-prefix=DATAFLOW-NETBSD
+// DATAFLOW-NETBSD: "-fsanitize=dataflow"
+
+// RUN: %clang -target i386--netbsd -fsanitize=cfi %s -### 2>&1 | FileCheck %s 
-check-prefix=CFI-NETBSD
+// RUN: %clang -target x86_64--netbsd -fsanitize=cfi %s -### 2>&1 | FileCheck 
%s -check-prefix=CFI-NETBSD
+// CFI-NETBSD: 
"-fsanitize=cfi-derived-cast,cfi-icall,cfi-mfcall,cfi-unrelated-cast,cfi-nvcall,cfi-vcall"
+
 // RUN: %clang -target i386--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
 // RUN: %clang -target x86_64--netbsd -fsanitize=safe-stack %s -### 2>&1 | 
FileCheck %s -check-prefix=SAFESTACK-NETBSD
 // SAFESTACK-NETBSD: "-fsanitize=safe-stack"
 
-// RUN: %clang -target i386--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
-// RUN: %clang -target x86_64--netbsd -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-NETBSD
-// FUNCTION-NETBSD: "-fsanitize=function"
+// RUN: %clang