예제 #1
0
 // This also parses super expressions when they appear in the statement position.
 Stmt* Parser::superStatement()
 {
     eat (T_Super);
     uint32_t pos = position();
     Seq<Expr*>* arguments = NULL;
     bool argsPresent = false;
     if (hd() == T_LeftParen) {
         argsPresent = true;
         arguments = argumentList();
     }
     // FIXME: We want to abstract "check for property operator" here.
     if (argsPresent && hd() != T_Dot && hd() != T_DoubleDot && hd() != T_LeftDotAngle && hd() != T_LeftBracket) {
         setUsesSuper();
         return ALLOC(SuperStmt, (pos, arguments));
     }
     if (argsPresent && (arguments == NULL || arguments->tl != NULL))
         compiler->syntaxError(pos, SYNTAXERR_ONE_ARGUMENT_REQUIRED);
     Expr* obj = argsPresent ? arguments->hd : ALLOC(ThisExpr, ());
     return ALLOC(ExprStmt, (pos, propertyOperator(ALLOC(SuperExpr, (obj)))));
 }
예제 #2
0
    foreach (const TestConfiguration *testConfiguration, selectedTests) {
        QScopedPointer<TestOutputReader> outputReader;
        switch (testConfiguration->testType()) {
        case TestTypeQt:
            outputReader.reset(new QtTestOutputReader(futureInterface, &testProcess,
                                                      testConfiguration->buildDirectory()));
            break;
        case TestTypeGTest:
            outputReader.reset(new GTestOutputReader(futureInterface, &testProcess,
                                                     testConfiguration->buildDirectory()));
            break;
        }
        if (futureInterface.isCanceled())
            break;

        if (!testConfiguration->project())
            continue;

        QProcessEnvironment environment = testConfiguration->environment().toProcessEnvironment();
        QString commandFilePath = executableFilePath(testConfiguration->targetFile(), environment);
        if (commandFilePath.isEmpty()) {
            futureInterface.reportResult(TestResultPtr(new FaultyTestResult(Result::MessageFatal,
                QObject::tr("Could not find command \"%1\". (%2)")
                                                   .arg(testConfiguration->targetFile())
                                                   .arg(testConfiguration->displayName()))));
            continue;
        }

        if (testConfiguration->testType() == TestTypeQt) {
            QStringList argumentList(QLatin1String("-xml"));
            if (!metricsOption.isEmpty())
                argumentList << metricsOption;
            if (testConfiguration->testCases().count())
                argumentList << testConfiguration->testCases();
            testProcess.setArguments(argumentList);
        } else { // TestTypeGTest
            QStringList argumentList;
            const QStringList &testSets = testConfiguration->testCases();
            if (testSets.size()) {
                argumentList << QLatin1String("--gtest_filter=")
                                + testSets.join(QLatin1Char(':'));
            }
            if (settings.gtestRunDisabled)
                argumentList << QLatin1String("--gtest_also_run_disabled_tests");
            if (settings.gtestRepeat)
                argumentList << QString::fromLatin1("--gtest_repeat=%1").arg(settings.gtestIterations);
            if (settings.gtestShuffle) {
                argumentList << QLatin1String("--gtest_shuffle");
                argumentList << QString::fromLatin1("--gtest_random_seed=%1").arg(settings.gtestSeed);
            }
            testProcess.setArguments(argumentList);
        }

        testProcess.setWorkingDirectory(testConfiguration->workingDirectory());
        if (Utils::HostOsInfo::isWindowsHost())
            environment.insert(QLatin1String("QT_LOGGING_TO_CONSOLE"), QLatin1String("1"));
        testProcess.setProcessEnvironment(environment);
        testProcess.setProgram(commandFilePath);
        testProcess.start();

        bool ok = testProcess.waitForStarted();
        QTime executionTimer;
        executionTimer.start();
        bool canceledByTimeout = false;
        if (ok) {
            while (testProcess.state() == QProcess::Running) {
                if (executionTimer.elapsed() >= timeout) {
                    canceledByTimeout = true;
                    break;
                }
                if (futureInterface.isCanceled()) {
                    testProcess.kill();
                    testProcess.waitForFinished();
                    return;
                }
                eventLoop.processEvents();
            }
        }

        if (canceledByTimeout) {
            if (testProcess.state() != QProcess::NotRunning) {
                testProcess.kill();
                testProcess.waitForFinished();
            }
            futureInterface.reportResult(TestResultPtr(
                    new FaultyTestResult(Result::MessageFatal, QObject::tr(
                    "Test case canceled due to timeout. \nMaybe raise the timeout?"))));
        }
    }
