[clang-tools-extra] e636e6b - [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro
Author: Konrad Kleine Date: 2020-06-03T16:56:03-04:00 New Revision: e636e6b79ac06b13059e46b49acb4d9de204c75b URL: https://github.com/llvm/llvm-project/commit/e636e6b79ac06b13059e46b49acb4d9de204c75b DIFF: https://github.com/llvm/llvm-project/commit/e636e6b79ac06b13059e46b49acb4d9de204c75b.diff LOG: [clang-tidy]: Added modernize-replace-disallow-copy-and-assign-macro Summary: This check finds macro expansions of `DISALLOW_COPY_AND_ASSIGN(Type)` and replaces them with a deleted copy constructor and a deleted assignment operator. Before the `delete` keyword was introduced in C++11 it was common practice to declare a copy constructor and an assignment operator as a private members. This effectively makes them unusable to the public API of a class. With the advent of the `delete` keyword in C++11 we can abandon the `private` access of the copy constructor and the assignment operator and delete the methods entirely. Migration example: ``` lang=dif class Foo { private: - DISALLOW_COPY_AND_ASSIGN(Foo); + Foo(const Foo &) = delete; + const Foo &operator=(const Foo &) = delete; }; ``` Reviewers: alexfh, hokein, aaron.ballman, njames93 Reviewed By: njames93 Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D80531 Added: clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.h clang-tools-extra/docs/clang-tidy/checks/modernize-replace-disallow-copy-and-assign-macro.rst clang-tools-extra/test/clang-tidy/checkers/modernize-replace-disallow-copy-and-assign-macro.cpp Modified: clang-tools-extra/clang-tidy/modernize/CMakeLists.txt clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp clang-tools-extra/docs/ReleaseNotes.rst clang-tools-extra/docs/clang-tidy/checks/list.rst Removed: diff --git a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt index 8fcbfbe40b23..c74c4051ade7 100644 --- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt @@ -19,6 +19,7 @@ add_clang_library(clangTidyModernizeModule RawStringLiteralCheck.cpp RedundantVoidArgCheck.cpp ReplaceAutoPtrCheck.cpp + ReplaceDisallowCopyAndAssignMacroCheck.cpp ReplaceRandomShuffleCheck.cpp ReturnBracedInitListCheck.cpp ShrinkToFitCheck.cpp diff --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp index 6280f9c991e8..d9ccd2cd0ad7 100644 --- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp @@ -21,6 +21,7 @@ #include "RawStringLiteralCheck.h" #include "RedundantVoidArgCheck.h" #include "ReplaceAutoPtrCheck.h" +#include "ReplaceDisallowCopyAndAssignMacroCheck.h" #include "ReplaceRandomShuffleCheck.h" #include "ReturnBracedInitListCheck.h" #include "ShrinkToFitCheck.h" @@ -67,6 +68,8 @@ class ModernizeModule : public ClangTidyModule { "modernize-redundant-void-arg"); CheckFactories.registerCheck( "modernize-replace-auto-ptr"); +CheckFactories.registerCheck( +"modernize-replace-disallow-copy-and-assign-macro"); CheckFactories.registerCheck( "modernize-replace-random-shuffle"); CheckFactories.registerCheck( diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp new file mode 100644 index ..2219a3c477b3 --- /dev/null +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceDisallowCopyAndAssignMacroCheck.cpp @@ -0,0 +1,90 @@ +//===--- ReplaceDisallowCopyAndAssignMacroCheck.cpp - clang-tidy --===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===--===// + +#include "ReplaceDisallowCopyAndAssignMacroCheck.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/Lex/MacroArgs.h" +#include "llvm/Support/FormatVariadic.h" + +namespace clang { +namespace tidy { +namespace modernize { + +namespace { + +class ReplaceDisallowCopyAndAssignMacroCallbacks : public PPCallbacks { +public: + explicit ReplaceDisallowCopyAndAssignMacroCallbacks( + ReplaceDisallowCopyAndAssignMacroCheck &Check, Preprocessor &PP) + : Check(Check), PP(PP) {} + + void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD, +SourceRange Range, const MacroArgs *
[clang-tools-extra] 24b4965 - [clang/clang-tools-extra] Fix BZ44437 - add_new_check.py does not work with Python 3
Author: Konrad Kleine Date: 2020-05-05T17:22:50-04:00 New Revision: 24b4965ce65b14ead595dcc68add22ba37533207 URL: https://github.com/llvm/llvm-project/commit/24b4965ce65b14ead595dcc68add22ba37533207 DIFF: https://github.com/llvm/llvm-project/commit/24b4965ce65b14ead595dcc68add22ba37533207.diff LOG: [clang/clang-tools-extra] Fix BZ44437 - add_new_check.py does not work with Python 3 Summary: This fixes https://bugs.llvm.org/show_bug.cgi?id=44437. Thanks to Arnaud Desitter for providing the patch in the bug report! A simple example program to reproduce this error is this: ```lang=python import sys with open(sys.argv[0], 'r') as f: lines = f.readlines() lines = iter(lines) line = lines.next() print(line) ``` which will error with this in python python 3: ``` Traceback (most recent call last): File "./mytest.py", line 8, in line = lines.next() AttributeError: 'list_iterator' object has no attribute 'next' ``` Here's the same strategy applied to my test program as applied to the `add_new_check.py` file: ```lang=python import sys with open(sys.argv[0], 'r') as f: lines = f.readlines() lines = iter(lines) line = next(lines) print(line) ``` The built-in function `next()` is new since Python 2.6: https://docs.python.org/2/library/functions.html#next Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D79419 Added: Modified: clang-tools-extra/clang-tidy/add_new_check.py Removed: diff --git a/clang-tools-extra/clang-tidy/add_new_check.py b/clang-tools-extra/clang-tidy/add_new_check.py index 22aadd612d70..4477444cc127 100755 --- a/clang-tools-extra/clang-tidy/add_new_check.py +++ b/clang-tools-extra/clang-tidy/add_new_check.py @@ -172,7 +172,7 @@ def adapt_module(module_path, module, check_name, check_name_camel): lines = iter(lines) try: while True: -line = lines.next() +line = next(lines) if not header_added: match = re.search('#include "(.*)"', line) if match: @@ -197,7 +197,7 @@ def adapt_module(module_path, module, check_name, check_name_camel): # If we didn't find the check name on this line, look on the # next one. prev_line = line -line = lines.next() +line = next(lines) match = re.search(' *"([^"]*)"', line) if match: current_check_name = match.group(1) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] test-release.sh: Add a CMake cache file for 3-stage release builds (PR #75903)
@@ -0,0 +1,41 @@ +# Plain options configure the first build. +# BOOTSTRAP_* options configure the second build. +# BOOTSTRAP_BOOTSTRAP_* options configure the third build. + +set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "") + +# Stage 1 Bootstrap Setup +set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "") +set(CLANG_BOOTSTRAP_TARGETS + clang + check-all + check-llvm + check-clang + test-suite + stage3 + stage3-clang + stage3-check-all + stage3-check-llvm + stage3-check-clang + stage3-install + stage3-test-suite CACHE STRING "") + +# Stage 1 Options +set(LLVM_ENABLE_PROJECTS "clang" CACHE STRING "") +set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "") + +# Stage 2 Bootstrap Setup +set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP=ON CACHE STRING "") kwk wrote: ```suggestion set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP ON CACHE STRING "") ``` We don't need the additional `=`, do we @tstellar ? https://github.com/llvm/llvm-project/pull/75903 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 063bd3b - [format] Use int8_t as the underlying type of all enums in FormatStyle
Author: Konrad Kleine Date: 2022-03-21T21:19:00Z New Revision: 063bd3b886b2e9baf35de5655807d150dd727038 URL: https://github.com/llvm/llvm-project/commit/063bd3b886b2e9baf35de5655807d150dd727038 DIFF: https://github.com/llvm/llvm-project/commit/063bd3b886b2e9baf35de5655807d150dd727038.diff LOG: [format] Use int8_t as the underlying type of all enums in FormatStyle It was requested here (https://reviews.llvm.org/D120398#3353053) to make the underlying type of all enums in `FormatStyle` an `int8_t`. Originally the type was changed in https://reviews.llvm.org/D93758. Reviewed By: HazardyKnusperkeks, curdeius, owenpan Differential Revision: https://reviews.llvm.org/D120884 Added: Modified: clang/include/clang/Format/Format.h Removed: diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index d815eb1165bb3..e1f5974bd74a0 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -62,7 +62,7 @@ struct FormatStyle { int AccessModifierOffset; /// Different styles for aligning after open brackets. - enum BracketAlignmentStyle : unsigned char { + enum BracketAlignmentStyle : int8_t { /// Align parameters on the open bracket, e.g.: /// \code /// someLongFunction(argument1, @@ -105,7 +105,7 @@ struct FormatStyle { BracketAlignmentStyle AlignAfterOpenBracket; /// Different style for aligning array initializers. - enum ArrayInitializerAlignmentStyle { + enum ArrayInitializerAlignmentStyle : int8_t { /// Align array column and left justify the columns e.g.: /// \code /// struct test demo[] = @@ -296,7 +296,7 @@ struct FormatStyle { AlignConsecutiveStyle AlignConsecutiveDeclarations; /// Different styles for aligning escaped newlines. - enum EscapedNewlineAlignmentStyle : unsigned char { + enum EscapedNewlineAlignmentStyle : int8_t { /// Don't align escaped newlines. /// \code /// #define A \ @@ -331,7 +331,7 @@ struct FormatStyle { EscapedNewlineAlignmentStyle AlignEscapedNewlines; /// Different styles for aligning operands. - enum OperandAlignmentStyle : unsigned char { + enum OperandAlignmentStyle : int8_t { /// Do not align operands of binary and ternary expressions. /// The wrapped lines are indented ``ContinuationIndentWidth`` spaces from /// the start of the line. @@ -434,7 +434,7 @@ struct FormatStyle { /// Different styles for merging short blocks containing at most one /// statement. - enum ShortBlockStyle : unsigned char { + enum ShortBlockStyle : int8_t { /// Never merge blocks into a single line. /// \code /// while (true) { @@ -481,7 +481,7 @@ struct FormatStyle { /// Different styles for merging short functions containing at most one /// statement. - enum ShortFunctionStyle : unsigned char { + enum ShortFunctionStyle : int8_t { /// Never merge functions into a single line. SFS_None, /// Only merge functions defined inside a class. Same as "inline", @@ -533,7 +533,7 @@ struct FormatStyle { ShortFunctionStyle AllowShortFunctionsOnASingleLine; /// Different styles for handling short if statements. - enum ShortIfStyle : unsigned char { + enum ShortIfStyle : int8_t { /// Never put short ifs on the same line. /// \code /// if (a) @@ -605,7 +605,7 @@ struct FormatStyle { /// Different styles for merging short lambdas containing at most one /// statement. - enum ShortLambdaStyle : unsigned char { + enum ShortLambdaStyle : int8_t { /// Never merge lambdas into a single line. SLS_None, /// Only merge empty lambdas. @@ -644,7 +644,7 @@ struct FormatStyle { /// Different ways to break after the function definition return type. /// This option is **deprecated** and is retained for backwards compatibility. - enum DefinitionReturnTypeBreakingStyle : unsigned char { + enum DefinitionReturnTypeBreakingStyle : int8_t { /// Break after return type automatically. /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account. DRTBS_None, @@ -656,7 +656,7 @@ struct FormatStyle { /// Different ways to break after the function definition or /// declaration return type. - enum ReturnTypeBreakingStyle : unsigned char { + enum ReturnTypeBreakingStyle : int8_t { /// Break after return type automatically. /// ``PenaltyReturnTypeOnItsOwnLine`` is taken into account. /// \code @@ -750,7 +750,7 @@ struct FormatStyle { bool AlwaysBreakBeforeMultilineStrings; /// Different ways to break after the template declaration. - enum BreakTemplateDeclarationsStyle : unsigned char { + enum BreakTemplateDeclarationsStyle : int8_t { /// Do not force break before declaration. /// ``PenaltyBreakTemplateDeclaration`` is taken into account. /// \code @@ -828,7 +828,7 @@ struct FormatStyle { bool
[clang] d46fa02 - [clang-format] SortIncludes should support "@import" lines in Objective-C
Author: Konrad Kleine Date: 2022-04-20T07:03:35Z New Revision: d46fa023caa2db5a9f1e21dd038bcb626261d958 URL: https://github.com/llvm/llvm-project/commit/d46fa023caa2db5a9f1e21dd038bcb626261d958 DIFF: https://github.com/llvm/llvm-project/commit/d46fa023caa2db5a9f1e21dd038bcb626261d958.diff LOG: [clang-format] SortIncludes should support "@import" lines in Objective-C Fixes [[ https://github.com/llvm/llvm-project/issues/38995 | #38995 ]] This is an attempt to modify the regular expression to identify `@import` and `import` alongside the regular `#include`. The challenging part was not to support `@` in addition to `#` but how to handle everything that comes after the `include|import` keywords. Previously everything that wasn't `"` or `<` was consumed. But as you can see in this example from the issue #38995, there is no `"` or `<` following the keyword: ``` @import Foundation; ``` I experimented with a lot of fancy and useful expressions in [this online regex tool](https://regex101.com) only to find out that some things are simply not supported by the regex implementation in LLVM. * For example the beginning `[\t\ ]*` should be replacable by the horizontal whitespace character `\h*` but this will break the `SortIncludesTest.LeadingWhitespace` test. That's why I've chosen to come back to the basic building blocks. The essential change in this patch is the change from this regular expression: ``` ^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]) ~ ~~ ^ ^ | | only support # prefix not @| only support "" and <> as delimiters no support for C++ modules and ; ending. Also this allows for "> or <" or "" or <> which all seems either off or wrong. ``` to this: ``` ^[\t\ ]*[@#][\t\ ]*(import|include)([^"]*("[^"]+")|[^<]*(<[^>]+>)|[\t\ ]*([^;]+;)) ~~ ~~ ~~ ^ ^ ^ ^ ^ | | | | | Now support @ and #.Clearly support "" and <> as well as an include name without enclosing characters. Allows for no mixture of "> or <" or empty include names. ``` Here is how I've tested this patch: ``` ninja clang-Format ninja FormatTests ./tools/clang/unittests/Format/FormatTests --gtest_filter=SortIncludesTest* ``` And if that worked I doubled checked that nothing else broke by running all format checks: ``` ./tools/clang/unittests/Format/FormatTests ``` One side effect of this change is it should partially support [C++20 Module](https://en.cppreference.com/w/cpp/language/modules) `import` lines without the optional `export` in front. Adding this can be a change on its own that shouldn't be too hard. I say partially because the `@` or `#` are currently *NOT* optional in the regular expression. I see an opportunity to optimized the matching to exclude `@include` for example. But eventually these should be caught by the compiler, so... With my change, the matching group is not at a fixed position any longer. I decided to choose the last match (group) that is not empty. Reviewed By: HazardyKnusperkeks Differential Revision: https://reviews.llvm.org/D121370 Added: Modified: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h clang/lib/Format/Format.cpp clang/lib/Tooling/Inclusions/HeaderIncludes.cpp clang/unittests/Format/SortIncludesTest.cpp Removed: diff --git a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h index ea8ad896be89f..a5017bf84c24a 100644 --- a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h +++ b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h @@ -129,6 +129,23 @@ class HeaderIncludes { llvm::Regex IncludeRegex; }; +/// \returns a regex that can match various styles of C++ includes. +/// For example: +/// \code +/// #include +/// @import bar; +/// #include "bar.h" +/// \endcode +llvm::Regex getCppIncludeRegex(); + +/// \returns the last match in the list of matches that is not empty. +llvm::StringRef getIncludeNameFromMatches( +const llvm::SmallVectorImpl &Matches); + +/// \returns the given include name and removes the following symbols from the +/// beginning and ending of the include name: " > < ; +llvm::StringRef trimInclude(llvm::StringRef IncludeName); + } // namespace tooling } // namespace clang diff --git a/clang/lib/
[llvm] [clang] [CMake][PGO] Build Sema.cpp to generate profdata for PGO builds (PR #77347)
kwk wrote: @tstellar thank you for looping me in. When I did my experiments I've used the llvm-test-suite and `test-suite/utils/compare.py --metric exec_time --metric compile_time --metric link_time --lhs-name 16.0.3 --rhs-name 16.0.2-pgo /root/rawhide/results.json vs /root/pgo/results.json` to get the geomean difference. How do you measure performance? Maybe the answer is in your code but I haven't checked your code yet because I am reading this on my phone. https://github.com/llvm/llvm-project/pull/77347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake][PGO] Add option for using an external project to generate profile data (PR #78879)
https://github.com/kwk approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/78879 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake][PGO] Build Sema.cpp to generate profdata for PGO builds (PR #77347)
@@ -26,9 +30,23 @@ if(LLVM_BUILD_INSTRUMENTED) message(STATUS "To enable merging PGO data LLVM_PROFDATA has to point to llvm-profdata") else() add_custom_target(generate-profdata - COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} + COMMAND "${Python3_EXECUTABLE}" ${CMAKE_CURRENT_SOURCE_DIR}/perf-helper.py merge ${LLVM_PROFDATA} ${CMAKE_CURRENT_BINARY_DIR}/clang.profdata ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/profiles/ COMMENT "Merging profdata" DEPENDS generate-profraw) +if (CLANG_PGO_TRAINING_DATA_SOURCE_DIR) + llvm_ExternalProject_Add(generate-profraw-external ${CLANG_PGO_TRAINING_DATA_SOURCE_DIR} + USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS generate-profraw) + add_dependencies(generate-profdata generate-profraw-external) +else() + # Default to compiling a file from clang. This also builds all the + # dependencies needed to build this file, like TableGen. + set(generate_profraw_clang_sema tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/Sema.cpp.o) + llvm_ExternalProject_Add(generate-profraw-clang ${CMAKE_CURRENT_SOURCE_DIR}/../../../llvm + USE_TOOLCHAIN EXLUDE_FROM_ALL NO_INSTALL DEPENDS generate-profraw + EXTRA_TARGETS generate_profraw_clang_sema kwk wrote: > The idea I'd like explore is using libc++ (and perhaps also libc) test suite > for training. It consists of self-contained test programs which should > sufficiently exercise various aspects of C/C++ frontend. @petrhosek are you suggesting to use libc++ from in-tree or from a fixed and already released version as @llvm-beanz has suggested [here](https://github.com/llvm/llvm-project/pull/77347#discussion_r1450669301)? He hasn't suggested to use libc++ but a recent LLVM release. https://github.com/llvm/llvm-project/pull/77347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake][PGO] Build Sema.cpp to generate profdata for PGO builds (PR #77347)
kwk wrote: I want to add something as a side note because it is PGO related. Last year I've experiment with a PGO enabled LLVM toolchain on Fedora ([1], [2]). ## Summary of my experiment For training data I've used a set of packages that we build on Fedora and I've smuggled in my PGO toolchain. The RPM packaging was also tweaked to pick up the profile data and create a sub packaging automatically just like we do for debug information. This part was rather tricky and RPM related but it worked and we ended up having a profiledata-sub-package for any given project in Fedora that uses LLVM. Like I've said I've only used it for a handful of project as demonstration. ## Encountered problem But back to the point I wanted to make: **disk space for profile data** can quickly increase. I've [compiled chromium](https://kwk.github.io/pgo-experiment/#find_and_merge_profiles) in my tests and our builders exploded because of diskspace just for profile data: ``` LLVM Profile Error: Failed to write file "/builddir/build/BUILD/raw-pgo-profdata //chromium.llvm.1970228969820616430_0.24617.profraw": No space left on device ``` ## Question Is it possible to have CMake collect and merge the profile data in the background? I've used tools like [`inotifywait`](https://src.fedoraproject.org/fork/kkleine/rpms/llvm/blob/pgo/f/pgo-background-merge.sh#_128) in my PoC to look for `close_write` events to any file under a build directory that matches `.*\.profraw$`. When an entry was found, I've stored it into a file to be consumed and all profiles in it merged, once there are 10 files. This continuous merge helped me reduce the size of total profile data from ~1,4GB (unmerged) to 1,6MB (merged). This was for the `retsnoop` project. Chromium simply took to long to build for my experiment. I understand this is a special use case but one should not underestimate the size of profile data, that's all I'm saying. [1]: https://kwk.github.io/pgo-experiment/ [2]: https://developers.redhat.com/articles/2023/11/07/how-i-experimented-pgo-enabled-llvm-fedora https://github.com/llvm/llvm-project/pull/77347 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -0,0 +1,135 @@ + +#include "clang/Frontend/CodeSnippetHighlighter.h" +#include "clang/Basic/DiagnosticOptions.h" +#include "clang/Basic/SourceManager.h" +#include "clang/Lex/Lexer.h" +#include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PreprocessorOptions.h" +#include "llvm/Support/raw_ostream.h" + +using namespace clang; + +static constexpr raw_ostream::Colors CommentColor = raw_ostream::GREEN; +static constexpr raw_ostream::Colors LiteralColor = raw_ostream::CYAN; +static constexpr raw_ostream::Colors KeywordColor = raw_ostream::BLUE; + +std::vector CodeSnippetHighlighter::highlightLine( +unsigned LineNumber, const Preprocessor *PP, const LangOptions &LangOpts, +FileID FID, const SourceManager &SM) { + if (!PP) +return {}; + + // Might cause emission of another diagnostic. + if (PP->getIdentifierTable().getExternalIdentifierLookup()) +return {}; + + // Classify the given token and append it to the given vector. + auto appendStyle = [PP, &LangOpts](std::vector &Vec, + const Token &T, unsigned Start, + unsigned Length) -> void { +if (T.is(tok::raw_identifier)) { + StringRef RawIdent = T.getRawIdentifier(); + // Special case true/false/nullptr literals, since they will otherwise be + // treated as keywords. + if (RawIdent == "true" || RawIdent == "false" || RawIdent == "nullptr") { +Vec.push_back(StyleRange{Start, Start + Length, LiteralColor}); + } else { +const IdentifierInfo *II = PP->getIdentifierInfo(RawIdent); +assert(II); + +if (II->isKeyword(LangOpts)) { + Vec.push_back(StyleRange{Start, Start + Length, KeywordColor}); +} + } +} else if (tok::isLiteral(T.getKind())) { + Vec.push_back(StyleRange{Start, Start + Length, LiteralColor}); +} else if (T.is(tok::comment)) { + Vec.push_back(StyleRange{Start, Start + Length, CommentColor}); +} + }; + + auto Buff = SM.getBufferOrNone(FID); + assert(Buff); + Lexer L = Lexer(FID, *Buff, SM, LangOpts); + L.SetKeepWhitespaceMode(true); + std::vector> Lines; + + bool Stop = false; + while (!Stop) { +Token T; +Stop = L.LexFromRawLexer(T); +if (T.is(tok::unknown)) + continue; + +bool Invalid; +unsigned StartCol = +SM.getSpellingColumnNumber(T.getLocation(), &Invalid) - 1; +if (Invalid) + continue; +unsigned StartLine = +SM.getSpellingLineNumber(T.getLocation(), &Invalid) - 1; +if (Invalid) + continue; + +while (Lines.size() <= StartLine) + Lines.push_back({}); + +unsigned EndLine = SM.getSpellingLineNumber(T.getEndLoc(), &Invalid) - 1; +if (Invalid) + continue; + +// Simple tokens. +if (StartLine == EndLine) { + appendStyle(Lines[StartLine], T, StartCol, T.getLength()); + continue; +} +unsigned NumLines = EndLine - StartLine; + +// For tokens that span multiple lines (think multiline comments), we +// divide them into multiple StyleRanges. +unsigned EndCol = SM.getSpellingColumnNumber(T.getEndLoc(), &Invalid) - 1; +if (Invalid) + continue; + +std::string Spelling = Lexer::getSpelling(T, SM, LangOpts); + +unsigned L = 0; +unsigned LineLength = 0; +for (unsigned I = 0; I <= Spelling.size(); ++I) { + // This line is done. + if (Spelling[I] == '\n' || Spelling[I] == '\r' || I == Spelling.size()) { +while (Lines.size() <= StartLine + L) + Lines.push_back({}); + +if (L == 0) // First line + appendStyle(Lines[StartLine + L], T, StartCol, LineLength); +else if (L == NumLines) // Last line kwk wrote: @tbaederr if you have 10 lines and the first number is 0, then the last number must be 9. But you check for `L == 10` which seems off by one. https://github.com/llvm/llvm-project/pull/66514 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: @@ -0,0 +1,135 @@ + +#include "clang/Frontend/CodeSnippetHighlighter.h" +#include "clang/Basic/DiagnosticOptions.h" +#include "clang/Basic/SourceManager.h" +#include "clang/Lex/Lexer.h" +#include "clang/Lex/Preprocessor.h" +#include "clang/Lex/PreprocessorOptions.h" +#include "llvm/Support/raw_ostream.h" + +using namespace clang; + +static constexpr raw_ostream::Colors CommentColor = raw_ostream::GREEN; +static constexpr raw_ostream::Colors LiteralColor = raw_ostream::CYAN; +static constexpr raw_ostream::Colors KeywordColor = raw_ostream::BLUE; + +std::vector CodeSnippetHighlighter::highlightLine( +unsigned LineNumber, const Preprocessor *PP, const LangOptions &LangOpts, +FileID FID, const SourceManager &SM) { + if (!PP) +return {}; + + // Might cause emission of another diagnostic. + if (PP->getIdentifierTable().getExternalIdentifierLookup()) +return {}; + + // Classify the given token and append it to the given vector. + auto appendStyle = [PP, &LangOpts](std::vector &Vec, + const Token &T, unsigned Start, + unsigned Length) -> void { +if (T.is(tok::raw_identifier)) { + StringRef RawIdent = T.getRawIdentifier(); + // Special case true/false/nullptr literals, since they will otherwise be + // treated as keywords. + if (RawIdent == "true" || RawIdent == "false" || RawIdent == "nullptr") { +Vec.push_back(StyleRange{Start, Start + Length, LiteralColor}); + } else { +const IdentifierInfo *II = PP->getIdentifierInfo(RawIdent); +assert(II); + +if (II->isKeyword(LangOpts)) { + Vec.push_back(StyleRange{Start, Start + Length, KeywordColor}); +} + } +} else if (tok::isLiteral(T.getKind())) { + Vec.push_back(StyleRange{Start, Start + Length, LiteralColor}); +} else if (T.is(tok::comment)) { + Vec.push_back(StyleRange{Start, Start + Length, CommentColor}); +} + }; + + auto Buff = SM.getBufferOrNone(FID); + assert(Buff); + Lexer L = Lexer(FID, *Buff, SM, LangOpts); + L.SetKeepWhitespaceMode(true); + std::vector> Lines; + + bool Stop = false; + while (!Stop) { +Token T; +Stop = L.LexFromRawLexer(T); +if (T.is(tok::unknown)) + continue; + +bool Invalid; +unsigned StartCol = +SM.getSpellingColumnNumber(T.getLocation(), &Invalid) - 1; +if (Invalid) + continue; +unsigned StartLine = +SM.getSpellingLineNumber(T.getLocation(), &Invalid) - 1; +if (Invalid) + continue; + +while (Lines.size() <= StartLine) + Lines.push_back({}); + +unsigned EndLine = SM.getSpellingLineNumber(T.getEndLoc(), &Invalid) - 1; +if (Invalid) + continue; + +// Simple tokens. +if (StartLine == EndLine) { + appendStyle(Lines[StartLine], T, StartCol, T.getLength()); + continue; +} +unsigned NumLines = EndLine - StartLine; + +// For tokens that span multiple lines (think multiline comments), we +// divide them into multiple StyleRanges. +unsigned EndCol = SM.getSpellingColumnNumber(T.getEndLoc(), &Invalid) - 1; +if (Invalid) + continue; + +std::string Spelling = Lexer::getSpelling(T, SM, LangOpts); + +unsigned L = 0; +unsigned LineLength = 0; +for (unsigned I = 0; I <= Spelling.size(); ++I) { + // This line is done. + if (Spelling[I] == '\n' || Spelling[I] == '\r' || I == Spelling.size()) { +while (Lines.size() <= StartLine + L) + Lines.push_back({}); + +if (L == 0) // First line + appendStyle(Lines[StartLine + L], T, StartCol, LineLength); +else if (L == NumLines) // Last line kwk wrote: Looking at the code above you do `unsigned NumLines = EndLine - StartLine;` which explains why it works. If `StartLine` is 0, then `NumLines` is really the last index of the line rather than the total of numbers, right? https://github.com/llvm/llvm-project/pull/66514 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/kwk resolved https://github.com/llvm/llvm-project/pull/66514 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk updated https://github.com/llvm/llvm-project/pull/106407 >From f64a72d67a201334cefc08b5725aa033f1610e70 Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Wed, 28 Aug 2024 17:22:29 +0200 Subject: [PATCH] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake Take all `LLVM_RELEASE_FINAL_STAGE_TARGETS` elements and append them prefixed with `stage2-` to `CLANG_BOOTSTRAP_TARGETS`. --- clang/cmake/caches/Release.cmake | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake index 6d5f75ca0074ee..c93ff40ff3ee48 100644 --- a/clang/cmake/caches/Release.cmake +++ b/clang/cmake/caches/Release.cmake @@ -55,14 +55,22 @@ set(STAGE1_RUNTIMES "compiler-rt") if (LLVM_RELEASE_ENABLE_PGO) list(APPEND STAGE1_PROJECTS "lld") - set(CLANG_BOOTSTRAP_TARGETS + set(tmp_targets generate-profdata stage2-package stage2-clang +stage2 stage2-install stage2-check-all stage2-check-llvm -stage2-check-clang CACHE STRING "") +stage2-check-clang) + + foreach(X IN LISTS LLVM_RELEASE_FINAL_STAGE_TARGETS) +list(APPEND tmp_targets "stage2-${X}") + endforeach() + list(REMOVE_DUPLICATES tmp_targets) + + set(CLANG_BOOTSTRAP_TARGETS "${tmp_targets}" CACHE STRING "") # Configuration for stage2-instrumented set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP ON CACHE STRING "") ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk deleted https://github.com/llvm/llvm-project/pull/106407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk closed https://github.com/llvm/llvm-project/pull/106407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk created https://github.com/llvm/llvm-project/pull/106407 Take all `LLVM_RELEASE_FINAL_STAGE_TARGETS` elements and append them prefixed with `stage2-` to `CLANG_BOOTSTRAP_TARGETS`. >From 8abe54ca62eedc1a7a0307eb17d188090160bf30 Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Wed, 28 Aug 2024 17:22:29 +0200 Subject: [PATCH] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake Take all `LLVM_RELEASE_FINAL_STAGE_TARGETS` elements and append them prefixed with `stage2-` to `CLANG_BOOTSTRAP_TARGETS`. --- clang/cmake/caches/Release.cmake | 4 1 file changed, 4 insertions(+) diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake index e5161dd9a27b96..4354a243f51e4e 100644 --- a/clang/cmake/caches/Release.cmake +++ b/clang/cmake/caches/Release.cmake @@ -68,6 +68,10 @@ if (LLVM_RELEASE_ENABLE_PGO) set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE STRING "") set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt" CACHE STRING "") set(BOOTSTRAP_LLVM_ENABLE_PROJECTS "clang;lld" CACHE STRING "") + foreach(X IN LISTS LLVM_RELEASE_FINAL_STAGE_TARGETS) +list(APPEND CLANG_BOOTSTRAP_TARGETS "stage2-${X}") + endforeach() + list(REMOVE_DUPLICATES CLANG_BOOTSTRAP_TARGETS) else() if (LLVM_RELEASE_ENABLE_LTO) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk edited https://github.com/llvm/llvm-project/pull/106407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk edited https://github.com/llvm/llvm-project/pull/106407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk converted_to_draft https://github.com/llvm/llvm-project/pull/106407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk updated https://github.com/llvm/llvm-project/pull/106407 >From ca503d037c9e05bd986dfe56296059c691db822a Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Wed, 28 Aug 2024 17:22:29 +0200 Subject: [PATCH] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake Take all `LLVM_RELEASE_FINAL_STAGE_TARGETS` elements and append them prefixed with `stage2-` to `CLANG_BOOTSTRAP_TARGETS`. --- clang/cmake/caches/Release.cmake | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake index 6d5f75ca0074ee..50c8696402b938 100644 --- a/clang/cmake/caches/Release.cmake +++ b/clang/cmake/caches/Release.cmake @@ -55,15 +55,23 @@ set(STAGE1_RUNTIMES "compiler-rt") if (LLVM_RELEASE_ENABLE_PGO) list(APPEND STAGE1_PROJECTS "lld") - set(CLANG_BOOTSTRAP_TARGETS + set(tmp_targets generate-profdata stage2-package stage2-clang +stage2 stage2-install stage2-check-all stage2-check-llvm stage2-check-clang CACHE STRING "") + foreach(X IN LISTS LLVM_RELEASE_FINAL_STAGE_TARGETS) +list(APPEND tmp_targets "stage2-${X}") + endforeach() + list(REMOVE_DUPLICATES tmp_targets) + + set(CLANG_BOOTSTRAP_TARGETS "${tmp_targets}" CACHE STRING "") + # Configuration for stage2-instrumented set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP ON CACHE STRING "") # This enables the build targets for the final stage which is called stage2. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk ready_for_review https://github.com/llvm/llvm-project/pull/106407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
https://github.com/kwk updated https://github.com/llvm/llvm-project/pull/106407 >From ca503d037c9e05bd986dfe56296059c691db822a Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Wed, 28 Aug 2024 17:22:29 +0200 Subject: [PATCH] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake Take all `LLVM_RELEASE_FINAL_STAGE_TARGETS` elements and append them prefixed with `stage2-` to `CLANG_BOOTSTRAP_TARGETS`. --- clang/cmake/caches/Release.cmake | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/clang/cmake/caches/Release.cmake b/clang/cmake/caches/Release.cmake index 6d5f75ca0074ee..50c8696402b938 100644 --- a/clang/cmake/caches/Release.cmake +++ b/clang/cmake/caches/Release.cmake @@ -55,15 +55,23 @@ set(STAGE1_RUNTIMES "compiler-rt") if (LLVM_RELEASE_ENABLE_PGO) list(APPEND STAGE1_PROJECTS "lld") - set(CLANG_BOOTSTRAP_TARGETS + set(tmp_targets generate-profdata stage2-package stage2-clang +stage2 stage2-install stage2-check-all stage2-check-llvm stage2-check-clang CACHE STRING "") + foreach(X IN LISTS LLVM_RELEASE_FINAL_STAGE_TARGETS) +list(APPEND tmp_targets "stage2-${X}") + endforeach() + list(REMOVE_DUPLICATES tmp_targets) + + set(CLANG_BOOTSTRAP_TARGETS "${tmp_targets}" CACHE STRING "") + # Configuration for stage2-instrumented set(BOOTSTRAP_CLANG_ENABLE_BOOTSTRAP ON CACHE STRING "") # This enables the build targets for the final stage which is called stage2. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Fix CLANG_BOOTSTRAP_TARGETS in Release.cmake (PR #106407)
@@ -55,15 +55,23 @@ set(STAGE1_RUNTIMES "compiler-rt") if (LLVM_RELEASE_ENABLE_PGO) list(APPEND STAGE1_PROJECTS "lld") - set(CLANG_BOOTSTRAP_TARGETS + set(tmp_targets generate-profdata stage2-package stage2-clang +stage2 stage2-install stage2-check-all stage2-check-llvm stage2-check-clang CACHE STRING "") kwk wrote: @tstellar I don't know but I guess the `CACHE STRING ""` can be removed for the `tmp_targets`, right? https://github.com/llvm/llvm-project/pull/106407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [perf-training] Fix dependencies when using -DCLANG_PGO_TRAINING_DATA_SOURCE_DIR (PR #108488)
kwk wrote: I'm trying this patch locally now. https://github.com/llvm/llvm-project/pull/108488 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Filter out configuration file from compile commands (PR #131099)
kwk wrote: @aaupov ping https://github.com/llvm/llvm-project/pull/131099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Filter out configuration line (PR #131099)
https://github.com/kwk created https://github.com/llvm/llvm-project/pull/131099 The commands to run the compilation when printed with `-###` shows various irrelevant lines for the perf-training. Most of them are filtered out already but when configured with `CLANG_CONFIG_FILE_SYSTEM_DIR` a new line like the following is added and needs to be filtered out: `Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg` >From db5d475fd1e24278782536f9ed13b898a2bc450a Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Thu, 13 Mar 2025 09:12:24 +0100 Subject: [PATCH] Filter out configuration line The commands to run the compilation when printed with `-###` shows various irrelevant lines for the perf-training. Most of them are filtered out already but when configured with `CLANG_CONFIG_FILE_SYSTEM_DIR` a new line like the following is added and needs to be filtered out: `Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg` --- clang/utils/perf-training/perf-helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/utils/perf-training/perf-helper.py b/clang/utils/perf-training/perf-helper.py index 80c6356d0497c..29904aded5ab0 100644 --- a/clang/utils/perf-training/perf-helper.py +++ b/clang/utils/perf-training/perf-helper.py @@ -237,6 +237,7 @@ def get_cc1_command_for_args(cmd, env): or ln.startswith("InstalledDir:") or ln.startswith("LLVM Profile Note") or ln.startswith(" (in-process)") +or ln.startswith("Configuration file:") or " version " in ln ): continue ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Filter out configuration file from compile commands (PR #131099)
https://github.com/kwk edited https://github.com/llvm/llvm-project/pull/131099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Filter out configuration file from compile command (PR #131099)
https://github.com/kwk edited https://github.com/llvm/llvm-project/pull/131099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Filter out configuration file from compile commands (PR #131099)
https://github.com/kwk edited https://github.com/llvm/llvm-project/pull/131099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Filter out configuration file from compile commands (PR #131099)
https://github.com/kwk updated https://github.com/llvm/llvm-project/pull/131099 >From e43271ec7438ecb78f99db134aeca274a47f6c28 Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Thu, 13 Mar 2025 09:12:24 +0100 Subject: [PATCH] Filter out configuration file from compile commands The commands to run the compilation when printed with `-###` contain various irrelevant lines for the perf-training. Most of them are filtered out already but when configured with `CLANG_CONFIG_FILE_SYSTEM_DIR` a new line like the following is added and needs to be filtered out: `Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg` --- clang/utils/perf-training/perf-helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/utils/perf-training/perf-helper.py b/clang/utils/perf-training/perf-helper.py index 80c6356d0497c..29904aded5ab0 100644 --- a/clang/utils/perf-training/perf-helper.py +++ b/clang/utils/perf-training/perf-helper.py @@ -237,6 +237,7 @@ def get_cc1_command_for_args(cmd, env): or ln.startswith("InstalledDir:") or ln.startswith("LLVM Profile Note") or ln.startswith(" (in-process)") +or ln.startswith("Configuration file:") or " version " in ln ): continue ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Filter out configuration file from compile commands (PR #131099)
https://github.com/kwk closed https://github.com/llvm/llvm-project/pull/131099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits