diff options
author | bloodstalker <thabogre@gmail.com> | 2019-10-04 07:20:58 +0000 |
---|---|---|
committer | bloodstalker <thabogre@gmail.com> | 2019-10-04 07:20:58 +0000 |
commit | d69f80304f5e1cd09176d45fcc1d24f362ba3319 (patch) | |
tree | b878b199122e8f831b3400daedb3d0bec46426c2 | |
parent | updated the latest llvm trunk version tested to 367652 (diff) | |
download | cgrep-d69f80304f5e1cd09176d45fcc1d24f362ba3319.tar.gz cgrep-d69f80304f5e1cd09176d45fcc1d24f362ba3319.zip |
update
-rw-r--r-- | README.md | 19 | ||||
-rw-r--r-- | cgrep.cpp | 7 |
2 files changed, 17 insertions, 9 deletions
@@ -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.<br/> The goal is to make the options and features as similar to `grep` as possible for ease of use.<br/> -## 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:<br/> ```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.<br/> -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.<br/> +If you have installed LLVM but don't have `llvm-config`, you are missing the dev package for LLVM.<br/> +`cgrep` supports LLVM 5,6,8,9. For 10. the latest tested trunk version is:367652.<br/> +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:<br/> +```bash +make CXX=clang-9.0 LLVM_CONF=llvm-config-9.0 +``` ## Usage A simple usage example:<br/> @@ -24,9 +28,10 @@ A simple usage example:<br/> 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 `\\`.<br/> -In order for cgrep to work, you need to have a compilation database, tools like cmake can generate one for you.<br/> -If your build tool doesn't do that, you can just use [bear](https://github.com/rizsotto/Bear).<br/> -You can also skip the compilation database alltogether passing cgrep `--` after the input file name.<br/> +In order for cgrep to work, you need to have a compilation database, tools like `cmake` can generate one for you.<br/> +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).<br/> +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.<br/> +You can pass the options by hand since cgrep is a Clang instance so it recognizes every option clang has.<br/> ## Options Here's an option list though it might not be necessarily up-to-date.<br/> @@ -58,7 +63,7 @@ For an up-to-date list, you can run `crep --help`.<br/> `cgrep` is a clang tool, so it will accecpt all valid clang commandline options.<br/> ## Known Issues -* bulding cgrep with `-j` will not work because shitty makefile.<br/> +* bulding cgrep with `-j` will not work because bad makefile.<br/> * the coloring is off right now and doesn't work properly.<br/> ======= @@ -196,6 +196,7 @@ std::vector<std::string> 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"; |