suppress wxFileName::Normalize error messages - c++

I have the following c++ code that used to normalize user supplied file path:
wxString orig_path;
wxFileName res_path(orig_path);
res_path.Normalize(wxPATH_NORM_DOTS);
Refs:
wxFileName::Normalize
wxFileName::Normalize flags
When:
orig_path = "../../dir1/f.csv"
I get annoying error messages:
Error: The path 'f.csv' contains too many ".."!
When:
orig_path = "dir1/../dir2/f.csv"
everything works as expected.
Question
Any way I can suppress those error messages? (silent flag?).
I guess I can do some processing myself before calling Normailze but what's the point? I prefer not to do anything or know anything about orig_path before calling Normailze

Use wxLogNull. All calls to the log functions during the life time of an object of this class are just ignored.
See documentation.
wxLogNull noLogsPlease;
wxString orig_path;
wxFileName res_path(orig_path);
res_path.Normalize(wxPATH_NORM_DOTS);

Related

Visual Studio 2017: Ruleset won't execute

I want to define a custom set of rules to be checked at compile time. But it seems not to work.
Example:
I choose one rule directly and I'll get the expected warning.
But when I instead create a custom ruleset containing the exact same rule then I won't get the expected warning.
What could be wrong?
Edit:
void f(std::string& i) {
std::string s = i;
cout << s;
}
int main()
{
std::string s ("abc");
f(s);
}
This gives me the expected warning Warnung C26460 The reference argument 'i' for function 'f' can be marked as const (con.3). in the first case.
Even if I create a custom ruleset including all available rules, I won't get any warnings.
Here you see me selecting the custom ruleset:
Edit: The ruleset action must change one time to enable it.
When I create a new ruleset containing only the const-checks then I will get a .ruleset that does not work and look like this:
In the ruleset editor it looks like this:
When I then change its action from Warning to Error:
Then the .ruleset gets additional lines for each test case:
When I change the action back to warning it looks like this:
Now it is working as expected.
I've been able to reproduce your error with Visual Studio 2017. I don't know exactly what I changed (or if I changed anything at all), but I am able to see the code analysis warning you expect with a custom rule set.
Things I would try:
Double check the Error List window is visible and not hiding somewhere.
Open the rule set file, change the Action to Error and then back to Warning and save it. I wouldn't expect this to be the problem but it's one of the things I did and after which I started seeing the Error List window.

llvm irbuilder call instruction throwing exception on function inlining pass

I'm new to LLVM. I am using the clang c++ API to compile multiple stub files (in c) to IR, and then stick them together using IR builder (after linking them) to eventually run via JIT.
All this works great, unless I add a functionInlining pass to my optimizations, at which point one of these function calls made in IR builder will trigger the following exception when the pass manager is run:
Assertion failed: (New->getType() == getType() && "replaceAllUses of value with new value of different type!"), function replaceAllUsesWith, file /Users/mike/Development/llvm/llvm/lib/IR/Value.cpp, line 356.
This is how I make the call instruction (pretty straight forward):
Function *kernelFunc = mModule->getFunction( (kernel->Name() + StringRef("_") + StringRef(funcName)).str());
if (kernelFunc){
CallInst* newInst = builder.CreateCall(kernelFunc, args);
}
Later the module is optimized:
legacy::PassManager passMan;
PassManagerBuilder Builder;
Builder.OptLevel = 3;
//Builder.Inliner = llvm::createFunctionInliningPass(); //commenting this back in trigger the exception
Builder.populateModulePassManager(passMan);
passMan.run( *mModule ); //exception occurs before this call returns
Any ideas what to look for?
Try running llvm::verifyModule on your module to see if it's correct. You might have an error and have been getting lucky beforehand but it tripped something up in the inliner.
In general assertions check a subset of things that can be wrong with your module but verify checks a lot more.
It could be a bug in LLVM but more than likely it's a bad module, it's easy to happen.
So I finally setup my dev environment so I could inspect the assertion call in the debugger. I turns out the basic block being replaced had a different context set than the one it was being replaced with. going back and making sure IRBuilder was using the same context as the IR parsers solved the problem.

Nodejs C++ event emitter. add-on error. Non-function in MakeCallback. method = emit Abort trap: 6

I'm creating a C++ level event emitter addon for node.js. I'm getting this C++ error when including the add-on in a node.js project.
Non-function in MakeCallback. method = emit Abort trap: 6
I found this Gist with a simplified example of the same behavior:
https://gist.github.com/jedi4ever/4250746
Hoping for some general insight into why this might be caused or what this error means.
If I understand what you're trying to do correctly, you have a couple of problems in your keylogger.js file;
util.inherits(new keylogger, events.EventEmitter);
exports = keylogger;
You're trying to extend an instance, and your export statement is a bit off. This should work better to export keylogger as an instance which the test file seems to expect;
util.inherits(keylogger, events.EventEmitter);
exports.keylogger = new keylogger();

Xerces: How to check the validity of an XML file using ErrorHandler

I am trying to determine if a given XML file is valid (has proper syntax and structure), and I am using Xerces. I have been able to succesfully read proper files but when I give it files with incorrect syntax, no errors are thrown.
I have been fishing around and found out that I might have to use an Error handler and user setErrorHandler to catch the errors instead of the traditional try-throw-catch exception handling.
The problem that I am having though is that I am very confused how to declare the proper handler, set it to my parser and then read the errors if there are any that show up.
Is there any chance somebody could shed some light on my situation?
// #input_parameter from function: const string & xmlConfigArg
xercesc::DOMDocument* doc = NULL;
string xmlConfig(xmlConfigArg);
Handler handler; // I'm not sure what type of handler to use
_parser->setErrorHandler(&handler);
try{
_parser->parse(xmlConfigArg.c_str());
doc = _parser-> getDocument();
}catch(...){
//Nothing is ever caught here
}
You need to derive a class from ErrorHandler (< xercesc/sax/ErrorHandler.hpp >)
then overwrite all the virtual methods there.
After doing so, You can get the error code from the class you created. No exceptions will be thrown in the parsing, so you can wave the try/cache block (or keep it for a different use).

Getting the error message from v8::Script::Compile()

I'm calling Script::Compile() and it returns me an empty handle as result. I've traced into this method and finally found that
i::Handle<i::SharedFunctionInfo> result = i::Compiler::Compile(str, ....
is returning the empty handle. That means compilation error.
But does anyone know is there a way to get error message from compuler in this case to get know where error has occured?
Take a look at the ReportException function in the Shell example. You need to use a v8::TryCatch to capture the exception and report on the error.