Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Parser can't read code. Declaration is skipped. With correct code. #1181

Closed
PawelKm opened this issue Jun 29, 2017 · 8 comments
Closed

Comments

@PawelKm
Copy link

PawelKm commented Jun 29, 2017

I have cpp file where I have function:

bool ConfigurationLoader::LoadSetting(
    const std::pair<std::string, const boost::property_tree::basic_ptree<std::string, std::string>> &inTree,
    const std::string &setting,
    std::pair<std::string,
                   boost::property_tree::basic_ptree<
                  std::string, std::string, std::less<std::string>>> &retVal)

and also hpp file where I have declaration:

static bool LoadSetting(
      const std::pair<std::string, const boost::property_tree::basic_ptree<std::string, std::string>> &inTree,
      const std::string &setting,
      std::pair<std::string,
                boost::property_tree::basic_ptree<
                    std::string, std::string, std::less<std::string>>> &retVal);

in both files I have #include <boost/property_tree/xml_parser.hpp>
what includes
#include <boost/property_tree/ptree.hpp>
what includes
#include <boost/property_tree/ptree_fwd.hpp> what contains the forward declaration:

template < class Key, class Data, class KeyCompare = std::less<Key> >
    class basic_ptree;

But still using const boost::property_tree::basic_ptree<std::string, std::string>> causes 5 issues reported with declarations skipped up to first namespace level.

Usage of const boost::property_tree::basic_ptree<std::string, std::string, std::less<std::string>>> fixes the problem for now.

@guwirth
Copy link
Collaborator

guwirth commented Jun 29, 2017

@PawelKm thanks for your feedback.

@PawelKm
Copy link
Author

PawelKm commented Jun 29, 2017

This I can provide now:

  • Which cxx plugin version are you using?
    -- 0.9.7 release version
  • Is your compiler supporting the code? Which compiler?
    -- yes I use VS2015 C++, Visual Studio2017 C++, gcc 4.9.2, gcc 4.9.4

I will try to narrow down problem whenever I find free time.

@guwirth guwirth added bug and removed question labels Jun 29, 2017
@guwirth guwirth added this to the 0.9.7 milestone Jun 29, 2017
@guwirth
Copy link
Collaborator

guwirth commented Jun 29, 2017

Hi @PawelKm

reduced sample:

bool ok1(templateName1<templateName<string>> declarator); // without const
bool ok2(templateName1<const templateName<string> > declarator); // blank between >>

bool failure(templateName1<const templateName<string>> declarator); // failure

As a workaround you can add a blank between >>.

Regards

@PawelKm
Copy link
Author

PawelKm commented Jun 30, 2017

Thanks @guwirth that helped also!

@guwirth guwirth modified the milestones: 0.9.8, 0.9.7 Aug 24, 2017
@guwirth
Copy link
Collaborator

guwirth commented Oct 14, 2017

@ametselaar we need your help. We have a hard grammar nut to crack.
Do you have some time to have a look to this issue?

@guwirth guwirth modified the milestones: 0.9.8, next Nov 14, 2017
@guwirth guwirth modified the milestones: 0.9.9, next Jan 1, 2018
@guwirth guwirth removed this from the next milestone Jan 16, 2018
@guwirth guwirth added this to the 1.2.1 milestone Nov 14, 2018
@guwirth guwirth modified the milestones: 1.2.1, 1.2.2 Dec 23, 2018
@guwirth guwirth removed this from the 1.2.2 milestone Feb 9, 2019
@guwirth
Copy link
Collaborator

guwirth commented Feb 9, 2019

see #1685

@guwirth guwirth closed this as completed Feb 9, 2019
@zdg123456
Copy link

@guwirth 您好
我这边也碰到C++ Parser can't read code.Declaration is skipped这个报错
具体报错:
ERROR: Undefined functionlike macro '__has_attribute' assuming 0
ERROR: Undefined functionlike macro '__has_attribute' assuming 0
ERROR: Undefined functionlike macro '__has_extension' assuming 0
ERROR: Undefined functionlike macro 'KERNEL_VERSION' assuming 0
ERROR: Undefined functionlike macro 'RHEL_RELEASE_VERSION' assuming 0
C插件版本:sonar-c-plugin-1.3.2.1853.jar
C++插件版本:sonar-cxx-plugin-2.0.7.3119.jar

@guwirth
Copy link
Collaborator

guwirth commented Mar 24, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants