Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java37
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java2138
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java2072
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CLanguageData.java6
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java229
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNodeSelector.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IType.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPPointerToMemberType.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java14
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java50
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArithmeticConversion.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java65
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExpressionTypes.java4
18 files changed, 2296 insertions, 2371 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java
index 9f68e1f51ee..4b1777864bc 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2BaseTest.java
@@ -366,19 +366,20 @@ public class AST2BaseTest extends BaseTestCase {
public int size() { return nameList.size(); }
public void dump() {
- for (int i=0; i<size(); i++) {
+ for (int i= 0; i < size(); i++) {
IASTName name= getName(i);
String parent= name.getParent() != null ? name.getParent().getRawSignature() : "";
- System.out.println(i+": #"+name.getRawSignature()+"# "+parent);
+ System.out.println(i + ": #" + name.getRawSignature() + "# " + parent);
}
}
}
protected void assertInstances(CPPNameCollector collector, IBinding binding, int num) throws Exception {
int count = 0;
- for (int i = 0; i < collector.size(); i++)
+ for (int i = 0; i < collector.size(); i++) {
if (collector.getName(i).resolveBinding() == binding)
count++;
+ }
assertEquals(num, count);
}
@@ -490,11 +491,11 @@ public class AST2BaseTest extends BaseTestCase {
}
protected static <T> T assertInstance(Object o, Class<T> clazz, Class... cs) {
- assertNotNull("Expected object of "+clazz.getName()+" but got a null value", o);
+ assertNotNull("Expected object of " + clazz.getName() + " but got a null value", o);
assertTrue("Expected "+clazz.getName()+" but got "+o.getClass().getName(), clazz.isInstance(o));
for (Class c : cs) {
- assertNotNull("Expected object of "+c.getName()+" but got a null value", o);
- assertTrue("Expected "+c.getName()+" but got "+o.getClass().getName(), c.isInstance(o));
+ assertNotNull("Expected object of " + c.getName() + " but got a null value", o);
+ assertTrue("Expected " + c.getName() + " but got " + o.getClass().getName(), c.isInstance(o));
}
return clazz.cast(o);
}
@@ -516,14 +517,14 @@ public class AST2BaseTest extends BaseTestCase {
this.isCPP= isCPP;
this.tu= parse(contents, isCPP ? ParserLanguage.CPP : ParserLanguage.C, true, false);
}
-
+
public IASTTranslationUnit getTranslationUnit() {
return tu;
}
-
- public IProblemBinding assertProblem(String section, int len) {
+
+ public IProblemBinding assertProblem(String section, int len) {
if (len <= 0)
- len= section.length()+len;
+ len= section.length() + len;
IBinding binding= binding(section, len);
assertTrue("Non-ProblemBinding for name: " + section.substring(0, len),
binding instanceof IProblemBinding);
@@ -532,11 +533,11 @@ public class AST2BaseTest extends BaseTestCase {
public <T extends IBinding> T assertNonProblem(String section, int len) {
if (len <= 0)
- len= section.length()+len;
+ len= section.length() + len;
IBinding binding= binding(section, len);
if (binding instanceof IProblemBinding) {
IProblemBinding problem= (IProblemBinding) binding;
- fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID())+")");
+ fail("ProblemBinding for name: " + section.substring(0, len) + " (" + renderProblemID(problem.getID()) + ")");
}
if (binding == null) {
fail("Null binding resolved for name: " + section.substring(0, len));
@@ -548,7 +549,7 @@ public class AST2BaseTest extends BaseTestCase {
IASTName name= findName(section, len);
if (name != null) {
String selection = section.substring(0, len);
- fail("Found unexpected \""+selection+"\": " + name.resolveBinding());
+ fail("Found unexpected \"" + selection + "\": " + name.resolveBinding());
}
}
@@ -559,7 +560,7 @@ public class AST2BaseTest extends BaseTestCase {
public IASTImplicitName assertImplicitName(String section, int len, Class<?> bindingClass) {
IASTName name = findImplicitName(section, len);
final String selection = section.substring(0, len);
- assertNotNull("did not find \""+selection+"\"", name);
+ assertNotNull("did not find \"" + selection + "\"", name);
assertInstance(name, IASTImplicitName.class);
IASTImplicitNameOwner owner = (IASTImplicitNameOwner) name.getParent();
@@ -587,7 +588,7 @@ public class AST2BaseTest extends BaseTestCase {
public void assertNoImplicitName(String section, int len) {
IASTName name = findImplicitName(section, len);
final String selection = section.substring(0, len);
- assertNull("found name \""+selection+"\"", name);
+ assertNull("found name \"" + selection + "\"", name);
}
public IASTImplicitName[] getImplicitNames(String section, int len) {
@@ -647,7 +648,7 @@ public class AST2BaseTest extends BaseTestCase {
public <T extends IBinding> T assertNonProblem(String section, int len, Class<T> type, Class... cs) {
if (len <= 0)
- len+= section.length();
+ len += section.length();
IBinding binding= binding(section, len);
assertTrue("ProblemBinding for name: " + section.substring(0, len),
!(binding instanceof IProblemBinding));
@@ -661,11 +662,11 @@ public class AST2BaseTest extends BaseTestCase {
private IBinding binding(String section, int len) {
IASTName name = findName(section, len);
final String selection = section.substring(0, len);
- assertNotNull("did not find \""+selection+"\"", name);
+ assertNotNull("did not find \"" + selection + "\"", name);
assertEquals(selection, name.getRawSignature());
IBinding binding = name.resolveBinding();
- assertNotNull("No binding for "+name.getRawSignature(), binding);
+ assertNotNull("No binding for " + name.getRawSignature(), binding);
return name.resolveBinding();
}
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
index ceb452abbd8..c1bb59c1559 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java
@@ -149,7 +149,7 @@ public class AST2CPPTests extends AST2BaseTest {
}
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
- IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(code, ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
assertNoProblemBindings(col);
@@ -231,7 +231,7 @@ public class AST2CPPTests extends AST2BaseTest {
}
private void checkDeclDef(String[] declNames, String[] defNames, IASTDeclaration[] decls) {
- int i= 0, j= 0;
+ int i= 0, j= 0;
for (IASTDeclaration decl : decls) {
if (decl instanceof ICPPASTLinkageSpecification) {
decl= ((ICPPASTLinkageSpecification) decl).getDeclarations()[0];
@@ -282,9 +282,9 @@ public class AST2CPPTests extends AST2BaseTest {
// enum type {A};
// enum type a, b;
- // type c;
+ // type c;
// enum type2 {A, B};
- // enum type2 d, e;
+ // enum type2 d, e;
public void testBug77967() throws Exception {
parseAndCheckBindings(getAboveComment());
}
@@ -353,10 +353,10 @@ public class AST2CPPTests extends AST2BaseTest {
}
// class A { int m(int); };
- // A a;
+ // A a;
// int (A::*pm)(int) = &A::m;
- // int f(){}
- // int f(int);
+ // int f(){}
+ // int f(int);
// int x = f((a.*pm)(5));
public void testBug43242() throws Exception {
parseAndCheckBindings(getAboveComment());
@@ -367,11 +367,11 @@ public class AST2CPPTests extends AST2BaseTest {
}
// int *zzz1 (char);
- // int (*zzz2) (char);
- // int ((*zzz3)) (char);
- // int (*(zzz4)) (char);
+ // int (*zzz2) (char);
+ // int ((*zzz3)) (char);
+ // int (*(zzz4)) (char);
public void testBug40768() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
assertNoProblemBindings(col);
@@ -540,8 +540,8 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(f.getScope(), A.getCompositeScope());
}
- // class A { void f(); };
- // void A::f() { }
+ // class A { void f(); };
+ // void A::f() { }
public void testMethodDefinition() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
@@ -577,8 +577,8 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(A, A2);
}
- // class A { void f(); int i; };
- // void A::f() { i; }
+ // class A { void f(); int i; };
+ // void A::f() { i; }
public void testMemberReference() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
@@ -627,9 +627,9 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(i1, i2);
}
- // class A { int i; };
- // class B : public A { void f(); };
- // void B::f() { i; }
+ // class A { int i; };
+ // class B : public A { void f(); };
+ // void B::f() { i; }
public void testBasicInheritance() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
@@ -682,24 +682,24 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(f2, f3);
}
- // namespace A{
- // int a;
- // }
- // namespace B{
- // using namespace A;
- // }
- // namespace C{
- // using namespace A;
- // }
- //
- // namespace BC{
- // using namespace B;
- // using namespace C;
- // }
- //
- // void f(){
- // BC::a++; //ok
- // }
+ // namespace A{
+ // int a;
+ // }
+ // namespace B{
+ // using namespace A;
+ // }
+ // namespace C{
+ // using namespace A;
+ // }
+ //
+ // namespace BC{
+ // using namespace B;
+ // using namespace C;
+ // }
+ //
+ // void f(){
+ // BC::a++; //ok
+ // }
public void testNamespaces() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
@@ -721,12 +721,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, f, 1);
}
- // int A;
- // class A {};
- // void f() {
- // A++;
- // class A a;
- // }
+ // int A;
+ // class A {};
+ // void f() {
+ // A++;
+ // class A a;
+ // }
public void testNameHiding() throws Exception {
String content= getAboveComment();
IASTTranslationUnit tu = parse(content, ParserLanguage.CPP);
@@ -753,12 +753,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(vA, A);
}
- // class A { void f(); };
- // class B;
- // void A::f() {
- // B b;
- // }
- // int B;
+ // class A { void f(); };
+ // class B;
+ // void A::f() {
+ // B b;
+ // }
+ // int B;
public void testBlockTraversal() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -779,12 +779,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, B2, 1);
}
- // void f(int i);
- // void f(char c);
- // void main() {
- // f(1); //calls f(int);
- // f('b');
- // }
+ // void f(int i);
+ // void f(char c);
+ // void main() {
+ // f(1); //calls f(int);
+ // f('b');
+ // }
public void testFunctionResolution() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -796,13 +796,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, f2, 2);
}
- // typedef struct {
- // int x;
- // } S;
- // void f() {
- // S myS;
- // myS.x = 5;
- // }
+ // typedef struct {
+ // int x;
+ // } S;
+ // void f() {
+ // S myS;
+ // myS.x = 5;
+ // }
public void testSimpleStruct() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -820,11 +820,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, myS, 2);
}
- // struct A;
- // void f(){
- // struct A;
- // struct A * a;
- // }
+ // struct A;
+ // void f(){
+ // struct A;
+ // struct A * a;
+ // }
public void testStructureTags_1() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -842,10 +842,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, A2, 2);
}
- // struct A;
- // void f(){
- // struct A * a;
- // }
+ // struct A;
+ // void f(){
+ // struct A * a;
+ // }
public void testStructureTags_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -862,12 +862,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, A1, 2);
}
- // struct A;
- // struct A * a;
- // struct A { int i; };
- // void f() {
- // a->i;
- // }
+ // struct A;
+ // struct A * a;
+ // struct A { int i; };
+ // void f() {
+ // a->i;
+ // }
public void testStructureDef() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -882,10 +882,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, i, 2);
}
- // struct x {};
- // void f(int x) {
- // struct x i;
- // }
+ // struct x {};
+ // void f(int x) {
+ // struct x i;
+ // }
public void testStructureNamespace() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -896,10 +896,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, x, 2);
}
- // void f(int a);
- // void f(int b){
- // b;
- // }
+ // void f(int a);
+ // void f(int b){
+ // b;
+ // }
public void testFunctionDef() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -916,11 +916,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(scope.getParent(), f.getScope());
}
- // void f();
- // void g() {
- // f();
- // }
- // void f(){ }
+ // void f();
+ // void g() {
+ // f();
+ // }
+ // void f(){ }
public void testSimpleFunctionCall() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -933,11 +933,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, g, 1);
}
- // void f() {
- // for(int i = 0; i < 5; i++) {
- // i;
- // }
- // }
+ // void f() {
+ // for(int i = 0; i < 5; i++) {
+ // i;
+ // }
+ // }
public void testForLoop() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -948,10 +948,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, i, 4);
}
- // struct A { int x; };
- // void f(){
- // ((struct A *) 1)->x;
- // }
+ // struct A { int x; };
+ // void f(){
+ // ((struct A *) 1)->x;
+ // }
public void testExpressionFieldReference() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -964,14 +964,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, x, 2);
}
- // enum hue { red, blue, green };
- // enum hue col, *cp;
- // void f() {
- // col = blue;
- // cp = &col;
- // if (*cp != red)
- // return;
- // }
+ // enum hue { red, blue, green };
+ // enum hue col, *cp;
+ // void f() {
+ // col = blue;
+ // cp = &col;
+ // if (*cp != red)
+ // return;
+ // }
public void testEnumerations() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -1020,10 +1020,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(pt.getType(), A);
}
- // struct A;
- // int * f(int i, char c);
- // void (*g) (A *);
- // void (* (*h)(A**)) (int);
+ // struct A;
+ // int * f(int i, char c);
+ // void (*g) (A *);
+ // void (* (*h)(A**)) (int);
public void testFunctionTypes() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
@@ -1104,18 +1104,18 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(ft.getParameterTypes().length, 1);
}
- // void f();
- // namespace A {
- // void g();
- // }
- // namespace X {
- // using ::f;
- // using A::g;
- // }
- // void h() {
- // X::f();
- // X::g();
- // }
+ // void f();
+ // namespace A {
+ // void g();
+ // }
+ // namespace X {
+ // using ::f;
+ // using A::g;
+ // }
+ // void h() {
+ // X::f();
+ // X::g();
+ // }
public void testUsingDeclaration_1() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -1139,14 +1139,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, using_g.getDelegates()[0], 3); // decl + using-decl + ref
}
- // typedef int Int;
- // void f(int i);
- // void f(const int);
- // void f(Int i);
- // void g(char *);
- // void g(char []);
- // void h(int(a)());
- // void h(int (*) ());
+ // typedef int Int;
+ // void f(int i);
+ // void f(const int);
+ // void f(Int i);
+ // void g(char *);
+ // void g(char []);
+ // void h(int(a)());
+ // void h(int (*) ());
public void testFunctionDeclarations() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -1164,13 +1164,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, h, 2);
}
- // class P1 { public: int x; };
- // class P2 { public: int x; };
- // class B : public P1, public P2 {};
- // void main() {
- // B * b = new B();
- // b->x;
- // }
+ // class P1 { public: int x; };
+ // class P2 { public: int x; };
+ // class B : public P1, public P2 {};
+ // void main() {
+ // B * b = new B();
+ // b->x;
+ // }
public void testProblem_AmbiguousInParent() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -1180,14 +1180,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(x.getID(), IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP);
}
- // class D { public: int x; };
- // class C : public virtual D {};
- // class B : public virtual D {};
- // class A : public B, public C {};
- // void main() {
- // A * a = new A();
- // a->x;
- // }
+ // class D { public: int x; };
+ // class C : public virtual D {};
+ // class B : public virtual D {};
+ // class A : public B, public C {};
+ // void main() {
+ // A * a = new A();
+ // a->x;
+ // }
public void testVirtualParentLookup() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -1209,14 +1209,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, x, 2);
}
- // class D { public: int x; };
- // class C : public D {};
- // class B : public D {};
- // class A : public B, public C {};
- // void main() {
- // A * a = new A();
- // a->x;
- // }
+ // class D { public: int x; };
+ // class C : public D {};
+ // class B : public D {};
+ // class A : public B, public C {};
+ // void main() {
+ // A * a = new A();
+ // a->x;
+ // }
public void testAmbiguousVirtualParentLookup() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -1241,13 +1241,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(collector, x1, 1);
}
- // namespace A {
- // int x;
- // }
- // int x;
- // namespace A {
- // void f() { x; }
- // }
+ // namespace A {
+ // int x;
+ // }
+ // int x;
+ // namespace A {
+ // void f() { x; }
+ // }
public void testExtendedNamespaces() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector collector = new CPPNameCollector();
@@ -1442,7 +1442,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertNotNull(ctors);
// one copy constructor, no implicit default constructor
- assertEquals(1, ctors.length);
+ assertEquals(1, ctors.length);
}
}
@@ -1461,7 +1461,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertNotNull(ctors);
// one copy constructor, one user declared constructor (not a copy constructor)
- assertEquals(2, ctors.length);
+ assertEquals(2, ctors.length);
}
}
@@ -1501,7 +1501,7 @@ public class AST2CPPTests extends AST2BaseTest {
// class A {public: void operator=(A &); };
// class B {protected: void operator=(const B &); };
// class C {private: void operator=(volatile C &) {} };
- // class D {D& operator=(volatile const D &); };
+ // class D {D& operator=(volatile const D &); };
public void testExplicitCopyAssignmentOperator_183160() throws Exception {
BufferedReader br= new BufferedReader(new StringReader(getAboveComment()));
for(String line= br.readLine(); line!=null; line= br.readLine()) {
@@ -1531,9 +1531,9 @@ public class AST2CPPTests extends AST2BaseTest {
}
}
- // namespace A { int x; }
- // namespace B = A;
- // int f(){ B::x; }
+ // namespace A { int x; }
+ // namespace B = A;
+ // int f(){ B::x; }
public void testNamespaceAlias() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1559,10 +1559,10 @@ public class AST2CPPTests extends AST2BaseTest {
// instanceof IASTSimpleDeclaration); //$NON-NLS-1$
// }
- // void f() {
- // int (*p) [2];
- // (&p)[0] = 1;
- // }
+ // void f() {
+ // int (*p) [2];
+ // (&p)[0] = 1;
+ // }
public void testBug84250() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1578,10 +1578,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, p, 2);
}
- // void f() {
- // int (*p) [2];
- // (&p)[0] = 1;
- // }
+ // void f() {
+ // int (*p) [2];
+ // (&p)[0] = 1;
+ // }
public void testBug84250_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1595,8 +1595,8 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(p_ref, p_decl);
}
- // struct s { double i; } f(void);
- // struct s f(void){}
+ // struct s { double i; } f(void);
+ // struct s f(void){}
public void testBug84266() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1630,11 +1630,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertNotNull(s);
}
- // void f(int m, int c[m][m]);
- // void f(int m, int c[m][m]){
- // int x;
- // { int x = x; }
- // }
+ // void f(int m, int c[m][m]);
+ // void f(int m, int c[m][m]){
+ // int x;
+ // { int x = x; }
+ // }
public void testBug84228() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1655,12 +1655,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, x2, 2);
}
- // class A { public : static int n; };
- // int main() {
- // int A;
- // A::n = 42;
- // A b;
- // }
+ // class A { public : static int n; };
+ // int main() {
+ // int A;
+ // A::n = 42;
+ // A b;
+ // }
public void testBug84615() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1693,14 +1693,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(name.getNames()[2].toString(), "ghi"); //$NON-NLS-1$
}
- // namespace Y { void f(float); }
- // namespace A { using namespace Y; void f(int); }
- // namespace B { void f(char); }
- // namespace AB { using namespace A; using namespace B; }
- // void h(){
- // AB::f(1);
- // AB::f(`c`);
- // }
+ // namespace Y { void f(float); }
+ // namespace A { using namespace Y; void f(int); }
+ // namespace B { void f(char); }
+ // namespace AB { using namespace A; using namespace B; }
+ // void h(){
+ // AB::f(1);
+ // AB::f(`c`);
+ // }
public void testBug84679() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP,
false, false);
@@ -1723,14 +1723,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, AB, 3);
}
- // struct Node {
- // struct Node* Next;
- // struct Data* Data;
- // };
- // struct Data {
- // struct Node * node;
- // friend struct Glob;
- // };
+ // struct Node {
+ // struct Node* Next;
+ // struct Data* Data;
+ // };
+ // struct Data {
+ // struct Node * node;
+ // friend struct Glob;
+ // };
public void testBug84692() throws Exception {
// also tests bug 234042.
CPPASTNameBase.sAllowRecursionBindings= false;
@@ -1749,10 +1749,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, Data, 2);
}
- // namespace B { int b; }
- // namespace A { using namespace B; int a; }
- // namespace B { using namespace A; }
- // void f() { B::a++; }
+ // namespace B { int b; }
+ // namespace A { using namespace B; int a; }
+ // namespace B { using namespace A; }
+ // void f() { B::a++; }
public void testBug84686() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1765,18 +1765,18 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(a1, a2);
}
- // struct C {
- // void f();
- // const C& operator=(const C&);
- // };
- // const C& C::operator=(const C& other) {
- // if (this != &other) {
- // this->~C();
- // new (this) C(other);
- // f();
- // }
- // return *this;
- // }
+ // struct C {
+ // void f();
+ // const C& operator=(const C&);
+ // };
+ // const C& C::operator=(const C& other) {
+ // if (this != &other) {
+ // this->~C();
+ // new (this) C(other);
+ // f();
+ // }
+ // return *this;
+ // }
public void testBug84705() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1801,9 +1801,9 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, other, 4);
}
- // class A { void f(); void g() const; };
- // void A::f(){ this; }
- // void A::g() const { *this; }
+ // class A { void f(); void g() const; };
+ // void A::f(){ this; }
+ // void A::g() const { *this; }
public void testThis() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
@@ -1841,16 +1841,16 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(T.getName(), "T"); //$NON-NLS-1$
}
- // namespace NS {
- // class T {};
- // void f(T);
- // }
- // NS::T parm;
- // int main() {
- // f(parm);
- // }
+ // namespace NS {
+ // class T {};
+ // void f(T);
+ // }
+ // NS::T parm;
+ // int main() {
+ // f(parm);
+ // }
public void testArgumentDependantLookup() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -1865,18 +1865,18 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, parm, 2);
}
- // namespace NS1{
- // void f(void *);
- // }
- // namespace NS2{
- // using namespace NS1;
- // class B {};
- // void f(void *);
- // }
- // class A : public NS2::B {} *a;
- // int main() {
- // f(a);
- // }
+ // namespace NS1{
+ // void f(void *);
+ // }
+ // namespace NS2{
+ // using namespace NS1;
+ // class B {};
+ // void f(void *);
+ // }
+ // class A : public NS2::B {} *a;
+ // int main() {
+ // f(a);
+ // }
public void testArgumentDependantLookup_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1892,20 +1892,20 @@ public class AST2CPPTests extends AST2BaseTest {
}
// namespace { int i; } //1
- // void f(){ i; }
- // namespace A {
- // namespace {
- // int i; //2
- // int j;
- // }
- // void g(){ i; }
- // }
- // using namespace A;
- // void h() {
- // i; //ambiguous
- // A::i; //i2
- // j;
- // }
+ // void f(){ i; }
+ // namespace A {
+ // namespace {
+ // int i; //2
+ // int j;
+ // }
+ // void g(){ i; }
+ // }
+ // using namespace A;
+ // void h() {
+ // i; //ambiguous
+ // A::i; //i2
+ // j;
+ // }
public void testBug84610() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1925,13 +1925,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, problem.getID());
}
- // struct B {
- // void mutate();
- // };
- // void g() {
- // B* pb = new B();
- // pb->mutate();
- // }
+ // struct B {
+ // void mutate();
+ // };
+ // void g() {
+ // B* pb = new B();
+ // pb->mutate();
+ // }
public void testBug84703() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1948,10 +1948,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, B, 2);
}
- // struct S { int i; };
- // void f() { ;
- // int S::* pm = &S::i;
- // }
+ // struct S { int i; };
+ // void f() { ;
+ // int S::* pm = &S::i;
+ // }
public void testBug84469() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1979,11 +1979,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(((ICPPPointerToMemberType) t).getType() instanceof IBasicType);
}
- // struct S { int i ; } *s;
- // int S::* pm = &S::i;
- // void f() {
- // s->*pm = 1;
- // }
+ // struct S { int i ; } *s;
+ // int S::* pm = &S::i;
+ // void f() {
+ // s->*pm = 1;
+ // }
public void testBug_PM_() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -1995,14 +1995,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(pm, ref);
}
- // struct S {
- // int i;
- // S* f();
- // } *s;
- // S* (S::* pm) () = &S::f;
- // void foo() {
- // (s->*pm)()->i;
- // }
+ // struct S {
+ // int i;
+ // S* f();
+ // } *s;
+ // S* (S::* pm) () = &S::f;
+ // void foo() {
+ // (s->*pm)()->i;
+ // }
public void testBug_PM_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2080,13 +2080,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(body.getStatements()[0] instanceof IASTDeclarationStatement);
}
- // class A { public: int i; };
- // class B : public A {};
- // void f(int B::*);
- // void g() {
- // int A::* pm = &A::i;
- // f(pm);
- // }
+ // class A { public: int i; };
+ // class B : public A {};
+ // void f(int B::*);
+ // void g() {
+ // int A::* pm = &A::i;
+ // f(pm);
+ // }
public void testPMConversions() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2105,14 +2105,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, pm, 2);
}
- // namespace N {
- // class A { public: int i; };
- // void f(int A::*);
- // }
- // int N::A::* pm = &N::A::i;
- // void g() {
- // f(pm);
- // }
+ // namespace N {
+ // class A { public: int i; };
+ // void f(int A::*);
+ // }
+ // int N::A::* pm = &N::A::i;
+ // void g() {
+ // f(pm);
+ // }
public void testPMKoenig() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2127,18 +2127,18 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, A, 4);
}
- // namespace M {
- // class B { };
- // void f(B*);
- // }
- // namespace N {
- // class A { public: M::B * b; };
- // }
- // M::B* N::A::* pm = &N::A::b;
- // void g() {
- // N::A * a;
- // f(a->*pm);
- // }
+ // namespace M {
+ // class B { };
+ // void f(B*);
+ // }
+ // namespace N {
+ // class A { public: M::B * b; };
+ // }
+ // M::B* N::A::* pm = &N::A::b;
+ // void g() {
+ // N::A * a;
+ // f(a->*pm);
+ // }
public void testPMKoenig_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2159,12 +2159,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, pm, 2);
}
- // class A {
- // friend void set();
- // friend class B;
- // };
- // void set();
- // class B{};
+ // class A {
+ // friend void set();
+ // friend class B;
+ // };
+ // void set();
+ // class B{};
public void testFriend_1() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2185,10 +2185,10 @@ public class AST2CPPTests extends AST2BaseTest {
// class Other {
// void m(); };
- // class A {
- // friend void set();
- // friend void Other::m();
- // };
+ // class A {
+ // friend void set();
+ // friend void Other::m();
+ // };
public void testFriend_Bug275358() throws Exception {
final String code = getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
@@ -2207,8 +2207,8 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(0, declaredMethods.length);
}
- // class A { friend class B; friend class B; };
- // class B{};
+ // class A { friend class B; friend class B; };
+ // class B{};
public void testBug59149() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2224,12 +2224,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(friends[0], B);
}
- // class A {
- // public: class N {};
- // };
- // class B {
- // friend class A::N;
- // };
+ // class A {
+ // public: class N {};
+ // };
+ // class B {
+ // friend class A::N;
+ // };
public void testBug59302() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2248,9 +2248,9 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(N.getFriends().length, 0);
}
- // class A {
- // friend class B *helper();
- // };
+ // class A {
+ // friend class B *helper();
+ // };
public void testBug75482() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2268,12 +2268,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(friends[0], helper);
}
- // void f(int);
- // void f(char);
- // void (*pf) (int) = &f;
- // void foo() {
- // pf = &f;
- // }
+ // void f(int);
+ // void f(char);
+ // void (*pf) (int) = &f;
+ // void foo() {
+ // pf = &f;
+ // }
public void testBug45763_1() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2288,14 +2288,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, f2, 1);
}
- // void f(char);
- // void f(int);
- // void g(void (*)(int)) {}
- // void (*pg)(void(*)(int));
- // void foo() {
- // g(&f);
- // (*pg)(&f);
- // }
+ // void f(char);
+ // void f(int);
+ // void g(void (*)(int)) {}
+ // void (*pg)(void(*)(int));
+ // void foo() {
+ // g(&f);
+ // (*pg)(&f);
+ // }
public void testBug45763_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2312,11 +2312,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, pg, 2);
}
- // void f(int);
- // void f(char);
- // void (* bar ()) (int) {
- // return &f;
- // }
+ // void f(int);
+ // void f(char);
+ // void (* bar ()) (int) {
+ // return &f;
+ // }
public void testBug45763_3() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2331,11 +2331,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, f2, 1);
}
- // void f(int);
- // void f(char);
- // void foo () {
- // (void (*)(int)) &f;
- // }
+ // void f(int);
+ // void f(char);
+ // void foo () {
+ // (void (*)(int)) &f;
+ // }
public void testBug45763_4() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2350,8 +2350,8 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, f2, 1);
}
- // extern int g;
- // int g;
+ // extern int g;
+ // int g;
// void f() { g = 1; }
public void testBug85824() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
@@ -2362,18 +2362,18 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, g, 3);
}
- // struct A {
- // int a2;
- // };
- // struct B : public A {
- // int a1;
- // void f();
- // };
- // int a3;
- // void B::f(){
- // int a4;
- // a;
- // }
+ // struct A {
+ // int a2;
+ // };
+ // struct B : public A {
+ // int a1;
+ // void f();
+ // };
+ // int a3;
+ // void B::f(){
+ // int a4;
+ // a;
+ // }
public void testPrefixLookup() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2404,7 +2404,7 @@ public class AST2CPPTests extends AST2BaseTest {
// }
// void test(){
// v_;
- // }
+ // }
public void testAdditionalNamespaceLookup() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2423,8 +2423,8 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(1, bs.length); // the bindings above
}
- // static void f();
- // void f() {}
+ // static void f();
+ // void f() {}
public void testIsStatic() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2440,7 +2440,7 @@ public class AST2CPPTests extends AST2BaseTest {
// // || __i < 2 || __sign.size() > 1
// // || ((static_cast<part>(__p.field[3]) !=
// // money_base::none)
- // // && __i == 2))
+ // // && __i == 2))
// // return;
// // }
// public void testBug85310() throws Exception {
@@ -2452,15 +2452,15 @@ public class AST2CPPTests extends AST2BaseTest {
// assertNotNull(if_stmt.getCondition());
// }
- // struct B { void mutate(); };
- // struct D1 : B {};
- // struct D2 : B {};
- // void B::mutate() {
- // new (this) D2;
- // }
- // void g() {
- // B* pb = new (p) D1;
- // }
+ // struct B { void mutate(); };
+ // struct D1 : B {};
+ // struct D2 : B {};
+ // void B::mutate() {
+ // new (this) D2;
+ // }
+ // void g() {
+ // B* pb = new (p) D1;
+ // }
public void testBug86267() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2479,18 +2479,18 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, d2_ctor, 1);
}
- // struct C {
- // void f();
- // const C& operator =(const C&);
- // };
- // const C& C::operator = (const C& other) {
- // if (this != &other) {
- // this->~C();
- // new (this) C(other);
- // f();
- // }
- // return *this;
- // }
+ // struct C {
+ // void f();
+ // const C& operator =(const C&);
+ // };
+ // const C& C::operator = (const C& other) {
+ // if (this != &other) {
+ // this->~C();
+ // new (this) C(other);
+ // f();
+ // }
+ // return *this;
+ // }
public void testBug86269() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2509,15 +2509,15 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(other.getName(), "other"); //$NON-NLS-1$
}
- // extern "C" {
- // void printf(const char *);
- // void sprintf(const char *);
- // }
- // void foo(){
- // char *p;
- // printf(p);
- // printf("abc");
- // }
+ // extern "C" {
+ // void printf(const char *);
+ // void sprintf(const char *);
+ // }
+ // void foo(){
+ // char *p;
+ // printf(p);
+ // printf("abc");
+ // }
public void testBug86279() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2531,12 +2531,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(printf, r2);
}
- // struct S;
- // extern S a;
- // void g(S);
- // void h() {
- // g(a);
- // }
+ // struct S;
+ // extern S a;
+ // void g(S);
+ // void h() {
+ // g(a);
+ // }
public void testBug86346() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2561,7 +2561,7 @@ public class AST2CPPTests extends AST2BaseTest {
// void foo() {
// struct B {
// int f();
- // };
+ // };
// int (B::*pb)() = &B::f;
// }
public void testBug84476() throws Exception {
@@ -2577,12 +2577,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(d.getNestedDeclarator().getPointerOperators()[0] instanceof ICPPASTPointerToMember);
}
- // struct T1 {
- // T1 operator() (int x) {
- // return T1(x);
- // }
- // T1(int) {}
- // };
+ // struct T1 {
+ // T1 operator() (int x) {
+ // return T1(x);
+ // }
+ // T1(int) {}
+ // };
public void testBug86336() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2598,10 +2598,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(T1_ctor, ctor2);
}
- // struct S { int i; };
- // void foo() {
- // int S::* pm = &S::i;
- // }
+ // struct S { int i; };
+ // void foo() {
+ // int S::* pm = &S::i;
+ // }
public void testBug86306() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2617,29 +2617,29 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(refs[1], col.getName(7));
}
- // class A {
- // public:
- // template <class T> void f(T);
- // template <class T> struct X { };
- // };
- // class B : public A {
- // public:
- // using A::f<double>; // illformed
- // using A::X<int>; // illformed
- // };
+ // class A {
+ // public:
+ // template <class T> void f(T);
+ // template <class T> struct X { };
+ // };
+ // class B : public A {
+ // public:
+ // using A::f<double>; // illformed
+ // using A::X<int>; // illformed
+ // };
public void testBug86372() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
}
- // void foo() {
- // int i = 42;
- // int a[10];
+ // void foo() {
+ // int i = 42;
+ // int a[10];
// for(int i = 0; i < 10; i++)
- // a[i] = 1;
- // int j = i;
- // }
+ // a[i] = 1;
+ // int j = i;
+ // }
public void testBug86319() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2653,16 +2653,16 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, i2, 4);
}
- // class X { int i, j; };
- // class Y { X x; };
- // void foo() {
- // const Y y;
- // y.x.i++;
- // y.x.j++;
- // Y* p = const_cast<Y*>(&y);
- // p->x.i;
- // p->x.j;
- // }
+ // class X { int i, j; };
+ // class Y { X x; };
+ // void foo() {
+ // const Y y;
+ // y.x.i++;
+ // y.x.j++;
+ // Y* p = const_cast<Y*>(&y);
+ // p->x.i;
+ // p->x.j;
+ // }
public void testBug86350() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2698,11 +2698,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertNotNull(whileStatement.getConditionDeclaration());
}
- // void foo() {
- // const int x = 12;
- // { enum { x = x }; }
- // }
- // enum { RED };
+ // void foo() {
+ // const int x = 12;
+ // { enum { x = x }; }
+ // }
+ // enum { RED };
public void testBug86353() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2729,13 +2729,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(decls[0], col.getName(6));
}
- // class D {};
- // D d1;
- // const D d2;
- // void foo() {
- // typeid(d1) == typeid(d2);
- // typeid(D) == typeid(d2);
- // }
+ // class D {};
+ // D d1;
+ // const D d2;
+ // void foo() {
+ // typeid(d1) == typeid(d2);
+ // typeid(D) == typeid(d2);
+ // }
public void testBug86274() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2751,12 +2751,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, d2, 3);
}
- // void point (int = 3, int = 4);
- // void foo() {
- // point(1, 2);
- // point(1);
- // point();
- // }
+ // void point (int = 3, int = 4);
+ // void foo() {
+ // point(1, 2);
+ // point(1);
+ // point();
+ // }
public void testBug86546() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2767,14 +2767,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, point, 4);
}
- // namespace Outer{
- // int i;
- // namespace Inner {
- // void f() { i++; }
- // int i;
- // void g() { i++; }
- // }
- // }
+ // namespace Outer{
+ // int i;
+ // namespace Inner {
+ // void f() { i++; }
+ // int i;
+ // void g() { i++; }
+ // }
+ // }
public void testBug86358_1() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2787,14 +2787,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, i2, 2);
}
- // namespace Q {
- // namespace V {
- // void f();
- // }
- // void V::f() {}
- // namespace V {
- // }
- // }
+ // namespace Q {
+ // namespace V {
+ // void f();
+ // }
+ // void V::f() {}
+ // namespace V {
+ // }
+ // }
public void testBug86358_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2816,15 +2816,15 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(f2.isGloballyQualified());
}
- // struct B {
- // void f (char);
- // void g (char);
- // };
- // struct D : B {
- // using B::f;
- // void f(int) { f('c'); }
- // void g(int) { g('c'); }
- // };
+ // struct B {
+ // void f (char);
+ // void g (char);
+ // };
+ // struct D : B {
+ // using B::f;
+ // void f(int) { f('c'); }
+ // void g(int) { g('c'); }
+ // };
public void test86371() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2853,10 +2853,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(f.isGloballyQualified());
}
- // namespace Company_with_veryblahblah {}
- // namespace CWVLN = Company_with_veryblahblah;
- // namespace CWVLN = Company_with_veryblahblah;
- // namespace CWVLN = CWVLN;
+ // namespace Company_with_veryblahblah {}
+ // namespace CWVLN = Company_with_veryblahblah;
+ // namespace CWVLN = Company_with_veryblahblah;
+ // namespace CWVLN = CWVLN;
public void testBug86369() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2893,11 +2893,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(decls[2], col.getName(5));
}
- // namespace A {
- // void f(char);
- // void f(int);
- // }
- // using A::f;
+ // namespace A {
+ // void f(char);
+ // void f(int);
+ // }
+ // using A::f;
public void testBug86470_1() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2923,20 +2923,20 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(decls[0], col.getName(1));
}
- // namespace A {
- // void f(int);
- // void f(double);
- // }
- // namespace B {
- // void f(int);
- // void f(double);
- // void f(char);
- // }
- // void g() {
- // using A::f;
- // using B::f;
- // f('c');
- // }
+ // namespace A {
+ // void f(int);
+ // void f(double);
+ // }
+ // namespace B {
+ // void f(int);
+ // void f(double);
+ // void f(char);
+ // }
+ // void g() {
+ // using A::f;
+ // using B::f;
+ // f('c');
+ // }
public void testBug86470_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2947,15 +2947,15 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(f_decl, f_ref);
}
- // namespace A {
- // struct g {};
- // void g (char);
- // }
- // void f() {
- // using A::g;
- // g('a');
- // struct g gg;
- // }
+ // namespace A {
+ // struct g {};
+ // void g (char);
+ // }
+ // void f() {
+ // using A::g;
+ // g('a');
+ // struct g gg;
+ // }
public void testBug86470_3() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -2978,18 +2978,18 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(decls[2], col.getName(7));
}
- // namespace A {
- // int x;
- // }
- // namespace B {
- // struct x {};
- // }
- // void f() {
- // using A::x;
- // using B::x;
- // x = 1;
- // struct x xx;
- // }
+ // namespace A {
+ // int x;
+ // }
+ // namespace B {
+ // struct x {};
+ // }
+ // void f() {
+ // using A::x;
+ // using B::x;
+ // x = 1;
+ // struct x xx;
+ // }
public void testBug86470_4() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3020,15 +3020,15 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(x_struct.isGloballyQualified());
}
- // namespace A {
- // void f(int);
- // void f(double);
- // }
- // void g() {
- // void f(char);
- // using A::f;
- // f(3.5);
- // }
+ // namespace A {
+ // void f(int);
+ // void f(double);
+ // }
+ // void g() {
+ // void f(char);
+ // using A::f;
+ // f(3.5);
+ // }
public void testBug86470_5() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3050,15 +3050,15 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(f.isGloballyQualified());
}
- // class B;
- // class A {
- // int i;
- // friend void f(B *);
- // };
- // class B : public A {};
- // void f(B* p) {
- // p->i = 1;
- // }
+ // class B;
+ // class A {
+ // int i;
+ // friend void f(B *);
+ // };
+ // class B : public A {};
+ // void f(B* p) {
+ // p->i = 1;
+ // }
public void testBug86678() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3073,12 +3073,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, p, 3);
}
- // int printf(const char *, ...);
- // void foo(){
- // int a, b;
- // printf("hello");
- // printf("a=%d b=%d", a, b);
- // }
+ // int printf(const char *, ...);
+ // void foo(){
+ // int a, b;
+ // printf("hello");
+ // printf("a=%d b=%d", a, b);
+ // }
public void testBug86543() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3088,10 +3088,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, printf, 3);
}
- // int max(int a, int b, int c) {
- // int m = (a > b) ? a : b;
- // return (m > c) ? m : c;
- // }
+ // int max(int a, int b, int c) {
+ // int m = (a > b) ? a : b;
+ // return (m > c) ? m : c;
+ // }
public void testBug86554() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3112,10 +3112,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, c, 3);
}
- // int g();
- // struct X { static int g(); };
- // struct Y : X { static int i ; };
- // int Y::i = g();
+ // int g();
+ // struct X { static int g(); };
+ // struct Y : X { static int i ; };
+ // int Y::i = g();
public void testBug86621() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3137,22 +3137,22 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, g2, 2);
}
- // class V { int f(); int x; };
- // class W { int g(); int y; };
- // class B : public virtual V, public W {
- // int f(); int x;
- // int g(); int y;
- // };
- // class C : public virtual V, public W {};
- // class D : public B, public C {
- // void foo();
- // };
- // void D::foo(){
- // x++;
- // f();
- // y++;
- // g();
- // }
+ // class V { int f(); int x; };
+ // class W { int g(); int y; };
+ // class B : public virtual V, public W {
+ // int f(); int x;
+ // int g(); int y;
+ // };
+ // class C : public virtual V, public W {};
+ // class D : public B, public C {
+ // void foo();
+ // };
+ // void D::foo(){
+ // x++;
+ // f();
+ // y++;
+ // g();
+ // }
public void testBug86649() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3181,10 +3181,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, f, 2);
}
- // struct C {
- // int c;
- // C() : c(0) { }
- // };
+ // struct C {
+ // int c;
+ // C() : c(0) { }
+ // };
public void testBug86827() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3203,12 +3203,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(refs[0], col.getName(3));
}
- // void f(int par) {
- // int v1;
- // {
- // int v2;
- // }
- // }
+ // void f(int par) {
+ // int v1;
+ // {
+ // int v2;
+ // }
+ // }
public void testFind_1() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3231,12 +3231,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(bs[0], v1);
}
- // class A { int a; };
- // class B : public A {
- // void f();
- // };
- // void B::f() {
- // }
+ // class A { int a; };
+ // class B : public A {
+ // void f();
+ // };
+ // void B::f() {
+ // }
public void testFind_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3261,14 +3261,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(bs[0], A);
}
- // namespace A {
- // void f(int);
- // void f(double);
- // }
- // void g() {
- // void f(char);
- // using A::f;
- // }
+ // namespace A {
+ // void f(int);
+ // void f(double);
+ // }
+ // void g() {
+ // void f(char);
+ // using A::f;
+ // }
public void testFind_3() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3293,20 +3293,20 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(((ICPPBinding) bs[1]).isGloballyQualified());
}
- // namespace A {
- // struct f;
- // void f();
- // }
- // namespace B {
- // void f(int);
- // }
- // namespace C {
- // using namespace B;
- // }
- // void g(){
- // using namespace A;
- // using namespace C;
- // }
+ // namespace A {
+ // struct f;
+ // void f();
+ // }
+ // namespace B {
+ // void f(int);
+ // }
+ // namespace C {
+ // using namespace B;
+ // }
+ // void g(){
+ // using namespace A;
+ // using namespace C;
+ // }
public void testFind_4() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3360,14 +3360,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(classType.getQualifiedName()[0], "A");
}
- // class A {
- // int a;
- // void fa();
- // };
- // class B : public A {
- // int b;
- // void fb();
- // };
+ // class A {
+ // int a;
+ // void fa();
+ // };
+ // class B : public A {
+ // int b;
+ // void fb();
+ // };
public void testGets() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3484,7 +3484,7 @@ public class AST2CPPTests extends AST2BaseTest {
// //$NON-NLS-1$
// CPPNameCollector col = new CPPNameCollector();
// tu.accept(col);
- //
+ //
// assertTrue(col.getName(0).resolveBinding() instanceof IVariable);
// IProblemBinding p = (IProblemBinding) col.getName(1).resolveBinding();
// assertEquals(p.getID(), IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
@@ -3501,13 +3501,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(p.getID(), IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
}
- // namespace A { int i; }
- // namespace B = A;
- // void f() {
- // B::i;
- // }
+ // namespace A { int i; }
+ // namespace B = A;
+ // void f() {
+ // B::i;
+ // }
public void testNamespaceAlias_2() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3529,13 +3529,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(alias.isGloballyQualified());
}
- // class A{};
- // class B : public A {
- // B () : A() {}
- // };
+ // class A{};
+ // class B : public A {
+ // B () : A() {}
+ // };
public void testBug89539() throws Exception {
String content= getAboveComment();
- IASTTranslationUnit tu = parse(content, ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(content, ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3546,20 +3546,20 @@ public class AST2CPPTests extends AST2BaseTest {
ICPPConstructor A3 = (ICPPConstructor) col.getName(4).resolveBinding();
assertSame(A3.getScope(), A1.getCompositeScope());
- tu = parse(content, ParserLanguage.CPP);
+ tu = parse(content, ParserLanguage.CPP);
col = new CPPNameCollector();
tu.accept(col);
assertTrue(col.getName(4).resolveBinding() instanceof ICPPConstructor);
}
- // class B * b;
- // class A {
- // A * a;
- // };
- // class A;
+ // class B * b;
+ // class A {
+ // A * a;
+ // };
+ // class A;
public void testBug89851() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3587,15 +3587,15 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(bs[1], f2);
}
- // class A {
- // enum type { t1, t2 };
- // void f(type t);
- // };
- // class B : public A {
- // void g() {
- // f(A::t1);
- // }
- // };
+ // class A {
+ // enum type { t1, t2 };
+ // void f(type t);
+ // };
+ // class B : public A {
+ // void g() {
+ // f(A::t1);
+ // }
+ // };
public void testBug90039() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3608,9 +3608,9 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, t1, 3);
}
- // void f(void) {
- // enum { one };
- // }
+ // void f(void) {
+ // enum { one };
+ // }
public void testBug90039_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3628,7 +3628,7 @@ public class AST2CPPTests extends AST2BaseTest {
// char& operator[](unsigned int);
// };
public void testOperatorConversionNames() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3648,12 +3648,12 @@ public class AST2CPPTests extends AST2BaseTest {
}
- // class X { operator int(); };
- // X::operator int() { }
- // template <class A,B> class X<A,C> { operator int(); };
- // template <class A,B> X<A,C>::operator int() { }
+ // class X { operator int(); };
+ // X::operator int() { }
+ // template <class A,B> class X<A,C> { operator int(); };
+ // template <class A,B> X<A,C>::operator int() { }
public void testBug36769B() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3779,12 +3779,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(((ITypedef) binding).getType() instanceof IFunctionType);
}
- // void f(int);
- // void foo(){
- // f((1, 2));
- // }
+ // void f(int);
+ // void foo(){
+ // f((1, 2));
+ // }
public void testBug90616() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3814,11 +3814,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(f1.getScope(), X.getCompositeScope());
}
- // class X { };
- // X x;
- // class X { };
+ // class X { };
+ // X x;
+ // class X { };
public void testBug90662() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3830,10 +3830,10 @@ public class AST2CPPTests extends AST2BaseTest {
IProblemBinding.SEMANTIC_INVALID_REDEFINITION);
}
- // struct C {
+ // struct C {
// void* operator new [ ] (unsigned int);
// void* operator new (unsigned int);
- // void operator delete [ ] (void *);
+ // void operator delete [ ] (void *);
// void operator delete (void *);
// const C& operator+=(const C&);
// const C& operator -= (const C&);
@@ -3871,11 +3871,11 @@ public class AST2CPPTests extends AST2BaseTest {
// const C& operator &(const C&);
// const C& operator |(const C&);
// const C& operator ~ (const C&);
- // const C& operator
+ // const C& operator
// ! /**/ (const C&);
// const C& operator <(const C&);
// const C& operator>(const C&);
- // };
+ // };
public void testOperatorNames() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -3926,16 +3926,16 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(col.getName(158).toString(), "operator >"); //$NON-NLS-1$
}
- // typedef int I;
- // typedef int I;
- // typedef I I;
- // class A {
- // typedef char I;
- // typedef char I;
- // typedef I I;
- // };
+ // typedef int I;
+ // typedef int I;
+ // typedef I I;
+ // class A {
+ // typedef char I;
+ // typedef char I;
+ // typedef I I;
+ // };
public void testBug90623() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3964,11 +3964,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(((IBasicType) I8.getType()).getType(), IBasicType.t_char);
}
- // typedef int I;
- // void f11(I i);
- // void main(){ f a; }
+ // typedef int I;
+ // void f11(I i);
+ // void main(){ f a; }
public void testBug90623_2() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3976,16 +3976,16 @@ public class AST2CPPTests extends AST2BaseTest {
f.getCompletionContext().findBindings(f, true);
}
- // class X {
- // X(const X &);
- // };
- // class Y {
- // operator X ();
- // };
- // Y y;
- // X x = new X(y);
+ // class X {
+ // X(const X &);
+ // };
+ // class Y {
+ // operator X ();
+ // };
+ // Y y;
+ // X x = new X(y);
public void testBug90654_1() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -3994,14 +3994,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(ctor, ctor1);
}
- // struct A {
- // operator short();
- // } a;
- // int f(int);
- // int f(float);
- // int x = f(a);
+ // struct A {
+ // operator short();
+ // } a;
+ // int f(int);
+ // int f(float);
+ // int x = f(a);
public void testBug90654_2() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4010,16 +4010,16 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(f1, f2);
}
- // struct A {};
- // struct B : public A {
- // B& operator = (const B &);
- // };
- // B& B::operator = (const B & s){
- // this->A::operator=(s);
- // return *this;
- // }
+ // struct A {};
+ // struct B : public A {
+ // B& operator = (const B &);
+ // };
+ // B& B::operator = (const B & s){
+ // this->A::operator=(s);
+ // return *this;
+ // }
public void testBug90653() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4035,12 +4035,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(op, implicit);
}
- // void f(char *);
- // void foo() {
- // f("test");
- // }
+ // void f(char *);
+ // void foo() {
+ // f("test");
+ // }
public void testBug86618() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4048,13 +4048,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, f, 2);
}
- // void f(int (*pf) (char));
- // int g(char);
- // void foo () {
- // f(g) ;
- // }
+ // void f(int (*pf) (char));
+ // int g(char);
+ // void foo () {
+ // f(g) ;
+ // }
public void testBug45129() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4068,12 +4068,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(g1, g2);
}
- // class ABC {
+ // class ABC {
// class DEF { };
// static int GHI;
- // };
+ // };
// int ABC::GHI = 77; // ray bourque
- // int f() {
+ // int f() {
// int value;
// ABC::DEF * var;
// ABC::GHI * value;
@@ -4088,12 +4088,12 @@ public class AST2CPPTests extends AST2BaseTest {
}
- // void f(){
- // union { int a; char* p; };
- // a = 1;
- // }
+ // void f(){
+ // union { int a; char* p; };
+ // a = 1;
+ // }
public void testBug86639() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4102,12 +4102,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(a, a2);
}
- // void f () {
- // int aa1, aa2;
- // a;
- // }
+ // void f () {
+ // int aa1, aa2;
+ // a;
+ // }
public void testBug80940() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4121,18 +4121,18 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(bs[1], a2);
}
- // struct Ex {
- // int d();
- // int d() const;
- // };
- // int Ex::d() {}
- // int Ex::d() const {}
- // void f() {
- // const Ex * e;
- // e->d();
- // }
+ // struct Ex {
+ // int d();
+ // int d() const;
+ // };
+ // int Ex::d() {}
+ // int Ex::d() const {}
+ // void f() {
+ // const Ex * e;
+ // e->d();
+ // }
public void testBug77024() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4154,12 +4154,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(d2, r);
}
- // class Point {
- // Point() : xCoord(0) {}
- // int xCoord;
- // };
+ // class Point {
+ // Point() : xCoord(0) {}
+ // int xCoord;
+ // };
public void testBug91773() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4187,10 +4187,10 @@ public class AST2CPPTests extends AST2BaseTest {
parse(code, ParserLanguage.CPP, true, false);
}
- // class Dummy { int v(); int d; };
- // void Dummy::v(int){ d++; }
+ // class Dummy { int v(); int d; };
+ // void Dummy::v(int){ d++; }
public void testBug92882() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4200,15 +4200,15 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(d1, d2);
}
- // void f(int, int);
- // void f(int, int = 3);
- // void f(int = 2, int);
- // void g() {
- // f(3);
- // f();
- // }
+ // void f(int, int);
+ // void f(int, int = 3);
+ // void f(int = 2, int);
+ // void g() {
+ // f(3);
+ // f();
+ // }
public void testBug86547() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -4270,11 +4270,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertNoProblemBindings(nameResolver);
}
- // class C {
- // static const int n = 1;
- // static int arr[ n ];
- // };
- // int C::arr[n];
+ // class C {
+ // static const int n = 1;
+ // static int arr[ n ];
+ // };
+ // int C::arr[n];
public void testBug90610() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4286,20 +4286,20 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstances(col, n, 3);
}
- // int a;
- // extern int b;
- // extern int c = 1;
- // int f();
- // int f(int p){}
- // struct S;
- // struct S { int d; };
- // struct X {
- // static int y;
- // };
- // namespace N {}
- // int X::y = 1;
- // int (*g(int))(int);
- // int (*pf)(int);
+ // int a;
+ // extern int b;
+ // extern int c = 1;
+ // int f();
+ // int f(int p){}
+ // struct S;
+ // struct S { int d; };
+ // struct X {
+ // static int y;
+ // };
+ // namespace N {}
+ // int X::y = 1;
+ // int (*g(int))(int);
+ // int (*pf)(int);
public void testDeclDefn() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4322,10 +4322,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(col.getName(18).isDefinition()); // pf
}
- // int f(double);
- // int f(int);
- // int (&rfi)(int) = f;
- // int (&rfd)(double) = f;
+ // int f(double);
+ // int f(int);
+ // int (&rfi)(int) = f;
+ // int (&rfd)(double) = f;
public void testBug95200() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4362,11 +4362,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(ctor, ctors[1]);
}
- // void f(char *);
- // void g(){
- // char x[100];
- // f(x);
- // }
+ // void f(char *);
+ // void g(){
+ // char x[100];
+ // f(x);
+ // }
public void testBug95461() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4377,7 +4377,7 @@ public class AST2CPPTests extends AST2BaseTest {
}
// class A { };
- // int f() {
+ // int f() {
// A * b = 0;
// A & c = 0;
// }
@@ -4396,7 +4396,7 @@ public class AST2CPPTests extends AST2BaseTest {
}
// struct A {
- // int a;
+ // int a;
// };
// struct B: virtual A { };
// struct C: B { };
@@ -4489,11 +4489,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(f.getNestedDeclarator().getName().toString(), "pfi"); //$NON-NLS-1$
}
- // class X { public: int bar; };
- // void f(){
- // X a[10];
- // a[0].bar;
- // }
+ // class X { public: int bar; };
+ // void f(){
+ // X a[10];
+ // a[0].bar;
+ // }
public void testBug95484() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4503,10 +4503,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(bar, col.getName(6).resolveBinding());
}
- // int strcmp(const char *);
- // void f(const char * const * argv){
- // strcmp(*argv);
- // }
+ // int strcmp(const char *);
+ // void f(const char * const * argv){
+ // strcmp(*argv);
+ // }
public void testBug95419() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4516,14 +4516,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(strcmp, col.getName(4).resolveBinding());
}
- // class Other;
- // class Base {
- // public: Base(Other *);
- // };
- // class Sub : public Base {
- // public: Sub(Other *);
- // };
- // Sub::Sub(Other * b) : Base(b) {}
+ // class Other;
+ // class Base {
+ // public: Base(Other *);
+ // };
+ // class Sub : public Base {
+ // public: Sub(Other *);
+ // };
+ // Sub::Sub(Other * b) : Base(b) {}
public void testBug95673() throws Exception {
BindingAssertionHelper ba= getAssertionHelper();
@@ -4532,12 +4532,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(ctor, ctor2);
}
- // void mem(void *, const void *);
- // void f() {
- // char *x; int offset;
- // mem(x, "FUNC");
- // mem(x + offset, "FUNC2");
- // }
+ // void mem(void *, const void *);
+ // void f() {
+ // char *x; int offset;
+ // mem(x, "FUNC");
+ // mem(x + offset, "FUNC2");
+ // }
public void testBug95768() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4548,13 +4548,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(mem, col.getName(8).resolveBinding());
}
- // void trace(const void *);
- // class Foo {
- // public: int import();
- // };
- // int Foo::import(){
- // trace(this);
- // }
+ // void trace(const void *);
+ // class Foo {
+ // public: int import();
+ // };
+ // int Foo::import(){
+ // trace(this);
+ // }
public void testBug95741() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4564,13 +4564,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(trace, col.getName(7).resolveBinding());
}
- // class RTCharacter {
- // char value;
- // public: operator char (void) const;
- // };
- // RTCharacter::operator char(void)const {
- // return value;
- // }
+ // class RTCharacter {
+ // char value;
+ // public: operator char (void) const;
+ // };
+ // RTCharacter::operator char(void)const {
+ // return value;
+ // }
public void testBug95692() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4580,11 +4580,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(op, col.getName(6).resolveBinding());
}
- // int str(const char *);
- // void f(){
- // str(0);
- // str(00); str(0x0);
- // }
+ // int str(const char *);
+ // void f(){
+ // str(0);
+ // str(00); str(0x0);
+ // }
public void testBug95734() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4596,12 +4596,12 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(str, col.getName(5).resolveBinding());
}
- // int str(bool);
- // enum { ONE };
- // void f(char * p){
- // str(1.2);
- // str(ONE); str(p);
- // }
+ // int str(bool);
+ // enum { ONE };
+ // void f(char * p){
+ // str(1.2);
+ // str(ONE); str(p);
+ // }
public void testBug95734_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4660,13 +4660,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(d.getName().resolveBinding() instanceof IVariable);
}
- // typedef struct xs {
- // int state;
- // } xs;
- // void f(xs *ci) {
- // ci->state;
- // (ci - 1)->state;
- // }
+ // typedef struct xs {
+ // int state;
+ // } xs;
+ // void f(xs *ci) {
+ // ci->state;
+ // (ci - 1)->state;
+ // }
public void testBug95714() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4689,13 +4689,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals(((IASTSimpleDeclSpecifier) ((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
}
- // class _A {
- // static int i;
- // };
- // typedef _A A;
- // void f(){
- // A::i++;
- // }
+ // class _A {
+ // static int i;
+ // };
+ // typedef _A A;
+ // void f(){
+ // A::i++;
+ // }
public void testTypedefQualified() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4720,11 +4720,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertNoProblemBindings(col);
}
- // void copy(void *);
- // typedef struct {} A;
- // void f(A * a) {
- // copy(a);
- // }
+ // void copy(void *);
+ // typedef struct {} A;
+ // void f(A * a) {
+ // copy(a);
+ // }
public void testBug96655() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4738,11 +4738,11 @@ public class AST2CPPTests extends AST2BaseTest {
parse("int x; // comment \r\n", ParserLanguage.CPP, false, true); //$NON-NLS-1$
}
- // struct A {};
- // void copy(A *);
- // void f() {
- // copy(new A());
- // }
+ // struct A {};
+ // void copy(A *);
+ // void f() {
+ // copy(new A());
+ // }
public void testNewExpressionType() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4752,9 +4752,9 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(copy, col.getName(5).resolveBinding());
}
- // class A {
- // A(int i = 0);
- // };
+ // class A {
+ // A(int i = 0);
+ // };
public void testDefaultConstructor() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4768,20 +4768,20 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(cs[1], ctor);
}
- // class C { public: int foo; };
- // class B {
- // C* operator ->();
- // C& operator [] (int);
- // };
- // void f(){
- // B b;
- // b->foo;
- // b[0].foo;
- // }
+ // class C { public: int foo; };
+ // class B {
+ // C* operator ->();
+ // C& operator [] (int);
+ // };
+ // void f(){
+ // B b;
+ // b->foo;
+ // b[0].foo;
+ // }
public void testBug91707() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
- tu.accept(col);
+ tu.accept(col);
ICPPField foo = (ICPPField) col.getName(1).resolveBinding();
@@ -4789,16 +4789,16 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(foo, col.getName(14).resolveBinding());
}
- // class A;
- // class A {
- // class B;
- // class C {};
- // };
- // class A::B{};
+ // class A;
+ // class A {
+ // class B;
+ // class C {};
+ // };
+ // class A::B{};
public void testBug92425() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
- tu.accept(col);
+ tu.accept(col);
ICPPClassType A = (ICPPClassType) col.getName(0).resolveBinding();
ICPPClassType B = (ICPPClassType) col.getName(2).resolveBinding();
@@ -4810,14 +4810,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(classes[1], C);
}
- // namespace A {
- // struct F {} f;
- // void f(int a) {}
- // }
+ // namespace A {
+ // struct F {} f;
+ // void f(int a) {}
+ // }
public void testBug92425_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
- tu.accept(col);
+ tu.accept(col);
ICPPNamespace A = (ICPPNamespace) col.getName(0).resolveBinding();
IBinding [] bindings = A.getMemberBindings();
@@ -4827,14 +4827,14 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(bindings[2], col.getName(3).resolveBinding());
}
- // A< B< C< D< E< F< G< H<int> > > > > > > > a;
- // int A::B<int>::* b;
+ // A< B< C< D< E< F< G< H<int> > > > > > > > a;
+ // int A::B<int>::* b;
public void testBug98704() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP);
}
- // void f();
- // void f(void) {}
+ // void f();
+ // void f(void) {}
public void testBug_AIOOBE() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4846,9 +4846,9 @@ public class AST2CPPTests extends AST2BaseTest {
assertNotNull(p);
}
- // void f(const int);
- // void f(int);
- // void g() { f(1); }
+ // void f(const int);
+ // void f(int);
+ // void g() { f(1); }
public void testRankingQualificationConversions_a() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4917,21 +4917,21 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(i1, ref);
}
- // namespace n {
- // namespace m {
- // class A;
- // }
- // }
- // namespace n {
- // namespace m {
- // class A { void f(); };
- // }
- // }
- // namespace n {
- // namespace m {
- // void A::f(){}
- // }
- // }
+ // namespace n {
+ // namespace m {
+ // class A;
+ // }
+ // }
+ // namespace n {
+ // namespace m {
+ // class A { void f(); };
+ // }
+ // }
+ // namespace n {
+ // namespace m {
+ // void A::f(){}
+ // }
+ // }
public void testBug98818() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4944,21 +4944,21 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(m, col.getName(4).resolveBinding());
assertSame(m, col.getName(8).resolveBinding());
- ICPPClassType A = (ICPPClassType) col.getName(2).resolveBinding();
+ ICPPClassType A = (ICPPClassType) col.getName(2).resolveBinding();
assertSame(A, col.getName(5).resolveBinding());
ICPPMethod f = (ICPPMethod) col.getName(9).resolveBinding();
assertSame(f, col.getName(11).resolveBinding());
}
- // struct A {
- // struct { int i; } B;
- // struct { int j; } C;
- // };
- // void f(){
- // A a;
- // a.B.i; a.C.j;
- // }
+ // struct A {
+ // struct { int i; } B;
+ // struct { int j; } C;
+ // };
+ // void f(){
+ // A a;
+ // a.B.i; a.C.j;
+ // }
public void testAnonymousStructures() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
@@ -4979,7 +4979,7 @@ public class AST2CPPTests extends AST2BaseTest {
// void f2() {
// f1(__null);
// }
- public void testBug240567() throws Exception {
+ public void testBug240567() throws Exception {
BindingAssertionHelper bh= getAssertionHelper();
bh.assertNonProblem("f1(__null", 2, ICPPFunction.class);
}
@@ -5002,24 +5002,24 @@ public class AST2CPPTests extends AST2BaseTest {
IASTTranslationUnit tu = parse("void foo() { for(int i = 0; int j = 0; ++i) {} }", ParserLanguage.CPP); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
- assertNoProblemBindings(col);
+ assertNoProblemBindings(col);
}
- // void f(){
- // if (int x = 1) x++;
- // else x--;
- // while(int y = 2)
- // y++;
- // for(int a = 1; int b = 2; b++){
- // a++; b++;
- // }
- // }
+ // void f(){
+ // if (int x = 1) x++;
+ // else x--;
+ // while(int y = 2)
+ // y++;
+ // for(int a = 1; int b = 2; b++){
+ // a++; b++;
+ // }
+ // }
public void testBug84478_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
- assertNoProblemBindings(col);
+ assertNoProblemBindings(col);
IVariable x = (IVariable) col.getName(1).resolveBinding();
assertSame(x, col.getName(2).resolveBinding());
assertSame(x, col.getName(3).resolveBinding());
@@ -5034,10 +5034,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(b, col.getName(10).resolveBinding());
}
- // void free(void*);
- // void f(char** p) {
+ // void free(void*);
+ // void f(char** p) {
// free(p);
- // }
+ // }
public void testBug100415() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector();
@@ -5047,17 +5047,17 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(free, col.getName(4).resolveBinding());
}
- // class X;
- // void f() {
- // class A {
- // friend class X;
- // };
- // }
- // namespace B {
- // class A {
- // friend class X;
- // };
- // }
+ // class X;
+ // void f() {
+ // class A {
+ // friend class X;
+ // };
+ // }
+ // namespace B {
+ // class A {
+ // friend class X;
+ // };
+ // }
public void testBug86688() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector();
@@ -5069,10 +5069,10 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(X, col.getName(6).resolveBinding());
}
- // class m {
- // int m::f();
- // };
- // int m::f(){}
+ // class m {
+ // int m::f();
+ // };
+ // int m::f(){}
public void testBug100403() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector();
@@ -5082,16 +5082,16 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(f, col.getName(6).resolveBinding());
}
- // struct A {
- // typedef int AT;
- // void f1(AT);
- // void f2(float);
- // };
- // struct B {
- // typedef float BT;
- // friend void A::f1(AT);
- // friend void A::f2(BT);
- // };
+ // struct A {
+ // typedef int AT;
+ // void f1(AT);
+ // void f2(float);
+ // };
+ // struct B {
+ // typedef float BT;
+ // friend void A::f1(AT);
+ // friend void A::f2(BT);
+ // };
public void testBug90609() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector();
@@ -5108,13 +5108,13 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(BT, col.getName(17).resolveBinding());
}
- // struct Except { int blah; };
- // void f() {
- // try { }
- // catch (Except * e) {
- // e->blah;
- // }
- // }
+ // struct Except { int blah; };
+ // void f() {
+ // try { }
+ // catch (Except * e) {
+ // e->blah;
+ // }
+ // }
public void testBug103281() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector();
@@ -5131,13 +5131,13 @@ public class AST2CPPTests extends AST2BaseTest {
parseAndCheckBindings("class Matrix { public: Matrix & operator *(Matrix &); }; Matrix rotate, translate; Matrix transform = rotate * translate;"); //$NON-NLS-1$
}
- // struct U { static int i; };
- // struct V : U { };
- // struct W : U { using U::i; };
- // struct X : V, W { void foo(); };
- // void X::foo() {
- // i;
- // }
+ // struct U { static int i; };
+ // struct V : U { };
+ // struct W : U { using U::i; };
+ // struct X : V, W { void foo(); };
+ // void X::foo() {
+ // i;
+ // }
public void test10_2s3b() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, true);
CPPNameCollector col = new CPPNameCollector();
@@ -5166,7 +5166,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertTrue(es.getExpression() instanceof IASTUnaryExpression);
}
- // int f() {
+ // int f() {
// int i;
// do { ++i; } while(i < 10);
// return 0;
@@ -5190,7 +5190,7 @@ public class AST2CPPTests extends AST2BaseTest {
buffer.append("}\r\n"); //$NON-NLS-1$
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.CPP);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
-
+
buffer = new StringBuffer();
buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\n"); //$NON-NLS-1$
buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)){\n"); //$NON-NLS-1$
@@ -5216,7 +5216,7 @@ public class AST2CPPTests extends AST2BaseTest {
}
- // // Test redundant class specifiers
+ // // Test redundant class specifiers
// class MyClass {
// int MyClass::field;
// static int MyClass::static_field;
@@ -5280,20 +5280,20 @@ public class AST2CPPTests extends AST2BaseTest {
parse(getAboveComment(), ParserLanguage.CPP, true, true);
}
- // class A {
- // double operator*(const A&);
- // };
- // class B : public A {
- // double operator*(double);
- // using A::operator*;
- // };
+ // class A {
+ // double operator*(const A&);
+ // };
+ // class B : public A {
+ // double operator*(double);
+ // using A::operator*;
+ // };
public void testBug178059() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, true);
}
- // void foo (void *p) throw () ;
- // void bar (void *p) __attribute__ ((__nonnull__(1)));
- // void zot (void *p) throw () __attribute__ ((__nonnull__(1)));
+ // void foo (void *p) throw () ;
+ // void bar (void *p) __attribute__ ((__nonnull__(1)));
+ // void zot (void *p) throw () __attribute__ ((__nonnull__(1)));
public void testBug179712() throws Exception {
parse(getAboveComment(), ParserLanguage.CPP, true, true);
}
@@ -5475,8 +5475,8 @@ public class AST2CPPTests extends AST2BaseTest {
// int * pBar = &bar;
// Test foo1 (bar, &bar);
// Test foo2 (bar, pBar);
- // Test foo3 (&bar);
- // }
+ // Test foo3 (&bar);
+ // }
public void testCastAmbiguity_Bug211756() throws Exception {
BindingAssertionHelper bh= getAssertionHelper();
@@ -5641,7 +5641,7 @@ public class AST2CPPTests extends AST2BaseTest {
bh.assertProblem("ns::", 2);
}
- // void func() {
+ // void func() {
// int a, b;
// a < b || (a==b && a < b);
// if (a > b) {
@@ -5683,7 +5683,7 @@ public class AST2CPPTests extends AST2BaseTest {
// foo/*b3*/(0x010U);
//
// /*c*/ /*d*/
- //
+ //
// foo/*e1*/(1L);
// foo/*e2*/(010L);
// foo/*e3*/(0x010L);
@@ -5785,24 +5785,24 @@ public class AST2CPPTests extends AST2BaseTest {
// void* operator new (unsigned int, int[100]);
// typedef int T;
- // int p[100];
+ // int p[100];
// void test(int f) {
- // new T;
+ // new T;
// new T();
// new T(f);
- // new (p) T;
+ // new (p) T;
// new (p) T();
// new (p) T(f);
- // new (T);
+ // new (T);
// new (T)();
// new (T)(f);
- // new (p) (T);
+ // new (p) (T);
// new (p) (T)();
// new (p) (T)(f);
- // new T[f][f];
- // new (p) T[f][f];
- // new (T[f][f]);
- // new (p) (T[f][f]);
+ // new T[f][f];
+ // new (p) T[f][f];
+ // new (T[f][f]);
+ // new (p) (T[f][f]);
// };
public void testNewPlacement() throws Exception {
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
@@ -5852,7 +5852,7 @@ public class AST2CPPTests extends AST2BaseTest {
IASTProblemDeclaration pdecl= getDeclaration(ls, 1);
assertEquals("+", pdecl.getRawSignature());
}
-
+
// class C;
// void func(void (C::*m)(int) const);
public void test233889_a() throws Exception {
@@ -5864,11 +5864,11 @@ public class AST2CPPTests extends AST2BaseTest {
ICPPFunctionType t= ((ICPPFunctionType)ptm.getType());
assertTrue(t.isConst());
}
-
+
// struct C {
// int m1(int a);
// int m2(int a) const;
- // };
+ // };
//
// C* func(int (C::*m)(int) const);
// C* func(int (C::*m)(int));
@@ -5883,7 +5883,7 @@ public class AST2CPPTests extends AST2BaseTest {
ICPPFunction fn2= bh.assertNonProblem("func(&C::m2", 4, ICPPFunction.class);
assertNotSame(fn1, fn2);
}
-
+
// class A;
//
// void foo(A* a) {}
@@ -6035,7 +6035,7 @@ public class AST2CPPTests extends AST2BaseTest {
// typedef char t2[8];
// typedef char* charp;
// void test(charp x) {}
- // int main(void) {
+ // int main(void) {
// char x[12];
// t1 y;
// t2 z;
@@ -6069,7 +6069,7 @@ public class AST2CPPTests extends AST2BaseTest {
// void test(char c) {
// void (A::* ptr2mem)(char);
// ptr2mem= reinterpret_cast<void (A::*)(char)>(&A::m);
- // ptr2mem= (void (A::*)(int))(0);
+ // ptr2mem= (void (A::*)(int))(0);
// }
public void testTypeIdForPtrToMember_Bug242197() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
@@ -6303,7 +6303,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(decl, func);
}
}
-
+
// class MyClass{
// public:
// int v;
@@ -6324,7 +6324,7 @@ public class AST2CPPTests extends AST2BaseTest {
exstmt= getStatement(fdef, 1);
assertInstance(exstmt.getExpression(), IASTBinaryExpression.class);
}
-
+
// template <int E> class A;
// class A {};
// class A;
@@ -6369,7 +6369,7 @@ public class AST2CPPTests extends AST2BaseTest {
public void testVoidParamInDefinition_257376() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
}
-
+
// namespace ns {
// struct C {
// C(C* c){}
@@ -6392,14 +6392,14 @@ public class AST2CPPTests extends AST2BaseTest {
// void donothing(VOID){}
// void donothing(VOID);
// void test() {
- // donothing();
+ // donothing();
// }
public void testVoidViaTypedef_Bug258694() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
}
// struct A {
- // B method(B p, int& a = y) { // B is not defined
+ // B method(B p, int& a = y) { // B is not defined
// B b;
// int x = y + 1;
// return b;
@@ -6524,8 +6524,8 @@ public class AST2CPPTests extends AST2BaseTest {
ba.assertNonProblem("a; //5", 1, ICPPField.class);
ba.assertProblem("a; //6", 1);
}
-
-
+
+
// struct A {
// int x;
// };
@@ -6544,8 +6544,8 @@ public class AST2CPPTests extends AST2BaseTest {
ba.assertNonProblem("x; //1", 1, ICPPField.class);
ba.assertNonProblem("x; //2", 1, ICPPField.class);
}
-
-
+
+
// struct A {
// int x;
// };
@@ -6562,7 +6562,7 @@ public class AST2CPPTests extends AST2BaseTest {
ba.assertNonProblem("x; //1", 1, ICPPField.class);
ba.assertNonProblem("x; //2", 1, ICPPField.class);
}
-
+
// struct A {
// int xx;
@@ -6593,7 +6593,7 @@ public class AST2CPPTests extends AST2BaseTest {
for(int i = 1; i <=6; i++)
ba.assertNonProblem("xx; // "+i, 2, ICPPField.class);
}
-
+
// struct A {
// int xx;
// };
@@ -6624,9 +6624,9 @@ public class AST2CPPTests extends AST2BaseTest {
for(int i = 1; i <=6; i++)
ba.assertNonProblem("xx; // "+i, 2, ICPPField.class);
}
-
-
-
+
+
+
// int a,b,c,d ;
// class X {
// void m() {
@@ -6663,10 +6663,10 @@ public class AST2CPPTests extends AST2BaseTest {
// friend void g(int);
// };
// };
- // void test() {
+ // void test() {
// f(1);
// g(1);
- // }
+ // }
// }
public void testFriendFunctionResolution_86368_1() throws Exception {
final String code= getAboveComment();
@@ -6723,7 +6723,7 @@ public class AST2CPPTests extends AST2BaseTest {
g1= bh.assertNonProblem("f(char)", 1);
assertSame(g1, g2);
}
-
+
// class A {
// public:
// void foo() const volatile;
@@ -6761,7 +6761,7 @@ public class AST2CPPTests extends AST2BaseTest {
ICPPFunctionType bar_v_ft= bar_v.getType();
ICPPFunctionType bar_c_ft= bar_c.getType();
ICPPFunctionType bar_ft= bar.getType();
-
+
assertTrue(bar_cv_ft.isConst()); assertTrue(bar_cv_ft.isVolatile());
assertTrue(!bar_v_ft.isConst()); assertTrue(bar_v_ft.isVolatile());
assertTrue(bar_c_ft.isConst()); assertTrue(!bar_c_ft.isVolatile());
@@ -6775,13 +6775,13 @@ public class AST2CPPTests extends AST2BaseTest {
bar_v_ft= bar_v.getType();
bar_c_ft= bar_c.getType();
bar_ft= bar.getType();
-
+
assertTrue(bar_cv_ft.isConst()); assertTrue(bar_cv_ft.isVolatile());
assertTrue(!bar_v_ft.isConst()); assertTrue(bar_v_ft.isVolatile());
assertTrue(bar_c_ft.isConst()); assertTrue(!bar_c_ft.isVolatile());
assertTrue(!bar_ft.isConst()); assertTrue(!bar_ft.isVolatile());
}
-
+
// void test1(float f);
// void test1(void);
// void blabla() {
@@ -6803,11 +6803,11 @@ public class AST2CPPTests extends AST2BaseTest {
// typedef int TInt;
// void select(int);
// void test() {
- // int a= TInt(1);
+ // int a= TInt(1);
// E e= E(0);
// void* h;
// select (int (h) + 1);
- // }
+ // }
public void testSimpleTypeConstructorExpressions() throws Exception {
final String code= getAboveComment();
parseAndCheckBindings(code);
@@ -7199,7 +7199,7 @@ public class AST2CPPTests extends AST2BaseTest {
// foo(L'a');
// }
public void testWideCharacterLiteralTypes_Bug270892() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP);
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
@@ -7483,9 +7483,9 @@ public class AST2CPPTests extends AST2BaseTest {
}
// class X {
- // struct S* m1;
+ // struct S* m1;
// struct T;
- // struct T* m2;
+ // struct T* m2;
// };
public void testStructOwner_290693() throws Exception {
final String code = getAboveComment();
@@ -7503,8 +7503,8 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(X, T.getOwner());
}
- // class ULONGLONG {
- // public :
+ // class ULONGLONG {
+ // public :
// ULONGLONG (unsigned long long val) {}
// friend ULONGLONG operator ~ (const ULONGLONG &) { return 0; }
// };
@@ -7666,7 +7666,7 @@ public class AST2CPPTests extends AST2BaseTest {
// void f(ns::E e) {}
// void test() {
// f(ns::e1);
- // f(ns::e1 | ns::e2); // the operator| needs to be looked up in the
+ // f(ns::e1 | ns::e2); // the operator| needs to be looked up in the
// // associated namespace.
// }
public void testAssociatedScopesForOverloadedOperators_293589() throws Exception {
@@ -7689,7 +7689,7 @@ public class AST2CPPTests extends AST2BaseTest {
ICPPFunctionTemplate template= bh.assertNonProblem("functionTemplate", 16);
assertNotNull(template.getType());
assertEquals(1, template.getParameters().length);
-
+
ICPPMethod method= bh.assertNonProblem("method", 6);
assertNotNull(method.getType());
assertEquals(1, method.getParameters().length);
@@ -7715,7 +7715,7 @@ public class AST2CPPTests extends AST2BaseTest {
// x("");
// Array a;
// xx(&a);
- // f("");
+ // f("");
// }
public void testCVQualifiersWithArrays_293982() throws Exception {
final String code = getAboveComment();
@@ -7800,18 +7800,18 @@ public class AST2CPPTests extends AST2BaseTest {
}
// struct A {};
- //
+ //
// void foo(const A&); // #1
// void foo(A&&); // #2
- //
+ //
// A source_rvalue();
// A& source_ref();
// A&& source_rvalue_ref();
- //
+ //
// const A source_const_rvalue();
// const A& source_const_ref();
// const A&& source_const_rvalue_ref();
- //
+ //
// int main() {
// A a;
// A& ra = a;
@@ -7819,7 +7819,7 @@ public class AST2CPPTests extends AST2BaseTest {
// const A ca;
// const A& rca = ca;
// const A&& rrca = ca;
- //
+ //
// foo(a); // #1
// foo(ra); // #1
// foo(rra); // #1
@@ -7907,7 +7907,7 @@ public class AST2CPPTests extends AST2BaseTest {
// double d = 2.0;
// const volatile double cvd = 1;
// int i = 2;
- // dref(d);
+ // dref(d);
// cdref(d);
// aref(b);
// caref(b);
@@ -8278,7 +8278,7 @@ public class AST2CPPTests extends AST2BaseTest {
// h({'a'}); // OK: same conversion as char to int
// h({1.0}); // error: narrowing
// h({ }); // OK: identity conversion
- // }
+ // }
public void testListInitialization_302412e() throws Exception {
String code= getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
@@ -8461,9 +8461,9 @@ public class AST2CPPTests extends AST2BaseTest {
}
// enum class E { a, b };
- // enum E x1 = E::a; // OK
+ // enum E x1 = E::a; // OK
// enum F { a, b };
- // enum F y1 = a; // OK
+ // enum F y1 = a; // OK
// enum E1 : int; // OK: E1 is un-scoped, underlying type is int
// enum class F1; // OK: F1 is scoped, underlying type is int
public void testScopedEnums_305975b() throws Exception {
@@ -8472,7 +8472,7 @@ public class AST2CPPTests extends AST2BaseTest {
}
// enum class E x2 = E::a; // illegal (elaborated type specifier)
- // enum class F y2 = a; // illegal
+ // enum class F y2 = a; // illegal
// enum E; // illegal
public void testScopedEnums_305975c() throws Exception {
String code= getAboveComment();
@@ -8484,11 +8484,11 @@ public class AST2CPPTests extends AST2BaseTest {
assertInstance(decls[2], IASTProblemDeclaration.class);
}
- // enum class Col { red, yellow, green };
+ // enum class Col { red, yellow, green };
// void fint(int);
// void fbool(bool);
// void fCol(Col);
- //
+ //
// void test() {
// fCol(Col::red);
// fint(Col::red); // error: no conversion to int
@@ -8510,29 +8510,29 @@ public class AST2CPPTests extends AST2BaseTest {
// d = direction::right; // OK
// }
//
- // enum class altitude { high=1, low=2 };
+ // enum class altitude { high=1, low=2 };
// void h() {
// altitude a; // OK
// a = altitude::low; // OK
// }
//
// struct X {
- // enum xdir { xl=1, xr=2 };
+ // enum xdir { xl=1, xr=2 };
// int f(int i) { return i==xl ? 0 : i==xr ? 1 : 2; }
// };
// void g(X* p) {
// int i;
- // i = p->f(X::xr); // OK
- // i = p->f(p->xl); // OK
+ // i = p->f(X::xr); // OK
+ // i = p->f(p->xl); // OK
// }
public void testScopedEnums_305975e() throws Exception {
String code= getAboveComment();
parseAndCheckBindings(code);
}
- // enum class altitude { high=1, low=2 };
+ // enum class altitude { high=1, low=2 };
// struct X {
- // enum xdir { xl=1, xr=2 };
+ // enum xdir { xl=1, xr=2 };
// int f(int i) { return i==xl ? 0 : i==xr ? 1 : 2; }
// };
// void g(X* p) {
@@ -8983,7 +8983,7 @@ public class AST2CPPTests extends AST2BaseTest {
// void test() {
// f(); // xvalue
// f().m; // xvalue
- // static_cast<A&&>(a); // xvalue
+ // static_cast<A&&>(a); // xvalue
// a+a; // xvalue
// ar; // rvalue
// }
@@ -9080,7 +9080,7 @@ public class AST2CPPTests extends AST2BaseTest {
// }
// int i;
// }
- // int j = A::i;
+ // int j = A::i;
public void testInlineNamespaceLookup_324096() throws Exception {
parseAndCheckBindings();
}
@@ -9117,7 +9117,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(fc, ref);
ref= bh.assertNonProblem("f(0 ? p : \"\")", 1); // "" converted to char*
assertSame(fc, ref);
- bh.assertNonProblem("g(0 ? p : \"\")", 1); //
+ bh.assertNonProblem("g(0 ? p : \"\")", 1); //
}
// struct C {
@@ -9303,7 +9303,7 @@ public class AST2CPPTests extends AST2BaseTest {
// S arr[5];
// std::pair<S*, S*> p{arr, arr + 5};
// for (const auto& r : p)
- // r.x;
+ // r.x;
// }
public void testAutoTypeInRangeBasedFor_332883c() throws Exception {
parseAndCheckBindings();
@@ -9485,8 +9485,8 @@ public class AST2CPPTests extends AST2BaseTest {
// void (g)(int); //2
public void testFunctionRedeclarations() throws Exception {
BindingAssertionHelper bh= getAssertionHelper();
- IFunction g1= bh.assertNonProblem("g)(char)", 1);
- IFunction g2= bh.assertNonProblem("g)(int); //1", 1);
+ IFunction g1= bh.assertNonProblem("g)(char)", 1);
+ IFunction g2= bh.assertNonProblem("g)(int); //1", 1);
IFunction g3= bh.assertNonProblem("g)(int); //2", 1);
assertNotSame(g1, g2);
assertSame(g2, g3);
@@ -9579,7 +9579,7 @@ public class AST2CPPTests extends AST2BaseTest {
// }
public void testModeAttribute_330635() throws Exception {
BindingAssertionHelper bh= getAssertionHelper();
- String[] calls = { "f(i8)", "f(i16)", "f(i32)", "f(i64)", "f(word)" };
+ String[] calls = { "f(i8)", "f(i16)", "f(i32)", "f(i64)", "f(word)" };
ICPPFunction[] functions = new ICPPFunction[calls.length];
for (int i = 0; i < calls.length; i++) {
functions[i] = bh.assertNonProblem(calls[i], 1, ICPPFunction.class);
@@ -9593,7 +9593,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertSame(calls[calls.length - 1] + " and " + calls[calls.length - 2] + " resolve to different functions",
functions[calls.length - 1], functions[calls.length - 2]);
}
-
+
// void f(int x) try {
// } catch(...) {
// (void)x;
@@ -9601,7 +9601,7 @@ public class AST2CPPTests extends AST2BaseTest {
public void testParentScopeOfCatchHandler_376246() throws Exception {
parseAndCheckBindings();
}
-
+
// struct MyClass {
// struct MyException {};
// void doSomething() throw(MyException);
@@ -9649,7 +9649,7 @@ public class AST2CPPTests extends AST2BaseTest {
public void testNullptr_327298a() throws Exception {
parseAndCheckBindings();
}
-
+
// namespace std {
// typedef decltype(nullptr) nullptr_t;
// }
@@ -9670,7 +9670,7 @@ public class AST2CPPTests extends AST2BaseTest {
bh.assertProblem("checklvalue(nullptr)", 11);
bh.assertProblem("g( nullptr )", 1);
}
-
+
// void f( char* );
// void f( int );
// void test2() {
@@ -9684,7 +9684,7 @@ public class AST2CPPTests extends AST2BaseTest {
assertEquals("void (char *)", ASTTypeUtil.getType(f.getType()));
f= bh.assertNonProblem("f( 0 )", 1);
assertEquals("void (int)", ASTTypeUtil.getType(f.getType()));
- }
+ }
// void foo(struct S s);
public void testParameterForwardDeclaration_379511() throws Exception {
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
index 6d25bb28016..e8479a2a0e6 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
@@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Doug Schaefer (IBM) - Initial API and implementation
- * Markus Schorn (Wind River Systems)
- * Andrew Ferguson (Symbian)
+ * Doug Schaefer (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
+ * Andrew Ferguson (Symbian)
*******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
@@ -127,17 +127,16 @@ import org.eclipse.cdt.internal.core.parser.ParserException;
* Testcases on the AST.
*/
public class AST2Tests extends AST2BaseTest {
-
private static final int NUM_TESTS = 3;
-
+
public static TestSuite suite() {
return suite(AST2Tests.class);
}
-
+
public AST2Tests() {
super();
}
-
+
public AST2Tests(String name) {
super(name);
}
@@ -151,18 +150,18 @@ public class AST2Tests extends AST2BaseTest {
protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception {
return parseAndCheckBindings(code, ParserLanguage.C);
}
-
+
public void testBug75189() throws Exception {
parseAndCheckBindings("struct A{};\n typedef int (*F) (struct A*);"); //$NON-NLS-1$
parseAndCheckBindings("struct A{};\n typedef int (*F) (A*);", ParserLanguage.CPP); //$NON-NLS-1$
}
-
+
public void testBug75340() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings("void f(int i = 0, int * p = 0);", ParserLanguage.CPP); //$NON-NLS-1$
IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0];
isParameterSignatureEqual(sd.getDeclarators()[0], "(int=0, int*=0)"); //$NON-NLS-1$
}
-
+
// int *p1; int *p2;
// union {
// struct {int a; int b;} A;
@@ -176,7 +175,7 @@ public class AST2Tests extends AST2BaseTest {
public void testBug78103() throws Exception {
parseAndCheckBindings(getAboveComment());
}
-
+
// int m(int);
// int (*pm)(int) = &m;
// int f(int);
@@ -184,18 +183,18 @@ public class AST2Tests extends AST2BaseTest {
public void testBug43241() throws Exception {
parseAndCheckBindings(getAboveComment());
}
-
+
// int *zzz1 (char);
- // int (*zzz2) (char);
- // int ((*zzz3)) (char);
- // int (*(zzz4)) (char);
+ // int (*zzz2) (char);
+ // int ((*zzz3)) (char);
+ // int (*(zzz4)) (char);
public void testBug40768() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
CNameCollector col = new CNameCollector();
tu.accept(col);
assertNoProblemBindings(col);
}
-
+
// int x;
// void f(int y) {
// int z = x + y;
@@ -205,9 +204,9 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IScope globalScope = tu.getScope();
-
+
IASTDeclaration[] declarations = tu.getDeclarations();
-
+
// int x
IASTSimpleDeclaration decl_x = (IASTSimpleDeclaration) declarations[0];
IASTSimpleDeclSpecifier declspec_x = (IASTSimpleDeclSpecifier) decl_x.getDeclSpecifier();
@@ -215,7 +214,7 @@ public class AST2Tests extends AST2BaseTest {
IASTDeclarator declor_x = decl_x.getDeclarators()[0];
IASTName name_x = declor_x.getName();
assertEquals("x", name_x.toString()); //$NON-NLS-1$
-
+
// function - void f()
IASTFunctionDefinition funcdef_f = (IASTFunctionDefinition) declarations[1];
IASTSimpleDeclSpecifier declspec_f = (IASTSimpleDeclSpecifier) funcdef_f
@@ -224,7 +223,7 @@ public class AST2Tests extends AST2BaseTest {
IASTFunctionDeclarator declor_f = funcdef_f.getDeclarator();
IASTName name_f = declor_f.getName();
assertEquals("f", name_f.toString()); //$NON-NLS-1$
-
+
// parameter - int y
assertTrue(declor_f instanceof IASTStandardFunctionDeclarator);
IASTParameterDeclaration decl_y = ((IASTStandardFunctionDeclarator) declor_f)
@@ -235,7 +234,7 @@ public class AST2Tests extends AST2BaseTest {
IASTDeclarator declor_y = decl_y.getDeclarator();
IASTName name_y = declor_y.getName();
assertEquals("y", name_y.toString()); //$NON-NLS-1$
-
+
// int z
IASTCompoundStatement body_f = (IASTCompoundStatement) funcdef_f
.getBody();
@@ -249,7 +248,7 @@ public class AST2Tests extends AST2BaseTest {
IASTDeclarator declor_z = decl_z.getDeclarators()[0];
IASTName name_z = declor_z.getName();
assertEquals("z", name_z.toString()); //$NON-NLS-1$
-
+
// = x + y
IASTEqualsInitializer initializer = (IASTEqualsInitializer) declor_z.getInitializer();
IASTBinaryExpression init_z = (IASTBinaryExpression) initializer.getInitializerClause();
@@ -257,11 +256,11 @@ public class AST2Tests extends AST2BaseTest {
IASTIdExpression ref_x = (IASTIdExpression) init_z.getOperand1();
IASTName name_ref_x = ref_x.getName();
assertEquals("x", name_ref_x.toString()); //$NON-NLS-1$
-
+
IASTIdExpression ref_y = (IASTIdExpression) init_z.getOperand2();
IASTName name_ref_y = ref_y.getName();
assertEquals("y", name_ref_y.toString()); //$NON-NLS-1$
-
+
// BINDINGS
// resolve the binding to get the variable object
IVariable var_x = (IVariable) name_x.resolveBinding();
@@ -271,39 +270,39 @@ public class AST2Tests extends AST2BaseTest {
IParameter var_y = (IParameter) name_y.resolveBinding();
assertEquals(((IASTCompoundStatement) funcdef_f.getBody()).getScope(),
var_y.getScope());
-
+
IVariable var_z = (IVariable) name_z.resolveBinding();
assertEquals(((ICFunctionScope) func_f.getFunctionScope()).getBodyScope(), var_z.getScope());
-
+
// make sure the variable referenced is the same one we declared above
assertEquals(var_x, name_ref_x.resolveBinding());
assertEquals(var_y, name_ref_y.resolveBinding());
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(name_x.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_x);
-
+
decls = tu.getDeclarationsInAST(name_f.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_f);
-
+
decls = tu.getDeclarationsInAST(name_y.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_y);
-
+
decls = tu.getDeclarationsInAST(name_z.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_z);
-
+
decls = tu.getDeclarationsInAST(name_ref_x.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_x);
-
+
decls = tu.getDeclarationsInAST(name_ref_y.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_y);
-
+
// // test clearBindings
// assertNotNull(((ICScope) tu.getScope()).getBinding(
// ICScope.NAMESPACE_TYPE_OTHER, new String("x").toCharArray()));
@@ -330,11 +329,11 @@ public class AST2Tests extends AST2BaseTest {
// assertNull(((ICScope) body_f.getScope()).getBinding(
// ICScope.NAMESPACE_TYPE_OTHER, new String("y").toCharArray()));
// //$NON-NLS-1$
-
+
tu = validateCopy(tu);
}
}
-
+
// typedef struct {
// int x;
// } S;
@@ -351,7 +350,7 @@ public class AST2Tests extends AST2BaseTest {
.getDeclarations()[0];
IASTCompositeTypeSpecifier type = (IASTCompositeTypeSpecifier) decl
.getDeclSpecifier();
-
+
// it's a typedef
assertEquals(IASTDeclSpecifier.sc_typedef, type.getStorageClass());
// this an anonymous struct
@@ -369,12 +368,12 @@ public class AST2Tests extends AST2BaseTest {
IASTDeclarator tor_x = decl_x.getDeclarators()[0];
IASTName name_x = tor_x.getName();
assertEquals("x", name_x.toString()); //$NON-NLS-1$
-
+
// declarator S
IASTDeclarator tor_S = decl.getDeclarators()[0];
IASTName name_S = tor_S.getName();
assertEquals("S", name_S.toString()); //$NON-NLS-1$
-
+
// function f
IASTFunctionDefinition def_f = (IASTFunctionDefinition) tu
.getDeclarations()[1];
@@ -408,7 +407,7 @@ public class AST2Tests extends AST2BaseTest {
IASTIdExpression ref_myS = (IASTIdExpression) fieldref.getFieldOwner();
IASTLiteralExpression lit_5 = (IASTLiteralExpression) assexpr.getOperand2();
assertEquals("5", lit_5.toString()); //$NON-NLS-1$
-
+
// Logical Bindings In Test
ICompositeType type_struct = (ICompositeType) name_struct.resolveBinding();
ITypedef typedef_S = (ITypedef) name_S.resolveBinding();
@@ -426,40 +425,40 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(var_myS, ref_myS.getName().resolveBinding());
IField field_x = (IField) name_x.resolveBinding();
assertEquals(field_x, fieldref.getFieldName().resolveBinding());
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(name_struct.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_struct);
-
+
decls = tu.getDeclarationsInAST(name_x.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_x);
-
+
decls = tu.getDeclarationsInAST(def_f.getDeclarator().getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], def_f.getDeclarator().getName());
-
+
decls = tu.getDeclarationsInAST(name_S.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_S);
-
+
decls = tu.getDeclarationsInAST(name_myS.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_myS);
-
+
decls = tu.getDeclarationsInAST(ref_myS.getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_myS);
-
+
decls = tu.getDeclarationsInAST(fieldref.getFieldName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_x);
-
+
tu = validateCopy(tu);
}
}
-
+
public void testCExpressions() throws ParserException {
validateSimpleUnaryExpressionC("++x", IASTUnaryExpression.op_prefixIncr); //$NON-NLS-1$
validateSimpleUnaryExpressionC("--x", IASTUnaryExpression.op_prefixDecr); //$NON-NLS-1$
@@ -528,7 +527,7 @@ public class AST2Tests extends AST2BaseTest {
"x||y", IASTBinaryExpression.op_logicalOr); //$NON-NLS-1$
validateConditionalExpressionC("x ? y : x"); //$NON-NLS-1$
}
-
+
public void testMultipleDeclarators() throws Exception {
IASTTranslationUnit tu = parse("int r, s;", ParserLanguage.C); //$NON-NLS-1$
assertTrue(tu.isFrozen());
@@ -536,30 +535,30 @@ public class AST2Tests extends AST2BaseTest {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTDeclarator[] declarators = decl.getDeclarators();
assertEquals(2, declarators.length);
-
+
IASTDeclarator dtor1 = declarators[0];
IASTDeclarator dtor2 = declarators[1];
-
+
IASTName name1 = dtor1.getName();
IASTName name2 = dtor2.getName();
-
+
assertEquals(name1.resolveBinding().getName(), "r"); //$NON-NLS-1$
assertEquals(name2.resolveBinding().getName(), "s"); //$NON-NLS-1$
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(name1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name1);
-
+
decls = tu.getDeclarationsInAST(name2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name2);
-
+
tu = validateCopy(tu);
}
}
-
-
+
+
public void testStructureTagScoping_1() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("struct A; \n"); //$NON-NLS-1$
@@ -567,9 +566,9 @@ public class AST2Tests extends AST2BaseTest {
buffer.append(" struct A; \n"); //$NON-NLS-1$
buffer.append(" struct A * a; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
-
+
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
-
+
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
// struct A;
@@ -578,19 +577,19 @@ public class AST2Tests extends AST2BaseTest {
IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1.getDeclSpecifier();
assertEquals(0, decl1.getDeclarators().length);
IASTName nameA1 = compTypeSpec.getName();
-
+
// void f() {
IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu.getDeclarations()[1];
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef.getBody();
assertEquals(2, compoundStatement.getStatements().length);
-
+
// struct A;
IASTDeclarationStatement declStatement = (IASTDeclarationStatement) compoundStatement.getStatements()[0];
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) declStatement.getDeclaration();
compTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier();
assertEquals(0, decl2.getDeclarators().length);
IASTName nameA2 = compTypeSpec.getName();
-
+
// struct A * a;
declStatement = (IASTDeclarationStatement) compoundStatement.getStatements()[1];
IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) declStatement.getDeclaration();
@@ -600,7 +599,7 @@ public class AST2Tests extends AST2BaseTest {
IASTName namea = dtor.getName();
assertEquals(1, dtor.getPointerOperators().length);
assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer);
-
+
// bindings
ICompositeType str1 = (ICompositeType) nameA1.resolveBinding();
ICompositeType str2 = (ICompositeType) nameA2.resolveBinding();
@@ -614,41 +613,41 @@ public class AST2Tests extends AST2BaseTest {
assertNotSame(str1, str2);
assertSame(str2, str3);
assertSame(str3, str4);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(nameA1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], nameA1);
-
+
decls = tu.getDeclarationsInAST(fndef.getDeclarator().getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], fndef.getDeclarator().getName());
-
+
decls = tu.getDeclarationsInAST(nameA2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], nameA2);
-
+
decls = tu.getDeclarationsInAST(nameA3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], nameA2);
-
+
decls = tu.getDeclarationsInAST(namea.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], namea);
-
+
tu = validateCopy(tu);
}
}
-
+
public void testStructureTagScoping_2() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("struct A; \n"); //$NON-NLS-1$
buffer.append("void f() { \n"); //$NON-NLS-1$
buffer.append(" struct A * a; \n"); //$NON-NLS-1$
buffer.append("} \r\n"); //$NON-NLS-1$
-
+
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
-
+
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
// struct A;
@@ -656,12 +655,12 @@ public class AST2Tests extends AST2BaseTest {
IASTElaboratedTypeSpecifier compTypeSpec = (IASTElaboratedTypeSpecifier) decl1.getDeclSpecifier();
assertEquals(0, decl1.getDeclarators().length);
IASTName nameA1 = compTypeSpec.getName();
-
+
// void f() {
IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu.getDeclarations()[1];
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef.getBody();
assertEquals(1, compoundStatement.getStatements().length);
-
+
// struct A * a;
IASTDeclarationStatement declStatement = (IASTDeclarationStatement) compoundStatement.getStatements()[0];
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) declStatement.getDeclaration();
@@ -671,7 +670,7 @@ public class AST2Tests extends AST2BaseTest {
IASTName namea = dtor.getName();
assertEquals(1, dtor.getPointerOperators().length);
assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer);
-
+
// bindings
ICompositeType str1 = (ICompositeType) nameA1.resolveBinding();
ICompositeType str2 = (ICompositeType) nameA2.resolveBinding();
@@ -681,28 +680,28 @@ public class AST2Tests extends AST2BaseTest {
assertNotNull(str1);
assertSame(str1, str2);
assertSame(str2, str3);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(nameA1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], nameA1);
-
+
decls = tu.getDeclarationsInAST(fndef.getDeclarator().getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], fndef.getDeclarator().getName());
-
+
decls = tu.getDeclarationsInAST(nameA2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], nameA1);
-
+
decls = tu.getDeclarationsInAST(namea.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], namea);
-
+
tu = validateCopy(tu);
}
}
-
+
public void testStructureDef() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("struct A; \r\n"); //$NON-NLS-1$
@@ -711,9 +710,9 @@ public class AST2Tests extends AST2BaseTest {
buffer.append("void f() { \n"); //$NON-NLS-1$
buffer.append(" a->i; \n"); //$NON-NLS-1$
buffer.append("} \n"); //$NON-NLS-1$
-
+
IASTTranslationUnit tu = parse(buffer.toString(), ParserLanguage.C);
-
+
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
// struct A;
@@ -721,7 +720,7 @@ public class AST2Tests extends AST2BaseTest {
IASTElaboratedTypeSpecifier elabTypeSpec = (IASTElaboratedTypeSpecifier) decl1.getDeclSpecifier();
assertEquals(0, decl1.getDeclarators().length);
IASTName name_A1 = elabTypeSpec.getName();
-
+
// struct A * a;
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
elabTypeSpec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier();
@@ -730,30 +729,30 @@ public class AST2Tests extends AST2BaseTest {
IASTName name_a = dtor.getName();
assertEquals(1, dtor.getPointerOperators().length);
assertTrue(dtor.getPointerOperators()[0] instanceof ICASTPointer);
-
+
// struct A {
IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu.getDeclarations()[2];
ICASTCompositeTypeSpecifier compTypeSpec = (ICASTCompositeTypeSpecifier) decl3.getDeclSpecifier();
IASTName name_Adef = compTypeSpec.getName();
-
+
// int i;
IASTSimpleDeclaration decl4 = (IASTSimpleDeclaration) compTypeSpec
.getMembers()[0];
dtor = decl4.getDeclarators()[0];
IASTName name_i = dtor.getName();
-
+
// void f() {
IASTFunctionDefinition fndef = (IASTFunctionDefinition) tu.getDeclarations()[3];
IASTCompoundStatement compoundStatement = (IASTCompoundStatement) fndef.getBody();
assertEquals(1, compoundStatement.getStatements().length);
-
+
// a->i;
IASTExpressionStatement exprstmt = (IASTExpressionStatement) compoundStatement.getStatements()[0];
IASTFieldReference fieldref = (IASTFieldReference) exprstmt.getExpression();
IASTIdExpression id_a = (IASTIdExpression) fieldref.getFieldOwner();
IASTName name_aref = id_a.getName();
IASTName name_iref = fieldref.getFieldName();
-
+
// bindings
IVariable var_a1 = (IVariable) name_aref.resolveBinding();
IVariable var_i1 = (IVariable) name_iref.resolveBinding();
@@ -762,114 +761,114 @@ public class AST2Tests extends AST2BaseTest {
ICompositeType structA_2 = (ICompositeType) name_A1.resolveBinding();
ICompositeType structA_3 = (ICompositeType) name_A2.resolveBinding();
ICompositeType structA_4 = (ICompositeType) name_Adef.resolveBinding();
-
+
IVariable var_a2 = (IVariable) name_a.resolveBinding();
IVariable var_i2 = (IVariable) name_i.resolveBinding();
-
+
assertSame(var_a1, var_a2);
assertSame(var_i1, var_i2);
assertSame(structA_1, structA_2);
assertSame(structA_2, structA_3);
assertSame(structA_3, structA_4);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(name_A1.resolveBinding());
assertEquals(decls.length, 2);
assertEquals(decls[0], name_A1);
assertEquals(decls[1], name_Adef);
-
+
decls = tu.getDeclarationsInAST(name_A2.resolveBinding());
assertEquals(decls.length, 2);
assertEquals(decls[0], name_A1);
assertEquals(decls[1], name_Adef);
-
+
decls = tu.getDeclarationsInAST(name_a.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_a);
-
+
decls = tu.getDeclarationsInAST(name_Adef.resolveBinding());
assertEquals(decls.length, 2);
assertEquals(decls[0], name_A1);
assertEquals(decls[1], name_Adef);
-
+
decls = tu.getDeclarationsInAST(name_i.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_i);
-
+
decls = tu.getDeclarationsInAST(fndef.getDeclarator().getName()
.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], fndef.getDeclarator().getName());
-
+
decls = tu.getDeclarationsInAST(name_aref.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_a);
-
+
decls = tu.getDeclarationsInAST(name_iref.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_i);
-
+
tu = validateCopy(tu);
}
}
-
- // struct x {};
- // void f(int x) {
- // struct x i;
- // }
+
+ // struct x {};
+ // void f(int x) {
+ // struct x i;
+ // }
public void testStructureNamespace() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
-
+
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration declaration1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTCompositeTypeSpecifier typeSpec = (IASTCompositeTypeSpecifier) declaration1.getDeclSpecifier();
IASTName x_1 = typeSpec.getName();
-
+
IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu.getDeclarations()[1];
assertTrue(fdef.getDeclarator() instanceof IASTStandardFunctionDeclarator);
IASTParameterDeclaration param = ((IASTStandardFunctionDeclarator) fdef.getDeclarator()).getParameters()[0];
IASTName x_2 = param.getDeclarator().getName();
-
+
IASTCompoundStatement compound = (IASTCompoundStatement) fdef.getBody();
IASTDeclarationStatement declStatement = (IASTDeclarationStatement) compound.getStatements()[0];
IASTSimpleDeclaration declaration2 = (IASTSimpleDeclaration) declStatement.getDeclaration();
IASTElaboratedTypeSpecifier elab = (IASTElaboratedTypeSpecifier) declaration2.getDeclSpecifier();
IASTName x_3 = elab.getName();
-
+
ICompositeType x1 = (ICompositeType) x_1.resolveBinding();
IVariable x2 = (IVariable) x_2.resolveBinding();
ICompositeType x3 = (ICompositeType) x_3.resolveBinding();
-
+
assertNotNull(x1);
assertNotNull(x2);
assertSame(x1, x3);
assertNotSame(x2, x3);
-
+
IASTDeclarator decl_i = declaration2.getDeclarators()[0];
decl_i.getName().resolveBinding(); // add i's binding to the scope
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(x_1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x_1);
-
+
decls = tu.getDeclarationsInAST(fdef.getDeclarator().getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], fdef.getDeclarator().getName());
-
+
decls = tu.getDeclarationsInAST(x_2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x_2);
-
+
decls = tu.getDeclarationsInAST(x_3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], x_1);
-
+
decls = tu.getDeclarationsInAST(declaration2.getDeclarators()[0].getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], declaration2.getDeclarators()[0].getName());
-
+
// assertNotNull(((ICScope) tu.getScope()).getBinding(
// ICScope.NAMESPACE_TYPE_TAG, new String("x").toCharArray()));
// //$NON-NLS-1$
@@ -895,19 +894,19 @@ public class AST2Tests extends AST2BaseTest {
// assertNull(((ICScope) compound.getScope()).getBinding(
// ICScope.NAMESPACE_TYPE_OTHER, new String("i").toCharArray()));
// //$NON-NLS-1$
-
+
tu = validateCopy(tu);
}
}
-
- // void f(int a);
- // void f(int b) {
- // b;
- // }
+
+ // void f(int a);
+ // void f(int b) {
+ // b;
+ // }
public void testFunctionParameters() throws Exception {
final String code = getAboveComment();
IASTTranslationUnit tu = parse(code, ParserLanguage.C);
-
+
assertTrue(tu.isFrozen());
// void f(
IASTSimpleDeclaration f_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
@@ -1008,7 +1007,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
-
+
// void f(int a, int b) { }
public void testSimpleFunction() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
@@ -1018,61 +1017,61 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(fDef.getDeclarator() instanceof IASTStandardFunctionDeclarator);
IASTStandardFunctionDeclarator fDtor = (IASTStandardFunctionDeclarator) fDef.getDeclarator();
IASTName fName = fDtor.getName();
-
+
IASTParameterDeclaration a = fDtor.getParameters()[0];
IASTName name_a = a.getDeclarator().getName();
-
+
IASTParameterDeclaration b = fDtor.getParameters()[1];
IASTName name_b = b.getDeclarator().getName();
-
+
IFunction function = (IFunction) fName.resolveBinding();
IParameter param_a = (IParameter) name_a.resolveBinding();
IParameter param_b = (IParameter) name_b.resolveBinding();
-
+
assertEquals("f", function.getName()); //$NON-NLS-1$
assertEquals("a", param_a.getName()); //$NON-NLS-1$
assertEquals("b", param_b.getName()); //$NON-NLS-1$
-
+
IParameter[] params = function.getParameters();
assertEquals(2, params.length);
assertSame(params[0], param_a);
assertSame(params[1], param_b);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(fName.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], fName);
-
+
decls = tu.getDeclarationsInAST(name_a.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_a);
-
+
decls = tu.getDeclarationsInAST(name_b.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_b);
-
+
tu = validateCopy(tu);
}
}
-
- // void f();
- // void g() {
- // f();
- // }
- // void f() { }
+
+ // void f();
+ // void g() {
+ // f();
+ // }
+ // void f() { }
public void testSimpleFunctionCall() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
-
+
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
// void f();
IASTSimpleDeclaration fdecl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) fdecl.getDeclarators()[0];
IASTName name_f = fdtor.getName();
-
+
// void g() {
IASTFunctionDefinition gdef = (IASTFunctionDefinition) tu.getDeclarations()[1];
-
+
// f();
IASTCompoundStatement compound = (IASTCompoundStatement) gdef.getBody();
IASTExpressionStatement expStatement = (IASTExpressionStatement) compound
@@ -1083,38 +1082,38 @@ public class AST2Tests extends AST2BaseTest {
.getFunctionNameExpression();
IASTName name_fcall = fcall_id.getName();
assertNull(fcall.getParameterExpression());
-
+
// void f() {}
IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu.getDeclarations()[2];
assertTrue(fdef.getDeclarator() instanceof IASTStandardFunctionDeclarator);
fdtor = (IASTStandardFunctionDeclarator) fdef.getDeclarator();
IASTName name_fdef = fdtor.getName();
-
+
// bindings
IFunction function_1 = (IFunction) name_fcall.resolveBinding();
IFunction function_2 = (IFunction) name_f.resolveBinding();
IFunction function_3 = (IFunction) name_fdef.resolveBinding();
-
+
assertNotNull(function_1);
assertSame(function_1, function_2);
assertSame(function_2, function_3);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(name_f.resolveBinding());
assertEquals(decls.length, 2);
assertEquals(decls[0], name_f);
assertEquals(decls[1], name_fdef);
-
+
decls = tu.getDeclarationsInAST(gdef.getDeclarator().getName()
.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], gdef.getDeclarator().getName());
-
+
decls = tu.getDeclarationsInAST(name_fcall.resolveBinding());
assertEquals(decls.length, 2);
assertEquals(decls[0], name_f);
assertEquals(decls[1], name_fdef);
-
+
decls = tu.getDeclarationsInAST(name_fdef.resolveBinding());
assertEquals(decls.length, 2);
assertEquals(decls[0], name_f);
@@ -1123,12 +1122,12 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
- // void f() {
- // for (int i = 0; i < 5; i++) {
- // i;
- // }
- // }
+
+ // void f() {
+ // for (int i = 0; i < 5; i++) {
+ // i;
+ // }
+ // }
public void testForLoop() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
@@ -1136,11 +1135,11 @@ public class AST2Tests extends AST2BaseTest {
// void f() {
IASTFunctionDefinition fdef = (IASTFunctionDefinition) tu.getDeclarations()[0];
IASTCompoundStatement compound = (IASTCompoundStatement) fdef.getBody();
-
+
// for(
IASTForStatement for_stmt = (IASTForStatement) compound.getStatements()[0];
// int i = 0;
-
+
IASTSimpleDeclaration initDecl = (IASTSimpleDeclaration) ((IASTDeclarationStatement) for_stmt
.getInitializerStatement()).getDeclaration();
IASTDeclarator dtor = initDecl.getDeclarators()[0];
@@ -1156,41 +1155,41 @@ public class AST2Tests extends AST2BaseTest {
IASTIdExpression id_i2 = (IASTIdExpression) un.getOperand();
IASTName name_i3 = id_i2.getName();
assertEquals(IASTUnaryExpression.op_postFixIncr, un.getOperator());
-
+
// i;
compound = (IASTCompoundStatement) for_stmt.getBody();
IASTExpressionStatement exprSt = (IASTExpressionStatement) compound.getStatements()[0];
IASTIdExpression id_i3 = (IASTIdExpression) exprSt.getExpression();
IASTName name_i4 = id_i3.getName();
-
+
// bindings
IVariable var_1 = (IVariable) name_i4.resolveBinding();
IVariable var_2 = (IVariable) name_i.resolveBinding();
IVariable var_3 = (IVariable) name_i2.resolveBinding();
IVariable var_4 = (IVariable) name_i3.resolveBinding();
-
+
assertSame(var_1, var_2);
assertSame(var_2, var_3);
assertSame(var_3, var_4);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(fdef.getDeclarator().getName()
.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], fdef.getDeclarator().getName());
-
+
decls = tu.getDeclarationsInAST(name_i.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_i);
-
+
decls = tu.getDeclarationsInAST(name_i2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_i);
-
+
decls = tu.getDeclarationsInAST(name_i3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_i);
-
+
decls = tu.getDeclarationsInAST(name_i4.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_i);
@@ -1198,11 +1197,11 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
- // struct A { int x; };
- // void f() {
- // ((struct A *) 1)->x;
- // }
+
+ // struct A { int x; };
+ // void f() {
+ // ((struct A *) 1)->x;
+ // }
public void testExpressionFieldReference() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
@@ -1250,21 +1249,21 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
- // void f() {
- // while (1) {
- // if (1)
- // goto end;
- // }
- // end: ;
- // }
+
+ // void f() {
+ // while (1) {
+ // if (1)
+ // goto end;
+ // }
+ // end: ;
+ // }
public void testLabels() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
CNameCollector collector = new CNameCollector();
tu.accept(collector);
-
+
assertEquals(collector.size(), 3);
IFunction function = (IFunction) collector.getName(0).resolveBinding();
ILabel label_1 = (ILabel) collector.getName(1).resolveBinding();
@@ -1272,25 +1271,25 @@ public class AST2Tests extends AST2BaseTest {
assertNotNull(function);
assertNotNull(label_1);
assertEquals(label_1, label_2);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(collector.getName(0)
.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], collector.getName(0));
-
+
decls = tu.getDeclarationsInAST(collector.getName(1).resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], collector.getName(2));
-
+
decls = tu.getDeclarationsInAST(collector.getName(2).resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], collector.getName(2));
-
+
tu = validateCopy(tu);
}
}
-
+
// typedef struct { } X;
// int f(X x);
public void testAnonStruct() throws Exception {
@@ -1306,49 +1305,49 @@ public class AST2Tests extends AST2BaseTest {
.getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
IASTName name_x = ((IASTStandardFunctionDeclarator) decl2
.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
-
+
IASTName[] decls = tu.getDeclarationsInAST(name_X1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_X1);
-
+
decls = tu.getDeclarationsInAST(name_f.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_f);
-
+
decls = tu.getDeclarationsInAST(name_X2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_X1);
-
+
decls = tu.getDeclarationsInAST(name_x.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_x);
-
+
tu = validateCopy(tu);
}
-
+
}
-
+
public void testLongLong() throws ParserException {
IASTTranslationUnit tu = parse("long long x;\n", ParserLanguage.C); //$NON-NLS-1$
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu
.getDeclarations()[0];
IASTName name_x = decl1.getDeclarators()[0].getName();
-
+
IASTName[] decls = tu.getDeclarationsInAST(name_x.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_x);
}
-
- // enum hue { red, blue, green };
- // enum hue col, *cp;
- // void f() {
- // col = blue;
- // cp = &col;
- // if (*cp != red)
- // return;
- // }
+
+ // enum hue { red, blue, green };
+ // enum hue col, *cp;
+ // void f() {
+ // col = blue;
+ // cp = &col;
+ // if (*cp != red)
+ // return;
+ // }
public void testEnumerations() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
@@ -1360,7 +1359,7 @@ public class AST2Tests extends AST2BaseTest {
IASTEnumerator e2 = enumSpec.getEnumerators()[1];
IASTEnumerator e3 = enumSpec.getEnumerators()[2];
IASTName name_hue = enumSpec.getName();
-
+
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IASTDeclarator dtor = decl2.getDeclarators()[0];
IASTName name_col = dtor.getName();
@@ -1369,7 +1368,7 @@ public class AST2Tests extends AST2BaseTest {
IASTElaboratedTypeSpecifier spec = (IASTElaboratedTypeSpecifier) decl2.getDeclSpecifier();
assertEquals(spec.getKind(), IASTElaboratedTypeSpecifier.k_enum);
IASTName name_hue2 = spec.getName();
-
+
IASTFunctionDefinition fn = (IASTFunctionDefinition) tu.getDeclarations()[2];
IASTCompoundStatement compound = (IASTCompoundStatement) fn.getBody();
IASTExpressionStatement expStatement1 = (IASTExpressionStatement) compound.getStatements()[0];
@@ -1379,7 +1378,7 @@ public class AST2Tests extends AST2BaseTest {
IASTIdExpression id2 = (IASTIdExpression) exp.getOperand2();
IASTName r_col = id1.getName();
IASTName r_blue = id2.getName();
-
+
IASTExpressionStatement expStatement2 = (IASTExpressionStatement) compound.getStatements()[1];
exp = (IASTBinaryExpression) expStatement2.getExpression();
assertEquals(exp.getOperator(), IASTBinaryExpression.op_assign);
@@ -1388,16 +1387,16 @@ public class AST2Tests extends AST2BaseTest {
id2 = (IASTIdExpression) ue.getOperand();
IASTName r_cp = id1.getName();
IASTName r_col2 = id2.getName();
-
+
IASTIfStatement ifStatement = (IASTIfStatement) compound.getStatements()[2];
exp = (IASTBinaryExpression) ifStatement.getConditionExpression();
ue = (IASTUnaryExpression) exp.getOperand1();
id1 = (IASTIdExpression) ue.getOperand();
id2 = (IASTIdExpression) exp.getOperand2();
-
+
IASTName r_cp2 = id1.getName();
IASTName r_red = id2.getName();
-
+
IEnumeration hue = (IEnumeration) name_hue.resolveBinding();
IEnumerator red = (IEnumerator) e1.getName().resolveBinding();
IEnumerator blue = (IEnumerator) e2.getName().resolveBinding();
@@ -1411,7 +1410,7 @@ public class AST2Tests extends AST2BaseTest {
IVariable col3 = (IVariable) r_col2.resolveBinding();
IVariable cp3 = (IVariable) r_cp2.resolveBinding();
IEnumerator red2 = (IEnumerator) r_red.resolveBinding();
-
+
assertNotNull(hue);
assertSame(hue, hue_2);
assertNotNull(red);
@@ -1425,61 +1424,61 @@ public class AST2Tests extends AST2BaseTest {
assertSame(col, col3);
assertSame(cp, cp3);
assertSame(red, red2);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(name_hue.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_hue);
-
+
decls = tu.getDeclarationsInAST(e1.getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], e1.getName());
-
+
decls = tu.getDeclarationsInAST(e2.getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], e2.getName());
-
+
decls = tu.getDeclarationsInAST(e3.getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], e3.getName());
-
+
decls = tu.getDeclarationsInAST(name_hue2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_hue);
-
+
decls = tu.getDeclarationsInAST(name_col.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_col);
-
+
decls = tu.getDeclarationsInAST(name_cp.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_cp);
-
+
decls = tu.getDeclarationsInAST(fn.getDeclarator().getName()
.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], fn.getDeclarator().getName());
-
+
decls = tu.getDeclarationsInAST(r_col.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_col);
-
+
decls = tu.getDeclarationsInAST(r_blue.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], e2.getName());
-
+
decls = tu.getDeclarationsInAST(r_cp.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_cp);
-
+
decls = tu.getDeclarationsInAST(r_col2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_col);
-
+
decls = tu.getDeclarationsInAST(r_cp2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_cp);
-
+
decls = tu.getDeclarationsInAST(r_red.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], e1.getName());
@@ -1487,7 +1486,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
public void testPointerToFunction() throws Exception {
IASTTranslationUnit tu = parse("int (*pfi)();", ParserLanguage.C); //$NON-NLS-1$
assertTrue(tu.isFrozen());
@@ -1502,7 +1501,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(f.getNestedDeclarator().getName().toString(), "pfi"); //$NON-NLS-1$
assertTrue(f.getPointerOperators().length == 0);
assertFalse(f.getNestedDeclarator().getPointerOperators().length == 0);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(f.getNestedDeclarator().getName()
.resolveBinding());
@@ -1512,13 +1511,13 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
- // int a;
- // char * b;
- // const int c;
- // const char * const d;
- // const char ** e;
- // const char * const * const volatile ** const * f;
+
+ // int a;
+ // char * b;
+ // const int c;
+ // const char * const d;
+ // const char ** e;
+ // const char * const * const volatile ** const * f;
public void testBasicTypes() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
@@ -1542,7 +1541,7 @@ public class AST2Tests extends AST2BaseTest {
decl = (IASTSimpleDeclaration) tu.getDeclarations()[5];
IVariable f = (IVariable) decl.getDeclarators()[0].getName()
.resolveBinding();
-
+
IType t_a_1 = a.getType();
assertTrue(t_a_1 instanceof IBasicType);
assertFalse(((IBasicType) t_a_1).isLong());
@@ -1550,20 +1549,20 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(((IBasicType) t_a_1).isSigned());
assertFalse(((IBasicType) t_a_1).isUnsigned());
assertEquals(((IBasicType) t_a_1).getType(), IBasicType.t_int);
-
+
IType t_b_1 = b.getType();
assertTrue(t_b_1 instanceof IPointerType);
IType t_b_2 = ((IPointerType) t_b_1).getType();
assertTrue(t_b_2 instanceof IBasicType);
assertEquals(((IBasicType) t_b_2).getType(), IBasicType.t_char);
-
+
IType t_c_1 = c.getType();
assertTrue(t_c_1 instanceof IQualifierType);
assertTrue(((IQualifierType) t_c_1).isConst());
IType t_c_2 = ((IQualifierType) t_c_1).getType();
assertTrue(t_c_2 instanceof IBasicType);
assertEquals(((IBasicType) t_c_2).getType(), IBasicType.t_int);
-
+
IType t_d_1 = d.getType();
assertTrue(t_d_1 instanceof IPointerType);
assertTrue(((IPointerType) t_d_1).isConst());
@@ -1573,7 +1572,7 @@ public class AST2Tests extends AST2BaseTest {
IType t_d_3 = ((IQualifierType) t_d_2).getType();
assertTrue(t_d_3 instanceof IBasicType);
assertEquals(((IBasicType) t_d_3).getType(), IBasicType.t_char);
-
+
IType t_e_1 = e.getType();
assertTrue(t_e_1 instanceof IPointerType);
assertFalse(((IPointerType) t_e_1).isConst());
@@ -1586,7 +1585,7 @@ public class AST2Tests extends AST2BaseTest {
IType t_e_4 = ((IQualifierType) t_e_3).getType();
assertTrue(t_e_4 instanceof IBasicType);
assertEquals(((IBasicType) t_e_4).getType(), IBasicType.t_char);
-
+
IType t_f_1 = f.getType();
assertTrue(t_f_1 instanceof IPointerType);
assertFalse(((IPointerType) t_f_1).isConst());
@@ -1617,7 +1616,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
// int plainInt = 7;
// signed int signedInt = -2;
// unsigned int unsignedInt = 99;
@@ -1625,20 +1624,20 @@ public class AST2Tests extends AST2BaseTest {
public void testBug270275_int_is_equivalent_to_signed_int() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
IASTDeclaration[] declarations = tu.getDeclarations();
- IType plainInt = ((IVariable)((IASTSimpleDeclaration)declarations[0]).getDeclarators()[0].getName().resolveBinding()).getType();
- IType signedInt = ((IVariable)((IASTSimpleDeclaration)declarations[1]).getDeclarators()[0].getName().resolveBinding()).getType();
- IType unsignedInt = ((IVariable)((IASTSimpleDeclaration)declarations[2]).getDeclarators()[0].getName().resolveBinding()).getType();
- IType noSpec = ((IVariable)((IASTSimpleDeclaration)declarations[3]).getDeclarators()[0].getName().resolveBinding()).getType();
+ IType plainInt = ((IVariable)((IASTSimpleDeclaration) declarations[0]).getDeclarators()[0].getName().resolveBinding()).getType();
+ IType signedInt = ((IVariable)((IASTSimpleDeclaration) declarations[1]).getDeclarators()[0].getName().resolveBinding()).getType();
+ IType unsignedInt = ((IVariable)((IASTSimpleDeclaration) declarations[2]).getDeclarators()[0].getName().resolveBinding()).getType();
+ IType noSpec = ((IVariable)((IASTSimpleDeclaration) declarations[3]).getDeclarators()[0].getName().resolveBinding()).getType();
assertTrue(plainInt.isSameType(signedInt));
assertFalse(plainInt.isSameType(unsignedInt));
assertFalse(signedInt.isSameType(unsignedInt));
assertTrue(plainInt.isSameType(noSpec));
}
-
- // struct A {} a1;
- // typedef struct A * AP;
- // struct A * const a2;
- // AP a3;
+
+ // struct A {} a1;
+ // typedef struct A * AP;
+ // struct A * const a2;
+ // AP a3;
public void testCompositeTypes() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
@@ -1660,50 +1659,50 @@ public class AST2Tests extends AST2BaseTest {
IVariable a3 = (IVariable) decl.getDeclarators()[0].getName().resolveBinding();
IASTName name_a3 = decl.getDeclarators()[0].getName();
IASTName name_AP2 = ((IASTNamedTypeSpecifier) decl.getDeclSpecifier()).getName();
-
+
IType t_a1 = a1.getType();
assertSame(t_a1, A);
-
+
IType t_a2 = a2.getType();
assertTrue(t_a2 instanceof IPointerType);
assertTrue(((IPointerType) t_a2).isConst());
assertSame(((IPointerType) t_a2).getType(), A);
-
+
IType t_a3 = a3.getType();
assertSame(t_a3, AP);
IType t_AP = AP.getType();
assertTrue(t_AP instanceof IPointerType);
assertSame(((IPointerType) t_AP).getType(), A);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(compSpec.getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], compSpec.getName());
-
+
decls = tu.getDeclarationsInAST(name_a1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_a1);
-
+
decls = tu.getDeclarationsInAST(name_A2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], compSpec.getName());
-
+
decls = tu.getDeclarationsInAST(name_AP.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_AP);
-
+
decls = tu.getDeclarationsInAST(name_A3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], compSpec.getName());
-
+
decls = tu.getDeclarationsInAST(name_a2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_a2);
-
+
decls = tu.getDeclarationsInAST(name_AP2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_AP);
-
+
decls = tu.getDeclarationsInAST(name_a3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_a3);
@@ -1711,10 +1710,10 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
- // int a[restrict];
- // char * b[][];
- // const char * const c[][][];
+
+ // int a[restrict];
+ // char * b[][];
+ // const char * const c[][][];
// char* d[const][];
public void testArrayTypes() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
@@ -1732,14 +1731,14 @@ public class AST2Tests extends AST2BaseTest {
decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
IASTName name_d = decl.getDeclarators()[0].getName();
IVariable d = (IVariable) decl.getDeclarators()[0].getName().resolveBinding();
-
+
IType t_a_1 = a.getType();
assertTrue(t_a_1 instanceof ICArrayType);
assertTrue(((ICArrayType) t_a_1).isRestrict());
IType t_a_2 = ((IArrayType) t_a_1).getType();
assertTrue(t_a_2 instanceof IBasicType);
assertEquals(((IBasicType) t_a_2).getType(), IBasicType.t_int);
-
+
IType t_b_1 = b.getType();
assertTrue(t_b_1 instanceof IArrayType);
IType t_b_2 = ((IArrayType) t_b_1).getType();
@@ -1749,7 +1748,7 @@ public class AST2Tests extends AST2BaseTest {
IType t_b_4 = ((IPointerType) t_b_3).getType();
assertTrue(t_b_4 instanceof IBasicType);
assertEquals(((IBasicType) t_b_4).getType(), IBasicType.t_char);
-
+
t_b_1 = d.getType();
assertTrue(t_b_1 instanceof IArrayType);
t_b_2 = ((IArrayType) t_b_1).getType();
@@ -1759,7 +1758,7 @@ public class AST2Tests extends AST2BaseTest {
t_b_4 = ((IPointerType) t_b_3).getType();
assertTrue(t_b_4 instanceof IBasicType);
assertEquals(((IBasicType) t_b_4).getType(), IBasicType.t_char);
-
+
IType t_c_1 = c.getType();
assertTrue(t_c_1 instanceof IArrayType);
IType t_c_2 = ((IArrayType) t_c_1).getType();
@@ -1775,16 +1774,16 @@ public class AST2Tests extends AST2BaseTest {
IType t_c_6 = ((IQualifierType) t_c_5).getType();
assertTrue(t_c_6 instanceof IBasicType);
assertEquals(((IBasicType) t_c_6).getType(), IBasicType.t_char);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(name_a.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_a);
-
+
decls = tu.getDeclarationsInAST(name_b.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_b);
-
+
decls = tu.getDeclarationsInAST(name_c.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_c);
@@ -1792,11 +1791,11 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
- // struct A;
- // int * f(int i, char c);
- // void (*g) (struct A *);
- // void (* (*h)(struct A**)) (int d);
+
+ // struct A;
+ // int * f(int i, char c);
+ // void (*g) (struct A *);
+ // void (* (*h)(struct A**)) (int d);
public void testFunctionTypes() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
@@ -1806,7 +1805,7 @@ public class AST2Tests extends AST2BaseTest {
ICompositeType A = (ICompositeType) elabSpec.getName().resolveBinding();
IASTName name_A1 = elabSpec.getName();
assertTrue(name_A1.isDeclaration());
-
+
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IFunction f = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
IASTName name_f = decl.getDeclarators()[0].getName();
@@ -1814,14 +1813,14 @@ public class AST2Tests extends AST2BaseTest {
.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
IASTName name_c = ((IASTStandardFunctionDeclarator) decl
.getDeclarators()[0]).getParameters()[1].getDeclarator().getName();
-
+
decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
IVariable g = (IVariable) decl.getDeclarators()[0]
.getNestedDeclarator().getName().resolveBinding();
IASTName name_g = decl.getDeclarators()[0].getNestedDeclarator().getName();
IASTName name_A2 = ((IASTElaboratedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl
.getDeclarators()[0]).getParameters()[0].getDeclSpecifier()).getName();
-
+
decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
IVariable h = (IVariable) decl.getDeclarators()[0]
.getNestedDeclarator().getNestedDeclarator().getName().resolveBinding();
@@ -1832,7 +1831,7 @@ public class AST2Tests extends AST2BaseTest {
.getDeclSpecifier()).getName();
IASTName name_d = ((IASTStandardFunctionDeclarator) decl
.getDeclarators()[0]).getParameters()[0].getDeclarator().getName();
-
+
IFunctionType t_f = f.getType();
IType t_f_return = t_f.getReturnType();
assertTrue(t_f_return instanceof IPointerType);
@@ -1841,7 +1840,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(t_f_params.length, 2);
assertTrue(t_f_params[0] instanceof IBasicType);
assertTrue(t_f_params[1] instanceof IBasicType);
-
+
// g is a pointer to a function that returns void and has 1 parameter
// struct A *
IType t_g = g.getType();
@@ -1855,7 +1854,7 @@ public class AST2Tests extends AST2BaseTest {
IType t_g_func_p1 = t_g_func_params[0];
assertTrue(t_g_func_p1 instanceof IPointerType);
assertSame(((IPointerType) t_g_func_p1).getType(), A);
-
+
// h is a pointer to a function that returns a pointer to a function
// the returned pointer to function returns void and takes 1 parameter
// int
@@ -1872,7 +1871,7 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(((IPointerType) t_h_func_p1).getType() instanceof IPointerType);
assertSame(((IPointerType) ((IPointerType) t_h_func_p1).getType())
.getType(), A);
-
+
assertTrue(t_h_func_return instanceof IPointerType);
IFunctionType h_return = (IFunctionType) ((IPointerType) t_h_func_return)
.getType();
@@ -1881,46 +1880,46 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(h_r instanceof IBasicType);
assertEquals(h_ps.length, 1);
assertTrue(h_ps[0] instanceof IBasicType);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(name_A1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_A1);
-
+
decls = tu.getDeclarationsInAST(name_f.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_f);
-
+
decls = tu.getDeclarationsInAST(name_i.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_i);
-
+
decls = tu.getDeclarationsInAST(name_c.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_c);
-
+
decls = tu.getDeclarationsInAST(name_g.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_g);
-
+
decls = tu.getDeclarationsInAST(name_A2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_A1);
-
+
decls = tu.getDeclarationsInAST(name_h.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_h);
-
+
decls = tu.getDeclarationsInAST(name_A3.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_A1);
-
+
assertNull("Expected null, got "+name_d.resolveBinding(), name_d.resolveBinding());
tu = validateCopy(tu);
}
}
-
+
// typedef struct {
// int x;
// int y;
@@ -1952,7 +1951,7 @@ public class AST2Tests extends AST2BaseTest {
.getDeclSpecifier()).getMembers()[1]).getDeclarators()[0].getName();
IASTFunctionDefinition main = (IASTFunctionDefinition) declarations[2];
IASTStatement[] statements = ((IASTCompoundStatement) main.getBody()).getStatements();
-
+
IASTSimpleDeclaration xy = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[0]).getDeclaration();
IASTName name_Coord2 = ((IASTNamedTypeSpecifier) xy.getDeclSpecifier()).getName();
IASTName name_xy = xy.getDeclarators()[0].getName();
@@ -1961,14 +1960,14 @@ public class AST2Tests extends AST2BaseTest {
.getInitializerClause()).getInitializers();
IASTName name_y2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[0])
.getDesignators()[0]).getName();
-
+
// test bug 87649
assertEquals(((ASTNode) (ICASTDesignatedInitializer) initializers1[0])
.getLength(), 7);
-
+
IASTName name_x2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers1[1])
.getDesignators()[0]).getName();
-
+
IASTSimpleDeclaration point = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statements[1])
.getDeclaration();
IASTName name_Point2 = ((IASTNamedTypeSpecifier) point
@@ -1984,47 +1983,47 @@ public class AST2Tests extends AST2BaseTest {
IASTName name_xy2 = ((IASTIdExpression) ((IASTUnaryExpression) ((IASTEqualsInitializer) ((ICASTDesignatedInitializer) initializers2[1])
.getOperandInitializer()).getInitializerClause()).getOperand())
.getName();
-
+
for (int j = 0; j < 2; ++j) {
ICASTDesignatedInitializer designatedInitializer = (ICASTDesignatedInitializer) initializers1[j];
assertEquals(designatedInitializer.getDesignators().length, 1);
ICASTFieldDesignator fieldDesignator = (ICASTFieldDesignator) designatedInitializer.getDesignators()[0];
assertNotNull(fieldDesignator.getName().toString());
}
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(name_Coord2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_Coord);
-
+
decls = tu.getDeclarationsInAST(name_xy.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_xy);
-
+
decls = tu.getDeclarationsInAST(name_y2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_y);
-
+
decls = tu.getDeclarationsInAST(name_x2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_x);
-
+
decls = tu.getDeclarationsInAST(name_Point2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_Point);
-
+
decls = tu.getDeclarationsInAST(name_point.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_point);
-
+
decls = tu.getDeclarationsInAST(name_width2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_width);
-
+
decls = tu.getDeclarationsInAST(name_pos2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_pos);
-
+
decls = tu.getDeclarationsInAST(name_xy2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_xy);
@@ -2032,7 +2031,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
// struct S {
// int a;
// int b;
@@ -2046,7 +2045,7 @@ public class AST2Tests extends AST2BaseTest {
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTFunctionDefinition f_def = (IASTFunctionDefinition) tu.getDeclarations()[1];
-
+
IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl
.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0]
.getName();
@@ -2055,19 +2054,19 @@ public class AST2Tests extends AST2BaseTest {
.getName();
final IASTDeclarator dtor = ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) f_def
.getBody()).getStatements()[0]).getDeclaration()).getDeclarators()[0];
- final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer)dtor.getInitializer()).getInitializerClause();
+ final IASTInitializerList initializerList = (IASTInitializerList) ((IASTEqualsInitializer) dtor.getInitializer()).getInitializerClause();
IASTName a2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[0])
.getDesignators()[0]).getName();
IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializerList.getInitializers()[1])
.getDesignators()[0]).getName();
-
+
assertEquals(a1.resolveBinding(), a2.resolveBinding());
assertEquals(b1.resolveBinding(), b2.resolveBinding());
-
+
IASTName[] decls = tu.getDeclarationsInAST(a1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(a1, decls[0]);
-
+
decls = tu.getDeclarationsInAST(b1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(b1, decls[0]);
@@ -2075,17 +2074,17 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
- // struct S {
- // int a;
- // int b;
+
+ // struct S {
+ // int a;
+ // int b;
// } s = {.a=1,.b=2};
public void testMoregetDeclarationsInAST2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
-
+
IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl
.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0]
.getName();
@@ -2098,25 +2097,25 @@ public class AST2Tests extends AST2BaseTest {
.getDesignators()[0]).getName();
IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) initializers[1])
.getDesignators()[0]).getName();
-
+
assertEquals(a1.resolveBinding(), a2.resolveBinding());
assertEquals(b1.resolveBinding(), b2.resolveBinding());
-
+
IASTName[] decls = tu.getDeclarationsInAST(a1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(a1, decls[0]);
-
+
decls = tu.getDeclarationsInAST(b1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(b1, decls[0]);
-
+
tu = validateCopy(tu);
}
}
-
- // typedef struct S {
- // int a;
- // int b;
+
+ // typedef struct S {
+ // int a;
+ // int b;
// } s;
// typedef s t;
// typedef t y;
@@ -2127,7 +2126,7 @@ public class AST2Tests extends AST2BaseTest {
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration S_decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IASTSimpleDeclaration x_decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
-
+
IASTName a1 = ((IASTSimpleDeclaration) ((IASTCompositeTypeSpecifier) S_decl
.getDeclSpecifier()).getMembers()[0]).getDeclarators()[0]
.getName();
@@ -2140,14 +2139,14 @@ public class AST2Tests extends AST2BaseTest {
.getDesignators()[0]).getName();
IASTName b2 = ((ICASTFieldDesignator) ((ICASTDesignatedInitializer) ((IASTInitializerList) initializer).getInitializers()[1])
.getDesignators()[0]).getName();
-
+
assertEquals(a1.resolveBinding(), a2.resolveBinding());
assertEquals(b1.resolveBinding(), b2.resolveBinding());
-
+
IASTName[] decls = tu.getDeclarationsInAST(a1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(a1, decls[0]);
-
+
decls = tu.getDeclarationsInAST(b1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(b1, decls[0]);
@@ -2155,7 +2154,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
public void testFnReturningPtrToFn() throws Exception {
IASTTranslationUnit tu = parse(
"void (* f(int))() {}", ParserLanguage.C); //$NON-NLS-1$
@@ -2164,12 +2163,12 @@ public class AST2Tests extends AST2BaseTest {
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
final IASTName fname = def.getDeclarator().getName();
IFunction f = (IFunction) fname.resolveBinding();
-
+
IFunctionType ft = f.getType();
assertTrue(ft.getReturnType() instanceof IPointerType);
assertTrue(((IPointerType) ft.getReturnType()).getType() instanceof IFunctionType);
assertEquals(ft.getParameterTypes().length, 1);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(f);
assertEquals(decls.length, 1);
@@ -2178,7 +2177,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
// test C99: 6.7.5.3-7 A declaration of a parameter as ''array of type''
// shall be adjusted to ''qualified pointer to
// type'', where the type qualifiers (if any) are those specified within the
@@ -2191,11 +2190,11 @@ public class AST2Tests extends AST2BaseTest {
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration def = (IASTSimpleDeclaration) tu.getDeclarations()[0];
IFunction f = (IFunction) def.getDeclarators()[0].getName().resolveBinding();
-
+
IFunctionType ft = f.getType();
assertTrue(ft.getParameterTypes()[0] instanceof IPointerType);
assertTrue(((IPointerType) ft.getParameterTypes()[0]).isConst());
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName name_parm = ((IASTStandardFunctionDeclarator) def
.getDeclarators()[0]).getParameters()[0].getDeclarator()
@@ -2225,46 +2224,38 @@ public class AST2Tests extends AST2BaseTest {
// int *f2() {}
// int (* f3())() {}
public void testFunctionDefTypes() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
-
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
+
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
- IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu
- .getDeclarations()[0];
- IFunction f = (IFunction) def1.getDeclarator().getName()
- .resolveBinding();
- IASTFunctionDefinition def2 = (IASTFunctionDefinition) tu
- .getDeclarations()[1];
- IFunction f2 = (IFunction) def2.getDeclarator().getName()
- .resolveBinding();
- IASTFunctionDefinition def3 = (IASTFunctionDefinition) tu
- .getDeclarations()[2];
- IFunction f3 = (IFunction) def3.getDeclarator().getName()
- .resolveBinding();
-
+ IASTFunctionDefinition def1 = (IASTFunctionDefinition) tu.getDeclarations()[0];
+ IFunction f = (IFunction) def1.getDeclarator().getName().resolveBinding();
+ IASTFunctionDefinition def2 = (IASTFunctionDefinition) tu.getDeclarations()[1];
+ IFunction f2 = (IFunction) def2.getDeclarator().getName().resolveBinding();
+ IASTFunctionDefinition def3 = (IASTFunctionDefinition) tu.getDeclarations()[2];
+ IFunction f3 = (IFunction) def3.getDeclarator().getName().resolveBinding();
+
IFunctionType ft = f.getType();
IFunctionType ft2 = f2.getType();
IFunctionType ft3 = f3.getType();
-
+
assertTrue(ft.getReturnType() instanceof IBasicType);
assertTrue(ft2.getReturnType() instanceof IPointerType);
assertTrue(((IPointerType) ft2.getReturnType()).getType() instanceof IBasicType);
assertTrue(ft3.getReturnType() instanceof IPointerType);
assertTrue(((IPointerType) ft3.getReturnType()).getType() instanceof IFunctionType);
- assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType())
- .getType()).getReturnType() instanceof IBasicType);
-
+ assertTrue(((IFunctionType) ((IPointerType) ft3.getReturnType()).getType()).getReturnType()
+ instanceof IBasicType);
+
// test tu.getDeclarationsInAST(IBinding)
- IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName()
- .resolveBinding());
+ IASTName[] decls = tu.getDeclarationsInAST(def1.getDeclarator().getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], def1.getDeclarator().getName());
-
- decls = tu.getDeclarationsInAST(def2.getDeclarator().getName()
- .resolveBinding());
+
+ decls = tu.getDeclarationsInAST(def2.getDeclarator().getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], def2.getDeclarator().getName());
-
+
decls = tu.getDeclarationsInAST(def3.getDeclarator().getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], def3.getDeclarator().getName());
@@ -2272,17 +2263,16 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
// any parameter to type function returning T is adjusted to be pointer to
// function returning T
public void testParmToFunction() throws Exception {
- IASTTranslationUnit tu = parse(
- "int f(int g(void)) { return g();}", ParserLanguage.C); //$NON-NLS-1$
+ IASTTranslationUnit tu = parse("int f(int g(void)) { return g();}", ParserLanguage.C);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTFunctionDefinition def = (IASTFunctionDefinition) tu.getDeclarations()[0];
IFunction f = (IFunction) def.getDeclarator().getName().resolveBinding();
-
+
IType ft = ((CFunction) f).getType();
assertTrue(ft instanceof IFunctionType);
IType gt_1 = ((IFunctionType) ft).getParameterTypes()[0];
@@ -2295,12 +2285,13 @@ public class AST2Tests extends AST2BaseTest {
IType gt_parm = ((IFunctionType) gt_2).getParameterTypes()[0];
assertTrue(gt_parm instanceof IBasicType);
assertEquals(((IBasicType) gt_parm).getType(), IBasicType.t_void);
-
+
// test tu.getDeclarationsInAST(IBinding)
assertTrue(def.getDeclarator() instanceof IASTStandardFunctionDeclarator);
IASTName name_g = ((IASTStandardFunctionDeclarator) def.getDeclarator())
.getParameters()[0].getDeclarator().getName();
- IASTName name_g_call = ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def
+ IASTName name_g_call =
+ ((IASTIdExpression) ((IASTFunctionCallExpression) ((IASTReturnStatement) ((IASTCompoundStatement) def
.getBody()).getStatements()[0]).getReturnValue())
.getFunctionNameExpression()).getName();
IASTName[] decls = tu.getDeclarationsInAST(name_g_call.resolveBinding());
@@ -2310,18 +2301,16 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
public void testArrayPointerFunction() throws Exception {
- IASTTranslationUnit tu = parse(
- "int (*v[])(int *x, int *y);", ParserLanguage.C); //$NON-NLS-1$
-
+ IASTTranslationUnit tu = parse("int (*v[])(int *x, int *y);", ParserLanguage.C);
+
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
- IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl
- .getDeclarators()[0]).getNestedDeclarator().getName()
- .resolveBinding();
-
+ IVariable v = (IVariable) ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0])
+ .getNestedDeclarator().getName().resolveBinding();
+
IType vt_1 = v.getType();
assertTrue(vt_1 instanceof IArrayType);
IType vt_2 = ((IArrayType) vt_1).getType();
@@ -2342,25 +2331,25 @@ public class AST2Tests extends AST2BaseTest {
IType vpt_2_2 = ((IPointerType) vpt_1).getType();
assertTrue(vpt_2_2 instanceof IBasicType);
assertEquals(((IBasicType) vpt_2_2).getType(), IBasicType.t_int);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName[] decls = tu.getDeclarationsInAST(((IASTStandardFunctionDeclarator) decl
.getDeclarators()[0]).getNestedDeclarator().getName()
.resolveBinding());
assertEquals(decls.length, 1);
- assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl
- .getDeclarators()[0]).getNestedDeclarator().getName());
+ assertEquals(decls[0], ((IASTStandardFunctionDeclarator) decl.getDeclarators()[0])
+ .getNestedDeclarator().getName());
tu = validateCopy(tu);
}
}
-
+
// typedef void DWORD;
// typedef DWORD v;
// v signal(int);
public void testTypedefExample4a() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
-
+
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration decl1 = (IASTSimpleDeclaration) tu.getDeclarations()[0];
@@ -2368,7 +2357,7 @@ public class AST2Tests extends AST2BaseTest {
IType dword_t = dword.getType();
assertTrue(dword_t instanceof IBasicType);
assertEquals(((IBasicType) dword_t).getType(), IBasicType.t_void);
-
+
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
ITypedef v = (ITypedef) decl2.getDeclarators()[0].getName().resolveBinding();
IType v_t_1 = v.getType();
@@ -2376,7 +2365,7 @@ public class AST2Tests extends AST2BaseTest {
IType v_t_2 = ((ITypedef) v_t_1).getType();
assertTrue(v_t_2 instanceof IBasicType);
assertEquals(((IBasicType) v_t_2).getType(), IBasicType.t_void);
-
+
IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu.getDeclarations()[2];
IFunction signal = (IFunction) decl3.getDeclarators()[0].getName().resolveBinding();
IFunctionType signal_t = signal.getType();
@@ -2387,20 +2376,20 @@ public class AST2Tests extends AST2BaseTest {
IType signal_ret3 = ((ITypedef) signal_ret2).getType();
assertTrue(signal_ret3 instanceof IBasicType);
assertEquals(((IBasicType) signal_ret3).getType(), IBasicType.t_void);
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName name_DWORD = decl1.getDeclarators()[0].getName();
IASTName name_v = decl2.getDeclarators()[0].getName();
-
+
IASTName[] decls = tu.getDeclarationsInAST(name_DWORD.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_DWORD);
-
- decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2
- .getDeclSpecifier()).getName().resolveBinding());
+
+ decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl2.getDeclSpecifier())
+ .getName().resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_DWORD);
-
+
decls = tu.getDeclarationsInAST(((IASTNamedTypeSpecifier) decl3
.getDeclSpecifier()).getName().resolveBinding());
assertEquals(decls.length, 1);
@@ -2409,7 +2398,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
// typedef void DWORD;
// typedef DWORD (*pfv)(int);
// pfv signal(int, pfv);
@@ -2422,7 +2411,7 @@ public class AST2Tests extends AST2BaseTest {
IType dword_t = dword.getType();
assertTrue(dword_t instanceof IBasicType);
assertEquals(((IBasicType) dword_t).getType(), IBasicType.t_void);
-
+
IASTSimpleDeclaration decl2 = (IASTSimpleDeclaration) tu.getDeclarations()[1];
ITypedef pfv = (ITypedef) decl2.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
IType pfv_t_1 = pfv.getType();
@@ -2438,7 +2427,7 @@ public class AST2Tests extends AST2BaseTest {
IType pfv_t_2_parm = ((IFunctionType) pfv_t_2).getParameterTypes()[0];
assertTrue(pfv_t_2_parm instanceof IBasicType);
assertEquals(((IBasicType) pfv_t_2_parm).getType(), IBasicType.t_int);
-
+
IASTSimpleDeclaration decl3 = (IASTSimpleDeclaration) tu.getDeclarations()[2];
IFunction signal = (IFunction) decl3.getDeclarators()[0].getName().resolveBinding();
IFunctionType signal_t = signal.getType();
@@ -2455,7 +2444,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(((IBasicType) signal_ret_ret_2).getType(),
IBasicType.t_void);
assertTrue(((ITypedef) signal_ret_ret_1).getName().equals("DWORD")); //$NON-NLS-1$
-
+
IType signal_parm_t1 = signal_t.getParameterTypes()[0];
assertTrue(signal_parm_t1 instanceof IBasicType);
assertEquals(((IBasicType) signal_parm_t1).getType(), IBasicType.t_int);
@@ -2472,65 +2461,65 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(((IBasicType) signal_parm_t2_ret_2).getType(),
IBasicType.t_void);
assertTrue(((ITypedef) signal_parm_t2_ret_1).getName().equals("DWORD")); //$NON-NLS-1$
-
+
// test tu.getDeclarationsInAST(IBinding)
IASTName name_pfv = decl2.getDeclarators()[0].getNestedDeclarator().getName();
IASTName name_pfv1 = ((IASTNamedTypeSpecifier) decl3.getDeclSpecifier()).getName();
IASTName name_pfv2 = ((IASTNamedTypeSpecifier) ((IASTStandardFunctionDeclarator) decl3
.getDeclarators()[0]).getParameters()[1].getDeclSpecifier()).getName();
-
+
IASTName[] decls = tu.getDeclarationsInAST(name_pfv1.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_pfv);
-
+
decls = tu.getDeclarationsInAST(name_pfv2.resolveBinding());
assertEquals(decls.length, 1);
assertEquals(decls[0], name_pfv);
-
+
tu = validateCopy(tu);
}
}
-
+
// typedef void fv(int), (*pfv)(int);
// void (*signal1(int, void (*)(int)))(int);
// fv *signal2(int, fv *);
// pfv signal3(int, pfv);
public void testTypedefExample4c() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
-
+
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0];
ITypedef fv = (ITypedef) decl.getDeclarators()[0].getName().resolveBinding();
ITypedef pfv = (ITypedef) decl.getDeclarators()[1].getNestedDeclarator().getName().resolveBinding();
-
+
IType fv_t = fv.getType();
assertEquals(((IBasicType) ((IFunctionType) fv_t).getReturnType())
.getType(), IBasicType.t_void);
assertEquals(
((IBasicType) ((IFunctionType) fv_t).getParameterTypes()[0])
.getType(), IBasicType.t_int);
-
+
IType pfv_t = pfv.getType();
assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv_t)
.getType()).getReturnType()).getType(), IBasicType.t_void);
assertEquals(((IBasicType) ((IFunctionType) ((IPointerType) pfv
.getType()).getType()).getParameterTypes()[0]).getType(),
IBasicType.t_int);
-
+
decl = (IASTSimpleDeclaration) tu.getDeclarations()[1];
IFunction signal1 = (IFunction) decl.getDeclarators()[0]
.getNestedDeclarator().getName().resolveBinding();
IType signal1_t = signal1.getType();
-
+
decl = (IASTSimpleDeclaration) tu.getDeclarations()[2];
IFunction signal2 = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
IType signal2_t = signal2.getType();
-
+
decl = (IASTSimpleDeclaration) tu.getDeclarations()[3];
IFunction signal3 = (IFunction) decl.getDeclarators()[0].getName().resolveBinding();
IType signal3_t = signal3.getType();
-
+
assertEquals(
((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t)
.getReturnType()).getType()).getReturnType()).getType(),
@@ -2545,7 +2534,7 @@ public class AST2Tests extends AST2BaseTest {
((IBasicType) ((IFunctionType) ((IPointerType) ((IFunctionType) signal1_t)
.getParameterTypes()[1]).getType()).getParameterTypes()[0])
.getType(), IBasicType.t_int);
-
+
assertEquals(
((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
.getReturnType()).getType()).getType()).getReturnType())
@@ -2560,7 +2549,7 @@ public class AST2Tests extends AST2BaseTest {
((IBasicType) ((IFunctionType) ((ITypedef) ((IPointerType) ((IFunctionType) signal2_t)
.getParameterTypes()[1]).getType()).getType())
.getParameterTypes()[0]).getType(), IBasicType.t_int);
-
+
assertEquals(
((IBasicType) ((IFunctionType) ((IPointerType) ((ITypedef) ((IFunctionType) signal3_t)
.getReturnType()).getType()).getType()).getReturnType())
@@ -2578,9 +2567,9 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
-
+
}
-
+
// const int x = 10;
// int y [ const static x ];
public void testBug80992() throws Exception {
@@ -2593,8 +2582,8 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(mod.isVolatile());
assertFalse(mod.isVariableSized());
}
-
-
+
+
// int y (int [ const *]);
public void testBug80978() throws Exception {
ICASTArrayModifier mod = (ICASTArrayModifier) ((IASTArrayDeclarator) ((IASTStandardFunctionDeclarator) ((IASTSimpleDeclaration) parse(
@@ -2607,12 +2596,12 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(mod.isRestrict());
assertFalse(mod.isVolatile());
}
-
- //AJN: bug 77383 don't do external variables
- // // void f() {
- // // if (a == 0)
- // // a = a + 3;
- // // }
+
+ //AJN: bug 77383 don't do external variables
+ // // void f() {
+ // // if (a == 0)
+ // // a = a + 3;
+ // // }
// public void testExternalVariable() throws Exception {
// IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
// CNameCollector col = new CNameCollector();
@@ -2623,53 +2612,53 @@ public class AST2Tests extends AST2BaseTest {
// assertTrue(a instanceof ICExternalBinding);
// assertInstances(col, a, 3);
// }
-
- // void f() {
- // int a = 1;
- // if (a == 0)
- // g(a);
- // if (a < 0)
- // g(a >> 1);
- // if (a > 0)
- // g(*(&a + 2));
- // }
+
+ // void f() {
+ // int a = 1;
+ // if (a == 0)
+ // g(a);
+ // if (a < 0)
+ // g(a >> 1);
+ // if (a > 0)
+ // g(*(&a + 2));
+ // }
public void testExternalDefs() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IVariable a = (IVariable) col.getName(1).resolveBinding();
IFunction g = (IFunction) col.getName(3).resolveBinding();
assertNotNull(a);
assertNotNull(g);
assertTrue(g instanceof ICExternalBinding);
-
+
assertEquals(col.size(), 11);
assertInstances(col, a, 7);
assertInstances(col, g, 3);
-
+
tu = validateCopy(tu);
}
}
-
- // typedef struct { int x; int y; } Coord;
- // int f() {
- // Coord xy = { .x = 10, .y = 11 };
- // }
+
+ // typedef struct { int x; int y; } Coord;
+ // int f() {
+ // Coord xy = { .x = 10, .y = 11 };
+ // }
public void testFieldDesignators() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 9);
IField x = (IField) col.getName(1).resolveBinding();
IField y = (IField) col.getName(2).resolveBinding();
ITypedef Coord = (ITypedef) col.getName(3).resolveBinding();
-
+
assertInstances(col, x, 2);
assertInstances(col, y, 2);
assertInstances(col, Coord, 2);
@@ -2677,7 +2666,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
// enum { member_one, member_two };
// const char *nm[] = {
// [member_one] = "one",
@@ -2689,18 +2678,18 @@ public class AST2Tests extends AST2BaseTest {
for (int i = 0; i < NUM_TESTS; i++) {
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 6);
IEnumerator one = (IEnumerator) col.getName(1).resolveBinding();
IEnumerator two = (IEnumerator) col.getName(2).resolveBinding();
-
+
assertInstances(col, one, 2);
assertInstances(col, two, 2);
tu = validateCopy(tu);
}
}
-
+
// void f() {
// if (a == 0)
// g(a);
@@ -2732,23 +2721,23 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
- // void f() {
- // while (1) {
- // if (1) goto end;
- // }
- // end: ;
- // }
+
+ // void f() {
+ // while (1) {
+ // if (1) goto end;
+ // }
+ // end: ;
+ // }
public void testBug84090_LabelReferences() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
assertTrue(tu.isFrozen());
for (int i = 0; i < NUM_TESTS; i++) {
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 3);
ILabel end = (ILabel) col.getName(1).resolveBinding();
-
+
IASTName[] refs = tu.getReferences(end);
assertEquals(refs.length, 1);
assertSame(refs[0].resolveBinding(), end);
@@ -2756,7 +2745,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
// enum col { red, blue };
// enum col c;
public void testBug84092_EnumReferences() throws Exception {
@@ -2765,10 +2754,10 @@ public class AST2Tests extends AST2BaseTest {
for (int i = 0; i < NUM_TESTS; i++) {
CNameCollector collector = new CNameCollector();
tu.accept(collector);
-
+
assertEquals(collector.size(), 5);
IEnumeration col = (IEnumeration) collector.getName(0).resolveBinding();
-
+
IASTName[] refs = tu.getReferences(col);
assertEquals(refs.length, 1);
assertSame(refs[0].resolveBinding(), col);
@@ -2776,7 +2765,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
public void testBug84096_FieldDesignatorRef() throws Exception {
IASTTranslationUnit tu = parse(
"struct s { int a; } ss = { .a = 1 }; \n", ParserLanguage.C); //$NON-NLS-1$
@@ -2784,10 +2773,10 @@ public class AST2Tests extends AST2BaseTest {
for (int i = 0; i < NUM_TESTS; i++) {
CNameCollector collector = new CNameCollector();
tu.accept(collector);
-
+
assertEquals(collector.size(), 4);
IField a = (IField) collector.getName(1).resolveBinding();
-
+
IASTName[] refs = tu.getReferences(a);
assertEquals(refs.length, 1);
assertSame(refs[0].resolveBinding(), a);
@@ -2795,16 +2784,16 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
public void testProblems() throws Exception {
-
+
IASTTranslationUnit tu = parse(
" a += ;", ParserLanguage.C, true, false); //$NON-NLS-1$
IASTProblem[] ps = CVisitor.getProblems(tu);
assertEquals(ps.length, 1);
ps[0].getMessage();
}
-
+
// enum e;
// enum e{ one };
public void testEnumerationForwards() throws Exception {
@@ -2813,55 +2802,55 @@ public class AST2Tests extends AST2BaseTest {
for (int i = 0; i < NUM_TESTS; i++) {
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 3);
IEnumeration e = (IEnumeration) col.getName(0).resolveBinding();
IEnumerator[] etors = e.getEnumerators();
assertTrue(etors.length == 1);
assertFalse(etors[0] instanceof IProblemBinding);
-
+
assertInstances(col, e, 2);
tu = validateCopy(tu);
}
}
-
- // void f() {
- // int (*p) [2];
- // (&p)[0] = 1;
- // }
+
+ // void f() {
+ // int (*p) [2];
+ // (&p)[0] = 1;
+ // }
public void testBug84185() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 3);
IVariable p = (IVariable) col.getName(1).resolveBinding();
assertTrue(p.getType() instanceof IPointerType);
assertTrue(((IPointerType) p.getType()).getType() instanceof IArrayType);
IArrayType at = (IArrayType) ((IPointerType) p.getType()).getType();
assertTrue(at.getType() instanceof IBasicType);
-
+
assertInstances(col, p, 2);
}
-
- // void f() {
- // int (*p) [2];
- // (&p)[0] = 1;
- // }
+
+ // void f() {
+ // int (*p) [2];
+ // (&p)[0] = 1;
+ // }
public void testBug84185_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 3);
-
+
IVariable p_ref = (IVariable) col.getName(2).resolveBinding();
IVariable p_decl = (IVariable) col.getName(1).resolveBinding();
-
+
assertSame(p_ref, p_decl);
}
-
+
// // example from: C99 6.5.2.5-16
// struct s { int i; };
// void f (void)
@@ -2869,14 +2858,14 @@ public class AST2Tests extends AST2BaseTest {
// struct s *p = 0, *q;
// int j = 0;
// q = p;
- // p = &((struct s) { j++ });
+ // p = &((struct s) { j++ });
// }
public void testBug84176() throws Exception {
parse(getAboveComment(), ParserLanguage.C, false, true);
}
-
- // struct s { double i; } f(void);
- // struct s f(void) {}
+
+ // struct s { double i; } f(void);
+ // struct s f(void) {}
public void testBug84266() throws Exception {
final String code = getAboveComment();
IASTTranslationUnit tu = parse(code, ParserLanguage.C);
@@ -2897,34 +2886,34 @@ public class AST2Tests extends AST2BaseTest {
s_ref = (ICompositeType) col.getName(4).resolveBinding();
assertSame(s_ref, s_decl);
}
-
+
public void testBug84266_2() throws Exception {
IASTTranslationUnit tu = parse("struct s f(void);", ParserLanguage.C); //$NON-NLS-1$
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 3);
-
+
ICompositeType s = (ICompositeType) col.getName(0).resolveBinding();
assertNotNull(s);
-
+
tu = parse("struct s f(void) {}", ParserLanguage.C); //$NON-NLS-1$
col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 3);
-
+
s = (ICompositeType) col.getName(0).resolveBinding();
assertNotNull(s);
}
-
+
public void testBug84250() throws Exception {
assertTrue(((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) parse(
"void f() { int (*p) [2]; }", ParserLanguage.C).getDeclarations()[0]).getBody()).getStatements()[0]).getDeclaration() instanceof IASTSimpleDeclaration); //$NON-NLS-1$
}
-
- // struct s1 { struct s2 *s2p; /* ... */ }; // D1
- // struct s2 { struct s1 *s1p; /* ... */ }; // D2
+
+ // struct s1 { struct s2 *s2p; /* ... */ }; // D1
+ // struct s2 { struct s1 *s1p; /* ... */ }; // D2
public void testBug84186() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
final String code = getAboveComment();
@@ -2948,26 +2937,26 @@ public class AST2Tests extends AST2BaseTest {
assertSame(s_ref, s_decl);
}
}
-
- // typedef struct { int a; } S;
- // void g(S* (*funcp) (void)) {
- // (*funcp)()->a;
- // funcp()->a;
- // }
+
+ // typedef struct { int a; } S;
+ // void g(S* (*funcp) (void)) {
+ // (*funcp)()->a;
+ // funcp()->a;
+ // }
public void testBug84267() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 11);
-
+
ITypedef S = (ITypedef) col.getName(2).resolveBinding();
IField a = (IField) col.getName(10).resolveBinding();
IParameter funcp = (IParameter) col.getName(7).resolveBinding();
assertNotNull(funcp);
assertInstances(col, funcp, 3);
assertInstances(col, a, 3);
-
+
assertTrue(funcp.getType() instanceof IPointerType);
IType t = ((IPointerType) funcp.getType()).getType();
assertTrue(t instanceof IFunctionType);
@@ -2975,36 +2964,36 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(ft.getReturnType() instanceof IPointerType);
assertSame(((IPointerType) ft.getReturnType()).getType(), S);
}
-
- // void f(int m, int c[m][m]);
- // void f(int m, int c[m][m]) {
- // int x;
- // { int x = x; }
- // }
+
+ // void f(int m, int c[m][m]);
+ // void f(int m, int c[m][m]) {
+ // int x;
+ // { int x = x; }
+ // }
public void testBug84228() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertEquals(col.size(), 13);
-
+
IParameter m = (IParameter) col.getName(3).resolveBinding();
IVariable x3 = (IVariable) col.getName(12).resolveBinding();
IVariable x2 = (IVariable) col.getName(11).resolveBinding();
IVariable x1 = (IVariable) col.getName(10).resolveBinding();
-
+
assertSame(x2, x3);
assertNotSame(x1, x2);
-
+
assertInstances(col, m, 6);
assertInstances(col, x1, 1);
assertInstances(col, x2, 2);
-
+
IASTName[] ds = tu.getDeclarationsInAST(x2);
assertEquals(ds.length, 1);
assertSame(ds[0], col.getName(11));
}
-
+
public void testBug84236() throws Exception {
String code = "double maximum(double a[ ][*]);"; //$NON-NLS-1$
IASTSimpleDeclaration d = (IASTSimpleDeclaration) parse(code,
@@ -3015,9 +3004,9 @@ public class AST2Tests extends AST2BaseTest {
IASTArrayDeclarator a = (IASTArrayDeclarator) p.getDeclarator();
ICASTArrayModifier star = (ICASTArrayModifier) a.getArrayModifiers()[1];
assertTrue(star.isVariableSized());
-
+
}
-
+
// typedef int B;
// void g() {
// B * bp; //1
@@ -3031,108 +3020,108 @@ public class AST2Tests extends AST2BaseTest {
IASTSimpleDeclaration bp = (IASTSimpleDeclaration) ((IASTDeclarationStatement) statement)
.getDeclaration();
assertTrue(bp.getDeclarators()[0].getName().resolveBinding() instanceof IVariable);
-
+
}
-
+
public void testBug86766() throws Exception {
IASTTranslationUnit tu = parse(
"char foo; void foo() {}", ParserLanguage.C); //$NON-NLS-1$
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IVariable foo = (IVariable) col.getName(0).resolveBinding();
IProblemBinding prob = (IProblemBinding) col.getName(1)
.resolveBinding();
assertEquals(prob.getID(), IProblemBinding.SEMANTIC_INVALID_OVERLOAD);
assertNotNull(foo);
}
-
+
public void testBug88338_C() throws Exception {
IASTTranslationUnit tu = parse(
"struct A; struct A* a;", ParserLanguage.C); //$NON-NLS-1$
CPPNameCollector col = new CPPNameCollector();
tu.accept(col);
-
+
assertTrue(col.getName(0).isDeclaration());
assertFalse(col.getName(0).isReference());
assertTrue(col.getName(1).isReference());
assertFalse(col.getName(1).isDeclaration());
-
+
tu = parse("struct A* a; struct A;", ParserLanguage.C); //$NON-NLS-1$
col = new CPPNameCollector();
tu.accept(col);
-
+
col.getName(2).resolveBinding();
-
+
assertTrue(col.getName(0).isDeclaration());
assertFalse(col.getName(0).isReference());
-
+
assertTrue(col.getName(2).isDeclaration());
assertFalse(col.getName(2).isReference());
}
-
+
public void test88460() throws Exception {
IASTTranslationUnit tu = parse("void f();", ParserLanguage.C); //$NON-NLS-1$
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IFunction f = (IFunction) col.getName(0).resolveBinding();
assertFalse(f.isStatic());
}
-
+
public void testBug90253() throws Exception {
IASTTranslationUnit tu = parse(
"void f(int par) { int v1; };", ParserLanguage.C); //$NON-NLS-1$
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IFunction f = (IFunction) col.getName(0).resolveBinding();
IParameter p = (IParameter) col.getName(1).resolveBinding();
IVariable v1 = (IVariable) col.getName(2).resolveBinding();
-
+
IASTFunctionDefinition fdef= getDeclaration(tu, 0);
IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope();
-
+
IBinding[] bs = scope.find("par"); //$NON-NLS-1$
assertEquals(1, bs.length);
assertSame(bs[0], p);
-
+
bs = scope.find("v1"); //$NON-NLS-1$
assertEquals(bs.length, 1);
assertSame(bs[0], v1);
}
-
- // struct S {};
- // int S;
- // void f() {
- // int S;
- // {
- // S : ;
- // }
- // }
+
+ // struct S {};
+ // int S;
+ // void f() {
+ // int S;
+ // {
+ // S : ;
+ // }
+ // }
public void testFind() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
ICompositeType S1 = (ICompositeType) col.getName(0).resolveBinding();
IVariable S2 = (IVariable) col.getName(1).resolveBinding();
IFunction f = (IFunction) col.getName(2).resolveBinding();
IVariable S3 = (IVariable) col.getName(3).resolveBinding();
ILabel S4 = (ILabel) col.getName(4).resolveBinding();
-
+
IASTFunctionDefinition fdef= getDeclaration(tu, 2);
IScope scope = ((IASTCompoundStatement) fdef.getBody()).getScope();
-
+
IBinding[] bs = scope.find("S"); //$NON-NLS-1$
-
+
assertNotNull(S2);
assertEquals(bs.length, 3);
assertSame(bs[0], S3);
assertSame(bs[1], S1);
assertSame(bs[2], S4);
}
-
+
public void test92791() throws Exception {
IASTTranslationUnit tu = parse(
"void f() { int x, y; x * y; }", ParserLanguage.C); //$NON-NLS-1$
@@ -3140,7 +3129,7 @@ public class AST2Tests extends AST2BaseTest {
tu.accept(col);
for (int i = 0; i < col.size(); ++i)
assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding);
-
+
tu = parse(
"int y; void f() { typedef int x; x * y; }", ParserLanguage.C); //$NON-NLS-1$
col = new CNameCollector();
@@ -3148,7 +3137,7 @@ public class AST2Tests extends AST2BaseTest {
for (int i = 0; i < col.size(); ++i)
assertFalse(col.getName(i).resolveBinding() instanceof IProblemBinding);
}
-
+
public void testBug85786() throws Exception {
IASTTranslationUnit tu = parse(
"void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", ParserLanguage.C); //$NON-NLS-1$
@@ -3156,7 +3145,7 @@ public class AST2Tests extends AST2BaseTest {
tu.accept(nameResolver);
assertNoProblemBindings(nameResolver);
}
-
+
// void func() {
// int i=0;
// i= i&0x00ff;
@@ -3166,21 +3155,21 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C);
CNameCollector nameResolver = new CNameCollector();
tu.accept(nameResolver);
- assertNoProblemBindings(nameResolver);
+ assertNoProblemBindings(nameResolver);
}
-
+
// #define ONE(a, ...) int x
// #define TWO(b, args...) int y
// int main()
// {
// ONE("string"); /* err */
// TWO("string"); /* err */
- // return 0;
+ // return 0;
// }
public void testBug94365() throws Exception {
parse(getAboveComment(), ParserLanguage.C);
}
-
+
// #define MACRO(a)
// void main() {
// MACRO('"');
@@ -3196,7 +3185,7 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0])
.getBody()).getStatements()[0] instanceof IASTNullStatement);
}
-
+
// #define MACRO(a)
// void main() {
// MACRO('X');
@@ -3212,150 +3201,150 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(((IASTCompoundStatement) ((IASTFunctionDefinition) declarations[0])
.getBody()).getStatements()[0] instanceof IASTNullStatement);
}
-
+
// typedef long _TYPE;
// typedef _TYPE TYPE;
// int function(TYPE (* pfv)(int parm));
public void testBug81739() throws Exception {
parse(getAboveComment(), ParserLanguage.C);
}
-
+
// float _Complex x;
// double _Complex y;
public void testBug95757() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true, true);
IASTDeclaration[] decls = tu.getDeclarations();
-
- assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).isComplex());
- assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
- assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).isComplex());
- assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration)decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
+
+ assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).isComplex());
+ assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[0]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_float);
+ assertTrue(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).isComplex());
+ assertEquals(((ICASTSimpleDeclSpecifier)((IASTSimpleDeclaration) decls[1]).getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_double);
}
-
- // int foo();
- // typeof({ int x = foo();
- // x; }) zoot;
+
+ // int foo();
+ // typeof({ int x = foo();
+ // x; }) zoot;
public void testBug93980() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IFunction foo = (IFunction) col.getName(0).resolveBinding();
assertSame(foo, col.getName(2).resolveBinding());
-
+
IVariable zoot = (IVariable) col.getName(4).resolveBinding();
IType t = zoot.getType();
assertTrue(t instanceof IBasicType);
- assertEquals(((IBasicType)t).getType(), IBasicType.t_int);
+ assertEquals(((IBasicType) t).getType(), IBasicType.t_int);
}
-
+
public void testBug95866() throws Exception {
IASTTranslationUnit tu = parse("int test[10] = { [0 ... 9] = 2 };", ParserLanguage.C, true, true); //$NON-NLS-1$
CNameCollector col = new CNameCollector();
tu.accept(col);
assertNoProblemBindings(col);
}
-
+
public void testBug98502() throws Exception {
IASTTranslationUnit tu = parse("typedef enum { ONE } e;", ParserLanguage.C, true, true); //$NON-NLS-1$
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IEnumeration etion = (IEnumeration) col.getName(0).resolveBinding();
ITypedef e = (ITypedef) col.getName(2).resolveBinding();
assertSame(e.getType(), etion);
}
-
- // typedef struct _loop_data {
- // enum { PIPERR } pipe_err;
- // } loop_data;
- // void f() {
- // PIPERR;
- // }
+
+ // typedef struct _loop_data {
+ // enum { PIPERR } pipe_err;
+ // } loop_data;
+ // void f() {
+ // PIPERR;
+ // }
public void testBug98365() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IEnumerator etor = (IEnumerator) col.getName(2).resolveBinding();
assertSame(etor, col.getName(6).resolveBinding());
}
-
+
public void testBug99262() throws Exception {
parse("void foo() {void *f; f=__null;}", ParserLanguage.C, true, true); //$NON-NLS-1$
}
-
+
// void f1(int*) {
// }
// void f2() {
// f1(__null);
// }
- public void testBug240567() throws Exception {
+ public void testBug240567() throws Exception {
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), false);
bh.assertNonProblem("f1(__null", 2, IFunction.class);
}
-
- // void f() {
- // int a;
- // { a; int a; }
- // }
+
+ // void f() {
+ // int a;
+ // { a; int a; }
+ // }
public void testBug98960() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IVariable a1 = (IVariable) col.getName(1).resolveBinding();
IVariable a2 = (IVariable) col.getName(2).resolveBinding();
IVariable a3 = (IVariable) col.getName(3).resolveBinding();
-
+
assertSame(a1, a2);
assertNotSame(a2, a3);
}
-
+
public void testBug100408() throws Exception {
IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", ParserLanguage.C); //$NON-NLS-1$
CNameCollector col = new CNameCollector();
tu.accept(col);
assertNoProblemBindings(col);
}
-
- // struct nfa;
- // void f() {
- // struct nfa * n;
- // freenfa(n);
- // }
- // static void freenfa(nfa)
- // struct nfa * nfa;
- // {
- // }
+
+ // struct nfa;
+ // void f() {
+ // struct nfa * n;
+ // freenfa(n);
+ // }
+ // static void freenfa(nfa)
+ // struct nfa * nfa;
+ // {
+ // }
public void testBug98760() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IFunction free = (IFunction) col.getName(4).resolveBinding();
IParameter [] ps = free.getParameters();
assertEquals(ps.length, 1);
-
+
assertSame(free, col.getName(6).resolveBinding());
}
-
+
// void testCasting() {
// typedef struct {
// int employee_id;
// int dept_id;
// } Employee;
// #define MY_DETAILS { 20, 30 }
- // Employee e = (Employee)MY_DETAILS;
+ // Employee e = (Employee)MY_DETAILS;
// }
public void testBug79650() throws Exception {
parseAndCheckBindings(getAboveComment());
}
-
+
public void testBug80171() throws Exception {
parseAndCheckBindings("static var;"); //$NON-NLS-1$
}
-
+
// enum E_OPTIONCODE {
// red = 1,
// black = 2,
@@ -3371,7 +3360,7 @@ public class AST2Tests extends AST2BaseTest {
public void testBug79067() throws Exception {
parseAndCheckBindings(getAboveComment());
}
-
+
// enum COLOR {
// RED=1
// };
@@ -3383,41 +3372,41 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1];
assertEquals(fd.getDeclSpecifier().getRawSignature(), "enum COLOR"); //$NON-NLS-1$
-
+
}
-
+
// int f() {
// int x = 4; while (x < 10) blah: ++x;
// }
public void test1043290() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment());
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0];
- IASTStatement [] statements = ((IASTCompoundStatement)fd.getBody()).getStatements();
+ IASTStatement [] statements = ((IASTCompoundStatement) fd.getBody()).getStatements();
IASTWhileStatement whileStmt = (IASTWhileStatement) statements[1];
IASTLabelStatement labelStmt = (IASTLabelStatement) whileStmt.getBody();
assertTrue(labelStmt.getNestedStatement() instanceof IASTExpressionStatement);
IASTExpressionStatement es = (IASTExpressionStatement) labelStmt.getNestedStatement();
assertTrue(es.getExpression() instanceof IASTUnaryExpression);
}
-
- // void f() {
- // int x;
- // for (int x; ;)
- // blah: x;
- // }
+
+ // void f() {
+ // int x;
+ // for (int x; ;)
+ // blah: x;
+ // }
public void testBug104390_2() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, true);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
IVariable x = (IVariable) col.getName(1).resolveBinding();
IVariable x2 = (IVariable) col.getName(2).resolveBinding();
assertNotSame(x, x2);
assertSame(x2, col.getName(4).resolveBinding());
assertTrue(col.getName(3).resolveBinding() instanceof ILabel);
}
-
- // int f() {
+
+ // int f() {
// int i;
// do { ++i; } while (i < 10);
// return 0;
@@ -3428,7 +3417,7 @@ public class AST2Tests extends AST2BaseTest {
IASTCompoundStatement body = (IASTCompoundStatement) f.getBody();
assertEquals(body.getStatements().length, 3);
}
-
+
public void testBug107150() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n"); //$NON-NLS-1$
@@ -3443,7 +3432,7 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
tu = parse(buffer.toString(), ParserLanguage.CPP);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
-
+
buffer = new StringBuffer();
buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\n"); //$NON-NLS-1$
buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)) {\n"); //$NON-NLS-1$
@@ -3458,7 +3447,7 @@ public class AST2Tests extends AST2BaseTest {
tu= parse(buffer.toString(), ParserLanguage.CPP);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
}
-
+
public void testBug107150b() throws Exception {
StringBuffer buffer = new StringBuffer();
buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n"); //$NON-NLS-1$
@@ -3471,10 +3460,10 @@ public class AST2Tests extends AST2BaseTest {
buffer.append("}\r\n"); //$NON-NLS-1$
IASTTranslationUnit tu= parse(buffer.toString(), ParserLanguage.C);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
-
+
tu = parse(buffer.toString(), ParserLanguage.CPP);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
-
+
buffer = new StringBuffer();
buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\n"); //$NON-NLS-1$
buffer.append("int func1 FUNC_PROTOTYPE_PARAMS((int arg1)) {\n"); //$NON-NLS-1$
@@ -3489,7 +3478,7 @@ public class AST2Tests extends AST2BaseTest {
tu = parse(buffer.toString(), ParserLanguage.CPP);
assertFalse(tu.getDeclarations()[1] instanceof IASTProblemDeclaration);
}
-
+
// NWindow NewWindowDuplicate(NWindow theWindow, bool insert)\n");
// {
// NWindow newWindow;
@@ -3534,7 +3523,7 @@ public class AST2Tests extends AST2BaseTest {
public void testBug143502() throws Exception {
parse(getAboveComment(), ParserLanguage.C, true, false);
}
-
+
// void func(int a) {
// int z=0;
// z= (a)+z;
@@ -3552,14 +3541,14 @@ public class AST2Tests extends AST2BaseTest {
IASTParameterDeclaration[] params= ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters();
IBinding binding= params[0].getDeclarator().getName().resolveBinding();
assertEquals(7, tu.getReferences(binding).length);
-
+
tu= parse(content, ParserLanguage.CPP, true, true);
func= (IASTFunctionDefinition) tu.getDeclarations()[0];
params= ((IASTStandardFunctionDeclarator) func.getDeclarator()).getParameters();
binding= params[0].getDeclarator().getName().resolveBinding();
assertEquals(7, tu.getReferences(binding).length);
}
-
+
// #define MAC(x) x
// void func() {
// MAC(");
@@ -3567,45 +3556,45 @@ public class AST2Tests extends AST2BaseTest {
public void testBug179383() throws ParserException, IOException {
parse(getAboveComment(), ParserLanguage.C, false, false);
}
-
+
/**
* Bug in not removing single-line comments from macros.
* @throws Exception
*/
public void testMacroCommentsBug_177154() throws Exception {
// simple case
- String simple =
- "#define LIT 1 // my value\r\n" +
- "int func(int x) {\r\n" +
- "}\r\n" +
- "int main() {\r\n" +
- " return func(LIT); // fails to parse\r\n" +
- "}\r\n";
-
+ String simple =
+ "#define LIT 1 // my value\r\n" +
+ "int func(int x) {\r\n" +
+ "}\r\n" +
+ "int main() {\r\n" +
+ " return func(LIT); // fails to parse\r\n" +
+ "}\r\n";
+
IASTTranslationUnit tu = parse(simple, ParserLanguage.CPP, true, true);
-
+
// actual reduced test case, plus extra cases
String text =
- "#define KBOOT 1 //0x00000002\r\n" +
- "#define KBOOT2 /* value */ 1 /* another */ //0x00000002\r\n" +
+ "#define KBOOT 1 //0x00000002\r\n" +
+ "#define KBOOT2 /* value */ 1 /* another */ //0x00000002\r\n" +
"#define KBOOT3 /* value \r\n" +
" multi line\r\n"+
" comment */ 1 \\\r\n"+
"/* another */ + \\\r\n"+
- "2 //0x00000002\r\n" +
- "#define DEBUGNUM(x) (KDebugNum(x))\r\n" +
- "bool KDebugNum(int aBitNum);\r\n" +
+ "2 //0x00000002\r\n" +
+ "#define DEBUGNUM(x) (KDebugNum(x))\r\n" +
+ "bool KDebugNum(int aBitNum);\r\n" +
"#define __KTRACE_OPT(a,p) {if ((DEBUGNUM(a)))p;}\r\n" +
"void fail();\r\n"+
"void test() {\r\n"+
- "__KTRACE_OPT(KBOOT,fail());\r\n" +
- "__KTRACE_OPT(KBOOT2,fail());\r\n" +
+ "__KTRACE_OPT(KBOOT,fail());\r\n" +
+ "__KTRACE_OPT(KBOOT2,fail());\r\n" +
"}\r\n"
;
-
+
// essential test: this code should be parseable
tu = parse(text, ParserLanguage.CPP, true, true);
-
+
// verify macros
IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
assertEquals(5, macroDefinitions.length);
@@ -3616,10 +3605,10 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(expectExpansion, macroDefinitions[2].getExpansion());
assertEquals("(KDebugNum(x))", macroDefinitions[3].getExpansion());
assertEquals("{if ((DEBUGNUM(a)))p;}", macroDefinitions[4].getExpansion());
-
+
// TODO: exhaustive macro testing
}
-
+
// void (decl)(char);
// void foo() {
// decl('a');
@@ -3627,7 +3616,7 @@ public class AST2Tests extends AST2BaseTest {
public void testBug181305_1() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parse(getAboveComment(), lang, true, true);
-
+
// check class
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1];
IASTCompoundStatement comp_stmt= (IASTCompoundStatement) fd.getBody();
@@ -3640,7 +3629,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(binding.getName(), "decl");
}
}
-
+
// void (*decl)(char);
// void foo() {
// decl('a');
@@ -3648,7 +3637,7 @@ public class AST2Tests extends AST2BaseTest {
public void testBug181305_2() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parse(getAboveComment(), lang, true, true);
-
+
// check class
IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[1];
IASTCompoundStatement comp_stmt= (IASTCompoundStatement) fd.getBody();
@@ -3660,64 +3649,64 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(lang.toString(), binding instanceof IProblemBinding);
}
}
-
+
public void testBug181735() throws Exception {
String code=
"int (*f)(int);\n"
+ "int g(int n) {return n;}\n"
+ "int g(int n, int m) {return n;}\n"
+ "void foo() { f=g; }";
-
+
for (ParserLanguage lang : ParserLanguage.values())
parseAndCheckBindings(code, lang);
}
-
+
// void test() {
// char d= *"b";
// }
public void testBug181942() throws Exception {
- for (ParserLanguage lang : ParserLanguage.values())
+ for (ParserLanguage lang : ParserLanguage.values())
parse(getAboveComment(), lang, true, true);
}
-
+
public void testMacroCommentsBug_177154_2() throws Exception {
String noCommentMacro =
- "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L)\r\n";
- String commentMacro =
- "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L) // add the varf value\r\n";
-
- String textTail = "\r\n" +
- "const int snd16SonarR[32] = {\r\n" +
- " 0xFF000000L, Sonar16G(0x01), Sonar16G(0x02), Sonar16G(0x03),\r\n" +
- " Sonar16G(0x04), Sonar16G(0x05), Sonar16G(0x06), Sonar16G(0x07),\r\n" +
- " Sonar16G(0x08), Sonar16G(0x09), Sonar16G(0x0A), Sonar16G(0x0B),\r\n" +
- " Sonar16G(0x0C), Sonar16G(0x0D), Sonar16G(0x0E), Sonar16G(0x0F),\r\n" +
- " Sonar16G(0x10), Sonar16G(0x11), Sonar16G(0x12), Sonar16G(0x13),\r\n" +
- " Sonar16G(0x14), Sonar16G(0x15), Sonar16G(0x16), Sonar16G(0x17),\r\n" +
- " Sonar16G(0x18), Sonar16G(0x19), Sonar16G(0x1A), Sonar16G(0x1B),\r\n" +
- " Sonar16G(0x1C), Sonar16G(0x1D), Sonar16G(0x1E), Sonar16G(0x1F),\r\n" +
- " };\r\n" +
- "\r\n" +
+ "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L)\r\n";
+ String commentMacro =
+ "#define Sonar16G(x) ((Sonr16G(x)<<16)|0xff000000L) // add the varf value\r\n";
+
+ String textTail = "\r\n" +
+ "const int snd16SonarR[32] = {\r\n" +
+ " 0xFF000000L, Sonar16G(0x01), Sonar16G(0x02), Sonar16G(0x03),\r\n" +
+ " Sonar16G(0x04), Sonar16G(0x05), Sonar16G(0x06), Sonar16G(0x07),\r\n" +
+ " Sonar16G(0x08), Sonar16G(0x09), Sonar16G(0x0A), Sonar16G(0x0B),\r\n" +
+ " Sonar16G(0x0C), Sonar16G(0x0D), Sonar16G(0x0E), Sonar16G(0x0F),\r\n" +
+ " Sonar16G(0x10), Sonar16G(0x11), Sonar16G(0x12), Sonar16G(0x13),\r\n" +
+ " Sonar16G(0x14), Sonar16G(0x15), Sonar16G(0x16), Sonar16G(0x17),\r\n" +
+ " Sonar16G(0x18), Sonar16G(0x19), Sonar16G(0x1A), Sonar16G(0x1B),\r\n" +
+ " Sonar16G(0x1C), Sonar16G(0x1D), Sonar16G(0x1E), Sonar16G(0x1F),\r\n" +
+ " };\r\n" +
+ "\r\n" +
"";
-
+
// this should work
String textNoComment = noCommentMacro + textTail;
IASTTranslationUnit tu = parse(textNoComment, ParserLanguage.CPP, true, true);
-
+
// this fails
String textComment = commentMacro + textTail;
tu = parse(textComment, ParserLanguage.CPP, true, true);
-
+
}
-
+
// int __builtin_sin;
public void testBug182464() throws Exception {
for (ParserLanguage lang : ParserLanguage.values())
parseAndCheckBindings(getAboveComment(), lang, true);
}
-
+
public void testBug186018() throws Exception {
- String code =
+ String code =
"int main() { \n" +
" switch(1) { \n" +
" case 1 : \n" +
@@ -3725,10 +3714,10 @@ public class AST2Tests extends AST2BaseTest {
" printf(\"pantera rules\"); \n" +
" } \n" +
"}\n";
-
+
parseAndCheckBindings(code, ParserLanguage.C);
}
-
+
// template <typename T>
// class auto_ptr {
// private:
@@ -3765,13 +3754,13 @@ public class AST2Tests extends AST2BaseTest {
assertEquals("method", methodc.getName());
assertInstance(methodb, ICPPMethod.class);
assertInstance(methodc, ICPPMethod.class);
- assertEquals("A", ((ICPPMethod)methodb).getClassOwner().getName());
- assertEquals("A", ((ICPPMethod)methodc).getClassOwner().getName());
-
+ assertEquals("A", ((ICPPMethod) methodb).getClassOwner().getName());
+ assertEquals("A", ((ICPPMethod) methodc).getClassOwner().getName());
+
tu = validateCopy(tu);
}
}
-
+
// template <typename T, typename U>
// class odd_pair {
// private:
@@ -3817,13 +3806,13 @@ public class AST2Tests extends AST2BaseTest {
assertEquals("method", methodAA.getName());
assertInstance(methodA, ICPPMethod.class);
assertInstance(methodAA, ICPPMethod.class);
- assertEquals("A", ((ICPPMethod)methodA).getClassOwner().getName());
- assertEquals("AA", ((ICPPMethod)methodAA).getClassOwner().getName());
+ assertEquals("A", ((ICPPMethod) methodA).getClassOwner().getName());
+ assertEquals("AA", ((ICPPMethod) methodAA).getClassOwner().getName());
tu = validateCopy(tu);
}
}
-
+
// class B {
// public:
// void bar() {}
@@ -3847,7 +3836,7 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
validateCopy(tu);
}
-
+
// typedef int int32;
// int32 f(int32 (*p)) {
// return *p;
@@ -3855,17 +3844,17 @@ public class AST2Tests extends AST2BaseTest {
public void test167833() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
- }
-
+ }
+
// // this is a \
- // single line comment
+ // single line comment
// char str[] = " multi \
// line \
// string";
public void testBug188707_backslashNewline() throws Exception {
parseAndCheckBindings(getAboveComment());
}
-
+
// typedef A B;
// typedef C D;
// typedef E E;
@@ -3890,7 +3879,7 @@ public class AST2Tests extends AST2BaseTest {
assertInstance(col.getName(9).resolveBinding(), ITypedef.class);
assertInstance(col.getName(10).resolveBinding(), IProblemBinding.class);
assertInstance(col.getName(11).resolveBinding(), ITypedef.class);
-
+
// function ptr
final IBinding typedef = col.getName(12).resolveBinding();
final IBinding secondJ = col.getName(13).resolveBinding();
@@ -3898,23 +3887,23 @@ public class AST2Tests extends AST2BaseTest {
if (lang == ParserLanguage.CPP) {
assertInstance(secondJ, IProblemBinding.class);
} else {
- // for plain C this is actually not a problem, the second J has to be interpreted as a (useless)
+ // for plain C this is actually not a problem, the second J has to be interpreted as a (useless)
// parameter name.
assertInstance(typedef, ITypedef.class);
isTypeEqual(((ITypedef) typedef).getType(), "int (*)(int)");
}
}
}
-
+
// /* a comment */
// #define INVALID(a, b) ## a ## b
// INVALID(1, 2)
//
public void test192639() throws Exception {
- parse(getAboveComment(), ParserLanguage.CPP, false, false);
- parse(getAboveComment(), ParserLanguage.C, false, false);
+ parse(getAboveComment(), ParserLanguage.CPP, false, false);
+ parse(getAboveComment(), ParserLanguage.C, false, false);
}
-
+
public void test195943() throws Exception {
final int depth= 100;
StringBuffer buffer = new StringBuffer();
@@ -3924,16 +3913,16 @@ public class AST2Tests extends AST2BaseTest {
}
buffer.append("int a= M" + (depth-1) + ";\n");
long time= System.currentTimeMillis();
- parse(buffer.toString(), ParserLanguage.CPP);
+ parse(buffer.toString(), ParserLanguage.CPP);
parse(buffer.toString(), ParserLanguage.C);
assertTrue(System.currentTimeMillis()-time < 2000);
}
-
+
// int array[12]= {};
public void testBug196468_emptyArrayInitializer() throws Exception {
final String content = getAboveComment();
- parse(content, ParserLanguage.CPP, false);
- parse(content, ParserLanguage.CPP, true);
+ parse(content, ParserLanguage.CPP, false);
+ parse(content, ParserLanguage.CPP, true);
parse(content, ParserLanguage.C, true);
try {
parse(content, ParserLanguage.C, false);
@@ -3942,7 +3931,7 @@ public class AST2Tests extends AST2BaseTest {
catch (ParserException e) {
}
}
-
+
// #define foo(f,...)
// void bar(void) {}
// int main(int argc, char **argv) {
@@ -3955,10 +3944,10 @@ public class AST2Tests extends AST2BaseTest {
// }
public void testBug197633_parenthesisInVarargMacros() throws Exception {
final String content = getAboveComment();
- parse(content, ParserLanguage.CPP);
- parse(content, ParserLanguage.C);
+ parse(content, ParserLanguage.CPP);
+ parse(content, ParserLanguage.C);
}
-
+
// void (__attribute__((__stdcall__))* foo1) (int);
// void (* __attribute__((__stdcall__)) foo2) (int);
// void (* __attribute__((__stdcall__))* foo3) (int);
@@ -3966,11 +3955,11 @@ public class AST2Tests extends AST2BaseTest {
parse(getAboveComment(), ParserLanguage.CPP, true, true);
parse(getAboveComment(), ParserLanguage.C, true, true);
}
-
- // class NameClash {};
+
+ // class NameClash {};
// namespace NameClash {};
// namespace NameClash2 {};
- // class NameClash2 {};
+ // class NameClash2 {};
public void testBug202271_nameClash() throws Exception {
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true);
assertTrue(tu.isFrozen());
@@ -3985,7 +3974,7 @@ public class AST2Tests extends AST2BaseTest {
tu = validateCopy(tu);
}
}
-
+
// #define WRAP(var) var
// #define MACRO 1
// int a= MACRO;
@@ -4007,7 +3996,7 @@ public class AST2Tests extends AST2BaseTest {
IASTImageLocation iloc= refs[1].getImageLocation();
assertEquals(idx+5, iloc.getNodeOffset());
}
-
+
// void OSi_Panic(const char *file, int line) {};
// void OSi_Panic(const char *file, int line, const char *fmt, ...) {};
//
@@ -4027,7 +4016,7 @@ public class AST2Tests extends AST2BaseTest {
// ASSERT(a > b, "Error!");// marked with error also
// ASSERT(false);// fine
// }
-
+
// void OSi_Panic(const char *file, int line) {};
// void OSi_Panic(const char *file, int line, const char *fmt, ...) {};
//
@@ -4051,45 +4040,45 @@ public class AST2Tests extends AST2BaseTest {
CharSequence[] buffer = getContents(2);
final String content1 = buffer[0].toString();
final String content2 = buffer[1].toString();
- parse(content1, ParserLanguage.CPP);
- parse(content1, ParserLanguage.C);
- parse(content2, ParserLanguage.CPP);
- parse(content2, ParserLanguage.C);
+ parse(content1, ParserLanguage.CPP);
+ parse(content1, ParserLanguage.C);
+ parse(content2, ParserLanguage.CPP);
+ parse(content2, ParserLanguage.C);
}
-
-
+
+
// typedef struct Point {
// int x;
// int y;
// } Point ;
- //
+ //
// typedef struct Tag {
// int tag;
// } Tag ;
- //
+ //
// typedef struct Line {
// Point p1;
// Point p2;
// Tag t;
// } Line ;
- //
+ //
// int foo() {
- // Point p1 = {.x = 1, .y = 2};
- //
- // Line l1 = {.p1 = {.x = 1, .y = 2}, {.x = 1, .y = 2}, {.tag = 5}};
- // Line l2 = {.t.tag = 9, .p1.x = 1, .p2.x = 3, .p1.y = 4, .p2.y = 9};
+ // Point p1 = {.x = 1, .y = 2};
//
+ // Line l1 = {.p1 = {.x = 1, .y = 2}, {.x = 1, .y = 2}, {.tag = 5}};
+ // Line l2 = {.t.tag = 9, .p1.x = 1, .p2.x = 3, .p1.y = 4, .p2.y = 9};
+ //
// Point points[] = {{.x=1, .y=1}, {.x=2, .y=2}};
- // }
+ // }
public void _testBug210019_nestedDesignatedInitializers() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
CNameCollector col = new CNameCollector();
tu.accept(col);
-
- // Point p1
+
+ // Point p1
assertField(col.getName(18).resolveBinding(), "x", "Point");
assertField(col.getName(19).resolveBinding(), "y", "Point");
-
+
// Line l1
assertField(col.getName(22).resolveBinding(), "p1", "Line");
assertField(col.getName(23).resolveBinding(), "x", "Point");
@@ -4097,7 +4086,7 @@ public class AST2Tests extends AST2BaseTest {
assertField(col.getName(25).resolveBinding(), "x", "Point");
assertField(col.getName(26).resolveBinding(), "y", "Point");
assertField(col.getName(27).resolveBinding(), "tag", "Tag");
-
+
// Line l2
assertField(col.getName(30).resolveBinding(), "t", "Line");
assertField(col.getName(31).resolveBinding(), "tag", "Tag");
@@ -4109,50 +4098,50 @@ public class AST2Tests extends AST2BaseTest {
assertField(col.getName(37).resolveBinding(), "y", "Point");
assertField(col.getName(38).resolveBinding(), "p2", "Line");
assertField(col.getName(39).resolveBinding(), "y", "Point");
-
+
// Point points[]
assertField(col.getName(42).resolveBinding(), "x", "Point");
assertField(col.getName(43).resolveBinding(), "y", "Point");
assertField(col.getName(44).resolveBinding(), "x", "Point");
assertField(col.getName(45).resolveBinding(), "y", "Point");
}
-
-
- // struct S1 {
- // int i;
+
+
+ // struct S1 {
+ // int i;
// float f;
// int a[2];
// };
- //
+ //
// struct S1 x = {
- // .f=3.1,
+ // .f=3.1,
// .i=2,
// .a[1]=9
// };
- //
+ //
// struct S2 {
// int x, y;
// };
- //
+ //
// struct S2 a1[3] = {1, 2, 3, 4, 5, 6};
- //
+ //
// struct S2 a2[3] =
// {{1, 2},{3, 4}, 5, 6};
- //
+ //
// struct S2 a3[3] =
// {
// [2].y=6, [2].x=5,
// [1].y=4, [1].x=3,
// [0].y=2, [0].x=1
// };
- //
+ //
// struct S2 a4[3] =
// {
// [0].x=1, [0].y=2,
// {.x=3, .y=4},
// 5, [2].y=6
// };
- //
+ //
// struct S2 a5[3] =
// {
// [2].x=5, 6,
@@ -4165,31 +4154,31 @@ public class AST2Tests extends AST2BaseTest {
for (int i = 0; i < NUM_TESTS; i++) {
CNameCollector col = new CNameCollector();
tu.accept(col);
-
+
assertField(col.getName(6).resolveBinding(), "f", "S1");
assertField(col.getName(7).resolveBinding(), "i", "S1");
assertField(col.getName(8).resolveBinding(), "a", "S1");
-
+
assertField(col.getName(18).resolveBinding(), "y", "S2");
assertField(col.getName(19).resolveBinding(), "x", "S2");
assertField(col.getName(20).resolveBinding(), "y", "S2");
assertField(col.getName(21).resolveBinding(), "x", "S2");
assertField(col.getName(22).resolveBinding(), "y", "S2");
assertField(col.getName(23).resolveBinding(), "x", "S2");
-
+
assertField(col.getName(26).resolveBinding(), "x", "S2");
assertField(col.getName(27).resolveBinding(), "y", "S2");
assertField(col.getName(28).resolveBinding(), "x", "S2");
assertField(col.getName(29).resolveBinding(), "y", "S2");
assertField(col.getName(30).resolveBinding(), "y", "S2");
-
+
assertField(col.getName(33).resolveBinding(), "x", "S2");
assertField(col.getName(34).resolveBinding(), "x", "S2");
tu = validateCopy(tu);
}
}
-
+
// extern "C" {
// extern "C" {
// void externFunc();
@@ -4201,7 +4190,7 @@ public class AST2Tests extends AST2BaseTest {
public void testBug183126_nestedLinkageSpecs() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP);
}
-
+
// int* i= 0;
// void f1(const int**);
// void f2(int *const*);
@@ -4213,18 +4202,18 @@ public class AST2Tests extends AST2BaseTest {
// f3(&i); // ok
// }
public void testBug213029_cvConversion() throws Exception {
- IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, false);
+ IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, false);
CNameCollector col = new CNameCollector();
tu.accept(col);
for (Object o : col.nameList) {
- IASTName n = (IASTName)o;
+ IASTName n = (IASTName) o;
if (n.isReference() && "f1".equals(n.toString()))
assertTrue(n.resolveBinding() instanceof IProblemBinding);
else
assertFalse(n.resolveBinding() instanceof IProblemBinding);
}
}
-
+
// void isTrue(int field, int bit) {
// return ((field) & (bit));
// }
@@ -4242,7 +4231,7 @@ public class AST2Tests extends AST2BaseTest {
cpp= !cpp;
} while (cpp);
}
-
+
// void f1(int& r) {}
// void f2(const int& r) {}
// void f3(volatile int& r) {}
@@ -4253,23 +4242,23 @@ public class AST2Tests extends AST2BaseTest {
// const int ci= 1;
// volatile int vi= 2;
// const volatile int cvi = 3;
- //
+ //
// f1(i);
// f1(ci); // should be an error
// f1(vi); // should be an error
// f1(cvi); // should be an error
- //
+ //
// f2(i);
// f2(ci);
// f2(vi); // should be an error
// f2(cvi); // should be an error
- //
+ //
// f3(i);
// f3(ci); // should be an error
// f3(vi);
// f3(cvi); // should be an error
- //
- // f4(i);
+ //
+ // f4(i);
// f4(ci);
// f4(vi);
// f4(cvi);
@@ -4280,25 +4269,25 @@ public class AST2Tests extends AST2BaseTest {
ba.assertProblem("f1(ci)", 2);
ba.assertProblem("f1(vi)", 2);
ba.assertProblem("f1(cvi)", 2);
-
+
ba.assertNonProblem("f2(i)", 2);
ba.assertNonProblem("f2(ci)",2);
ba.assertProblem("f2(vi)", 2);
ba.assertProblem("f2(cvi)", 2);
-
+
ba.assertNonProblem("f3(i)", 2);
ba.assertProblem("f3(ci)", 2);
ba.assertNonProblem("f3(vi)",2);
ba.assertProblem("f3(cvi)", 2);
-
+
ba.assertNonProblem("f4(i)", 2);
ba.assertNonProblem("f4(ci)", 2);
ba.assertNonProblem("f4(vi)", 2);
ba.assertNonProblem("f4(cvi)",2);
}
-
+
// void f1(int& r) {} // 1
- // void f1(const int& r) {} // 2
+ // void f1(const int& r) {} // 2
// void f1(volatile int& r) {} // 3
// void f1(const volatile int& r) {} // 4
//
@@ -4307,38 +4296,38 @@ public class AST2Tests extends AST2BaseTest {
// const int ci= 1;
// volatile int vi= 2;
// const volatile int cvi = 3;
- //
+ //
// f1(i); // (1)
- // f1(ci); // (2)
+ // f1(ci); // (2)
// f1(vi); // (3)
// f1(cvi); // (4)
// }
public void testBug222418_b() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
-
+
ICPPFunction f1_1= ba.assertNonProblem("f1(i)", 2, ICPPFunction.class);
ICPPFunction f1_2= ba.assertNonProblem("f1(ci)", 2, ICPPFunction.class);
ICPPFunction f1_3= ba.assertNonProblem("f1(vi)", 2, ICPPFunction.class);
ICPPFunction f1_4= ba.assertNonProblem("f1(cvi)",2, ICPPFunction.class);
-
+
assertEquals(ASTTypeUtil.getParameterTypeString(f1_1.getType()), "(int &)");
assertEquals(ASTTypeUtil.getParameterTypeString(f1_2.getType()), "(const int &)");
assertEquals(ASTTypeUtil.getParameterTypeString(f1_3.getType()), "(volatile int &)");
assertEquals(ASTTypeUtil.getParameterTypeString(f1_4.getType()), "(const volatile int &)");
}
-
+
// void f1(int r) {} // 1
- // void f1(const int r) {} // 2
+ // void f1(const int r) {} // 2
// void f1(volatile int r) {} // 3
// void f1(const volatile int r) {} // 4
public void testBug222418_b_regression() throws Exception {
- BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f1(int", 2, ICPPFunction.class);
ba.assertProblem("f1(const i", 2);
ba.assertProblem("f1(vol", 2);
ba.assertProblem("f1(const v",2);
}
-
+
// void fa(int& r) {}
// void fb(const int& r) {}
// void fc(volatile int& r) {}
@@ -4348,35 +4337,35 @@ public class AST2Tests extends AST2BaseTest {
//
// void ref() {
// fa(5); // should be an error
- // fb(5); // ok
+ // fb(5); // ok
// fc(5); // should be an error
// fd(5); // should be an error
//
// fb(five()); // ok
- // fa(five()); // should be an error
+ // fa(five()); // should be an error
// fc(five()); // should be an error
// fd(five()); // should be an error
// }
public void testBug222418_c() throws Exception {
- BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
-
+ BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
+
ICPPFunction fn= ba.assertNonProblem("five() {", 4, ICPPFunction.class);
assertFalse(fn.getType().getReturnType() instanceof IProblemBinding);
-
+
ba.assertProblem("fa(5", 2);
ICPPFunction fb= ba.assertNonProblem("fb(5", 2, ICPPFunction.class);
ba.assertProblem("fc(5", 2);
ba.assertProblem("fd(5",2);
-
+
ICPPFunction fb2= ba.assertNonProblem("fb(f", 2, ICPPFunction.class);
ba.assertProblem("fa(f",2);
ba.assertProblem("fc(f",2);
ba.assertProblem("fd(f",2);
-
+
assertEquals(ASTTypeUtil.getParameterTypeString(fb.getType()), "(const int &)");
assertEquals(ASTTypeUtil.getParameterTypeString(fb2.getType()), "(const int &)");
}
-
+
// class X {
// public:
// X(int x) {}
@@ -4390,11 +4379,11 @@ public class AST2Tests extends AST2BaseTest {
// f_nonconst(2); // should be an error
// }
public void testBug222418_d() throws Exception {
- BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f_const(2", 7, ICPPFunction.class);
ba.assertProblem("f_nonconst(2", 10);
}
-
+
// class A {};
//
// void f1(A& r) {}
@@ -4423,7 +4412,7 @@ public class AST2Tests extends AST2BaseTest {
// f3(vi);
// f3(cvi); // should be an error
//
- // f4(i);
+ // f4(i);
// f4(ci);
// f4(vi);
// f4(cvi);
@@ -4434,23 +4423,23 @@ public class AST2Tests extends AST2BaseTest {
ba.assertProblem("f1(ci)", 2);
ba.assertProblem("f1(vi)", 2);
ba.assertProblem("f1(cvi)", 2);
-
+
ba.assertNonProblem("f2(i)", 2);
ba.assertNonProblem("f2(ci)",2);
ba.assertProblem("f2(vi)", 2);
ba.assertProblem("f2(cvi)", 2);
-
+
ba.assertNonProblem("f3(i)", 2);
ba.assertProblem("f3(ci)", 2);
ba.assertNonProblem("f3(vi)",2);
ba.assertProblem("f3(cvi)", 2);
-
+
ba.assertNonProblem("f4(i)", 2);
ba.assertNonProblem("f4(ci)", 2);
ba.assertNonProblem("f4(vi)", 2);
ba.assertNonProblem("f4(cvi)",2);
}
-
+
// class B {};
//
// class A {
@@ -4483,10 +4472,10 @@ public class AST2Tests extends AST2BaseTest {
// C c;
// D d;
//
- // foo1(a);
+ // foo1(a);
// foo2(a); // not copied
//
- // foo1(3);
+ // foo1(3);
// foo2(4); // should be an error (222418)
//
// foo1(A(5));
@@ -4498,13 +4487,13 @@ public class AST2Tests extends AST2BaseTest {
// foo1(d);
// foo2(d); // should be an error
//
- // foo1(b);
+ // foo1(b);
// foo2(b); // should be an error
//
// return 0;
// }
public void testBug222418_f() throws Exception {
- BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
+ BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("foo1(a)", 4);
ba.assertNonProblem("foo2(a)", 4);
ba.assertNonProblem("foo1(3)", 4);
@@ -4518,8 +4507,8 @@ public class AST2Tests extends AST2BaseTest {
ba.assertNonProblem("foo1(b)", 4);
ba.assertProblem("foo2(b)", 4);
}
-
-
+
+
// class A {};
// class B : public A {};
//
@@ -4533,7 +4522,7 @@ public class AST2Tests extends AST2BaseTest {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f(b2)", 1);
}
-
+
// void f(int &i) {}
// void ref() {
// int a=3;
@@ -4544,7 +4533,7 @@ public class AST2Tests extends AST2BaseTest {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f(r)", 1);
}
-
+
// class A {};
// class B : public A {};
// void f(A &a) {}
@@ -4557,11 +4546,11 @@ public class AST2Tests extends AST2BaseTest {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("f(b2)", 1);
}
-
+
// // test adapted from IndexNamesTests.testReadWriteFlagsCpp()
- //
+ //
// int ri, wi, rwi, ridebug;
- // int* rp; int* wp; int* rwp;
+ // int* rp; int* wp; int* rwp;
// int* const rpc= 0;
// const int * const rcpc= 0;
// void fi(int);
@@ -4579,49 +4568,49 @@ public class AST2Tests extends AST2BaseTest {
// void fcpcr(int const *const&);
//
// int test() {
- // fi(ri); fp(&rwi); fcp(&ri);
- // fi(*rp); fp(rp); fcp(rp); fpp(&rwp); fpcp(&rpc); fcpcp(&rcpc);
+ // fi(ri); fp(&rwi); fcp(&ri);
+ // fi(*rp); fp(rp); fcp(rp); fpp(&rwp); fpcp(&rpc); fcpcp(&rcpc);
// fr(rwi); fcr(ri);
// fpcr(&rwi); fcpcr(&ri);
// fpr(rwp); fpcr(rp); fcpcr(rp);
- //
- // fcpp(&rwp); // should be error
+ //
+ // fcpp(&rwp); // should be error
// fpr(&rwi); // should be error
// fcpr(&ridebug); // should be error
// fcpr(rwp); // should be error
- //
+ //
// return ri;
// }
public void testBug222418_j() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
-
+
ba.assertNonProblem("fi(ri)", 2);
ba.assertNonProblem("fp(&rwi)", 2);
ba.assertNonProblem("fcp(&ri)", 3);
-
+
ba.assertNonProblem("fi(*rp)", 2);
ba.assertNonProblem("fp(rp)", 2);
ba.assertNonProblem("fcp(rp)", 3);
ba.assertNonProblem("fpp(&rwp)", 3);
ba.assertNonProblem("fpcp(&rpc)", 4);
ba.assertNonProblem("fcpcp(&rcpc)", 5);
-
+
ba.assertNonProblem("fr(rwi)", 2);
ba.assertNonProblem("fcr(ri)", 3);
-
+
ba.assertNonProblem("fpcr(&rwi)", 4);
ba.assertNonProblem("fcpcr(&ri)", 5);
-
+
ba.assertNonProblem("fpr(rwp)", 3);
ba.assertNonProblem("fpcr(rp)", 4);
ba.assertNonProblem("fcpcr(rp)", 5);
-
+
ba.assertProblem("fcpp(&rwp)", 4);
ba.assertProblem("fpr(&rwi)", 3);
ba.assertProblem("fcpr(&ridebug)", 4);
ba.assertProblem("fcpr(rwp)", 4);
}
-
+
// class A {
// public:
// void foo() {}
@@ -4635,13 +4624,13 @@ public class AST2Tests extends AST2BaseTest {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ba.assertNonProblem("foo();", 3);
}
-
+
// class B {};
//
- // class C {
- // public:
+ // class C {
+ // public:
// operator const B() const { return *new B();}
- // };
+ // };
//
// void foo(B b) {}
//
@@ -4649,28 +4638,28 @@ public class AST2Tests extends AST2BaseTest {
// const C c= *new C();
// const B b= *new B();
//
- // foo(b);
- // foo(c);
+ // foo(b);
+ // foo(c);
// }
public void testBug222444_a() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ICPPFunction foo1= ba.assertNonProblem("foo(b", 3, ICPPFunction.class);
ICPPFunction foo2= ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
}
-
+
// class A {};
// class B : public A {};
- //
- // class C {
- // public:
+ //
+ // class C {
+ // public:
// operator const B() { return *new B();}
- // };
+ // };
//
// void foo(A a) {}
//
// void refs() {
// C c= *new C();
- //
+ //
// foo(c);
// }
public void testBug222444_b() throws Exception {
@@ -4680,24 +4669,24 @@ public class AST2Tests extends AST2BaseTest {
// class A {};
// class B : public A {};
- //
- // class C {
- // public:
+ //
+ // class C {
+ // public:
// operator const B&() { return *new B();}
- // };
+ // };
//
// void foo(A a) {}
//
// void refs() {
// C c= *new C();
- //
+ //
// foo(c);
// }
public void testBug222444_c() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
ICPPFunction foo2= ba.assertNonProblem("foo(c", 3, ICPPFunction.class);
}
-
+
// int a, b, c;
// void test() {
// a= b ? : c;
@@ -4707,7 +4696,7 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C);
parseAndCheckBindings(code, ParserLanguage.CPP);
}
-
+
// #define __inline__ __inline__ __attribute__((always_inline))
// typedef int __u32;
// static __inline__ __u32 f(int x) {
@@ -4718,15 +4707,15 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// int foo asm ("myfoo") __attribute__((__used__)), ff asm("ss") = 2;
- // extern void func () asm ("FUNC") __attribute__((__used__));
+ // extern void func () asm ("FUNC") __attribute__((__used__));
public void testASMLabels_Bug226121() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// void test() {
// ({1;}) != 0;
// }
@@ -4734,8 +4723,8 @@ public class AST2Tests extends AST2BaseTest {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
- }
-
+ }
+
// void test(int count) {
// __typeof__(count) a= 1;
// int ret0 = ((__typeof__(count)) 1);
@@ -4745,7 +4734,7 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// void test(int count) {
// typeof(count==1) a= 1;
// }
@@ -4754,16 +4743,16 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// void func() {
// typeof(__attribute__((regparm(3)))void (*)(int *)) a;
- // }
+ // }
public void testTypeofExpressionWithAttribute_Bug226492() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// void test(int count) {
// switch(count) {
// case 1 ... 3: break;
@@ -4773,26 +4762,26 @@ public class AST2Tests extends AST2BaseTest {
final String code = getAboveComment();
{
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.C, true);
- IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody();
- IASTSwitchStatement switchStmt = (IASTSwitchStatement)body.getStatements()[0];
- IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement)switchStmt.getBody()).getStatements()[0];
- IASTBinaryExpression binExpr = (IASTBinaryExpression)caseStmt.getExpression();
+ IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
+ IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
+ IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
+ IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
}
{
IASTTranslationUnit tu = parseAndCheckBindings(code, ParserLanguage.CPP, true);
- IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[0]).getBody();
- IASTSwitchStatement switchStmt = (IASTSwitchStatement)body.getStatements()[0];
- IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement)switchStmt.getBody()).getStatements()[0];
- IASTBinaryExpression binExpr = (IASTBinaryExpression)caseStmt.getExpression();
+ IASTCompoundStatement body = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[0]).getBody();
+ IASTSwitchStatement switchStmt = (IASTSwitchStatement) body.getStatements()[0];
+ IASTCaseStatement caseStmt = (IASTCaseStatement)((IASTCompoundStatement) switchStmt.getBody()).getStatements()[0];
+ IASTBinaryExpression binExpr = (IASTBinaryExpression) caseStmt.getExpression();
assertTrue(binExpr.getOperator() == IASTBinaryExpression.op_ellipses);
assertTrue(binExpr.getOperand1() instanceof IASTLiteralExpression);
assertTrue(binExpr.getOperand2() instanceof IASTLiteralExpression);
}
}
-
+
// typedef int* TIntPtr;
// int x(int (int * a));
// int x(int(TIntPtr));
@@ -4801,7 +4790,7 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// template<typename T> class X {
// typename T::t func() {
// return typename T::t();
@@ -4811,29 +4800,29 @@ public class AST2Tests extends AST2BaseTest {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP);
}
-
+
// struct __attribute__((declspec)) bla;
public void testAttributeInElaboratedTypeSpecifier_Bug227085() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// struct X;
// void test(struct X* __restrict result);
public void testRestrictReference_Bug227110() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// char buf[256];
// int x= sizeof(buf)[0];
public void testSizeofUnaryWithParenthesis_Bug227122() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.C);
parseAndCheckBindings(code, ParserLanguage.CPP);
- }
-
+ }
+
// class X {
// public:
// void* operator new(unsigned int sz, char* buf) {return buf;}
@@ -4846,8 +4835,8 @@ public class AST2Tests extends AST2BaseTest {
public void testPlacementNewInConditionalExpression_Bug227104() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.CPP);
- }
-
+ }
+
// int f(x) {
// return 0;
// }
@@ -4855,7 +4844,7 @@ public class AST2Tests extends AST2BaseTest {
CharSequence buffer = getContents(1)[0];
parse(buffer.toString(), ParserLanguage.C, false);
}
-
+
// struct {
// char foo;
// } myStruct, *myStructPointer;
@@ -4874,7 +4863,7 @@ public class AST2Tests extends AST2BaseTest {
// myStructPointer->bar=2;
// myUnion.bar=3;
// myUnionPointer->bar=4;
- // }
+ // }
public void testBug228504_nonExistingMembers() throws Exception {
boolean[] isCpps= {true, false};
for (boolean isCpp : isCpps) {
@@ -4885,13 +4874,13 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
// struct S {
- // int value;
+ // int value;
// };
- // typedef struct S *PtrS;
+ // typedef struct S *PtrS;
// struct T {
- // PtrS ptrS;
+ // PtrS ptrS;
// };
//
// void testint(int x);
@@ -4904,18 +4893,18 @@ public class AST2Tests extends AST2BaseTest {
// testptr(t-0);
// testint(t-t);
// testint(0-t);
- // }
+ // }
public void testTypeOfPointerOperations() throws Exception {
String code= getAboveComment();
parseAndCheckBindings(code, ParserLanguage.C);
parseAndCheckBindings(code, ParserLanguage.CPP);
}
-
+
// int globalArray[4] = {1,2,3,4};
// void function1(); // decl
//
// void function1() {
- // getArray()[0] = 1;
+ // getArray()[0] = 1;
// }
//
// void function2() {
@@ -4933,7 +4922,7 @@ public class AST2Tests extends AST2BaseTest {
assertSame(b2, b3);
}
}
-
+
// #define foo __typeof__((int*)0 - (int*)0)
// typedef foo ptrdiff_t;
public void testRedefinePtrdiff_Bug230895() throws Exception {
@@ -4946,9 +4935,9 @@ public class AST2Tests extends AST2BaseTest {
ITypedef td= (ITypedef) b1;
IType t= td.getType();
assertFalse(t instanceof ITypedef);
- }
+ }
}
-
+
// int a;
// int b= a; // ref
// struct S;
@@ -4965,9 +4954,9 @@ public class AST2Tests extends AST2BaseTest {
IType t= td.getType();
assertFalse(t instanceof IProblemBinding);
assertSame(t, ct);
- }
+ }
}
-
+
// void checkLong(long);
// void test() {
// checkLong(__builtin_expect(1, 1));
@@ -4977,19 +4966,19 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// typedef void VOID;
// VOID func(VOID) {
// }
public void testTypedefVoid_Bug221567() throws Exception {
- final boolean[] isCpps= {false, true};
+ final boolean[] isCpps= { false, true };
String code= getAboveComment();
for (boolean isCpp : isCpps) {
BindingAssertionHelper ba= new BindingAssertionHelper(code, isCpp);
ITypedef td= ba.assertNonProblem("VOID;", 4, ITypedef.class);
IBinding ref= ba.assertNonProblem("VOID)", 4);
assertSame(td, ref);
-
+
IFunction func= ba.assertNonProblem("func", 4, IFunction.class);
IFunctionType ft= func.getType();
IType rt= ft.getReturnType();
@@ -4998,37 +4987,37 @@ public class AST2Tests extends AST2BaseTest {
IType pt = pts[0];
assertInstance(rt, ITypedef.class);
assertInstance(pt, ITypedef.class);
- rt= ((ITypedef)rt).getType();
- pt= ((ITypedef)pt).getType();
+ rt= ((ITypedef) rt).getType();
+ pt= ((ITypedef) pt).getType();
assertTrue(rt instanceof IBasicType);
- assertEquals(IBasicType.t_void, ((IBasicType)rt).getType());
+ assertEquals(IBasicType.t_void, ((IBasicType) rt).getType());
assertTrue(pt instanceof IBasicType);
- assertEquals(IBasicType.t_void, ((IBasicType)pt).getType());
+ assertEquals(IBasicType.t_void, ((IBasicType) pt).getType());
}
}
-
+
// #define str(s) # s
//
// void foo() {
// printf(str(this is a // this should go away
- // string));
+ // string));
// }
public void testCommentInExpansion_Bug84276() throws Exception {
IASTTranslationUnit tu= parseAndCheckBindings(getAboveComment());
IASTFunctionDefinition func= (IASTFunctionDefinition) tu.getDeclarations()[0];
-
+
IASTFunctionCallExpression fcall= (IASTFunctionCallExpression) ((IASTExpressionStatement)((IASTCompoundStatement) func.getBody()).getStatements()[0]).getExpression();
IASTLiteralExpression lit= (IASTLiteralExpression) fcall.getParameterExpression();
assertEquals("\"this is a string\"", lit.toString());
}
-
+
// typedef int tint;
// tint f1(tint (tint));
// int f2(int (int));
// int f3(int (tint));
// int f4(int (identifier));
- // int f5(int *(tint[10]));
+ // int f5(int *(tint[10]));
public void testParamWithFunctionType_Bug84242() throws Exception {
final String comment= getAboveComment();
final boolean[] isCpps= {false, true};
@@ -5046,14 +5035,14 @@ public class AST2Tests extends AST2BaseTest {
f= ba.assertNonProblem("f4", 2, IFunction.class);
isTypeEqual(f.getType(), "int (int)");
-
+
f= ba.assertNonProblem("f5", 2, IFunction.class);
isTypeEqual(f.getType(), "int (int * (*)(int *))");
}
}
// class C { };
- // void f1(int(C)) { }
+ // void f1(int(C)) { }
public void testParamWithFunctionTypeCpp_Bug84242() throws Exception {
BindingAssertionHelper ba= new BindingAssertionHelper(getAboveComment(), true);
@@ -5071,12 +5060,12 @@ public class AST2Tests extends AST2BaseTest {
IFunction f= ba.assertNonProblem("f1", 2, IFunction.class);
isTypeEqual(f.getType(), "int (* (int))[5]");
-
+
f= ba.assertNonProblem("f1 ", 2, IFunction.class);
isTypeEqual(f.getType(), "int (* (int))[5]");
}
}
-
+
// void f1() {}
// void (f2)() {}
// void (f3()) {}
@@ -5118,7 +5107,7 @@ public class AST2Tests extends AST2BaseTest {
IBinding binding= sdef.getDeclarators()[0].getName().resolveBinding();
assertInstance(binding, IFunction.class);
assertEquals(2, tu.getDeclarationsInAST(binding).length);
-
+
sdef= getDeclaration(tu, 5);
binding= sdef.getDeclarators()[0].getNestedDeclarator().getName().resolveBinding();
assertInstance(binding, IFunction.class);
@@ -5136,9 +5125,9 @@ public class AST2Tests extends AST2BaseTest {
}
}
- // void f() {
- // int a,b;
- // { b; a; int a; }
+ // void f() {
+ // int a,b;
+ // { b; a; int a; }
// }
public void testLocalVariableResolution_Bug235831() throws Exception {
final String comment= getAboveComment();
@@ -5154,7 +5143,7 @@ public class AST2Tests extends AST2BaseTest {
assertNotSame(v2, v3);
}
}
-
+
// int foo(int (*ptr) (int, int));
public void testComplexParameterBinding_Bug214482() throws Exception {
final String comment= getAboveComment();
@@ -5165,7 +5154,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals("ptr", p.getName());
}
}
-
+
// void test() {}
// +
public void testTrailingSyntaxErrorInTU() throws Exception {
@@ -5192,7 +5181,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals("+", pdecl.getRawSignature());
}
}
-
+
// void func() {
// {
// int test;
@@ -5210,7 +5199,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals("+", pstmt.getRawSignature());
}
}
-
+
// struct X {
// ;
// };
@@ -5226,7 +5215,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(";", empty.getRawSignature());
}
}
-
+
// void test() {
// int foux = 3;
// switch(foux) // no brace!
@@ -5245,11 +5234,11 @@ public class AST2Tests extends AST2BaseTest {
assertEquals("foux= 1;", stmt.getRawSignature());
}
}
-
+
// typedef int t;
// int a,b;
// void test() {
-
+
// b* (t)+a *b // b,t,a,unary+,cast,*,b,*
// b*(a) + a*b // b,a,*,a,b,*,+
// b* (t)-a *b // b,t,a,unary-,cast,*,b,*
@@ -5293,7 +5282,7 @@ public class AST2Tests extends AST2BaseTest {
// struct s* a;
// struct s* f(struct s*);
// void test() {
-
+
// (t)(a) // t,a,cast
// (f)(a) // f,a,()
// (t)(t)(a) // t,t,a,cast,cast
@@ -5330,7 +5319,7 @@ public class AST2Tests extends AST2BaseTest {
// int a,b;
// void test() {
-
+
// 1+2+3 // 1,2,+,3,+
// a=b=1 // a,b,1,=,=
// 0, a= 1 ? 2,3 : b= 4, 5 // 0,a,1,2,3,,,b,4,=,?,=,5,,
@@ -5355,7 +5344,7 @@ public class AST2Tests extends AST2BaseTest {
// int a,b;
// void test(int a=
-
+
// 1+2+3 // 1,2,+,3,+
// a=b=1 // a,b,1,=,=
// 1 ? 2,3 : b= 4 // 1,2,3,,,b,4,=,?
@@ -5413,7 +5402,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals("in expr: " + exprStr, endOffset(unaryExpr), endOffset(unaryExpr.getOperand()));
break;
}
- }
+ }
}
private int offset(IASTNode expr) {
@@ -5502,25 +5491,25 @@ public class AST2Tests extends AST2BaseTest {
buf.append(expr.getRawSignature());
}
}
-
+
// typedef struct {
// int x;
// } spinlock_t;
- // spinlock_t _lock = (spinlock_t) { };
+ // spinlock_t _lock = (spinlock_t) { };
public void testCompoundInitializer_bug145387() throws Exception {
// valid in C99, not in C++.
parseAndCheckBindings(getAboveComment(), ParserLanguage.C, true);
}
-
+
// enum __declspec(uuid("uuid")) bla { a, b};
public void testDeclspecInEnumSpecifier_bug241203() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
parseAndCheckBindings(getAboveComment(), lang, true);
}
}
-
+
// struct Outer {
- // struct {int a1;};
+ // struct {int a1;};
// struct {int a2;} a3;
// };
// void test() {
@@ -5536,7 +5525,7 @@ public class AST2Tests extends AST2BaseTest {
bh.assertNonProblem("a3=", 2);
}
}
-
+
// void test() {
// char* p;
// if (__builtin_types_compatible_p(typeof(p), char[])) {
@@ -5547,10 +5536,10 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(getAboveComment(), lang, true);
}
}
-
+
// void alloc(const char * id) {}
// void test() {
- // alloc(__func__);
+ // alloc(__func__);
// }
public void testPredefinedFunctionName_Bug247747() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.C, false);
@@ -5559,15 +5548,15 @@ public class AST2Tests extends AST2BaseTest {
// void alloc(const char * id) {}
// void test() {
- // alloc(__func__);
- // alloc(__FUNCTION__);
- // alloc(__PRETTY_FUNCTION__);
+ // alloc(__func__);
+ // alloc(__FUNCTION__);
+ // alloc(__PRETTY_FUNCTION__);
// }
public void testPredefinedFunctionNameGcc_Bug247747() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.C, true);
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true);
}
-
+
// int foo = 42;
// typedef char StupidType;
// StupidType const *bar = (StupidType const*)&foo;
@@ -5575,11 +5564,11 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(getAboveComment(), ParserLanguage.C, true);
parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, true);
}
-
+
// #define IF if
// #define IF_P if (
// #define IF_P_T if (1
- // #define SEMI_IF ; if
+ // #define SEMI_IF ; if
// #define IF_COND if (1)
// void test() {
public void testLeadingSyntax_Bug250251() throws Exception {
@@ -5658,14 +5647,14 @@ public class AST2Tests extends AST2BaseTest {
IToken syntax= x.getTrailingSyntax();
checkToken(syntax, ")", 0); syntax= syntax.getNext();
assertNull(syntax);
-
+
tu= parseAndCheckBindings(code + "do {} while(1 );}");
f= getDeclaration(tu, 0); IASTDoStatement dstmt= getStatement(f, 0); x= dstmt.getCondition();
syntax= x.getTrailingSyntax();
checkToken(syntax, ")", 1); syntax= syntax.getNext();
checkToken(syntax, ";", 2); syntax= syntax.getNext();
assertNull(syntax);
-
+
tu= parseAndCheckBindings(code + "if(1 ) BLOCK()}");
f= getDeclaration(tu, 0); i= getStatement(f, 0); x= i.getConditionExpression();
@@ -5705,11 +5694,11 @@ public class AST2Tests extends AST2BaseTest {
} catch (ExpansionOverlapsBoundaryException e) {
}
}
-
+
// #define IF if
// #define IF_P if (
// #define IF_P_T if (1
- // #define SEMI_IF ; if
+ // #define SEMI_IF ; if
// #define IF_COND if (1)
// void test() {
public void testSyntax_Bug250251() throws Exception {
@@ -5728,7 +5717,7 @@ public class AST2Tests extends AST2BaseTest {
assertNull(syntax);
tu= parseAndCheckBindings(code + "if( 1) {}}");
- f= getDeclaration(tu, 0); x= getStatement(f, 0);
+ f= getDeclaration(tu, 0); x= getStatement(f, 0);
syntax= x.getSyntax();
checkToken(syntax, "if", 0); syntax= syntax.getNext();
checkToken(syntax, "(", 2); syntax= syntax.getNext();
@@ -5761,13 +5750,13 @@ public class AST2Tests extends AST2BaseTest {
private void checkToken(IToken token, String image, int offset) {
assertEquals(image, token.getImage());
assertEquals(offset, token.getOffset());
- assertEquals(image.length(), token.getLength());
+ assertEquals(image.length(), token.getLength());
}
-
+
// void test() {
// int x,y;
// x
- // <<
+ // <<
// y;
// }
public void testSyntaxWithNL_Bug280175() throws Exception {
@@ -5775,14 +5764,14 @@ public class AST2Tests extends AST2BaseTest {
int offsetX= code.indexOf('x', code.indexOf('x')+1);
int offsetShift= code.indexOf('<');
int offsetY= code.indexOf('y', offsetX);
-
+
IASTTranslationUnit tu= parseAndCheckBindings(code);
IASTFunctionDefinition f= getDeclaration(tu, 0);
IASTExpressionStatement i = getStatement(f, 1);
final IASTBinaryExpression expr = (IASTBinaryExpression) i.getExpression();
IASTExpression x= expr.getOperand1();
IASTExpression y= expr.getOperand2();
-
+
IToken syntax= x.getTrailingSyntax();
checkToken(syntax, "<<", offsetShift-offsetX-1); syntax= syntax.getNext();
assertNull(syntax);
@@ -5834,7 +5823,7 @@ public class AST2Tests extends AST2BaseTest {
assertNotNull(numericalValue);
assertEquals(i, numericalValue.intValue());
}
-
+
// void myfunc(char *arg) {}
// void (*funcVar2)(char *) = myfunc;
// void caller() {
@@ -5859,11 +5848,11 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, lang);
}
}
-
+
// int a[]= {
-
- // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
+
+ // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
// };
public void testScalabilityOfLargeTrivialInitializer_Bug253690() throws Exception {
sValidateCopy= false;
@@ -5882,20 +5871,20 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu= parse(code, lang, false, true, true);
long diff= memoryUsed()-mem;
// allow a copy of the buffer + less than 2 bytes per initializer
- final int expected = code.length()*2 + AMOUNT + AMOUNT/2;
+ final int expected = code.length()*2 + AMOUNT + AMOUNT/2;
assertTrue(String.valueOf(diff) + " expected < " + expected, diff < expected);
assertTrue(tu.isFrozen());
}
}
-
+
// struct MyStrcutType {};
// MyStructType Data [1000000] = {
// {1,2,3},
// 1.2,
- // {
-
- // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-
+ // {
+
+ // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
// }
// };
public void testLargeTrivialAggregateInitializer_Bug253690() throws Exception {
@@ -5915,7 +5904,7 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu= parse(code, lang, false, true, true);
long diff= memoryUsed()-mem;
// allow a copy of the buffer + not even 1 byte per initializer
- final int expected = code.length()*2 + AMOUNT + AMOUNT/2;
+ final int expected = code.length()*2 + AMOUNT + AMOUNT/2;
assertTrue(String.valueOf(diff) + " expected < " + expected, diff < expected);
assertTrue(tu.isFrozen());
}
@@ -5929,7 +5918,7 @@ public class AST2Tests extends AST2BaseTest {
do {
Thread.sleep(50);
System.gc();
- mem= newMem;
+ mem= newMem;
newMem= runtime.totalMemory()-runtime.freeMemory();
} while (newMem < mem && ++i<5);
return mem;
@@ -5955,17 +5944,17 @@ public class AST2Tests extends AST2BaseTest {
final String code = getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
IASTNode node= parseAndCheckBindings(code, lang);
-
+
IASTNode[] children= node.getChildren();
assertEquals(1, children.length);
assertInstance(children[0], IASTFunctionDefinition.class);
-
+
children= children[0].getChildren();
assertEquals(3, children.length);
assertInstance(children[0], IASTDeclSpecifier.class);
assertInstance(children[1], IASTDeclarator.class);
assertInstance(children[2], IASTCompoundStatement.class);
-
+
children= children[2].getChildren();
assertEquals(1, children.length);
assertInstance(children[0], IASTDeclarationStatement.class);
@@ -5975,21 +5964,21 @@ public class AST2Tests extends AST2BaseTest {
assertInstance(children[0], IASTDeclSpecifier.class);
assertInstance(children[1], IASTDeclarator.class);
- children= children[1].getChildren();
+ children= children[1].getChildren();
assertEquals(3, children.length);
assertInstance(children[0], IASTPointerOperator.class);
assertInstance(children[1], IASTName.class);
assertInstance(children[2], IASTInitializer.class);
- children= children[2].getChildren()[0].getChildren(); // skip binary expression
+ children= children[2].getChildren()[0].getChildren(); // skip binary expression
assertEquals(2, children.length);
assertInstance(children[0], IASTLiteralExpression.class);
assertInstance(children[1], IASTLiteralExpression.class);
-
+
assertEquals(0, children[0].getChildren().length);
}
}
-
+
// struct s {
// int (mem);
// };
@@ -6002,7 +5991,7 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C);
parseAndCheckBindings(code, ParserLanguage.CPP);
}
-
+
// typedef struct {
// float a;
// int b;
@@ -6025,7 +6014,7 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// void test() {
// int a,b;
// if ((a)+b);
@@ -6040,7 +6029,7 @@ public class AST2Tests extends AST2BaseTest {
assertInstance(expr, IASTBinaryExpression.class);
}
}
-
+
// typedef int TInt;
// struct X {
// const TInt; // declaration without name
@@ -6053,7 +6042,7 @@ public class AST2Tests extends AST2BaseTest {
ITypedef td= bh.assertNonProblem("TInt; //", 4);
IField f= bh.assertNonProblem("a;", 1);
}
-
+
// struct beta {
// int glob;
// };
@@ -6074,7 +6063,7 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
}
}
-
+
// typedef struct A A;
// struct A; // struct
// struct A* a;
@@ -6082,7 +6071,7 @@ public class AST2Tests extends AST2BaseTest {
final String code= getAboveComment();
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu= parseAndCheckBindings(code, lang, true);
-
+
BindingAssertionHelper ba= new BindingAssertionHelper(code, lang == ParserLanguage.CPP);
ITypedef t= ba.assertNonProblem("A;", 1);
ICompositeType s1= ba.assertNonProblem("A; // struct", 1);
@@ -6091,9 +6080,9 @@ public class AST2Tests extends AST2BaseTest {
assertSame(s1, t.getType());
}
}
-
+
// typedef int TInt;
- // int a= TInt; //ref
+ // int a= TInt; //ref
public void testTypeAsExpressionIsProblem_261175() throws Exception {
final String code= getAboveComment();
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
@@ -6102,7 +6091,7 @@ public class AST2Tests extends AST2BaseTest {
bh= new BindingAssertionHelper(code, false);
bh.assertProblem("TInt; //ref", 4);
}
-
+
// typedef int x, y;
// void func(int c) {
// c= sizeof(x(y));
@@ -6116,7 +6105,7 @@ public class AST2Tests extends AST2BaseTest {
IVariable v= ba.assertNonProblem("y);", 1);
}
}
-
+
// int* v;
public void testPointerOperatorsAsChildren_260461() throws Exception {
final String code= getAboveComment();
@@ -6141,13 +6130,13 @@ public class AST2Tests extends AST2BaseTest {
// int i = 8888uL;
public void testBug269705_int_literal() throws Exception {
final String code= getAboveComment();
-
+
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
IASTDeclaration[] declarations = tu.getDeclarations();
-
+
// int a = -142;
- {
+ {
IBasicType t = getTypeForDeclaration(declarations, 0);
assertTrue(t.getType() == IBasicType.t_int);
assertFalse(t.isUnsigned());
@@ -6155,7 +6144,7 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(t.isLong());
assertFalse(isLongLong(t));
}
-
+
// int b = 456L;
{
IBasicType t = getTypeForDeclaration(declarations, 1);
@@ -6165,7 +6154,7 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(t.isLong());
assertFalse(isLongLong(t));
}
-
+
// int c = 100000LL;
{
IBasicType t = getTypeForDeclaration(declarations, 2);
@@ -6175,7 +6164,7 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(t.isLong());
assertTrue(isLongLong(t));
}
-
+
// int d = 0U;
{
IBasicType t = getTypeForDeclaration(declarations, 3);
@@ -6186,7 +6175,7 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(t.isLong());
}
-
+
// int e = 1UL;
{
IBasicType t = getTypeForDeclaration(declarations, 4);
@@ -6196,7 +6185,7 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(t.isLong());
assertFalse(isLongLong(t));
}
-
+
// int f = 9u;
{
IBasicType t = getTypeForDeclaration(declarations, 5);
@@ -6207,7 +6196,7 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(t.isLong());
}
-
+
// int g = 1234l;
{
IBasicType t = getTypeForDeclaration(declarations, 6);
@@ -6217,7 +6206,7 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(t.isLong());
assertFalse(isLongLong(t));
}
-
+
// int h = -123ll;
{
IBasicType t = getTypeForDeclaration(declarations, 7);
@@ -6227,7 +6216,7 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(t.isLong());
assertTrue(isLongLong(t));
}
-
+
// int i = 8888uL;
{
IBasicType t = getTypeForDeclaration(declarations, 8);
@@ -6310,15 +6299,15 @@ public class AST2Tests extends AST2BaseTest {
}
return false;
}
-
+
/**
* @param declarations
* @param index
* @return
*/
private IBasicType getTypeForDeclaration(IASTDeclaration[] declarations, int index) {
- IASTInitializer init = ((IASTSimpleDeclaration)declarations[index]).getDeclarators()[0].getInitializer();
- return (IBasicType)((IASTExpression)((IASTEqualsInitializer)init).getInitializerClause()).getExpressionType();
+ IASTInitializer init = ((IASTSimpleDeclaration) declarations[index]).getDeclarators()[0].getInitializer();
+ return (IBasicType)((IASTExpression)((IASTEqualsInitializer) init).getInitializerClause()).getExpressionType();
}
// void test() {
@@ -6332,7 +6321,7 @@ public class AST2Tests extends AST2BaseTest {
public void testPredefinedMacroNamesC() throws Exception {
parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
}
-
+
// long double longDouble = 1.0;
// double _double = 1.0;
// float _float= 1.0;
@@ -6387,7 +6376,7 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
// double _double = 1.0;
// float _float= 1.0;
// long long int longLongInt = 1;
@@ -6439,7 +6428,7 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
// float _float= 1.0;
// long long int longLongInt = 1;
// long int longInt = 1;
@@ -6486,7 +6475,7 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
// long long int longLongInt = 1;
// long int longInt = 1;
// int _int = 1;
@@ -6534,7 +6523,7 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
// long long int longLongInt = 1;
// long int longInt = 1;
// int _int = 1;
@@ -6578,7 +6567,7 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
// int _int = 1;
// short int shortInt = 1;
// char _char = 1;
@@ -6619,7 +6608,7 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
// short int shortInt = 1;
// char _char = 1;
//
@@ -6658,7 +6647,7 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
// char _char = 1;
//
// float var;
@@ -6692,7 +6681,7 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
//
// char _char = 1;
// signed char signedChar = 1;
@@ -6716,7 +6705,7 @@ public class AST2Tests extends AST2BaseTest {
//
// /* (3) Should be an unsigned int*/
// var = unsignedInt + signedChar;
- //
+ //
// /* (4) Should be a signed long int */
// var = signedLongInt + unsignedInt;
//
@@ -6724,7 +6713,7 @@ public class AST2Tests extends AST2BaseTest {
// var = signedLongInt + unsignedLongInt;
//
// /* (6) Should be an unsigned long int*/
- // var = unsignedLongInt + signedLongInt;
+ // var = unsignedLongInt + signedLongInt;
// }
public void testTypePromotion_signedAndUnsignedInts() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
@@ -6830,8 +6819,8 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(type1.isLongLong());
}
}
- }
-
+ }
+
// char c;
// void func() {
// c;
@@ -6847,7 +6836,7 @@ public class AST2Tests extends AST2BaseTest {
IBasicType t= (IBasicType) expr.getExpressionType();
assertEquals(Kind.eChar, t.getKind());
assertEquals(0, t.getModifiers());
-
+
for (int i = 1; i < 4; i++) {
expr= getExpressionOfStatement(fdef, i);
t= (IBasicType) expr.getExpressionType();
@@ -6856,16 +6845,16 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
//
// int MyGlobal[10];
//
public void testBug273797() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
- IASTName n = ((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclarators()[0].getName();
+ IASTName n = ((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclarators()[0].getName();
IVariable v = (IVariable) n.resolveBinding();
-
- ICArrayType t = (ICArrayType)v.getType();
+
+ ICArrayType t = (ICArrayType) v.getType();
assertFalse(t.isConst());
assertFalse(t.isRestrict());
assertFalse(t.isVolatile());
@@ -6884,9 +6873,9 @@ public class AST2Tests extends AST2BaseTest {
// }
public void testBug278797() throws Exception {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.C);
- IASTFunctionDefinition func = (IASTFunctionDefinition)tu.getDeclarations()[1];
- IASTExpressionStatement stmt = ((IASTExpressionStatement)((IASTCompoundStatement)func.getBody()).getStatements()[0]);
- IType t = ((IASTCastExpression)stmt.getExpression()).getOperand().getExpressionType();
+ IASTFunctionDefinition func = (IASTFunctionDefinition) tu.getDeclarations()[1];
+ IASTExpressionStatement stmt = ((IASTExpressionStatement)((IASTCompoundStatement) func.getBody()).getStatements()[0]);
+ IType t = ((IASTCastExpression) stmt.getExpression()).getOperand().getExpressionType();
assertNotNull(t);
assertTrue(t instanceof IEnumeration);
}
@@ -6902,39 +6891,39 @@ public class AST2Tests extends AST2BaseTest {
//int a[2][3] = {{1,2,3},{4,5,6}};
{
IASTDeclaration d = tu.getDeclarations()[0];
- IBinding b = ((IASTSimpleDeclaration)d).getDeclarators()[0].getName().resolveBinding();
- IType t = ((IVariable)b).getType();
+ IBinding b = ((IASTSimpleDeclaration) d).getDeclarators()[0].getName().resolveBinding();
+ IType t = ((IVariable) b).getType();
assertTrue(t instanceof IArrayType);
- IArrayType at1 = (IArrayType)t;
+ IArrayType at1 = (IArrayType) t;
IASTExpression size1 = at1.getArraySizeExpression();
assertTrue(at1.getType() instanceof IArrayType);
IArrayType at2 = (IArrayType) at1.getType();
IASTExpression size2 = at2.getArraySizeExpression();
assertTrue(size1 instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression)size1).getValue()[0], '2');
+ assertEquals(((IASTLiteralExpression) size1).getValue()[0], '2');
assertTrue(size2 instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression)size2).getValue()[0], '3');
+ assertEquals(((IASTLiteralExpression) size2).getValue()[0], '3');
}
//int b[3][2] = {{1,2},{3,4},{5,6}};
{
IASTDeclaration d = tu.getDeclarations()[1];
- IBinding b = ((IASTSimpleDeclaration)d).getDeclarators()[0].getName().resolveBinding();
- IType t = ((IVariable)b).getType();
+ IBinding b = ((IASTSimpleDeclaration) d).getDeclarators()[0].getName().resolveBinding();
+ IType t = ((IVariable) b).getType();
assertTrue(t instanceof IArrayType);
- IArrayType at1 = (IArrayType)t;
+ IArrayType at1 = (IArrayType) t;
IASTExpression size1 = at1.getArraySizeExpression();
assertTrue(at1.getType() instanceof IArrayType);
IArrayType at2 = (IArrayType) at1.getType();
IASTExpression size2 = at2.getArraySizeExpression();
assertTrue(size1 instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression)size1).getValue()[0], '3');
+ assertEquals(((IASTLiteralExpression) size1).getValue()[0], '3');
assertTrue(size2 instanceof IASTLiteralExpression);
- assertEquals(((IASTLiteralExpression)size2).getValue()[0], '2');
+ assertEquals(((IASTLiteralExpression) size2).getValue()[0], '2');
}
}
}
- // /* Check that a parameter declared as a typedef'd array
+ // /* Check that a parameter declared as a typedef'd array
// * is treated as a pointer
// */
//typedef int my_buf[16];
@@ -6948,7 +6937,7 @@ public class AST2Tests extends AST2BaseTest {
assertTrue(((IFunction) n.resolveBinding()).getType().getParameterTypes()[0] instanceof IPointerType);
}
}
-
+
//
// /* check that enumerator values are evaluated correctly for
// * conditional expressions */
@@ -6962,7 +6951,7 @@ public class AST2Tests extends AST2BaseTest {
public void testBug295851() throws Exception {
for (ParserLanguage lang : ParserLanguage.values()) {
IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), lang);
- IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)((IASTSimpleDeclaration)tu.getDeclarations()[0]).getDeclSpecifier();
+ IASTEnumerationSpecifier enumSpec = (IASTEnumerationSpecifier)((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclSpecifier();
IEnumerator enumeratorBinding = (IEnumerator) enumSpec.getEnumerators()[0].getName().resolveBinding();
IValue value = enumeratorBinding.getValue();
assertEquals(2, value.numericalValue().longValue());
@@ -6984,30 +6973,30 @@ public class AST2Tests extends AST2BaseTest {
// }
public void testBindingsOnFields() throws Exception {
IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, false);
- IASTCompoundStatement bodyStmt = (IASTCompoundStatement)((IASTFunctionDefinition)tu.getDeclarations()[2]).getBody();
+ IASTCompoundStatement bodyStmt = (IASTCompoundStatement)((IASTFunctionDefinition) tu.getDeclarations()[2]).getBody();
// Get the IFields bindings from the type used in the declaration of structure
- IASTName n = ((IASTSimpleDeclaration)((IASTDeclarationStatement)bodyStmt.getStatements()[0]).getDeclaration()).getDeclarators()[0].getName();
- ICompositeType t = (ICompositeType)((IVariable)n.resolveBinding()).getType();
+ IASTName n = ((IASTSimpleDeclaration)((IASTDeclarationStatement) bodyStmt.getStatements()[0]).getDeclaration()).getDeclarators()[0].getName();
+ ICompositeType t = (ICompositeType)((IVariable) n.resolveBinding()).getType();
IField[] fields = t.getFields();
assertTrue(fields.length == 2);
// Get the IField for the first assignment
- IASTFieldReference ref1 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement)bodyStmt.getStatements()[1]).getExpression()).getOperand1();
+ IASTFieldReference ref1 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[1]).getExpression()).getOperand1();
IBinding field1 = ref1.getFieldName().resolveBinding();
-
+
// Get the IField for the second assignment
- IASTFieldReference ref2 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement)bodyStmt.getStatements()[2]).getExpression()).getOperand1();
+ IASTFieldReference ref2 = (IASTFieldReference)((IASTBinaryExpression)((IASTExpressionStatement) bodyStmt.getStatements()[2]).getExpression()).getOperand1();
IBinding field2 = ref2.getFieldName().resolveBinding();
// Compare the IField from the type and the assignments
assertEquals(fields[0], field1);
assertEquals(fields[1], field2); // fails
-
+
assertEquals(1, ((ICInternalBinding) field1).getDeclarations().length);
assertEquals(1, ((ICInternalBinding) field2).getDeclarations().length);
}
-
+
// /*
// * Check that the type returned by CASTArraySubscriptExpression
// * handles typedefs correctly.
@@ -7025,7 +7014,7 @@ public class AST2Tests extends AST2BaseTest {
// newArray var5;
//
// void foo() {
- // /* The type of the arraysubscript expression should be struct s
+ // /* The type of the arraysubscript expression should be struct s
// * each of the following statements
// */
// var1[1].a = 1;
@@ -7045,13 +7034,13 @@ public class AST2Tests extends AST2BaseTest {
IASTExpression owner = ((IASTFieldReference) op1).getFieldOwner();
IType t = owner.getExpressionType();
assertTrue(t instanceof ICompositeType);
- assertEquals("s",((ICompositeType)t).getName());
+ assertEquals("s", ((ICompositeType) t).getName());
}
}
}
}
}
-
+
// char array[10];
// char* ptr;
//
@@ -7076,7 +7065,7 @@ public class AST2Tests extends AST2BaseTest {
}
}
}
-
+
// extern int a[];
// int a[1];
public void testIncompleteArrays_269926() throws Exception {
@@ -7084,7 +7073,7 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C);
parseAndCheckBindings(code, ParserLanguage.CPP);
}
-
+
// void f1(const int* p);
// void f2(const int* p) {}
public void testDroppingOfStorageDecl_293322() throws Exception {
@@ -7095,7 +7084,7 @@ public class AST2Tests extends AST2BaseTest {
f= bh.assertNonProblem("f2", 2);
assertEquals("const int *", ASTTypeUtil.getType(f.getParameters()[0].getType()));
}
-
+
// typedef int f(int);
// f ff;
public void testFunctionDeclViaTypedef_86495() throws Exception {
@@ -7108,9 +7097,9 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(1, ff.getParameters().length);
}
}
-
+
// void f() {
- // int a=
+ // int a=
public void testLargeExpression_294029() throws Exception {
// when running the test in a suite, it cannot handle more than 160 parenthesis.
// run as a single test it does > 500.
@@ -7131,13 +7120,13 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
}
}
-
+
// static a[2]= {0,0};
public void testSkipAggregateInitializer_297550() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.C, false, true);
}
-
+
// typeof(b(1)) b(int);
public void testRecursiveFunctionType_321856() throws Exception {
final String code = getAboveComment();
@@ -7146,7 +7135,7 @@ public class AST2Tests extends AST2BaseTest {
f= bh.assertNonProblem("b(int)", 1);
f.getType();
}
-
+
public void testDeepBinaryExpression_294969() throws Exception {
sValidateCopy= false;
StringBuilder buf= new StringBuilder("void f() {0");
@@ -7159,7 +7148,7 @@ public class AST2Tests extends AST2BaseTest {
IASTTranslationUnit tu = parseAndCheckBindings(code, lang);
}
}
-
+
public void testDeepElseif_298455() throws Exception {
sValidateCopy= false;
StringBuilder buf= new StringBuilder("void f() {if (0) {}");
@@ -7179,7 +7168,7 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// void func(int* obj) {
// int* obj = 0;
// }
@@ -7192,7 +7181,7 @@ public class AST2Tests extends AST2BaseTest {
bh.assertNonProblem("obj", 3, IParameter.class);
bh.assertProblem("obj =", 3);
}
-
+
// #define ONCE() PRAGMA(once)
// #define PRAGMA(x) _Pragma(#x)
// #pragma once
@@ -7216,7 +7205,7 @@ public class AST2Tests extends AST2BaseTest {
assertEquals(i>2, ((IASTPreprocessorPragmaStatement) stmt).isPragmaOperator());
}
}
-
+
// int min(int,int);
// void test() {
// int a= (min)(1, 2);
@@ -7226,7 +7215,7 @@ public class AST2Tests extends AST2BaseTest {
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// #define MACRO
// void funca(){
// }
@@ -7243,20 +7232,20 @@ public class AST2Tests extends AST2BaseTest {
assertEquals("MACRO", t.getImage());
}
}
-
+
// typedef __builtin_va_list va_list;
// #define va_arg(v,l) __builtin_va_arg(v,l)
// void test(int c, ...) {
// int (*x)[3];
// va_list list;
- // x = va_arg(list, int(*)[3]);
+ // x = va_arg(list, int(*)[3]);
// }
public void testVaArgWithFunctionPtr_311030() throws Exception {
final String code = getAboveComment();
parseAndCheckBindings(code, ParserLanguage.C, true);
parseAndCheckBindings(code, ParserLanguage.CPP, true);
}
-
+
// void test() {
// __builtin_va_list result;
// }
@@ -7272,7 +7261,7 @@ public class AST2Tests extends AST2BaseTest {
assertInstance(var, IVariable.class);
assertTrue(var.getScope().getKind() == EScopeKind.eLocal);
}
-
+
// void foo(int i);
// void foo(int j) { }
public void testParameterBindings_316931() throws Exception {
@@ -7283,15 +7272,15 @@ public class AST2Tests extends AST2BaseTest {
IParameter i= bh.assertNonProblem("i)", 1);
IParameter j= bh.assertNonProblem("j)", 1);
assertSame(i, j);
-
+
IASTTranslationUnit tu= bh.getTranslationUnit();
IASTName[] decls = tu.getDeclarationsInAST(i);
assertEquals(2, decls.length);
decls = tu.getDeclarationsInAST(j);
assertEquals(2, decls.length);
}
- }
-
+ }
+
// typedef __typeof__((int*)0-(int*)0) ptrdiff_t;
// typedef __typeof__(sizeof(int)) size_t;
public void testPtrDiffRecursion_317004() throws Exception {
@@ -7312,14 +7301,14 @@ public class AST2Tests extends AST2BaseTest {
td= bh.assertNonProblem("size_t", 0);
assertEquals("unsigned long int", ASTTypeUtil.getType(td.getType()));
}
-
+
// void f(int a) {
// int tmp = a;
// }
// void f(int);
public void testParameterResolution() throws Exception {
final String code = getAboveComment();
-
+
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
bh.assertNonProblem("f(int a)", 1);
bh.assertNonProblem("f(int)", 1);
@@ -7342,12 +7331,11 @@ public class AST2Tests extends AST2BaseTest {
assertFalse(stmts[1].isActive());
assertFalse(stmts[2].isActive());
assertTrue(stmts[3].isActive());
-
+
assertFalse(((IASTPreprocessorIfdefStatement) stmts[0]).taken());
assertFalse(((IASTPreprocessorIfdefStatement) stmts[1]).taken());
- }
-
-
+ }
+
// void a() {
// typedef float size_t;
// sizeof(10); // wrong - getExpressionType returns float
@@ -7369,15 +7357,15 @@ public class AST2Tests extends AST2BaseTest {
es= getStatement(a, 2);
assertEquals("unsigned long int", ASTTypeUtil.getType(es.getExpression().getExpressionType()));
}
-
+
// void foo(){
// typedef int foobar_t;
// foobar_t *a = 0, *b = a;
// }
public void testAmbiguousStatement_Bug360541() throws Exception {
parseAndCheckBindings();
- }
-
+ }
+
// typedef int T[sizeof(int)];
public void testSizeofExpression_Bug362464() throws Exception {
String code= getAboveComment();
@@ -7389,8 +7377,8 @@ public class AST2Tests extends AST2BaseTest {
IValue v= at.getSize();
assertTrue(v.numericalValue() == 4);
}
- }
-
+ }
+
// #define NULL_STATEMENT_MACRO ;;
// void macro_test() {
// NULL_STATEMENT_MACRO //comment
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CLanguageData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CLanguageData.java
index b8ed907138d..55c90586e8d 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CLanguageData.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CLanguageData.java
@@ -6,15 +6,15 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Intel Corporation - Initial API and implementation
+ * Intel Corporation - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.settings.model.extension;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
public abstract class CLanguageData extends CDataObject {
+
protected CLanguageData() {
-
}
// public abstract CDataObject[] getChildrenOfKind(int kind);
@@ -52,7 +52,7 @@ public abstract class CLanguageData extends CDataObject {
public abstract void setSourceExtensions(String exts[]);
- public boolean containsDiscoveredScannerInfo(){
+ public boolean containsDiscoveredScannerInfo() {
return true;
}
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java
index e140e2f0bc0..bab280e25f4 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java
@@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Intel Corporation - Initial API and implementation
- * James Blackburn (Broadcom Corp.)
- * Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
+ * Intel Corporation - Initial API and implementation
+ * James Blackburn (Broadcom Corp.)
+ * Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
*******************************************************************************/
package org.eclipse.cdt.internal.core.settings.model;
@@ -62,21 +62,21 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
private boolean fNeedsPersistance;
private boolean fIsCfgModified;
- CfgIdPair(CfgIdPair base){
+ CfgIdPair(CfgIdPair base) {
fId = base.fId;
fPersistanceName = base.fPersistanceName;
}
- CfgIdPair(QualifiedName persistanceName){
+ CfgIdPair(QualifiedName persistanceName) {
fPersistanceName = persistanceName;
}
- public String getId(){
- if(fId == null){
+ public String getId() {
+ if (fId == null) {
fId = load();
- if(fId == null){
+ if (fId == null) {
fId = getFirstCfgId();
- if(fId != null){
+ if (fId != null) {
fNeedsPersistance = true;
}
}
@@ -85,13 +85,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
public ICConfigurationDescription getConfiguration() {
- if(fCfg == null){
+ if (fCfg == null) {
String id = getId();
- if(id != null){
+ if (id != null) {
fCfg = getConfigurationById(id);
- if(fCfg == null){
+ if (fCfg == null) {
fId = getFirstCfgId();
- if(fId != null){
+ if (fId != null) {
fCfg = getConfigurationById(fId);
fNeedsPersistance = true;
}
@@ -101,11 +101,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
return fCfg;
}
- public void setConfiguration(ICConfigurationDescription cfg){
- if(cfg.getProjectDescription() != CProjectDescription.this)
+ public void setConfiguration(ICConfigurationDescription cfg) {
+ if (cfg.getProjectDescription() != CProjectDescription.this)
throw new IllegalArgumentException();
- if(cfg.getId().equals(getId()))
+ if (cfg.getId().equals(getId()))
return;
fCfg = cfg;
@@ -114,11 +114,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
fNeedsPersistance = true;
}
- public void configurationRemoved(ICConfigurationDescription cfg){
- if(cfg.getProjectDescription() != CProjectDescription.this)
+ public void configurationRemoved(ICConfigurationDescription cfg) {
+ if (cfg.getProjectDescription() != CProjectDescription.this)
throw new IllegalArgumentException();
- if(!cfg.getId().equals(getId()))
+ if (!cfg.getId().equals(getId()))
return;
fIsCfgModified = true;
@@ -126,7 +126,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
getConfiguration();
}
- private String load(){
+ private String load() {
try {
return getProject().getPersistentProperty(fPersistanceName);
} catch (CoreException e) {
@@ -135,8 +135,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
return null;
}
- private boolean store(String oldId, boolean force){
- if(force || fIsCfgModified || fNeedsPersistance || oldId == null || !oldId.equals(fId)){
+ private boolean store(String oldId, boolean force) {
+ if (force || fIsCfgModified || fNeedsPersistance || oldId == null || !oldId.equals(fId)) {
try {
getProject().setPersistentProperty(fPersistanceName, fId);
fIsCfgModified = false;
@@ -162,7 +162,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
fIsCreating = isCreating;
ICStorageElement el = null;
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
- if(loading){
+ if (loading) {
Map<String, ICStorageElement> cfgStorMap = mngr.createCfgStorages(this);
for (ICStorageElement sel : cfgStorMap.values()) {
@@ -174,22 +174,22 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
fPrefs = new CProjectDescriptionPreferences(el,
- (CProjectDescriptionPreferences)mngr.getProjectDescriptionWorkspacePreferences(false),
+ (CProjectDescriptionPreferences) mngr.getProjectDescriptionWorkspacePreferences(false),
false);
fPropertiesMap = new HashMap<QualifiedName, Object>();
}
- public void updateProject(IProject project){
+ public void updateProject(IProject project) {
fProject = project;
}
- public void loadDatas(){
- if(!fIsReadOnly || !fIsLoading)
+ public void loadDatas() {
+ if (!fIsReadOnly || !fIsLoading)
return;
- for(Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();){
- CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
+ for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
+ CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) iter.next();
try {
cache.loadData();
} catch (CoreException e) {
@@ -203,15 +203,15 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
// fIsLoading = false;
}
- public boolean applyDatas(SettingsContext context){
- if(!fIsReadOnly || !fIsApplying)
+ public boolean applyDatas(SettingsContext context) {
+ if (!fIsReadOnly || !fIsApplying)
return false;
boolean modified = false;
for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
- CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
+ CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) iter.next();
try {
- if(cache.applyData(context))
+ if (cache.applyData(context))
modified = true;
} catch (CoreException e) {
CCorePlugin.log(e);
@@ -233,7 +233,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
* setModified (false)
* set the ICSettingsStorage to readonly
*/
- public void doneApplying(){
+ public void doneApplying() {
doneInitializing();
fIsApplying = false;
@@ -246,31 +246,31 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
setModified(false);
}
- public void doneLoading(){
+ public void doneLoading() {
doneInitializing();
fIsLoading = false;
}
- public void setLoading(boolean loading){
+ public void setLoading(boolean loading) {
fIsLoading = loading;
}
- private void doneInitializing(){
+ private void doneInitializing() {
for (ICConfigurationDescription cfg : fCfgMap.values()) {
// FIXME How and why are we down casting to a CConfigurationDescriptionCache. Comments, please!
- CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)cfg;
+ CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache) cfg;
cache.doneInitialization();
}
- if(fIsReadOnly)
+ if (fIsReadOnly)
fPrefs.setReadOnly(true);
}
- public boolean isLoading(){
+ public boolean isLoading() {
return fIsLoading;
}
- public boolean isApplying(){
+ public boolean isApplying() {
return fIsApplying;
}
@@ -296,30 +296,30 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
fPrefs = new CProjectDescriptionPreferences(base.fPrefs, (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false), false);
- for(Iterator<ICConfigurationDescription> iter = base.fCfgMap.values().iterator(); iter.hasNext();){
+ for (Iterator<ICConfigurationDescription> iter = base.fCfgMap.values().iterator(); iter.hasNext();) {
try {
- IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)iter.next();
- if(fIsReadOnly){
+ IInternalCCfgInfo cfgDes = (IInternalCCfgInfo) iter.next();
+ if (fIsReadOnly) {
CConfigurationData baseData = cfgDes.getConfigurationData(false);
CConfigurationDescriptionCache baseCache = null;
- if(baseData instanceof CConfigurationDescriptionCache){
- baseCache = (CConfigurationDescriptionCache)baseData;
+ if (baseData instanceof CConfigurationDescriptionCache) {
+ baseCache = (CConfigurationDescriptionCache) baseData;
baseData = baseCache.getConfigurationData();
}
- CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICConfigurationDescription)cfgDes, baseData, baseCache, cfgDes.getSpecSettings(), this, null);
+ CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICConfigurationDescription) cfgDes, baseData, baseCache, cfgDes.getSpecSettings(), this, null);
configurationCreated(cache);
} else {
CConfigurationData baseData = cfgDes.getConfigurationData(false);
CConfigurationDescription cfg = new CConfigurationDescription(baseData, this);
configurationCreated(cfg);
}
- } catch (CoreException e){
+ } catch (CoreException e) {
CCorePlugin.log(e);
}
}
@SuppressWarnings("unchecked")
- HashMap<QualifiedName, Object> cloneMap = (HashMap<QualifiedName, Object>)base.fPropertiesMap.clone();
+ HashMap<QualifiedName, Object> cloneMap = (HashMap<QualifiedName, Object>) base.fPropertiesMap.clone();
fPropertiesMap = cloneMap;
}
@@ -328,14 +328,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
* This occurs during the SetCProjectDescription Operation
*/
void switchToCachedConfigurationDescriptions() throws CoreException {
-
for (Map.Entry<String, ICConfigurationDescription> e : fCfgMap.entrySet()) {
if (e.getValue() instanceof CConfigurationDescription) {
- CConfigurationDescription cfgDes = (CConfigurationDescription)e.getValue();
- CConfigurationData baseData = ((IInternalCCfgInfo)cfgDes).getConfigurationData(false);
+ CConfigurationDescription cfgDes = (CConfigurationDescription) e.getValue();
+ CConfigurationData baseData = ((IInternalCCfgInfo) cfgDes).getConfigurationData(false);
CConfigurationDescriptionCache baseCache = null;
- if(baseData instanceof CConfigurationDescriptionCache){
- baseCache = (CConfigurationDescriptionCache)baseData;
+ if (baseData instanceof CConfigurationDescriptionCache) {
+ baseCache = (CConfigurationDescriptionCache) baseData;
baseData = baseCache.getConfigurationData();
}
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache(cfgDes, baseData, baseCache,
@@ -345,14 +344,14 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
}
- void configurationCreated(ICConfigurationDescription des){
+ void configurationCreated(ICConfigurationDescription des) {
fCfgMap.put(des.getId(), des);
}
@Override
public ICConfigurationDescription createConfiguration(String id, String name,
ICConfigurationDescription base) throws CoreException{
- if(fIsReadOnly)
+ if (fIsReadOnly)
throw ExceptionFactory.createIsReadOnlyException();
CConfigurationDescription cfg = new CConfigurationDescription(id, name, base, this);
configurationCreated(cfg);
@@ -364,8 +363,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
return fActiveCfgInfo.getConfiguration();
}
- private String getFirstCfgId(){
- if(!fCfgMap.isEmpty()){
+ private String getFirstCfgId() {
+ if (!fCfgMap.isEmpty()) {
return fCfgMap.keySet().iterator().next();
}
return null;
@@ -378,9 +377,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
@Override
public ICConfigurationDescription getConfigurationByName(String name) {
- for(Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();){
+ for (Iterator<ICConfigurationDescription> iter = fCfgMap.values().iterator(); iter.hasNext();) {
ICConfigurationDescription cfg = iter.next();
- if(name.equals(cfg.getName()))
+ if (name.equals(cfg.getName()))
return cfg;
}
return null;
@@ -393,18 +392,17 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
@Override
public void removeConfiguration(String name) throws WriteAccessException {
- if(fIsReadOnly)
+ if (fIsReadOnly)
throw ExceptionFactory.createIsReadOnlyException();
- CConfigurationDescription cfgDes = (CConfigurationDescription)getConfigurationByName(name);
- if(cfgDes != null){
+ CConfigurationDescription cfgDes = (CConfigurationDescription) getConfigurationByName(name);
+ if (cfgDes != null) {
cfgDes.removeConfiguration();
}
-
}
- void configurationRemoved(CConfigurationDescription des){
+ void configurationRemoved(CConfigurationDescription des) {
fCfgMap.remove(des.getId());
fIsModified = true;
@@ -414,25 +412,24 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
@Override
public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
- if(fIsReadOnly)
+ if (fIsReadOnly)
throw ExceptionFactory.createIsReadOnlyException();
- ((CConfigurationDescription)cfg).removeConfiguration();
+ ((CConfigurationDescription) cfg).removeConfiguration();
}
@Override
public void setActiveConfiguration(
ICConfigurationDescription cfg) throws WriteAccessException {
- if(fIsReadOnly)
+ if (fIsReadOnly)
throw ExceptionFactory.createIsReadOnlyException();
- if(cfg == null)
+ if (cfg == null)
throw new NullPointerException();
fActiveCfgInfo.setConfiguration(cfg);
- if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
+ if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
fSettingCfgInfo.setConfiguration(cfg);
-
}
@Override
@@ -492,10 +489,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
@Override
public void updateChild(CDataProxy child, boolean write) {
- if(write){
+ if (write) {
try {
String oldId = child.getId();
- CConfigurationDescription cfgDes = ((CConfigurationDescription)child);
+ CConfigurationDescription cfgDes = ((CConfigurationDescription) child);
cfgDes.doWritable();
updateMap(cfgDes, oldId);
} catch (CoreException e) {
@@ -504,8 +501,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
}
- void updateMap(CConfigurationDescription des, String oldId){
- if(!oldId.equals(des.getId())){
+ void updateMap(CConfigurationDescription des, String oldId) {
+ if (!oldId.equals(des.getId())) {
fCfgMap.remove(oldId);
fCfgMap.put(des.getId(), des);
}
@@ -515,26 +512,26 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
if (fRootStorageElement == null)
throw ExceptionFactory.createCoreException("CProjectDescription ICStorageElement == null"); //$NON-NLS-1$
-// if(fRootStorageElement == null){
+// if (fRootStorageElement == null) {
// fRootStorageElement = CProjectDescriptionManager.getInstance().createStorage(fProject, true, true, isReadOnly());
// }
return fRootStorageElement;
}
-// ICStorageElement doGetCachedRootStorageElement(){
+// ICStorageElement doGetCachedRootStorageElement() {
// return fRootStorageElement;
// }
ICSettingsStorage getStorageBase() throws CoreException{
- if(fStorage == null)
-// fStorage = new CStorage((InternalXmlStorageElement)getRootStorageElement());
+ if (fStorage == null)
+// fStorage = new CStorage((InternalXmlStorageElement) getRootStorageElement());
throw ExceptionFactory.createCoreException("CProjectDescription ICSettingsStorage == null"); //$NON-NLS-1$
return fStorage;
}
@Override
public ICConfigurationDescription createConfiguration(String buildSystemId, CConfigurationData data) throws CoreException {
- if(fIsReadOnly)
+ if (fIsReadOnly)
throw ExceptionFactory.createIsReadOnlyException();
CConfigurationDescription cfg = new CConfigurationDescription(data, buildSystemId, this);
configurationCreated(cfg);
@@ -542,7 +539,7 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
public CConfigurationDescription createConvertedConfiguration(String id, String name, ICStorageElement el) throws CoreException{
- if(fIsReadOnly)
+ if (fIsReadOnly)
throw ExceptionFactory.createIsReadOnlyException();
CConfigurationDescription cfg = new CConfigurationDescription(id, name, el, this);
configurationCreated(cfg);
@@ -550,47 +547,48 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
boolean needsDescriptionPersistence() {
- if(fIsModified)
+ if (fIsModified)
return true;
- if(fPrefs.isModified())
+ if (fPrefs.isModified())
return true;
- if(fStorage.isModified())
+ if (fStorage.isModified())
return true;
- for(ICConfigurationDescription cfgDes : fCfgMap.values())
- if(cfgDes.isModified())
+ for (ICConfigurationDescription cfgDes : fCfgMap.values()) {
+ if (cfgDes.isModified())
return true;
+ }
return false;
}
@Override
public boolean isModified() {
- if(needsDescriptionPersistence())
+ if (needsDescriptionPersistence())
return true;
- if(needsActiveCfgPersistence())
+ if (needsActiveCfgPersistence())
return true;
- if(needsSettingCfgPersistence())
+ if (needsSettingCfgPersistence())
return true;
return false;
}
- private void setModified(boolean modified){
+ private void setModified(boolean modified) {
fIsModified = modified;
- if(!modified){
+ if (!modified) {
fActiveCfgInfo.fIsCfgModified = false;
fSettingCfgInfo.fIsCfgModified = false;
fPrefs.setModified(false);
- //no need to do that for config cache since they always maintain the "isModified == false"
+ // no need to do that for config cache since they always maintain the "isModified == false"
}
}
@@ -614,8 +612,8 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
@Override
- public ICConfigurationDescription getDefaultSettingConfiguration(){
- if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
+ public ICConfigurationDescription getDefaultSettingConfiguration() {
+ if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
return getActiveConfiguration();
return fSettingCfgInfo.getConfiguration();
@@ -623,14 +621,14 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
@Override
public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
- if(fIsReadOnly)
+ if (fIsReadOnly)
throw ExceptionFactory.createIsReadOnlyException();
- if(cfg == null)
+ if (cfg == null)
throw new NullPointerException();
fSettingCfgInfo.setConfiguration(cfg);
- if(getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
+ if (getConfigurationRelations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
fActiveCfgInfo.setConfiguration(cfg);
}
@@ -641,10 +639,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
@Override
public void setSessionProperty(QualifiedName name, Object value) {
- if(value != null)
+ if (value != null) {
fPropertiesMap.put(name, value);
- else
+ } else {
fPropertiesMap.remove(name);
+ }
fIsModified = true;
}
@@ -654,41 +653,41 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
getStorageBase().removeStorage(id);
}
- void switchToCachedAppliedData(CProjectDescription appliedCache){
- if(fIsReadOnly)
+ void switchToCachedAppliedData(CProjectDescription appliedCache) {
+ if (fIsReadOnly)
return;
ICConfigurationDescription[] cfgs = appliedCache.getConfigurations();
- for(int i = 0; i < cfgs.length; i++){
- CConfigurationDescriptionCache cfgCache = (CConfigurationDescriptionCache)cfgs[i];
- CConfigurationDescription des = (CConfigurationDescription)getChildSettingById(cfgCache.getId());
- if(des != null){
+ for (int i = 0; i < cfgs.length; i++) {
+ CConfigurationDescriptionCache cfgCache = (CConfigurationDescriptionCache) cfgs[i];
+ CConfigurationDescription des = (CConfigurationDescription) getChildSettingById(cfgCache.getId());
+ if (des != null) {
des.setData(cfgCache);
// ICResourceDescription rcDes = des.getResourceDescription(new Path("dd"), false);
// rcDes = des.getResourceDescription(new Path("dd"), false);
// ICBuildSetting bs = des.getBuildSetting();
-// ICLanguageSetting lss[] = ((ICFolderDescription)rcDes).getLanguageSettings();
+// ICLanguageSetting lss[] = ((ICFolderDescription) rcDes).getLanguageSettings();
}
}
}
- boolean checkPersistActiveCfg(String oldId, boolean force){
+ boolean checkPersistActiveCfg(String oldId, boolean force) {
return fActiveCfgInfo.store(oldId, force);
}
- boolean checkPersistSettingCfg(String oldId, boolean force){
+ boolean checkPersistSettingCfg(String oldId, boolean force) {
return fSettingCfgInfo.store(oldId, force);
}
- boolean needsActiveCfgPersistence(){
+ boolean needsActiveCfgPersistence() {
return fActiveCfgInfo.fIsCfgModified;
}
- boolean needsSettingCfgPersistence(){
+ boolean needsSettingCfgPersistence() {
return fSettingCfgInfo.fIsCfgModified;
}
- CProjectDescriptionPreferences getPreferences(){
+ CProjectDescriptionPreferences getPreferences() {
return fPrefs;
}
@@ -719,10 +718,10 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
@Override
public void setCdtProjectCreated() {
- if(!fIsCreating)
+ if (!fIsCreating)
return;
- if(fIsReadOnly)
+ if (fIsReadOnly)
throw ExceptionFactory.createIsReadOnlyException();
fIsCreating = false;
@@ -730,11 +729,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
}
public void touch() throws WriteAccessException {
- if(fIsReadOnly)
+ if (fIsReadOnly)
throw ExceptionFactory.createIsReadOnlyException();
fIsModified = true;
}
-
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNodeSelector.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNodeSelector.java
index fea86d7c702..e418d73e41f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNodeSelector.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNodeSelector.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@@ -20,7 +20,6 @@ package org.eclipse.cdt.core.dom.ast;
* @since 5.0
*/
public interface IASTNodeSelector {
-
/**
* Returns the name for the exact given range, or <code>null</code> if there is no such node.
* Will not return an implicit name.
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IType.java
index e3f13bc2bfd..e661796ec86 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IType.java
@@ -22,7 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IType extends Cloneable {
- public static final IType[] EMPTY_TYPE_ARRAY = new IType[0];
+ public static final IType[] EMPTY_TYPE_ARRAY = {};
public static final ASTTypeMatcher TYPE_MATCHER = new ASTTypeMatcher();
public Object clone();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java
index 011381d1cb4..00f34adeb60 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ITypedef.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Doug Schaefer (IBM) - Initial API and implementation
+ * Doug Schaefer (IBM) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@@ -15,7 +15,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ITypedef extends IBinding, IType {
-
/**
* Returns the type that this thing is a typedef of
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPPointerToMemberType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPPointerToMemberType.java
index 9d53659ed25..aa13028531e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPPointerToMemberType.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPPointerToMemberType.java
@@ -19,9 +19,8 @@ import org.eclipse.cdt.core.dom.ast.IType;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPPointerToMemberType extends IPointerType {
-
/**
- * Get the class to whose members this points to.
+ * Returns the class to whose members this points to.
* @return Either ICPPClassType or ICPPTeplateTypeParameter.
*/
public IType getMemberOfClass();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java
index 8bdc3abcf97..70e5fe1dcbd 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ArithmeticConversion.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser;
@@ -85,7 +85,7 @@ public abstract class ArithmeticConversion {
private boolean isArithmeticOrUnscopedEnum(IType op1) {
if (op1 instanceof IBasicType) {
- final Kind kind = ((IBasicType)op1).getKind();
+ final Kind kind = ((IBasicType) op1).getKind();
switch (kind) {
case eUnspecified:
case eVoid:
@@ -190,7 +190,8 @@ public abstract class ArithmeticConversion {
return signedType;
}
- return createBasicType(signedType.getKind(), changeModifier(signedType.getModifiers(), IBasicType.IS_SIGNED, IBasicType.IS_UNSIGNED));
+ return createBasicType(signedType.getKind(),
+ changeModifier(signedType.getModifiers(), IBasicType.IS_SIGNED, IBasicType.IS_UNSIGNED));
}
private IBasicType promote(IType type, Domain domain) {
@@ -331,21 +332,21 @@ public abstract class ArithmeticConversion {
return false;
if (basicTarget.isShort()) {
- return n < (Short.MAX_VALUE + 1L)*2;
+ return n < (Short.MAX_VALUE + 1L) * 2;
}
// Can't represent long longs with java longs.
if (basicTarget.isLong() || basicTarget.isLongLong()) {
return true;
}
- return n < (Integer.MAX_VALUE + 1L)*2;
+ return n < (Integer.MAX_VALUE + 1L) * 2;
case eFloat:
float f= n;
- return (long)f == n;
+ return (long) f == n;
case eDouble:
double d= n;
- return (long)d == n;
+ return (long) d == n;
default:
return false;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java
index d433dcdb11d..d40707ddac7 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBinaryExpression.java
@@ -54,11 +54,7 @@ public class CASTBinaryExpression extends ASTNode
copy.op = op;
copy.setOperand1(operand1 == null ? null : operand1.copy(style));
copy.setOperand2(operand2 == null ? null : operand2.copy(style));
- copy.setOffsetAndLength(this);
- if (style == CopyStyle.withLocations) {
- copy.setCopyLocation(this);
- }
- return copy;
+ return copy(copy, style);
}
@Override
@@ -118,9 +114,9 @@ public class CASTBinaryExpression extends ASTNode
if (action.shouldVisitExpressions) {
switch (action.visit(this)) {
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
+ default: break;
}
}
@@ -147,7 +143,7 @@ public class CASTBinaryExpression extends ASTNode
public static boolean acceptWithoutRecursion(IASTBinaryExpression bexpr, ASTVisitor action) {
N stack= new N(bexpr);
- while(stack != null) {
+ while (stack != null) {
IASTBinaryExpression expr= stack.fExpression;
if (stack.fState == 0) {
if (action.shouldVisitExpressions) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java
index bed10b3ca86..6bd1a077232 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTUnaryExpression.java
@@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * John Camelon (IBM Rational Software) - Initial API and implementation
- * Yuan Zhang / Beth Tibbitts (IBM Research)
- * Markus Schorn (Wind River Systems)
+ * John Camelon (IBM Rational Software) - Initial API and implementation
+ * Yuan Zhang / Beth Tibbitts (IBM Research)
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@@ -29,7 +29,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression, IASTAmbiguityParent {
private int operator;
private IASTExpression operand;
-
public CASTUnaryExpression() {
}
@@ -46,13 +45,9 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
@Override
public CASTUnaryExpression copy(CopyStyle style) {
- CASTUnaryExpression copy = new CASTUnaryExpression(operator, operand == null ? null
- : operand.copy(style));
- copy.setOffsetAndLength(this);
- if (style == CopyStyle.withLocations) {
- copy.setCopyLocation(this);
- }
- return copy;
+ CASTUnaryExpression copy =
+ new CASTUnaryExpression(operator, operand == null ? null : operand.copy(style));
+ return copy(copy, style);
}
@Override
@@ -82,22 +77,22 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
}
@Override
- public boolean accept( ASTVisitor action ){
- if( action.shouldVisitExpressions ){
- switch( action.visit( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
+ public boolean accept(ASTVisitor action) {
+ if (action.shouldVisitExpressions) {
+ switch (action.visit(this)) {
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
+ default: break;
}
}
- if( operand != null ) if( !operand.accept( action ) ) return false;
+ if (operand != null && !operand.accept(action)) return false;
- if( action.shouldVisitExpressions ){
- switch( action.leave( this ) ){
- case ASTVisitor.PROCESS_ABORT : return false;
- case ASTVisitor.PROCESS_SKIP : return true;
- default : break;
+ if (action.shouldVisitExpressions) {
+ switch (action.leave(this)) {
+ case ASTVisitor.PROCESS_ABORT: return false;
+ case ASTVisitor.PROCESS_SKIP: return true;
+ default: break;
}
}
return true;
@@ -105,10 +100,9 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
@Override
public void replace(IASTNode child, IASTNode other) {
- if( child == operand )
- {
- other.setPropertyInParent( child.getPropertyInParent() );
- other.setParent( child.getParent() );
+ if (child == operand) {
+ other.setPropertyInParent(child.getPropertyInParent());
+ other.setParent(child.getParent());
operand = (IASTExpression) other;
}
}
@@ -121,7 +115,7 @@ public class CASTUnaryExpression extends ASTNode implements IASTUnaryExpression,
}
final IType exprType = getOperand().getExpressionType();
IType type = CVisitor.unwrapTypedefs(exprType);
- switch(op) {
+ switch (op) {
case op_star:
if (type instanceof IPointerType || type instanceof IArrayType) {
return ((ITypeContainer) type).getType();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArithmeticConversion.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArithmeticConversion.java
index f1749cd8b2a..58c15d59ff9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArithmeticConversion.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPArithmeticConversion.java
@@ -6,13 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.IBasicType;
-import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
+import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.internal.core.dom.parser.ArithmeticConversion;
public class CPPArithmeticConversion extends ArithmeticConversion {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java
index e81e3416b41..863b3dbd6c1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitTypedef.java
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Devin Steffler (IBM) - Initial API and implementation
- * Markus Schorn (Wind River Systems)
+ * Devin Steffler (IBM) - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -23,9 +23,9 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
* An example is the GCC built-in typedef: typedef char * __builtin_va_list;
*/
public class CPPImplicitTypedef extends CPPTypedef {
- private IType type=null;
- private char[] name=null;
- private IScope scope=null;
+ private IType type;
+ private char[] name;
+ private IScope scope;
public CPPImplicitTypedef(IType type, char[] name, IScope scope) {
super(null);
@@ -135,5 +135,4 @@ public class CPPImplicitTypedef extends CPPTypedef {
public boolean isGloballyQualified() {
return true;
}
-
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
index 50032369a36..e49137afdc1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPParameter.java
@@ -38,20 +38,20 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.core.runtime.PlatformObject;
/**
- * Binding for a c++ function parameter
+ * Binding for a c++ function parameter.
*/
public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPInternalBinding, ICPPTwoPhaseBinding {
+
public static class CPPParameterProblem extends ProblemBinding implements ICPPParameter {
public CPPParameterProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg);
}
}
- private IType fType = null;
- private IASTName[] fDeclarations = null;
+ private IType fType;
+ private IASTName[] fDeclarations;
private int fPosition;
-
-
+
public CPPParameter(IASTName name, int pos) {
this.fDeclarations = new IASTName[] { name };
fPosition= pos;
@@ -61,23 +61,17 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
this.fType = type;
fPosition= pos;
}
-
+
@Override
public boolean isParameterPack() {
return getType() instanceof ICPPParameterPackType;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDeclarations()
- */
@Override
public IASTNode[] getDeclarations() {
return fDeclarations;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPBinding#getDefinition()
- */
@Override
public IASTNode getDefinition() {
return null;
@@ -121,17 +115,12 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
}
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
- */
+
@Override
public String getName() {
return new String(getNameCharArray());
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
- */
@Override
public char[] getNameCharArray() {
IASTName name = getPrimaryDeclaration();
@@ -140,26 +129,17 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
return CharArrayUtils.EMPTY;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
- */
@Override
public IScope getScope() {
return CPPVisitor.getContainingScope(getPrimaryDeclaration());
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode()
- */
public IASTNode getPhysicalNode() {
if (fDeclarations != null)
return fDeclarations[0];
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
- */
@Override
public IType getType() {
if (fType == null && fDeclarations != null) {
@@ -175,75 +155,48 @@ public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPI
return fType;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic()
- */
@Override
public boolean isStatic() {
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedName()
- */
@Override
public String[] getQualifiedName() {
return new String[] { getName() };
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IBinding#getFullyQualifiedNameCharArray()
- */
@Override
public char[][] getQualifiedNameCharArray() {
return new char[][] { getNameCharArray() };
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
- */
@Override
public boolean isGloballyQualified() {
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
- */
@Override
public void addDefinition(IASTNode node) {
addDeclaration(node);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
- */
@Override
public boolean isExtern() {
- //7.1.1-5 extern can not be used in the declaration of a parameter
+ // 7.1.1-5 extern can not be used in the declaration of a parameter
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable#isMutable()
- */
@Override
public boolean isMutable() {
- //7.1.1-8 mutable can only apply to class members
+ // 7.1.1-8 mutable can only apply to class members
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
- */
@Override
public boolean isAuto() {
return hasStorageClass(IASTDeclSpecifier.sc_auto);
}
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
- */
@Override
public boolean isRegister() {
return hasStorageClass(IASTDeclSpecifier.sc_register);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java
index 6974a726823..01c64516bbc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTypedef.java
@@ -35,7 +35,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
private IType type;
public CPPTypedef(IASTName name) {
- // bug 223020 even though qualified names are not legal, we need to deal with them.
+ // Bug 223020 even though qualified names are not legal, we need to deal with them.
if (name != null && name.getParent() instanceof ICPPASTQualifiedName) {
name= (IASTName) name.getParent();
}
@@ -61,7 +61,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
if (o instanceof ITypedef) {
IType t = getType();
if (t != null)
- return t.isSameType(((ITypedef)o).getType());
+ return t.isSameType(((ITypedef) o).getType());
return false;
}
@@ -105,7 +105,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
try {
t = (IType) super.clone();
} catch (CloneNotSupportedException e) {
- //not going to happen
+ // Not going to happen
}
return t;
}
@@ -123,7 +123,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
@Override
public boolean isGloballyQualified() throws DOMException {
IScope scope = getScope();
- while(scope != null) {
+ while (scope != null) {
if (scope instanceof ICPPBlockScope)
return false;
scope = scope.getParent();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
index 7b13aa7ef33..edff05c939e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java
@@ -2017,7 +2017,8 @@ public class CPPVisitor extends ASTQueries {
return createAutoType(autoInitClause, declSpec, declarator);
}
- private static IType createAutoType(IASTInitializerClause initClause, IASTDeclSpecifier declSpec, IASTDeclarator declarator) {
+ private static IType createAutoType(IASTInitializerClause initClause, IASTDeclSpecifier declSpec,
+ IASTDeclarator declarator) {
// C++0x: 7.1.6.4
if (initClause == null || !autoTypeDeclSpecs.get().add(declSpec)) {
// Detected a self referring auto type, e.g.: auto x = x;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExpressionTypes.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExpressionTypes.java
index 70e059bea65..6f4565f3ee6 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExpressionTypes.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExpressionTypes.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Markus Schorn - initial API and implementation
+ * Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
@@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
-
/**
* Methods for computing the type of an expression
*/
@@ -41,7 +40,6 @@ public class ExpressionTypes {
return Conversions.lvalue_to_rvalue(type);
}
-
public static ValueCategory valueCategoryFromFunctionCall(ICPPFunction function) {
final ICPPFunctionType ft = function.getType();
return valueCategoryFromReturnType(ft.getReturnType());

Back to the top