From d69f80304f5e1cd09176d45fcc1d24f362ba3319 Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Fri, 4 Oct 2019 10:50:58 +0330 Subject: update --- README.md | 19 ++++++++++++------- cgrep.cpp | 7 +++++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4ff7d07..111455c 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Should be more or less fine for other C-family languages as well but I haven't tested for those since I don't use those. Let me know if you run into trouble using cgrep on those.
The goal is to make the options and features as similar to `grep` as possible for ease of use.
-## Bulding +## Building Assuming you have the llvm/clang libraries(the build file will read your llvm options using `llvm-config` so make sure it's in path), just run:
```bash git clone https://github.com/bloodstalker/cgrep @@ -15,8 +15,12 @@ git submodule init git submodule update make ``` -`cgrep` supports LLVM 5,6,8,9. For 10. the latest tested trunk version is:367652. support for 5 and 6 might be dropped in the future.
-The makefile assumes clang is called `clang` and llvm-config is called `llvm-config`. On some distros, the names might not be the same. In those cases use `CXX` and `LLVM_CONF` to pass the values to the makefile.
+If you have installed LLVM but don't have `llvm-config`, you are missing the dev package for LLVM.
+`cgrep` supports LLVM 5,6,8,9. For 10. the latest tested trunk version is:367652.
+The makefile assumes clang is called `clang` and llvm-config is called `llvm-config`. On some distros, the names might not be the same. In those cases use `CXX` and `LLVM_CONF` to pass the values to the makefile like so:
+```bash +make CXX=clang-9.0 LLVM_CONF=llvm-config-9.0 +``` ## Usage A simple usage example:
@@ -24,9 +28,10 @@ A simple usage example:
cgrep -A 1 -B 1 --func --var --regex n[aA]m ./cgrep.cpp ``` Pleade do note that the regex will pass through both C++ and the regex engine, so if you would want to escape `\`, the regex you pass as the commandline arg would be `\\\\` instead of the normal `\\`.
-In order for cgrep to work, you need to have a compilation database, tools like cmake can generate one for you.
-If your build tool doesn't do that, you can just use [bear](https://github.com/rizsotto/Bear).
-You can also skip the compilation database alltogether passing cgrep `--` after the input file name.
+In order for cgrep to work, you need to have a compilation database, tools like `cmake` can generate one for you.
+If your build tool doesn't do that, you can just use [bear](https://github.com/rizsotto/Bear) or [scan-build](https://github.com/rizsotto/scan-build).
+You can also skip the compilation database alltogether passing cgrep `--` after the input file name which means you have chosen not to pass it anything.
+You can pass the options by hand since cgrep is a Clang instance so it recognizes every option clang has.
## Options Here's an option list though it might not be necessarily up-to-date.
@@ -58,7 +63,7 @@ For an up-to-date list, you can run `crep --help`.
`cgrep` is a clang tool, so it will accecpt all valid clang commandline options.
## Known Issues -* bulding cgrep with `-j` will not work because shitty makefile.
+* bulding cgrep with `-j` will not work because bad makefile.
* the coloring is off right now and doesn't work properly.
======= diff --git a/cgrep.cpp b/cgrep.cpp index cdbfe60..0e12759 100644 --- a/cgrep.cpp +++ b/cgrep.cpp @@ -196,6 +196,7 @@ std::vector listDirs(std::string _path) { std::cout << "name: " << ent_->d_name << "\ttype:" << int(ent_->d_type) << "\n"; if (ent_->d_type == DT_DIR) { + std::cout << ent_->d_name << "\n"; } dummy_.push_back(ent_->d_name); } @@ -632,10 +633,12 @@ public: CheckSLValidity(HashLoc); SourceLocation SL = Devi::SourceLocationHasMacro(HashLoc, Rewrite, "start"); - if (Devi::IsTheMatchInSysHeader(CO_SYSHDR, SM, SL)) + if (Devi::IsTheMatchInSysHeader(CO_SYSHDR, SM, SL)) { return void(); - if (!Devi::IsTheMatchInMainFile(CO_MAINFILE, SM, SL)) + } + if (!Devi::IsTheMatchInMainFile(CO_MAINFILE, SM, SL)) { return void(); + } std::string name = FileName.str(); if (regex_handler(REGEX_PP(CO_REGEX), name)) { std::cout << name << "\t"; -- cgit v1.2.3