Giter Club home page Giter Club logo

caide-cpp-inliner's People

Contributors

alcash07 avatar bahnwaerter avatar konakarthik12 avatar slycelote avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

caide-cpp-inliner's Issues

Function template is removed while referenced as a function pointer

If I pass as a default value to a function another function, the passed function is not kept (The minimal example I could reproduce was with functions using templates, which is my use case).

main.cpp

#include <iostream>
#include "lib.hpp"

int main()
{
    A a;

    std::cout << a.f() << std::endl;
}

lib.hpp

#include <functional>

using namespace std;

template <typename T>
T value()
{
    return 42;
}

class A
{
public:
    function<int()> f;

    A(function<int()> f = value<int>) : f(f)
    {
    }
};

result.cpp

#include <iostream>
#include <functional>

using namespace std;


class A
{
public:
    function<int()> f;

    A(function<int()> f = value<int>) : f(f)
    {
    }
};

int main()
{
    A a;

    std::cout << a.f() << std::endl;
}

Notice how declaration of function value was removed. If I use value without any templates it is not removed.

Function is removed if it is used from an object defined with auto

Note function foo in the following code:

Input:

#include <vector>
#include <algorithm>

using namespace std;

class Value
{
public:
    int value;

    Value(int value) : value(value) {}

    int foo() { return value; }
};

int main()
{
    vector<Value> v;

    sort(v.begin(), v.end(), [&](auto &a, auto &b) {
        return a.foo() < b.foo();
    });

    return 0;
}

The expected output is the same code, however, the function foo is removed. Here is the result code:

#include <vector>
#include <algorithm>

using namespace std;

class Value
{
public:
    int value;


};

int main()
{
    vector<Value> v;

    sort(v.begin(), v.end(), [&](auto &a, auto &b) {
        return a.foo() < b.foo();
    });

    return 0;
}

It works ok, if in the comparer, instead of using auto I use [&](Value &a, Value &b) { ... }

Some comments aren't removed

Comments in global namespace aren't removed, and I didn't find an option to change this behavior. Comments inside classes that are at least partially inlined are also affected.

Build fails on XCode

I was going to check out the latest changes, so I updated the repo with submodules. Now I get the following compilation error on XCode:

In file included from /Users/oleksandr.bacherikov/caide-cpp-inliner/src/RemoveInactivePreprocessorBlocks.cpp:7:
/Users/oleksandr.bacherikov/caide-cpp-inliner/src/RemoveInactivePreprocessorBlocks.h:40:93: error: non-virtual member function marked 'override' hides virtual member function
void MacroUndefined(const clang::Token& MacroNameTok, const clang::MacroDefinition& MD) override;
^
In file included from /Users/oleksandr.bacherikov/caide-cpp-inliner/src/RemoveInactivePreprocessorBlocks.cpp:7:
In file included from /Users/oleksandr.bacherikov/caide-cpp-inliner/src/RemoveInactivePreprocessorBlocks.h:12:
/Users/oleksandr.bacherikov/caide-cpp-inliner/src/clang/include/clang/Lex/PPCallbacks.h:255:16: note: hidden overloaded virtual function 'clang::PPCallbacks::MacroUndefined' declared here: different number of parameters (3 vs 2)
virtual void MacroUndefined(const Token &MacroNameTok,

Looks like some change was made in Clang in that function on April 27.

run this project

Hi,after I build this project successfully,I don't know how to run the examples,I read the readme and some other files.I still not found how to use it.when I use ./cmd -std=c++11 -I . -isystem ../../src/clang/lib/Headers/ -- main.cpp ascii_graphics.cpp,it turned out the error
"error: no such file or directory: '/home/wc/gitHub/caide-cpp-inliner/doc/demo/caide-tmp/concat.cpp'
error: no input files
error: unable to handle compilation, expected exactly one compiler job in ''
Error while processing /home/wc/gitHub/caide-cpp-inliner/doc/demo/caide-tmp/concat.cpp.
Compilation error"
please help me

C++20 concepts are not being removed

Declarations of concepts, a feature introduced in C++ 20, are not being removed.

In the example below, the Printable concept is unused and should be removed.

input.cpp:

#include <iostream>
#include <concepts>

template<typename T>
concept Addable = requires(T a, T b) {
    {a + b} -> std::same_as<T>;
};

template<typename T>
concept Printable = requires(T t) { // this concept is unused but it is not removed
    {std::cout << t};
};

template<Addable T>
T add(T a, T b) {
    return a + b;
}

int main() {
    std::cout << add(5, 3) << std::endl;
    std::cout << add(2.5, 3.7) << std::endl;
    return 0;
}

result.cpp (identical to input):

#include <iostream>
#include <concepts>

template<typename T>
concept Addable = requires(T a, T b) {
    {a + b} -> std::same_as<T>;
};

template<typename T>
concept Printable = requires(T t) { // this concept is unused but it is not removed
    {std::cout << t};
};

template<Addable T>
T add(T a, T b) {
    return a + b;
}

int main() {
    std::cout << add(5, 3) << std::endl;
    std::cout << add(2.5, 3.7) << std::endl;
    return 0;
}

Template friend declaration gets removed

Example:

template <typename T>
class C;
template <typename T>
class D
{
  static void f ();
  template <typename>
  friend class C;
};
template <typename T>
class C
{
public:
  static void f ()
  {
    D<T>::f ();
  }
};
int main ()
{
  C<int>::f ();
}

Everything else is preserved but

template <typename>
friend class C;

gets removed which makes D<T> inaccessible from C<T>

Unused fields are not removed

Header:

#pragma once
struct C { using type = int; };
struct D { C::type v; };

And use only class D in actual code.

That's very simplified example but obviously it leads to inability to use any sort of your own type trait in library code.

Used constructor is deleted

Here's an example where range constructor gets erroneously deleted http://ideone.com/edb9hQ. Interesting thing is that, if I remove range forward declaration, the constructor remains in place, but since using base_type is removed, it doesn't compile anyway.

Build issue

Recently,I try to build this project,and I encountered a problem,and I don't know how to solve it.here is the problem:
[ 70%] Building CXX object CMakeFiles/caideInliner.dir/util.cpp.o
[ 76%] Linking CXX static library libcaideInliner.a
[ 76%] Built target caideInliner
Scanning dependencies of target cmd
[ 82%] Building CXX object cmd/CMakeFiles/cmd.dir/cmd.cpp.o
[ 88%] Linking CXX executable cmd
../libcaideInliner.a(inliner.cpp.o):(.rodata._ZTIN5caide8internal10TrackMacroE[_ZTIN5caide8internal10TrackMacroE]+0x10): undefined reference to typeinfo for clang::PPCallbacks' ../libcaideInliner.a(inliner.cpp.o):(.rodata._ZTIN5caide8internal21InlinerFrontendActionE[_ZTIN5caide8internal21InlinerFrontendActionE]+0x10): undefined reference to typeinfo for clang::ASTFrontendAction'
../libcaideInliner.a(inliner.cpp.o):(.rodata._ZTIN5caide8internal28InlinerFrontendActionFactoryE[_ZTIN5caide8internal28InlinerFrontendActionFactoryE]+0x10): undefined reference to typeinfo for clang::tooling::FrontendActionFactory' ../libcaideInliner.a(optimizer.cpp.o):(.rodata._ZTIN5caide8internal17OptimizerConsumerE[_ZTIN5caide8internal17OptimizerConsumerE]+0x10): undefined reference to typeinfo for clang::ASTConsumer'
../libcaideInliner.a(optimizer.cpp.o):(.rodata._ZTIN5caide8internal23OptimizerFrontendActionE[_ZTIN5caide8internal23OptimizerFrontendActionE]+0x10): undefined reference to typeinfo for clang::ASTFrontendAction' ../libcaideInliner.a(optimizer.cpp.o):(.rodata._ZTIN5caide8internal30OptimizerFrontendActionFactoryE[_ZTIN5caide8internal30OptimizerFrontendActionFactoryE]+0x10): undefined reference to typeinfo for clang::tooling::FrontendActionFactory'
../libcaideInliner.a(RemoveInactivePreprocessorBlocks.cpp.o):(.rodata._ZTIN5caide8internal32RemoveInactivePreprocessorBlocksE[_ZTIN5caide8internal32RemoveInactivePreprocessorBlocksE]+0x10): undefined reference to `typeinfo for clang::PPCallbacks'
collect2: error: ld returned 1 exit status
cmd/CMakeFiles/cmd.dir/build.make:116: recipe for target 'cmd/cmd' failed
make[2]: *** [cmd/cmd] Error 1
CMakeFiles/Makefile2:154: recipe for target 'cmd/CMakeFiles/cmd.dir/all' failed
make[1]: *** [cmd/CMakeFiles/cmd.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2

Type alias is removed

using iterator_category = std::input_iterator_tag;
Type aliases like this one inside my iterator classes are removed even with the // caide keep comment.

[Feature] C++17 support

Is there a plan to support C++17? Currently, I get the following error right away when I change 14 into 17 error: invalid value 'c++17' in '-std=c++17'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.