├── PluginTest ├── .gitignore ├── src │ └── PluginTest.cpp └── .project ├── CPPLanguageModel ├── .gitignore ├── src │ ├── Constants.h │ ├── ParameterValues.cpp │ ├── ListAliases.h │ ├── Static.h │ ├── NamedEntity.h │ ├── Access.h │ ├── MiscCode.cpp │ ├── Serialization.h │ ├── ASTEntry.h │ ├── Result.h │ ├── SourceElement.h │ ├── CompilerSpecific.h │ ├── GlobalVar.h │ ├── UID.h │ ├── PluginManager.h │ ├── SourceLocation.h │ ├── Union.h │ ├── ConstantValue.h │ ├── Template.h │ ├── Attribute.h │ ├── Function.h │ ├── Namespace.h │ ├── ASTDictionary.cpp │ └── ParameterValues.h ├── .settings │ └── org.eclipse.cdt.core.prefs └── .project ├── GCCInternalsTools ├── .gitignore ├── .settings │ └── language.settings.xml ├── src │ ├── AttributeParser.h │ ├── DeclOrTypeBaseTree.cpp │ ├── PluginManagerImpl.h │ ├── IdentifierTree.h │ ├── DeclOrTypeBaseTree.h │ ├── TypeTree.h │ ├── ConstantTree.h │ ├── NamespaceTree.h │ ├── AttributeParser.cpp │ ├── DeclTree.h │ ├── TreeList.h │ ├── PluginManagerImpl.cpp │ └── DeclTree.cpp └── .project ├── GCCInternalsUTFixture ├── .gitignore └── .project ├── GCCPlugin ├── .gitignore ├── gdbinit ├── HelloWorld.cpp ├── .settings │ └── language.settings.xml ├── src │ └── gccplugin.cpp └── .project ├── GCCInternalsUnitTest ├── expectedResults │ ├── Classes │ │ ├── SimpleClassTestCase.out │ │ ├── WriteToFieldByOffsetTestCase.out │ │ └── WriteToFieldByOffsetTestCase.xml │ ├── GlobalVars │ │ ├── AddGlobalVarClassInstanceTest.out │ │ ├── AddFundamentalValueGlobalVarTest.out │ │ ├── NonIntrinsicTestCase.xml │ │ ├── LocallyUserDefinedClassTestCase.xml │ │ ├── IntrinsicTestCase.xml │ │ ├── AttributesTestCase.xml │ │ ├── AddFundamentalArrayValueGlobalVarTest.out │ │ └── DerivedTypesTestCase.xml │ ├── Unions │ │ └── SimpleUnionTestCase.xml │ ├── Namespaces │ │ ├── CreateNamespaceTest.xml │ │ └── NamespaceBasicTestCase.xml │ └── Functions │ │ ├── SimpleFunctionTestCase.xml │ │ └── FunctionsWithParametersTestCase.xml ├── .gitignore ├── testCaseSourceCode │ ├── Namespaces │ │ ├── CreateNamespaceTest.cpp │ │ └── NamespaceBasicTestCase.cpp │ ├── Unions │ │ └── SimpleUnionTestCase.cpp │ ├── GlobalVars │ │ ├── AttributesTestCase.cpp │ │ ├── IntrinsicTestCase.cpp │ │ ├── NonIntrinsicTestCase.cpp │ │ ├── LocallyUserDefinedClassTestCase.cpp │ │ ├── DerivedTypesTestCase.cpp │ │ ├── AddGlobalVarClassInstanceTest.cpp │ │ ├── AddFundamentalValueGlobalVarTest.cpp │ │ └── AddFundamentalArrayValueGlobalVarTest.cpp │ ├── Functions │ │ ├── FunctionPrototypeTestCase.cpp │ │ ├── SimpleFunctionTestCase.cpp │ │ └── FunctionsWithParametersTestCase.cpp │ └── Classes │ │ ├── SimpleClassTestCase.cpp │ │ └── WriteToFieldByOffsetTestCase.cpp ├── .gdbinit ├── test │ ├── UnionTests.cpp │ ├── AllTests.cpp │ ├── ClassTests.cpp │ ├── FunctionTests.cpp │ ├── NamespaceTests.cpp │ └── GlobalVarTests.cpp ├── gdbinit ├── .project ├── src │ ├── HelperFunctions.h │ └── HelperFunctions.cpp └── gcc_wrapper.sh └── TestExtensions └── TestExtensions ├── .gitignore ├── .project └── src ├── NamespaceTestExtension.cpp └── ClassTestExtension.cpp /PluginTest/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug 2 | -------------------------------------------------------------------------------- /CPPLanguageModel/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug 2 | /Release 3 | -------------------------------------------------------------------------------- /GCCInternalsTools/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug 2 | /Release 3 | -------------------------------------------------------------------------------- /GCCInternalsUTFixture/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug 2 | /Release 3 | -------------------------------------------------------------------------------- /GCCPlugin/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug 2 | /a.out 3 | /Release 4 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/Classes/SimpleClassTestCase.out: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /TestExtensions/TestExtensions/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug 2 | /Release 3 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug 2 | /contrib 3 | /results 4 | /temp 5 | /gcc_wrapper.sh~ 6 | /Release 7 | /Debug 8 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/Namespaces/CreateNamespaceTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NamespaceBasicTestCase.cpp 3 | * 4 | * Created on: Jul 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | #include 10 | 11 | 12 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/Classes/WriteToFieldByOffsetTestCase.out: -------------------------------------------------------------------------------- 1 | In SimpleClass constructor. 2 | m_booleanValue : 1 3 | m_charValue : b 4 | m_stringValue : A quick brown fox 5 | m_intValue : 12345 6 | m_longValue : 67890 7 | m_floatValue : 1.234 8 | m_doubleValue : 5.678e-100 9 | In SimpleClass constructor. 10 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/.gdbinit: -------------------------------------------------------------------------------- 1 | # 2 | # .gdbinit : GDB Config file 3 | # 4 | # 3/2010 - Ichthyo: add python pretty printers for STL 5 | 6 | python 7 | import sys 8 | sys.path.insert(0, '/opt/gdb/stlPrettyPrinter') 9 | from libstdcxx.v6.printers import register_libstdcxx_printers 10 | register_libstdcxx_printers (None) 11 | end 12 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/test/UnionTests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GlobalVarTests.cpp 3 | * 4 | * Created on: Jun 9, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | 11 | namespace 12 | { 13 | TEST(TestUnions, BasicTests) 14 | { 15 | ForkGCCTestCase( "-c", "Unions", "SimpleUnionTestCase", "namespaces=TestNamespace::", "list-all-namespaces" ); 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Constants.h 3 | * 4 | * Created on: Dec 20, 2013 5 | * Author: steve 6 | */ 7 | 8 | #ifndef CONSTANTS_H_ 9 | #define CONSTANTS_H_ 10 | 11 | 12 | 13 | 14 | namespace CPPModel 15 | { 16 | const std::string SCOPE_RESOLUTION_OPERATOR = "::"; 17 | const std::string STD_NAMESPACE_LABEL = "std::"; 18 | } 19 | 20 | 21 | #endif /* CONSTANTS_H_ */ 22 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/Unions/SimpleUnionTestCase.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 4 | 5 | #include 6 | #include 7 | 8 | 9 | 10 | 11 | namespace TestNamespace 12 | { 13 | union SimpleUnion 14 | { 15 | int m_intValue; 16 | double m_doubleValue; 17 | 18 | char* m_charPointer; 19 | } 20 | SimpleUnionInstance; 21 | 22 | } 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /GCCPlugin/gdbinit: -------------------------------------------------------------------------------- 1 | set schedule-multiple 2 | 3 | dir ~/gcc_build/4.8.0/build/gcc 4 | dir ~/gcc_build/4.8.0/gcc 5 | dir ~/gcc_build/4.8.0/gcc/cp 6 | dir ~/gcc_build/4.8.0/gcc/lto 7 | source ~/gcc_build/4.8.0/build/gcc/gdbinit.in 8 | 9 | python 10 | import sys 11 | sys.path.insert(0, '/home/steve/gdb_printers/python') 12 | from libstdcxx.v6.printers import register_libstdcxx_printers 13 | register_libstdcxx_printers (None) 14 | end -------------------------------------------------------------------------------- /CPPLanguageModel/.settings/org.eclipse.cdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/project/cdt.managedbuild.config.gnu.so.debug.310167330/append=true 3 | environment/project/cdt.managedbuild.config.gnu.so.debug.310167330/appendContributed=true 4 | environment/project/cdt.managedbuild.config.gnu.so.release.2123133652/append=true 5 | environment/project/cdt.managedbuild.config.gnu.so.release.2123133652/appendContributed=true 6 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/GlobalVars/AttributesTestCase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SimpleTestCaseWithIntrinsic.cpp 3 | * 4 | * Created on: Jun 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | 11 | namespace TestNamespace 12 | { 13 | static int globalInt [[unit_test::attribute1( "arg1" )]]; 14 | 15 | double globaldoubleWithoutStaticKeyword [[unit_test::attribute1( "arg2", "arg3" )]]; 16 | } 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/gdbinit: -------------------------------------------------------------------------------- 1 | set schedule-multiple 2 | 3 | dir ~/gcc_build/4.8.0/build/gcc 4 | dir ~/gcc_build/4.8.0/gcc 5 | dir ~/gcc_build/4.8.0/gcc/cp 6 | dir ~/gcc_build/4.8.0/gcc/lto 7 | source ~/gcc_build/4.8.0/build/gcc/gdbinit.in 8 | 9 | python 10 | import sys 11 | sys.path.insert(0, '/home/steve/gdb_printers/python') 12 | from libstdcxx.v6.printers import register_libstdcxx_printers 13 | register_libstdcxx_printers (None) 14 | end 15 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/Functions/FunctionPrototypeTestCase.cpp: -------------------------------------------------------------------------------- 1 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 2 | 3 | #include 4 | #include 5 | 6 | 7 | namespace TestNamespace 8 | { 9 | void FunctionReturningVoid(); 10 | 11 | int FunctionReturningInt(); 12 | 13 | std::string FunctionReturningString(); 14 | 15 | 16 | void* FunctionReturningVoidPointer(); 17 | void* (*PointerToFunctionReturningVoidPointer)(); 18 | } 19 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/test/AllTests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * AllTests.cpp 3 | * 4 | * Created on: Jun 9, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | #include "gtest/gtest.h" 10 | 11 | #include "../src/HelperFunctions.h" 12 | 13 | 14 | #include "NamespaceTests.cpp" 15 | #include "GlobalVarTests.cpp" 16 | #include "FunctionTests.cpp" 17 | #include "ClassTests.cpp" 18 | #include "UnionTests.cpp" 19 | 20 | 21 | 22 | int main( int argc, char** argv) 23 | { 24 | ::testing::InitGoogleTest( &argc, argv ); 25 | return RUN_ALL_TESTS(); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/GlobalVars/AddGlobalVarClassInstanceTest.out: -------------------------------------------------------------------------------- 1 | Test Class Initialized. 2 | Message: Source Code Message. 3 | Message: All Values Source Code Message. 4 | Boolean Value: 1 5 | Char Value: a 6 | Integer Value: 1 7 | Long Value: 2 8 | Float Value: 3 9 | Double Value: 4 10 | Test Class Initialized. 11 | Message: Injected String Value. 12 | Message: Second Injected String Value. 13 | Boolean Value: 0 14 | Char Value: b 15 | Integer Value: 30 16 | Long Value: 40 17 | Float Value: 50 18 | Double Value: 60 19 | AddGlobalVarClassInstanceTest 20 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/GlobalVars/IntrinsicTestCase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SimpleTestCaseWithIntrinsic.cpp 3 | * 4 | * Created on: Jun 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | // Both of these variables will be marked as 'static' as both have the 11 | // same storage type wrt compiling, the static keyword should 12 | // just restrict the scope of the integer to this translation unit. 13 | 14 | 15 | namespace TestNamespace 16 | { 17 | static int globalInt; 18 | 19 | double globalDoubleWithoutStaticKeyword; 20 | } 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/GlobalVars/NonIntrinsicTestCase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NonIntrisicTestCase.cpp 3 | * 4 | * Created on: Jun 16, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | // Without the symbol defined below, this example will not compile with gcc 4.8.0 10 | // I expect that might change in the future. 11 | 12 | 13 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 14 | 15 | #include 16 | 17 | 18 | namespace TestNamespace 19 | { 20 | static std::string globalString; 21 | 22 | std::string globalStringWithoutStaticKeyword; 23 | } 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/Functions/SimpleFunctionTestCase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SimpleTestCaseWithIntrinsic.cpp 3 | * 4 | * Created on: Jun 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 11 | 12 | #include 13 | #include 14 | 15 | 16 | namespace TestNamespace 17 | { 18 | void FunctionReturningVoid() 19 | {}; 20 | 21 | int FunctionReturningInt() 22 | { 23 | return( 5 ); 24 | }; 25 | 26 | std::string FunctionReturningString() 27 | { 28 | return( "ReturnedString" ); 29 | }; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/test/ClassTests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GlobalVarTests.cpp 3 | * 4 | * Created on: Jun 9, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | namespace 11 | { 12 | TEST(TestClasses, BasicTests) 13 | { 14 | ForkGCCTestCase( "", "Classes", "SimpleClassTestCase", "namespaces=TestNamespace::", "list-all-namespaces" ); 15 | 16 | ForkGCCTestCase( "", 17 | "Classes", 18 | "WriteToFieldByOffsetTestCase", 19 | "namespaces=TestCreatedNamespace::", 20 | "test-extension=libTestExtensions.so:WriteToFieldByOffsetTest" ); 21 | 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/test/FunctionTests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GlobalVarTests.cpp 3 | * 4 | * Created on: Jun 9, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | 11 | 12 | namespace 13 | { 14 | TEST(TestFunctions, BasicTests) 15 | { 16 | ForkGCCTestCase( "-c", "Functions", "SimpleFunctionTestCase", "namespaces=TestNamespace::", "list-all-namespaces" ); 17 | ForkGCCTestCase( "-c", "Functions", "FunctionsWithParametersTestCase", "namespaces=TestNamespace::", "list-all-namespaces" ); 18 | ForkGCCTestCase( "-c", "Functions", "FunctionPrototypeTestCase", "namespaces=TestNamespace::", "list-all-namespaces" ); 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /GCCPlugin/HelloWorld.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | 5 | 6 | 7 | namespace TestNamespace 8 | { 9 | class TestClass 10 | { 11 | public : 12 | 13 | int publicInt; 14 | 15 | int getPublicInt() const 16 | { 17 | return( publicInt ); 18 | } 19 | 20 | protected : 21 | 22 | double getPrivateDouble() const 23 | { 24 | return( privateDouble ); 25 | } 26 | 27 | 28 | private : 29 | 30 | double privateDouble; 31 | }; 32 | 33 | 34 | char* globalString = "This is a global string"; 35 | 36 | TestClass globalTestClassInstance; 37 | } 38 | 39 | 40 | 41 | int main() 42 | { 43 | std::cout << "!!!Hello World!!!" << std::endl; // prints !!!Hello World!!! 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/test/NamespaceTests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NamespaceTests.cpp 3 | * 4 | * Created on: Jul 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | 11 | 12 | namespace 13 | { 14 | TEST(TestNamespaces, BasicTests) 15 | { 16 | ForkGCCTestCase( "-c", 17 | "Namespaces", 18 | "NamespaceBasicTestCase", 19 | "namespaces=SimpleNamespace::,NestedNamespaceBase::", 20 | "list-all-namespaces" ); 21 | 22 | ForkGCCTestCase( "-c", 23 | "Namespaces", 24 | "CreateNamespaceTest", 25 | "namespaces=NestedNamespaceBase::", 26 | "test-extension=libTestExtensions.so:AddNamespaceTest", 27 | "list-all-namespaces" ); 28 | } 29 | } 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/GlobalVars/LocallyUserDefinedClassTestCase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NonIntrisicTestCase.cpp 3 | * 4 | * Created on: Jun 16, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | namespace LocalNamespace 10 | { 11 | class LocalClass 12 | { 13 | public : 14 | 15 | LocalClass() 16 | : m_integerDataMember( 1 ) 17 | {}; 18 | 19 | ~LocalClass() 20 | {}; 21 | 22 | 23 | int integerDataMember() const 24 | { 25 | return( m_integerDataMember ); 26 | } 27 | 28 | 29 | private : 30 | 31 | int m_integerDataMember; 32 | }; 33 | }; 34 | 35 | 36 | namespace TestNamespace 37 | { 38 | static LocalNamespace::LocalClass globalClass; 39 | 40 | LocalNamespace::LocalClass globalClassWithoutStaticKeyword; 41 | } 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/Functions/FunctionsWithParametersTestCase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * SimpleTestCaseWithIntrinsic.cpp 3 | * 4 | * Created on: Jun 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 11 | 12 | #include 13 | #include 14 | 15 | 16 | namespace TestNamespace 17 | { 18 | void FunctionReturningVoid( int intParameter ) 19 | {}; 20 | 21 | int FunctionReturningInt( int intParameter, 22 | float floatParameter ) 23 | { 24 | return( intParameter + floatParameter + 5 ); 25 | }; 26 | 27 | std::string FunctionReturningString( std::string stringParameter, 28 | double doubleParameter, 29 | long longParameter ) 30 | { 31 | return( "ReturnedString" ); 32 | }; 33 | } 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/Namespaces/NamespaceBasicTestCase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NamespaceBasicTestCase.cpp 3 | * 4 | * Created on: Jul 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | // Without the symbol defined below, this example will not compile with gcc 4.8.0 9 | // I expect that might change in the future. 10 | 11 | 12 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 13 | 14 | 15 | #include 16 | 17 | 18 | 19 | namespace SimpleNamespace 20 | { 21 | } 22 | 23 | 24 | 25 | namespace NestedNamespaceBase 26 | { 27 | namespace FirstNestedNamespace 28 | { 29 | namespace SecondNestedNamespace 30 | { 31 | namespace ThirdNestedNamespace 32 | { 33 | namespace FourthNestedNamespace 34 | { 35 | } 36 | 37 | namespace FourthNestedNamespacePeer 38 | { 39 | } 40 | } 41 | } 42 | 43 | namespace SecondNestedNamespacePeer 44 | { 45 | } 46 | } 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /GCCPlugin/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /GCCInternalsTools/.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /CPPLanguageModel/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | CPPLanguageModel 4 | 5 | 6 | Utility 7 | 8 | 9 | 10 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 11 | clean,full,incremental, 12 | 13 | 14 | 15 | 16 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 17 | full,incremental, 18 | 19 | 20 | 21 | 22 | 23 | org.eclipse.cdt.core.cnature 24 | org.eclipse.cdt.core.ccnature 25 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 26 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 27 | 28 | 29 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/ParameterValues.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ParameterValues.cpp 3 | * 4 | * Created on: Feb 26, 2014 5 | * Author: steve 6 | */ 7 | 8 | 9 | #include "ParameterValues.h" 10 | 11 | 12 | namespace CPPModel 13 | { 14 | 15 | const ParameterType BOOLEAN_PARAM = { TypeSpecifier::BOOLEAN }; 16 | const ParameterType CHAR_PARAM = { TypeSpecifier::CHAR }; 17 | const ParameterType STRING_PARAM = { TypeSpecifier::STRING }; 18 | const ParameterType INT_PARAM = { TypeSpecifier::INT }; 19 | const ParameterType LONG_PARAM = { TypeSpecifier::LONG_INT }; 20 | const ParameterType FLOAT_PARAM = { TypeSpecifier::FLOAT }; 21 | const ParameterType DOUBLE_PARAM = { TypeSpecifier::DOUBLE }; 22 | const ParameterType CLASS_PARAM = { TypeSpecifier::CLASS }; 23 | const ParameterType FUNCTION_PARAM = { TypeSpecifier::FUNCTION }; 24 | 25 | 26 | TypeSpecifier AsTypeSpecifier( const ParameterType& paramType ) 27 | { 28 | return( paramType.at( 0 )); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /GCCInternalsUTFixture/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | GCCInternalsUTFixture 4 | 5 | 6 | CPPLanguageModel 7 | GCCInternalsTools 8 | 9 | 10 | 11 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 12 | clean,full,incremental, 13 | 14 | 15 | 16 | 17 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 18 | full,incremental, 19 | 20 | 21 | 22 | 23 | 24 | org.eclipse.cdt.core.cnature 25 | org.eclipse.cdt.core.ccnature 26 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 27 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 28 | 29 | 30 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/GlobalVars/AddFundamentalValueGlobalVarTest.out: -------------------------------------------------------------------------------- 1 | AddFundamentalValueGlobalVarTest 2 | 3 | Value of testBoolVar: 1 Should be: 1 4 | Value of testCharVar: a Should be: 'a' 5 | Value of testStringVar: Test String Should be: 'Test String' 6 | Value of testIntVar: 2147483647 Should be: 2147483647 7 | Value of testLongVar: 9223372036854775807 Should be: 9223372036854775807 8 | Value of testFloatVar: 3.40282e+38 Should be: 3.40282e+38 9 | Value of testDoubleVar: 1.79769e+308 Should be: 1.79769e+308 10 | 11 | Value pointed to by testBoolPointerVar: 1 12 | Value pointed to by testCharPointerVar: a 13 | Value pointed to by testStringPointerVar: Test String 14 | Value pointed to by testIntPointerVar: 2147483647 15 | Value pointed to by testLongPointerVar: 9223372036854775807 16 | Value pointed to by testFloatPointerVar: 3.40282e+38 17 | Value pointed to by testDoublePointerVar: 1.79769e+308 18 | -------------------------------------------------------------------------------- /TestExtensions/TestExtensions/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestExtensions 4 | 5 | 6 | CPPLanguageModel 7 | GCCInternalsTools 8 | 9 | 10 | 11 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 12 | clean,full,incremental, 13 | 14 | 15 | 16 | 17 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 18 | full,incremental, 19 | 20 | 21 | 22 | 23 | 24 | org.eclipse.cdt.core.cnature 25 | org.eclipse.cdt.core.ccnature 26 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 27 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 28 | 29 | 30 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NonIntrisicTestCase.cpp 3 | * 4 | * Created on: Jun 16, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | namespace LocalNamespace 11 | { 12 | class LocalClass 13 | { 14 | public : 15 | 16 | LocalClass() 17 | : m_integerDataMember( 1 ) 18 | {}; 19 | 20 | ~LocalClass() 21 | {}; 22 | 23 | 24 | int integerDataMember() const 25 | { 26 | return( m_integerDataMember ); 27 | } 28 | 29 | 30 | private : 31 | 32 | int m_integerDataMember; 33 | }; 34 | }; 35 | 36 | 37 | namespace TestNamespace 38 | { 39 | static LocalNamespace::LocalClass* ptrGlobalClass; 40 | 41 | LocalNamespace::LocalClass* ptrGlobalClassWithoutStaticKeyword; 42 | 43 | static long* ptrGlobalLong; 44 | 45 | long* ptrGlobalLongWithoutStaticKeyword; 46 | 47 | static float** hdlGlobalFloat; 48 | 49 | float** hdlGlobalFloatWithoutStaticKeyword; 50 | 51 | static int globalInt = 5; 52 | int& refGlobalInt = globalInt; 53 | } 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/AttributeParser.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef ATTRIBUTES_H_ 15 | #define ATTRIBUTES_H_ 16 | 17 | 18 | #include "TreeList.h" 19 | 20 | 21 | namespace GCCInternalsTools 22 | { 23 | // Forward Declarations for this namespace 24 | 25 | class IdentifierTree; 26 | 27 | 28 | std::unique_ptr GetAttribute( const IdentifierTree& identifier, 29 | const PurposeValueList& arguments ); 30 | 31 | CPPModel::ConstListPtr GetAttributes( const PurposeValueList& treeList ); 32 | 33 | } 34 | 35 | 36 | 37 | #endif /* ATTRIBUTES_H_ */ 38 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | GCCInternalsUnitTest 4 | 5 | 6 | CPPLanguageModel 7 | GCCInternalsTools 8 | GCCInternalsUTFixture 9 | TestExtensions 10 | Utility 11 | 12 | 13 | 14 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 15 | clean,full,incremental, 16 | 17 | 18 | 19 | 20 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 21 | full,incremental, 22 | 23 | 24 | 25 | 26 | 27 | org.eclipse.cdt.core.cnature 28 | org.eclipse.cdt.core.ccnature 29 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 31 | 32 | 33 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/Classes/WriteToFieldByOffsetTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | :: 5 | 6 | 7 | TestNamespace:: 8 | 9 | 10 | __cxxabiv1:: 11 | 12 | 13 | 14 | 15 | 16 | __gnu_cxx:: 17 | 18 | 19 | __gnu_debug:: 20 | 21 | 22 | std:: 23 | 24 | 25 | 26 | 27 | 28 | std::__debug:: 29 | 30 | 31 | std::__exception_ptr:: 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/ListAliases.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef LISTALIASES_H_ 15 | #define LISTALIASES_H_ 16 | 17 | 18 | #include 19 | #include 20 | 21 | 22 | namespace CPPModel 23 | { 24 | template using ListPtr = std::unique_ptr>; 25 | template using ConstListPtr = std::unique_ptr>; 26 | 27 | template using ListRef = const boost::ptr_list&; 28 | 29 | template ConstListPtr MakeConst( ListPtr& nonConstList ) { return( ConstListPtr( std::move( nonConstList ) ) ); } 30 | } 31 | 32 | #endif /* LISTALIASES_H_ */ 33 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Static.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | #ifndef STATIC_H_ 13 | #define STATIC_H_ 14 | 15 | 16 | 17 | #include "Serialization.h" 18 | 19 | 20 | 21 | namespace CPPModel 22 | { 23 | class Static : public IXMLSerializable 24 | { 25 | public : 26 | 27 | Static() = delete; 28 | Static( Static& ) = delete; 29 | Static( const Static& ) = delete; 30 | 31 | Static( bool isStatic ) 32 | : m_isStatic( isStatic ) 33 | {} 34 | 35 | 36 | 37 | 38 | bool isStatic() const 39 | { 40 | return( m_isStatic ); 41 | } 42 | 43 | 44 | std::ostream& toXML( std::ostream& outputStream, 45 | SerializationOptions options ) const; 46 | 47 | 48 | private : 49 | 50 | const bool m_isStatic; 51 | }; 52 | } 53 | 54 | 55 | 56 | #endif /* STATIC_H_ */ 57 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/src/HelperFunctions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * HelperFunctions.h 3 | * 4 | * Created on: Jun 13, 2013 5 | * Author: steve 6 | */ 7 | 8 | #ifndef HELPERFUNCTIONS_H_ 9 | #define HELPERFUNCTIONS_H_ 10 | 11 | 12 | void ForkGCCTestCase( const char* gccOptions, 13 | const char* testDirectoryName, 14 | const char* testCaseName ); 15 | 16 | void ForkGCCTestCase( const char* gccOptions, 17 | const char* testDirectoryName, 18 | const char* testCaseName, 19 | const char* option1 ); 20 | 21 | void ForkGCCTestCase( const char* gccOptions, 22 | const char* testDirectoryName, 23 | const char* testCaseName, 24 | const char* option1, 25 | const char* option2 ); 26 | 27 | void ForkGCCTestCase( const char* gccOptions, 28 | const char* testDirectoryName, 29 | const char* testCaseName, 30 | const char* option1, 31 | const char* option2, 32 | const char* option3 ); 33 | 34 | void ForkGCCTestCase( const char* gccOptions, 35 | const char* testDirectoryName, 36 | const char* testCaseName, 37 | const char* option1, 38 | const char* option2, 39 | const char* option3, 40 | const char* option4 ); 41 | 42 | #endif /* HELPERFUNCTIONS_H_ */ 43 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/Unions/SimpleUnionTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | :: 5 | 6 | 7 | TestNamespace:: 8 | 9 | 10 | __cxxabiv1:: 11 | 12 | 13 | 14 | 15 | 16 | __gnu_cxx:: 17 | 18 | 19 | __gnu_debug:: 20 | 21 | 22 | std:: 23 | 24 | 25 | 26 | 27 | 28 | std::__debug:: 29 | 30 | 31 | std::__exception_ptr:: 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/Classes/SimpleClassTestCase.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 4 | 5 | 6 | 7 | namespace TestNamespace 8 | { 9 | class SimpleClassWithOnlyDataMembers 10 | { 11 | public : 12 | 13 | bool m_booleanValue; 14 | char m_charValue; 15 | char* m_stringValue; 16 | int m_intValue; 17 | long m_longValue; 18 | float m_floatValue; 19 | double m_doubleValue; 20 | 21 | }; 22 | 23 | 24 | static SimpleClassWithOnlyDataMembers g_testInstance; 25 | 26 | 27 | 28 | class SimpleClassWithOnlyMethods 29 | { 30 | public : 31 | 32 | SimpleClassWithOnlyMethods() 33 | {} 34 | 35 | 36 | bool returnBool() 37 | { 38 | return( true ); 39 | } 40 | 41 | char returnChar() 42 | { 43 | return( 'a' ); 44 | } 45 | 46 | char* returnCharPointer() 47 | { 48 | return( "Test String" ); 49 | } 50 | 51 | int returnInt() 52 | { 53 | return( 1 ); 54 | } 55 | 56 | long returnLong() 57 | { 58 | return( 2L ); 59 | } 60 | 61 | float returnFloat() 62 | { 63 | return( 1.0 ); 64 | } 65 | 66 | double returnDouble() 67 | { 68 | return( 2.0 ); 69 | } 70 | 71 | }; 72 | 73 | } 74 | 75 | 76 | 77 | 78 | int main() 79 | { 80 | TestNamespace::g_testInstance.m_booleanValue = true; 81 | } 82 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/NamedEntity.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef NAMEDENTITY_H_ 15 | #define NAMEDENTITY_H_ 16 | 17 | 18 | #include "Serialization.h" 19 | 20 | 21 | namespace CPPModel 22 | { 23 | 24 | class NamedEntity : public IXMLSerializable 25 | { 26 | public : 27 | 28 | NamedEntity() = delete; 29 | NamedEntity( NamedEntity& ) = delete; 30 | NamedEntity( const NamedEntity& ) = delete; 31 | 32 | NamedEntity( const std::string& name ) 33 | : m_name( name ) 34 | {} 35 | 36 | virtual ~NamedEntity() 37 | {} 38 | 39 | 40 | const std::string& name() const 41 | { 42 | return( m_name ); 43 | } 44 | 45 | 46 | std::ostream& toXML( std::ostream& outputStream, 47 | SerializationOptions options ) const; 48 | 49 | private : 50 | 51 | const std::string m_name; 52 | }; 53 | 54 | } 55 | 56 | #endif /* NAMEDENTITY_H_ */ 57 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/DeclOrTypeBaseTree.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | 15 | #include "ASTDictionary.h" 16 | 17 | #include "config.h" 18 | #include "gcc-plugin.h" 19 | #include "tree.h" 20 | #include "cp/cp-tree.h" 21 | 22 | #include "DeclOrTypeBaseTree.h" 23 | 24 | #include "TypeTree.h" 25 | #include "DeclTree.h" 26 | 27 | 28 | 29 | 30 | namespace GCCInternalsTools 31 | { 32 | 33 | 34 | std::unique_ptr DeclOrTypeBaseTree::convert( const tree& treeToConvert ) 35 | { 36 | if( DECL_P( treeToConvert ) ) 37 | { 38 | return( std::unique_ptr( new DeclTree( treeToConvert ) )); 39 | } 40 | else if( TYPE_P( treeToConvert ) ) 41 | { 42 | return( std::unique_ptr( new TypeTree( treeToConvert ) )); 43 | } 44 | 45 | assert( "Request to convert unknown tree to a descendant of TreeBase" ); 46 | 47 | return( NULL ); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Access.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | 15 | #ifndef ACCESS_H_ 16 | #define ACCESS_H_ 17 | 18 | 19 | #include "Serialization.h" 20 | 21 | 22 | 23 | namespace CPPModel 24 | { 25 | 26 | enum class AccessSpecifier 27 | { 28 | PUBLIC, 29 | PROTECTED, 30 | PRIVATE 31 | }; 32 | 33 | 34 | 35 | const char* toString( AccessSpecifier accessSpec ); 36 | 37 | 38 | 39 | class Access : public IXMLSerializable 40 | { 41 | public : 42 | 43 | Access( AccessSpecifier accessSpec ) 44 | : m_accessSpec( accessSpec ) 45 | {} 46 | 47 | 48 | AccessSpecifier accessSpecifier() const 49 | { 50 | return( m_accessSpec ); 51 | } 52 | 53 | 54 | std::ostream& toXML( std::ostream& outputStream, 55 | SerializationOptions options ) const; 56 | 57 | 58 | private : 59 | 60 | const AccessSpecifier m_accessSpec; 61 | }; 62 | 63 | } 64 | 65 | 66 | 67 | #endif /* ACCESS_H_ */ 68 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/Namespaces/CreateNamespaceTest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | :: 5 | 6 | 7 | TestCreatedNamespace:: 8 | 9 | 10 | TestCreatedNamespace::NestedNamespace:: 11 | 12 | 13 | TestCreatedNamespace::NestedNamespace::SecondNestedNamespace:: 14 | 15 | 16 | __cxxabiv1:: 17 | 18 | 19 | 20 | 21 | 22 | __gnu_cxx:: 23 | 24 | 25 | __gnu_debug:: 26 | 27 | 28 | std:: 29 | 30 | 31 | 32 | 33 | 34 | std::__debug:: 35 | 36 | 37 | std::__exception_ptr:: 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/MiscCode.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MiscCode.cpp 3 | * 4 | * Created on: Aug 23, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | #include "Access.h" 10 | #include "ConstantValue.h" 11 | 12 | 13 | #include 14 | 15 | 16 | 17 | namespace CPPModel 18 | { 19 | 20 | const char* toString( AccessSpecifier accessSpec ) 21 | { 22 | switch( accessSpec ) 23 | { 24 | case AccessSpecifier::PUBLIC : 25 | return( "PUBLIC" ); 26 | break; 27 | 28 | case AccessSpecifier::PROTECTED : 29 | return( "PROTECTED" ); 30 | break; 31 | 32 | case AccessSpecifier::PRIVATE : 33 | return( "PRIVATE" ); 34 | break; 35 | } 36 | 37 | return( "PRIVATE" ); 38 | } 39 | 40 | 41 | ConstantValue* ConstantValue::Copy( const ConstantValue& valueToCopy ) 42 | { 43 | switch( valueToCopy.kind() ) 44 | { 45 | case Kind::STRING : 46 | return( new StringConstant( ((const StringConstant&)valueToCopy).value() ) ); 47 | break; 48 | 49 | case Kind::INTEGER : 50 | return( new IntegerConstant( ((const IntegerConstant&)valueToCopy).value() ) ); 51 | break; 52 | 53 | case Kind::REAL : 54 | return( new RealConstant( ((const RealConstant&)valueToCopy).value() ) ); 55 | break; 56 | 57 | case Kind::UNRECOGNIZED : 58 | return( new UnrecognizedConstant() ); 59 | break; 60 | } 61 | 62 | return( new UnrecognizedConstant() ); 63 | 64 | } 65 | 66 | } 67 | 68 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Serialization.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | #ifndef SERIALIZATION_H_ 13 | #define SERIALIZATION_H_ 14 | 15 | 16 | #include 17 | #include 18 | 19 | 20 | 21 | 22 | namespace CPPModel 23 | { 24 | 25 | enum class SerializationOptions : std::int64_t 26 | { NONE = 0, 27 | NO_ATTRIBUTES = 1, 28 | NO_BUILT_INS = 2, 29 | NO_ARTIFICIALS = 4 30 | }; 31 | 32 | 33 | 34 | 35 | bool MatchOptions( SerializationOptions firstOption, 36 | SerializationOptions secondOption ); 37 | 38 | SerializationOptions AddOption( SerializationOptions option, 39 | SerializationOptions optionToAdd ); 40 | 41 | 42 | 43 | 44 | class IXMLSerializable 45 | { 46 | public : 47 | 48 | virtual ~IXMLSerializable() 49 | {} 50 | 51 | virtual std::ostream& toXML( std::ostream& outputStream, 52 | SerializationOptions options ) const = 0; 53 | }; 54 | 55 | } // namespace CPPModel 56 | 57 | #endif /* SERIALIZATION_H_ */ 58 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/test/GlobalVarTests.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * GlobalVarTests.cpp 3 | * 4 | * Created on: Jun 9, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | 11 | namespace 12 | { 13 | TEST(TestGlobalVariables, BasicTests) 14 | { 15 | ForkGCCTestCase( "-c", "GlobalVars", "IntrinsicTestCase", "namespaces=TestNamespace::" ); 16 | ForkGCCTestCase( "-c", "GlobalVars", "NonIntrinsicTestCase", "namespaces=TestNamespace::" ); 17 | ForkGCCTestCase( "-c", "GlobalVars", "LocallyUserDefinedClassTestCase", "namespaces=LocalNamespace::,TestNamespace::" ); 18 | ForkGCCTestCase( "-c", "GlobalVars", "DerivedTypesTestCase", "namespaces=TestNamespace::" ); 19 | ForkGCCTestCase( "-c", "GlobalVars", "AttributesTestCase", "namespaces=TestNamespace::" ); 20 | 21 | ForkGCCTestCase( "", 22 | "GlobalVars", 23 | "AddFundamentalValueGlobalVarTest", 24 | "namespaces=TestCreatedNamespace::,LocalTestNamespace::", 25 | "test-extension=libTestExtensions.so:AddFundamentalValueGlobalVarTest" ); 26 | 27 | ForkGCCTestCase( "", 28 | "GlobalVars", 29 | "AddFundamentalArrayValueGlobalVarTest", 30 | "namespaces=TestCreatedNamespace::,LocalTestNamespace::", 31 | "test-extension=libTestExtensions.so:AddFundamentalArrayValueGlobalVarTest" ); 32 | 33 | ForkGCCTestCase( "", 34 | "GlobalVars", 35 | "AddGlobalVarClassInstanceTest", 36 | "namespaces=TestCreatedNamespace::,LocalTestNamespace::", 37 | "test-extension=libTestExtensions.so:AddGlobalVarClassInstanceTest" ); 38 | 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/PluginManagerImpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PassManager.h 3 | * 4 | * Created on: May 31, 2014 5 | * Author: steve 6 | */ 7 | 8 | #ifndef PLUGINMANAGERIMPL_H_ 9 | #define PLUGINMANAGERIMPL_H_ 10 | 11 | 12 | 13 | #include "PluginManager.h" 14 | 15 | #include "GCCInternalsTools.h" 16 | #include "DeclOrTypeBaseTree.h" 17 | 18 | #include "plugin.h" 19 | #include "tree-pass.h" 20 | 21 | 22 | 23 | namespace GCCInternalsTools 24 | { 25 | 26 | class PluginManagerImpl : public CPPModel::PluginManager 27 | { 28 | public: 29 | 30 | PluginManagerImpl(); 31 | 32 | virtual ~PluginManagerImpl(); 33 | 34 | 35 | 36 | bool dictionaryBuilt() const 37 | { 38 | return( m_ASTBuilt ); 39 | } 40 | 41 | CPPModel::ASTDictionary& GetASTDictionary() 42 | { 43 | return( m_ASTDictionary ); 44 | } 45 | 46 | 47 | void Initialize( const char* pluginName, 48 | CPPModel::CallbackIfx* callbacks ); 49 | 50 | void RegisterAttributes( void ); 51 | 52 | bool BuildASTGate( void ); 53 | unsigned int BuildASTCallback( void ); 54 | 55 | unsigned int GlobalDeclarationCallback( void ); 56 | 57 | 58 | private : 59 | 60 | std::string m_pluginName; 61 | 62 | ASTDictionaryImpl m_ASTDictionary; 63 | 64 | bool m_ASTBuilt; 65 | 66 | bool m_globalsGenerated; 67 | 68 | CPPModel::CallbackIfx* m_userCallbacks; 69 | 70 | 71 | void RegisterCallbacks( const char* pluginName ); 72 | }; 73 | 74 | } /* namespace GCCInternalsTools */ 75 | 76 | #endif /* PLUGINMANAGERIMPL_H_ */ 77 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/ASTEntry.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef ASTENTRY_H_ 15 | #define ASTENTRY_H_ 16 | 17 | 18 | #include "Serialization.h" 19 | #include "UID.h" 20 | #include "SourceLocation.h" 21 | 22 | 23 | 24 | namespace CPPModel 25 | { 26 | 27 | /* 28 | class ASTEntry : public SourceLocation 29 | { 30 | public : 31 | 32 | ASTEntry() = delete; 33 | ASTEntry( ASTEntry& ) = delete; 34 | 35 | ASTEntry( const UID& uid, 36 | const SourceLocation& sourceLocation ) 37 | : SourceLocation( sourceLocation ), 38 | m_uid( uid ) 39 | {} 40 | 41 | ASTEntry( const ASTEntry& elementToCopy ) 42 | : SourceLocation( elementToCopy.sourceLocation() ), 43 | m_uid( elementToCopy.m_uid ) 44 | {} 45 | 46 | 47 | virtual ~ASTEntry() {}; 48 | 49 | 50 | const UID& uid() const 51 | { 52 | return( m_uid ); 53 | } 54 | 55 | 56 | std::ostream& toXML( std::ostream& outputStream, 57 | int indentLevel, 58 | SerializationOptions options ) const; 59 | 60 | private : 61 | 62 | const UID m_uid; 63 | }; 64 | */ 65 | } 66 | 67 | 68 | #endif /* ASTENTRY_H_ */ 69 | -------------------------------------------------------------------------------- /GCCPlugin/src/gccplugin.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | 15 | #include "config.h" 16 | 17 | #include "ASTDictionary.h" 18 | #include "PluginManager.h" 19 | 20 | #include "gcc-plugin.h" 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | int plugin_is_GPL_compatible; 29 | 30 | 31 | 32 | 33 | 34 | class Callbacks : public CPPModel::CallbackIfx 35 | { 36 | public : 37 | 38 | Callbacks() 39 | {} 40 | 41 | virtual ~Callbacks() 42 | {} 43 | 44 | 45 | void ASTReady() 46 | { 47 | std::list namespacesToDump( { "TestNamespace::" } ); 48 | 49 | CPPModel::GetPluginManager().GetASTDictionary().DumpASTXMLByNamespaces( std::cerr, namespacesToDump ); 50 | }; 51 | 52 | void CreateNamespaces() 53 | { 54 | }; 55 | 56 | void InjectCode() 57 | { 58 | }; 59 | 60 | }; 61 | 62 | 63 | 64 | Callbacks g_pluginCallbacks; 65 | 66 | 67 | 68 | 69 | 70 | int plugin_init( plugin_name_args* info, 71 | plugin_gcc_version* ver ) 72 | { 73 | std::cerr << "Starting Plugin: "<< info->base_name << std::endl; 74 | 75 | CPPModel::GetPluginManager().Initialize( "HelloWorld Plugin", &g_pluginCallbacks ); 76 | 77 | return( 0 ); 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /TestExtensions/TestExtensions/src/NamespaceTestExtension.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #include "ASTDictionary.h" 15 | 16 | 17 | 18 | extern "C" 19 | { 20 | bool AddNamespaceTest( int callbackType, 21 | CPPModel::ASTDictionary* astDictionary ); 22 | } 23 | 24 | 25 | 26 | bool AddNamespaceTest( int callbackType, 27 | CPPModel::ASTDictionary* astDictionary ) 28 | { 29 | std::cerr << "In Extension" << std::endl; 30 | 31 | // This first call should succeed and create a total of 3 namespaces 32 | 33 | if( callbackType == 2 ) 34 | { 35 | CPPModel::CreateNamespaceResult cnResult = astDictionary->CreateNamespace( "TestCreatedNamespace::NestedNamespace::SecondNestedNamespace::" ); 36 | 37 | if( !cnResult.Succeeded() ) 38 | { 39 | return( false ); 40 | } 41 | 42 | // This call should fail as the namespace has already been created 43 | 44 | CPPModel::CreateNamespaceResult cnResult2 = astDictionary->CreateNamespace( "TestCreatedNamespace::" ); 45 | 46 | if( cnResult2.errorCode() != CPPModel::CreateNamespaceResultCodes::NAMESPACE_ALREADY_EXISTS ) 47 | { 48 | return( false ); 49 | } 50 | } 51 | 52 | return( true ); 53 | }; 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Result.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Result.h 3 | * 4 | * Created on: Jul 6, 2013 5 | * Author: steve 6 | */ 7 | 8 | #ifndef RESULT_H_ 9 | #define RESULT_H_ 10 | 11 | namespace CPPModel 12 | { 13 | enum class ResultCode 14 | { 15 | SUCCESS = 1, 16 | 17 | NAMESPACE_ALREADY_EXISTS = 100 18 | }; 19 | 20 | 21 | class Result 22 | { 23 | public: 24 | 25 | Result() = delete; 26 | 27 | Result( const Result& resultToCopy ) 28 | : m_resultCode( resultToCopy.m_resultCode ), 29 | m_message( resultToCopy.m_message ) 30 | {} 31 | 32 | ~Result() 33 | {}; 34 | 35 | 36 | Result& operator=( const Result& resultToCopy ) 37 | { 38 | m_resultCode = resultToCopy.m_resultCode; 39 | m_message = resultToCopy.m_message; 40 | 41 | return( *this ); 42 | } 43 | 44 | 45 | ResultCode code() const 46 | { 47 | return( m_resultCode ); 48 | } 49 | 50 | 51 | const std::string& message() const 52 | { 53 | return( m_message ); 54 | } 55 | 56 | const bool isSuccess() const 57 | { 58 | return( m_resultCode == ResultCode::SUCCESS ); 59 | } 60 | 61 | const bool isFailure() const 62 | { 63 | return( !isSuccess() ); 64 | } 65 | 66 | static Result Success() 67 | { 68 | return( Result( ResultCode::SUCCESS, "Success" ) ); 69 | } 70 | 71 | static Result Failed( ResultCode failureCode, 72 | const char* message ) 73 | { 74 | return( Result( failureCode, message ) ); 75 | } 76 | 77 | private : 78 | 79 | 80 | Result( ResultCode resultCode, 81 | const char* message ) 82 | : m_resultCode( resultCode ), 83 | m_message( message ) 84 | {} 85 | 86 | 87 | ResultCode m_resultCode; 88 | std::string m_message; 89 | }; 90 | 91 | } /* namespace CPPModel */ 92 | #endif /* RESULT_H_ */ 93 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/SourceElement.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef SOURCEELEMENT_H_ 15 | #define SOURCEELEMENT_H_ 16 | 17 | 18 | #include "UID.h" 19 | #include "SourceLocation.h" 20 | #include "NamedEntity.h" 21 | 22 | 23 | namespace CPPModel 24 | { 25 | 26 | 27 | class SourceElement : public NamedEntity, public UID, public SourceLocation 28 | { 29 | public : 30 | 31 | SourceElement() = delete; 32 | SourceElement( SourceElement& ) = delete; 33 | 34 | SourceElement( const std::string& name, 35 | const UID& uid, 36 | const SourceLocation& sourceLocation ) 37 | : NamedEntity( name ), 38 | UID( uid ), 39 | SourceLocation( sourceLocation ) 40 | {} 41 | 42 | SourceElement( const SourceElement& elementToCopy ) 43 | : NamedEntity( elementToCopy.name() ), 44 | UID( elementToCopy.uid() ), 45 | SourceLocation( elementToCopy.fileName().c_str(), elementToCopy.lineNumber(), elementToCopy.characterCount(), elementToCopy.location() ) 46 | {} 47 | 48 | 49 | virtual ~SourceElement() {}; 50 | 51 | 52 | const SourceElement& sourceElement() const 53 | { 54 | return( *this ); 55 | } 56 | 57 | 58 | std::ostream& toXML( std::ostream& outputStream, 59 | SerializationOptions options ) const; 60 | }; 61 | 62 | } 63 | 64 | 65 | #endif /* SOURCEELEMENT_H_ */ 66 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/CompilerSpecific.h: -------------------------------------------------------------------------------- 1 | /* 2 | * CompilerSpecific.h 3 | * 4 | * Created on: Jul 13, 2013 5 | * Author: steve 6 | */ 7 | 8 | #ifndef COMPILERSPECIFIC_H_ 9 | #define COMPILERSPECIFIC_H_ 10 | 11 | 12 | #include "Serialization.h" 13 | 14 | 15 | 16 | namespace CPPModel 17 | { 18 | 19 | class CompilerSpecific : public IXMLSerializable 20 | { 21 | public: 22 | 23 | CompilerSpecific() = delete; 24 | 25 | CompilerSpecific( bool builtIn, 26 | bool artificial ) 27 | : m_builtIn( builtIn ), 28 | m_artificial( artificial ) 29 | {} 30 | 31 | CompilerSpecific( const CompilerSpecific& attributesToCopy ) 32 | : m_builtIn( attributesToCopy.m_builtIn ), 33 | m_artificial( attributesToCopy.m_artificial ) 34 | {} 35 | 36 | virtual ~CompilerSpecific() 37 | {} 38 | 39 | 40 | 41 | bool isBuiltIn() const 42 | { 43 | return( m_builtIn ); 44 | } 45 | 46 | bool isArtificial() const 47 | { 48 | return( m_artificial ); 49 | } 50 | 51 | 52 | SerializationOptions SerializationMask() const 53 | { 54 | std::int64_t mask; 55 | 56 | mask = ( isBuiltIn() ? (std::int64_t)SerializationOptions::NO_BUILT_INS : (std::int64_t)0 ) | 57 | ( isArtificial() ? (std::int64_t)SerializationOptions::NO_ARTIFICIALS : (std::int64_t)0 ); 58 | 59 | return( (SerializationOptions)mask ); 60 | } 61 | 62 | 63 | 64 | std::ostream& toXML( std::ostream& outputStream, 65 | SerializationOptions options ) const; 66 | 67 | 68 | 69 | private : 70 | 71 | bool m_builtIn; 72 | bool m_artificial; 73 | }; 74 | 75 | 76 | class ICompilerSpecific 77 | { 78 | public : 79 | 80 | virtual ~ICompilerSpecific () 81 | {}; 82 | 83 | virtual const CompilerSpecific& compilerSpecific() const = 0; 84 | }; 85 | 86 | } /* namespace CPPLanguageModel */ 87 | #endif /* COMPILERSPECIFIC_H_ */ 88 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/IdentifierTree.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | /* 13 | * IdentifierTree.h 14 | * 15 | * Created on: May 7, 2013 16 | * Author: steve 17 | */ 18 | 19 | #ifndef IDENTIFIERTREE_H_ 20 | #define IDENTIFIERTREE_H_ 21 | 22 | 23 | namespace GCCInternalsTools 24 | { 25 | 26 | class IdentifierTree 27 | { 28 | public : 29 | 30 | IdentifierTree( const tree& identifierTree ) 31 | : m_tree( identifierTree ) 32 | { 33 | assert( TREE_CODE( identifierTree ) == IDENTIFIER_NODE ); 34 | } 35 | 36 | 37 | IdentifierTree& operator= ( const tree& identifierTree ) 38 | { 39 | assert( TREE_CODE( identifierTree ) == IDENTIFIER_NODE ); 40 | 41 | (tree&)m_tree = identifierTree; 42 | 43 | return( *this ); 44 | } 45 | 46 | operator const tree&() const 47 | { 48 | return( m_tree ); 49 | } 50 | 51 | operator const char*() const 52 | { 53 | return( IDENTIFIER_POINTER( m_tree ) ); 54 | } 55 | 56 | CPPModel::AccessSpecifier AccessSpecifier() 57 | { 58 | // This is pretty straightforward. If there is no access specifier node, then we'll default to public. 59 | 60 | if( m_tree == 0 || m_tree == access_public_node ) 61 | { 62 | return( CPPModel::AccessSpecifier::PUBLIC ); 63 | } 64 | else if( m_tree == access_protected_node ) 65 | { 66 | return( CPPModel::AccessSpecifier::PROTECTED ); 67 | } 68 | 69 | return( CPPModel::AccessSpecifier::PRIVATE ); 70 | } 71 | 72 | private : 73 | 74 | const tree& m_tree; 75 | }; 76 | } 77 | 78 | 79 | 80 | #endif /* IDENTIFIERTREE_H_ */ 81 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/DeclOrTypeBaseTree.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef DECLORTYPEBASETREE_H_ 15 | #define DECLORTYPEBASETREE_H_ 16 | 17 | 18 | #include 19 | 20 | 21 | 22 | typedef union tree_node *tree; 23 | 24 | 25 | namespace CPPModel 26 | { 27 | enum class TypeSpecifier; 28 | class CompilerSpecific; 29 | class UID; 30 | class Type; 31 | class ASTDictionary; 32 | } 33 | 34 | 35 | namespace GCCInternalsTools 36 | { 37 | 38 | class NamespaceTree; 39 | 40 | 41 | class DeclOrTypeBaseTree 42 | { 43 | public : 44 | 45 | static std::unique_ptr convert( const tree& treeToConvert ); 46 | 47 | 48 | virtual ~DeclOrTypeBaseTree() 49 | {} 50 | 51 | 52 | operator const tree&() const 53 | { 54 | return( m_tree ); 55 | } 56 | 57 | bool isNull() const 58 | { 59 | return( m_tree == NULL ); 60 | } 61 | 62 | // 63 | // Virtual Methods 64 | // 65 | 66 | virtual const std::string identifier() const = 0; 67 | 68 | virtual const CPPModel::UID uid() const = 0; 69 | 70 | virtual const CPPModel::CompilerSpecific compilerSpecificFlags() const = 0; 71 | 72 | virtual const NamespaceTree fullyQualifiedNamespace() const = 0; 73 | 74 | virtual CPPModel::TypeSpecifier typeSpecifier() const = 0; 75 | 76 | virtual std::unique_ptr type( const CPPModel::ASTDictionary& dictionary ) const = 0; 77 | 78 | 79 | protected : 80 | 81 | DeclOrTypeBaseTree( const tree& unclassifiedTree ) 82 | : m_tree( unclassifiedTree ) 83 | {} 84 | 85 | const tree& m_tree; 86 | }; 87 | } 88 | 89 | 90 | #endif /* DECLORTYPEBASETREE_H_ */ 91 | 92 | 93 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/GlobalVars/NonIntrinsicTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestNamespace:: 4 | 5 | globalStringWithoutStaticKeyword 6 | 19336 7 | 8 | ../testCaseSourceCode/GlobalVars/NonIntrinsicTestCase.cpp 9 | 22 10 | 1 11 | 4843794 12 | 13 | true 14 | 15 | 16 | 17 | TestNamespace:: 18 | 19 | globalString 20 | 19335 21 | 22 | ../testCaseSourceCode/GlobalVars/NonIntrinsicTestCase.cpp 23 | 20 24 | 1 25 | 4843543 26 | 27 | true 28 | 29 | 30 | 31 | TestNamespace:: 32 | 33 | globalStringWithoutStaticKeyword 34 | 19336 35 | 36 | ../testCaseSourceCode/GlobalVars/NonIntrinsicTestCase.cpp 37 | 22 38 | 1 39 | 4843794 40 | 41 | true 42 | 43 | class-or-struct 44 | std::string 45 | 46 | 47 | 48 | 49 | TestNamespace:: 50 | 51 | globalString 52 | 19335 53 | 54 | ../testCaseSourceCode/GlobalVars/NonIntrinsicTestCase.cpp 55 | 20 56 | 1 57 | 4843543 58 | 59 | true 60 | 61 | class-or-struct 62 | std::string 63 | 64 | 65 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/TypeTree.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef TYPETREE_H_ 15 | #define TYPETREE_H_ 16 | 17 | 18 | #include "DeclOrTypeBaseTree.h" 19 | 20 | 21 | 22 | namespace GCCInternalsTools 23 | { 24 | 25 | class TypeTree : public DeclOrTypeBaseTree 26 | { 27 | public : 28 | 29 | TypeTree( const tree& typeTree ) 30 | : DeclOrTypeBaseTree( typeTree ) 31 | { 32 | assert( TYPE_P( typeTree ) ); 33 | } 34 | 35 | TypeTree& operator= ( const tree& typeTree ) 36 | { 37 | assert( TYPE_P( typeTree ) ); 38 | 39 | (tree&)m_tree = typeTree; 40 | 41 | return( *this ); 42 | } 43 | 44 | 45 | const std::string identifier() const 46 | { 47 | const tree& typeName = TYPE_IDENTIFIER( m_tree ); 48 | 49 | if( typeName == 0 ) 50 | { 51 | return( "[No Identifier]" ); 52 | } 53 | 54 | const char* identifier = IDENTIFIER_POINTER( typeName ); 55 | 56 | return( identifier ? std::string( identifier ) : std::string( "[No Identifier]" )); 57 | } 58 | 59 | const CPPModel::UID uid() const 60 | { 61 | return( CPPModel::UID( TYPE_UID( m_tree ), CPPModel::UID::UIDType::TYPE ) ); 62 | } 63 | 64 | const CPPModel::CompilerSpecific compilerSpecificFlags() const 65 | { 66 | return( CPPModel::CompilerSpecific( false, TYPE_ARTIFICIAL( m_tree ) ) ); 67 | } 68 | 69 | 70 | virtual const NamespaceTree fullyQualifiedNamespace() const; 71 | 72 | std::unique_ptr type( const CPPModel::ASTDictionary& dictionary ) const; 73 | 74 | CPPModel::TypeSpecifier typeSpecifier() const; 75 | 76 | CPPModel::ConstListPtr attributes(); 77 | }; 78 | } 79 | 80 | 81 | #endif /* TYPETREE_H_ */ 82 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/GlobalVars/AddGlobalVarClassInstanceTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NamespaceBasicTestCase.cpp 3 | * 4 | * Created on: Jul 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | // Without the symbol defined below, this example will not compile with gcc 4.8.0 10 | // I expect that might change in the future. 11 | 12 | 13 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 14 | 15 | #include 16 | 17 | 18 | 19 | namespace LocalTestNamespace 20 | { 21 | class CTestClass 22 | { 23 | public : 24 | 25 | CTestClass() 26 | { 27 | std::cout << "Test Class Initialized." << std::endl; 28 | } 29 | 30 | 31 | CTestClass( const char* message ) 32 | { 33 | std::cout << "Message: " << message << std::endl; 34 | } 35 | 36 | CTestClass( const char* message, 37 | bool booleanValue, 38 | char charValue, 39 | int integerValue, 40 | long longValue, 41 | float floatValue, 42 | double doubleValue ) 43 | { 44 | std::cout << "Message: " << message << std::endl; 45 | std::cout << "Boolean Value: " << booleanValue << std::endl; 46 | std::cout << "Char Value: " << charValue << std::endl; 47 | std::cout << "Integer Value: " << integerValue << std::endl; 48 | std::cout << "Long Value: " << longValue << std::endl; 49 | std::cout << "Float Value: " << floatValue << std::endl; 50 | std::cout << "Double Value: " << doubleValue << std::endl; 51 | } 52 | 53 | }; 54 | 55 | 56 | class CTestClassTakingPointer 57 | { 58 | public : 59 | 60 | CTestClassTakingPointer( int* intPointer ) 61 | { 62 | std::cout << "Int pointed to by argument: " << *intPointer << std::endl; 63 | } 64 | 65 | }; 66 | } 67 | 68 | 69 | 70 | LocalTestNamespace::CTestClass sourceCodeGlobalTestClass; 71 | LocalTestNamespace::CTestClass sourceCodeGlobalTestClassWithStringInit( "Source Code Message." ); 72 | LocalTestNamespace::CTestClass sourceCodeGlobalTestClassWithAllValues( "All Values Source Code Message.", true, 'a', 1, 2, 3.0, 4.0 ); 73 | 74 | 75 | 76 | 77 | int main() 78 | { 79 | std::cout << "AddGlobalVarClassInstanceTest" << std::endl; 80 | 81 | return( 1 ); 82 | } 83 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/GlobalVar.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | 15 | #ifndef GLOBALVAR_H_ 16 | #define GLOBALVAR_H_ 17 | 18 | 19 | #include "Static.h" 20 | #include "SourceElement.h" 21 | #include "Attribute.h" 22 | #include "Namespace.h" 23 | 24 | 25 | 26 | 27 | namespace CPPModel 28 | { 29 | 30 | 31 | 32 | class GlobalVarDefinition : public SourceElement, public NamespaceScoped, public Static, public IAttributes 33 | { 34 | public : 35 | 36 | GlobalVarDefinition() = delete; 37 | GlobalVarDefinition( GlobalVarDefinition& ) = delete; 38 | GlobalVarDefinition( const GlobalVarDefinition& ) = delete; 39 | 40 | GlobalVarDefinition( const std::string& name, 41 | const UID& uid, 42 | const Namespace& namespaceScope, 43 | const SourceLocation& sourceLocation, 44 | bool isStatic, 45 | const Attributes& attributes, 46 | std::unique_ptr varType ) 47 | : SourceElement( name, uid, sourceLocation ), 48 | NamespaceScoped( namespaceScope ), 49 | Static( isStatic ), 50 | m_attributes( std::move( attributes ) ), 51 | m_varType( std::move( varType ) ) 52 | {} 53 | 54 | virtual ~GlobalVarDefinition() {}; 55 | 56 | 57 | const Type& type() const 58 | { 59 | return( *m_varType ); 60 | } 61 | 62 | const Attributes& attributes() const 63 | { 64 | return( m_attributes ); 65 | } 66 | 67 | 68 | std::ostream& toXML( std::ostream& outputStream, 69 | SerializationOptions options ) const; 70 | 71 | private : 72 | 73 | const Attributes m_attributes; 74 | 75 | const std::unique_ptr m_varType; 76 | }; 77 | 78 | } 79 | 80 | 81 | 82 | #endif /* GLOBALVAR_H_ */ 83 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/ConstantTree.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef CONSTANTTREE_H_ 15 | #define CONSTANTTREE_H_ 16 | 17 | 18 | 19 | namespace GCCInternalsTools 20 | { 21 | 22 | class ConstantTree 23 | { 24 | public : 25 | 26 | ConstantTree( const tree& constantTree ) 27 | : m_tree( constantTree ) 28 | { 29 | assert( CONSTANT_CLASS_P( constantTree ) ); 30 | } 31 | 32 | 33 | const ConstantTree& operator= ( const tree& constantTree ) 34 | { 35 | assert( CONSTANT_CLASS_P( constantTree ) ); 36 | 37 | (tree&)m_tree = constantTree; 38 | 39 | return( *this ); 40 | } 41 | 42 | operator const tree&() const 43 | { 44 | return( m_tree ); 45 | } 46 | 47 | std::unique_ptr value() 48 | { 49 | if( TREE_CODE( m_tree ) == INTEGER_CST ) 50 | { 51 | // The following generates a warning regarding left shift count >= width of type. It works so I am leaving it. 52 | 53 | long fullValue = (( TREE_INT_CST_HIGH( m_tree ) << HOST_BITS_PER_WIDE_INT ) + TREE_INT_CST_LOW( m_tree ) ); 54 | 55 | return( std::unique_ptr( new CPPModel::IntegerConstant( fullValue ) )); 56 | } 57 | else if( TREE_CODE( m_tree ) == STRING_CST ) 58 | { 59 | const char* stringValue = TREE_STRING_POINTER( m_tree ); 60 | 61 | return( std::unique_ptr( new CPPModel::StringConstant( stringValue ? stringValue : "" ))); 62 | } 63 | else if( TREE_CODE( m_tree ) == REAL_CST ) 64 | { 65 | // TODO FIX REAL CONSTANT CONVERSION 66 | 67 | return( std::unique_ptr( new CPPModel::RealConstant( 0 ) )); 68 | } 69 | 70 | return( std::unique_ptr( new CPPModel::UnrecognizedConstant() )); 71 | } 72 | 73 | 74 | private : 75 | 76 | const tree& m_tree; 77 | }; 78 | 79 | } 80 | 81 | 82 | #endif /* CONSTANTTREE_H_ */ 83 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/GlobalVars/LocallyUserDefinedClassTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestNamespace:: 4 | 5 | globalClassWithoutStaticKeyword 6 | 2006 7 | 8 | ../testCaseSourceCode/GlobalVars/LocallyUserDefinedClassTestCase.cpp 9 | 40 10 | 1 11 | 13651 12 | 13 | true 14 | 15 | 16 | 17 | TestNamespace:: 18 | 19 | globalClass 20 | 1996 21 | 22 | ../testCaseSourceCode/GlobalVars/LocallyUserDefinedClassTestCase.cpp 23 | 38 24 | 1 25 | 13400 26 | 27 | true 28 | 29 | 30 | 31 | TestNamespace:: 32 | 33 | globalClassWithoutStaticKeyword 34 | 2006 35 | 36 | ../testCaseSourceCode/GlobalVars/LocallyUserDefinedClassTestCase.cpp 37 | 40 38 | 1 39 | 13651 40 | 41 | true 42 | 43 | class-or-struct 44 | LocalNamespace::LocalClass 45 | 46 | LocalNamespace:: 47 | 48 | 49 | 50 | 51 | 52 | TestNamespace:: 53 | 54 | globalClass 55 | 1996 56 | 57 | ../testCaseSourceCode/GlobalVars/LocallyUserDefinedClassTestCase.cpp 58 | 38 59 | 1 60 | 13400 61 | 62 | true 63 | 64 | class-or-struct 65 | LocalNamespace::LocalClass 66 | 67 | LocalNamespace:: 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/Namespaces/NamespaceBasicTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | :: 5 | 6 | 7 | NestedNamespaceBase:: 8 | 9 | 10 | NestedNamespaceBase::FirstNestedNamespace:: 11 | 12 | 13 | NestedNamespaceBase::FirstNestedNamespace::SecondNestedNamespace:: 14 | 15 | 16 | NestedNamespaceBase::FirstNestedNamespace::SecondNestedNamespace::ThirdNestedNamespace:: 17 | 18 | 19 | NestedNamespaceBase::FirstNestedNamespace::SecondNestedNamespace::ThirdNestedNamespace::FourthNestedNamespace:: 20 | 21 | 22 | NestedNamespaceBase::FirstNestedNamespace::SecondNestedNamespace::ThirdNestedNamespace::FourthNestedNamespacePeer:: 23 | 24 | 25 | NestedNamespaceBase::FirstNestedNamespace::SecondNestedNamespacePeer:: 26 | 27 | 28 | SimpleNamespace:: 29 | 30 | 31 | __cxxabiv1:: 32 | 33 | 34 | 35 | 36 | 37 | __gnu_cxx:: 38 | 39 | 40 | __gnu_debug:: 41 | 42 | 43 | std:: 44 | 45 | 46 | 47 | 48 | 49 | std::__debug:: 50 | 51 | 52 | std::__exception_ptr:: 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/NamespaceTree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FullyQualifiedNamespace.h 3 | * 4 | * Created on: Dec 14, 2013 5 | * Author: steve 6 | */ 7 | 8 | #ifndef NAMESPACETREE_H_ 9 | #define NAMESPACETREE_H_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include "Constants.h" 16 | 17 | //#include "config.h" 18 | //#include "gcc-plugin.h" 19 | //#include "tree.h" 20 | //#include "cp/cp-tree.h" 21 | 22 | #include "DeclTree.h" 23 | 24 | 25 | namespace GCCInternalsTools 26 | { 27 | 28 | class NamespaceTree 29 | { 30 | public: 31 | 32 | NamespaceTree( const tree& namespaceNode ) 33 | { 34 | for( tree currentContext = (tree&)namespaceNode; ( currentContext != NULL ) && ( TREE_CODE( currentContext ) == NAMESPACE_DECL ) && ( currentContext != global_namespace ); currentContext = DECL_CONTEXT( currentContext ) ) 35 | { 36 | m_namespaceNodes.push_front( currentContext ); 37 | } 38 | 39 | m_namespaceNodes.push_front( global_namespace ); 40 | } 41 | 42 | 43 | virtual ~NamespaceTree() {}; 44 | 45 | 46 | const std::list& nodes() const 47 | { 48 | return( m_namespaceNodes ); 49 | } 50 | 51 | const std::string asString() const 52 | { 53 | std::string fqNamespace; 54 | 55 | if(( m_namespaceNodes.size() == 1 ) && ( m_namespaceNodes.front() == global_namespace )) 56 | { 57 | fqNamespace = CPPModel::SCOPE_RESOLUTION_OPERATOR; 58 | } 59 | else 60 | { 61 | for( tree currentNode : m_namespaceNodes ) 62 | { 63 | // If this is the global namespace, then just tack it on and continue 64 | 65 | if( currentNode == global_namespace ) 66 | { 67 | continue; 68 | } 69 | 70 | // If this is the standard library namespace, then tack it on and continue 71 | 72 | if( DECL_NAMESPACE_STD_P( currentNode )) 73 | { 74 | fqNamespace += CPPModel::STD_NAMESPACE_LABEL; 75 | continue; 76 | } 77 | 78 | // If we are inside of a class, then add that to the namespace 79 | 80 | if( TREE_CODE( currentNode ) == RECORD_TYPE ) 81 | { 82 | currentNode = TYPE_NAME( currentNode ); 83 | } 84 | 85 | fqNamespace += IDENTIFIER_POINTER( DECL_NAME( currentNode ) ) + CPPModel::SCOPE_RESOLUTION_OPERATOR; 86 | } 87 | } 88 | 89 | return( fqNamespace ); 90 | } 91 | 92 | 93 | private : 94 | 95 | std::list m_namespaceNodes; 96 | }; 97 | 98 | } /* namespace GCCInternalsTools */ 99 | 100 | #endif /* NAMESPACETREE_H_ */ 101 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/UID.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | #ifndef UID_H_ 13 | #define UID_H_ 14 | 15 | 16 | #include "Serialization.h" 17 | 18 | 19 | 20 | namespace CPPModel 21 | { 22 | 23 | class UID : public IXMLSerializable 24 | { 25 | public : 26 | 27 | enum class UIDType { TYPE, DECLARATION }; 28 | 29 | UID() = delete; 30 | 31 | explicit UID( long uid, 32 | UIDType type ) 33 | : m_uid( uid ), 34 | m_type( type ) 35 | {} 36 | 37 | UID( UID& uidToCopy ) 38 | : m_uid( uidToCopy.m_uid ), 39 | m_type( uidToCopy.m_type ) 40 | {} 41 | 42 | UID( const UID& uidToCopy ) 43 | : m_uid( uidToCopy.m_uid ), 44 | m_type( uidToCopy.m_type ) 45 | {} 46 | 47 | virtual ~UID() 48 | {} 49 | 50 | 51 | const UID& uid() const 52 | { 53 | return( *this ); 54 | } 55 | 56 | long uidValue() const 57 | { 58 | return( m_uid ); 59 | } 60 | 61 | UIDType uidType() const 62 | { 63 | return( m_type ); 64 | } 65 | 66 | // The numeric identifier of UID is unique only within TYPEs or DECLs, so we have 67 | // to check the UID type in comparisons. 68 | // 69 | // For example: UID( 1234, TYPE) and UID( 1234, DECLARATION) can both exist 70 | 71 | bool operator==( const UID& entryToCompare ) const 72 | { 73 | return(( m_uid == entryToCompare.m_uid ) && ( m_type == entryToCompare.m_type )); 74 | } 75 | 76 | bool operator!=( const UID& entryToCompare ) const 77 | { 78 | return( !( *this == entryToCompare )); 79 | } 80 | 81 | bool operator<( const UID& entryToCompare ) const 82 | { 83 | if( m_type != entryToCompare.m_type ) 84 | { 85 | return( m_type < entryToCompare.m_type ); 86 | } 87 | 88 | return( m_uid < entryToCompare.m_uid ); 89 | } 90 | 91 | 92 | std::ostream& toXML( std::ostream& outputStream, 93 | SerializationOptions options ) const; 94 | 95 | 96 | 97 | private : 98 | 99 | long m_uid; 100 | UIDType m_type; 101 | }; 102 | 103 | 104 | } // namespace CPPModel 105 | 106 | 107 | #endif /* UID_H_ */ 108 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/PluginManager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * PluginManager.h 3 | * 4 | * Created on: May 31, 2014 5 | * Author: steve 6 | */ 7 | 8 | #ifndef PLUGINMANAGER_H_ 9 | #define PLUGINMANAGER_H_ 10 | 11 | 12 | #include "ASTDictionary.h" 13 | 14 | 15 | 16 | namespace CPPModel 17 | { 18 | 19 | 20 | class AttributeSpec 21 | { 22 | public : 23 | 24 | enum class RequiredElement { DECL_REQUIRED, TYPE_REQUIRED, FUNCTION_TYPE_REQUIRED, ANY }; 25 | 26 | AttributeSpec( const char* name, 27 | int minNumArguments, 28 | int maxNumArguments, 29 | RequiredElement elementRequired, 30 | bool affectsTypeIdentity ) 31 | : m_name( name ), 32 | m_minNumArgs( minNumArguments ), 33 | m_maxNumArgs( maxNumArguments ), 34 | m_elementRequired( elementRequired ), 35 | m_affectsTypeIdentity( affectsTypeIdentity ) 36 | {} 37 | 38 | 39 | 40 | const std::string& name() const 41 | { 42 | return( m_name ); 43 | } 44 | 45 | int minNumArguments() const 46 | { 47 | return( m_minNumArgs ); 48 | } 49 | 50 | int maxNumArguments() const 51 | { 52 | return( m_maxNumArgs ); 53 | } 54 | 55 | const RequiredElement elementRequired() const 56 | { 57 | return( m_elementRequired ); 58 | } 59 | 60 | bool affectsTypeIdentity() const 61 | { 62 | return( m_affectsTypeIdentity ); 63 | } 64 | 65 | 66 | 67 | private : 68 | 69 | const std::string m_name; 70 | const int m_minNumArgs; 71 | const int m_maxNumArgs; 72 | const RequiredElement m_elementRequired; 73 | const bool m_affectsTypeIdentity; 74 | 75 | }; 76 | 77 | 78 | typedef std::list AttributeSpecList; 79 | 80 | 81 | class CallbackIfx 82 | { 83 | public : 84 | 85 | virtual ~CallbackIfx() 86 | {} 87 | 88 | virtual std::unique_ptr RegisterAttributes() = 0; 89 | 90 | virtual void ASTReady() = 0; 91 | 92 | virtual void CreateNamespaces() = 0; 93 | 94 | virtual void InjectCode() = 0; 95 | }; 96 | 97 | 98 | 99 | 100 | class PluginManager 101 | { 102 | public : 103 | 104 | virtual ~PluginManager() 105 | {} 106 | 107 | 108 | 109 | virtual void Initialize( const char* pluginName, 110 | CallbackIfx* callbacks ) = 0; 111 | 112 | virtual ASTDictionary& GetASTDictionary() = 0; 113 | 114 | }; 115 | 116 | 117 | extern PluginManager& GetPluginManager(); 118 | } 119 | 120 | 121 | #endif /* PLUGINMANAGER_H_ */ 122 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/SourceLocation.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | #ifndef SOURCELOCATION_H_ 13 | #define SOURCELOCATION_H_ 14 | 15 | 16 | 17 | #include "Serialization.h" 18 | 19 | 20 | 21 | namespace CPPModel 22 | { 23 | class SourceLocation : public IXMLSerializable 24 | { 25 | public : 26 | 27 | SourceLocation() = delete; 28 | SourceLocation( SourceLocation& ) = delete; 29 | 30 | SourceLocation( const char* fileName, 31 | long lineNumber, 32 | int characterCount, 33 | long location ) 34 | : m_fileName( fileName != NULL ? fileName : "" ), 35 | m_lineNumber( lineNumber ), 36 | m_characterCount( characterCount ), 37 | m_location( location ) 38 | {} 39 | 40 | SourceLocation( const SourceLocation& locationToCopy ) 41 | : m_fileName( locationToCopy.m_fileName ), 42 | m_lineNumber( locationToCopy.m_lineNumber ), 43 | m_characterCount( locationToCopy.m_characterCount ), 44 | m_location( locationToCopy.m_location ) 45 | {} 46 | 47 | virtual ~SourceLocation() 48 | {} 49 | 50 | 51 | 52 | const SourceLocation& sourceLocation() const 53 | { 54 | return( *this ); 55 | } 56 | 57 | 58 | virtual const bool isUnknown() const 59 | { 60 | return( false ); 61 | } 62 | 63 | const std::string& fileName() const 64 | { 65 | return( m_fileName ); 66 | } 67 | 68 | long lineNumber() const 69 | { 70 | return( m_lineNumber ); 71 | } 72 | 73 | int characterCount() const 74 | { 75 | return( m_characterCount ); 76 | } 77 | 78 | long location() const 79 | { 80 | return( m_location ); 81 | } 82 | 83 | 84 | // Comparison operator for ordered lists 85 | 86 | bool operator<( const SourceLocation& locationToCompare ) const 87 | { 88 | return( m_location < locationToCompare.m_location ); 89 | } 90 | 91 | 92 | // Implementation of XMLSerializable virtual method 93 | 94 | virtual std::ostream& toXML( std::ostream& outputStream, 95 | SerializationOptions options ) const; 96 | 97 | private : 98 | 99 | const std::string m_fileName; 100 | const long m_lineNumber; 101 | const int m_characterCount; 102 | const long m_location; 103 | }; 104 | 105 | } // namespace CPPModel 106 | 107 | 108 | #endif /* SOURCELOCATION_H_ */ 109 | -------------------------------------------------------------------------------- /GCCInternalsTools/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | GCCInternalsTools 4 | 5 | 6 | CPPLanguageModel 7 | 8 | 9 | 10 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 11 | clean,full,incremental, 12 | 13 | 14 | ?name? 15 | 16 | 17 | 18 | org.eclipse.cdt.make.core.append_environment 19 | true 20 | 21 | 22 | org.eclipse.cdt.make.core.autoBuildTarget 23 | all 24 | 25 | 26 | org.eclipse.cdt.make.core.buildArguments 27 | 28 | 29 | 30 | org.eclipse.cdt.make.core.buildCommand 31 | make 32 | 33 | 34 | org.eclipse.cdt.make.core.buildLocation 35 | ${workspace_loc:/GCCHelpers/Debug} 36 | 37 | 38 | org.eclipse.cdt.make.core.cleanBuildTarget 39 | clean 40 | 41 | 42 | org.eclipse.cdt.make.core.contents 43 | org.eclipse.cdt.make.core.activeConfigSettings 44 | 45 | 46 | org.eclipse.cdt.make.core.enableAutoBuild 47 | false 48 | 49 | 50 | org.eclipse.cdt.make.core.enableCleanBuild 51 | true 52 | 53 | 54 | org.eclipse.cdt.make.core.enableFullBuild 55 | true 56 | 57 | 58 | org.eclipse.cdt.make.core.fullBuildTarget 59 | all 60 | 61 | 62 | org.eclipse.cdt.make.core.stopOnError 63 | true 64 | 65 | 66 | org.eclipse.cdt.make.core.useDefaultBuildCmd 67 | true 68 | 69 | 70 | 71 | 72 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 73 | full,incremental, 74 | 75 | 76 | 77 | 78 | 79 | org.eclipse.cdt.core.cnature 80 | org.eclipse.cdt.core.ccnature 81 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 82 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 83 | 84 | 85 | -------------------------------------------------------------------------------- /PluginTest/src/PluginTest.cpp: -------------------------------------------------------------------------------- 1 | //============================================================================ 2 | // Name : PluginTest.cpp 3 | // Author : 4 | // Version : 5 | // Copyright : Your copyright notice 6 | // Description : Hello World in C++, Ansi-style 7 | //============================================================================ 8 | 9 | #include 10 | 11 | #include 12 | 13 | 14 | namespace TestJunkNamespace 15 | { 16 | 17 | } 18 | 19 | 20 | namespace TestNamespace 21 | { 22 | 23 | int g_globalIntVariable; 24 | 25 | 26 | class FriendClass 27 | { 28 | public : 29 | 30 | long longValue; 31 | }; 32 | 33 | 34 | union [[json::generalized_attribute( "union" )]] TestUnion 35 | { 36 | int intValue; 37 | double doubleValue; 38 | std::string stringValue; 39 | 40 | FriendClass classValue; 41 | FriendClass* classPtr; 42 | }; 43 | 44 | 45 | class [[json::generalized_attribute( "arg1", "arg2", 3 )]] SecondFriendClass 46 | { 47 | public : 48 | 49 | [[json::generalized_attribute]] 50 | long FriendFunction( long value ) 51 | { 52 | std::cerr << value << std::endl; 53 | 54 | return( value ); 55 | } 56 | 57 | long longValue; 58 | }; 59 | 60 | 61 | [[json::generalized_attribute( "function" )]] 62 | long FriendFunction( long value ) 63 | { 64 | std::cerr << value << std::endl; 65 | 66 | return( value ); 67 | } 68 | 69 | 70 | class SimpleBase 71 | { 72 | public : 73 | 74 | std::string stringValue; 75 | double doubleValue; 76 | }; 77 | 78 | 79 | class MarkerInterface 80 | { 81 | }; 82 | 83 | 84 | class [[json::json_serialize("arg1")]] ClassWithAttribute : public SimpleBase, public virtual MarkerInterface 85 | { 86 | public : 87 | 88 | ClassWithAttribute() 89 | { 90 | m_intValue = 5; 91 | } 92 | 93 | 94 | int intValue() const 95 | { 96 | return( m_intValue ); 97 | } 98 | 99 | class InnerClass 100 | { 101 | public: 102 | 103 | int innerClassIntValue; 104 | }; 105 | 106 | private : 107 | 108 | 109 | int m_intValue; 110 | 111 | std::string m_stringValue; 112 | 113 | double m_doubleValue [[json::generalized_attribute("double value")]]; 114 | 115 | 116 | friend class FriendClass; 117 | 118 | friend long FriendFunction( long value ); 119 | 120 | friend long SecondFriendClass::FriendFunction( long value ); 121 | 122 | friend void InternalFriendFunction() {} 123 | 124 | friend void InternalFriendFunctionWithParameter( ClassWithAttribute& classWithAttr ) {} 125 | 126 | friend class SecondFriendClass; 127 | }; 128 | } 129 | 130 | 131 | 132 | 133 | int main() 134 | { 135 | 136 | TestNamespace::ClassWithAttribute testClass(); 137 | 138 | std::cout << "!!!Hello World!!!" << std::endl; // prints !!!Hello World!!! 139 | return 0; 140 | } 141 | 142 | 143 | -------------------------------------------------------------------------------- /GCCPlugin/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | GCCPlugin 4 | 5 | 6 | CPPLanguageModel 7 | GCCInternalsTools 8 | Utility 9 | 10 | 11 | 12 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 13 | clean,full,incremental, 14 | 15 | 16 | ?name? 17 | 18 | 19 | 20 | org.eclipse.cdt.make.core.append_environment 21 | true 22 | 23 | 24 | org.eclipse.cdt.make.core.autoBuildTarget 25 | all 26 | 27 | 28 | org.eclipse.cdt.make.core.buildArguments 29 | 30 | 31 | 32 | org.eclipse.cdt.make.core.buildCommand 33 | make 34 | 35 | 36 | org.eclipse.cdt.make.core.buildLocation 37 | ${workspace_loc:/GCCPlugin/Debug} 38 | 39 | 40 | org.eclipse.cdt.make.core.cleanBuildTarget 41 | clean 42 | 43 | 44 | org.eclipse.cdt.make.core.contents 45 | org.eclipse.cdt.make.core.activeConfigSettings 46 | 47 | 48 | org.eclipse.cdt.make.core.enableAutoBuild 49 | false 50 | 51 | 52 | org.eclipse.cdt.make.core.enableCleanBuild 53 | true 54 | 55 | 56 | org.eclipse.cdt.make.core.enableFullBuild 57 | true 58 | 59 | 60 | org.eclipse.cdt.make.core.fullBuildTarget 61 | all 62 | 63 | 64 | org.eclipse.cdt.make.core.stopOnError 65 | true 66 | 67 | 68 | org.eclipse.cdt.make.core.useDefaultBuildCmd 69 | true 70 | 71 | 72 | 73 | 74 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 75 | full,incremental, 76 | 77 | 78 | 79 | 80 | 81 | org.eclipse.cdt.core.cnature 82 | org.eclipse.cdt.core.ccnature 83 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 84 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 85 | 86 | 87 | -------------------------------------------------------------------------------- /PluginTest/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PluginTest 4 | 5 | 6 | CPPLanguageModel 7 | GCCInternalsTools 8 | Utility 9 | 10 | 11 | 12 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 13 | clean,full,incremental, 14 | 15 | 16 | ?name? 17 | 18 | 19 | 20 | org.eclipse.cdt.make.core.append_environment 21 | true 22 | 23 | 24 | org.eclipse.cdt.make.core.autoBuildTarget 25 | all 26 | 27 | 28 | org.eclipse.cdt.make.core.buildArguments 29 | 30 | 31 | 32 | org.eclipse.cdt.make.core.buildCommand 33 | make 34 | 35 | 36 | org.eclipse.cdt.make.core.buildLocation 37 | ${workspace_loc:/PluginTest/Debug} 38 | 39 | 40 | org.eclipse.cdt.make.core.cleanBuildTarget 41 | clean 42 | 43 | 44 | org.eclipse.cdt.make.core.contents 45 | org.eclipse.cdt.make.core.activeConfigSettings 46 | 47 | 48 | org.eclipse.cdt.make.core.enableAutoBuild 49 | false 50 | 51 | 52 | org.eclipse.cdt.make.core.enableCleanBuild 53 | true 54 | 55 | 56 | org.eclipse.cdt.make.core.enableFullBuild 57 | true 58 | 59 | 60 | org.eclipse.cdt.make.core.fullBuildTarget 61 | all 62 | 63 | 64 | org.eclipse.cdt.make.core.stopOnError 65 | true 66 | 67 | 68 | org.eclipse.cdt.make.core.useDefaultBuildCmd 69 | true 70 | 71 | 72 | 73 | 74 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 75 | full,incremental, 76 | 77 | 78 | 79 | 80 | 81 | org.eclipse.cdt.core.cnature 82 | org.eclipse.cdt.core.ccnature 83 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 84 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 85 | 86 | 87 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/Classes/WriteToFieldByOffsetTestCase.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 4 | 5 | 6 | #include 7 | 8 | 9 | 10 | 11 | namespace TestNamespace 12 | { 13 | extern int fieldOffsets[]; 14 | extern char* fieldNames[]; 15 | extern void* (*factoryFunction)(); 16 | 17 | 18 | 19 | class SimpleClass 20 | { 21 | public: 22 | 23 | SimpleClass() 24 | { 25 | std::cout << "In SimpleClass constructor." << std::endl; 26 | } 27 | 28 | bool booleanValue() const 29 | { 30 | return( m_booleanValue ); 31 | } 32 | 33 | char charValue() const 34 | { 35 | return( m_charValue ); 36 | } 37 | 38 | char* stringValue() const 39 | { 40 | return( m_stringValue ); 41 | } 42 | 43 | int intValue() const 44 | { 45 | return( m_intValue ); 46 | } 47 | 48 | long longValue() const 49 | { 50 | return( m_longValue ); 51 | } 52 | 53 | float floatValue() const 54 | { 55 | return( m_floatValue ); 56 | } 57 | 58 | double doubleValue() const 59 | { 60 | return( m_doubleValue ); 61 | } 62 | 63 | 64 | 65 | private : 66 | 67 | bool m_booleanValue; 68 | char m_charValue; 69 | char* m_stringValue; 70 | int m_intValue; 71 | long m_longValue; 72 | float m_floatValue; 73 | double m_doubleValue; 74 | 75 | }; 76 | 77 | 78 | SimpleClass* SimpleClassFactory() 79 | { 80 | return( new SimpleClass() ); 81 | } 82 | 83 | } 84 | 85 | 86 | 87 | 88 | int main() 89 | { 90 | TestNamespace::SimpleClass testInstance; 91 | 92 | 93 | void* testInstancePointer = &testInstance; 94 | 95 | *((bool*)(testInstancePointer + TestNamespace::fieldOffsets[0])) = true; 96 | *((char*)(testInstancePointer + TestNamespace::fieldOffsets[1])) = 'b'; 97 | *((char**)(testInstancePointer + TestNamespace::fieldOffsets[2])) = "A quick brown fox"; 98 | *((int*)(testInstancePointer + TestNamespace::fieldOffsets[3])) = 12345; 99 | *((long*)(testInstancePointer + TestNamespace::fieldOffsets[4])) = 67890; 100 | *((float*)(testInstancePointer + TestNamespace::fieldOffsets[5])) = 1.234; 101 | *((double*)(testInstancePointer + TestNamespace::fieldOffsets[6])) = 5.678E-100; 102 | 103 | std::cout << TestNamespace::fieldNames[0] << " : " << testInstance.booleanValue() << std::endl; 104 | std::cout << TestNamespace::fieldNames[1] << " : " << testInstance.charValue() << std::endl; 105 | std::cout << TestNamespace::fieldNames[2] << " : " << testInstance.stringValue() << std::endl; 106 | std::cout << TestNamespace::fieldNames[3] << " : " << testInstance.intValue() << std::endl; 107 | std::cout << TestNamespace::fieldNames[4] << " : " << testInstance.longValue() << std::endl; 108 | std::cout << TestNamespace::fieldNames[5] << " : " << testInstance.floatValue() << std::endl; 109 | std::cout << TestNamespace::fieldNames[6] << " : " << testInstance.doubleValue() << std::endl; 110 | 111 | 112 | void* byFactory = (*TestNamespace::factoryFunction)(); 113 | 114 | } 115 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/GlobalVars/AddFundamentalValueGlobalVarTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NamespaceBasicTestCase.cpp 3 | * 4 | * Created on: Jul 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | // Without the symbol defined below, this example will not compile with gcc 4.8.0 10 | // I expect that might change in the future. 11 | 12 | 13 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | 21 | 22 | namespace TestCreatedNamespace 23 | { 24 | extern bool testBoolVar; 25 | extern char testCharVar; 26 | extern int testIntVar; 27 | extern long testLongVar; 28 | extern float testFloatVar; 29 | extern double testDoubleVar; 30 | 31 | extern char* testStringVar; 32 | 33 | extern bool* testBoolPointerVar; 34 | extern char* testCharPointerVar; 35 | extern int* testIntPointerVar; 36 | extern long* testLongPointerVar; 37 | extern float* testFloatPointerVar; 38 | extern double* testDoublePointerVar; 39 | 40 | extern char** testStringPointerVar; 41 | 42 | } 43 | 44 | 45 | 46 | 47 | 48 | int main() 49 | { 50 | std::cout << "AddFundamentalValueGlobalVarTest" << std::endl << std::endl; 51 | 52 | std::cout << "Value of testBoolVar: " << TestCreatedNamespace::testBoolVar << " Should be: 1" << std::endl; 53 | std::cout << "Value of testCharVar: " << TestCreatedNamespace::testCharVar << " Should be: 'a'" << std::endl; 54 | std::cout << "Value of testStringVar: " << TestCreatedNamespace::testStringVar << " Should be: 'Test String'" << std::endl; 55 | std::cout << "Value of testIntVar: " << TestCreatedNamespace::testIntVar << " Should be: " << __INT_MAX__ << std::endl; 56 | std::cout << "Value of testLongVar: " << TestCreatedNamespace::testLongVar << " Should be: " << __LONG_MAX__ << std::endl; 57 | std::cout << "Value of testFloatVar: " << TestCreatedNamespace::testFloatVar << " Should be: " << FLT_MAX << std::endl; 58 | std::cout << "Value of testDoubleVar: " << TestCreatedNamespace::testDoubleVar << " Should be: " << DBL_MAX << std::endl; 59 | 60 | std::cout << std::endl; 61 | 62 | std::cout << "Value pointed to by testBoolPointerVar: " << *TestCreatedNamespace::testBoolPointerVar << std::endl; 63 | std::cout << "Value pointed to by testCharPointerVar: " << *TestCreatedNamespace::testCharPointerVar << std::endl; 64 | std::cout << "Value pointed to by testStringPointerVar: " << *TestCreatedNamespace::testStringPointerVar << std::endl; 65 | std::cout << "Value pointed to by testIntPointerVar: " << *TestCreatedNamespace::testIntPointerVar << std::endl; 66 | std::cout << "Value pointed to by testLongPointerVar: " << *TestCreatedNamespace::testLongPointerVar << std::endl; 67 | std::cout << "Value pointed to by testFloatPointerVar: " << *TestCreatedNamespace::testFloatPointerVar << std::endl; 68 | std::cout << "Value pointed to by testDoublePointerVar: " << *TestCreatedNamespace::testDoublePointerVar << std::endl; 69 | 70 | return( 1 ); 71 | } 72 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/GlobalVars/IntrinsicTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | TestNamespace:: 7 | 8 | globalDoubleWithoutStaticKeyword 9 | 1961 10 | 11 | ../testCaseSourceCode/GlobalVars/IntrinsicTestCase.cpp 12 | 19 13 | 1 14 | 10942 15 | 16 | true 17 | 18 | 19 | 20 | TestNamespace:: 21 | 22 | globalInt 23 | 1960 24 | 25 | ../testCaseSourceCode/GlobalVars/IntrinsicTestCase.cpp 26 | 17 27 | 1 28 | 10689 29 | 30 | true 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | TestNamespace:: 39 | 40 | globalDoubleWithoutStaticKeyword 41 | 1961 42 | 43 | ../testCaseSourceCode/GlobalVars/IntrinsicTestCase.cpp 44 | 19 45 | 1 46 | 10942 47 | 48 | true 49 | 50 | fundamental 51 | double 52 | 53 | 54 | 55 | 56 | TestNamespace:: 57 | 58 | globalInt 59 | 1960 60 | 61 | ../testCaseSourceCode/GlobalVars/IntrinsicTestCase.cpp 62 | 17 63 | 1 64 | 10689 65 | 66 | true 67 | 68 | fundamental 69 | int 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Union.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef UNION_H_ 15 | #define UNION_H_ 16 | 17 | 18 | #include "Access.h" 19 | #include "Attribute.h" 20 | #include "SourceElement.h" 21 | #include "Namespace.h" 22 | #include "Types.h" 23 | 24 | 25 | 26 | namespace CPPModel 27 | { 28 | 29 | class UnionMember : public SourceElement, public Access 30 | { 31 | public : 32 | 33 | UnionMember() = delete; 34 | UnionMember( UnionMember& ) = delete; 35 | UnionMember( const UnionMember& ) = delete; 36 | 37 | UnionMember( const std::string& name, 38 | const UID& uid, 39 | std::unique_ptr type, 40 | AccessSpecifier accessSpec, 41 | const SourceLocation& sourceLocation) 42 | : SourceElement( name, uid, sourceLocation ), 43 | Access( accessSpec ), 44 | m_type( std::move( type )) 45 | {} 46 | 47 | virtual ~UnionMember() 48 | {} 49 | 50 | 51 | const Type& type() const 52 | { 53 | return( *m_type ); 54 | } 55 | 56 | std::ostream& toXML( std::ostream& outputStream, 57 | SerializationOptions options ) const; 58 | 59 | private : 60 | 61 | const std::unique_ptr m_type; 62 | }; 63 | 64 | 65 | 66 | class UnionDefinition : public SourceElement, public NamespaceScoped, public IAttributes 67 | { 68 | public : 69 | 70 | UnionDefinition() = delete; 71 | UnionDefinition( UnionDefinition& ) = delete; 72 | UnionDefinition( const UnionDefinition& ) = delete; 73 | 74 | UnionDefinition( const std::string& name, 75 | const UID& uid, 76 | const Namespace& namespaceScope, 77 | const SourceLocation& sourceLocation, 78 | ConstListPtr attributes, 79 | ConstListPtr memberList ) 80 | : SourceElement( name, uid, sourceLocation ), 81 | NamespaceScoped( namespaceScope ), 82 | m_attributes( attributes ), 83 | m_memberList( std::move( memberList )) 84 | { 85 | assert( uid.uidType() == UID::UIDType::DECLARATION ); 86 | } 87 | 88 | virtual ~UnionDefinition() 89 | {} 90 | 91 | 92 | const ListRef members() const 93 | { 94 | return( *m_memberList ); 95 | } 96 | 97 | 98 | const Attributes& attributes() const 99 | { 100 | return( m_attributes ); 101 | } 102 | 103 | 104 | std::ostream& toXML( std::ostream& outputStream, 105 | SerializationOptions options ) const; 106 | 107 | private : 108 | 109 | const Attributes m_attributes; 110 | 111 | const ConstListPtr m_memberList; 112 | }; 113 | 114 | } 115 | 116 | 117 | 118 | #endif /* UNION_H_ */ 119 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/GlobalVars/AttributesTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestNamespace:: 4 | 5 | globaldoubleWithoutStaticKeyword 6 | 1961 7 | 8 | ../testCaseSourceCode/GlobalVars/AttributesTestCase.cpp 9 | 15 10 | 1 11 | 10430 12 | 13 | 14 | 15 | attribute1 16 | 17 | arg2 18 | arg3 19 | 20 | 21 | 22 | true 23 | 24 | 25 | 26 | TestNamespace:: 27 | 28 | globalInt 29 | 1960 30 | 31 | ../testCaseSourceCode/GlobalVars/AttributesTestCase.cpp 32 | 13 33 | 1 34 | 10177 35 | 36 | 37 | 38 | attribute1 39 | 40 | arg1 41 | 42 | 43 | 44 | true 45 | 46 | 47 | 48 | TestNamespace:: 49 | 50 | globaldoubleWithoutStaticKeyword 51 | 1961 52 | 53 | ../testCaseSourceCode/GlobalVars/AttributesTestCase.cpp 54 | 15 55 | 1 56 | 10430 57 | 58 | 59 | 60 | attribute1 61 | 62 | arg2 63 | arg3 64 | 65 | 66 | 67 | true 68 | 69 | fundamental 70 | double 71 | 72 | 73 | 74 | 75 | TestNamespace:: 76 | 77 | globalInt 78 | 1960 79 | 80 | ../testCaseSourceCode/GlobalVars/AttributesTestCase.cpp 81 | 13 82 | 1 83 | 10177 84 | 85 | 86 | 87 | attribute1 88 | 89 | arg1 90 | 91 | 92 | 93 | true 94 | 95 | fundamental 96 | int 97 | 98 | 99 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/ConstantValue.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | #ifndef CONSTANTVALUE_H_ 13 | #define CONSTANTVALUE_H_ 14 | 15 | 16 | #include "Serialization.h" 17 | 18 | 19 | 20 | namespace CPPModel 21 | { 22 | 23 | // 24 | // Classes for AST constants 25 | // 26 | 27 | class ConstantValue : public virtual IXMLSerializable 28 | { 29 | public : 30 | 31 | enum class Kind { STRING, INTEGER, REAL, UNRECOGNIZED }; 32 | 33 | virtual ~ConstantValue() {}; 34 | 35 | virtual Kind kind() const = 0; 36 | 37 | 38 | static ConstantValue* Copy( const ConstantValue& valueToCopy ); 39 | }; 40 | 41 | 42 | class UnrecognizedConstant : public ConstantValue 43 | { 44 | public : 45 | 46 | UnrecognizedConstant() 47 | {} 48 | 49 | 50 | Kind kind() const 51 | { 52 | return( Kind::UNRECOGNIZED ); 53 | } 54 | 55 | std::ostream& toXML( std::ostream& outputStream, 56 | SerializationOptions options ) const; 57 | 58 | }; 59 | 60 | class StringConstant : public ConstantValue 61 | { 62 | public : 63 | 64 | StringConstant( const char* value ) 65 | : m_value( value ) 66 | {} 67 | 68 | StringConstant( const std::string& value ) 69 | : m_value( value ) 70 | {} 71 | 72 | 73 | Kind kind() const 74 | { 75 | return( ConstantValue::Kind::STRING ); 76 | } 77 | 78 | const std::string& value() const 79 | { 80 | return( m_value ); 81 | } 82 | 83 | 84 | std::ostream& toXML( std::ostream& outputStream, 85 | SerializationOptions options ) const; 86 | 87 | 88 | private : 89 | 90 | std::string m_value; 91 | }; 92 | 93 | class IntegerConstant : public ConstantValue 94 | { 95 | public : 96 | 97 | IntegerConstant( long value ) 98 | : m_value( value ) 99 | {} 100 | 101 | 102 | Kind kind() const 103 | { 104 | return( ConstantValue::Kind::INTEGER ); 105 | } 106 | 107 | long value() const 108 | { 109 | return( m_value ); 110 | } 111 | 112 | std::ostream& toXML( std::ostream& outputStream, 113 | SerializationOptions options ) const; 114 | 115 | 116 | private : 117 | 118 | long m_value; 119 | }; 120 | 121 | class RealConstant : public ConstantValue 122 | { 123 | public : 124 | 125 | RealConstant( double value ) 126 | : m_value( value ) 127 | {} 128 | 129 | 130 | Kind kind() const 131 | { 132 | return( ConstantValue::Kind::REAL ); 133 | } 134 | 135 | double value() const 136 | { 137 | return( m_value ); 138 | } 139 | 140 | std::ostream& toXML( std::ostream& outputStream, 141 | SerializationOptions options ) const; 142 | 143 | 144 | private : 145 | 146 | double m_value; 147 | }; 148 | 149 | } 150 | 151 | 152 | #endif /* CONSTANTVALUE_H_ */ 153 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/AttributeParser.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #include "ASTDictionary.h" 15 | 16 | #include "config.h" 17 | #include "gcc-plugin.h" 18 | #include "tree.h" 19 | 20 | #include "cp/cp-tree.h" 21 | 22 | #include "AttributeParser.h" 23 | 24 | #include "ConstantTree.h" 25 | #include "IdentifierTree.h" 26 | 27 | 28 | 29 | 30 | namespace GCCInternalsTools 31 | { 32 | 33 | std::unique_ptr GetAttribute( const IdentifierTree& identifier, 34 | const PurposeValueList& arguments ) 35 | { 36 | // Extract the arguments for the attribute 37 | // Attribute arguments are stored in a TREE_LIST without PURPOSE fields, so we just have to 38 | // worry about the VALUE fields 39 | 40 | CPPModel::ListPtr argumentList( new boost::ptr_list() ); 41 | 42 | for( PurposeValueList::iterator currentArgument = arguments.begin(); currentArgument != arguments.end(); ++currentArgument ) 43 | { 44 | // I don't fully understand this but sometimes the tree value is NULL which I suspect means a null list ??? 45 | 46 | if( currentArgument->value() == NULL ) 47 | { 48 | break; 49 | } 50 | 51 | // Get the value and add it to our list of attributes 52 | 53 | if( CONSTANT_CLASS_P( currentArgument->value() )) 54 | { 55 | // Generally, arguments are strings but I have tripped over a couple of integer constants 56 | 57 | argumentList->push_back( ConstantTree( currentArgument->value() ).value().release() ); 58 | } 59 | else if( TREE_CODE( currentArgument->value() ) == IDENTIFIER_NODE ) 60 | { 61 | // It appears as if sometimes there are identifiers rather than constants 62 | 63 | argumentList->push_back( new CPPModel::StringConstant( IDENTIFIER_POINTER( currentArgument->value() ) )); 64 | } 65 | else 66 | { 67 | argumentList->push_back( new CPPModel::UnrecognizedConstant() ); 68 | } 69 | } 70 | 71 | return( std::unique_ptr( new CPPModel::Attribute( identifier, argumentList ))); 72 | } 73 | 74 | 75 | CPPModel::ConstListPtr GetAttributes( const PurposeValueList& treeList ) 76 | { 77 | // I'd rather have a list of 'const Attribute' but the lib seems to have a bug in it that causes problems 78 | // with const elements of in a ptr_list<>. 79 | 80 | CPPModel::ListPtr attributeList( new boost::ptr_list() ); 81 | 82 | for( PurposeValueList::iterator attribute = treeList.begin(); attribute != treeList.end(); ++attribute ) 83 | { 84 | attributeList->push_back( (CPPModel::Attribute*)GetAttribute( IdentifierTree( attribute->purpose() ), PurposeValueList( attribute->value() )).release() ); 85 | } 86 | 87 | // Return a moved unique pointer to a const-ed version of the list 88 | 89 | return( CPPModel::ConstListPtr( std::move( attributeList ))); 90 | } 91 | } 92 | 93 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Template.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Template.h 3 | * 4 | * Created on: Aug 11, 2013 5 | * Author: steve 6 | */ 7 | 8 | #ifndef TEMPLATE_H_ 9 | #define TEMPLATE_H_ 10 | 11 | 12 | #include "ListAliases.h" 13 | 14 | #include "CompilerSpecific.h" 15 | #include "NamedEntity.h" 16 | #include "UID.h" 17 | #include "SourceLocation.h" 18 | #include "Namespace.h" 19 | 20 | 21 | 22 | namespace CPPModel 23 | { 24 | 25 | class TemplateParameter : public NamedEntity, public CompilerSpecific 26 | { 27 | public : 28 | 29 | TemplateParameter() = delete; 30 | TemplateParameter( TemplateParameter& ) = delete; 31 | TemplateParameter( const TemplateParameter& ) = delete; 32 | 33 | TemplateParameter( const std::string name, 34 | CompilerSpecific compilerSpecific ) 35 | : NamedEntity( name ), 36 | CompilerSpecific( compilerSpecific ) 37 | {} 38 | 39 | ~TemplateParameter() 40 | {} 41 | 42 | 43 | std::ostream& toXML( std::ostream& outputStream, 44 | SerializationOptions options ) const; 45 | }; 46 | 47 | 48 | class TemplateParameters : public IXMLSerializable 49 | { 50 | public : 51 | 52 | TemplateParameters() = delete; 53 | TemplateParameters( TemplateParameters& ) = delete; 54 | TemplateParameters( const TemplateParameters& ) = delete; 55 | 56 | TemplateParameters( ConstListPtr& parameters ) 57 | : m_parameters( std::move( parameters )) 58 | {} 59 | 60 | TemplateParameters( ListPtr& parameters ) 61 | : m_parameters( std::move( parameters )) 62 | {} 63 | 64 | 65 | 66 | const ListRef parameters() const 67 | { 68 | return( *(m_parameters.get()) ); 69 | } 70 | 71 | 72 | std::ostream& toXML( std::ostream& outputStream, 73 | SerializationOptions options ) const; 74 | 75 | private : 76 | 77 | const ConstListPtr m_parameters; 78 | }; 79 | 80 | 81 | class FunctionTemplateDefinition : public SourceElement, public NamespaceScoped, public IAttributes 82 | { 83 | public : 84 | 85 | FunctionTemplateDefinition() = delete; 86 | FunctionTemplateDefinition( FunctionTemplateDefinition& ) = delete; 87 | FunctionTemplateDefinition( const FunctionTemplateDefinition& ) = delete; 88 | 89 | FunctionTemplateDefinition( const std::string& name, 90 | const UID& uid, 91 | const Namespace& namespaceScope, 92 | const SourceLocation& sourceLocation, 93 | const bool hiddenFriend, 94 | ConstListPtr attributes, 95 | ConstListPtr parameters ) 96 | : SourceElement( name, uid, sourceLocation ), 97 | NamespaceScoped( namespaceScope ), 98 | m_attributes( attributes ), 99 | m_hiddenFriend( hiddenFriend ), 100 | m_parameters( parameters ) 101 | {} 102 | 103 | 104 | const bool isHiddenFriend() const 105 | { 106 | return( m_hiddenFriend ); 107 | } 108 | 109 | const Attributes& attributes() const 110 | { 111 | return( m_attributes ); 112 | } 113 | 114 | 115 | std::ostream& toXML( std::ostream& outputStream, 116 | SerializationOptions options ) const; 117 | 118 | private : 119 | 120 | const Attributes m_attributes; 121 | 122 | const bool m_hiddenFriend; 123 | 124 | const TemplateParameters m_parameters; 125 | }; 126 | 127 | 128 | 129 | } /* namespace CPPModel */ 130 | 131 | #endif /* TEMPLATE_H_ */ 132 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/src/HelperFunctions.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "gtest/gtest.h" 14 | 15 | 16 | 17 | static void ForkGCCTestCaseInternal( const char* gccOptions, 18 | const char* testDirectoryName, 19 | const char* testCaseName, 20 | int numOptions, 21 | ... ) 22 | { 23 | // First, pass through the variable argument list. 24 | // The list must end with an empty string. 25 | 26 | va_list arguments; 27 | char* execvArgArray[1024]; 28 | int argIndex = 0; 29 | 30 | execvArgArray[argIndex++] = (char*)"./gcc_wrapper.sh"; 31 | 32 | #ifdef DEBUG 33 | execvArgArray[argIndex++] = (char*)"Debug"; 34 | #else 35 | execvArgArray[argIndex++] = (char*)"Release"; 36 | #endif 37 | execvArgArray[argIndex++] = (char*)gccOptions; 38 | execvArgArray[argIndex++] = (char*)testDirectoryName; 39 | execvArgArray[argIndex++] = (char*)testCaseName; 40 | 41 | va_start( arguments, numOptions ); 42 | char* currentArgument = va_arg( arguments, char* ); 43 | 44 | for( int i = 0; i < numOptions; i++ ) 45 | { 46 | execvArgArray[argIndex++] = currentArgument; 47 | currentArgument = va_arg( arguments, char* ); 48 | } 49 | 50 | execvArgArray[argIndex] = NULL; 51 | 52 | // Next, launch the child process. The fork() function creates a new 53 | // process identical to the existing process, so effectively we have 54 | // two processes executing the code after 'fork'. If the process id 55 | // is zero, then we are in the child process, otherwise we are still 56 | // in the parent process. 57 | // 58 | // The child process launches the gcc_wrapper script and the parent process 59 | // simply waits for the child to exit. 60 | 61 | pid_t childPid = fork(); 62 | 63 | if( childPid == 0 ) 64 | { 65 | execv( "./gcc_wrapper.sh", execvArgArray ); 66 | } 67 | else 68 | { 69 | int status; 70 | 71 | wait( &status ); 72 | 73 | ASSERT_TRUE( WEXITSTATUS( status ) == 0 ); 74 | } 75 | } 76 | 77 | 78 | void ForkGCCTestCase( const char* gccOptions, 79 | const char* testDirectoryName, 80 | const char* testCaseName ) 81 | { 82 | ForkGCCTestCaseInternal( gccOptions, testDirectoryName, testCaseName, 0 ); 83 | } 84 | 85 | 86 | void ForkGCCTestCase( const char* gccOptions, 87 | const char* testDirectoryName, 88 | const char* testCaseName, 89 | const char* option1 ) 90 | { 91 | ForkGCCTestCaseInternal( gccOptions, testDirectoryName, testCaseName, 1, option1 ); 92 | } 93 | 94 | 95 | void ForkGCCTestCase( const char* gccOptions, 96 | const char* testDirectoryName, 97 | const char* testCaseName, 98 | const char* option1, 99 | const char* option2 ) 100 | { 101 | ForkGCCTestCaseInternal( gccOptions, testDirectoryName, testCaseName, 2, option1, option2 ); 102 | } 103 | 104 | 105 | void ForkGCCTestCase( const char* gccOptions, 106 | const char* testDirectoryName, 107 | const char* testCaseName, 108 | const char* option1, 109 | const char* option2, 110 | const char* option3 ) 111 | { 112 | ForkGCCTestCaseInternal( gccOptions, testDirectoryName, testCaseName, 3, option1, option2, option3 ); 113 | } 114 | 115 | 116 | void ForkGCCTestCase( const char* gccOptions, 117 | const char* testDirectoryName, 118 | const char* testCaseName, 119 | const char* option1, 120 | const char* option2, 121 | const char* option3, 122 | const char* option4 ) 123 | { 124 | ForkGCCTestCaseInternal( gccOptions, testDirectoryName, testCaseName, 4, option1, option2, option3, option4 ); 125 | } 126 | 127 | 128 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Attribute.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef ATTRIBUTE_H_ 15 | #define ATTRIBUTE_H_ 16 | 17 | 18 | #include "ListAliases.h" 19 | 20 | #include "ConstantValue.h" 21 | #include "NamedEntity.h" 22 | 23 | 24 | namespace CPPModel 25 | { 26 | 27 | class Attribute : public NamedEntity 28 | { 29 | public : 30 | 31 | Attribute() = delete; 32 | Attribute( Attribute& ) = delete; 33 | 34 | Attribute( const char* name, 35 | ListPtr& arguments ) 36 | : NamedEntity( name ), 37 | m_arguments( std::move( arguments )) 38 | {} 39 | 40 | ~Attribute() 41 | {} 42 | 43 | 44 | const ListRef arguments() const 45 | { 46 | return( *m_arguments ); 47 | } 48 | 49 | std::ostream& toXML( std::ostream& outputStream, 50 | SerializationOptions options ) const; 51 | 52 | protected : 53 | 54 | // The following is needed for deep copying 55 | 56 | friend class Attributes; 57 | 58 | Attribute( const Attribute& attrToCopy ) 59 | : NamedEntity( attrToCopy.name() ) 60 | { 61 | ListPtr argumentsCopy( new boost::ptr_list() ); 62 | 63 | ListRef values( *((attrToCopy.m_arguments).get()) ); 64 | 65 | for( const ConstantValue& itrValue : values ) 66 | { 67 | argumentsCopy->push_back( ConstantValue::Copy( itrValue ) ); 68 | } 69 | 70 | m_arguments = std::move( argumentsCopy ); 71 | } 72 | 73 | 74 | private : 75 | 76 | // This data member cannot be const as the copy constructor cannot initialize it up front 77 | 78 | ConstListPtr m_arguments; 79 | }; 80 | 81 | 82 | class Attributes : public IXMLSerializable 83 | { 84 | public : 85 | 86 | Attributes( Attributes& ) = delete; 87 | 88 | Attributes( ConstListPtr& attributes ) 89 | : m_attributes( std::move( attributes )) 90 | {} 91 | 92 | Attributes() 93 | : m_attributes( ConstListPtr( new boost::ptr_list() )) 94 | {} 95 | 96 | Attributes( const Attributes& attributesToCopy ) 97 | : m_attributes( deepCopy( attributesToCopy ) ) 98 | {} 99 | 100 | 101 | 102 | const ListRef attributes() const 103 | { 104 | return( *(m_attributes.get()) ); 105 | } 106 | 107 | static ConstListPtr deepCopy( const Attributes& attributesToCopy ) 108 | { 109 | return( deepCopy( attributesToCopy.attributes() ) ); 110 | } 111 | 112 | static ConstListPtr deepCopy( const ListRef listToCopy ) 113 | { 114 | boost::ptr_list* copiedList( new boost::ptr_list() ); 115 | 116 | for( const Attribute& itrAttribute : listToCopy ) 117 | { 118 | copiedList->push_back( new Attribute( itrAttribute ) ); 119 | } 120 | 121 | // Return the list 'constified' 122 | 123 | return( ConstListPtr( copiedList )); 124 | } 125 | 126 | 127 | std::ostream& toXML( std::ostream& outputStream, 128 | SerializationOptions options ) const; 129 | 130 | 131 | static ConstListPtr emptyList() 132 | { 133 | return( ConstListPtr( new boost::ptr_list() ) ); 134 | } 135 | 136 | private : 137 | 138 | const ConstListPtr m_attributes; 139 | }; 140 | 141 | 142 | 143 | class IAttributes 144 | { 145 | public : 146 | 147 | virtual ~IAttributes() 148 | {}; 149 | 150 | virtual const Attributes& attributes() const = 0; 151 | }; 152 | } 153 | 154 | 155 | 156 | #endif /* ATTRIBUTE_H_ */ 157 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/gcc_wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | DEBUG_OR_RELEASE=$1 5 | GCC_OPTIONS=$2 6 | TEST_DIRECTORY=$3 7 | TEST_NAME=$4 8 | 9 | 10 | if [ ! -d "temp" ]; then 11 | /bin/mkdir temp 12 | fi 13 | 14 | if [ ! -d "results" ]; then 15 | /bin/mkdir results 16 | fi 17 | 18 | if [ ! -d "results/$TEST_DIRECTORY" ]; then 19 | /bin/mkdir results/$TEST_DIRECTORY 20 | fi 21 | 22 | 23 | CREATE_EXE=true 24 | 25 | if [[ $GCC_OPTIONS == "-c" || $GCC_OPTIONS == *" -c "* ]] 26 | then 27 | CREATE_EXE=false 28 | fi 29 | 30 | 31 | if $CREATE_EXE 32 | then 33 | OUTPUT_OPTION="-o ../results/$TEST_DIRECTORY/$TEST_NAME.exe" 34 | else 35 | OUTPUT_OPTION="" 36 | fi 37 | 38 | 39 | 40 | cd temp 41 | 42 | 43 | 44 | if [ $# -eq 4 ] 45 | then 46 | 47 | /usr/gcc-4.8.0/bin/g++-4.8.0 $GCC_OPTIONS -std=c++11 \ 48 | -fplugin=../../GCCInternalsUTFixture/$DEBUG_OR_RELEASE/libGCCInternalsUTFixture.so \ 49 | -fplugin-arg-libGCCInternalsUTFixture-output-filename=../results/$TEST_DIRECTORY/$TEST_NAME.xml \ 50 | $OUTPUT_OPTION \ 51 | ../testCaseSourceCode/$TEST_DIRECTORY/$TEST_NAME.cpp 52 | 53 | elif [ $# -eq 5 ] 54 | then 55 | 56 | /usr/gcc-4.8.0/bin/g++-4.8.0 $GCC_OPTIONS -std=c++11 \ 57 | -fplugin=../../GCCInternalsUTFixture/$DEBUG_OR_RELEASE/libGCCInternalsUTFixture.so \ 58 | -fplugin-arg-libGCCInternalsUTFixture-output-filename=../results/$TEST_DIRECTORY/$TEST_NAME.xml \ 59 | -fplugin-arg-libGCCInternalsUTFixture-$5 \ 60 | $OUTPUT_OPTION \ 61 | ../testCaseSourceCode/$TEST_DIRECTORY/$TEST_NAME.cpp 62 | 63 | elif [ $# -eq 6 ] 64 | then 65 | 66 | /usr/gcc-4.8.0/bin/g++-4.8.0 $GCC_OPTIONS -std=c++11 \ 67 | -fplugin=../../GCCInternalsUTFixture/$DEBUG_OR_RELEASE/libGCCInternalsUTFixture.so \ 68 | -fplugin-arg-libGCCInternalsUTFixture-output-filename=../results/$TEST_DIRECTORY/$TEST_NAME.xml \ 69 | -fplugin-arg-libGCCInternalsUTFixture-$5 \ 70 | -fplugin-arg-libGCCInternalsUTFixture-$6 \ 71 | $OUTPUT_OPTION \ 72 | ../testCaseSourceCode/$TEST_DIRECTORY/$TEST_NAME.cpp 73 | 74 | elif [ $# -eq 7 ] 75 | then 76 | 77 | /usr/gcc-4.8.0/bin/g++-4.8.0 $GCC_OPTIONS -std=c++11 \ 78 | -fplugin=../../GCCInternalsUTFixture/$DEBUG_OR_RELEASE/libGCCInternalsUTFixture.so \ 79 | -fplugin-arg-libGCCInternalsUTFixture-output-filename=../results/$TEST_DIRECTORY/$TEST_NAME.xml \ 80 | -fplugin-arg-libGCCInternalsUTFixture-$5 \ 81 | -fplugin-arg-libGCCInternalsUTFixture-$6 \ 82 | -fplugin-arg-libGCCInternalsUTFixture-$7 \ 83 | $OUTPUT_OPTION \ 84 | ../testCaseSourceCode/$TEST_DIRECTORY/$TEST_NAME.cpp 85 | 86 | fi 87 | 88 | cd .. 89 | 90 | /bin/rm -f ./temp/*.* 91 | 92 | 93 | cmp -s ./results/$TEST_DIRECTORY/$TEST_NAME.xml ./expectedResults/$TEST_DIRECTORY/$TEST_NAME.xml 94 | 95 | if $CREATE_EXE 96 | then 97 | ./results/$TEST_DIRECTORY/$TEST_NAME.exe > ./results/$TEST_DIRECTORY/$TEST_NAME.out 98 | cmp -s ./results/$TEST_DIRECTORY/$TEST_NAME.out ./expectedResults/$TEST_DIRECTORY/$TEST_NAME.out 99 | fi 100 | 101 | exit $? 102 | 103 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/DeclTree.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef DECLTREE_H_ 15 | #define DECLTREE_H_ 16 | 17 | 18 | #include "TypeTree.h" 19 | 20 | 21 | 22 | namespace GCCInternalsTools 23 | { 24 | 25 | class DeclTree : public DeclOrTypeBaseTree 26 | { 27 | public : 28 | 29 | DeclTree( const tree& declTree ) 30 | : DeclOrTypeBaseTree( declTree ) 31 | { 32 | assert( DECL_P( declTree ) ); 33 | } 34 | 35 | 36 | const DeclTree& operator= ( const tree& declTree ) 37 | { 38 | assert( DECL_P( declTree ) ); 39 | 40 | (tree&)m_tree = declTree; 41 | 42 | return( *this ); 43 | } 44 | 45 | const CPPModel::CompilerSpecific compilerSpecificFlags() const 46 | { 47 | return( CPPModel::CompilerSpecific( isBuiltIn(), isArtificial() ) ); 48 | } 49 | 50 | bool isArtificial() const 51 | { 52 | return( DECL_ARTIFICIAL( m_tree ) ); 53 | } 54 | 55 | bool isBuiltIn() const 56 | { 57 | return( DECL_IS_BUILTIN( m_tree ) ); 58 | } 59 | 60 | bool isAFunctionDeclaration() const 61 | { 62 | // Function declarations are simple, the tree is a FUNCTION_DECL or not 63 | 64 | return( TREE_CODE( m_tree ) == FUNCTION_DECL ); 65 | } 66 | 67 | int treeCode() const 68 | { 69 | return( TREE_CODE( m_tree ) ); 70 | } 71 | 72 | TypeTree treeType() const 73 | { 74 | return( TypeTree( TREE_TYPE( m_tree ) ) ); 75 | } 76 | 77 | const std::string identifier() const 78 | { 79 | const tree& declName = DECL_NAME( m_tree ); 80 | 81 | if( declName == 0 ) 82 | { 83 | return( "[No Identifier]" ); 84 | } 85 | 86 | const char* identifier = IDENTIFIER_POINTER( declName ); 87 | 88 | return( identifier ? std::string( identifier ) : std::string( "[No Identifier]" )); 89 | } 90 | 91 | const CPPModel::UID uid() const 92 | { 93 | return( CPPModel::UID( DECL_UID( m_tree ), CPPModel::UID::UIDType::DECLARATION ) ); 94 | } 95 | 96 | 97 | CPPModel::AccessSpecifier accessSpecifier() const 98 | { 99 | // We only have tests for PRIVATE or PROTECTED, so if it is not either of those access types then it is PUBLIC 100 | 101 | if( TREE_PRIVATE( m_tree )) 102 | { 103 | return( CPPModel::AccessSpecifier::PRIVATE ); 104 | } 105 | else if( TREE_PROTECTED( m_tree )) 106 | { 107 | return( CPPModel::AccessSpecifier::PROTECTED ); 108 | } 109 | 110 | return( CPPModel::AccessSpecifier::PUBLIC ); 111 | } 112 | 113 | 114 | const CPPModel::SourceLocation sourceLocation() const 115 | { 116 | return( CPPModel::SourceLocation( DECL_SOURCE_FILE ( m_tree ), DECL_SOURCE_LINE ( m_tree ), 1, DECL_SOURCE_LOCATION( m_tree ) ) ); 117 | } 118 | 119 | 120 | virtual const NamespaceTree fullyQualifiedNamespace() const; 121 | 122 | 123 | CPPModel::TypeSpecifier typeSpecifier() const 124 | { 125 | return( TypeTree( TREE_TYPE( m_tree )).typeSpecifier() ); 126 | } 127 | 128 | 129 | std::unique_ptr type( const CPPModel::ASTDictionary& dictionary ) const 130 | { 131 | return( TypeTree( TREE_TYPE( m_tree )).type( dictionary ) ); 132 | } 133 | 134 | CPPModel::ConstListPtr attributes(); 135 | 136 | const CPPModel::FieldOffsetInfo offsetInfo() const 137 | { 138 | return( CPPModel::FieldOffsetInfo( TREE_INT_CST_LOW ( DECL_SIZE_UNIT( m_tree )), 139 | DECL_ALIGN_UNIT( m_tree ), 140 | TREE_INT_CST_LOW ( DECL_FIELD_OFFSET( m_tree )), 141 | DECL_OFFSET_ALIGN( m_tree ), 142 | TREE_INT_CST_LOW ( DECL_FIELD_BIT_OFFSET( m_tree ) ) )); 143 | } 144 | 145 | }; 146 | 147 | } 148 | 149 | 150 | #endif /* DECLTREE_H_ */ 151 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Function.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef FUNCTION_H_ 15 | #define FUNCTION_H_ 16 | 17 | 18 | #include 19 | 20 | #include "CompilerSpecific.h" 21 | #include "NamedEntity.h" 22 | #include "Types.h" 23 | 24 | 25 | namespace CPPModel 26 | { 27 | 28 | class FunctionParameter : public NamedEntity, public CompilerSpecific 29 | { 30 | public : 31 | 32 | FunctionParameter() = delete; 33 | FunctionParameter( FunctionParameter& ) = delete; 34 | FunctionParameter( const FunctionParameter& ) = delete; 35 | 36 | FunctionParameter( const std::string name, 37 | std::unique_ptr type, 38 | CompilerSpecific compilerSpecific ) 39 | : NamedEntity( name ), 40 | CompilerSpecific( compilerSpecific ), 41 | m_type( std::move( type ) ) 42 | {} 43 | 44 | ~FunctionParameter() 45 | {} 46 | 47 | 48 | const Type& type() const 49 | { 50 | return( *m_type ); 51 | } 52 | 53 | 54 | std::ostream& toXML( std::ostream& outputStream, 55 | SerializationOptions options ) const; 56 | 57 | private : 58 | 59 | const std::unique_ptr m_type; 60 | }; 61 | 62 | 63 | 64 | class FunctionParameters : public IXMLSerializable 65 | { 66 | public : 67 | 68 | FunctionParameters() = delete; 69 | FunctionParameters( FunctionParameters& ) = delete; 70 | FunctionParameters( const FunctionParameters& ) = delete; 71 | 72 | FunctionParameters( ConstListPtr& parameters ) 73 | : m_parameters( std::move( parameters )) 74 | {} 75 | 76 | FunctionParameters( ListPtr& parameters ) 77 | : m_parameters( std::move( parameters )) 78 | {} 79 | 80 | 81 | 82 | const ListRef parameters() const 83 | { 84 | return( *(m_parameters.get()) ); 85 | } 86 | 87 | 88 | std::ostream& toXML( std::ostream& outputStream, 89 | SerializationOptions options ) const; 90 | 91 | private : 92 | 93 | const ConstListPtr m_parameters; 94 | }; 95 | 96 | 97 | 98 | class FunctionDefinition : public SourceElement, public NamespaceScoped, public IAttributes 99 | { 100 | public : 101 | 102 | FunctionDefinition() = delete; 103 | FunctionDefinition( FunctionDefinition& ) = delete; 104 | FunctionDefinition( const FunctionDefinition& ) = delete; 105 | 106 | FunctionDefinition( const std::string& name, 107 | const UID& uid, 108 | const Namespace& namespaceScope, 109 | const SourceLocation& sourceLocation, 110 | const bool hiddenFriend, 111 | ConstListPtr attributes, 112 | std::unique_ptr returnType, 113 | ConstListPtr parameters ) 114 | : SourceElement( name, uid, sourceLocation ), 115 | NamespaceScoped( namespaceScope ), 116 | m_attributes( attributes ), 117 | m_hiddenFriend( hiddenFriend ), 118 | m_returnType( std::move( returnType ) ), 119 | m_parameters( parameters ) 120 | {} 121 | 122 | 123 | const bool isHiddenFriend() const 124 | { 125 | return( m_hiddenFriend ); 126 | } 127 | 128 | const Type& returnType() const 129 | { 130 | return( *m_returnType ); 131 | } 132 | 133 | const Attributes& attributes() const 134 | { 135 | return( m_attributes ); 136 | } 137 | 138 | 139 | std::ostream& toXML( std::ostream& outputStream, 140 | SerializationOptions options ) const; 141 | 142 | private : 143 | 144 | const Attributes m_attributes; 145 | 146 | const bool m_hiddenFriend; 147 | 148 | const std::unique_ptr m_returnType; 149 | 150 | const FunctionParameters m_parameters; 151 | }; 152 | 153 | } 154 | 155 | 156 | #endif /* FUNCTION_H_ */ 157 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/testCaseSourceCode/GlobalVars/AddFundamentalArrayValueGlobalVarTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * NamespaceBasicTestCase.cpp 3 | * 4 | * Created on: Jul 12, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | // Without the symbol defined below, this example will not compile with gcc 4.8.0 10 | // I expect that might change in the future. 11 | 12 | 13 | #define _GLIBCXX_GTHREAD_USE_WEAK 0 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | 21 | 22 | namespace TestCreatedNamespace 23 | { 24 | extern bool testBoolArray[]; 25 | extern char testCharArray[]; 26 | extern int testIntArray[]; 27 | extern long testLongArray[]; 28 | extern float testFloatArray[]; 29 | extern double testDoubleArray[]; 30 | extern char* testStringArray[]; 31 | 32 | extern bool* testBoolArrayPointer[]; 33 | extern char* testCharArrayPointer[]; 34 | extern int* testIntArrayPointer[]; 35 | extern long* testLongArrayPointer[]; 36 | extern float* testFloatArrayPointer[]; 37 | extern double* testDoubleArrayPointer[]; 38 | extern char** testStringArrayPointer[]; 39 | } 40 | 41 | 42 | 43 | 44 | 45 | int main() 46 | { 47 | std::cout << "AddFundamentalArrayValueGlobalVarTest" << std::endl << std::endl; 48 | 49 | for( int i = 0; i < 12; ++i ) 50 | { 51 | std::cout << "Value of test bool array " << i << ": " << TestCreatedNamespace::testBoolArray[i] << std::endl; 52 | } 53 | 54 | std::cout << std::endl; 55 | 56 | for( int i = 0; i < 26; ++i ) 57 | { 58 | std::cout << "Value of test char array " << i << ": " << TestCreatedNamespace::testCharArray[i] << std::endl; 59 | } 60 | 61 | std::cout << std::endl; 62 | 63 | for( int i = 0; i < 12; ++i ) 64 | { 65 | std::cout << "Value of test int array " << i << ": " << TestCreatedNamespace::testIntArray[i] << std::endl; 66 | } 67 | 68 | std::cout << std::endl; 69 | 70 | for( int i = 0; i < 12; ++i ) 71 | { 72 | std::cout << "Value of test long array " << i << ": " << TestCreatedNamespace::testLongArray[i] << std::endl; 73 | } 74 | 75 | std::cout << std::endl; 76 | 77 | for( int i = 0; i < 10; ++i ) 78 | { 79 | std::cout << "Value of test float array " << i << ": " << TestCreatedNamespace::testFloatArray[i] << std::endl; 80 | } 81 | 82 | std::cout << std::endl; 83 | 84 | for( int i = 0; i < 10; ++i ) 85 | { 86 | std::cout << "Value of test double array " << i << ": " << TestCreatedNamespace::testDoubleArray[i] << std::endl; 87 | } 88 | 89 | std::cout << std::endl; 90 | 91 | for( int i = 0; i < 10; ++i ) 92 | { 93 | std::cout << "Value of test string array " << i << ": " << TestCreatedNamespace::testStringArray[i] << std::endl; 94 | } 95 | 96 | 97 | std::cout << std::endl; 98 | std::cout << std::endl; 99 | std::cout << std::endl; 100 | 101 | 102 | for( int i = 0; i < 12; ++i ) 103 | { 104 | std::cout << "Value of test bool array pointer " << i << ": " << (*TestCreatedNamespace::testBoolArrayPointer)[i] << std::endl; 105 | } 106 | 107 | std::cout << std::endl; 108 | 109 | for( int i = 0; i < 26; ++i ) 110 | { 111 | std::cout << "Value of test char array pointer " << i << ": " << (*TestCreatedNamespace::testCharArrayPointer)[i] << std::endl; 112 | } 113 | 114 | std::cout << std::endl; 115 | 116 | for( int i = 0; i < 12; ++i ) 117 | { 118 | std::cout << "Value of test int array pointer " << i << ": " << (*TestCreatedNamespace::testIntArrayPointer)[i] << std::endl; 119 | } 120 | 121 | std::cout << std::endl; 122 | 123 | for( int i = 0; i < 12; ++i ) 124 | { 125 | std::cout << "Value of test long array pointer " << i << ": " << (*TestCreatedNamespace::testLongArrayPointer)[i] << std::endl; 126 | } 127 | 128 | std::cout << std::endl; 129 | 130 | for( int i = 0; i < 10; ++i ) 131 | { 132 | std::cout << "Value of test float array pointer " << i << ": " << (*TestCreatedNamespace::testFloatArrayPointer)[i] << std::endl; 133 | } 134 | 135 | std::cout << std::endl; 136 | 137 | for( int i = 0; i < 10; ++i ) 138 | { 139 | std::cout << "Value of test double array pointer " << i << ": " << (*TestCreatedNamespace::testDoubleArrayPointer)[i] << std::endl; 140 | } 141 | 142 | std::cout << std::endl; 143 | 144 | for( int i = 0; i < 10; ++i ) 145 | { 146 | std::cout << "Value of test string array pointer " << i << ": " << (*TestCreatedNamespace::testStringArrayPointer)[i] << std::endl; 147 | } 148 | 149 | 150 | return( 1 ); 151 | } 152 | -------------------------------------------------------------------------------- /TestExtensions/TestExtensions/src/ClassTestExtension.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ClassTestExtension.cpp 3 | * 4 | * Created on: Aug 26, 2014 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | #include "ASTDictionary.h" 11 | 12 | #include 13 | #include 14 | 15 | 16 | 17 | 18 | 19 | extern "C" 20 | { 21 | bool WriteToFieldByOffsetTest( int callbackType, 22 | CPPModel::ASTDictionary* astDictionary ); 23 | } 24 | 25 | 26 | 27 | 28 | 29 | bool WriteToFieldByOffsetTest( int callbackType, 30 | CPPModel::ASTDictionary* astDictionary ) 31 | { 32 | 33 | if( callbackType == 3 ) 34 | { 35 | const CPPModel::Namespace *testCreatedNamespace; 36 | 37 | if( !astDictionary->GetNamespace( "TestNamespace::", testCreatedNamespace )) 38 | { 39 | std::cerr << "In AddFundamentalArrayValueGlobalVarTest: Get TestCreatedNamesapce failed." << std::endl; 40 | return( false ); 41 | } 42 | 43 | // Get the dictionary entry for the TestNamespace::SimpleClass class 44 | 45 | 46 | CPPModel::ASTDictionary::FQNameIndexConstIterator itrClass = astDictionary->FQNameIdx().find( "TestNamespace::SimpleClass" ); 47 | 48 | 49 | if( itrClass == astDictionary->FQNameIdx().end() ) 50 | { 51 | return( false ); 52 | } 53 | 54 | if( (*itrClass)->entryKind() != CPPModel::DictionaryEntry::EntryKind::CLASS ) 55 | { 56 | return( false ); 57 | } 58 | 59 | const CPPModel::DictionaryClassEntry& classEntry = dynamic_cast( *(*itrClass) ); 60 | 61 | CPPModel::GetClassDefinitionResult classDef = classEntry.GetClassDefinition( CPPModel::ParseOptions() ); 62 | 63 | 64 | std::vector offsetInitializerArray; 65 | std::vector nameInitializerArray; 66 | 67 | for( boost::ptr_list::const_iterator itrField = classDef.ReturnPtr()->fields().begin(); itrField != classDef.ReturnPtr()->fields().end(); itrField++ ) 68 | { 69 | offsetInitializerArray.push_back( itrField->offsetInfo().totalOffsetInBytes() ); 70 | nameInitializerArray.push_back( std::string( itrField->name().c_str() )); 71 | } 72 | 73 | // Create an array of ints 74 | 75 | CPPModel::IntArrayGlobalVarDeclaration offsetGlobalVarDec( "fieldOffsets", 76 | *testCreatedNamespace, 77 | offsetInitializerArray ); 78 | 79 | CPPModel::CreateGlobalVarResult gvResult = astDictionary->CreateGlobalVar( offsetGlobalVarDec ); 80 | 81 | if( !gvResult.Succeeded() ) 82 | { 83 | std::cerr << "In WriteToFieldByOffsetTest: Creating integer array of field offsets failed." << std::endl; 84 | return( false ); 85 | } 86 | 87 | // Create an array of ints 88 | 89 | CPPModel::StringArrayGlobalVarDeclaration nameGlobalVarDec( "fieldNames", 90 | *testCreatedNamespace, 91 | nameInitializerArray ); 92 | 93 | gvResult = astDictionary->CreateGlobalVar( nameGlobalVarDec ); 94 | 95 | if( !gvResult.Succeeded() ) 96 | { 97 | std::cerr << "In WriteToFieldByOffsetTest: Creating integer array of field offsets failed." << std::endl; 98 | return( false ); 99 | } 100 | 101 | 102 | // Now for the function pointer 103 | 104 | CPPModel::ASTDictionary::FQNameIndexConstIterator itrFactory = astDictionary->FQNameIdx().find( "TestNamespace::SimpleClassFactory" ); 105 | 106 | 107 | if( itrFactory == astDictionary->FQNameIdx().end() ) 108 | { 109 | return( false ); 110 | } 111 | 112 | if( (*itrFactory)->entryKind() != CPPModel::DictionaryEntry::EntryKind::FUNCTION ) 113 | { 114 | return( false ); 115 | } 116 | 117 | 118 | CPPModel::DerivedType voidPointer( CPPModel::TypeSpecifier::POINTER, std::unique_ptr( new CPPModel::FundamentalType( CPPModel::TypeSpecifier::VOID )) ); 119 | 120 | CPPModel::FunctionPrototype prototype( voidPointer ); 121 | 122 | CPPModel::UID functionUID = (*itrFactory)->uid(); 123 | 124 | CPPModel::FunctionPointerGlobalVarDeclaration globalPointerVarDec( "factoryFunction", 125 | prototype, 126 | *testCreatedNamespace, 127 | functionUID ); 128 | 129 | gvResult = astDictionary->CreateGlobalVar( globalPointerVarDec ); 130 | 131 | if( !gvResult.Succeeded() ) 132 | { 133 | std::cerr << "In WriteToFieldByOffsetTest: Function Pointer CreateGlobalVar failed." << std::endl; 134 | return( false ); 135 | } 136 | 137 | 138 | } 139 | 140 | return( true ); 141 | } 142 | 143 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/TreeList.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef TREELIST_H_ 15 | #define TREELIST_H_ 16 | 17 | 18 | #include "DeclTree.h" 19 | 20 | 21 | 22 | namespace GCCInternalsTools 23 | { 24 | 25 | template 26 | class TreeList 27 | { 28 | public : 29 | 30 | class iterator 31 | { 32 | public : 33 | 34 | iterator( const iterator& itrToCopy ) 35 | : m_tree( itrToCopy.m_tree ) 36 | { 37 | if( m_tree != NULL_TREE ) 38 | { 39 | m_castTree.reset( new T( m_tree ) ); 40 | } 41 | else 42 | { 43 | m_castTree.reset(); 44 | } 45 | } 46 | 47 | 48 | iterator& operator=( const iterator& itrToCopy ) 49 | { 50 | m_tree = itrToCopy.m_tree; 51 | 52 | if( m_tree != NULL_TREE ) 53 | { 54 | m_castTree.reset( new T( m_tree ) ); 55 | } 56 | else 57 | { 58 | m_castTree.reset(); 59 | } 60 | 61 | return( *this ); 62 | } 63 | 64 | const iterator& operator ++() 65 | { 66 | m_tree = TREE_CHAIN( m_tree ); 67 | 68 | if( m_tree != NULL_TREE ) 69 | { 70 | m_castTree.reset( new T( m_tree ) ); 71 | } 72 | else 73 | { 74 | m_castTree.reset(); 75 | } 76 | 77 | return( *this ); 78 | } 79 | 80 | bool operator ==( const iterator& itrToCompare ) const 81 | { 82 | return( m_tree == itrToCompare.m_tree ); 83 | } 84 | 85 | bool operator !=( const iterator& itrToCompare ) const 86 | { 87 | return( m_tree != itrToCompare.m_tree ); 88 | } 89 | 90 | const T& operator*() const 91 | { 92 | assert( m_tree != NULL_TREE ); 93 | 94 | return( *m_castTree ); 95 | } 96 | 97 | const T* const operator->() const 98 | { 99 | assert( m_tree != NULL_TREE ); 100 | 101 | return( m_castTree.get() ); 102 | } 103 | 104 | private : 105 | 106 | tree m_tree; 107 | 108 | std::unique_ptr m_castTree; 109 | 110 | 111 | iterator( tree treeList ) 112 | : m_tree( treeList ) 113 | { 114 | if( m_tree != NULL_TREE ) 115 | { 116 | m_castTree.reset( new T( m_tree ) ); 117 | } 118 | else 119 | { 120 | m_castTree.reset(); 121 | } 122 | } 123 | 124 | friend TreeList; 125 | }; 126 | 127 | 128 | TreeList( const tree treeList ) 129 | : m_begin( treeList ), 130 | m_end( NULL_TREE ) 131 | { 132 | if(( treeList != NULL ) && ( treeCode != 0 )) 133 | { 134 | assert( TREE_CODE( treeList ) == treeCode ); 135 | } 136 | } 137 | 138 | 139 | 140 | TreeList& operator= ( const TreeList& treeList ) 141 | { 142 | m_begin = treeList.m_begin; 143 | 144 | return( *this ); 145 | } 146 | 147 | 148 | bool empty() const 149 | { 150 | return( m_begin == NULL_TREE ); 151 | } 152 | 153 | iterator begin() const 154 | { 155 | return( m_begin ); 156 | } 157 | 158 | iterator end() const 159 | { 160 | return( m_end ); 161 | } 162 | 163 | 164 | private : 165 | 166 | 167 | const iterator m_begin; 168 | const iterator m_end; 169 | }; 170 | 171 | 172 | 173 | 174 | class PurposeValueElement 175 | { 176 | public : 177 | 178 | PurposeValueElement( const tree& listElement ) 179 | : m_listElement( listElement ) 180 | {} 181 | 182 | 183 | const PurposeValueElement& operator=( const tree& listElement ) 184 | { 185 | (tree&)m_listElement = listElement; 186 | 187 | return( *this ); 188 | } 189 | 190 | const tree& purpose() const 191 | { 192 | return( TREE_PURPOSE( m_listElement ) ); 193 | } 194 | 195 | const tree& value() const 196 | { 197 | return( TREE_VALUE( m_listElement ) ); 198 | } 199 | 200 | private : 201 | 202 | const tree& m_listElement; 203 | 204 | 205 | operator const tree&() const 206 | { 207 | return( m_listElement ); 208 | } 209 | 210 | 211 | friend TreeList; 212 | }; 213 | 214 | 215 | 216 | typedef TreeList PurposeValueList; 217 | 218 | // Field lists contain a variety elements, thus passing zero to disable the type checking 219 | 220 | typedef TreeList DeclList; 221 | typedef TreeList NamespaceList; 222 | 223 | typedef TreeList FieldList; 224 | 225 | typedef TreeList FunctionList; 226 | typedef TreeList MethodList; 227 | typedef TreeList ParameterList; 228 | 229 | typedef TreeList UnionMemberList; 230 | 231 | } 232 | 233 | 234 | 235 | #endif /* TREELIST_H_ */ 236 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/Namespace.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | #ifndef NAMESPACE_H_ 15 | #define NAMESPACE_H_ 16 | 17 | 18 | #include "ListAliases.h" 19 | 20 | #include "Constants.h" 21 | #include "CompilerSpecific.h" 22 | #include "UID.h" 23 | #include "SourceElement.h" 24 | #include "Attribute.h" 25 | 26 | 27 | 28 | namespace CPPModel 29 | { 30 | 31 | 32 | 33 | class Namespace : public SourceElement, public CompilerSpecific, public IAttributes 34 | { 35 | public : 36 | 37 | // Namespace() = delete; 38 | 39 | virtual ~Namespace() 40 | {}; 41 | 42 | virtual bool isGlobal() const = 0; 43 | 44 | virtual const Namespace& parentNamespace() const = 0; 45 | 46 | virtual const std::string& fqName() const = 0; 47 | 48 | 49 | const Attributes& attributes() const 50 | { 51 | return( m_attributes ); 52 | } 53 | 54 | 55 | std::ostream& toXML( std::ostream& outputStream, 56 | SerializationOptions options ) const; 57 | 58 | protected : 59 | 60 | Namespace( const std::string& name, 61 | const UID& uid, 62 | const SourceLocation& sourceLocation, 63 | const CompilerSpecific& compilerSpecificAttr, 64 | ConstListPtr& attributes ) 65 | : SourceElement( name, uid, sourceLocation ), 66 | CompilerSpecific( compilerSpecificAttr ), 67 | m_attributes( attributes ) 68 | {} 69 | 70 | Namespace( const std::string& name, 71 | const UID& uid, 72 | const SourceLocation& sourceLocation, 73 | const CompilerSpecific& compilerSpecificAttr ) 74 | : SourceElement( name, uid, sourceLocation ), 75 | CompilerSpecific( compilerSpecificAttr ), 76 | m_attributes() 77 | {} 78 | 79 | private : 80 | 81 | const Attributes m_attributes; 82 | 83 | }; 84 | 85 | 86 | 87 | class GlobalNamespace : public Namespace 88 | { 89 | public : 90 | 91 | GlobalNamespace( GlobalNamespace& ) = delete; 92 | GlobalNamespace( const GlobalNamespace& ) = delete; 93 | 94 | GlobalNamespace() 95 | : Namespace( SCOPE_RESOLUTION_OPERATOR, UID( (long)0, UID::UIDType::DECLARATION ), SourceLocation( NULL, 0, 0, 0 ), CompilerSpecific( false, false ) ) 96 | {} 97 | 98 | ~GlobalNamespace() 99 | {} 100 | 101 | 102 | bool isGlobal() const 103 | { 104 | return( true ); 105 | } 106 | 107 | const Namespace& parentNamespace() const 108 | { 109 | return( *this ); 110 | } 111 | 112 | const std::string& fqName() const 113 | { 114 | return( name() ); 115 | } 116 | }; 117 | 118 | 119 | 120 | class NestedNamespace : public Namespace 121 | { 122 | public : 123 | 124 | NestedNamespace( NestedNamespace& ) = delete; 125 | NestedNamespace( const NestedNamespace& ) = delete; 126 | 127 | NestedNamespace( const std::string& name, 128 | const UID& uid, 129 | const SourceLocation& sourceLocation, 130 | const CompilerSpecific& compilerSpecificAttr, 131 | ConstListPtr& attributes, 132 | const Namespace& parentNamespace ) 133 | : Namespace( name, uid, sourceLocation, compilerSpecificAttr, attributes ), 134 | m_parentNamespace( parentNamespace ), 135 | m_fqName( parentNamespace.isGlobal() ? name + SCOPE_RESOLUTION_OPERATOR : parentNamespace.fqName() + name + SCOPE_RESOLUTION_OPERATOR ) 136 | {} 137 | 138 | NestedNamespace( const char* name, 139 | const UID& uid, 140 | const SourceLocation& sourceLocation, 141 | const CompilerSpecific& compilerSpecificAttr, 142 | ConstListPtr& attributes, 143 | const Namespace& parentNamespace ) 144 | : Namespace( name, uid, sourceLocation, compilerSpecificAttr, attributes ), 145 | m_parentNamespace( parentNamespace ), 146 | m_fqName( parentNamespace.isGlobal() ? name + SCOPE_RESOLUTION_OPERATOR : parentNamespace.fqName() + name + SCOPE_RESOLUTION_OPERATOR ) 147 | {} 148 | 149 | ~NestedNamespace() 150 | {} 151 | 152 | 153 | 154 | bool isGlobal() const 155 | { 156 | return( false ); 157 | } 158 | 159 | const Namespace& parentNamespace() const 160 | { 161 | return( m_parentNamespace ); 162 | } 163 | 164 | const std::string& fqName() const 165 | { 166 | return( m_fqName ); 167 | } 168 | 169 | 170 | private : 171 | 172 | const Namespace& m_parentNamespace; 173 | 174 | const std::string m_fqName; 175 | }; 176 | 177 | 178 | class NamespaceScoped : public virtual IXMLSerializable 179 | { 180 | public : 181 | 182 | NamespaceScoped( const Namespace& namespaceScope ) 183 | : m_namespaceScope( namespaceScope ) 184 | {} 185 | 186 | 187 | const Namespace& namespaceScope() const 188 | { 189 | return( m_namespaceScope ); 190 | } 191 | 192 | std::ostream& toXML( std::ostream& outputStream, 193 | SerializationOptions options ) const 194 | { 195 | m_namespaceScope.toXML( outputStream, options ); 196 | 197 | return( outputStream ); 198 | } 199 | 200 | 201 | private : 202 | 203 | const Namespace& m_namespaceScope; 204 | }; 205 | 206 | 207 | } 208 | 209 | #endif /* NAMESPACE_H_ */ 210 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/Functions/SimpleFunctionTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | :: 5 | 6 | 7 | TestNamespace:: 8 | 9 | 10 | __cxxabiv1:: 11 | 12 | 13 | 14 | 15 | 16 | __gnu_cxx:: 17 | 18 | 19 | __gnu_debug:: 20 | 21 | 22 | std:: 23 | 24 | 25 | 26 | 27 | 28 | std::__debug:: 29 | 30 | 31 | std::__exception_ptr:: 32 | 33 | 34 | 35 | 36 | 37 | 38 | TestNamespace:: 39 | 40 | FunctionReturningInt 41 | 28421 42 | 43 | ../testCaseSourceCode/Functions/SimpleFunctionTestCase.cpp 44 | 21 45 | 1 46 | 6478501 47 | 48 | 49 | 50 | 51 | TestNamespace:: 52 | 53 | FunctionReturningString 54 | 28423 55 | 56 | ../testCaseSourceCode/Functions/SimpleFunctionTestCase.cpp 57 | 26 58 | 1 59 | 6479147 60 | 61 | 62 | 63 | 64 | TestNamespace:: 65 | 66 | FunctionReturningVoid 67 | 28419 68 | 69 | ../testCaseSourceCode/Functions/SimpleFunctionTestCase.cpp 70 | 18 71 | 1 72 | 6478117 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | TestNamespace:: 82 | 83 | FunctionReturningInt 84 | 28421 85 | 86 | ../testCaseSourceCode/Functions/SimpleFunctionTestCase.cpp 87 | 21 88 | 1 89 | 6478501 90 | 91 | 92 | 93 | fundamental 94 | int 95 | 96 | 97 | 98 | 99 | 100 | TestNamespace:: 101 | 102 | FunctionReturningString 103 | 28423 104 | 105 | ../testCaseSourceCode/Functions/SimpleFunctionTestCase.cpp 106 | 26 107 | 1 108 | 6479147 109 | 110 | 111 | 112 | derived 113 | 114 | reference 115 | 116 | class-or-struct 117 | std::string 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | TestNamespace:: 126 | 127 | FunctionReturningVoid 128 | 28419 129 | 130 | ../testCaseSourceCode/Functions/SimpleFunctionTestCase.cpp 131 | 18 132 | 1 133 | 6478117 134 | 135 | 136 | 137 | fundamental 138 | void 139 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/ASTDictionary.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * ASTDictionary.cpp 3 | * 4 | * Created on: Dec 31, 2013 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | #include "ASTDictionary.h" 11 | 12 | #include 13 | 14 | #include "Utility/IndentingOutputStreambuf.h" 15 | 16 | 17 | 18 | 19 | 20 | namespace CPPModel 21 | { 22 | 23 | DictionaryEntry::DictionaryEntry( const ASTDictionary& dictionary, 24 | const UID& uid, 25 | const std::string& name, 26 | const Namespace& enclosingNamespace, 27 | bool isStatic, 28 | bool isExtern, 29 | const SourceLocation& sourceLocation, 30 | const CompilerSpecific& compilerSpecific, 31 | ConstListPtr& attributes ) 32 | : m_dictionary( dictionary ), 33 | m_uid( uid ), 34 | m_name( name ), 35 | m_sourceLocation( sourceLocation ), 36 | m_compilerSpecific( compilerSpecific ), 37 | m_attributes( attributes ), 38 | m_static( isStatic ), 39 | m_extern( isExtern ), 40 | m_enclosingNamespace( enclosingNamespace ), 41 | m_enclosingNamespaceFQName( enclosingNamespace.fqName() ), 42 | m_fqName( enclosingNamespace.fqName() + name ) 43 | {} 44 | 45 | 46 | bool ASTDictionary::Insert( std::shared_ptr& entryToAdd ) 47 | { 48 | std::pair insertResult = m_dictionary->insert( std::shared_ptr( entryToAdd ) ); 49 | 50 | return( insertResult.second ); 51 | } 52 | 53 | 54 | 55 | void ASTDictionary::DumpASTXMLByNamespaces( std::ostream& outputStream, 56 | std::list& namespacesToDump, 57 | XMLOutputOptions outputOptions ) const 58 | { 59 | outputStream << "\n"; 60 | 61 | if( (std::int64_t)outputOptions && (std::int64_t)XMLOutputOptions::LIST_NAMESPACES ) 62 | { 63 | SEFUtility::IndentingOutputStreambuf indent( outputStream ); 64 | 65 | outputStream << "\n"; 66 | 67 | { 68 | SEFUtility::IndentingOutputStreambuf indent( outputStream ); 69 | 70 | for( CPPModel::ASTDictionary::NamespaceMapConstIterator itrNamespace = namespaces().begin(); itrNamespace != namespaces().end(); itrNamespace++ ) 71 | { 72 | itrNamespace->second->toXML( outputStream, CPPModel::SerializationOptions::NONE ); 73 | } 74 | } 75 | 76 | outputStream << "\n"; 77 | } 78 | 79 | { 80 | SEFUtility::IndentingOutputStreambuf indent( outputStream ); 81 | 82 | outputStream << "\n"; 83 | 84 | { 85 | SEFUtility::IndentingOutputStreambuf indent( outputStream ); 86 | 87 | for( std::string currentNamespace : namespacesToDump ) 88 | { 89 | DumpDictionaryXMLByNamespace( outputStream, currentNamespace ); 90 | } 91 | } 92 | outputStream << "\n"; 93 | 94 | outputStream << "\n"; 95 | 96 | { 97 | SEFUtility::IndentingOutputStreambuf indent( outputStream ); 98 | 99 | for( std::string currentNamespace : namespacesToDump ) 100 | { 101 | DumpElementsXMLByNamespace( outputStream, currentNamespace ); 102 | } 103 | } 104 | 105 | outputStream << "\n"; 106 | } 107 | 108 | outputStream << "\n"; 109 | } 110 | 111 | 112 | void ASTDictionary::DumpDictionaryXMLByNamespace( std::ostream& outputStream, 113 | const std::string& namespaceToDump ) const 114 | { 115 | // Return immediately if the namespace does not exist 116 | 117 | if( !ContainsNamespace( namespaceToDump ) ) 118 | { 119 | return; 120 | } 121 | 122 | outputStream << "\n"; 123 | 124 | { 125 | SEFUtility::IndentingOutputStreambuf indent( outputStream ); 126 | 127 | for( CPPModel::ASTDictionary::NamespaceIndexConstIterator namespaceIndex = NamespaceIdx().lower_bound( namespaceToDump ); namespaceIndex != NamespaceIdx().upper_bound( namespaceToDump ); namespaceIndex++ ) 128 | { 129 | (*namespaceIndex)->toXML( outputStream, CPPModel::SerializationOptions::NONE ); 130 | } 131 | } 132 | 133 | outputStream << "\n"; 134 | } 135 | 136 | 137 | 138 | void ASTDictionary::DumpElementsXMLByNamespace( std::ostream& outputStream, 139 | const std::string& namespaceToDump ) const 140 | { 141 | // Return immediately if the namespace does not exist 142 | 143 | if( !ContainsNamespace( namespaceToDump ) ) 144 | { 145 | return; 146 | } 147 | 148 | outputStream << "\n"; 149 | 150 | { 151 | SEFUtility::IndentingOutputStreambuf indent( outputStream ); 152 | 153 | CPPModel::ParseOptions parseOptions; 154 | 155 | for( CPPModel::ASTDictionary::NamespaceIndexConstIterator namespaceIndex = NamespaceIdx().lower_bound( namespaceToDump ); namespaceIndex != NamespaceIdx().upper_bound( namespaceToDump ); namespaceIndex++ ) 156 | { 157 | if( (*namespaceIndex)->entryKind() == CPPModel::DictionaryEntry::EntryKind::CLASS ) 158 | { 159 | GetClassDefinitionResult classDef = ((CPPModel::DictionaryClassEntry*)&(**namespaceIndex))->GetClassDefinition( parseOptions ); 160 | 161 | classDef.ReturnPtr()->toXML( outputStream, CPPModel::SerializationOptions::NONE ); 162 | } 163 | else if( (*namespaceIndex)->entryKind() == CPPModel::DictionaryEntry::EntryKind::UNION ) 164 | { 165 | GetUnionDefinitionResult unionDef = ((CPPModel::DictionaryUnionEntry*)&(**namespaceIndex))->GetUnionDefinition( parseOptions ); 166 | 167 | unionDef.ReturnPtr()->toXML( outputStream, CPPModel::SerializationOptions::NONE ); 168 | } 169 | else if( (*namespaceIndex)->entryKind() == CPPModel::DictionaryEntry::EntryKind::FUNCTION ) 170 | { 171 | GetFunctionDefinitionResult functionDef = ((CPPModel::DictionaryFunctionEntry*)&(**namespaceIndex))->GetFunctionDefinition( parseOptions ); 172 | 173 | functionDef.ReturnPtr()->toXML( outputStream, CPPModel::SerializationOptions::NONE ); 174 | } 175 | else if( (*namespaceIndex)->entryKind() == CPPModel::DictionaryEntry::EntryKind::GLOBAL_VAR ) 176 | { 177 | GetGlobalVarDefinitionResult globalVarDef = ((CPPModel::DictionaryGlobalVarEntry*)&(**namespaceIndex))->GetGlobalVarDefinition( parseOptions ); 178 | 179 | globalVarDef.ReturnPtr()->toXML( outputStream, CPPModel::SerializationOptions::NONE ); 180 | } 181 | } 182 | } 183 | 184 | outputStream << "\n"; 185 | } 186 | 187 | } 188 | 189 | 190 | 191 | -------------------------------------------------------------------------------- /CPPLanguageModel/src/ParameterValues.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FunctionCallParameters.h 3 | * 4 | * Created on: Jan 31, 2014 5 | * Author: steve 6 | */ 7 | 8 | #ifndef PARAMETERVALUES_H_ 9 | #define PARAMETERVALUES_H_ 10 | 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include "Types.h" 18 | 19 | 20 | 21 | namespace CPPModel 22 | { 23 | class ASTDictionaryEntry; 24 | 25 | 26 | typedef std::vector ParameterType; 27 | 28 | 29 | extern const ParameterType BOOLEAN_PARAM; 30 | extern const ParameterType CHAR_PARAM; 31 | extern const ParameterType STRING_PARAM; 32 | extern const ParameterType INT_PARAM; 33 | extern const ParameterType LONG_PARAM; 34 | extern const ParameterType FLOAT_PARAM; 35 | extern const ParameterType DOUBLE_PARAM; 36 | extern const ParameterType CLASS_PARAM; 37 | extern const ParameterType FUNCTION_PARAM; 38 | 39 | 40 | enum class ParameterModifier 41 | { 42 | CONSTANT, 43 | POINTER, 44 | ARRAY 45 | }; 46 | 47 | 48 | 49 | 50 | 51 | TypeSpecifier AsTypeSpecifier( const ParameterType& paramType ); 52 | 53 | 54 | class ParameterValueBase 55 | { 56 | public : 57 | 58 | virtual ~ParameterValueBase() 59 | {} 60 | 61 | virtual std::unique_ptr deepCopy() const = 0; 62 | 63 | virtual const ParameterModifier& modifier() const = 0; 64 | 65 | virtual const ParameterType& type() const = 0; 66 | }; 67 | 68 | 69 | 70 | 71 | template class ParameterValue : public ParameterValueBase 72 | { 73 | public : 74 | 75 | ParameterValue( const T& value ) 76 | : m_modifier( paramModifier ), 77 | m_paramType( paramType ), 78 | m_value( value ) 79 | {} 80 | 81 | 82 | ParameterValue( const ParameterValue& valueToCopy ) 83 | : m_modifier( valueToCopy.m_modifier ), 84 | m_value( valueToCopy.m_value ), 85 | m_paramType( valueToCopy.m_paramType ) 86 | {} 87 | 88 | 89 | std::unique_ptr deepCopy() const 90 | { 91 | return( std::unique_ptr( new ParameterValue( m_value ) )); 92 | } 93 | 94 | 95 | 96 | const ParameterModifier& modifier() const 97 | { 98 | return( m_modifier ); 99 | } 100 | 101 | const ParameterType& type() const 102 | { 103 | return( m_paramType ); 104 | } 105 | 106 | 107 | 108 | const T& value() const 109 | { 110 | return( m_value ); 111 | } 112 | 113 | 114 | private : 115 | 116 | const ParameterModifier m_modifier; 117 | const ParameterType& m_paramType; 118 | T m_value; 119 | 120 | }; 121 | 122 | 123 | 124 | 125 | typedef ParameterValue< bool, ParameterModifier::CONSTANT, BOOLEAN_PARAM> BooleanConstantParameter; 126 | typedef ParameterValue< char, ParameterModifier::CONSTANT, CHAR_PARAM> CharConstantParameter; 127 | typedef ParameterValue< std::string, ParameterModifier::CONSTANT, STRING_PARAM> StringConstantParameter; 128 | typedef ParameterValue< int, ParameterModifier::CONSTANT, INT_PARAM> IntConstantParameter; 129 | typedef ParameterValue< long, ParameterModifier::CONSTANT, LONG_PARAM> LongConstantParameter; 130 | typedef ParameterValue< float, ParameterModifier::CONSTANT, FLOAT_PARAM> FloatConstantParameter; 131 | typedef ParameterValue< double, ParameterModifier::CONSTANT, DOUBLE_PARAM> DoubleConstantParameter; 132 | typedef ParameterValue< const ASTDictionaryEntry&, ParameterModifier::CONSTANT, CLASS_PARAM> ClassParameter; 133 | 134 | typedef ParameterValue< std::vector, ParameterModifier::ARRAY, BOOLEAN_PARAM> BooleanArrayParameter; 135 | typedef ParameterValue< std::vector, ParameterModifier::ARRAY, CHAR_PARAM> CharArrayParameter; 136 | typedef ParameterValue< std::vector, ParameterModifier::ARRAY, STRING_PARAM> StringArrayParameter; 137 | typedef ParameterValue< std::vector, ParameterModifier::ARRAY, INT_PARAM> IntArrayParameter; 138 | typedef ParameterValue< std::vector, ParameterModifier::ARRAY, LONG_PARAM> LongArrayParameter; 139 | typedef ParameterValue< std::vector, ParameterModifier::ARRAY, FLOAT_PARAM> FloatArrayParameter; 140 | typedef ParameterValue< std::vector, ParameterModifier::ARRAY, DOUBLE_PARAM> DoubleArrayParameter; 141 | typedef ParameterValue< std::vector, ParameterModifier::ARRAY, CLASS_PARAM> ClassArrayParameter; 142 | 143 | 144 | 145 | 146 | class ParameterPointerBase 147 | { 148 | public : 149 | 150 | virtual ~ParameterPointerBase() 151 | {} 152 | 153 | virtual const CPPModel::UID& value() const = 0; 154 | }; 155 | 156 | 157 | template class ParameterPointer : public ParameterValue< CPPModel::UID, ParameterModifier::POINTER, paramType>, public ParameterPointerBase 158 | { 159 | public : 160 | 161 | ParameterPointer( const CPPModel::UID& value ) 162 | : ParameterValue< CPPModel::UID, ParameterModifier::POINTER, paramType>( value ) 163 | {} 164 | 165 | 166 | ParameterPointer( const ParameterPointer& valueToCopy ) 167 | : ParameterValue< CPPModel::UID, ParameterModifier::POINTER, paramType>( valueToCopy ) 168 | {} 169 | 170 | const CPPModel::UID& value() const 171 | { 172 | return( ParameterValue< CPPModel::UID, ParameterModifier::POINTER, paramType>::value() ); 173 | } 174 | }; 175 | 176 | 177 | typedef ParameterPointer BooleanPointerParameter; 178 | typedef ParameterPointer CharPointerParameter; 179 | typedef ParameterPointer StringPointerParameter; 180 | typedef ParameterPointer IntPointerParameter; 181 | typedef ParameterPointer LongPointerParameter; 182 | typedef ParameterPointer FloatPointerParameter; 183 | typedef ParameterPointer DoublePointerParameter; 184 | 185 | typedef ParameterPointer FunctionPointerParameter; 186 | 187 | 188 | 189 | class ParameterValueList : public boost::ptr_list 190 | { 191 | public : 192 | 193 | ParameterValueList() 194 | {} 195 | 196 | ParameterValueList( const ParameterValueList& listToCopy ) 197 | { 198 | for( const ParameterValueBase& paramToCopy : listToCopy ) 199 | { 200 | this->push_back( (paramToCopy.deepCopy()).release() ); 201 | } 202 | } 203 | }; 204 | 205 | 206 | 207 | const ParameterValueList EmptyParameterValueList; 208 | 209 | } 210 | 211 | 212 | 213 | 214 | #endif /* PARAMETERVALUES_H_ */ 215 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/PluginManagerImpl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * PassManager.cpp 3 | * 4 | * Created on: May 31, 2014 5 | * Author: steve 6 | */ 7 | 8 | 9 | 10 | #include "PluginManagerImpl.h" 11 | 12 | #include 13 | 14 | 15 | 16 | 17 | namespace GCCInternalsTools 18 | { 19 | 20 | PluginManagerImpl g_PluginManager; 21 | 22 | 23 | 24 | bool BuildASTPassGate() 25 | { 26 | return( !g_PluginManager.dictionaryBuilt() ); 27 | } 28 | 29 | 30 | static tree HandleAttribute( tree* node, 31 | tree attrName, 32 | tree attrArguments, 33 | int flags, 34 | bool* no_add_attrs ) 35 | { 36 | // Just return a null tree now. 37 | 38 | return( NULL_TREE ); 39 | } 40 | 41 | 42 | 43 | static void RegisterAttributesGCCCallback( void* eventData, 44 | void* userData ) 45 | { 46 | g_PluginManager.RegisterAttributes(); 47 | } 48 | 49 | unsigned int BuildASTCallback( void ) 50 | { 51 | return( g_PluginManager.BuildASTCallback() ); 52 | } 53 | 54 | unsigned int GlobalDeclarationCallback( void ) 55 | { 56 | return( g_PluginManager.GlobalDeclarationCallback() ); 57 | } 58 | 59 | 60 | 61 | static const struct gimple_opt_pass g_BuildASTPass = 62 | { 63 | { 64 | GIMPLE_PASS, 65 | "BuildAST", 66 | (unsigned int)NULL, 67 | &BuildASTPassGate, 68 | &BuildASTCallback, 69 | NULL, 70 | NULL, 71 | 0, 72 | TV_NONE, 73 | PROP_gimple_any, 74 | 0, 75 | 0, 76 | 0, 77 | 0 78 | } 79 | }; 80 | 81 | 82 | static const struct gimple_opt_pass g_GlobalDeclarationPass = 83 | { 84 | { 85 | GIMPLE_PASS, 86 | "DeclareGlobals", 87 | (unsigned int)NULL, 88 | NULL, 89 | &GlobalDeclarationCallback, 90 | NULL, 91 | NULL, 92 | 0, 93 | TV_NONE, 94 | PROP_gimple_any, 95 | 0, 96 | 0, 97 | 0, 98 | 0 99 | } 100 | }; 101 | 102 | 103 | 104 | attribute_spec *g_attributeSpecs; 105 | 106 | 107 | 108 | 109 | PluginManagerImpl::PluginManagerImpl() 110 | : m_ASTBuilt( false ), 111 | m_globalsGenerated( false ), 112 | m_userCallbacks( NULL ) 113 | {} 114 | 115 | 116 | PluginManagerImpl::~PluginManagerImpl() 117 | {} 118 | 119 | 120 | 121 | 122 | void PluginManagerImpl::Initialize( const char* pluginName, 123 | CPPModel::CallbackIfx* callbacks ) 124 | { 125 | m_pluginName = pluginName; 126 | 127 | m_userCallbacks = callbacks; 128 | 129 | RegisterCallbacks( pluginName ); 130 | } 131 | 132 | 133 | 134 | void PluginManagerImpl::RegisterCallbacks( const char* pluginName ) 135 | { 136 | register_callback( pluginName, PLUGIN_ATTRIBUTES, &RegisterAttributesGCCCallback, NULL ); 137 | 138 | 139 | 140 | struct register_pass_info buildASTPassInfo; 141 | 142 | buildASTPassInfo.pass = const_cast( &g_BuildASTPass.pass ); 143 | buildASTPassInfo.reference_pass_name = pass_warn_unused_result.pass.name; 144 | buildASTPassInfo.ref_pass_instance_number = 0; 145 | buildASTPassInfo.pos_op = PASS_POS_INSERT_BEFORE; 146 | 147 | register_callback ( pluginName, PLUGIN_PASS_MANAGER_SETUP, NULL, &buildASTPassInfo ); 148 | 149 | 150 | 151 | struct register_pass_info globalDeclarationPassInfo; 152 | 153 | globalDeclarationPassInfo.pass = const_cast( &g_GlobalDeclarationPass.pass ); 154 | globalDeclarationPassInfo.reference_pass_name = "cfg"; 155 | globalDeclarationPassInfo.ref_pass_instance_number = 0; 156 | globalDeclarationPassInfo.pos_op = PASS_POS_INSERT_BEFORE; 157 | 158 | register_callback ( pluginName, PLUGIN_PASS_MANAGER_SETUP, NULL, &globalDeclarationPassInfo ); 159 | } 160 | 161 | 162 | 163 | 164 | 165 | void PluginManagerImpl::RegisterAttributes( void ) 166 | { 167 | std::unique_ptr attributes = std::move( m_userCallbacks->RegisterAttributes() ); 168 | 169 | if( attributes->empty() ) 170 | { 171 | g_attributeSpecs = NULL; 172 | return; 173 | } 174 | 175 | g_attributeSpecs = new attribute_spec[ attributes->size() + 1 ]; 176 | 177 | int i = 0; 178 | 179 | for( CPPModel::AttributeSpec currentSpec : *attributes ) 180 | { 181 | g_attributeSpecs[i].name = currentSpec.name().c_str(); 182 | g_attributeSpecs[i].min_length = currentSpec.minNumArguments(); 183 | g_attributeSpecs[i].max_length = currentSpec.maxNumArguments(); 184 | 185 | switch( currentSpec.elementRequired() ) 186 | { 187 | case CPPModel::AttributeSpec::RequiredElement::DECL_REQUIRED : 188 | { 189 | g_attributeSpecs[i].decl_required = true; 190 | g_attributeSpecs[i].type_required = false; 191 | g_attributeSpecs[i].function_type_required = false; 192 | } 193 | break; 194 | 195 | case CPPModel::AttributeSpec::RequiredElement::TYPE_REQUIRED : 196 | { 197 | g_attributeSpecs[i].decl_required = false; 198 | g_attributeSpecs[i].type_required = true; 199 | g_attributeSpecs[i].function_type_required = false; 200 | } 201 | break; 202 | 203 | case CPPModel::AttributeSpec::RequiredElement::FUNCTION_TYPE_REQUIRED : 204 | { 205 | g_attributeSpecs[i].decl_required = false; 206 | g_attributeSpecs[i].type_required = false; 207 | g_attributeSpecs[i].function_type_required = true; 208 | } 209 | break; 210 | 211 | case CPPModel::AttributeSpec::RequiredElement::ANY : 212 | { 213 | g_attributeSpecs[i].decl_required = false; 214 | g_attributeSpecs[i].type_required = false; 215 | g_attributeSpecs[i].function_type_required = false; 216 | } 217 | break; 218 | } 219 | 220 | g_attributeSpecs[i].affects_type_identity = currentSpec.affectsTypeIdentity(); 221 | 222 | g_attributeSpecs[i].handler = HandleAttribute; 223 | 224 | i++; 225 | } 226 | 227 | g_attributeSpecs[i].name = NULL; 228 | 229 | register_scoped_attributes( g_attributeSpecs, m_pluginName.c_str() ); 230 | } 231 | 232 | 233 | 234 | bool PluginManagerImpl::BuildASTGate( void ) 235 | { 236 | return( m_ASTBuilt ); 237 | } 238 | 239 | 240 | unsigned int PluginManagerImpl::BuildASTCallback( void ) 241 | { 242 | // Build the dictionary 243 | 244 | m_ASTDictionary.Build(); 245 | 246 | m_ASTBuilt = true; 247 | 248 | // Let the user program know the AST is ready 249 | 250 | m_userCallbacks->ASTReady(); 251 | 252 | // Now is the time to add namespaces 253 | 254 | m_userCallbacks->CreateNamespaces(); 255 | 256 | return( 0 ); 257 | } 258 | 259 | 260 | unsigned int PluginManagerImpl::GlobalDeclarationCallback( void ) 261 | { 262 | std::unique_ptr typeAsTree = GCCInternalsTools::DeclOrTypeBaseTree::convert( cfun->decl ); 263 | 264 | // std::cerr << "Function: " << typeAsTree->identifier() << std::endl; 265 | 266 | if( typeAsTree->identifier().compare( "__static_initialization_and_destruction_0" ) != 0 ) 267 | { 268 | return( 0 ); 269 | } 270 | 271 | if( m_globalsGenerated ) 272 | { 273 | return( 0 ); 274 | } 275 | 276 | m_globalsGenerated = true; 277 | 278 | std::cerr << "Declaring Globals" << std::endl; 279 | 280 | m_userCallbacks->InjectCode(); 281 | 282 | return( 0 ); 283 | } 284 | 285 | } /* namespace GCCInternalsTools */ 286 | 287 | 288 | 289 | 290 | namespace CPPModel 291 | { 292 | PluginManager& GetPluginManager() 293 | { 294 | return( GCCInternalsTools::g_PluginManager ); 295 | } 296 | } 297 | 298 | 299 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/GlobalVars/AddFundamentalArrayValueGlobalVarTest.out: -------------------------------------------------------------------------------- 1 | AddFundamentalArrayValueGlobalVarTest 2 | 3 | Value of test bool array 0: 1 4 | Value of test bool array 1: 0 5 | Value of test bool array 2: 1 6 | Value of test bool array 3: 1 7 | Value of test bool array 4: 0 8 | Value of test bool array 5: 0 9 | Value of test bool array 6: 1 10 | Value of test bool array 7: 1 11 | Value of test bool array 8: 1 12 | Value of test bool array 9: 0 13 | Value of test bool array 10: 0 14 | Value of test bool array 11: 0 15 | 16 | Value of test char array 0: a 17 | Value of test char array 1: b 18 | Value of test char array 2: c 19 | Value of test char array 3: d 20 | Value of test char array 4: e 21 | Value of test char array 5: f 22 | Value of test char array 6: g 23 | Value of test char array 7: h 24 | Value of test char array 8: i 25 | Value of test char array 9: j 26 | Value of test char array 10: k 27 | Value of test char array 11: l 28 | Value of test char array 12: m 29 | Value of test char array 13: n 30 | Value of test char array 14: o 31 | Value of test char array 15: p 32 | Value of test char array 16: q 33 | Value of test char array 17: r 34 | Value of test char array 18: s 35 | Value of test char array 19: t 36 | Value of test char array 20: u 37 | Value of test char array 21: v 38 | Value of test char array 22: w 39 | Value of test char array 23: x 40 | Value of test char array 24: y 41 | Value of test char array 25: z 42 | 43 | Value of test int array 0: 1 44 | Value of test int array 1: 2 45 | Value of test int array 2: 3 46 | Value of test int array 3: 4 47 | Value of test int array 4: 5 48 | Value of test int array 5: 6 49 | Value of test int array 6: 7 50 | Value of test int array 7: 8 51 | Value of test int array 8: 9 52 | Value of test int array 9: 10 53 | Value of test int array 10: 11 54 | Value of test int array 11: 12 55 | 56 | Value of test long array 0: 101 57 | Value of test long array 1: 102 58 | Value of test long array 2: 103 59 | Value of test long array 3: 104 60 | Value of test long array 4: 105 61 | Value of test long array 5: 106 62 | Value of test long array 6: 107 63 | Value of test long array 7: 108 64 | Value of test long array 8: 109 65 | Value of test long array 9: 110 66 | Value of test long array 10: 111 67 | Value of test long array 11: 112 68 | 69 | Value of test float array 0: 1.1 70 | Value of test float array 1: 2.2 71 | Value of test float array 2: 3.3 72 | Value of test float array 3: 4.4 73 | Value of test float array 4: 5.5 74 | Value of test float array 5: 6.6 75 | Value of test float array 6: 7.7 76 | Value of test float array 7: 8.8 77 | Value of test float array 8: 9.9 78 | Value of test float array 9: 10.1 79 | 80 | Value of test double array 0: 2.22507e-308 81 | Value of test double array 1: 1.79769e+308 82 | Value of test double array 2: 3.003 83 | Value of test double array 3: 4.004 84 | Value of test double array 4: 5.005 85 | Value of test double array 5: 6.006 86 | Value of test double array 6: 7.007 87 | Value of test double array 7: 8.008 88 | Value of test double array 8: 9.009 89 | Value of test double array 9: 10.001 90 | 91 | Value of test string array 0: one 92 | Value of test string array 1: two 93 | Value of test string array 2: three 94 | Value of test string array 3: four 95 | Value of test string array 4: five 96 | Value of test string array 5: six 97 | Value of test string array 6: seven 98 | Value of test string array 7: eight 99 | Value of test string array 8: nine 100 | Value of test string array 9: ten 101 | 102 | 103 | 104 | Value of test bool array pointer 0: 1 105 | Value of test bool array pointer 1: 0 106 | Value of test bool array pointer 2: 1 107 | Value of test bool array pointer 3: 1 108 | Value of test bool array pointer 4: 0 109 | Value of test bool array pointer 5: 0 110 | Value of test bool array pointer 6: 1 111 | Value of test bool array pointer 7: 1 112 | Value of test bool array pointer 8: 1 113 | Value of test bool array pointer 9: 0 114 | Value of test bool array pointer 10: 0 115 | Value of test bool array pointer 11: 0 116 | 117 | Value of test char array pointer 0: a 118 | Value of test char array pointer 1: b 119 | Value of test char array pointer 2: c 120 | Value of test char array pointer 3: d 121 | Value of test char array pointer 4: e 122 | Value of test char array pointer 5: f 123 | Value of test char array pointer 6: g 124 | Value of test char array pointer 7: h 125 | Value of test char array pointer 8: i 126 | Value of test char array pointer 9: j 127 | Value of test char array pointer 10: k 128 | Value of test char array pointer 11: l 129 | Value of test char array pointer 12: m 130 | Value of test char array pointer 13: n 131 | Value of test char array pointer 14: o 132 | Value of test char array pointer 15: p 133 | Value of test char array pointer 16: q 134 | Value of test char array pointer 17: r 135 | Value of test char array pointer 18: s 136 | Value of test char array pointer 19: t 137 | Value of test char array pointer 20: u 138 | Value of test char array pointer 21: v 139 | Value of test char array pointer 22: w 140 | Value of test char array pointer 23: x 141 | Value of test char array pointer 24: y 142 | Value of test char array pointer 25: z 143 | 144 | Value of test int array pointer 0: 1 145 | Value of test int array pointer 1: 2 146 | Value of test int array pointer 2: 3 147 | Value of test int array pointer 3: 4 148 | Value of test int array pointer 4: 5 149 | Value of test int array pointer 5: 6 150 | Value of test int array pointer 6: 7 151 | Value of test int array pointer 7: 8 152 | Value of test int array pointer 8: 9 153 | Value of test int array pointer 9: 10 154 | Value of test int array pointer 10: 11 155 | Value of test int array pointer 11: 12 156 | 157 | Value of test long array pointer 0: 101 158 | Value of test long array pointer 1: 102 159 | Value of test long array pointer 2: 103 160 | Value of test long array pointer 3: 104 161 | Value of test long array pointer 4: 105 162 | Value of test long array pointer 5: 106 163 | Value of test long array pointer 6: 107 164 | Value of test long array pointer 7: 108 165 | Value of test long array pointer 8: 109 166 | Value of test long array pointer 9: 110 167 | Value of test long array pointer 10: 111 168 | Value of test long array pointer 11: 112 169 | 170 | Value of test float array pointer 0: 1.1 171 | Value of test float array pointer 1: 2.2 172 | Value of test float array pointer 2: 3.3 173 | Value of test float array pointer 3: 4.4 174 | Value of test float array pointer 4: 5.5 175 | Value of test float array pointer 5: 6.6 176 | Value of test float array pointer 6: 7.7 177 | Value of test float array pointer 7: 8.8 178 | Value of test float array pointer 8: 9.9 179 | Value of test float array pointer 9: 10.1 180 | 181 | Value of test double array pointer 0: 2.22507e-308 182 | Value of test double array pointer 1: 1.79769e+308 183 | Value of test double array pointer 2: 3.003 184 | Value of test double array pointer 3: 4.004 185 | Value of test double array pointer 4: 5.005 186 | Value of test double array pointer 5: 6.006 187 | Value of test double array pointer 6: 7.007 188 | Value of test double array pointer 7: 8.008 189 | Value of test double array pointer 8: 9.009 190 | Value of test double array pointer 9: 10.001 191 | 192 | Value of test string array pointer 0: one 193 | Value of test string array pointer 1: two 194 | Value of test string array pointer 2: three 195 | Value of test string array pointer 3: four 196 | Value of test string array pointer 4: five 197 | Value of test string array pointer 5: six 198 | Value of test string array pointer 6: seven 199 | Value of test string array pointer 7: eight 200 | Value of test string array pointer 8: nine 201 | Value of test string array pointer 9: ten 202 | -------------------------------------------------------------------------------- /GCCInternalsTools/src/DeclTree.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------------- 2 | Copyright (c) 2013 Stephan Friedl. 3 | 4 | All rights reserved. This program and the accompanying materials 5 | are made available under the terms of the GNU Public License v3.0 6 | which accompanies this distribution, and is available at 7 | http://www.gnu.org/licenses/gpl.html 8 | 9 | Contributors: 10 | Stephan Friedl 11 | -------------------------------------------------------------------------------*/ 12 | 13 | 14 | 15 | 16 | #include "ASTDictionary.h" 17 | 18 | #include "config.h" 19 | #include "gcc-plugin.h" 20 | #include "tree.h" 21 | #include "cp/cp-tree.h" 22 | 23 | #include "DeclTree.h" 24 | #include "NamespaceTree.h" 25 | #include "AttributeParser.h" 26 | 27 | 28 | 29 | 30 | 31 | namespace GCCInternalsTools 32 | { 33 | 34 | CPPModel::ConstListPtr DeclTree::attributes() 35 | { 36 | return( GetAttributes( PurposeValueList( DECL_ATTRIBUTES( m_tree )) )); 37 | } 38 | 39 | 40 | const NamespaceTree DeclTree::fullyQualifiedNamespace() const 41 | { 42 | tree namespaceNode; 43 | 44 | // Functions have to be handled distinctly from other declarations 45 | 46 | if(( TREE_CODE( m_tree ) == FUNCTION_DECL ) || ( TREE_CODE( m_tree ) == VAR_DECL )) 47 | { 48 | namespaceNode = DECL_CONTEXT( m_tree ); 49 | } 50 | else 51 | { 52 | namespaceNode = CP_DECL_CONTEXT( TREE_TYPE( m_tree ) ); 53 | } 54 | 55 | return( NamespaceTree( namespaceNode ) ); 56 | 57 | // Functions have to be handled distinctly from Types 58 | /* 59 | if( TREE_CODE( m_tree ) == RECORD_TYPE ) 60 | { 61 | // Types first, they are pretty straightforward. Use CP_DECL_CONTEXT. 62 | 63 | tree& declType = TREE_TYPE( m_tree ); 64 | 65 | // Namespaces can be aliased in the AST, make sure we get the original 66 | 67 | tree& startingScope = CP_DECL_CONTEXT( declType ); 68 | 69 | // If this is the global namespace, return the scope resolution operator 70 | 71 | if( startingScope == global_namespace ) 72 | { 73 | namespaceNodes.push_back( global_namespace ); 74 | } 75 | else if( DECL_NAMESPACE_STD_P( startingScope )) 76 | { 77 | namespaceNodes.push_back( startingScope ); 78 | } 79 | else 80 | { 81 | // We have to build the namespace context by context 82 | 83 | for( tree& currentScope = startingScope; currentScope != global_namespace; currentScope = CP_DECL_CONTEXT( currentScope ) ) 84 | { 85 | if( TREE_CODE( currentScope ) == RECORD_TYPE ) 86 | { 87 | currentScope = TYPE_NAME( currentScope ); 88 | } 89 | 90 | namespaceNodes.push_front( currentScope ); 91 | } 92 | } 93 | } 94 | else 95 | { 96 | // For functions, use DECL_CONTEXT. 97 | // 98 | // Best I can tell, the DECL_CONTEXT for a function is a linked list which has the translation unit decl for the function 99 | // as the last element in the list. If a function is globally scoped, then the context just points to the translation unit. 100 | // If the function is within a namespace, the namespace decl(s) will precede the translation unit decl. 101 | 102 | 103 | tree& functionContext = DECL_CONTEXT( m_tree ); 104 | 105 | if( functionContext == NULL_TREE ) 106 | { 107 | namespaceNodes.push_back( global_namespace ); 108 | } 109 | else 110 | { 111 | tree& originalNamespace = ORIGINAL_NAMESPACE( functionContext ); 112 | 113 | // If this is the global namespace, return the scope resolution operator 114 | 115 | if( TREE_CODE( originalNamespace ) != NAMESPACE_DECL ) 116 | { 117 | namespaceNodes.push_back( global_namespace ); 118 | } 119 | else if( DECL_NAMESPACE_STD_P( originalNamespace )) 120 | { 121 | // If this is the standard library namespace, then return that constant now 122 | 123 | namespaceNodes.push_back( originalNamespace ); 124 | } 125 | else if( TREE_CODE( originalNamespace ) == NAMESPACE_DECL ) 126 | { 127 | // Build the namespace up level by level. For functions, if the original namespace is not 128 | // a namespace decl then we have the global namespace 129 | 130 | for( tree& currentContext = originalNamespace; ( currentContext != NULL ) && ( TREE_CODE( currentContext ) == NAMESPACE_DECL ); currentContext = DECL_CONTEXT( currentContext ) ) 131 | { 132 | namespaceNodes.push_front( currentContext ); 133 | } 134 | } 135 | else 136 | { 137 | namespaceNodes.push_back( global_namespace ); 138 | } 139 | } 140 | } 141 | 142 | // Return the namespace 143 | 144 | return( FullyQualifiedNamespace( namespaceNodes ) ); 145 | */ 146 | 147 | } 148 | 149 | /* 150 | const std::string DeclTree::enclosingNamespace() const 151 | { 152 | std::string declScope = ""; 153 | 154 | // Functions have to be handled distinctly from Types 155 | 156 | if( TREE_CODE( m_tree ) == RECORD_TYPE ) 157 | { 158 | // Types first, they are pretty straightforward. Use CP_DECL_CONTEXT. 159 | 160 | tree& declType = TREE_TYPE( m_tree ); 161 | 162 | // Namespaces can be aliased in the AST, make sure we get the original 163 | 164 | tree& startingScope = CP_DECL_CONTEXT( declType ); 165 | 166 | // If this is the global namespace, return the scope resolution operator 167 | 168 | if( startingScope == global_namespace ) 169 | { 170 | return( CPPModel::SCOPE_RESOLUTION_OPERATOR ); 171 | } 172 | 173 | // If this is the standard library namespace, then return that constant now 174 | 175 | if( DECL_NAMESPACE_STD_P( startingScope )) 176 | { 177 | return( CPPModel::STD_NAMESPACE_LABEL ); 178 | } 179 | 180 | // We have to build the namespace context by context 181 | 182 | for( tree& currentScope = startingScope; currentScope != global_namespace; currentScope = CP_DECL_CONTEXT( currentScope ) ) 183 | { 184 | if( TREE_CODE( currentScope ) == RECORD_TYPE ) 185 | { 186 | currentScope = TYPE_NAME( currentScope ); 187 | } 188 | 189 | declScope = DeclTree( currentScope ).identifier() + CPPModel::SCOPE_RESOLUTION_OPERATOR + declScope; 190 | } 191 | } 192 | else 193 | { 194 | // For functions, use DECL_CONTEXT. 195 | // 196 | // Best I can tell, the DECL_CONTEXT for a function is a linked list which has the translation unit decl for the function 197 | // as the last element in the list. If a function is globally scoped, then the context just points to the translation unit. 198 | // If the function is within a namespace, the namespace decl(s) will precede the translation unit decl. 199 | 200 | 201 | tree& functionContext = DECL_CONTEXT( m_tree ); 202 | 203 | if( functionContext == NULL_TREE ) 204 | { 205 | return( CPPModel::SCOPE_RESOLUTION_OPERATOR ); 206 | } 207 | 208 | tree& originalNamespace = ORIGINAL_NAMESPACE( functionContext ); 209 | 210 | // If this is the global namespace, return the scope resolution operator 211 | 212 | if( TREE_CODE( originalNamespace ) != NAMESPACE_DECL ) 213 | { 214 | return( CPPModel::SCOPE_RESOLUTION_OPERATOR ); 215 | } 216 | 217 | // If this is the standard library namespace, then return that constant now 218 | 219 | if( DECL_NAMESPACE_STD_P( originalNamespace )) 220 | { 221 | return( CPPModel::STD_NAMESPACE_LABEL ); 222 | } 223 | 224 | // Build the namespace up level by level. For functions, if the original namespace is not 225 | // a namespace decl then we have the global namespace 226 | 227 | if( TREE_CODE( originalNamespace ) == NAMESPACE_DECL ) 228 | { 229 | for( tree& currentContext = originalNamespace; ( currentContext != NULL ) && ( TREE_CODE( currentContext ) == NAMESPACE_DECL ); currentContext = DECL_CONTEXT( currentContext ) ) 230 | { 231 | declScope = DeclTree( currentContext ).identifier() + CPPModel::SCOPE_RESOLUTION_OPERATOR + declScope; 232 | } 233 | } 234 | else 235 | { 236 | declScope = CPPModel::SCOPE_RESOLUTION_OPERATOR; 237 | } 238 | } 239 | 240 | // Return the namespace 241 | 242 | return( declScope ); 243 | } 244 | */ 245 | } 246 | 247 | 248 | 249 | 250 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/Functions/FunctionsWithParametersTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | :: 5 | 6 | 7 | TestNamespace:: 8 | 9 | 10 | __cxxabiv1:: 11 | 12 | 13 | 14 | 15 | 16 | __gnu_cxx:: 17 | 18 | 19 | __gnu_debug:: 20 | 21 | 22 | std:: 23 | 24 | 25 | 26 | 27 | 28 | std::__debug:: 29 | 30 | 31 | std::__exception_ptr:: 32 | 33 | 34 | 35 | 36 | 37 | 38 | TestNamespace:: 39 | 40 | FunctionReturningInt 41 | 28424 42 | 43 | ../testCaseSourceCode/Functions/FunctionsWithParametersTestCase.cpp 44 | 21 45 | 1 46 | 6478501 47 | 48 | 49 | 50 | 51 | TestNamespace:: 52 | 53 | FunctionReturningString 54 | 28429 55 | 56 | ../testCaseSourceCode/Functions/FunctionsWithParametersTestCase.cpp 57 | 27 58 | 1 59 | 6479275 60 | 61 | 62 | 63 | 64 | TestNamespace:: 65 | 66 | FunctionReturningVoid 67 | 28420 68 | 69 | ../testCaseSourceCode/Functions/FunctionsWithParametersTestCase.cpp 70 | 18 71 | 1 72 | 6478117 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | TestNamespace:: 82 | 83 | FunctionReturningInt 84 | 28424 85 | 86 | ../testCaseSourceCode/Functions/FunctionsWithParametersTestCase.cpp 87 | 21 88 | 1 89 | 6478501 90 | 91 | 92 | 93 | fundamental 94 | int 95 | 96 | 97 | 98 | 99 | intParameter 100 | 101 | fundamental 102 | int 103 | 104 | 105 | 106 | floatParameter 107 | 108 | fundamental 109 | float 110 | 111 | 112 | 113 | 114 | 115 | 116 | TestNamespace:: 117 | 118 | FunctionReturningString 119 | 28429 120 | 121 | ../testCaseSourceCode/Functions/FunctionsWithParametersTestCase.cpp 122 | 27 123 | 1 124 | 6479275 125 | 126 | 127 | 128 | derived 129 | 130 | reference 131 | 132 | class-or-struct 133 | std::string 134 | 135 | 136 | 137 | 138 | 139 | 140 | stringParameter 141 | 142 | derived 143 | 144 | reference 145 | 146 | class-or-struct 147 | std::string 148 | 149 | 150 | 151 | 152 | 153 | doubleParameter 154 | 155 | fundamental 156 | double 157 | 158 | 159 | 160 | longParameter 161 | 162 | fundamental 163 | long int 164 | 165 | 166 | 167 | 168 | 169 | 170 | TestNamespace:: 171 | 172 | FunctionReturningVoid 173 | 28420 174 | 175 | ../testCaseSourceCode/Functions/FunctionsWithParametersTestCase.cpp 176 | 18 177 | 1 178 | 6478117 179 | 180 | 181 | 182 | fundamental 183 | void 184 | 185 | 186 | 187 | 188 | intParameter 189 | 190 | fundamental 191 | int 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /GCCInternalsUnitTest/expectedResults/GlobalVars/DerivedTypesTestCase.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TestNamespace:: 4 | 5 | refGlobalInt 6 | 2003 7 | 8 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 9 | 52 10 | 1 11 | 15170 12 | 13 | true 14 | 15 | 16 | 17 | TestNamespace:: 18 | 19 | globalInt 20 | 2002 21 | 22 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 23 | 51 24 | 1 25 | 15047 26 | 27 | true 28 | 29 | 30 | 31 | TestNamespace:: 32 | 33 | hdlGlobalFloatWithoutStaticKeyword 34 | 2001 35 | 36 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 37 | 49 38 | 1 39 | 14789 40 | 41 | true 42 | 43 | 44 | 45 | TestNamespace:: 46 | 47 | hdlGlobalFloat 48 | 2000 49 | 50 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 51 | 47 52 | 1 53 | 14538 54 | 55 | true 56 | 57 | 58 | 59 | TestNamespace:: 60 | 61 | ptrGlobalLongWithoutStaticKeyword 62 | 1999 63 | 64 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 65 | 45 66 | 1 67 | 14275 68 | 69 | true 70 | 71 | 72 | 73 | TestNamespace:: 74 | 75 | ptrGlobalLong 76 | 1998 77 | 78 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 79 | 43 80 | 1 81 | 14024 82 | 83 | true 84 | 85 | 86 | 87 | TestNamespace:: 88 | 89 | ptrGlobalClassWithoutStaticKeyword 90 | 1997 91 | 92 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 93 | 41 94 | 1 95 | 13780 96 | 97 | true 98 | 99 | 100 | 101 | TestNamespace:: 102 | 103 | ptrGlobalClass 104 | 1996 105 | 106 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 107 | 39 108 | 1 109 | 13529 110 | 111 | true 112 | 113 | 114 | 115 | TestNamespace:: 116 | 117 | refGlobalInt 118 | 2003 119 | 120 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 121 | 52 122 | 1 123 | 15170 124 | 125 | true 126 | 127 | derived 128 | 129 | reference 130 | 131 | fundamental 132 | int 133 | 134 | 135 | 136 | 137 | 138 | 139 | TestNamespace:: 140 | 141 | globalInt 142 | 2002 143 | 144 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 145 | 51 146 | 1 147 | 15047 148 | 149 | true 150 | 151 | fundamental 152 | int 153 | 154 | 155 | 156 | 157 | TestNamespace:: 158 | 159 | hdlGlobalFloatWithoutStaticKeyword 160 | 2001 161 | 162 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 163 | 49 164 | 1 165 | 14789 166 | 167 | true 168 | 169 | derived 170 | 171 | pointer 172 | pointer 173 | 174 | fundamental 175 | float 176 | 177 | 178 | 179 | 180 | 181 | 182 | TestNamespace:: 183 | 184 | hdlGlobalFloat 185 | 2000 186 | 187 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 188 | 47 189 | 1 190 | 14538 191 | 192 | true 193 | 194 | derived 195 | 196 | pointer 197 | pointer 198 | 199 | fundamental 200 | float 201 | 202 | 203 | 204 | 205 | 206 | 207 | TestNamespace:: 208 | 209 | ptrGlobalLongWithoutStaticKeyword 210 | 1999 211 | 212 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 213 | 45 214 | 1 215 | 14275 216 | 217 | true 218 | 219 | derived 220 | 221 | pointer 222 | 223 | fundamental 224 | long int 225 | 226 | 227 | 228 | 229 | 230 | 231 | TestNamespace:: 232 | 233 | ptrGlobalLong 234 | 1998 235 | 236 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 237 | 43 238 | 1 239 | 14024 240 | 241 | true 242 | 243 | derived 244 | 245 | pointer 246 | 247 | fundamental 248 | long int 249 | 250 | 251 | 252 | 253 | 254 | 255 | TestNamespace:: 256 | 257 | ptrGlobalClassWithoutStaticKeyword 258 | 1997 259 | 260 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 261 | 41 262 | 1 263 | 13780 264 | 265 | true 266 | 267 | derived 268 | 269 | pointer 270 | 271 | class-or-struct 272 | LocalNamespace::LocalClass 273 | 274 | LocalNamespace:: 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | TestNamespace:: 283 | 284 | ptrGlobalClass 285 | 1996 286 | 287 | ../testCaseSourceCode/GlobalVars/DerivedTypesTestCase.cpp 288 | 39 289 | 1 290 | 13529 291 | 292 | true 293 | 294 | derived 295 | 296 | pointer 297 | 298 | class-or-struct 299 | LocalNamespace::LocalClass 300 | 301 | LocalNamespace:: 302 | 303 | 304 | 305 | 306 | 307 | --------------------------------------------------------------------------------