Giter Club home page Giter Club logo

codinuum / cca Goto Github PK

View Code? Open in Web Editor NEW
18.0 2.0 5.0 7.16 MB

Code Continuity Analysis Framework

Home Page: https://codinuum.github.io/gallery-cca/

License: Apache License 2.0

Python 4.04% Makefile 0.52% OCaml 93.14% Shell 0.14% Standard ML 0.90% Dockerfile 0.03% JavaScript 1.03% CSS 0.15% HTML 0.04% Verilog 0.01%
ast-differencing ast-patching java-parser fortran-parser python-parser cpp-parser verilog-parser ast-diff-tool ast-patch-tool ast-matching

cca's People

Contributors

codinuum avatar mstmhsmt avatar

Stargazers

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

Watchers

 avatar  avatar

cca's Issues

[cpp] Regression in cpp parsing of marcros

Hey team.
I noticed that recent changed introduced a small regression specifically

int main() {
  P *p = new P();
  foreach (QString arg, options->args)
    p->play(arg);
}

Crashes the parser with

PARSING ERROR: File "cpp_tree.ml", line 248, characters 22-28: Assertion failed

Somehow the fact that p was declared and then used in the macro confuses the hash table in the visitor.

Opam packaging?

Hello,
some users are trying to make a Spack package for cca, and have some difficulties:
spack/spack#18733

It would be very helpful if you could make an opam package for cca. We would then have the possibility to use opam-bundle to create a .tar.gz file containing cca and all its dependencies, and its installation on a machine without OCaml would then be very easy. I know it requires a little bit of time to make an opam package, but it is very beneficial in the long term for sharing your code.

best,
Anthony

[cpp] Parsing new-statement inside lambda can fail

For example here:

int main() {
  int *ptr = nullptr;
  foo.bar([&ptr]() {
    ptr = new int;
  });
  return 1;
}

The assignment ptr = new int; fails. Maybe inside the context of a lambda (as argument) primitives types are not seen as types?

[cpp] 2 more parsing failures

The following fails to parse:

  1. typedef with struct declaration
typedef struct A {} *LP_A;
  1. template disambiguator for dependent names
class c {
    struct t {
        template<template<typename V0> class V> struct s {};
        template<typename V> static void f( s<V::template r>* = 0 );
    };
};

ForStatement in C has ambiguous AST

This might be an intentional choice so feel free to close the issue.
I have noticed that the following codes produce the same AST:

for (;cond();) {}

and

for (;;iter()) {}

In the sense that, from the AST itself, it is not possible to determine which expression is the loop-condition and which is the iteration-expression.

I understand that this might be non-trivial to fix. I noticed that empty init_statement in represented as ExpressionStatement. Maybe if there was a similar place-holder for an empty(non-present) expression? Or if ForStatement had a fixed number of children that may be empty?

LinkageSpecification spans multiple pre-processor conditions

Hey team. You are doing an amazing work. ❤️
I'm not sure if this is an actual issue or a known "feature", but in the following code:

#ifdef __cplusplus
extern "C" {
#endif
struct foo;
#ifdef __cplusplus
} /* End extern "C".  */
#endif

The AST tree looks a bit weird. It looks like the linkage-specification has higher priority than the pre-processor conditionals. I understand that it's impossible to parse all non-pre-processed code. Just wanted to ask if this is known.

[C++] sizeof with complex types

The types from complex.h seem to be parsed in other contexts, e.g.

bar<double _Complex>();
float _Imaginary ** c;

But the same types are refused by the parser when given to sizeof operator, e.g.

std::size_t double_size = sizeof(double _Complex);

ceph/ceph

hi @codinuum , thank you for this super library
I tried running it on a popular C++ library (https://github.com/ceph/ceph) and ran into a few parse errors.
Here's one file affected (src/common/FixedCDC.cc):

// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#pragma

#include "FixedCDC.h"

void FixedCDC::calc_chunks(
  const bufferlist& bl,
  std::vector<std::pair<uint64_t, uint64_t>> *chunks) const
{
  size_t len = bl.length();
  if (!len) {
    return;
  }
  for (size_t pos = 0; pos < len; pos += chunk_size) {
    chunks->push_back(std::pair<uint64_t,uint64_t>(pos, std::min(chunk_size,
								 len - pos)));
  }
}

[cpp] 2 parsing issues

Hey cca team, thank you for the amazing work.
We noticed that some syntax causes issues with parsing, specifically:
1)

struct left {} constexpr right{};

It seems that the parser does not expect constexpr in this declaration context.
2)

auto [a,b]{c()};

Directly calling the constructor of the structured binding instead of the more common assignment operator, e.g. auto [a,b] = c();, causes parser error.

Declaration as if-condition

This is probably more of a feature-request:

int main() {
  if (A* a = get_A()) return 1;
  return 0;
}

Will translate the condition as assignment where lhs is a multiplicative-expression.

int main() {
  if (A a = get_A()) return 1;
  return 0;
}

Will translate as macro A applied to a.

I understand it's ambiguous without knowing what is a type but a similar code outside of an if-statement works as expected, e.g.

int main() {
  A* a = get_A();
  return 0;
}

Is it because the parser by default expects the condition to be an expression?

cpp parser: declaration at the end of function bodies

Hello and thanks again for your amazing project.

I've noticed a strange AST for the following code:

struct Foo {
  Foo(int b) {}
};
void bar() {
  Foo f(1);
}

The declaration of f is split into StatementMacro:Foo and function-call f(1). But if I add return statement after the declaration:

struct Foo {
  Foo(int b) {}
};
void bar() {
  Foo f(1);
  return;
}

The AST looks as expected.

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.