forked from myint/cppclean
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement basic support for ctor initializer lists and exporting defi…
…nes with values (myint#128) * Implement preliminary solution to myint#56 for exporting defines This change modifies WarningHunter._determine_uses()._add_use() to take in a full VariableDeclaration object instead of Type. This allows us to check for the initial_value attribute of a VariableDeclaration object which may contain a symbol from an included file (e.g. a #define). This change also exports Define objects in order to capture their value and check if they are being used. To fully implement the issue rasied in myint#56, inline constructor member initializer lists need to be supported. * Implement basic support for ctor initializer lists This change adds basic support for initializing variables (initial_value attribute of VariableDeclaration) inside ctor initializer lists. It only supports one parameter for a given member. The ctor must also be inline defined. In other words, a ctor with its definition outside the class is not supported. Below is an example of what's supported: ``` class Foo { public: Foo() : foo(1) {} private: int foo; }; ``` In this case, the `initial_value` of `foo` is set to `1`. Whereas, the following is not supported, and will be ignored: ``` class Foo { public: Foo() : bar(1, 2, 3, 4) {} private: Bar bar; }; ``` This ctor is defined outside the class, and thus not supported: ``` class Foo { public: Foo(); private: Bar bar; }; Foo:Foo() : bar(1) {} ``` * Add tests for ctor initializer lists * Fix travis ci errors * Fix using explicit python3 type This fixes the broken build for Python 2. * Fix inconsistency with usage of local variable
- Loading branch information
1 parent
4bb45d6
commit 9fcab0f
Showing
6 changed files
with
189 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef CONST_DEFINE_H | ||
# define CONST_DEFINE_H | ||
|
||
# define CONST_DEFINE 1 | ||
|
||
#endif //! CONST_DEFINE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include "const_define.h" | ||
|
||
class A { | ||
public: | ||
A() : | ||
abc(CONST_DEFINE), | ||
efg(2), | ||
hij(3) | ||
{} | ||
private: | ||
int abc; | ||
int efg; | ||
int hij; | ||
}; | ||
|
||
struct B { | ||
int arg1; | ||
|
||
B() : | ||
arg1(CONST_DEFINE) | ||
{} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters