From: John Kessenich Date: Wed, 16 Jan 2019 09:07:51 +0000 (+0700) Subject: HLSL: Fix #1655; use "" for nullptr file names. Needs test cases. X-Git-Tag: upstream/11.4.0~565^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b2395e9ddf443b4449ae1ca86fc48e24de3470ba;p=platform%2Fupstream%2Fglslang.git HLSL: Fix #1655; use "" for nullptr file names. Needs test cases. --- diff --git a/glslang/Include/Common.h b/glslang/Include/Common.h index b136dde..98e5a1a 100644 --- a/glslang/Include/Common.h +++ b/glslang/Include/Common.h @@ -250,7 +250,8 @@ struct TSourceLoc { return nullptr; return name->c_str(); } - TString* name; // descriptive name for this string + const char* getFilenameStr() const { return name == nullptr ? "" : name->c_str(); } + TString* name; // descriptive name for this string, when a textual name is available, otherwise nullptr int string; int line; int column; diff --git a/glslang/MachineIndependent/preprocessor/PpContext.h b/glslang/MachineIndependent/preprocessor/PpContext.h old mode 100755 new mode 100644 index 7b8b22e..73fe5e3 --- a/glslang/MachineIndependent/preprocessor/PpContext.h +++ b/glslang/MachineIndependent/preprocessor/PpContext.h @@ -549,9 +549,9 @@ protected: scanner.setLine(startLoc.line); scanner.setString(startLoc.string); - scanner.setFile(startLoc.name->c_str(), 0); - scanner.setFile(startLoc.name->c_str(), 1); - scanner.setFile(startLoc.name->c_str(), 2); + scanner.setFile(startLoc.getFilenameStr(), 0); + scanner.setFile(startLoc.getFilenameStr(), 1); + scanner.setFile(startLoc.getFilenameStr(), 2); } // tInput methods: diff --git a/hlsl/hlslParseHelper.cpp b/hlsl/hlslParseHelper.cpp old mode 100755 new mode 100644 index d6dc2e8..72edbd7 --- a/hlsl/hlslParseHelper.cpp +++ b/hlsl/hlslParseHelper.cpp @@ -133,7 +133,7 @@ bool HlslParseContext::parseShaderStrings(TPpContext& ppContext, TInputScanner& // Print a message formated such that if you click on the message it will take you right to // the line through most UIs. const glslang::TSourceLoc& sourceLoc = input.getSourceLoc(); - infoSink.info << sourceLoc.name->c_str() << "(" << sourceLoc.line << "): error at column " << sourceLoc.column + infoSink.info << sourceLoc.getFilenameStr() << "(" << sourceLoc.line << "): error at column " << sourceLoc.column << ", HLSL parsing failed.\n"; ++numErrors; return false;