[clang] ebc6608 - [AST] Remove args from LocationCall

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 17 09:22:09 PDT 2021


Author: Stephen Kelly
Date: 2021-04-17T17:21:55+01:00
New Revision: ebc6608fb79057eaed27435d62d5dea0979bd9d3

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

LOG: [AST] Remove args from LocationCall

This class initially had args to be generic to future needs. In
particular, I thought that source location introspection should show the
getBeginLoc of CallExpr args and the getArgLoc of
TemplateSpecializationLocInfo etc.  However, that is probably best left
out of source location introspection because it involves node traversal.

If something like this is needed in the future, it can be added in the
future.

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

Added: 
    

Modified: 
    clang/include/clang/Tooling/NodeIntrospection.h
    clang/lib/Tooling/NodeIntrospection.cpp
    clang/unittests/Introspection/IntrospectionTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h b/clang/include/clang/Tooling/NodeIntrospection.h
index 5489a67efa22..c8518ea63546 100644
--- a/clang/include/clang/Tooling/NodeIntrospection.h
+++ b/clang/include/clang/Tooling/NodeIntrospection.h
@@ -38,14 +38,9 @@ class LocationCall : public llvm::ThreadSafeRefCountedBase<LocationCall> {
   LocationCall(SharedLocationCall on, std::string name,
                LocationCallFlags flags = NoFlags)
       : m_flags(flags), m_on(std::move(on)), m_name(std::move(name)) {}
-  LocationCall(SharedLocationCall on, std::string name,
-               std::vector<std::string> args, LocationCallFlags flags = NoFlags)
-      : m_flags(flags), m_on(std::move(on)), m_name(std::move(name)),
-        m_args(std::move(args)) {}
 
   LocationCall *on() const { return m_on.get(); }
   StringRef name() const { return m_name; }
-  ArrayRef<std::string> args() const { return m_args; }
   bool returnsPointer() const { return m_flags & ReturnsPointer; }
   bool isCast() const { return m_flags & IsCast; }
 
@@ -53,7 +48,6 @@ class LocationCall : public llvm::ThreadSafeRefCountedBase<LocationCall> {
   LocationCallFlags m_flags;
   SharedLocationCall m_on;
   std::string m_name;
-  std::vector<std::string> m_args;
 };
 
 class LocationCallFormatterCpp {

diff  --git a/clang/lib/Tooling/NodeIntrospection.cpp b/clang/lib/Tooling/NodeIntrospection.cpp
index 0e3ef3c6a01e..6a8d7267f8ae 100644
--- a/clang/lib/Tooling/NodeIntrospection.cpp
+++ b/clang/lib/Tooling/NodeIntrospection.cpp
@@ -29,16 +29,7 @@ void LocationCallFormatterCpp::print(const LocationCall &Call,
       OS << '.';
   }
 
-  OS << Call.name();
-  if (Call.args().empty()) {
-    OS << "()";
-    return;
-  }
-  OS << '(' << Call.args().front();
-  for (const std::string &Arg : Call.args().drop_front()) {
-    OS << ", " << Arg;
-  }
-  OS << ')';
+  OS << Call.name() << "()";
 }
 
 std::string LocationCallFormatterCpp::format(const LocationCall &Call) {

diff  --git a/clang/unittests/Introspection/IntrospectionTest.cpp b/clang/unittests/Introspection/IntrospectionTest.cpp
index ad21748f11f8..e56963aa41a6 100644
--- a/clang/unittests/Introspection/IntrospectionTest.cpp
+++ b/clang/unittests/Introspection/IntrospectionTest.cpp
@@ -61,16 +61,7 @@ class LocationCallFormatterSimple {
       print(*On, OS);
       OS << '.';
     }
-    OS << Call.name();
-    if (Call.args().empty()) {
-      OS << "()";
-      return;
-    }
-    OS << '(' << Call.args().front();
-    for (const std::string &Arg : Call.args().drop_front()) {
-      OS << ", " << Arg;
-    }
-    OS << ')';
+    OS << Call.name() << "()";
   }
 
   static std::string format(const LocationCall &Call) {


        


More information about the cfe-commits mailing list