lebedev.ri added a comment.

Global question: you are using `NamedDecl::getNameAsString()`, and passing it 
as `StringRef`.
You have looked at this with ASAN, and it's ok?

Also, have you considered using the `NamedDecl::getName()`, which already 
returns `StringRef`.?



================
Comment at: clang-doc/Serialize.cpp:185
+        I.Members.emplace_back(getUSRForDecl(T), N->getNameAsString(),
+                               InfoType::IT_enum,
+                               F->getQualifiedNameAsString());
----------------
This change from `InfoType::IT_record` is intentional?


================
Comment at: clang-doc/Serialize.cpp:200-217
 static void parseParameters(FunctionInfo &I, const FunctionDecl *D) {
   for (const ParmVarDecl *P : D->parameters()) {
-    SymbolID Type;
-    std::string Name;
-    InfoType RefType;
     if (const auto *T = getDeclForType(P->getOriginalType())) {
-      Type = getUSRForDecl(T);
-      if (dyn_cast<EnumDecl>(T))
-        RefType = InfoType::IT_enum;
-      else if (dyn_cast<RecordDecl>(T))
-        RefType = InfoType::IT_record;
-      I.Params.emplace_back(Type, RefType, P->getQualifiedNameAsString());
-    } else {
-      Name = P->getOriginalType().getAsString();
-      I.Params.emplace_back(Name, P->getQualifiedNameAsString());
+      if (const auto *N = dyn_cast<EnumDecl>(T)) {
+        I.Params.emplace_back(getUSRForDecl(N), N->getNameAsString(),
+                              InfoType::IT_enum, 
P->getQualifiedNameAsString());
+        continue;
----------------
This very closely matches the `parseFields()`, with a few changes (`I.Params` 
vs `I.Members`,
`getUSRForDecl(T)` vs `getUSRForDecl(N)`, `F->getQualifiedNameAsString()` vs 
`P->getQualifiedNameAsString()`).
If it makes sense, it might be a good idea to refactor them together?


https://reviews.llvm.org/D46281



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

Reply via email to