예제 #3
0
QByteArray DwarfDie::typeName() const
{
    const auto n = name();
    if (!n.isEmpty())
        return n;

    const auto typeDie = attribute(DW_AT_type).value<DwarfDie*>();
    QByteArray typeName;
    if (!typeDie) {
        switch (tag()) {
            case DW_TAG_class_type:
                return "<anon class>";
            case DW_TAG_enumeration_type:
                return "<anon enum>";
            case DW_TAG_structure_type:
                return "<anon struct>";
            case DW_TAG_union_type:
                return "<anon union>";
            case DW_TAG_namespace:
                return "(anonymous namespace)";
            case DW_TAG_array_type:
            case DW_TAG_base_type:
            case DW_TAG_const_type:
            case DW_TAG_pointer_type:
            case DW_TAG_ptr_to_member_type:
            case DW_TAG_reference_type:
            case DW_TAG_restrict_type:
            case DW_TAG_rvalue_reference_type:
            case DW_TAG_subroutine_type:
            case DW_TAG_typedef:
                typeName = "void";
                break;
            default:
                return {};
        }
    } else {
        typeName = typeDie->typeName();
    }

    // TODO: function pointers and pointer to members
    switch (tag()) {
        case DW_TAG_pointer_type:
            return typeName + '*';
        case DW_TAG_reference_type:
            return typeName + '&';
        case DW_TAG_rvalue_reference_type:
            return typeName + "&&";
        case DW_TAG_const_type:
            return typeName + " const";
        case DW_TAG_array_type:
        {
            const auto dims = arrayDimensions(this);
            QByteArray n = typeName;
            for (int d : dims)
                n += '[' + QByteArray::number(d) + ']';
            return n;
        }
        case DW_TAG_restrict_type:
            return typeName + " restrcit";
        case DW_TAG_volatile_type:
            return typeName + " volatile";
        case DW_TAG_subroutine_type:
            return typeName + " (*)(" + argumentList(this).join(", ") + ')';
        case DW_TAG_ptr_to_member_type:
        {
            const auto classDie = attribute(DW_AT_containing_type).value<DwarfDie*>();
            QByteArray className;
            if (classDie)
                className = classDie->typeName();
            return typeName + " (" + className + "::*)(" + argumentList(this).join(", ") + ')';
        }
    }
    return typeName;
}
예제 #4
0
/**
Function to parse the command line options.
Responsible to
1. Parse the input values.
2. Print the usage note. 
3. Identify the valdations to be carried out.
4. Type of report needs to be generated.

@internalComponent
@released

@param aArgc - argument count
@param aArgv[] - argument values
*/
ReturnType CmdLineHandler::ProcessCommandLine(unsigned int aArgc, char* aArgv[])
{
	if(aArgc < 2)
	{
		std::cout << PrintVersion().c_str() << std::endl;
		std::cout << PrintUsage().c_str() << std::endl;
		return EQuit;
	}
	ArgumentList argumentList(&aArgv[0], aArgv + aArgc);
	int argCount = argumentList.size();

	 iInputCommand = KToolName;

	for( int i = 1; i < argCount; i++ ) //Skip tool name
	{
		String name = argumentList.at(i);
		iInputCommand += " ";
		iInputCommand += name;
		int longOptionFlag = 0;
		if(IsOption(name, longOptionFlag))
		{
			String optionName;
			bool optionValue = false;
			StringList optionValueList;
			ParseOption(name, optionName, optionValueList, optionValue);
			char shortOption = KNull;
			if(Validate(ReaderUtil::ToLower(optionName), optionValue, optionValueList.size()))
			{
				if(longOptionFlag)
				{
					shortOption = optionName.at(2);
				}
				else
				{
					shortOption = optionName.at(1);
				}
			}

			switch(shortOption)
			{
				case 'q':
					iCommmandFlag |= QuietMode;
					break;
				case 'a':
					iCommmandFlag |= KAll;
					break;
				case 'x':
					iCommmandFlag |= KXmlReport;
					break;
				case 'o':
					iXmlFileName.assign(optionValueList.front());
					NormaliseName();
					break;
				case 's':
					if((optionName == KShortSuppressOption) || (optionName == KLongSuppressOption))
					{
						String value;
						while(optionValueList.size() > 0)
						{
							value = optionValueList.front();
							if(iSuppressVal[value])
							{
								if(iValidations > 0) //Is any check enabled?
								{
									if(iValidations & iSuppressVal[value])
									{
										iValidations ^= iSuppressVal[value]; //Consider only 3 LSB's
									}
								}
								else //Is this valid value?
								{
									iSuppressions |= iSuppressVal[value];
								}
							}
							else
							{
								throw ExceptionReporter(UNKNOWNSUPPRESSVAL,(char*)(optionValueList.front().c_str()));
							}
							optionValueList.pop_front();
						}
					}
					else if(optionName == KLongEnableSidCheck)
					{
						iValidations |= KMarkEnable;
						iValidations |= ESid;
					}
					else if(optionName == KLongSidAllOption)
					{
						iCommmandFlag |= KSidAll;
					}
					break;
				case 'd':
					if(optionName == KLongEnableDbgFlagCheck)
					{
						iValidations |= KMarkEnable;
						iValidations |= EDbg;
						if(optionValueList.size() > 0)
						{
							if(optionValueList.front() == String("true"))
							{
								iDebuggableFlagVal = true;
							}
							else if (optionValueList.front() == String("false"))
							{
								iDebuggableFlagVal = false; 
							}
							else
							{
								throw ExceptionReporter(UNKNOWNDBGVALUE);
							}
						}
					}
					else if (optionName == KLongEnableDepCheck)
					{
						iValidations |= KMarkEnable;
						iValidations |= EDep;
					}
					break;

				case 'e':
					if (optionName == KLongE32InputOption)
					{
						iCommmandFlag |= KE32Input;
					}
					break;

				case 'v':
					if(optionName == KLongVidValOption)
					{
						StringListToUnIntList(optionValueList, iVidValList);
					}
					else if(optionName == KLongEnableVidCheck)
					{
						iValidations |= KMarkEnable;
						iValidations |= EVid;
					}
					else
					{
						iCommmandFlag |= KVerbose;
						/**Initialize ExceptionImplementation class with verbose mode flag
						to print all status information to standard output*/
						ExceptionImplementation::Instance(iCommmandFlag);
					}
					break;
				case 'n':
						iCommmandFlag |= KNoCheck;
					break;
				case 'h':
					std::cout << PrintVersion().c_str() << std::endl;
					std::cout << PrintUsage().c_str() << std::endl;
					return EQuit; //Don't proceed further
			}
		}
		else
		{
			if(!AlreadyReceived(name))
			{
				iImageNameList.push_back(name);
			}
			else
			{
				ExceptionReporter(IMAGENAMEALREADYRECEIVED, (char*)name.c_str()).Report();
			}

			iNoImage = false;
		}
	} //While loop ends here
	if((iCommmandFlag || iValidations || iSuppressions) && iNoImage)
	{
		PrintVersion();
		PrintUsage();
	}
	//Always log the version information into log file
	ExceptionImplementation::Instance(iCommmandFlag)->Log(iVersion);
	ValidateArguments();
	ValidateE32NoCheckArguments();
	if(iCommmandFlag & KE32Input)
	{
		ValidateImageNameList();
	}
	return ESuccess;
}