[Lldb-commits] [PATCH] D39844: CompilerType: Add ability to retrieve an integral template argument

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 9 11:13:18 PST 2017


labath added inline comments.


================
Comment at: unittests/Symbol/TestClangASTContext.cpp:418-419
 
-    arg = m_ast->GetTemplateArgument(t.GetOpaqueQualType(), 1, kind);
-    EXPECT_EQ(kind, eTemplateArgumentKindIntegral);
-    EXPECT_EQ(arg, int_type);
+    EXPECT_EQ(m_ast->GetTemplateArgumentKind(t.GetOpaqueQualType(), 1),
+              eTemplateArgumentKindIntegral);
+    auto p = m_ast->GetIntegralTemplateArgument(t.GetOpaqueQualType(), 1);
----------------
zturner wrote:
> What about booleans, functions, pointers, references, parameter packs, and everything else?  Even if you want to limit the scope of your change to exclude parameter packs, I think we should handle the other stuff.  If it already works, can you add some tests for those cases?
I think boolean is handled as an integral type, but I can check that.

The other options here are "declaration", "template", "template expansion", "expression", "nullptr", and "pack".

Of these, I think I know what a "declaration" kind is, but I am not sure about most of the others (e.g. I don't think "expression" kind can even appear in our case, as we should always see a fully resolved template.

The thing is, there is nothing to "work" here. We have no API to retrieve and represent these entities. All you can do is call GetTemplateArgumentKind on them (which only translates between one enum and the other) and one of these two getters (which will return the empty value, because they're called on the wrong kind). I suppose I could test that.

What would be interesting is to test the other cases in the `GetAsTemplateSpecialization` (seeing through typedefs and stuff). This is actually the main reason why I wrote this test, as I had to refactor that code. I didn't do that, because I felt I would have to go through heroic efforts to construct e.g. a `clang::Type::Elaborated` object -- I don't think our ClangASTContext even has methods for constructing that.


https://reviews.llvm.org/D39844





More information about the lldb-commits mailing list