[PATCH] Adding 4 ASTMatchers: typedefDecl, isInMainFile, isInSystemFile, isInFileMatchingName

Hendrik von Prince raise.rescue at gmail.com
Tue Nov 4 15:14:08 PST 2014


Glad that my patch got accepted, thanks!
Well, as I have no commit access I thought that someone might apply that patch by himself - or that there is a magic mechanism that would have allowed me to commit the patch by using arcanist. Apparently, both assumptions seem to be wrong - may somebody apply that patch to the tree?

================
Comment at: include/clang/ASTMatchers/ASTMatchers.h:219
@@ +218,3 @@
+                          std::string, RegExp) {
+  assert(!RegExp.empty());
+
----------------
djasper wrote:
> I think it is unnecessary, to assert here. The behavior is well-defined.
I took that from the existing matchesName-matcher (Line 1707 currently). Is there a difference between the matchesName-matcher and the isInFileMatchingName-matcher that makes sense to have a different behaviour regarding of empty regex? Or should that assertion also be removed from the matchesName-regex?

================
Comment at: include/clang/Tooling/Tooling.h:157
@@ -157,1 +156,3 @@
+                           const Twine &FileName = "input.cc",
+                           const std::vector<std::pair<std::string, std::string>> &VirtualMappedFiles= {});
 
----------------
djasper wrote:
> sbenza wrote:
> > I believe we can't still use brace init in clang. More instances of this in other files.
> > See http://llvm.org/docs/CodingStandards.html#supported-c-11-language-and-library-features
> Stick to 80 columns.
I see. So replacing the empty initializer list by const std::vector<std::pair<std::string, std::string>>() would do the thing, but repeating the nesting template definition doesn't appeal me. A typedef could improve it.
Searching for std::vector<std::pair<std::string, std::string>>in the project brings the RemappedFile-variable in PreprocessorOptions.h up, so it would make sense to declare the type at a level where it could be also reused in PreprocessorOptions.h, wouldn't it?
I would be lucky of some advices to this:
- should I introduce a typedef for that?
- where would be a good place?
- what should it be named? (my first guess would be something like "FileMappings", but I'm honestly not so good in choosing names)

http://reviews.llvm.org/D4283






More information about the cfe-commits mailing list