[PATCH] D102159: [index][analyzer][ctu] Eliminate white spaces in the CTU lookup name.

Ella Ma via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 10 03:33:07 PDT 2021


OikawaKirie created this revision.
OikawaKirie added reviewers: akyrtzi, martong, steakhal.
OikawaKirie added a project: clang.
Herald added subscribers: ASDenysPetrov, dkrupp, donat.nagy, Szelethus, arphaman, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, xazax.hun.
OikawaKirie requested review of this revision.
Herald added a subscriber: cfe-commits.

In the analyzer, the CTU definition index file requires there are no white spaces in the CTU lookup name, aka. the USR of a function decl or a global variable decl. Otherwise, the index file will be wrongly parsed.
However, it is difficult for the analyzer to know whether a white space `' '` is the separator between the index string and the file path, or it is just a part of the index string or the path. It means that using either the first or the last white space as the separator could not be a good idea. As it is valid for a file path to have white spaces, a better choice seems to be eliminating all the white spaces in the index string.
In this patch, the white space `' '` for an unsupported type is replaced with a question mark `'?'`, which solves the problem as well as makes the index more reasonable as far as I am thinking.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102159

Files:
  clang/lib/Index/USRGeneration.cpp
  clang/test/Index/unsupported.cpp


Index: clang/test/Index/unsupported.cpp
===================================================================
--- /dev/null
+++ clang/test/Index/unsupported.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_extdef_map %s -- | FileCheck %s
+
+struct X {
+  bool f(char *);
+};
+
+typedef bool (X::*XFP)(char *);
+
+// CHECK-NOT: {{ [^ ]+ }}
+void f(XFP xfp) {}
Index: clang/lib/Index/USRGeneration.cpp
===================================================================
--- clang/lib/Index/USRGeneration.cpp
+++ clang/lib/Index/USRGeneration.cpp
@@ -895,7 +895,7 @@
     }
 
     // Unhandled type.
-    Out << ' ';
+    Out << '?';
     break;
   } while (true);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102159.344014.patch
Type: text/x-patch
Size: 651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210510/d3315a62/attachment.bin>


More information about the cfe-commits mailing list