r338503 - [Modules] Do not emit relocation error when -fno-validate-pch is set
Author: yamaguchi Date: Wed Aug 1 02:50:02 2018 New Revision: 338503 URL: http://llvm.org/viewvc/llvm-project?rev=338503&view=rev Log: [Modules] Do not emit relocation error when -fno-validate-pch is set Summary: Clang emits error when implicit modules was relocated from the first build directory. However this was biting our usecase where we copy the contents of build directory to another directory in order to distribute. Differential Revision: https://reviews.llvm.org/D49852 Modified: cfe/trunk/lib/Serialization/ASTReader.cpp cfe/trunk/test/Modules/resolution-change.m Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=338503&r1=338502&r2=338503&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Aug 1 02:50:02 2018 @@ -2632,7 +2632,9 @@ ASTReader::ReadControlBlock(ModuleFile & if (M && M->Directory) { // If we're implicitly loading a module, the base directory can't // change between the build and use. -if (F.Kind != MK_ExplicitModule && F.Kind != MK_PrebuiltModule) { +// Don't emit module relocation error if we have -fno-validate-pch +if (!PP.getPreprocessorOpts().DisablePCHValidation && +F.Kind != MK_ExplicitModule && F.Kind != MK_PrebuiltModule) { const DirectoryEntry *BuildDir = PP.getFileManager().getDirectory(Blob); if (!BuildDir || BuildDir != M->Directory) { @@ -3602,7 +3604,8 @@ ASTReader::ReadModuleMapFileBlock(Record Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName); auto &Map = PP.getHeaderSearchInfo().getModuleMap(); const FileEntry *ModMap = M ? Map.getModuleMapFileForUniquing(M) : nullptr; -if (!ModMap) { +// Don't emit module relocation error if we have -fno-validate-pch +if (!PP.getPreprocessorOpts().DisablePCHValidation && !ModMap) { assert(ImportedBy && "top-level import should be verified"); if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) { if (auto *ASTFE = M ? M->getASTFile() : nullptr) { @@ -5039,7 +5042,9 @@ ASTReader::ReadSubmoduleBlock(ModuleFile if (!ParentModule) { if (const FileEntry *CurFile = CurrentModule->getASTFile()) { - if (CurFile != F.File) { + // Don't emit module relocation error if we have -fno-validate-pch + if (!PP.getPreprocessorOpts().DisablePCHValidation && + CurFile != F.File) { if (!Diags.isDiagnosticInFlight()) { Diag(diag::err_module_file_conflict) << CurrentModule->getTopLevelModuleName() Modified: cfe/trunk/test/Modules/resolution-change.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/resolution-change.m?rev=338503&r1=338502&r2=338503&view=diff == --- cfe/trunk/test/Modules/resolution-change.m (original) +++ cfe/trunk/test/Modules/resolution-change.m Wed Aug 1 02:50:02 2018 @@ -21,6 +21,8 @@ // RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path2/A -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-WRONGA %s // CHECK-WRONGA: module 'A' was built in directory '{{.*Inputs.modules-with-same-name.path1.A}}' but now resides in directory '{{.*Inputs.modules-with-same-name.path2.A}}' +// RUN: %clang_cc1 -fno-validate-pch -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path2/A -include-pch %t-A.pch %s -fsyntax-only + #ifndef HEADER #define HEADER @import DependsOnA; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305392 - Be more strict when checking the -flto option value
Author: yamaguchi Date: Wed Jun 14 10:37:11 2017 New Revision: 305392 URL: http://llvm.org/viewvc/llvm-project?rev=305392&view=rev Log: Be more strict when checking the -flto option value Summary: It seems -flto must be either "thin" or "full". I think the use of containValue is just a typo. Reviewers: ruiu, tejohnson Subscribers: mehdi_amini, inglorion Differential Revision: https://reviews.llvm.org/D34055 Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGen/thinlto-backend-option.ll Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=305392&r1=305391&r2=305392&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Jun 14 10:37:11 2017 @@ -649,8 +649,14 @@ static bool ParseCodeGenArgs(CodeGenOpti Opts.NoUseJumpTables = Args.hasArg(OPT_fno_jump_tables); Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ); - const Arg *A = Args.getLastArg(OPT_flto, OPT_flto_EQ); - Opts.EmitSummaryIndex = A && A->containsValue("thin"); + Opts.EmitSummaryIndex = false; + if (Arg *A = Args.getLastArg(OPT_flto_EQ)) { +StringRef S = A->getValue(); +if (S == "thin") + Opts.EmitSummaryIndex = true; +else if (S != "full") + Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S; + } Opts.LTOUnit = Args.hasFlag(OPT_flto_unit, OPT_fno_lto_unit, false); if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) { if (IK.getLanguage() != InputKind::LLVM_IR) Modified: cfe/trunk/test/CodeGen/thinlto-backend-option.ll URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-backend-option.ll?rev=305392&r1=305391&r2=305392&view=diff == --- cfe/trunk/test/CodeGen/thinlto-backend-option.ll (original) +++ cfe/trunk/test/CodeGen/thinlto-backend-option.ll Wed Jun 14 10:37:11 2017 @@ -8,6 +8,8 @@ ; RUN: %clang -flto=thin -c -o %t.o %s ; RUN: llvm-lto -thinlto -o %t %t.o -; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option -nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s +; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -backend-option -nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN +; UNKNOWN: clang: Unknown command line argument '-nonexistent' -; CHECK: clang: Unknown command line argument '-nonexistent' +; RUN: not %clang_cc1 -flto=thinfoo 2>&1 | FileCheck %s -check-prefix=INVALID +; INVALID: error: invalid value 'thinfoo' in '-flto=thinfoo' ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305561 - Fix a bug that warnings generated with -M or -MM flags
Author: yamaguchi Date: Fri Jun 16 11:01:13 2017 New Revision: 305561 URL: http://llvm.org/viewvc/llvm-project?rev=305561&view=rev Log: Fix a bug that warnings generated with -M or -MM flags This is a patch for bug: https://bugs.llvm.org/show_bug.cgi?id=6817 Warnings should not be emitted with -M and -MM flags, because this mode is only used for generate MakeFiles. Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/test/Driver/m_and_mm.c Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=305561&r1=305560&r2=305561&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Jun 16 11:01:13 2017 @@ -980,6 +980,9 @@ void Clang::AddPreprocessingOptions(Comp DepTarget = Args.MakeArgString(llvm::sys::path::filename(P)); } + if (!A->getOption().matches(options::OPT_MD) && !A->getOption().matches(options::OPT_MMD)) { +CmdArgs.push_back("-w"); + } CmdArgs.push_back("-MT"); SmallString<128> Quoted; QuoteTarget(DepTarget, Quoted); Modified: cfe/trunk/test/Driver/m_and_mm.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/m_and_mm.c?rev=305561&r1=305560&r2=305561&view=diff == --- cfe/trunk/test/Driver/m_and_mm.c (original) +++ cfe/trunk/test/Driver/m_and_mm.c Fri Jun 16 11:01:13 2017 @@ -1,3 +1,15 @@ // RUN: %clang -### \ // RUN: -M -MM %s 2> %t // RUN: not grep '"-sys-header-deps"' %t + +// RUN: %clang -M -MM %s 2> %t +// RUN: not grep "warning" %t + +// RUN: %clang -MMD -MD %s 2> %t +// RUN: grep "warning" %t + +#warning "This warning shouldn't show up with -M and -MM" +int main (void) +{ +return 0; +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r305805 - [GSoC] Flag value completion for clang
Author: yamaguchi Date: Tue Jun 20 11:31:31 2017 New Revision: 305805 URL: http://llvm.org/viewvc/llvm-project?rev=305805&view=rev Log: [GSoC] Flag value completion for clang This is patch for GSoC project, bash-completion for clang. To use this on bash, please run `source clang/utils/bash-autocomplete.sh`. bash-autocomplete.sh is code for bash-completion. In this patch, Options.td was mainly changed in order to add value class in Options.inc. Modified: cfe/trunk/include/clang/Driver/Options.h cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/DriverOptions.cpp cfe/trunk/test/Driver/autocomplete.c cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/include/clang/Driver/Options.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.h?rev=305805&r1=305804&r2=305805&view=diff == --- cfe/trunk/include/clang/Driver/Options.h (original) +++ cfe/trunk/include/clang/Driver/Options.h Tue Jun 20 11:31:31 2017 @@ -39,8 +39,9 @@ enum ClangFlags { 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, VALUES) \ + OPT_##ID, #include "clang/Driver/Options.inc" LastOption #undef OPTION Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=305805&r1=305804&r2=305805&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue Jun 20 11:31:31 2017 @@ -493,7 +493,7 @@ def cl_mad_enable : Flag<["-"], "cl-mad- def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, Group, Flags<[CC1Option]>, HelpText<"OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.">; def cl_std_EQ : Joined<["-"], "cl-std=">, Group, Flags<[CC1Option]>, - HelpText<"OpenCL language standard to compile for.">; + HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0">; def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, Group, Flags<[CC1Option]>, HelpText<"OpenCL only. Allow denormals to be flushed to zero.">; def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], "cl-fp32-correctly-rounded-divide-sqrt">, Group, Flags<[CC1Option]>, @@ -804,7 +804,7 @@ def fno_sanitize_coverage : CommaJoined<["-"], "fno-sanitize-coverage=">, Group, Flags<[CoreOption, DriverOption]>, HelpText<"Disable specified features of coverage instrumentation for " - "Sanitizers">; + "Sanitizers">, Values<"func,bb,edge,indirect-calls,trace-bb,trace-cmp,trace-div,trace-gep,8bit-counters,trace-pc,trace-pc-guard,no-prune,inline-8bit-counters">; def fsanitize_memory_track_origins_EQ : Joined<["-"], "fsanitize-memory-track-origins=">, Group, HelpText<"Enable origins tracking in MemorySanitizer">; @@ -923,7 +923,7 @@ def ftrapping_math : Flag<["-"], "ftrapp def fno_trapping_math : Flag<["-"], "fno-trapping-math">, Group, Flags<[CC1Option]>; def ffp_contract : Joined<["-"], "ffp-contract=">, Group, Flags<[CC1Option]>, HelpText<"Form fused FP ops (e.g. FMAs): fast (everywhere)" - " | on (according to FP_CONTRACT pragma, default) | off (never fuse)">; + " | on (according to FP_CONTRACT pragma, default) | off (never fuse)">, Values<"fast,on,off">; def ffor_scope : Flag<["-"], "ffor-scope">, Group; def fno_for_scope : Flag<["-"], "fno-for-scope">, Group; @@ -1000,7 +1000,7 @@ def flat__namespace : Flag<["-"], "flat_ def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, Group; def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, Group; def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, Group, - HelpText<"Set LTO mode to either 'full' or 'thin'">; + HelpText<"Set LTO mode to either 'full' or 'thin'">, Values<"thin,full">; def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group, HelpText<"Enable LTO in 'full' mode">; def fno_lto : Flag<["-"], "fno-lto">, Group, @@ -1158,7 +1158,7 @@ def fno_experimental_new_pass_manager : Group, Flags<[CC1Option]>, HelpText<"Disables an experimental new pass manager in LLVM.">; def fveclib : Joined<["-"], "fveclib=">, Group, Flags<[CC1Option]>, -HelpText<"Use the given vector functions library">; +HelpText<"Use the given vector functions library">, Values<"Accelerate,SVML,none">; def fno_lax_vector_conversions : Flag<["-"],
r306127 - [GSoC] Add support for CC1 options.
Author: yamaguchi Date: Fri Jun 23 12:05:50 2017 New Revision: 306127 URL: http://llvm.org/viewvc/llvm-project?rev=306127&view=rev Log: [GSoC] Add support for CC1 options. Summary: Add value completion support for options which are defined in CC1Options.td, because we only handled options in Options.td. Reviewers: ruiu, v.g.vassilev, teemperor Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34558 Modified: cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=306127&r1=306126&r2=306127&view=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Jun 23 12:05:50 2017 @@ -158,7 +158,7 @@ def msave_temp_labels : Flag<["-"], "msa "Note this may change .s semantics and shouldn't generally be used " "on compiler-generated code.">; def mrelocation_model : Separate<["-"], "mrelocation-model">, - HelpText<"The relocation model to use">; + HelpText<"The relocation model to use">, Values<"static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic">; def fno_math_builtin : Flag<["-"], "fno-math-builtin">, HelpText<"Disable implicit builtin knowledge of math functions">; } @@ -229,7 +229,7 @@ def no_struct_path_tbaa : Flag<["-"], "n def masm_verbose : Flag<["-"], "masm-verbose">, HelpText<"Generate verbose assembly output">; def mcode_model : Separate<["-"], "mcode-model">, - HelpText<"The code model to use">; + HelpText<"The code model to use">, Values<"small,kernel,medium,large">; def mdebug_pass : Separate<["-"], "mdebug-pass">, HelpText<"Enable additional debug output">; def mdisable_fp_elim : Flag<["-"], "mdisable-fp-elim">, @@ -308,7 +308,7 @@ def fsanitize_coverage_no_prune HelpText<"Disable coverage pruning (i.e. instrument all blocks/edges)">; def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">, HelpText<"Enable PGO instrumentation. The accepted value is clang, llvm, " - "or none">; + "or none">, Values<"none,clang,llvm">; def fprofile_instrument_path_EQ : Joined<["-"], "fprofile-instrument-path=">, HelpText<"Generate instrumented code to collect execution counts into " " (overridden by LLVM_PROFILE_FILE env var)">; @@ -348,9 +348,9 @@ def diagnostic_serialized_file : Separat HelpText<"File for serializing diagnostics in a binary format">; def fdiagnostics_format : Separate<["-"], "fdiagnostics-format">, - HelpText<"Change diagnostic formatting to match IDE and command line tools">; + HelpText<"Change diagnostic formatting to match IDE and command line tools">, Values<"clang,msvc,msvc-fallback,vi">; def fdiagnostics_show_category : Separate<["-"], "fdiagnostics-show-category">, - HelpText<"Print diagnostic category">; + HelpText<"Print diagnostic category">, Values<"none,id,name">; def fno_diagnostics_use_presumed_location : Flag<["-"], "fno-diagnostics-use-presumed-location">, HelpText<"Ignore #line directives when displaying diagnostic locations">; def ftabstop : Separate<["-"], "ftabstop">, MetaVarName<"">, @@ -595,11 +595,11 @@ def fconstant_string_class : Separate<[" MetaVarName<"">, HelpText<"Specify the class to use for constant Objective-C string objects.">; def fobjc_arc_cxxlib_EQ : Joined<["-"], "fobjc-arc-cxxlib=">, - HelpText<"Objective-C++ Automatic Reference Counting standard library kind">; + HelpText<"Objective-C++ Automatic Reference Counting standard library kind">, Values<"libc++,libstdc++,none">; def fobjc_runtime_has_weak : Flag<["-"], "fobjc-runtime-has-weak">, HelpText<"The target Objective-C runtime supports ARC weak operations">; def fobjc_dispatch_method_EQ : Joined<["-"], "fobjc-dispatch-method=">, - HelpText<"Objective-C dispatch method to use">; + HelpText<"Objective-C dispatch method to use">, Values<"legacy,non-legacy,mixed">; def disable_objc_default_synthesize_properties : Flag<["-"], "disable-objc-default-synthesize-properties">, HelpText<"disable the default synthesis of Objective-C properties">; def fencode_extended_block_signature : Flag<["-"], "fencode-extended-block-signature">, @@ -673,7 +673,7 @@ def fnative_half_arguments_and_returns : def fallow_half_arguments_and_returns : Flag<["-"], "fallow-half-arguments-and-returns">, HelpText<"Allow function arguments and returns of type half">; def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">, - HelpText<"Set default MS calling convention">; + HelpText<"Set default MS calling convention">, Values<"cdecl,fastcall,stdcall,vectorcall">; def finclude_default_header : Flag<["-"], "finclude-default-header">, HelpText<"Include the default header file for OpenCL">; def fpreserve_vec3_type : Flag<["-"], "f
r306258 - [bash-autocompletion] Delete space after flags which has '=' prefix
Author: yamaguchi Date: Sun Jun 25 17:35:36 2017 New Revision: 306258 URL: http://llvm.org/viewvc/llvm-project?rev=306258&view=rev Log: [bash-autocompletion] Delete space after flags which has '=' prefix Summary: This is patch for bash completion for clang project. We don't need space when completing options like "-stdlib=". Differential Revision: https://reviews.llvm.org/D34594 Modified: cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=306258&r1=306257&r2=306258&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Sun Jun 25 17:35:36 2017 @@ -22,16 +22,17 @@ _clang() elif [[ "$w2" == -* && "$w1" == '=' ]]; then # -foo=bar arg="$w2=,$cur" - else -_filedir fi local flags=$( clang --autocomplete="$arg" ) - if [[ "$cur" == "=" ]]; then + if [[ "$cur" == '=' ]]; then COMPREPLY=( $( compgen -W "$flags" -- "") ) - elif [[ "$flags" == "" ]]; then + elif [[ "$flags" == "" || "$arg" == "" ]]; then _filedir else +# Bash automatically appends a space after '=' by default. +# Disable it so that it works nicely for options in the form of -foo=bar. +[[ "${flags: -1}" == '=' ]] && compopt -o nospace COMPREPLY=( $( compgen -W "$flags" -- "$cur" ) ) fi } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326684 - [Bash-autocompletion] Pass all flags in shell command-line to Clang
Author: yamaguchi Date: Mon Mar 5 00:54:20 2018 New Revision: 326684 URL: http://llvm.org/viewvc/llvm-project?rev=326684&view=rev Log: [Bash-autocompletion] Pass all flags in shell command-line to Clang Previously, we passed "#" to --autocomplete to indicate to enable cc1 flags. For example, when -cc1 or -Xclang was passed to bash, bash executed `clang --autocomplete=#-`. However, this was not a good implementation because it depends -Xclang and -cc1 parsing to shell. So I changed this to pass all flags shell has, so that Clang can handle them internally. I had to change many testcases because API spec changed quite a lot. Reviewers: teemperor, v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39342 Modified: cfe/trunk/include/clang/Driver/Driver.h cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/test/Driver/autocomplete.c cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/include/clang/Driver/Driver.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=326684&r1=326683&r2=326684&view=diff == --- cfe/trunk/include/clang/Driver/Driver.h (original) +++ cfe/trunk/include/clang/Driver/Driver.h Mon Mar 5 00:54:20 2018 @@ -442,9 +442,9 @@ public: // FIXME: This should be in CompilationInfo. std::string GetProgramPath(StringRef Name, const ToolChain &TC) const; - /// handleAutocompletions - Handle --autocomplete by searching and printing + /// HandleAutocompletions - Handle --autocomplete by searching and printing /// possible flags, descriptions, and its arguments. - void handleAutocompletions(StringRef PassedFlags) const; + void HandleAutocompletions(StringRef PassedFlags) const; /// HandleImmediateArgs - Handle any arguments which should be /// treated before building actions or binding tools. Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=326684&r1=326683&r2=326684&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Mon Mar 5 00:54:20 2018 @@ -1419,44 +1419,56 @@ static void PrintDiagnosticCategories(ra OS << i << ',' << DiagnosticIDs::getCategoryNameFromID(i) << '\n'; } -void Driver::handleAutocompletions(StringRef PassedFlags) const { +void Driver::HandleAutocompletions(StringRef PassedFlags) const { + if (PassedFlags == "") return; // Print out all options that start with a given argument. This is used for // shell autocompletion. std::vector SuggestedCompletions; + std::vector Flags; unsigned short DisableFlags = options::NoDriverOption | options::Unsupported | options::Ignored; - // We want to show cc1-only options only when clang is invoked as "clang - // -cc1". When clang is invoked as "clang -cc1", we add "#" to the beginning - // of an --autocomplete option so that the clang driver can distinguish - // whether it is requested to show cc1-only options or not. - if (PassedFlags.size() > 0 && PassedFlags[0] == '#') { + + // Parse PassedFlags by "," as all the command-line flags are passed to this + // function separated by "," + StringRef TargetFlags = PassedFlags; + while (TargetFlags != "") { +StringRef CurFlag; +std::tie(CurFlag, TargetFlags) = TargetFlags.split(","); +Flags.push_back(std::string(CurFlag)); + } + + // We want to show cc1-only options only when clang is invoked with -cc1 or + // -Xclang. + if (std::find(Flags.begin(), Flags.end(), "-Xclang") != Flags.end() || std::find(Flags.begin(), Flags.end(), "-cc1") != Flags.end()) DisableFlags &= ~options::NoDriverOption; -PassedFlags = PassedFlags.substr(1); + + StringRef Cur; + Cur = Flags.at(Flags.size() - 1); + StringRef Prev; + if (Flags.size() >= 2) { +Prev = Flags.at(Flags.size() - 2); +SuggestedCompletions = Opts->suggestValueCompletions(Prev, Cur); } - if (PassedFlags.find(',') == StringRef::npos) { + if (SuggestedCompletions.empty()) +SuggestedCompletions = Opts->suggestValueCompletions(Cur, ""); + + if (SuggestedCompletions.empty()) { // If the flag is in the form of "--autocomplete=-foo", // we were requested to print out all option names that start with "-foo". // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only". -SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags); +SuggestedCompletions = Opts->findByPrefix(Cur, DisableFlags); // We have to query the -W flags manually as they're not in the OptTable. // TODO: Find a good way to add them to OptTable instead and them remove // this code. for (StringRef S : DiagnosticIDs::getDiagnosticFlags()) - if (S.startswith(PassedFlags)) + if (S.startswith(Cur)) SuggestedCompletions.push_back(S); - } else { -// If the flag
r326685 - [Bash-autocompletion] Fixed formatting
Author: yamaguchi Date: Mon Mar 5 01:01:31 2018 New Revision: 326685 URL: http://llvm.org/viewvc/llvm-project?rev=326685&view=rev Log: [Bash-autocompletion] Fixed formatting Fixed a trivial formatting and indent. Modified: cfe/trunk/lib/Driver/Driver.cpp Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=326685&r1=326684&r2=326685&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Mon Mar 5 01:01:31 2018 @@ -1420,7 +1420,8 @@ static void PrintDiagnosticCategories(ra } void Driver::HandleAutocompletions(StringRef PassedFlags) const { - if (PassedFlags == "") return; + if (PassedFlags == "") +return; // Print out all options that start with a given argument. This is used for // shell autocompletion. std::vector SuggestedCompletions; @@ -1440,7 +1441,8 @@ void Driver::HandleAutocompletions(Strin // We want to show cc1-only options only when clang is invoked with -cc1 or // -Xclang. - if (std::find(Flags.begin(), Flags.end(), "-Xclang") != Flags.end() || std::find(Flags.begin(), Flags.end(), "-cc1") != Flags.end()) + if (std::find(Flags.begin(), Flags.end(), "-Xclang") != Flags.end() || + std::find(Flags.begin(), Flags.end(), "-cc1") != Flags.end()) DisableFlags &= ~options::NoDriverOption; StringRef Cur; @@ -1468,7 +1470,6 @@ void Driver::HandleAutocompletions(Strin SuggestedCompletions.push_back(S); } - // Sort the autocomplete candidates so that shells print them out in a // deterministic order. We could sort in any way, but we chose // case-insensitive sorting for consistency with the -help option ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r326889 - Add Clang ReleaseNotes that --autocomplete breaks backward compatibily
Author: yamaguchi Date: Wed Mar 7 03:34:02 2018 New Revision: 326889 URL: http://llvm.org/viewvc/llvm-project?rev=326889&view=rev Log: Add Clang ReleaseNotes that --autocomplete breaks backward compatibily Summary: --autocomplete flag now handles all the flags passed to shell, and this implementation breaks backward compatibily before Clang 6.0. Reviewers: teemperor, v.g.vassilev Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D44191 Modified: cfe/trunk/docs/ReleaseNotes.rst Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=326889&r1=326888&r2=326889&view=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Wed Mar 7 03:34:02 2018 @@ -71,6 +71,15 @@ future versions of Clang. - ... +Modified Compiler Flags +--- + +- Before Clang 7.0, we prepended the "#" character to the --autocomplete argument to +enable cc1 flags. For example, when the -cc1 or -Xclang flag is in the clang invocation, +the shell executed clang --autocomplete=#-. Clang 7.0 now +requires the whole invocation including all flags to be passed to the --autocomplete +like this: clang --autocomplete=-cc1,-xc++,-fsyn. + New Pragmas in Clang --- ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r345121 - [bash-autocompletion] Fix bug when a flag ends with '='
Author: yamaguchi Date: Wed Oct 24 01:24:16 2018 New Revision: 345121 URL: http://llvm.org/viewvc/llvm-project?rev=345121&view=rev Log: [bash-autocompletion] Fix bug when a flag ends with '=' There was a bug that when a flag ends with '=' and no value was suggested, clang autocompletes the flag itself. For example, in bash, it looked like this: ``` $ clang -fmodule-file=[tab] -> $clang -fmodule-file=-fmodule-file ``` This is not what we expect. We expect a file autocompletion when no value was found. With this patch, pressing tab suggests files in the current directory. Reviewers: teemperor, ruiu Subscribers: cfe-commits Modified: cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=345121&r1=345120&r2=345121&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Wed Oct 24 01:24:16 2018 @@ -1534,7 +1534,9 @@ void Driver::HandleAutocompletions(Strin if (SuggestedCompletions.empty()) SuggestedCompletions = Opts->suggestValueCompletions(Cur, ""); - if (SuggestedCompletions.empty()) { + // When flag ends with '=' and there was no value completion, return empty + // string and fall back to the file autocompletion. + if (SuggestedCompletions.empty() && !Cur.endswith("=")) { // If the flag is in the form of "--autocomplete=-foo", // we were requested to print out all option names that start with "-foo". // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only". Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=345121&r1=345120&r2=345121&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Wed Oct 24 01:24:16 2018 @@ -115,3 +115,9 @@ // Check if they can autocomplete values with coron // RUN: %clang --autocomplete=foo,bar,,,-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER-CORON // FNOSANICOVER-CORON: func + +// Clang should return empty string when no value completion was found, which will fall back to file autocompletion +// RUN: %clang --autocomplete=-fmodule-file= | FileCheck %s -check-prefix=MODULE_FILE_EQUAL +// MODULE_FILE_EQUAL-NOT: -fmodule-file= +// RUN: %clang --autocomplete=-fmodule-file | FileCheck %s -check-prefix=MODULE_FILE +// MODULE_FILE: -fmodule-file= ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r345133 - [autocompletion] Handle the space before pressing tab
Author: yamaguchi Date: Wed Oct 24 05:43:25 2018 New Revision: 345133 URL: http://llvm.org/viewvc/llvm-project?rev=345133&view=rev Log: [autocompletion] Handle the space before pressing tab Summary: Distinguish "--autocomplete=-someflag" and "--autocomplete=-someflag," because the latter indicates that the user put a space before pushing tab which should end up in a file completion. Differential Revision: https://reviews.llvm.org/D53639 Modified: cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=345133&r1=345132&r2=345133&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Wed Oct 24 05:43:25 2018 @@ -1508,6 +1508,11 @@ void Driver::HandleAutocompletions(Strin unsigned short DisableFlags = options::NoDriverOption | options::Unsupported | options::Ignored; + // Distinguish "--autocomplete=-someflag" and "--autocomplete=-someflag," + // because the latter indicates that the user put space before pushing tab + // which should end up in a file completion. + const bool HasSpace = PassedFlags.endswith(","); + // Parse PassedFlags by "," as all the command-line flags are passed to this // function separated by "," StringRef TargetFlags = PassedFlags; @@ -1534,6 +1539,16 @@ void Driver::HandleAutocompletions(Strin if (SuggestedCompletions.empty()) SuggestedCompletions = Opts->suggestValueCompletions(Cur, ""); + // If Flags were empty, it means the user typed `clang [tab]` where we should + // list all possible flags. If there was no value completion and the user + // pressed tab after a space, we should fall back to a file completion. + // We're printing a newline to be consistent with what we print at the end of + // this function. + if (SuggestedCompletions.empty() && HasSpace && !Flags.empty()) { +llvm::outs() << '\n'; +return; + } + // When flag ends with '=' and there was no value completion, return empty // string and fall back to the file autocompletion. if (SuggestedCompletions.empty() && !Cur.endswith("=")) { Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=345133&r1=345132&r2=345133&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Wed Oct 24 05:43:25 2018 @@ -25,6 +25,7 @@ // STDLIBALL-NEXT: platform // RUN: %clang --autocomplete=-meabi,d | FileCheck %s -check-prefix=MEABI // MEABI: default +// RUN: %clang --autocomplete=-meabi, | FileCheck %s -check-prefix=MEABIALL // RUN: %clang --autocomplete=-meabi | FileCheck %s -check-prefix=MEABIALL // MEABIALL: 4 // MEABIALL-NEXT: 5 @@ -121,3 +122,8 @@ // MODULE_FILE_EQUAL-NOT: -fmodule-file= // RUN: %clang --autocomplete=-fmodule-file | FileCheck %s -check-prefix=MODULE_FILE // MODULE_FILE: -fmodule-file= + +// RUN: %clang --autocomplete=-Qunused-arguments, | FileCheck %s -check-prefix=QUNUSED_COMMA +// QUNUSED_COMMA-NOT: -Qunused-arguments +// RUN: %clang --autocomplete=-Qunused-arguments | FileCheck %s -check-prefix=QUNUSED +// QUNUSED: -Qunused-arguments ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311958 - Revert "Revert r311552: [Bash-autocompletion] Add support for static analyzer flags"
Author: yamaguchi Date: Mon Aug 28 17:09:31 2017 New Revision: 311958 URL: http://llvm.org/viewvc/llvm-project?rev=311958&view=rev Log: Revert "Revert r311552: [Bash-autocompletion] Add support for static analyzer flags" This reverts commit 7c46b80c022e18d43c1fdafb117b0c409c5a6d1e. r311552 broke lld buildbot because I've changed OptionInfos type from ArrayRef to vector. However the bug is fixed, so I'll commit this again. Modified: cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/lib/Driver/DriverOptions.cpp cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=311958&r1=311957&r2=311958&view=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Aug 28 17:09:31 2017 @@ -99,7 +99,19 @@ def analyzer_stats : Flag<["-"], "analyz HelpText<"Print internal analyzer statistics.">; def analyzer_checker : Separate<["-"], "analyzer-checker">, - HelpText<"Choose analyzer checkers to enable">; + HelpText<"Choose analyzer checkers to enable">, + ValuesCode<[{ +const char *Values = +#define GET_CHECKERS +#define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H) FULLNAME "," +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" +#undef GET_CHECKERS +#define GET_PACKAGES +#define PACKAGE(FULLNAME, G, D) FULLNAME "," +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" +#undef GET_PACKAGES +; + }]>; def analyzer_checker_EQ : Joined<["-"], "analyzer-checker=">, Alias; Modified: cfe/trunk/lib/Driver/DriverOptions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/DriverOptions.cpp?rev=311958&r1=311957&r2=311958&view=diff == --- cfe/trunk/lib/Driver/DriverOptions.cpp (original) +++ cfe/trunk/lib/Driver/DriverOptions.cpp Mon Aug 28 17:09:31 2017 @@ -11,6 +11,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Option/OptTable.h" #include "llvm/Option/Option.h" +#include using namespace clang::driver; using namespace clang::driver::options; @@ -40,5 +41,13 @@ public: } std::unique_ptr clang::driver::createDriverOptTable() { - return llvm::make_unique(); + auto Result = llvm::make_unique(); + // Options.inc is included in DriverOptions.cpp, and calls OptTable's + // addValues function. + // Opt is a variable used in the code fragment in Options.inc. + OptTable &Opt = *Result; +#define OPTTABLE_ARG_INIT +#include "clang/Driver/Options.inc" +#undef OPTTABLE_ARG_INIT + return std::move(Result); } Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=311958&r1=311957&r2=311958&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Mon Aug 28 17:09:31 2017 @@ -93,3 +93,5 @@ // WARNING-NEXT: -Wmax-unsigned-zero // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING // NOWARNING: -Wno-invalid-pp-token +// RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s -check-prefix=ANALYZER +// ANALYZER: unix.Malloc ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311971 - [Bash-autocompletion] Add support for -std=
Author: yamaguchi Date: Mon Aug 28 19:01:56 2017 New Revision: 311971 URL: http://llvm.org/viewvc/llvm-project?rev=311971&view=rev Log: [Bash-autocompletion] Add support for -std= Summary: Add support for autocompleting values of -std= by including LangStandards.def. This patch relies on D36782, and is using two-stage code generation. Reviewers: v.g.vassilev, teemperor, ruiu Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36820 Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=311971&r1=311970&r2=311971&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Mon Aug 28 19:01:56 2017 @@ -2270,7 +2270,14 @@ def static_libstdcxx : Flag<["-"], "stat def static : Flag<["-", "--"], "static">, Flags<[NoArgumentUnused]>; def std_default_EQ : Joined<["-"], "std-default=">; def std_EQ : Joined<["-", "--"], "std=">, Flags<[CC1Option]>, - Group, HelpText<"Language standard to compile for">; + Group, HelpText<"Language standard to compile for">, + ValuesCode<[{ +const char *Values = +#define LANGSTANDARD(id, name, lang, desc, features) name "," +#define LANGSTANDARD_ALIAS(id, alias) alias "," +#include "clang/Frontend/LangStandards.def" +; + }]>; def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>, HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">; def sub__library : JoinedOrSeparate<["-"], "sub_library">; Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=311971&r1=311970&r2=311971&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Mon Aug 28 19:01:56 2017 @@ -95,3 +95,5 @@ // NOWARNING: -Wno-invalid-pp-token // RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s -check-prefix=ANALYZER // ANALYZER: unix.Malloc +// RUN: %clang --autocomplete=-std=, | FileCheck %s -check-prefix=STDVAL +// STDVAL: c99 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r312018 - [Bash-autocomplete] Refactor autocomplete code into own function
Author: yamaguchi Date: Tue Aug 29 10:46:46 2017 New Revision: 312018 URL: http://llvm.org/viewvc/llvm-project?rev=312018&view=rev Log: [Bash-autocomplete] Refactor autocomplete code into own function Summary: We wrote many codes in HandleImediateArgs, so I've refactored it into handleAutocompletions. Reviewers: v.g.vassilev, teemperor Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D37249 Modified: cfe/trunk/include/clang/Driver/Driver.h cfe/trunk/lib/Driver/Driver.cpp Modified: cfe/trunk/include/clang/Driver/Driver.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=312018&r1=312017&r2=312018&view=diff == --- cfe/trunk/include/clang/Driver/Driver.h (original) +++ cfe/trunk/include/clang/Driver/Driver.h Tue Aug 29 10:46:46 2017 @@ -425,6 +425,10 @@ public: // FIXME: This should be in CompilationInfo. std::string GetProgramPath(StringRef Name, const ToolChain &TC) const; + /// handleAutocompletions - Handle --autocomplete by searching and printing + /// possible flags, descriptions, and its arguments. + void handleAutocompletions(StringRef PassedFlags) const; + /// HandleImmediateArgs - Handle any arguments which should be /// treated before building actions or binding tools. /// Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=312018&r1=312017&r2=312018&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue Aug 29 10:46:46 2017 @@ -1156,6 +1156,56 @@ static void PrintDiagnosticCategories(ra OS << i << ',' << DiagnosticIDs::getCategoryNameFromID(i) << '\n'; } +void Driver::handleAutocompletions(StringRef PassedFlags) const { + // Print out all options that start with a given argument. This is used for + // shell autocompletion. + std::vector SuggestedCompletions; + + unsigned short DisableFlags = + options::NoDriverOption | options::Unsupported | options::Ignored; + // We want to show cc1-only options only when clang is invoked as "clang + // -cc1". + // When clang is invoked as "clang -cc1", we add "#" to the beginning of an + // --autocomplete + // option so that the clang driver can distinguish whether it is requested to + // show cc1-only options or not. + if (PassedFlags[0] == '#') { +DisableFlags &= ~options::NoDriverOption; +PassedFlags = PassedFlags.substr(1); + } + + if (PassedFlags.find(',') == StringRef::npos) { +// If the flag is in the form of "--autocomplete=-foo", +// we were requested to print out all option names that start with "-foo". +// For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only". +SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags); + +// We have to query the -W flags manually as they're not in the OptTable. +// TODO: Find a good way to add them to OptTable instead and them remove +// this code. +for (StringRef S : DiagnosticIDs::getDiagnosticFlags()) + if (S.startswith(PassedFlags)) +SuggestedCompletions.push_back(S); + } else { +// If the flag is in the form of "--autocomplete=foo,bar", we were +// requested to print out all option values for "-foo" that start with +// "bar". For example, +// "--autocomplete=-stdlib=,l" is expanded to "libc++" and "libstdc++". +StringRef Option, Arg; +std::tie(Option, Arg) = PassedFlags.split(','); +SuggestedCompletions = Opts->suggestValueCompletions(Option, Arg); + } + + // Sort the autocomplete candidates so that shells print them out in a + // deterministic order. We could sort in any way, but we chose + // case-insensitive sorting for consistency with the -help option + // which prints out options in the case-insensitive alphabetical order. + std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(), +[](StringRef A, StringRef B) { return A.compare_lower(B) < 0; }); + + llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n'; +} + bool Driver::HandleImmediateArgs(const Compilation &C) { // The order these options are handled in gcc is all over the place, but we // don't expect inconsistencies w.r.t. that to matter in practice. @@ -1249,50 +1299,8 @@ bool Driver::HandleImmediateArgs(const C } if (Arg *A = C.getArgs().getLastArg(options::OPT_autocomplete)) { -// Print out all options that start with a given argument. This is used for -// shell autocompletion. StringRef PassedFlags = A->getValue(); -std::vector SuggestedCompletions; - -unsigned short DisableFlags = options::NoDriverOption | options::Unsupported | options::Ignored; -// We want to show cc1-only options only when clang is invoked as "clang -cc1". -// When clang is invoked as "clang -cc1", we add "#" t
Re: r311958 - Revert "Revert r311552: [Bash-autocompletion] Add support for static analyzer flags"
Sorry I totally forgot. Taking a look now, I will add you to a reviewer when I have an alternative patch! Thanks for the reminder. On Thu, 20 Dec 2018 at 15:20, Nico Weber wrote: > > Have you had a chance to look at making this change? > > On Mon, Apr 9, 2018 at 9:08 AM Yuka Takahashi wrote: >> >> Sounds good! >> >> 2018-04-09 15:03 GMT+02:00 Nico Weber : >>> >>> Yes. >>> >>> On Mon, Apr 9, 2018 at 9:00 AM, Yuka Takahashi wrote: >>>> >>>> Hi Nico, >>>> >>>> Thanks for your comment! >>>> >>>> I do agree that this code is hacky. Do you mean to ask tablegen to >>>> generate Checkers.inc under Driver so that we can do like this? : >>>> #define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H) FULLNAME "," >>>> #include "clang/Driver/Checkers.inc" >>>> #undef GET_CHECKERS >>>> >>>> Cheers, >>>> Yuka >>>> >>>> 2018-04-07 4:28 GMT+02:00 Nico Weber : >>>>> >>>>> Hi Yuka, >>>>> >>>>> sorry about the late review comment on this. I just happened to see that >>>>> this lets Driver's Option.inc depend on StaticAnalyzer/Checker's >>>>> Checker.inc. However, Driver does not depend on StaticAnalyzer/Checker. >>>>> In practice, it works ok because of all tablegen targets being collected >>>>> into clang-tablegen-targets and driver depending on that >>>>> (http://llvm-cs.pcc.me.uk/tools/clang/CMakeLists.txt#442), but it still >>>>> feels a bit hacky that Driver's tablegen output depends on code generated >>>>> by StaticAnalyzer/Checker. Maybe we should move Checker.td into Driver >>>>> now? >>>>> >>>>> Nico >>>>> >>>>> On Mon, Aug 28, 2017 at 8:09 PM, Yuka Takahashi via cfe-commits >>>>> wrote: >>>>>> >>>>>> Author: yamaguchi >>>>>> Date: Mon Aug 28 17:09:31 2017 >>>>>> New Revision: 311958 >>>>>> >>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=311958&view=rev >>>>>> Log: >>>>>> Revert "Revert r311552: [Bash-autocompletion] Add support for static >>>>>> analyzer flags" >>>>>> >>>>>> This reverts commit 7c46b80c022e18d43c1fdafb117b0c409c5a6d1e. >>>>>> >>>>>> r311552 broke lld buildbot because I've changed OptionInfos type from >>>>>> ArrayRef to vector. However the bug is fixed, so I'll commit this again. >>>>>> >>>>>> Modified: >>>>>> cfe/trunk/include/clang/Driver/CC1Options.td >>>>>> cfe/trunk/lib/Driver/DriverOptions.cpp >>>>>> cfe/trunk/test/Driver/autocomplete.c >>>>>> >>>>>> Modified: cfe/trunk/include/clang/Driver/CC1Options.td >>>>>> URL: >>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=311958&r1=311957&r2=311958&view=diff >>>>>> == >>>>>> --- cfe/trunk/include/clang/Driver/CC1Options.td (original) >>>>>> +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Aug 28 17:09:31 2017 >>>>>> @@ -99,7 +99,19 @@ def analyzer_stats : Flag<["-"], "analyz >>>>>>HelpText<"Print internal analyzer statistics.">; >>>>>> >>>>>> def analyzer_checker : Separate<["-"], "analyzer-checker">, >>>>>> - HelpText<"Choose analyzer checkers to enable">; >>>>>> + HelpText<"Choose analyzer checkers to enable">, >>>>>> + ValuesCode<[{ >>>>>> +const char *Values = >>>>>> +#define GET_CHECKERS >>>>>> +#define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H) FULLNAME "," >>>>>> +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" >>>>>> +#undef GET_CHECKERS >>>>>> +#define GET_PACKAGES >>>>>> +#define PACKAGE(FULLNAME, G, D) FULLNAME "," >>>>>> +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" >>>>>> +#
r330946 - Add getDeserializationListener to ASTReader
Author: yamaguchi Date: Thu Apr 26 08:09:13 2018 New Revision: 330946 URL: http://llvm.org/viewvc/llvm-project?rev=330946&view=rev Log: Add getDeserializationListener to ASTReader Summary: We need to know if ASTReader already has a DeserializationListner or not, and this also helps to create a multiplexing deserialization listener if there is one already attached. Reviewers: v.g.vassilev, rsmith, dblaikie, thakis Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45921 Modified: cfe/trunk/include/clang/Serialization/ASTReader.h Modified: cfe/trunk/include/clang/Serialization/ASTReader.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=330946&r1=330945&r2=330946&view=diff == --- cfe/trunk/include/clang/Serialization/ASTReader.h (original) +++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Apr 26 08:09:13 2018 @@ -1599,6 +1599,11 @@ public: void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership = false); + /// \brief Get the AST deserialization listener. + ASTDeserializationListener *getDeserializationListener() { +return DeserializationListener; + } + /// \brief Determine whether this AST reader has a global index. bool hasGlobalIndex() const { return (bool)GlobalIndex; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r336660 - [modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts
Author: yamaguchi Date: Tue Jul 10 05:17:34 2018 New Revision: 336660 URL: http://llvm.org/viewvc/llvm-project?rev=336660&view=rev Log: [modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts Summary: Reproducer and errors: https://bugs.llvm.org/show_bug.cgi?id=37878 lookupModule was falling back to loadSubdirectoryModuleMaps when it couldn't find ModuleName in (proper) search paths. This was causing iteration over all files in the search path subdirectories for example "/usr/include/foobar" in bugzilla case. Users don't expect Clang to load modulemaps in subdirectories implicitly, and also the disk access is not cheap. if (AllowExtraModuleMapSearch) true with ObjC with @import ModuleName. Reviewers: rsmith, aprantl, bruno Subscribers: cfe-commits, teemperor, v.g.vassilev Differential Revision: https://reviews.llvm.org/D48367 Added: cfe/trunk/test/Modules/Inputs/autoload-subdirectory/ cfe/trunk/test/Modules/Inputs/autoload-subdirectory/a.h cfe/trunk/test/Modules/Inputs/autoload-subdirectory/b.h cfe/trunk/test/Modules/Inputs/autoload-subdirectory/c.h cfe/trunk/test/Modules/Inputs/autoload-subdirectory/include/ cfe/trunk/test/Modules/Inputs/autoload-subdirectory/include/module.modulemap cfe/trunk/test/Modules/Inputs/autoload-subdirectory/module.modulemap cfe/trunk/test/Modules/autoload-subdirectory.cpp Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h cfe/trunk/lib/Frontend/CompilerInstance.cpp cfe/trunk/lib/Lex/HeaderSearch.cpp cfe/trunk/lib/Serialization/ASTReader.cpp Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=336660&r1=336659&r2=336660&view=diff == --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original) +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jul 10 05:17:34 2018 @@ -529,8 +529,12 @@ public: /// search directories to produce a module definition. If not, this lookup /// will only return an already-known module. /// + /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps + /// in subdirectories. + /// /// \returns The module with the given name. - Module *lookupModule(StringRef ModuleName, bool AllowSearch = true); + Module *lookupModule(StringRef ModuleName, bool AllowSearch = true, + bool AllowExtraModuleMapSearch = false); /// Try to find a module map file in the given directory, returning /// \c nullptr if none is found. @@ -595,8 +599,12 @@ private: /// but for compatibility with some buggy frameworks, additional attempts /// may be made to find the module under a related-but-different search-name. /// + /// \param AllowExtraModuleMapSearch Whether we allow to search modulemaps + /// in subdirectories. + /// /// \returns The module named ModuleName. - Module *lookupModule(StringRef ModuleName, StringRef SearchName); + Module *lookupModule(StringRef ModuleName, StringRef SearchName, + bool AllowExtraModuleMapSearch = false); /// Retrieve a module with the given name, which may be part of the /// given framework. Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=336660&r1=336659&r2=336660&view=diff == --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Jul 10 05:17:34 2018 @@ -1653,8 +1653,10 @@ CompilerInstance::loadModule(SourceLocat // Retrieve the cached top-level module. Module = Known->second; } else if (ModuleName == getLangOpts().CurrentModule) { -// This is the module we're building. -Module = PP->getHeaderSearchInfo().lookupModule(ModuleName); +// This is the module we're building. +Module = PP->getHeaderSearchInfo().lookupModule( +ModuleName, /*AllowSearch*/ true, +/*AllowExtraModuleMapSearch*/ !IsInclusionDirective); /// FIXME: perhaps we should (a) look for a module using the module name // to file map (PrebuiltModuleFiles) and (b) diagnose if still not found? //if (Module == nullptr) { @@ -1666,7 +1668,8 @@ CompilerInstance::loadModule(SourceLocat Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first; } else { // Search for a module with the given name. -Module = PP->getHeaderSearchInfo().lookupModule(ModuleName); +Module = PP->getHeaderSearchInfo().lookupModule(ModuleName, true, +!IsInclusionDirective); HeaderSearchOptions &HSOpts = PP->getHeaderSearchInfo().getHeaderSearchOpts(); @@ -1743,7 +1746,8 @@ CompilerInstance::loadModule(SourceLocat ImportLoc, ARRFlags)) { case ASTR
r309794 - [Bash-autocompletion] Add comment to test so that it is easier to fix
Author: yamaguchi Date: Wed Aug 2 00:20:27 2017 New Revision: 309794 URL: http://llvm.org/viewvc/llvm-project?rev=309794&view=rev Log: [Bash-autocompletion] Add comment to test so that it is easier to fix Summary: clang/test/Driver/autocomplete.c is a test for --autocomplete, and this test might break if people add/modify flags or HelpText. So I've add comment for future developers so that they can fix this file according to the change they had made. Reviewers: v.g.vassilev, teemperor, ruiu Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36209 Modified: cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=309794&r1=309793&r2=309794&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Wed Aug 2 00:20:27 2017 @@ -1,3 +1,7 @@ +// Test for the --autocompletion flag, which is an API used for shell +// autocompletion. You may have to update tests in this file when you +// add/modify flags, change HelpTexts or the values of some flags. + // RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN // FSYN: -fsyntax-only // RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r310700 - [Bash-autocompletion] Add --autocomplete flag to 5.0 release notes
Author: yamaguchi Date: Fri Aug 11 02:44:42 2017 New Revision: 310700 URL: http://llvm.org/viewvc/llvm-project?rev=310700&view=rev Log: [Bash-autocompletion] Add --autocomplete flag to 5.0 release notes Summary: I thought we should add this information to release notes, because we added a new flag to clang driver. Reviewers: v.g.vassilev, teemperor, ruiu Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36567 Modified: cfe/trunk/docs/ReleaseNotes.rst Modified: cfe/trunk/docs/ReleaseNotes.rst URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=310700&r1=310699&r2=310700&view=diff == --- cfe/trunk/docs/ReleaseNotes.rst (original) +++ cfe/trunk/docs/ReleaseNotes.rst Fri Aug 11 02:44:42 2017 @@ -75,7 +75,7 @@ Non-comprehensive list of changes in thi New Compiler Flags -- -The option +- --autocomplete was implemented to obtain a list of flags and its arguments. This is used for shell autocompletion. Deprecated Compiler Flags - ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r311552 - [Bash-autocompletion] Add support for static analyzer flags
Author: yamaguchi Date: Wed Aug 23 06:39:47 2017 New Revision: 311552 URL: http://llvm.org/viewvc/llvm-project?rev=311552&view=rev Log: [Bash-autocompletion] Add support for static analyzer flags Summary: This is a patch for clang autocomplete feature. It will collect values which -analyzer-checker takes, which is defined in clang/StaticAnalyzer/Checkers/Checkers.inc, dynamically. First, from ValuesCode class in Options.td, TableGen will generate C++ code in Options.inc. Options.inc will be included in DriverOptions.cpp, and calls OptTable's addValues function. addValues function will add second argument to Option's Values class. Values contains string like "foo,bar,.." which is handed to Values class in OptTable. Reviewers: v.g.vassilev, teemperor, ruiu Subscribers: hiraditya, cfe-commits Differential Revision: https://reviews.llvm.org/D36782 Modified: cfe/trunk/include/clang/Driver/CC1Options.td cfe/trunk/lib/Driver/DriverOptions.cpp cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/include/clang/Driver/CC1Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=311552&r1=311551&r2=311552&view=diff == --- cfe/trunk/include/clang/Driver/CC1Options.td (original) +++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Aug 23 06:39:47 2017 @@ -99,7 +99,19 @@ def analyzer_stats : Flag<["-"], "analyz HelpText<"Print internal analyzer statistics.">; def analyzer_checker : Separate<["-"], "analyzer-checker">, - HelpText<"Choose analyzer checkers to enable">; + HelpText<"Choose analyzer checkers to enable">, + ValuesCode<[{ +const char *Values = +#define GET_CHECKERS +#define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H) FULLNAME "," +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" +#undef GET_CHECKERS +#define GET_PACKAGES +#define PACKAGE(FULLNAME, G, D) FULLNAME "," +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" +#undef GET_PACKAGES +; + }]>; def analyzer_checker_EQ : Joined<["-"], "analyzer-checker=">, Alias; Modified: cfe/trunk/lib/Driver/DriverOptions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/DriverOptions.cpp?rev=311552&r1=311551&r2=311552&view=diff == --- cfe/trunk/lib/Driver/DriverOptions.cpp (original) +++ cfe/trunk/lib/Driver/DriverOptions.cpp Wed Aug 23 06:39:47 2017 @@ -11,6 +11,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Option/OptTable.h" #include "llvm/Option/Option.h" +#include using namespace clang::driver; using namespace clang::driver::options; @@ -40,5 +41,13 @@ public: } std::unique_ptr clang::driver::createDriverOptTable() { - return llvm::make_unique(); + auto Result = llvm::make_unique(); + // Options.inc is included in DriverOptions.cpp, and calls OptTable's + // addValues function. + // Opt is a variable used in the code fragment in Options.inc. + OptTable &Opt = *Result; +#define OPTTABLE_ARG_INIT +#include "clang/Driver/Options.inc" +#undef OPTTABLE_ARG_INIT + return std::move(Result); } Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=311552&r1=311551&r2=311552&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Wed Aug 23 06:39:47 2017 @@ -93,3 +93,5 @@ // WARNING-NEXT: -Wmax-unsigned-zero // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING // NOWARNING: -Wno-invalid-pp-token +// RUN: %clang --autocomplete=-analyzer-checker, | FileCheck %s -check-prefix=ANALYZER +// ANALYZER: unix.Malloc ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r311958 - Revert "Revert r311552: [Bash-autocompletion] Add support for static analyzer flags"
Hi Nico, Thanks for your comment! I do agree that this code is hacky. Do you mean to ask tablegen to generate Checkers.inc under Driver so that we can do like this? : #define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H) FULLNAME "," #include "clang/Driver/Checkers.inc" #undef GET_CHECKERS Cheers, Yuka 2018-04-07 4:28 GMT+02:00 Nico Weber : > Hi Yuka, > > sorry about the late review comment on this. I just happened to see that > this lets Driver's Option.inc depend on StaticAnalyzer/Checker's > Checker.inc. However, Driver does not depend on StaticAnalyzer/Checker. In > practice, it works ok because of all tablegen targets being collected > into clang-tablegen-targets and driver depending on that ( > http://llvm-cs.pcc.me.uk/tools/clang/CMakeLists.txt#442), but it still > feels a bit hacky that Driver's tablegen output depends on code generated > by StaticAnalyzer/Checker. Maybe we should move Checker.td into Driver now? > > Nico > > On Mon, Aug 28, 2017 at 8:09 PM, Yuka Takahashi via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: yamaguchi >> Date: Mon Aug 28 17:09:31 2017 >> New Revision: 311958 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=311958&view=rev >> Log: >> Revert "Revert r311552: [Bash-autocompletion] Add support for static >> analyzer flags" >> >> This reverts commit 7c46b80c022e18d43c1fdafb117b0c409c5a6d1e. >> >> r311552 broke lld buildbot because I've changed OptionInfos type from >> ArrayRef to vector. However the bug is fixed, so I'll commit this again. >> >> Modified: >> cfe/trunk/include/clang/Driver/CC1Options.td >> cfe/trunk/lib/Driver/DriverOptions.cpp >> cfe/trunk/test/Driver/autocomplete.c >> >> Modified: cfe/trunk/include/clang/Driver/CC1Options.td >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Driver/CC1Options.td?rev=311958&r1=311957&r2=311958&view=diff >> >> == >> --- cfe/trunk/include/clang/Driver/CC1Options.td (original) >> +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Aug 28 17:09:31 2017 >> @@ -99,7 +99,19 @@ def analyzer_stats : Flag<["-"], "analyz >>HelpText<"Print internal analyzer statistics.">; >> >> def analyzer_checker : Separate<["-"], "analyzer-checker">, >> - HelpText<"Choose analyzer checkers to enable">; >> + HelpText<"Choose analyzer checkers to enable">, >> + ValuesCode<[{ >> +const char *Values = >> +#define GET_CHECKERS >> +#define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H) FULLNAME "," >> +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" >> +#undef GET_CHECKERS >> +#define GET_PACKAGES >> +#define PACKAGE(FULLNAME, G, D) FULLNAME "," >> +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" >> +#undef GET_PACKAGES >> +; >> + }]>; >> def analyzer_checker_EQ : Joined<["-"], "analyzer-checker=">, >>Alias; >> >> >> Modified: cfe/trunk/lib/Driver/DriverOptions.cpp >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Dri >> verOptions.cpp?rev=311958&r1=311957&r2=311958&view=diff >> >> == >> --- cfe/trunk/lib/Driver/DriverOptions.cpp (original) >> +++ cfe/trunk/lib/Driver/DriverOptions.cpp Mon Aug 28 17:09:31 2017 >> @@ -11,6 +11,7 @@ >> #include "llvm/ADT/STLExtras.h" >> #include "llvm/Option/OptTable.h" >> #include "llvm/Option/Option.h" >> +#include >> >> using namespace clang::driver; >> using namespace clang::driver::options; >> @@ -40,5 +41,13 @@ public: >> } >> >> std::unique_ptr clang::driver::createDriverOptTable() { >> - return llvm::make_unique(); >> + auto Result = llvm::make_unique(); >> + // Options.inc is included in DriverOptions.cpp, and calls OptTable's >> + // addValues function. >> + // Opt is a variable used in the code fragment in Options.inc. >> + OptTable &Opt = *Result; >> +#define OPTTABLE_ARG_INIT >> +#include "clang/Driver/Options.inc" >> +#undef OPTTABLE_ARG_INIT >> + return std::move(Result); >> } >> >> Modified: cfe/trunk/test/Driver/autocomplete.c
Re: r311958 - Revert "Revert r311552: [Bash-autocompletion] Add support for static analyzer flags"
Sounds good! 2018-04-09 15:03 GMT+02:00 Nico Weber : > Yes. > > On Mon, Apr 9, 2018 at 9:00 AM, Yuka Takahashi wrote: > >> Hi Nico, >> >> Thanks for your comment! >> >> I do agree that this code is hacky. Do you mean to ask tablegen to >> generate Checkers.inc under Driver so that we can do like this? : >> #define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H) FULLNAME "," >> #include "clang/Driver/Checkers.inc" >> #undef GET_CHECKERS >> >> Cheers, >> Yuka >> >> 2018-04-07 4:28 GMT+02:00 Nico Weber : >> >>> Hi Yuka, >>> >>> sorry about the late review comment on this. I just happened to see that >>> this lets Driver's Option.inc depend on StaticAnalyzer/Checker's >>> Checker.inc. However, Driver does not depend on StaticAnalyzer/Checker. In >>> practice, it works ok because of all tablegen targets being collected >>> into clang-tablegen-targets and driver depending on that ( >>> http://llvm-cs.pcc.me.uk/tools/clang/CMakeLists.txt#442), but it still >>> feels a bit hacky that Driver's tablegen output depends on code generated >>> by StaticAnalyzer/Checker. Maybe we should move Checker.td into Driver now? >>> >>> Nico >>> >>> On Mon, Aug 28, 2017 at 8:09 PM, Yuka Takahashi via cfe-commits < >>> cfe-commits@lists.llvm.org> wrote: >>> >>>> Author: yamaguchi >>>> Date: Mon Aug 28 17:09:31 2017 >>>> New Revision: 311958 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=311958&view=rev >>>> Log: >>>> Revert "Revert r311552: [Bash-autocompletion] Add support for static >>>> analyzer flags" >>>> >>>> This reverts commit 7c46b80c022e18d43c1fdafb117b0c409c5a6d1e. >>>> >>>> r311552 broke lld buildbot because I've changed OptionInfos type from >>>> ArrayRef to vector. However the bug is fixed, so I'll commit this again. >>>> >>>> Modified: >>>> cfe/trunk/include/clang/Driver/CC1Options.td >>>> cfe/trunk/lib/Driver/DriverOptions.cpp >>>> cfe/trunk/test/Driver/autocomplete.c >>>> >>>> Modified: cfe/trunk/include/clang/Driver/CC1Options.td >>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >>>> Driver/CC1Options.td?rev=311958&r1=311957&r2=311958&view=diff >>>> >>>> == >>>> --- cfe/trunk/include/clang/Driver/CC1Options.td (original) >>>> +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Aug 28 17:09:31 >>>> 2017 >>>> @@ -99,7 +99,19 @@ def analyzer_stats : Flag<["-"], "analyz >>>>HelpText<"Print internal analyzer statistics.">; >>>> >>>> def analyzer_checker : Separate<["-"], "analyzer-checker">, >>>> - HelpText<"Choose analyzer checkers to enable">; >>>> + HelpText<"Choose analyzer checkers to enable">, >>>> + ValuesCode<[{ >>>> +const char *Values = >>>> +#define GET_CHECKERS >>>> +#define CHECKER(FULLNAME, CLASS, DESCFILE, HT, G, H) FULLNAME "," >>>> +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" >>>> +#undef GET_CHECKERS >>>> +#define GET_PACKAGES >>>> +#define PACKAGE(FULLNAME, G, D) FULLNAME "," >>>> +#include "clang/StaticAnalyzer/Checkers/Checkers.inc" >>>> +#undef GET_PACKAGES >>>> +; >>>> + }]>; >>>> def analyzer_checker_EQ : Joined<["-"], "analyzer-checker=">, >>>>Alias; >>>> >>>> >>>> Modified: cfe/trunk/lib/Driver/DriverOptions.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Dri >>>> verOptions.cpp?rev=311958&r1=311957&r2=311958&view=diff >>>> >>>> == >>>> --- cfe/trunk/lib/Driver/DriverOptions.cpp (original) >>>> +++ cfe/trunk/lib/Driver/DriverOptions.cpp Mon Aug 28 17:09:31 2017 >>>> @@ -11,6 +11,7 @@ >>>> #include "llvm/ADT/STLExtras.h" >>>> #include "llvm/Option/OptTable.h" >>>> #include &
r306555 - [Bash-autocompletion] Check clang version in Bash
Author: yamaguchi Date: Wed Jun 28 08:59:55 2017 New Revision: 306555 URL: http://llvm.org/viewvc/llvm-project?rev=306555&view=rev Log: [Bash-autocompletion] Check clang version in Bash Summary: Add check if user's clang version supports --autocomplete or not. If not, we just autocomplete files. Reviewers: ruiu, v.g.vassilev, teemperor Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34607 Modified: cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=306555&r1=306554&r2=306555&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Wed Jun 28 08:59:55 2017 @@ -1,7 +1,7 @@ # Please add "source /path/to/bash-autocomplete.sh" to your .bashrc to use this. _clang() { - local cur prev words cword arg + local cur prev words cword arg flags _init_completion -n : || return # bash always separates '=' as a token even if there's no space before/after '='. @@ -24,7 +24,14 @@ _clang() arg="$w2=,$cur" fi - local flags=$( clang --autocomplete="$arg" ) + flags=$( clang --autocomplete="$arg" 2>/dev/null ) + # If clang is old that it does not support --autocomplete, + # fall back to the filename completion. + if [[ "$?" != 0 ]]; then +_filedir +return + fi + if [[ "$cur" == '=' ]]; then COMPREPLY=( $( compgen -W "$flags" -- "") ) elif [[ "$flags" == "" || "$arg" == "" ]]; then ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r306559 - [Bash-autocompletion] Invoke clang where user called
Author: yamaguchi Date: Wed Jun 28 09:29:26 2017 New Revision: 306559 URL: http://llvm.org/viewvc/llvm-project?rev=306559&view=rev Log: [Bash-autocompletion] Invoke clang where user called Summary: When user build clang and used completion Eg. `build/bin/clang -fno[tab]`, we want to invoke `build/bin/clang --autocomplete=-fno`, rather than `clang --autocomplete=-fno`. Differential Revision: https://reviews.llvm.org/D34761 Modified: cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=306559&r1=306558&r2=306559&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Wed Jun 28 09:29:26 2017 @@ -24,7 +24,7 @@ _clang() arg="$w2=,$cur" fi - flags=$( clang --autocomplete="$arg" 2>/dev/null ) + flags=$( "${COMP_WORDS[0]}" --autocomplete="$arg" 2>/dev/null ) # If clang is old that it does not support --autocomplete, # fall back to the filename completion. if [[ "$?" != 0 ]]; then ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r306127 - [GSoC] Add support for CC1 options.
Thank you for your feedback! For options which have `NoDriverOption` Flags (such as -mrelocation-model), I agree that we should expose these flags to users only when `-cc1` is also passed. However, as to `-mrelocation-model [tab]`, I think it is fine to provide possible values for this option (static,pic,ropi..) because user has already typed `-mrelocation-model` and maybe already be aware that this is cc1 option. I'll create a new patch and send it to review soon :) 2017-06-27 18:32 GMT+09:00 Vassil Vassilev : > On 27/06/17 07:17, Saleem Abdulrasool via cfe-commits wrote: > > I think that we shouldn't be providing completion for `-cc1` options. > `-cc1as` options are fine as the IAS serves as a replacement for the > traditional unix `as`. But, the `NoDriverOption` values shouldn't be > exposed to users. They are internal details, with no compatibility. If > users start using those options, it makes it harder to prevent command line > incompatibilities. > > Thanks for the feedback! > > We probably should only expose the cc1 options if the user typed clang > -cc1 -f[tab], i.e. the user already is looking for something internal or > make sure they are noted as a cc1 arguments. On the other hand, this should > be of great help to more advanced users. > > > On Fri, Jun 23, 2017 at 10:05 AM, Yuka Takahashi via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> Author: yamaguchi >> Date: Fri Jun 23 12:05:50 2017 >> New Revision: 306127 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=306127&view=rev >> Log: >> [GSoC] Add support for CC1 options. >> >> Summary: >> Add value completion support for options which are defined in >> CC1Options.td, because we only handled options in Options.td. >> >> Reviewers: ruiu, v.g.vassilev, teemperor >> >> Subscribers: llvm-commits >> >> Differential Revision: https://reviews.llvm.org/D34558 >> >> Modified: >> cfe/trunk/include/clang/Driver/CC1Options.td >> cfe/trunk/test/Driver/autocomplete.c >> >> Modified: cfe/trunk/include/clang/Driver/CC1Options.td >> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ >> Driver/CC1Options.td?rev=306127&r1=306126&r2=306127&view=diff >> >> == >> --- cfe/trunk/include/clang/Driver/CC1Options.td (original) >> +++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Jun 23 12:05:50 2017 >> @@ -158,7 +158,7 @@ def msave_temp_labels : Flag<["-"], "msa >> "Note this may change .s semantics and shouldn't generally be >> used " >> "on compiler-generated code.">; >> def mrelocation_model : Separate<["-"], "mrelocation-model">, >> - HelpText<"The relocation model to use">; >> + HelpText<"The relocation model to use">, Values<"static,pic,ropi,rwpi,r >> opi-rwpi,dynamic-no-pic">; >> def fno_math_builtin : Flag<["-"], "fno-math-builtin">, >>HelpText<"Disable implicit builtin knowledge of math functions">; >> } >> @@ -229,7 +229,7 @@ def no_struct_path_tbaa : Flag<["-"], "n >> def masm_verbose : Flag<["-"], "masm-verbose">, >>HelpText<"Generate verbose assembly output">; >> def mcode_model : Separate<["-"], "mcode-model">, >> - HelpText<"The code model to use">; >> + HelpText<"The code model to use">, Values<"small,kernel,medium,la >> rge">; >> def mdebug_pass : Separate<["-"], "mdebug-pass">, >>HelpText<"Enable additional debug output">; >> def mdisable_fp_elim : Flag<["-"], "mdisable-fp-elim">, >> @@ -308,7 +308,7 @@ def fsanitize_coverage_no_prune >>HelpText<"Disable coverage pruning (i.e. instrument all >> blocks/edges)">; >> def fprofile_instrument_EQ : Joined<["-"], "fprofile-instrument=">, >> HelpText<"Enable PGO instrumentation. The accepted value is clang, >> llvm, " >> - "or none">; >> + "or none">, Values<"none,clang,llvm">; >> def fprofile_instrument_path_EQ : Joined<["-"], >> "fprofile-instrument-path=">, >> HelpText<"Generate instrumented code to collect execution counts >> into "
r306953 - Changed Opts.EABIVersion type string to llvm::EABI enum class
Author: yamaguchi Date: Sat Jul 1 00:57:23 2017 New Revision: 306953 URL: http://llvm.org/viewvc/llvm-project?rev=306953&view=rev Log: Changed Opts.EABIVersion type string to llvm::EABI enum class Summary: Changed EABIVersion type from string to llvm::EABI. It seems it was just a typo and this is intended implementation. Differential Revision: https://reviews.llvm.org/D34595 Modified: cfe/trunk/include/clang/Basic/TargetOptions.h cfe/trunk/lib/Basic/Targets.cpp cfe/trunk/lib/CodeGen/BackendUtil.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp Modified: cfe/trunk/include/clang/Basic/TargetOptions.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=306953&r1=306952&r2=306953&view=diff == --- cfe/trunk/include/clang/Basic/TargetOptions.h (original) +++ cfe/trunk/include/clang/Basic/TargetOptions.h Sat Jul 1 00:57:23 2017 @@ -18,6 +18,7 @@ #include #include #include "clang/Basic/OpenCLOptions.h" +#include "llvm/Target/TargetOptions.h" namespace clang { @@ -41,7 +42,7 @@ public: std::string ABI; /// The EABI version to use - std::string EABIVersion; + llvm::EABI EABIVersion; /// If given, the version string of the linker in use. std::string LinkerVersion; Modified: cfe/trunk/lib/Basic/Targets.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=306953&r1=306952&r2=306953&view=diff == --- cfe/trunk/lib/Basic/Targets.cpp (original) +++ cfe/trunk/lib/Basic/Targets.cpp Sat Jul 1 00:57:23 2017 @@ -5443,7 +5443,7 @@ public: if (Triple.getOS() == llvm::Triple::Linux || Triple.getOS() == llvm::Triple::UnknownOS) this->MCountName = - Opts.EABIVersion == "gnu" ? "\01__gnu_mcount_nc" : "\01mcount"; + Opts.EABIVersion == llvm::EABI::GNU ? "\01__gnu_mcount_nc" : "\01mcount"; } StringRef getABI() const override { return ABI; } @@ -6283,7 +6283,7 @@ public: if (Triple.getOS() == llvm::Triple::Linux) this->MCountName = "\01_mcount"; else if (Triple.getOS() == llvm::Triple::UnknownOS) - this->MCountName = Opts.EABIVersion == "gnu" ? "\01_mcount" : "mcount"; + this->MCountName = Opts.EABIVersion == llvm::EABI::GNU ? "\01_mcount" : "mcount"; } StringRef getABI() const override { return ABI; } Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=306953&r1=306952&r2=306953&view=diff == --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original) +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sat Jul 1 00:57:23 2017 @@ -415,11 +415,7 @@ static void initTargetOptions(llvm::Targ Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations; // Set EABI version. - Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion) -.Case("4", llvm::EABI::EABI4) -.Case("5", llvm::EABI::EABI5) -.Case("gnu", llvm::EABI::GNU) -.Default(llvm::EABI::Default); + Options.EABIVersion = TargetOpts.EABIVersion; if (LangOpts.SjLjExceptions) Options.ExceptionModel = llvm::ExceptionHandling::SjLj; Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=306953&r1=306952&r2=306953&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sat Jul 1 00:57:23 2017 @@ -2568,7 +2568,7 @@ static void ParseTargetArgs(TargetOption Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Value; else - Opts.EABIVersion = Value; + Opts.EABIVersion = EABIVersion; } Opts.CPU = Args.getLastArgValue(OPT_target_cpu); Opts.FPMath = Args.getLastArgValue(OPT_mfpmath); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r306957 - [Bash-completion] Fixed a bug that ~ doesn't expanded to $HOME
Author: yamaguchi Date: Sat Jul 1 09:30:02 2017 New Revision: 306957 URL: http://llvm.org/viewvc/llvm-project?rev=306957&view=rev Log: [Bash-completion] Fixed a bug that ~ doesn't expanded to $HOME Summary: `~/build/bin/clang -f[tab]` was executed without ~ expanded to $HOME, so changed this by expanding ~ to path using eval. Differential Revision: https://reviews.llvm.org/D34925 Modified: cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=306957&r1=306956&r2=306957&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Sat Jul 1 09:30:02 2017 @@ -24,7 +24,9 @@ _clang() arg="$w2=,$cur" fi - flags=$( "${COMP_WORDS[0]}" --autocomplete="$arg" 2>/dev/null ) + # expand ~ to $HOME + eval local path=${COMP_WORDS[0]} + flags=$( "$path" --autocomplete="$arg" 2>/dev/null ) # If clang is old that it does not support --autocomplete, # fall back to the filename completion. if [[ "$?" != 0 ]]; then ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r306962 - [Bash-autocompletion] Add support for older bash version.
Author: yamaguchi Date: Sat Jul 1 11:32:55 2017 New Revision: 306962 URL: http://llvm.org/viewvc/llvm-project?rev=306962&view=rev Log: [Bash-autocompletion] Add support for older bash version. Summary: OS X seems to use older bash version which doesn't suport _init_completion and compopt, so add support for this. Reviewers: ruiu, v.g.vassilev, teemperor Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34924 Modified: cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=306962&r1=306961&r2=306962&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Sat Jul 1 11:32:55 2017 @@ -1,15 +1,33 @@ # Please add "source /path/to/bash-autocomplete.sh" to your .bashrc to use this. + +_clang_filedir() +{ + # _filedir function provided by recent versions of bash-completion package is + # better than "compgen -f" because the former honors spaces in pathnames while + # the latter doesn't. So we use compgen only when _filedir is not provided. + _filedir 2> /dev/null || COMPREPLY=( $( compgen -f ) ) +} + _clang() { - local cur prev words cword arg flags - _init_completion -n : || return + local cur prev words cword arg flags w1 w2 + # If latest bash-completion is not supported just initialize COMPREPLY and + # initialize variables by setting manualy. + _init_completion -n 2> /dev/null + if [[ "$?" != 0 ]]; then +COMPREPLY=() +cword=$COMP_CWORD +cur="${COMP_WORDS[$cword]}" + fi # bash always separates '=' as a token even if there's no space before/after '='. # On the other hand, '=' is just a regular character for clang options that # contain '='. For example, "-stdlib=" is defined as is, instead of "-stdlib" and "=". # So, we need to partially undo bash tokenization here for integrity. - local w1="${COMP_WORDS[$cword - 1]}" - local w2="${COMP_WORDS[$cword - 2]}" + w1="${COMP_WORDS[$cword - 1]}" + if [[ $cword > 1 ]]; then +w2="${COMP_WORDS[$cword - 2]}" + fi if [[ "$cur" == -* ]]; then # -foo arg="$cur" @@ -30,18 +48,18 @@ _clang() # If clang is old that it does not support --autocomplete, # fall back to the filename completion. if [[ "$?" != 0 ]]; then -_filedir +_clang_filedir return fi if [[ "$cur" == '=' ]]; then COMPREPLY=( $( compgen -W "$flags" -- "") ) elif [[ "$flags" == "" || "$arg" == "" ]]; then -_filedir +_clang_filedir else # Bash automatically appends a space after '=' by default. # Disable it so that it works nicely for options in the form of -foo=bar. -[[ "${flags: -1}" == '=' ]] && compopt -o nospace +[[ "${flags: -1}" == '=' ]] && compopt -o nospace 2> /dev/null COMPREPLY=( $( compgen -W "$flags" -- "$cur" ) ) fi } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307478 - [Bash-autocompletion] Fix a bug that -foo=bar doesn't handled properly
Author: yamaguchi Date: Sat Jul 8 10:34:02 2017 New Revision: 307478 URL: http://llvm.org/viewvc/llvm-project?rev=307478&view=rev Log: [Bash-autocompletion] Fix a bug that -foo=bar doesn't handled properly Summary: Fixed a bug that -foo=bar wasn't handled properly on old version of bash. Differential Revision: https://reviews.llvm.org/D34927 Modified: cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=307478&r1=307477&r2=307478&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Sat Jul 8 10:34:02 2017 @@ -34,12 +34,18 @@ _clang() elif [[ "$w1" == -* && "$cur" == '=' ]]; then # -foo= arg="$w1=," + elif [[ "$cur" == -*= ]]; then +# -foo= +arg="$cur," elif [[ "$w1" == -* ]]; then # -foo or -foo bar arg="$w1,$cur" elif [[ "$w2" == -* && "$w1" == '=' ]]; then # -foo=bar arg="$w2=,$cur" + elif [[ ${cur: -1} != '=' && ${cur/=} != $cur ]]; then +# -foo=bar +arg="${cur%=*}=,${cur#*=}" fi # expand ~ to $HOME ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r307479 - [Bash-autocompletion] Auto complete cc1 options if -cc1 is specified
Author: yamaguchi Date: Sat Jul 8 10:48:59 2017 New Revision: 307479 URL: http://llvm.org/viewvc/llvm-project?rev=307479&view=rev Log: [Bash-autocompletion] Auto complete cc1 options if -cc1 is specified Summary: We don't want to autocomplete flags whose Flags class has `NoDriverOption` when argv[1] is not `-cc1`. Another idea for this implementation is to make --autocomplete a cc1 option and handle it in clang Frontend, by porting --autocomplete handler from Driver to Frontend, so that we can handle Driver options and CC1 options in unified manner. Differential Revision: https://reviews.llvm.org/D34770 Modified: cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/test/Driver/autocomplete.c cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=307479&r1=307478&r2=307479&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Sat Jul 8 10:48:59 2017 @@ -1261,11 +1261,20 @@ bool Driver::HandleImmediateArgs(const C StringRef PassedFlags = A->getValue(); std::vector SuggestedCompletions; +unsigned short DisableFlags = options::NoDriverOption | options::Unsupported | options::Ignored; +// We want to show cc1-only options only when clang is invoked as "clang -cc1". +// When clang is invoked as "clang -cc1", we add "#" to the beginning of an --autocomplete +// option so that the clang driver can distinguish whether it is requested to show cc1-only options or not. +if (PassedFlags[0] == '#') { + DisableFlags &= ~options::NoDriverOption; + PassedFlags = PassedFlags.substr(1); +} + if (PassedFlags.find(',') == StringRef::npos) { // If the flag is in the form of "--autocomplete=-foo", // we were requested to print out all option names that start with "-foo". // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only". - SuggestedCompletions = Opts->findByPrefix(PassedFlags); + SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags); } else { // If the flag is in the form of "--autocomplete=foo,bar", we were // requested to print out all option values for "-foo" that start with Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=307479&r1=307478&r2=307479&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Sat Jul 8 10:48:59 2017 @@ -36,3 +36,7 @@ // MTHREADMODELALL: posix single // RUN: %clang --autocomplete=-mrelocation-model, | FileCheck %s -check-prefix=MRELOCMODELALL // MRELOCMODELALL: dynamic-no-pic pic ropi ropi-rwpi rwpi static +// RUN: %clang --autocomplete=-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CLANG +// MRELOCMODEL_CLANG-NOT: -mrelocation-model +// RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1 +// MRELOCMODEL_CC1: -mrelocation-model Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=307479&r1=307478&r2=307479&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Sat Jul 8 10:48:59 2017 @@ -27,25 +27,29 @@ _clang() w1="${COMP_WORDS[$cword - 1]}" if [[ $cword > 1 ]]; then w2="${COMP_WORDS[$cword - 2]}" + # Clang want to know if -cc1 or -Xclang option is specified or not, because we don't want to show + # cc1 options otherwise. + if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then +arg="#" fi if [[ "$cur" == -* ]]; then # -foo -arg="$cur" +arg="$arg$cur" elif [[ "$w1" == -* && "$cur" == '=' ]]; then # -foo= -arg="$w1=," +arg="$arg$w1=," elif [[ "$cur" == -*= ]]; then # -foo= -arg="$cur," +arg="$arg$cur," elif [[ "$w1" == -* ]]; then # -foo or -foo bar -arg="$w1,$cur" +arg="$arg$w1,$cur" elif [[ "$w2" == -* && "$w1" == '=' ]]; then # -foo=bar -arg="$w2=,$cur" +arg="$arg$w2=,$cur" elif [[ ${cur: -1} != '=' && ${cur/=} != $cur ]]; then # -foo=bar -arg="${cur%=*}=,${cur#*=}" +arg="$arg${cur%=*}=,${cur#*=}" fi # expand ~ to $HOME ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r308091 - [Bash-autocompletion] Fixed a bug on bash
Author: yamaguchi Date: Sat Jul 15 02:09:51 2017 New Revision: 308091 URL: http://llvm.org/viewvc/llvm-project?rev=308091&view=rev Log: [Bash-autocompletion] Fixed a bug on bash Summary: Maybe I mismerged when merging previous commits by hand. Differential Revision: https://reviews.llvm.org/D35448 Modified: cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=308091&r1=308090&r2=308091&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Sat Jul 15 02:09:51 2017 @@ -20,18 +20,21 @@ _clang() cur="${COMP_WORDS[$cword]}" fi - # bash always separates '=' as a token even if there's no space before/after '='. - # On the other hand, '=' is just a regular character for clang options that - # contain '='. For example, "-stdlib=" is defined as is, instead of "-stdlib" and "=". - # So, we need to partially undo bash tokenization here for integrity. w1="${COMP_WORDS[$cword - 1]}" if [[ $cword > 1 ]]; then w2="${COMP_WORDS[$cword - 2]}" + fi + # Clang want to know if -cc1 or -Xclang option is specified or not, because we don't want to show # cc1 options otherwise. if [[ "${COMP_WORDS[1]}" == "-cc1" || "$w1" == "-Xclang" ]]; then arg="#" fi + + # bash always separates '=' as a token even if there's no space before/after '='. + # On the other hand, '=' is just a regular character for clang options that + # contain '='. For example, "-stdlib=" is defined as is, instead of "-stdlib" and "=". + # So, we need to partially undo bash tokenization here for integrity. if [[ "$cur" == -* ]]; then # -foo arg="$arg$cur" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r308139 - [Bash-autocompletion] Add support for -W and -Wno
Author: yamaguchi Date: Sun Jul 16 08:07:20 2017 New Revision: 308139 URL: http://llvm.org/viewvc/llvm-project?rev=308139&view=rev Log: [Bash-autocompletion] Add support for -W and -Wno Summary: `-W[tab]` will autocomplete warnings defined in this link: https://clang.llvm.org/docs/DiagnosticsReference.html#wweak-vtables Differential Revision: https://reviews.llvm.org/D35447 Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h cfe/trunk/lib/Basic/DiagnosticIDs.cpp cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=308139&r1=308138&r2=308139&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original) +++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Sun Jul 16 08:07:20 2017 @@ -18,6 +18,7 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringRef.h" +#include namespace clang { class DiagnosticsEngine; @@ -263,6 +264,13 @@ public: /// are not SFINAE errors. static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID); + /// \brief Get the string of all diagnostic flags. + /// + /// \returns A list of all diagnostics flags as they would be written in a + /// command line invocation including their `no-` variants. For example: + /// `{"-Wempty-body", "-Wno-empty-body", ...}` + static std::vector getDiagnosticFlags(); + /// \brief Get the set of all diagnostic IDs in the group with the given name. /// /// \param[out] Diags - On return, the diagnostics in the group. Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=308139&r1=308138&r2=308139&view=diff == --- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original) +++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Sun Jul 16 08:07:20 2017 @@ -510,6 +510,18 @@ StringRef DiagnosticIDs::getWarningOptio return StringRef(); } +std::vector DiagnosticIDs::getDiagnosticFlags() { + std::vector Res; + for (size_t I = 1; DiagGroupNames[I] != '\0';) { +std::string Diag(DiagGroupNames + I + 1, DiagGroupNames[I]); +I += DiagGroupNames[I] + 1; +Res.push_back("-W" + Diag); +Res.push_back("-Wno" + Diag); + } + + return Res; +} + /// Return \c true if any diagnostics were found in this group, even if they /// were filtered out due to having the wrong flavor. static bool getDiagnosticsInGroup(diag::Flavor Flavor, Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=308139&r1=308138&r2=308139&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Sun Jul 16 08:07:20 2017 @@ -1275,6 +1275,13 @@ bool Driver::HandleImmediateArgs(const C // we were requested to print out all option names that start with "-foo". // For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only". SuggestedCompletions = Opts->findByPrefix(PassedFlags, DisableFlags); + + // We have to query the -W flags manually as they're not in the OptTable. + // TODO: Find a good way to add them to OptTable instead and them remove + // this code. + for (StringRef S : DiagnosticIDs::getDiagnosticFlags()) +if (S.startswith(PassedFlags)) + SuggestedCompletions.push_back(S); } else { // If the flag is in the form of "--autocomplete=foo,bar", we were // requested to print out all option values for "-foo" that start with Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=308139&r1=308138&r2=308139&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Sun Jul 16 08:07:20 2017 @@ -40,3 +40,7 @@ // MRELOCMODEL_CLANG-NOT: -mrelocation-model // RUN: %clang --autocomplete=#-mrelocation-mode | FileCheck %s -check-prefix=MRELOCMODEL_CC1 // MRELOCMODEL_CC1: -mrelocation-model +// RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING +// WARNING: -Wmacro-redefined -Wmain -Wmain-return-type -Wmalformed-warning-check -Wmany-braces-around-scalar-init -Wmax-unsigned-zero +// RUN: %clang --autocomplete=-Wnoinvalid-pp- | FileCheck %s -check-prefix=NOWARNING +// NOWARNING: -Wnoinvalid-pp-token ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r308824 - [Bash-autocompletion] Fixed typo and add '-' after -Wno
Author: yamaguchi Date: Sat Jul 22 05:35:15 2017 New Revision: 308824 URL: http://llvm.org/viewvc/llvm-project?rev=308824&view=rev Log: [Bash-autocompletion] Fixed typo and add '-' after -Wno Summary: -Wno- was autocompleted as -Wno, so fixed this typo. Differential Revision: https://reviews.llvm.org/D35762 Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp cfe/trunk/test/Driver/autocomplete.c Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=308824&r1=308823&r2=308824&view=diff == --- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original) +++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Sat Jul 22 05:35:15 2017 @@ -516,7 +516,7 @@ std::vector DiagnosticIDs:: std::string Diag(DiagGroupNames + I + 1, DiagGroupNames[I]); I += DiagGroupNames[I] + 1; Res.push_back("-W" + Diag); -Res.push_back("-Wno" + Diag); +Res.push_back("-Wno-" + Diag); } return Res; Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=308824&r1=308823&r2=308824&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Sat Jul 22 05:35:15 2017 @@ -42,5 +42,5 @@ // MRELOCMODEL_CC1: -mrelocation-model // RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING // WARNING: -Wmacro-redefined -Wmain -Wmain-return-type -Wmalformed-warning-check -Wmany-braces-around-scalar-init -Wmax-unsigned-zero -// RUN: %clang --autocomplete=-Wnoinvalid-pp- | FileCheck %s -check-prefix=NOWARNING -// NOWARNING: -Wnoinvalid-pp-token +// RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING +// NOWARNING: -Wno-invalid-pp-token ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r309112 - [Bash-completion] Fixed a bug that file doesn't autocompleted after =
Author: yamaguchi Date: Wed Jul 26 06:30:36 2017 New Revision: 309112 URL: http://llvm.org/viewvc/llvm-project?rev=309112&view=rev Log: [Bash-completion] Fixed a bug that file doesn't autocompleted after = Summary: File path wasn't autocompleted after `-fmodule-cache-path=[tab]`, so fixed this bug by checking if $flags contains only a newline or not. Differential Revision: https://reviews.llvm.org/D35763 Modified: cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=309112&r1=309111&r2=309112&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Wed Jul 26 06:30:36 2017 @@ -65,10 +65,14 @@ _clang() return fi - if [[ "$cur" == '=' ]]; then -COMPREPLY=( $( compgen -W "$flags" -- "") ) - elif [[ "$flags" == "" || "$arg" == "" ]]; then + # When clang does not emit any possible autocompletion, or user pushed tab after " ", + # just autocomplete files. + if [[ "$flags" == "$(echo -e '\n')" || "$arg" == "" ]]; then +# If -foo= and there was no possible values, autocomplete files. +[[ "$cur" == '=' || "$cur" == -*= ]] && cur="" _clang_filedir + elif [[ "$cur" == '=' ]]; then +COMPREPLY=( $( compgen -W "$flags" -- "") ) else # Bash automatically appends a space after '=' by default. # Disable it so that it works nicely for options in the form of -foo=bar. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r309113 - [Bash-autocompletion] Show HelpText with possible flags
Author: yamaguchi Date: Wed Jul 26 06:36:58 2017 New Revision: 309113 URL: http://llvm.org/viewvc/llvm-project?rev=309113&view=rev Log: [Bash-autocompletion] Show HelpText with possible flags Summary: `clang --autocomplete=-std` will show ``` -std: Language standard to compile for -std= Language standard to compile for -stdlib=C++ standard library to use ``` after this change. However, showing HelpText with completion in bash seems super tricky, so this feature will be used in other shells (fish, zsh...). Reviewers: v.g.vassilev, teemperor, ruiu Subscribers: cfe-commits, hiraditya Differential Revision: https://reviews.llvm.org/D35759 Modified: cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/test/Driver/autocomplete.c cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=309113&r1=309112&r2=309113&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Wed Jul 26 06:36:58 2017 @@ -1297,7 +1297,7 @@ bool Driver::HandleImmediateArgs(const C std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(), [](StringRef A, StringRef B) { return A.compare_lower(B) < 0; }); -llvm::outs() << llvm::join(SuggestedCompletions, " ") << '\n'; +llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n'; return false; } Modified: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=309113&r1=309112&r2=309113&view=diff == --- cfe/trunk/test/Driver/autocomplete.c (original) +++ cfe/trunk/test/Driver/autocomplete.c Wed Jul 26 06:36:58 2017 @@ -1,46 +1,91 @@ // RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN // FSYN: -fsyntax-only -// RUN: %clang --autocomplete=-s | FileCheck %s -check-prefix=STD -// STD: -std={{.*}}-stdlib= +// RUN: %clang --autocomplete=-std= | FileCheck %s -check-prefix=STD +// STD: -std= Language standard to compile for // RUN: %clang --autocomplete=foo | FileCheck %s -check-prefix=FOO // FOO-NOT: foo // RUN: %clang --autocomplete=-stdlib=,l | FileCheck %s -check-prefix=STDLIB -// STDLIB: libc++ libstdc++ +// STDLIB: libc++ +// STDLIB-NEXT: libstdc++ // RUN: %clang --autocomplete=-stdlib=, | FileCheck %s -check-prefix=STDLIBALL -// STDLIBALL: libc++ libstdc++ platform +// STDLIBALL: libc++ +// STDLIBALL-NEXT: libstdc++ +// STDLIBALL-NEXT: platform // RUN: %clang --autocomplete=-meabi,d | FileCheck %s -check-prefix=MEABI // MEABI: default // RUN: %clang --autocomplete=-meabi, | FileCheck %s -check-prefix=MEABIALL -// MEABIALL: 4 5 default gnu +// MEABIALL: 4 +// MEABIALL-NEXT: 5 +// MEABIALL-NEXT: default +// MEABIALL-NEXT: gnu // RUN: %clang --autocomplete=-cl-std=,CL2 | FileCheck %s -check-prefix=CLSTD // CLSTD: CL2.0 // RUN: %clang --autocomplete=-cl-std=, | FileCheck %s -check-prefix=CLSTDALL -// CLSTDALL: cl CL cl1.1 CL1.1 cl1.2 CL1.2 cl2.0 CL2.0 +// CLSTDALL: cl +// CLSTDALL-NEXT: CL +// CLSTDALL-NEXT: cl1.1 +// CLSTDALL-NEXT: CL1.1 +// CLSTDALL-NEXT: cl1.2 +// CLSTDALL-NEXT: CL1.2 +// CLSTDALL-NEXT: cl2.0 +// CLSTDALL-NEXT: CL2.0 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER // FNOSANICOVER: func // RUN: %clang --autocomplete=-fno-sanitize-coverage=, | FileCheck %s -check-prefix=FNOSANICOVERALL -// FNOSANICOVERALL: 8bit-counters bb edge func indirect-calls inline-8bit-counters no-prune trace-bb trace-cmp trace-div trace-gep trace-pc trace-pc-guard +// FNOSANICOVERALL: 8bit-counters +// FNOSANICOVERALL-NEXT: bb +// FNOSANICOVERALL-NEXT: edge +// FNOSANICOVERALL-NEXT: func +// FNOSANICOVERALL-NEXT: indirect-calls +// FNOSANICOVERALL-NEXT: inline-8bit-counters +// FNOSANICOVERALL-NEXT: no-prune +// FNOSANICOVERALL-NEXT: trace-bb +// FNOSANICOVERALL-NEXT: trace-cmp +// FNOSANICOVERALL-NEXT: trace-div +// FNOSANICOVERALL-NEXT: trace-gep +// FNOSANICOVERALL-NEXT: trace-pc +// FNOSANICOVERALL-NEXT: trace-pc-guard // RUN: %clang --autocomplete=-ffp-contract=, | FileCheck %s -check-prefix=FFPALL -// FFPALL: fast off on +// FFPALL: fast +// FFPALL-NEXT: off +// FFPALL-NEXT: on // RUN: %clang --autocomplete=-flto=, | FileCheck %s -check-prefix=FLTOALL -// FLTOALL: full thin +// FLTOALL: full +// FLTOALL-NEXT: thin // RUN: %clang --autocomplete=-fveclib=, | FileCheck %s -check-prefix=FVECLIBALL -// FVECLIBALL: Accelerate none SVML +// FVECLIBALL: Accelerate +// FVECLIBALL-NEXT: none +// FVECLIBALL-NEXT: SVML // RUN: %clang --autocomplete=-fshow-overloads=, | FileCheck %s -check-prefix=FSOVERALL -// FSOVERALL: all best +// FSOVERALL: all +// FSOVERALL-NEXT: best // RUN: %clang --autocomplete=-fvisibility=, | FileCheck %s -check-prefix=FVISIBILITYALL -// FVISIBILITYALL: default hidden +/
r302000 - Revert rL301998: "Fix a bug that -isysroot is completely ignored on Unix"
Author: yamaguchi Date: Wed May 3 01:02:45 2017 New Revision: 302000 URL: http://llvm.org/viewvc/llvm-project?rev=302000&view=rev Log: Revert rL301998: "Fix a bug that -isysroot is completely ignored on Unix" This reverts commit because it broke sanitizer-x86_64-linux-autoconf bot and clang-ppc64be-linux-multistage bot. Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Driver/sysroot-flags.c Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=302000&r1=301999&r2=302000&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed May 3 01:02:45 2017 @@ -1565,7 +1565,7 @@ static void ParseHeaderSearchArgs(Header frontend::IncludeDirGroup Group = frontend::System; if (A->getOption().matches(OPT_internal_externc_isystem)) Group = frontend::ExternCSystem; -Opts.AddPath(A->getValue(), Group, false, false); +Opts.AddPath(A->getValue(), Group, false, true); } // Add the path prefixes which are implicitly treated as being system headers. Modified: cfe/trunk/test/Driver/sysroot-flags.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sysroot-flags.c?rev=302000&r1=301999&r2=302000&view=diff == --- cfe/trunk/test/Driver/sysroot-flags.c (original) +++ cfe/trunk/test/Driver/sysroot-flags.c Wed May 3 01:02:45 2017 @@ -26,7 +26,3 @@ // RUN: FileCheck %s -check-prefix=SYSROOT_SEPARATE // SYSROOT_SEPARATE: "-isysroot" "{{[^"]*}}/foo/bar" // SYSROOT_SEPARATE: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar" - -// Check that -isysroot is handled properly -// RUN: %clang -isysroot /foo/bar -c %s -v 2>&1 | \ -// RUN: grep "/foo/bar" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r301998 - Fix a bug that -isysroot is completely ignored on Unix
Author: yamaguchi Date: Tue May 2 23:58:39 2017 New Revision: 301998 URL: http://llvm.org/viewvc/llvm-project?rev=301998&view=rev Log: Fix a bug that -isysroot is completely ignored on Unix -isysroot is the flag which set the system root directory. This bug report https://bugs.llvm.org//show_bug.cgi?id=11503 shows that -isysroot is not handled at all on Unix, so fixed this bug. After this diff, I could get this result https://pastebin.com/TeCmn9mj . Differential Revision: https://reviews.llvm.org/D31495 Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Driver/sysroot-flags.c Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=301998&r1=301997&r2=301998&view=diff == --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue May 2 23:58:39 2017 @@ -1565,7 +1565,7 @@ static void ParseHeaderSearchArgs(Header frontend::IncludeDirGroup Group = frontend::System; if (A->getOption().matches(OPT_internal_externc_isystem)) Group = frontend::ExternCSystem; -Opts.AddPath(A->getValue(), Group, false, true); +Opts.AddPath(A->getValue(), Group, false, false); } // Add the path prefixes which are implicitly treated as being system headers. Modified: cfe/trunk/test/Driver/sysroot-flags.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sysroot-flags.c?rev=301998&r1=301997&r2=301998&view=diff == --- cfe/trunk/test/Driver/sysroot-flags.c (original) +++ cfe/trunk/test/Driver/sysroot-flags.c Tue May 2 23:58:39 2017 @@ -26,3 +26,7 @@ // RUN: FileCheck %s -check-prefix=SYSROOT_SEPARATE // SYSROOT_SEPARATE: "-isysroot" "{{[^"]*}}/foo/bar" // SYSROOT_SEPARATE: "--sysroot{{" "|=}}{{[^"]*}}/foo/bar" + +// Check that -isysroot is handled properly +// RUN: %clang -isysroot /foo/bar -c %s -v 2>&1 | \ +// RUN: grep "/foo/bar" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r303670 - [GSoC] Shell autocompletion for clang
Author: yamaguchi Date: Tue May 23 13:39:08 2017 New Revision: 303670 URL: http://llvm.org/viewvc/llvm-project?rev=303670&view=rev Log: [GSoC] Shell autocompletion for clang Summary: This is a first patch for GSoC project, bash-completion for clang. To use this on bash, please run `source clang/utils/bash-autocomplete.sh`. bash-autocomplete.sh is code for bash-completion. Simple flag completion and path completion is available in this patch. Reviewers: teemperor, v.g.vassilev, ruiu, Bigcheese, efriedma Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33237 Added: cfe/trunk/test/Driver/autocomplete.c cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/CMakeLists.txt cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Driver/Driver.cpp Modified: cfe/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=303670&r1=303669&r2=303670&view=diff == --- cfe/trunk/CMakeLists.txt (original) +++ cfe/trunk/CMakeLists.txt Tue May 23 13:39:08 2017 @@ -359,6 +359,10 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) PATTERN "*.inc" PATTERN "*.h" ) + + install(PROGRAMS utils/bash-autocomplete.sh +DESTINATION share/clang +) endif() add_definitions( -D_GNU_SOURCE ) Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=303670&r1=303669&r2=303670&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue May 23 13:39:08 2017 @@ -469,6 +469,7 @@ def arch__errors__fatal : Flag<["-"], "a def arch : Separate<["-"], "arch">, Flags<[DriverOption]>; def arch__only : Separate<["-"], "arch_only">; def a : Joined<["-"], "a">; +def autocomplete : Joined<["--"], "autocomplete=">; def bind__at__load : Flag<["-"], "bind_at_load">; def bundle__loader : Separate<["-"], "bundle_loader">; def bundle : Flag<["-"], "bundle">; Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=303670&r1=303669&r2=303670&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Tue May 23 13:39:08 2017 @@ -1216,6 +1216,13 @@ bool Driver::HandleImmediateArgs(const C return false; } + if (Arg *A = C.getArgs().getLastArg(options::OPT_autocomplete)) { +// Print out all options that start with a given argument. This is used for +// shell autocompletion. +llvm::outs() << llvm::join(Opts->findByPrefix(A->getValue()), " ") << '\n'; +return false; + } + if (C.getArgs().hasArg(options::OPT_print_libgcc_file_name)) { ToolChain::RuntimeLibType RLT = TC.GetRuntimeLibType(C.getArgs()); switch (RLT) { Added: cfe/trunk/test/Driver/autocomplete.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/autocomplete.c?rev=303670&view=auto == --- cfe/trunk/test/Driver/autocomplete.c (added) +++ cfe/trunk/test/Driver/autocomplete.c Tue May 23 13:39:08 2017 @@ -0,0 +1,6 @@ +// RUN: %clang --autocomplete=-fsyn | FileCheck %s -check-prefix=FSYN +// FSYN: -fsyntax-only +// RUN: %clang --autocomplete=-s | FileCheck %s -check-prefix=STD +// STD: -std={{.*}}-stdlib= +// RUN: %clang --autocomplete=foo | not FileCheck %s -check-prefix=NONE +// NONE: foo Added: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=303670&view=auto == --- cfe/trunk/utils/bash-autocomplete.sh (added) +++ cfe/trunk/utils/bash-autocomplete.sh Tue May 23 13:39:08 2017 @@ -0,0 +1,14 @@ +# Please add "source /path/to/bash-autocomplete.sh" to your .bashrc to use this. +_clang() +{ + local cur prev words cword flags + _init_completion -n : || return + + flags=$( clang --autocomplete="$cur" ) + if [[ "$flags" == "" || "$cur" == "" ]]; then +_filedir + else +COMPREPLY=( $( compgen -W "$flags" -- "$cur" ) ) + fi +} +complete -F _clang clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r303672 - Remove trailing whitespace
Author: yamaguchi Date: Tue May 23 13:52:27 2017 New Revision: 303672 URL: http://llvm.org/viewvc/llvm-project?rev=303672&view=rev Log: Remove trailing whitespace Modified: cfe/trunk/utils/bash-autocomplete.sh Modified: cfe/trunk/utils/bash-autocomplete.sh URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=303672&r1=303671&r2=303672&view=diff == --- cfe/trunk/utils/bash-autocomplete.sh (original) +++ cfe/trunk/utils/bash-autocomplete.sh Tue May 23 13:52:27 2017 @@ -10,5 +10,5 @@ _clang() else COMPREPLY=( $( compgen -W "$flags" -- "$cur" ) ) fi -} +} complete -F _clang clang ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits