chore(developer): changes in UnrechableRules::VerifyUnreachableRules() to run test_6440_unreachable_code..kmn

This commit is contained in:
Sabine 2023-02-03 13:27:51 +01:00
parent dcd8ef8526
commit 76d3534871
5 changed files with 28 additions and 9 deletions

View file

@ -81,8 +81,8 @@ KMX_DWORD CheckFilenameConsistency(KMX_WCHAR const * Filename, bool ReportMissin
}
#if defined(_WIN32) || defined(_WIN64)
// convert char16_t to wchar_t*
// char16_t -> std::u16string
// convert char16_t* -> std::u16string -> std::string -> std::wstring -> wchar_t*
// char16_t* -> std::u16string
std::u16string u16str(Name);
// std::u16string -> std::string
std::string stri = string_from_u16string(u16str);

View file

@ -110,7 +110,8 @@ const struct CompilerError CompilerErrors[] = {
{ CERR_DuplicateGroup , "A group with this name has already been defined."},
{ CERR_DuplicateStore , "A store with this name has already been defined."},
{ CERR_RepeatedBegin , "Begin has already been set"},
{ CHINT_FilenameHasDifferingCase , "HINT: Casing differences may fail on some platforms."},
{ CHINT_FilenameHasDifferingCase , "Casing differences may fail on some platforms."},
{ CHINT_UnreachableRule , "This rule will never be matched as another rule takes precedence"},
{ 0, nullptr }
};

View file

@ -66,12 +66,12 @@
*/
#include "pch.h"
#include <compfile.h>
#include "compfile.h"
#include <comperr.h>
#include "../../../../common/windows/cpp/include/vkeys.h"
#include <cuchar>
#include <versioning.h>
#include <kmcmpdll.h>
#include "kmcmpdll.h"
#include <DeprecationChecks.h>
#include "virtualcharkeys.h"

View file

@ -1,10 +1,10 @@
#include "pch.h"
#include <compfile.h>
#include "compfile.h"
#include <comperr.h>
#include "../../../../common/windows/cpp/include/vkeys.h"
#include <kmcmpdll.h>
#include "kmcmpdll.h"
#include <unordered_map>
#include <unordered_set>
@ -12,7 +12,25 @@
#include <sstream>
#include "UnreachableRules.h"
namespace kmcmp {
WCHAR conv_KMX_WCHAR__TO__WCHAR(KMX_WCHAR in) {
// char16_t -> std::u16string -> std::string -> std::wstring -> wchar_t*
std::u16string u16str(&in);
std::string stri = string_from_u16string(u16str);
std::wstring wstr = wstring_from_string(stri);
return *wstring_from_string(stri).c_str();
}
std::wstring MakeHashKeyFromFileKey16(PFILE_KEY kp) {
std::wstringstream key16;
const WCHAR* ctxt = u16fmt((PKMX_WCHAR) kp->dpContext).c_str();
key16 << conv_KMX_WCHAR__TO__WCHAR(kp->Key) << "," << (DWORD) kp->ShiftFlags << ",";
if (ctxt) key16 << ctxt;
return key16.str();
};
std::wstring MakeHashKeyFromFileKey(PFILE_KEY kp) {
std::wstringstream key;
key << kp->Key << "," << kp->ShiftFlags << ",";
@ -31,7 +49,7 @@ KMX_DWORD VerifyUnreachableRules(PFILE_GROUP gp) {
std::unordered_set<int> reportedLines;
for (i = 0; i < gp->cxKeyArray; i++, kp++) {
std::wstring key = kmcmp::MakeHashKeyFromFileKey(kp);
std::wstring key = kmcmp::MakeHashKeyFromFileKey16(kp);
if (map.count(key) > 0) {
FILE_KEY const & k1 = map.at(key);
if (kp->Line != k1.Line && reportedLines.count(kp->Line) == 0) {

View file

@ -1,6 +1,6 @@
#pragma once
#include <compfile.h>
#include "compfile.h"
namespace kmcmp {
KMX_BOOL AddCompileWarning(LPSTR buf);