1 | /**************************************************************************** |
2 | * Copyright (C) 2013-2016 Woboq GmbH |
3 | * Olivier Goffart <contact at woboq.com> |
4 | * https://woboq.com/ |
5 | * |
6 | * This program is free software: you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation, either version 3 of the License, or |
9 | * (at your option) any later version. |
10 | * |
11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. |
15 | * |
16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | */ |
19 | |
20 | #include "generator.h" |
21 | #include <clang/AST/DeclCXX.h> |
22 | #include <llvm/ADT/StringSwitch.h> |
23 | |
24 | /* |
25 | * Some tests do not pass because moc is different from moc-ng and there is no reason for them |
26 | * to change (for example the tests expect different warnings message) |
27 | * This cheat by detecting these tests and generating code to SKIP them |
28 | * |
29 | * Keep a comment for each blacklisted test case with the reason why it is blacklisted |
30 | */ |
31 | |
32 | bool Generator::WorkaroundTests(llvm::StringRef ClassName, const clang::CXXMethodDecl* MD, |
33 | llvm::raw_ostream& OS) |
34 | { |
35 | llvm::StringRef MethodName = MD->getName(); |
36 | bool Match = false; |
37 | if (ClassName == "tst_Moc" ) { |
38 | Match = llvm::StringSwitch<bool>(MethodName) |
39 | // The wording of the warnings is not the same with moc-ng (it is better) |
40 | .Cases("warnings" , "warnOnExtraSignalSlotQualifiaction" , "warnOnMultipleInheritance" , true) |
41 | .Cases("forgottenQInterface" , "warnOnPropertyWithoutREAD" , true) |
42 | .Cases("warnOnVirtualSignal" , "notifyError" , "optionsFileError" , true) |
43 | |
44 | // Small difference in the handling of the options |
45 | .Case("ignoreOptionClashes" , true) |
46 | |
47 | // Not implemented because I was focusing on Linux! ### FIXME |
48 | .Case("frameworkSearchPath" , true) |
49 | |
50 | // The header is not self contained (that could be easy to solve upstream) |
51 | .Case("templateGtGt" , true) |
52 | |
53 | // moc -E to preprocess behave differently |
54 | .Case("unterminatedFunctionMacro" , true) |
55 | |
56 | // MSVC compat mode for $INCLUDE environment variable not implemented |
57 | .Case("environmentIncludePaths" , true) |
58 | |
59 | .Default(false); |
60 | } else if(ClassName == "tst_QObject" ){ |
61 | if (MethodName == "normalize" ) { |
62 | // "unsigned long int" is a builtin type, but is not registered by default, and clang |
63 | // mangle it as "unsigned long" with no way to get what was the actual string. |
64 | // By registering the right string we ensure that the function is found when. |
65 | // This is actually a bug in QMetaType that should be fixed in Qt https://codereview.qt-project.org/55193 |
66 | OS << "\n qRegisterMetaType<unsigned long int>(\"unsigned long int\");\n " ; |
67 | return false; // The normal function will be called |
68 | } |
69 | } |
70 | |
71 | if (!Match) |
72 | return false; |
73 | |
74 | OS << " QSKIP(\"This test does not make sens with moc-ng\");\n" ; |
75 | // testlib is expected to be included in the test. |
76 | // QSKIP calls return; so no need to add the break; |
77 | return true; |
78 | } |
79 | |