-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[READY] Translate libclang error codes to exceptions #861
Conversation
Thanks for the PR! Review status: 0 of 7 files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
a823557
to
9fd92f3
Compare
Codecov Report
@@ Coverage Diff @@
## master #861 +/- ##
==========================================
+ Coverage 96.2% 96.29% +0.09%
==========================================
Files 83 84 +1
Lines 6500 6506 +6
==========================================
+ Hits 6253 6265 +12
+ Misses 247 241 -6 |
Reviewed 5 of 7 files at r1, 3 of 3 files at r2. cpp/ycm/ClangCompleter/ClangCompleter.cpp, line 86 at r2 (raw file):
We don't need this check and the others below anymore since the cpp/ycm/ClangCompleter/ClangCompleter.cpp, line 100 at r2 (raw file):
Cannot be reached. cpp/ycm/tests/ClangCompleter/ClangCompleter_test.cpp, line 259 at r2 (raw file):
These tests are obsolete; they all raise the same Comments from Reviewable |
Review status: all files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. cpp/ycm/exceptions.h, line 0 at r2 (raw file):
I think we can easily predict that the errors are due to parsing the code, because that's what the API tells us. The CPP Core Guidelines say explicitly not to do this, so I think we should derive a new exception type. cpp/ycm/ClangCompleter/ClangCompleter.cpp, line 87 at r2 (raw file):
should probably catch by const reference cpp/ycm/ClangCompleter/ClangUtils.cpp, line 46 at r2 (raw file): According to the docs:
This means the line
OTOH a
I realise this is pedantic bikeshedding. So feel free to ignore. cpp/ycm/ClangCompleter/ClangUtils.cpp, line 60 at r2 (raw file):
Is this reachable? I tend to prefer to not have a More bikeshedding. Comments from Reviewable |
Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed. cpp/ycm/ClangCompleter/ClangUtils.cpp, line 46 at r2 (raw file): Previously, puremourning (Ben Jackson) wrote…
FWIW https://godbolt.org/g/vku1G3 Comments from Reviewable |
9fd92f3
to
f3d56b6
Compare
Reviewed 7 of 7 files at r1, 1 of 3 files at r2, 5 of 8 files at r3. cpp/ycm/ClangCompleter/ClangUtils.cpp, line 60 at r2 (raw file): Previously, puremourning (Ben Jackson) wrote…
Not having a Comments from Reviewable |
61e8873
to
45b8438
Compare
Reviewed 7 of 8 files at r3, 2 of 2 files at r4, 4 of 4 files at r5. cpp/ycm/exceptions.h, line at r2 (raw file): Previously, puremourning (Ben Jackson) wrote…
Reasons were:
I updated the PR to use a custom exception. In addition to translate cpp/ycm/ClangCompleter/ClangCompleter.cpp, line 87 at r2 (raw file): Previously, puremourning (Ben Jackson) wrote…
Done. cpp/ycm/ClangCompleter/ClangUtils.cpp, line 46 at r2 (raw file): Previously, puremourning (Ben Jackson) wrote…That's convincing. Done. cpp/ycm/ClangCompleter/ClangUtils.cpp, line 60 at r2 (raw file): Previously, bstaletic (Boris Staletic) wrote…
The code won't compile in debug mode if there is a missing
Comments from Reviewable |
Review status: all files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. cpp/ycm/ycm_core.cpp, line 58 at r5 (raw file):
I'm kinda unsure what this is doing and why. I'm not super familiar with the python binding stuff here, but it seems to be injecting an exception object into a scope? Sorry, can't brain today and struggling to get it! If our exception inherits from cpp/ycm/ycm_core.cpp, line 62 at r5 (raw file):
on the surface, this looks pretty evil. Why the need for the I'm expecting that I cpp/ycm/ycm_core.cpp, line 70 at r5 (raw file):
This global with no storage class is irksome. Do we really need global variable here? Should it at least be in this file's unnamed namespace? That would at least give it TU scope, rather than global. I must confess, I'm a little perplexed why cpp/ycm/ClangCompleter/ClangUtils.h, line 46 at r5 (raw file):
woah. virtual inheritance... that's unusual. This is like an interview question in a code review ! Fortunately, unless i'm very much mistaken, this is all single-inheritance, and there is no dreaded diamond, so we don't actually need to virtually inherit here. Pretty sure
And then none of us has to explain how RTTI works and the stable layout for a CatDog which is a Cat and is a Dog and both Cat and Dog are Animals and we can pretend that we just know, and it will all be fine. cpp/ycm/ClangCompleter/TranslationUnit.cpp, line 105 at r5 (raw file):
I actually prefer to use the explicit check on cpp/ycm/ClangCompleter/TranslationUnit.cpp, line 372 at r5 (raw file):
I'd prefer to compare with a value in the enum. Comments from Reviewable |
70450d9
to
ed3b504
Compare
Reviewed 4 of 4 files at r6. cpp/ycm/ycm_core.cpp, line 58 at r5 (raw file):
By default, Boost.Python translates all C++ exceptions to try {
...
} except ycm_core.ClangParseError {
...
} cpp/ycm/ycm_core.cpp, line 62 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
The signature of cpp/ycm/ycm_core.cpp, line 70 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
Now a private member of cpp/ycm/ClangCompleter/ClangUtils.h, line 46 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
That's what happens when you copy paste code without understanding it. Thanks for the link. Given that a cpp/ycm/ClangCompleter/TranslationUnit.cpp, line 105 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
At least, I learned it was working this way. Done. cpp/ycm/ClangCompleter/TranslationUnit.cpp, line 372 at r5 (raw file): Previously, puremourning (Ben Jackson) wrote…
Done. Comments from Reviewable |
To be frank, I'm not a fan of using python's C API directly. Yet it looks like we don't have too much choice if we want to keep using exceptions like we alwas had. So, after having explained what @puremourning asked about the C API, this is . Reviewed 1 of 2 files at r4, 3 of 4 files at r5, 4 of 4 files at r6. Comments from Reviewable |
Review status: all files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. cpp/ycm/PythonSupport.h, line 65 at r6 (raw file):
OK so I read up on the python API and boost python as best I could to understand this. What I was trying to work out was this: we create this I came to the conclusion that I was not sure whether or not we need to decrement the reference count for the the exception object in the destructor of this class. It's frustratingly difficult to be sure. I was leaning towards thinking that perhaps the member object should be a I honestly don't know if that's likely/possible, but this line seems odd in that it allocates and immediately deallocates a smart pointer object wrapping Sorry that's waffly, but I'm really not that familiar with this API and the docs are categorically abysmal. cpp/ycm/ycm_core.cpp, line 58 at r5 (raw file): Previously, micbou wrote…
Got it, thanks! P.S. Tee hee. The example syntax in your comment is like the scary lovechild of c++ and python! cpp/ycm/ycm_core.cpp, line 55 at r6 (raw file):
cpp/ycm/ClangCompleter/ClangUtils.cpp, line 55 at r6 (raw file):
This message doesn't seem to make sense in isolation. Perhaps it should say "Invalid compiler flags supplied for the translation unit." ? Comments from Reviewable |
Review status: all files reviewed at latest revision, 8 unresolved discussions, some commit checks failed. cpp/ycm/PythonSupport.h, line 76 at r6 (raw file):
initialise to nullptr?
Shrug. Comments from Reviewable |
Review status: all files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. cpp/ycm/PythonSupport.h, line 65 at r6 (raw file): Previously, puremourning (Ben Jackson) wrote…
No I think i'm talking rubbish. cpp/ycm/ycm_core.cpp, line 98 at r6 (raw file):
This call instantiates the class Comments from Reviewable |
☔ The latest upstream changes (presumably #900) made this pull request unmergeable. Please resolve the merge conflicts. |
18606e8
to
c108a32
Compare
☔ The latest upstream changes (presumably #909) made this pull request unmergeable. Please resolve the merge conflicts. |
c108a32
to
2f0156b
Compare
Reviewed 2 of 2 files at r10, 1 of 1 files at r11, 3 of 3 files at r12. cpp/ycm/PythonSupport.h, line 60 at r9 (raw file): Previously, bstaletic (Boris Staletic) wrote…
I removed the call to Comments from Reviewable |
Reviewed 1 of 2 files at r9, 2 of 2 files at r10, 1 of 1 files at r11, 3 of 3 files at r12. cpp/ycm/PythonSupport.h, line 60 at r9 (raw file): Previously, micbou wrote…
Since @puremourning recently confirmed this is working, this does get a green light from me. Comments from Reviewable |
f51b8b4
to
9c92f26
Compare
311974c
to
4eacc49
Compare
Do not silence the exceptions.
4eacc49
to
7033503
Compare
Improved coverage and added comments in the tests explaining why libclang fails to parse (or reparse) the translation unit. Reviewed 6 of 6 files at r13, 3 of 3 files at r14. Comments from Reviewable |
I believe we can merge this now. Reviewed 4 of 6 files at r13, 3 of 3 files at r14. Comments from Reviewable |
Thanks. I did confirm this works well @zzbot r+ Reviewed 1 of 7 files at r1, 1 of 8 files at r3, 1 of 4 files at r6, 1 of 2 files at r9, 1 of 1 files at r11, 3 of 3 files at r12, 3 of 6 files at r13, 3 of 3 files at r14. cpp/ycm/ycm_core.cpp, line 98 at r6 (raw file): Previously, micbou wrote…
ok Comments from Reviewable |
📌 Commit 7033503 has been approved by |
[READY] Translate libclang error codes to exceptions This PR translates [libclang error codes](https://clang.llvm.org/doxygen/CXErrorCode_8h.html#adba17f287f8184fc266f2db4e669bf0f) returned by the `clang_parseTranslationUnit2FullArgv` and `clang_reparseTranslationUnit` functions to `std::runtime_error` exceptions with the corresponding error message; replacing the `ClangParseError` exception. Unlike `ClangParseError`, we don't silence them as they can help understand why the Clang completer is not working. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/861) <!-- Reviewable:end -->
💔 Test failed - status-appveyor |
☀️ Test successful - status-appveyor, status-travis |
[READY] Update ycmd Include the following changes: - PR ycm-core/ycmd#789: add support for Windows flags when --driver-mode=cl is given; - PR ycm-core/ycmd#848: hide C++ symbols by default; - PR ycm-core/ycmd#857: add Java support using jdt.ls; - PR ycm-core/ycmd#861: translate libclang error codes to exceptions; - PR ycm-core/ycmd#880: support downloading Clang binaries on ARM systems; - PR ycm-core/ycmd#883: handle zero column diagnostic from OmniSharp; - PR ycm-core/ycmd#884: specify Platform property when compiling OmniSharp; - PR ycm-core/ycmd#886: use current working directory in JavaScript completer; - PR ycm-core/ycmd#887: update Boost to 1.66.0; - PR ycm-core/ycmd#888: update JediHTTP; - PR ycm-core/ycmd#889: update Clang to 5.0.1; - PR ycm-core/ycmd#891: fix building with system libclang on Gentoo amd64; - PR ycm-core/ycmd#904: drop Python 2.6 and Python 3.3 support; - PR ycm-core/ycmd#905: calculate the start column when items are not resolved in the language server completer; - PR ycm-core/ycmd#912: download Clang binaries from HTTPS; - PR ycm-core/ycmd#914: do not try to symlink libclang on Windows. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2902) <!-- Reviewable:end -->
This PR translates libclang error codes returned by the
clang_parseTranslationUnit2FullArgv
andclang_reparseTranslationUnit
functions tostd::runtime_error
exceptions with the corresponding error message; replacing theClangParseError
exception. UnlikeClangParseError
, we don't silence them as they can help understand why the Clang completer is not working.This change is