使用Clang C ++ API生成USR

时间:2018-09-17 01:56:51

标签: c++ clang

我正在尝试使用clang C ++ API进行一些代码分析,但发现有时<Mutation mutation={addUserQuery}> { (addUser, data)=>{ console.log(data) return ( <div className="form"> <form onSubmit={(e)=>{ e.preventDefault(); console.log(e); addUser({variables: {username: "AuraDivitiae", firstname: "Michael", lastname: "Lee"}}) }}> <button type="submit">Add User</button> </form> </div> ) } } </Mutation> 会崩溃。

例如,给出以下代码:

clang::index::generateUSRForDecl

为代表template<typename T> struct foo { enum { val = T::val }; }; 的DeclRefExpr引用的声明生成USR将会崩溃(看起来就像在访问不存在的AST上下文时一样)。

类似地,给出(稍微复杂一些)示例

T::val

尝试为代表下一行的struct base { template<typename T> static int helper(const T&); static double helper(...); }; template<typename T> struct derived : base { using type = decltype(helper(T{})); }; 调用的DeclRefExpr引用的声明生成USR也会崩溃。

这两种方式对我来说都是有意义的:在实例化所涉及的模板之前,没有有意义的实体可以引用,但是我很好奇是否有足够合理的前提条件可以检查代码以避免尝试为实体生成USR将不起作用(在这种情况下,libclang崩溃了)?

0 个答案:

没有答案