[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation
zaks.anna added inline comments. Comment at: lib/StaticAnalyzer/Core/SValBuilder.cpp:356 QualType ResultTy) { - if (!State->isTainted(RHS) && !State->isTainted(LHS)) -return UnknownVal(); ddcc wrote: > zaks.anna wrote: > > I am concerned that removing the guard will regress performance in the > > vanilla case. (Note that Z3 support as well as taint are not on by default.) > > > > I am curious how much of the regression you've measured could be gained > > back if we make this conditional. > To clarify, the changes made in this patch aren't specific to Z3 support, > especially simplifying `SymbolCast` and `IntSymExpr`. With the exception of > `PR24184.cpp` and `plist-macros.cpp`, all testcases pass with both the > default and Z3 constraint managers. However, creating additional constraints > does have performance overhead, and it may be useful to consider the > parameters for gating this functionality. > > On a combined execution (Range + Z3) through the testcases, except the two > mentioned above, the runtime is 327 sec with this patch applied, and 195 sec > without this patch applied. On a separate execution through the testcases > with only the Z3 constraint manager, I get runtimes 320 and 191, respectively. > > For testing purposes, I also tried the following code, which has combined > runtime 311 sec, but loses the accuracy improvements with the Range > constraint manager on `bitwise-ops.c`, `conditional-path-notes.c`, > `explain-svals.cpp`, and `std-c-library-functions.c`. > > ``` > ConstraintManager &CM = getStateManager().getConstraintManager(); > if (!State->isTainted(RHS) && !State->isTainted(LHS) && !CM.isZ3()) > ``` Thanks for the explanation! Regressing the current default behavior is my main concern. By looking at the numbers you provided before (Pre-commit and Post-Commit for RangeConstraintManager), it seems that this patch will introduce a performance regression of about 20%, which is large. But you are pointing out that there are improvements to the modeling as well and those are captured by the updated tests. Here are a couple of ideas that came into mind on gaining back performance for the RangeConstraintManager case: - Can we drop computing these for some expressions that we know the RangeConstraintManager will not utilize? - We could implement the TODO described below and possibly also lower the MaxComp value. This means that instead of keeping a complex expression and constraints on every symbol used in that expression, we would conjure a new symbol and associate a new constrain derived from the expression with it. (Would this strategy also work for the Z3 case?) I have to point out that this code is currently only used by taint analysis, which is experimental and the current MaxComp value is targeted at that. We would probably need to refine the strategy here if we want to apply this logic to a general case. It's possible that different MaxComp should be used for different cases. It would be valuable to run this on real code and measure how the number of reports we get differs depending on these values. https://reviews.llvm.org/D28953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34091: Support for querying the exception specification type through libclang
ajbennieston updated this revision to Diff 102934. ajbennieston added a comment. V3 with indentation and punctuation fixes. https://reviews.llvm.org/D34091 Files: bindings/python/clang/cindex.py bindings/python/tests/cindex/test_exception_specification_kind.py include/clang-c/Index.h test/Index/get-cursor.cpp tools/c-index-test/c-index-test.c tools/libclang/CXType.cpp tools/libclang/libclang.exports Index: tools/libclang/libclang.exports === --- tools/libclang/libclang.exports +++ tools/libclang/libclang.exports @@ -175,6 +175,7 @@ clang_getCursorDefinition clang_getCursorDisplayName clang_getCursorExtent +clang_getCursorExceptionSpecificationType clang_getCursorKind clang_getCursorKindSpelling clang_getCursorLanguage @@ -210,6 +211,7 @@ clang_getEnumConstantDeclUnsignedValue clang_getEnumConstantDeclValue clang_getEnumDeclIntegerType +clang_getExceptionSpecificationType clang_getFieldDeclBitWidth clang_getExpansionLocation clang_getFile Index: tools/libclang/CXType.cpp === --- tools/libclang/CXType.cpp +++ tools/libclang/CXType.cpp @@ -684,6 +684,24 @@ return MakeCXType(QualType(), cxcursor::getCursorTU(C)); } +int clang_getExceptionSpecificationType(CXType X) { + QualType T = GetQualType(X); + if (T.isNull()) +return -1; + + if (const auto *FD = T->getAs()) +return static_cast(FD->getExceptionSpecType()); + + return -1; +} + +int clang_getCursorExceptionSpecificationType(CXCursor C) { + if (clang_isDeclaration(C.kind)) +return clang_getExceptionSpecificationType(clang_getCursorType(C)); + + return -1; +} + unsigned clang_isPODType(CXType X) { QualType T = GetQualType(X); if (T.isNull()) Index: tools/c-index-test/c-index-test.c === --- tools/c-index-test/c-index-test.c +++ tools/c-index-test/c-index-test.c @@ -809,6 +809,37 @@ if (clang_Cursor_isObjCOptional(Cursor)) printf(" (@optional)"); +switch (clang_getCursorExceptionSpecificationType(Cursor)) +{ + case CXCursor_ExceptionSpecificationKind_None: +break; + + case CXCursor_ExceptionSpecificationKind_DynamicNone: +printf(" (noexcept dynamic none)"); +break; + + case CXCursor_ExceptionSpecificationKind_Dynamic: +printf(" (noexcept dynamic)"); +break; + + case CXCursor_ExceptionSpecificationKind_MSAny: +printf(" (noexcept dynamic any)"); +break; + + case CXCursor_ExceptionSpecificationKind_BasicNoexcept: +printf(" (noexcept)"); +break; + + case CXCursor_ExceptionSpecificationKind_ComputedNoexcept: +printf(" (computed-noexcept)"); +break; + + case CXCursor_ExceptionSpecificationKind_Unevaluated: + case CXCursor_ExceptionSpecificationKind_Uninstantiated: + case CXCursor_ExceptionSpecificationKind_Unparsed: +break; +} + { CXString language; CXString definedIn; Index: test/Index/get-cursor.cpp === --- test/Index/get-cursor.cpp +++ test/Index/get-cursor.cpp @@ -145,6 +145,13 @@ const int operator""_toint(unsigned long long val) { return int(val); } +// noexcept specifications +void f_noexcept() noexcept; +template void f_computed_noexcept(T t) noexcept(noexcept(t+t)); +void f_dynamic_noexcept_none() throw(); +void f_dynamic_noexcept() throw(int); +void f_dynamic_noexcept_any() throw(...); + // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s // CHECK-COMPLETION-1: CXXConstructor=X:6:3 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )} @@ -209,11 +216,11 @@ // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck -check-prefix=CHECK-TEMPLSPEC %s // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25]) -// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 -cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 -cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 -cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 -cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 -cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 -cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 -cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 -cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 -cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 -cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 -cursor-at=
[PATCH] D28953: [analyzer] Eliminate analyzer limitations on symbolic constraint generation
NoQ added a comment. Hmm, curious, having a look. A couple of blind guesses before i actually understand what's going on: (1) The `simplifySVal()` code has its own complexity threshold: 1060 SVal VisitNonLocSymbolVal(nonloc::SymbolVal V) { 1061 // Simplification is much more costly than computing complexity. 1062 // For high complexity, it may be not worth it. 1063 if (V.getSymbol()->computeComplexity() > 100) 1064 return V; 1065 return Visit(V.getSymbol()); 1066 } Would it help to decrease `100` to `10` here? (2) With RangeConstraintManager, simplification is not entirely idempotent: we may simplify a symbol further when one of its sub-symbols gets constrained to a constant in a new state. However, apart from that, we might be able to avoid re-simplifying the same symbol by caching results based on the (symbol, state's constraint data) pair. Probably it may work with Z3 as well. https://reviews.llvm.org/D28953 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34225: [clang-format] Teach clang-format how to handle C++ coroutines
EricWF added inline comments. Comment at: lib/Format/UnwrappedLineParser.cpp:433 case tok::kw___try: + assert(!Tok->is(tok::kw_co_await)); if (!LBraceStack.empty() && LBraceStack.back()->BlockKind == BK_Unknown) This change is accidental. https://reviews.llvm.org/D34225 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305638 - CodeGen: make the type match the comment for a libcall
Author: compnerd Date: Sat Jun 17 12:30:31 2017 New Revision: 305638 URL: http://llvm.org/viewvc/llvm-project?rev=305638&view=rev Log: CodeGen: make the type match the comment for a libcall Fix the type for a (runtime) library call to match both the comment and the runtime implementation. As it happens, the type being used matched, this just makes it more precise. Added: cfe/trunk/test/CodeGenObjC/objc_copyStruct.m Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=305638&r1=305637&r2=305638&view=diff == --- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original) +++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Sat Jun 17 12:30:31 2017 @@ -308,7 +308,7 @@ public: SmallVector Params; Params.push_back(Ctx.VoidPtrTy); Params.push_back(Ctx.VoidPtrTy); -Params.push_back(Ctx.LongTy); +Params.push_back(Ctx.getSizeType()); Params.push_back(Ctx.BoolTy); Params.push_back(Ctx.BoolTy); llvm::FunctionType *FTy = Added: cfe/trunk/test/CodeGenObjC/objc_copyStruct.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc_copyStruct.m?rev=305638&view=auto == --- cfe/trunk/test/CodeGenObjC/objc_copyStruct.m (added) +++ cfe/trunk/test/CodeGenObjC/objc_copyStruct.m Sat Jun 17 12:30:31 2017 @@ -0,0 +1,16 @@ +// RUN: %clang -target x86_64-unknown-windows-msvc -fobjc-runtime=ios -Wno-objc-root-class -S -o - -emit-llvm %s | FileCheck %s +// RUN: %clang -target x86_64-apple-ios -fobjc-runtime=ios -Wno-objc-root-class -S -o - -emit-llvm %s | FileCheck %s + +struct S { + float f, g; +}; + +@interface I +@property struct S s; +@end + +@implementation I +@end + +// CHECK: declare {{.*}}void @objc_copyStruct(i8*, i8*, i64, i1, i1) + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34018: Support __float128 on NetBSD libstdc++ x86/x86_64
krytarowski added a comment. ping Repository: rL LLVM https://reviews.llvm.org/D34018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34018: Support __float128 on NetBSD libstdc++ x86/x86_64
joerg added a comment. As I said, I don't see the point in pretending we support float128 when the runtime doesn't contain the necessary pieces. Repository: rL LLVM https://reviews.llvm.org/D34018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34018: Support __float128 on NetBSD libstdc++ x86/x86_64
krytarowski added a comment. In https://reviews.llvm.org/D34018#783218, @joerg wrote: > As I said, I don't see the point in pretending we support float128 when the > runtime doesn't contain the necessary pieces. On the other hand cmake and other packages break now. What's the alternative? Repository: rL LLVM https://reviews.llvm.org/D34018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34018: Support __float128 on NetBSD libstdc++ x86/x86_64
krytarowski added a comment. We can patch libstdc++ to conditionally enable float128 on NetBSD, this works too. All other systems I'm aware of including cygwin moved to `this->HasFloat128 = true;`. Repository: rL LLVM https://reviews.llvm.org/D34018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33383: [GSoC] Flag value completion for clang
yamaguchi updated this revision to Diff 102944. yamaguchi marked 3 inline comments as done. yamaguchi added a comment. Herald added a subscriber: hiraditya. Update patch and add support for `clang -stdlib=[tab]` case. In this case we expect to see all possible values. (Eg. `libc++ libstdc++ platform` for `clang -stdlib=[tab]`). https://reviews.llvm.org/D33383 Files: clang/include/clang/Driver/Options.h clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/DriverOptions.cpp clang/test/Driver/autocomplete.c clang/utils/bash-autocomplete.sh lld/COFF/Driver.h lld/COFF/DriverUtils.cpp lld/ELF/Driver.h lld/ELF/DriverUtils.cpp lld/lib/Driver/DarwinLdDriver.cpp llvm/include/llvm/Option/OptParser.td llvm/include/llvm/Option/OptTable.h llvm/include/llvm/Option/Option.h llvm/lib/Option/OptTable.cpp llvm/lib/Option/Option.cpp llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp llvm/tools/llvm-cvtres/llvm-cvtres.cpp llvm/unittests/Option/OptionParsingTest.cpp llvm/utils/TableGen/OptParserEmitter.cpp Index: llvm/utils/TableGen/OptParserEmitter.cpp === --- llvm/utils/TableGen/OptParserEmitter.cpp +++ llvm/utils/TableGen/OptParserEmitter.cpp @@ -196,6 +196,9 @@ OS << ", nullptr"; // The option meta-variable name (unused). +OS << ", nullptr"; + +// The option Values (unused for groups). OS << ", nullptr)\n"; } OS << "\n"; @@ -285,6 +288,13 @@ else OS << "nullptr"; +// The option Values. Used for shell autocompletion. +OS << ", "; +if (!isa(R.getValueInit("ArgValues"))) + write_cstring(OS, R.getValueAsString("ArgValues")); +else + OS << "nullptr"; + OS << ")\n"; } OS << "#endif // OPTION\n"; Index: llvm/unittests/Option/OptionParsingTest.cpp === --- llvm/unittests/Option/OptionParsingTest.cpp +++ llvm/unittests/Option/OptionParsingTest.cpp @@ -18,8 +18,9 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) OPT_##ID, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + OPT_##ID, #include "Opts.inc" LastOption #undef OPTION @@ -36,10 +37,10 @@ }; static const OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ - { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \ -FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS }, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + {PREFIX, NAME, HELPTEXT,METAVAR, OPT_##ID, Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp === --- llvm/tools/llvm-cvtres/llvm-cvtres.cpp +++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp @@ -37,7 +37,7 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ OPT_##ID, #include "Opts.inc" #undef OPTION @@ -49,12 +49,12 @@ static const opt::OptTable::Info InfoTable[] = { #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ {\ - PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, opt::Option::KIND##Class, \ - PARAM, FLAGS,OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS}, + PREFIX, NAME, HELPTEXT,\ + METAVAR, OPT_##ID, opt::Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, \ + OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp === --- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -31,7 +31,7 @@ enum { OPT_INVALID = 0, -#define OPTION(_1, _
[PATCH] D33383: [GSoC] Flag value completion for clang
yamaguchi added inline comments. Comment at: clang/test/Driver/autocomplete.c:7 // NONE: foo +// RUN: %clang --autocomplete=l,=,-stdlib | FileCheck %s -check-prefix=STDLIB +// STDLIB: libc++ libstdc++ ruiu wrote: > Why do you want to pass the arguments in the reverse order? In the reverse order, current flag is always exists at first, so I thought it is more simple. (Eg. `clang -fsyntax-only -o foo -std=c` will be passed as `c,=,-std,foo,-i,-fsyntax-only`) https://reviews.llvm.org/D33383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33383: [GSoC] Flag value completion for clang
yamaguchi marked 2 inline comments as done. yamaguchi added inline comments. Comment at: llvm/lib/Option/OptTable.cpp:198 + continue; +std::string S = "-" + std::string(In.Name); +std::string C = (Command[1] == "=") ? yamaguchi wrote: > teemperor wrote: > > Hmm, will this work with "--" flags? Also, same as above with naming `S` > > and `C`. > @teemperor > Do you think we should add some sample value completions to flags start with > "--" (such as --target) and flags which don't contain "=" (such as -mllvm > ) ? > This part of code is rather ad hoc right now for -stdlib. I had add support for this in this update as well, thanks. https://reviews.llvm.org/D33383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33383: [GSoC] Flag value completion for clang
ruiu added a comment. As to the order of Command variable contents, I think I'm not convinced. You can access the last element as `Command[Command.size() - 1]` (or maybe `Command.back()`), no? It is slightly awkward than `Command[0]`, but that's not horribly hard to handle, and passing arguments in the reverse order seems more counter-intuitive to me. Comment at: clang/include/clang/Driver/Options.td:2198 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, - HelpText<"C++ standard library to use">; + HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">; def sub__library : JoinedOrSeparate<["-"], "sub_library">; v.g.vassilev wrote: > ruiu wrote: > > v.g.vassilev wrote: > > > `Values` seems too generic, can we use `ArgValues` instead? > > I'd keep it as `Values`, as everything is essentially related to command > > line arguments, and `Args` seems redundant. For example, we didn't name > > `ArgFlags` but just `Flags`, and `HelpText` instead of `ArgHelpText`, etc. > My reasoning for asking this is that I wanted to hint about the relationship > between the values (as this is a very broad term) and arguments. I'd read > `ArgValues` as possible values for an argument without having to dig into > context. > > That said, I don't think switching back to `Values` is a significant issue, > if @ruiu feels strongly about it , please follow his suggestion and land the > patch. I think I feel fairly strongly prefer "Value" over "ArgValue". If this is a one-time name, I agree that we should use "ArgValue", but this is not the case. We are going to add bunch of "Values" to options that take arguments, and I expect that the verbose name will start feeling too verbose. So please switch back to "Values". Comment at: clang/utils/bash-autocomplete.sh:7 - flags=$( clang --autocomplete="$cur" ) - if [[ "$flags" == "" || "$cur" == "" ]]; then + arg="" + for (( i = $cword; i >= 1; i-- )) ; Don't you want to make it `local`? Comment at: clang/utils/bash-autocomplete.sh:8 + arg="" + for (( i = $cword; i >= 1; i-- )) ; + do If you don't write `do` on the same line as `for`, you don't need to write `;` at end of a line. I.e. write it in either for ... do command... done or for ...; do command... done This is because you need a newline between `for` and `do`, and `;` works as a newline. Comment at: clang/utils/bash-autocomplete.sh:10 + do +arg="$arg""${COMP_WORDS[$i]}," + done nit: you don't need double double-quotes. Instead, `"$arg${COMP_WORDS[$i]}," should just work. Comment at: clang/utils/bash-autocomplete.sh:15-16 + if [[ "$cur" == "=" ]]; then +cur="" +COMPREPLY=( $( compgen -W "$flags" -- "$cur") ) + else if [[ "$flags" == "" || "$cur" == "" ]]; then Alternatively, `COMPRELY=( $( compgen -W "$flags" -- "") )` should work. Comment at: clang/utils/bash-autocomplete.sh:17 +COMPREPLY=( $( compgen -W "$flags" -- "$cur") ) + else if [[ "$flags" == "" || "$cur" == "" ]]; then _filedir Use `elif` so that you don't have to write two `fi`s at end. In a bash script, if ... else if is usually written as if ...; then elif ...; then elif ...; then fi If you use `else if` instead of `elif`, and if you indent the code properly, it'll look like if ...; then else if ...; then fi fi This is why you needed two `fi`s. https://reviews.llvm.org/D33383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33383: [GSoC] Flag value completion for clang
ruiu added inline comments. Comment at: clang/utils/bash-autocomplete.sh:10 + do +arg="$arg""${COMP_WORDS[$i]}," + done ruiu wrote: > nit: you don't need double double-quotes. Instead, `"$arg${COMP_WORDS[$i]}," > should just work. On second thought, I think what you actually want to do is to concatenate the elements of the array with `,`, without adding `,` at end of the string. For example, if COMP_WORDS contains "a", "b" and "c", you want to create "a,b,c" instead of "a,b,c," or ",a,b,c". There are surprisingly large number of different ways of doing this, but it seems this is one of the easiest ways. arg="$(IFS=,; echo "${COMP_WORDS[*]}")" IFS is a special shell variable containing a word splitting words. By setting the variable, COMP_WORDS[*] is expanded to (for example) "a,b,c" instead of the default "a b c". https://reviews.llvm.org/D33383 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33383: [GSoC] Flag value completion for clang
yamaguchi updated this revision to Diff 102946. yamaguchi marked 5 inline comments as done. yamaguchi added a comment. Update patch. Rui's comment about the bash part is very reasonable. https://reviews.llvm.org/D33383 Files: clang/include/clang/Driver/Options.h clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/DriverOptions.cpp clang/test/Driver/autocomplete.c clang/utils/bash-autocomplete.sh lld/COFF/Driver.h lld/COFF/DriverUtils.cpp lld/ELF/Driver.h lld/ELF/DriverUtils.cpp lld/lib/Driver/DarwinLdDriver.cpp llvm/include/llvm/Option/OptParser.td llvm/include/llvm/Option/OptTable.h llvm/include/llvm/Option/Option.h llvm/lib/Option/OptTable.cpp llvm/lib/Option/Option.cpp llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp llvm/tools/llvm-cvtres/llvm-cvtres.cpp llvm/unittests/Option/OptionParsingTest.cpp llvm/utils/TableGen/OptParserEmitter.cpp Index: llvm/utils/TableGen/OptParserEmitter.cpp === --- llvm/utils/TableGen/OptParserEmitter.cpp +++ llvm/utils/TableGen/OptParserEmitter.cpp @@ -196,6 +196,9 @@ OS << ", nullptr"; // The option meta-variable name (unused). +OS << ", nullptr"; + +// The option Values (unused for groups). OS << ", nullptr)\n"; } OS << "\n"; @@ -285,6 +288,13 @@ else OS << "nullptr"; +// The option Values. Used for shell autocompletion. +OS << ", "; +if (!isa(R.getValueInit("ArgValues"))) + write_cstring(OS, R.getValueAsString("ArgValues")); +else + OS << "nullptr"; + OS << ")\n"; } OS << "#endif // OPTION\n"; Index: llvm/unittests/Option/OptionParsingTest.cpp === --- llvm/unittests/Option/OptionParsingTest.cpp +++ llvm/unittests/Option/OptionParsingTest.cpp @@ -18,8 +18,9 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) OPT_##ID, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + OPT_##ID, #include "Opts.inc" LastOption #undef OPTION @@ -36,10 +37,10 @@ }; static const OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ - { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \ -FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS }, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + {PREFIX, NAME, HELPTEXT,METAVAR, OPT_##ID, Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp === --- llvm/tools/llvm-cvtres/llvm-cvtres.cpp +++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp @@ -37,7 +37,7 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ OPT_##ID, #include "Opts.inc" #undef OPTION @@ -49,12 +49,12 @@ static const opt::OptTable::Info InfoTable[] = { #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ {\ - PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, opt::Option::KIND##Class, \ - PARAM, FLAGS,OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS}, + PREFIX, NAME, HELPTEXT,\ + METAVAR, OPT_##ID, opt::Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, \ + OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp === --- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -31,7 +31,7 @@ enum { OPT_INVALID = 0, -#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID, +#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID, #include "Opti
[PATCH] D34018: Support __float128 on NetBSD libstdc++ x86/x86_64
krytarowski added a comment. We can change NetBSD base libstdc++ in `/usr/include/g++/bits/*/c++config.h` from /* Define if __float128 is supported on this host. */ #define _GLIBCXX_USE_FLOAT128 1 to: #if !defined(__clang__) /* Define if __float128 is supported on this host. */ #define _GLIBCXX_USE_FLOAT128 1 #endif Repository: rL LLVM https://reviews.llvm.org/D34018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32950: Support C++1z features in `__has_extension`
EricWF added a comment. @rsmith ping. I need this for http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0607r0.html https://reviews.llvm.org/D32950 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33852: Enable __declspec(selectany) on linux
davide added inline comments. Comment at: include/clang/Basic/Attr.td:2421 -def SelectAny : InheritableAttr, TargetSpecificAttr { +def SelectAny : InheritableAttr, TargetSpecificAttr { let Spellings = [Declspec<"selectany">, GCC<"selectany">]; rnk wrote: > Prazek wrote: > > rnk wrote: > > > davide wrote: > > > > Prazek wrote: > > > > > majnemer wrote: > > > > > > selectany should work on targets other than "x86", "x86_64", "arm", > > > > > > "thumb", etc. I think it is only necessary to require that it be a > > > > > > COFF or ELF target. > > > > > Should we allow other OSes than Win32 and Linux? > > > > I guess everything ELF should be allowed. > > > Why not use weak_odr / linkonce_odr on MachO? Microsoft builds Office for > > > Mac and I suspect they use `__declspec(selectany)`. > > I think this is what would happen right now. The question is - should we > > warn about using declspec on macho? Beause not using comdat looks like "not > > supporting" it, but I am not sure about it. > I'm pretty sure weak_odr / linkonce_odr with ld64 on macho are the same as > having a comdat. LLVM didn't always have comdats, but it's supported inline > functions for a very long time. We should support selectany there. I agree with @rnk here. https://reviews.llvm.org/D33852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34287: Moved code hanlding precompiled preamble out of the ASTUnit.
arphaman added inline comments. Comment at: include/clang/Frontend/PrecompiledPreamble.h:248 +/// doesn't restore the state \p CI had before calling AddImplicitPreamble, only +/// clears relevant settings, so that preamble is disabled in \p CI. +} // namespace clang Is there a missing declaration here or is this a comment for another declaration? https://reviews.llvm.org/D34287 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34175: [driver][macOS] Pick the system version for the deployment target if the SDK is newer than the system
dexonsmith accepted this revision. dexonsmith added a comment. This revision is now accepted and ready to land. LGTM. Repository: rL LLVM https://reviews.llvm.org/D34175 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34268: [clang] Fix format specifiers fixits for nested macros
alexshap added a comment. Ping Repository: rL LLVM https://reviews.llvm.org/D34268 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34324: [clang-format] let PointerAlignment dictate spacing of function ref qualifiers
jtbandes created this revision. Herald added a subscriber: klimek. The original changes for ref qualifiers in https://reviews.llvm.org/rL272537 and https://reviews.llvm.org/rL272548 allowed function const+ref qualifier spacing to diverge from the spacing used for variables. It seems more consistent for `T const& x;` to match `void foo() const&;`. https://reviews.llvm.org/D34324 Files: lib/Format/TokenAnnotator.cpp unittests/Format/FormatTest.cpp Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -4958,7 +4958,8 @@ verifyFormat("SomeType MemberFunction(const Deleted &) && {}"); verifyFormat("SomeType MemberFunction(const Deleted &) && final {}"); verifyFormat("SomeType MemberFunction(const Deleted &) && override {}"); - verifyFormat("SomeType MemberFunction(const Deleted &) const &;"); + verifyFormat("void Fn(T const &) const &;"); + verifyFormat("void Fn(T const volatile &&) const volatile &&;"); verifyFormat("template \n" "void F(T) && = delete;", getGoogleStyle()); @@ -4975,7 +4976,8 @@ verifyFormat("auto Function(T... t) & -> void {}", AlignLeft); verifyFormat("auto Function(T) & -> void {}", AlignLeft); verifyFormat("auto Function(T) & -> void;", AlignLeft); - verifyFormat("SomeType MemberFunction(const Deleted&) const &;", AlignLeft); + verifyFormat("void Fn(T const&) const&;", AlignLeft); + verifyFormat("void Fn(T const volatile&&) const volatile&&;", AlignLeft); FormatStyle Spaces = getLLVMStyle(); Spaces.SpacesInCStyleCastParentheses = true; Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2155,8 +2155,7 @@ return false; if (Right.is(TT_PointerOrReference)) return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) || - (Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous && - Left.Previous->is(tok::r_paren)) || + (Left.Tok.isLiteral() || (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) && (Style.PointerAlignment != FormatStyle::PAS_Left || (Line.IsMultiVariableDeclStmt && Index: unittests/Format/FormatTest.cpp === --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -4958,7 +4958,8 @@ verifyFormat("SomeType MemberFunction(const Deleted &) && {}"); verifyFormat("SomeType MemberFunction(const Deleted &) && final {}"); verifyFormat("SomeType MemberFunction(const Deleted &) && override {}"); - verifyFormat("SomeType MemberFunction(const Deleted &) const &;"); + verifyFormat("void Fn(T const &) const &;"); + verifyFormat("void Fn(T const volatile &&) const volatile &&;"); verifyFormat("template \n" "void F(T) && = delete;", getGoogleStyle()); @@ -4975,7 +4976,8 @@ verifyFormat("auto Function(T... t) & -> void {}", AlignLeft); verifyFormat("auto Function(T) & -> void {}", AlignLeft); verifyFormat("auto Function(T) & -> void;", AlignLeft); - verifyFormat("SomeType MemberFunction(const Deleted&) const &;", AlignLeft); + verifyFormat("void Fn(T const&) const&;", AlignLeft); + verifyFormat("void Fn(T const volatile&&) const volatile&&;", AlignLeft); FormatStyle Spaces = getLLVMStyle(); Spaces.SpacesInCStyleCastParentheses = true; Index: lib/Format/TokenAnnotator.cpp === --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -2155,8 +2155,7 @@ return false; if (Right.is(TT_PointerOrReference)) return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) || - (Left.Tok.isLiteral() || (Left.is(tok::kw_const) && Left.Previous && - Left.Previous->is(tok::r_paren)) || + (Left.Tok.isLiteral() || (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) && (Style.PointerAlignment != FormatStyle::PAS_Left || (Line.IsMultiVariableDeclStmt && ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D34175: [driver][macOS] Pick the system version for the deployment target if the SDK is newer than the system
kubamracek added a comment. Nice! Repository: rL LLVM https://reviews.llvm.org/D34175 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33383: [GSoC] Flag value completion for clang
yamaguchi updated this revision to Diff 102958. yamaguchi marked 10 inline comments as done. yamaguchi added a comment. Cleaned suggestValueCompletions and bash-autocomplete.sh, and added tests. We have passed flags and values from bash to clang like `clang --autocomplete=l,=,-stdlib`, but I've changed this to pass `clang --autocomplte=-stdlib=,l` instead. This is more simple. Added support and test for -meabi flag. This flag is corner case, because it doesn't take `=` suffix like `-stdlib=`. When `clang -stdlib=[tab]` is pushed, we would give possible values (libstd++,..), and when `clang -stdlib= [tab]` is pushed, we just give files under current directory. And when `clang -meabi [tab]` is pushed, we give possible values (gnu,..). https://reviews.llvm.org/D33383 Files: clang/include/clang/Driver/Options.h clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/DriverOptions.cpp clang/test/Driver/autocomplete.c clang/utils/bash-autocomplete.sh lld/COFF/Driver.h lld/COFF/DriverUtils.cpp lld/ELF/Driver.h lld/ELF/DriverUtils.cpp lld/lib/Driver/DarwinLdDriver.cpp llvm/include/llvm/Option/OptParser.td llvm/include/llvm/Option/OptTable.h llvm/include/llvm/Option/Option.h llvm/lib/Option/OptTable.cpp llvm/lib/Option/Option.cpp llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp llvm/tools/llvm-cvtres/llvm-cvtres.cpp llvm/unittests/Option/OptionParsingTest.cpp llvm/utils/TableGen/OptParserEmitter.cpp Index: llvm/utils/TableGen/OptParserEmitter.cpp === --- llvm/utils/TableGen/OptParserEmitter.cpp +++ llvm/utils/TableGen/OptParserEmitter.cpp @@ -196,6 +196,9 @@ OS << ", nullptr"; // The option meta-variable name (unused). +OS << ", nullptr"; + +// The option Values (unused for groups). OS << ", nullptr)\n"; } OS << "\n"; @@ -285,6 +288,13 @@ else OS << "nullptr"; +// The option Values. Used for shell autocompletion. +OS << ", "; +if (!isa(R.getValueInit("Values"))) + write_cstring(OS, R.getValueAsString("Values")); +else + OS << "nullptr"; + OS << ")\n"; } OS << "#endif // OPTION\n"; Index: llvm/unittests/Option/OptionParsingTest.cpp === --- llvm/unittests/Option/OptionParsingTest.cpp +++ llvm/unittests/Option/OptionParsingTest.cpp @@ -18,8 +18,9 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) OPT_##ID, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + OPT_##ID, #include "Opts.inc" LastOption #undef OPTION @@ -36,10 +37,10 @@ }; static const OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ - { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \ -FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS }, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + {PREFIX, NAME, HELPTEXT,METAVAR, OPT_##ID, Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp === --- llvm/tools/llvm-cvtres/llvm-cvtres.cpp +++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp @@ -37,7 +37,7 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ OPT_##ID, #include "Opts.inc" #undef OPTION @@ -49,12 +49,12 @@ static const opt::OptTable::Info InfoTable[] = { #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ {\ - PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, opt::Option::KIND##Class, \ - PARAM, FLAGS,OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS}, + PREFIX, NAME, HELPTEXT,\ + METAVAR, OPT_##ID, opt::Option::KIND##Class,\ + PARAM, FLAGS, OPT
[PATCH] D33383: [GSoC] Flag value completion for clang
yamaguchi updated this revision to Diff 102959. yamaguchi marked an inline comment as done. yamaguchi added a comment. Made trivial change. https://reviews.llvm.org/D33383 Files: clang/include/clang/Driver/Options.h clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/DriverOptions.cpp clang/test/Driver/autocomplete.c clang/utils/bash-autocomplete.sh lld/COFF/Driver.h lld/COFF/DriverUtils.cpp lld/ELF/Driver.h lld/ELF/DriverUtils.cpp lld/lib/Driver/DarwinLdDriver.cpp llvm/include/llvm/Option/OptParser.td llvm/include/llvm/Option/OptTable.h llvm/include/llvm/Option/Option.h llvm/lib/Option/OptTable.cpp llvm/lib/Option/Option.cpp llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp llvm/tools/llvm-cvtres/llvm-cvtres.cpp llvm/unittests/Option/OptionParsingTest.cpp llvm/utils/TableGen/OptParserEmitter.cpp Index: llvm/utils/TableGen/OptParserEmitter.cpp === --- llvm/utils/TableGen/OptParserEmitter.cpp +++ llvm/utils/TableGen/OptParserEmitter.cpp @@ -196,6 +196,9 @@ OS << ", nullptr"; // The option meta-variable name (unused). +OS << ", nullptr"; + +// The option Values (unused for groups). OS << ", nullptr)\n"; } OS << "\n"; @@ -285,6 +288,13 @@ else OS << "nullptr"; +// The option Values. Used for shell autocompletion. +OS << ", "; +if (!isa(R.getValueInit("Values"))) + write_cstring(OS, R.getValueAsString("Values")); +else + OS << "nullptr"; + OS << ")\n"; } OS << "#endif // OPTION\n"; Index: llvm/unittests/Option/OptionParsingTest.cpp === --- llvm/unittests/Option/OptionParsingTest.cpp +++ llvm/unittests/Option/OptionParsingTest.cpp @@ -18,8 +18,9 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) OPT_##ID, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + OPT_##ID, #include "Opts.inc" LastOption #undef OPTION @@ -36,10 +37,10 @@ }; static const OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ - { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \ -FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS }, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + {PREFIX, NAME, HELPTEXT,METAVAR, OPT_##ID, Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp === --- llvm/tools/llvm-cvtres/llvm-cvtres.cpp +++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp @@ -37,7 +37,7 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ OPT_##ID, #include "Opts.inc" #undef OPTION @@ -49,12 +49,12 @@ static const opt::OptTable::Info InfoTable[] = { #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ {\ - PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, opt::Option::KIND##Class, \ - PARAM, FLAGS,OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS}, + PREFIX, NAME, HELPTEXT,\ + METAVAR, OPT_##ID, opt::Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, \ + OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp === --- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -31,7 +31,7 @@ enum { OPT_INVALID = 0, -#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID, +#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID, #include "Options.inc" #undef OPTION }; @@ -41,11 +41,9 @@ #unde
[PATCH] D33383: [GSoC] Flag value completion for clang
yamaguchi updated this revision to Diff 102960. yamaguchi added a comment. Made trivial bug fix. https://reviews.llvm.org/D33383 Files: clang/include/clang/Driver/Options.h clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/DriverOptions.cpp clang/test/Driver/autocomplete.c clang/utils/bash-autocomplete.sh lld/COFF/Driver.h lld/COFF/DriverUtils.cpp lld/ELF/Driver.h lld/ELF/DriverUtils.cpp lld/lib/Driver/DarwinLdDriver.cpp llvm/include/llvm/Option/OptParser.td llvm/include/llvm/Option/OptTable.h llvm/include/llvm/Option/Option.h llvm/lib/Option/OptTable.cpp llvm/lib/Option/Option.cpp llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp llvm/tools/llvm-cvtres/llvm-cvtres.cpp llvm/unittests/Option/OptionParsingTest.cpp llvm/utils/TableGen/OptParserEmitter.cpp Index: llvm/utils/TableGen/OptParserEmitter.cpp === --- llvm/utils/TableGen/OptParserEmitter.cpp +++ llvm/utils/TableGen/OptParserEmitter.cpp @@ -196,6 +196,9 @@ OS << ", nullptr"; // The option meta-variable name (unused). +OS << ", nullptr"; + +// The option Values (unused for groups). OS << ", nullptr)\n"; } OS << "\n"; @@ -285,6 +288,13 @@ else OS << "nullptr"; +// The option Values. Used for shell autocompletion. +OS << ", "; +if (!isa(R.getValueInit("Values"))) + write_cstring(OS, R.getValueAsString("Values")); +else + OS << "nullptr"; + OS << ")\n"; } OS << "#endif // OPTION\n"; Index: llvm/unittests/Option/OptionParsingTest.cpp === --- llvm/unittests/Option/OptionParsingTest.cpp +++ llvm/unittests/Option/OptionParsingTest.cpp @@ -18,8 +18,9 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) OPT_##ID, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + OPT_##ID, #include "Opts.inc" LastOption #undef OPTION @@ -36,10 +37,10 @@ }; static const OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ - { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \ -FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS }, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + {PREFIX, NAME, HELPTEXT,METAVAR, OPT_##ID, Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp === --- llvm/tools/llvm-cvtres/llvm-cvtres.cpp +++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp @@ -37,7 +37,7 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ OPT_##ID, #include "Opts.inc" #undef OPTION @@ -49,12 +49,12 @@ static const opt::OptTable::Info InfoTable[] = { #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ {\ - PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, opt::Option::KIND##Class, \ - PARAM, FLAGS,OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS}, + PREFIX, NAME, HELPTEXT,\ + METAVAR, OPT_##ID, opt::Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, \ + OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp === --- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -31,7 +31,7 @@ enum { OPT_INVALID = 0, -#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID, +#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID, #include "Options.inc" #undef OPTION }; @@ -41,11 +41,9 @@ #undef PREFIX static const llvm::opt::OptTabl
[PATCH] D33383: [GSoC] Flag value completion for clang
yamaguchi updated this revision to Diff 102961. yamaguchi added a comment. Made trivial change. https://reviews.llvm.org/D33383 Files: clang/include/clang/Driver/Options.h clang/include/clang/Driver/Options.td clang/lib/Driver/Driver.cpp clang/lib/Driver/DriverOptions.cpp clang/test/Driver/autocomplete.c clang/utils/bash-autocomplete.sh lld/COFF/Driver.h lld/COFF/DriverUtils.cpp lld/ELF/Driver.h lld/ELF/DriverUtils.cpp lld/lib/Driver/DarwinLdDriver.cpp llvm/include/llvm/Option/OptParser.td llvm/include/llvm/Option/OptTable.h llvm/include/llvm/Option/Option.h llvm/lib/Option/OptTable.cpp llvm/lib/Option/Option.cpp llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp llvm/tools/llvm-cvtres/llvm-cvtres.cpp llvm/unittests/Option/OptionParsingTest.cpp llvm/utils/TableGen/OptParserEmitter.cpp Index: llvm/utils/TableGen/OptParserEmitter.cpp === --- llvm/utils/TableGen/OptParserEmitter.cpp +++ llvm/utils/TableGen/OptParserEmitter.cpp @@ -196,6 +196,9 @@ OS << ", nullptr"; // The option meta-variable name (unused). +OS << ", nullptr"; + +// The option Values (unused for groups). OS << ", nullptr)\n"; } OS << "\n"; @@ -285,6 +288,13 @@ else OS << "nullptr"; +// The option Values. Used for shell autocompletion. +OS << ", "; +if (!isa(R.getValueInit("Values"))) + write_cstring(OS, R.getValueAsString("Values")); +else + OS << "nullptr"; + OS << ")\n"; } OS << "#endif // OPTION\n"; Index: llvm/unittests/Option/OptionParsingTest.cpp === --- llvm/unittests/Option/OptionParsingTest.cpp +++ llvm/unittests/Option/OptionParsingTest.cpp @@ -18,8 +18,9 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) OPT_##ID, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + OPT_##ID, #include "Opts.inc" LastOption #undef OPTION @@ -36,10 +37,10 @@ }; static const OptTable::Info InfoTable[] = { -#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ - { PREFIX, NAME, HELPTEXT, METAVAR, OPT_##ID, Option::KIND##Class, PARAM, \ -FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS }, +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, ARGVALUE)\ + {PREFIX, NAME, HELPTEXT,METAVAR, OPT_##ID, Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/tools/llvm-cvtres/llvm-cvtres.cpp === --- llvm/tools/llvm-cvtres/llvm-cvtres.cpp +++ llvm/tools/llvm-cvtres/llvm-cvtres.cpp @@ -37,7 +37,7 @@ enum ID { OPT_INVALID = 0, // This is not an option ID. #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ OPT_##ID, #include "Opts.inc" #undef OPTION @@ -49,12 +49,12 @@ static const opt::OptTable::Info InfoTable[] = { #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ - HELPTEXT, METAVAR) \ + HELPTEXT, METAVAR, ARGVALUE)\ {\ - PREFIX, NAME, HELPTEXT, \ - METAVAR, OPT_##ID, opt::Option::KIND##Class, \ - PARAM, FLAGS,OPT_##GROUP, \ - OPT_##ALIAS, ALIASARGS}, + PREFIX, NAME, HELPTEXT,\ + METAVAR, OPT_##ID, opt::Option::KIND##Class,\ + PARAM, FLAGS, OPT_##GROUP, \ + OPT_##ALIAS, ALIASARGS, ARGVALUE}, #include "Opts.inc" #undef OPTION }; Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp === --- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -31,7 +31,7 @@ enum { OPT_INVALID = 0, -#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID, +#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID, #include "Options.inc" #undef OPTION }; @@ -41,11 +41,9 @@ #undef PREFIX static const llvm::opt::OptTable