@@ -1264,38 +1264,40 @@ int runDPCT(int argc, const char **argv) {
12641264 return MigrationErrorInconsistentFileInDatabase;
12651265 }
12661266
1267- if (RunResult && StopOnParseErr) {
1268- DumpOutputFile ();
1269- if (RunResult == 1 ) {
1270- if (DpctGlobalInfo::isQueryAPIMapping ()) {
1271- std::string Err = getDpctTermStr ();
1272- StringRef ErrStr = Err;
1273- // Avoid the "Visual Studio version" error on windows platform.
1274- if (ErrStr.find_first_of (" error" ) == ErrStr.find_last_of (" error" ) &&
1275- ErrStr.contains (
1276- " error -- unsupported Microsoft Visual Studio version" )) {
1277- continue ;
1278- }
1279- if (ErrStr.contains (" use of undeclared identifier" )) {
1280- ShowStatus (MigrationErrorAPIMappingWrongCUDAHeader,
1281- QueryAPIMapping);
1282- return MigrationErrorAPIMappingWrongCUDAHeader;
1283- } else if (ErrStr.contains (" file not found" )) {
1284- ShowStatus (MigrationErrorAPIMappingNoCUDAHeader, QueryAPIMapping);
1285- return MigrationErrorAPIMappingNoCUDAHeader;
1267+ do {
1268+ if (RunResult && StopOnParseErr) {
1269+ DumpOutputFile ();
1270+ if (RunResult == 1 ) {
1271+ if (DpctGlobalInfo::isQueryAPIMapping ()) {
1272+ std::string Err = getDpctTermStr ();
1273+ StringRef ErrStr = Err;
1274+ // Avoid the "Visual Studio version" error on windows platform.
1275+ if (ErrStr.find (" error:" ) == ErrStr.rfind (" error:" ) &&
1276+ ErrStr.contains (
1277+ " error -- unsupported Microsoft Visual Studio version" )) {
1278+ break ;
1279+ }
1280+ if (ErrStr.contains (" use of undeclared identifier" )) {
1281+ ShowStatus (MigrationErrorAPIMappingWrongCUDAHeader,
1282+ QueryAPIMapping);
1283+ return MigrationErrorAPIMappingWrongCUDAHeader;
1284+ } else if (ErrStr.contains (" file not found" )) {
1285+ ShowStatus (MigrationErrorAPIMappingNoCUDAHeader, QueryAPIMapping);
1286+ return MigrationErrorAPIMappingNoCUDAHeader;
1287+ }
1288+ ShowStatus (MigrationErrorNoAPIMapping);
1289+ dpctExit (MigrationErrorNoAPIMapping);
12861290 }
1287- ShowStatus (MigrationErrorNoAPIMapping);
1288- dpctExit (MigrationErrorNoAPIMapping);
1291+ ShowStatus (MigrationErrorFileParseError);
1292+ return MigrationErrorFileParseError;
1293+ } else {
1294+ // When RunResult equals to 2, it means no error, but some files are
1295+ // skipped due to missing compile commands.
1296+ // And clang::tooling::ReFactoryTool will emit error message.
1297+ return MigrationSKIPForMissingCompileCommand;
12891298 }
1290- ShowStatus (MigrationErrorFileParseError);
1291- return MigrationErrorFileParseError;
1292- } else {
1293- // When RunResult equals to 2, it means no error, but some files are
1294- // skipped due to missing compile commands.
1295- // And clang::tooling::ReFactoryTool will emit error message.
1296- return MigrationSKIPForMissingCompileCommand;
12971299 }
1298- }
1300+ } while ( 0 );
12991301
13001302 Action.runPasses ();
13011303 } while (DpctGlobalInfo::isNeedRunAgain ());
0 commit comments