<div dir="ltr">All chromium bots build with asserts on and we definitely don't want shared libs :-) Having the people who care about this build config make sure it keeps working seems like a good approach to me.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 4, 2018 at 8:15 AM, David Zarzycki via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What’s stopping the project from automatically setting BUILD_SHARED_LIBS to TRUE if asserts are enabled? That’d automatically “force” active developers to test the scenario on their local machines, but not change the way release builds work.<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
<br>
> On Jun 4, 2018, at 8:11 AM, Roman Lebedev via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
> <br>
> This broke building as shared libraries.<br>
> <br>
> I've committed the fix, but the bot coverage is clearly severely missing,<br>
> given that such breakages are very often.<br>
> <br>
> Roman.<br>
> <br>
> On Mon, Jun 4, 2018 at 12:04 PM, Eric Liu via cfe-commits<br>
> <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
>> Author: ioeric<br>
>> Date: Mon Jun 4 02:04:12 2018<br>
>> New Revision: 333874<br>
>> <br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=333874&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=333874&view=rev</a><br>
>> Log:<br>
>> Reland "Move #include manipulation code to new lib/Tooling/Inclusions."<br>
>> <br>
>> This reverts commit r333534 (i.e. reland r332720) after fixing module build.<br>
>> <br>
>> Differential Revision: <a href="https://reviews.llvm.org/D47068" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D47068</a><br>
>> <br>
>> Added:<br>
>> cfe/trunk/include/clang/<wbr>Tooling/Inclusions/<wbr>HeaderIncludes.h<br>
>> - copied, changed from r333865, cfe/trunk/include/clang/<wbr>Tooling/Core/HeaderIncludes.h<br>
>> cfe/trunk/include/clang/<wbr>Tooling/Inclusions/<wbr>IncludeStyle.h<br>
>> - copied, changed from r333865, cfe/trunk/include/clang/<wbr>Tooling/Core/IncludeStyle.h<br>
>> cfe/trunk/lib/Tooling/<wbr>Inclusions/CMakeLists.txt<br>
>> - copied, changed from r333865, cfe/trunk/lib/Tooling/Core/<wbr>CMakeLists.txt<br>
>> cfe/trunk/lib/Tooling/<wbr>Inclusions/HeaderIncludes.cpp<br>
>> - copied, changed from r333865, cfe/trunk/lib/Tooling/Core/<wbr>HeaderIncludes.cpp<br>
>> cfe/trunk/lib/Tooling/<wbr>Inclusions/IncludeStyle.cpp<br>
>> - copied, changed from r333865, cfe/trunk/lib/Tooling/Core/<wbr>IncludeStyle.cpp<br>
>> Removed:<br>
>> cfe/trunk/include/clang/<wbr>Tooling/Core/HeaderIncludes.h<br>
>> cfe/trunk/include/clang/<wbr>Tooling/Core/IncludeStyle.h<br>
>> cfe/trunk/lib/Tooling/Core/<wbr>HeaderIncludes.cpp<br>
>> cfe/trunk/lib/Tooling/Core/<wbr>IncludeStyle.cpp<br>
>> Modified:<br>
>> cfe/trunk/include/clang/<wbr>Format/Format.h<br>
>> cfe/trunk/include/clang/<wbr>module.modulemap<br>
>> cfe/trunk/lib/Format/<wbr>CMakeLists.txt<br>
>> cfe/trunk/lib/Format/Format.<wbr>cpp<br>
>> cfe/trunk/lib/Tooling/<wbr>CMakeLists.txt<br>
>> cfe/trunk/lib/Tooling/Core/<wbr>CMakeLists.txt<br>
>> cfe/trunk/unittests/Tooling/<wbr>HeaderIncludesTest.cpp<br>
>> <br>
>> Modified: cfe/trunk/include/clang/<wbr>Format/Format.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=333874&r1=333873&r2=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Format/Format.h?rev=<wbr>333874&r1=333873&r2=333874&<wbr>view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/include/clang/<wbr>Format/Format.h (original)<br>
>> +++ cfe/trunk/include/clang/<wbr>Format/Format.h Mon Jun 4 02:04:12 2018<br>
>> @@ -16,8 +16,8 @@<br>
>> #define LLVM_CLANG_FORMAT_FORMAT_H<br>
>> <br>
>> #include "clang/Basic/LangOptions.h"<br>
>> -#include "clang/Tooling/Core/<wbr>IncludeStyle.h"<br>
>> #include "clang/Tooling/Core/<wbr>Replacement.h"<br>
>> +#include "clang/Tooling/Inclusions/<wbr>IncludeStyle.h"<br>
>> #include "llvm/ADT/ArrayRef.h"<br>
>> #include "llvm/Support/Regex.h"<br>
>> #include <system_error><br>
>> <br>
>> Removed: cfe/trunk/include/clang/<wbr>Tooling/Core/HeaderIncludes.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h?rev=333873&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Tooling/Core/<wbr>HeaderIncludes.h?rev=333873&<wbr>view=auto</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/include/clang/<wbr>Tooling/Core/HeaderIncludes.h (original)<br>
>> +++ cfe/trunk/include/clang/<wbr>Tooling/Core/HeaderIncludes.h (removed)<br>
>> @@ -1,137 +0,0 @@<br>
>> -//===--- HeaderIncludes.h - Insert/Delete #includes for C++ code--*- C++-*-===//<br>
>> -//<br>
>> -// The LLVM Compiler Infrastructure<br>
>> -//<br>
>> -// This file is distributed under the University of Illinois Open Source<br>
>> -// License. See LICENSE.TXT for details.<br>
>> -//<br>
>> -//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
>> -<br>
>> -#ifndef LLVM_CLANG_TOOLING_CORE_<wbr>HEADERINCLUDES_H<br>
>> -#define LLVM_CLANG_TOOLING_CORE_<wbr>HEADERINCLUDES_H<br>
>> -<br>
>> -#include "clang/Basic/SourceManager.h"<br>
>> -#include "clang/Tooling/Core/<wbr>Replacement.h"<br>
>> -#include "clang/Tooling/Core/<wbr>IncludeStyle.h"<br>
>> -#include "llvm/Support/Path.h"<br>
>> -#include "llvm/Support/Regex.h"<br>
>> -#include <unordered_map><br>
>> -<br>
>> -namespace clang {<br>
>> -namespace tooling {<br>
>> -<br>
>> -/// This class manages priorities of C++ #include categories and calculates<br>
>> -/// priorities for headers.<br>
>> -/// FIXME(ioeric): move this class into implementation file when clang-format's<br>
>> -/// include sorting functions are also moved here.<br>
>> -class IncludeCategoryManager {<br>
>> -public:<br>
>> - IncludeCategoryManager(const IncludeStyle &Style, StringRef FileName);<br>
>> -<br>
>> - /// Returns the priority of the category which \p IncludeName belongs to.<br>
>> - /// If \p CheckMainHeader is true and \p IncludeName is a main header, returns<br>
>> - /// 0. Otherwise, returns the priority of the matching category or INT_MAX.<br>
>> - /// NOTE: this API is not thread-safe!<br>
>> - int getIncludePriority(StringRef IncludeName, bool CheckMainHeader) const;<br>
>> -<br>
>> -private:<br>
>> - bool isMainHeader(StringRef IncludeName) const;<br>
>> -<br>
>> - const IncludeStyle Style;<br>
>> - bool IsMainFile;<br>
>> - std::string FileName;<br>
>> - // This refers to a substring in FileName.<br>
>> - StringRef FileStem;<br>
>> - // Regex is not thread-safe.<br>
>> - mutable SmallVector<llvm::Regex, 4> CategoryRegexs;<br>
>> -};<br>
>> -<br>
>> -/// Generates replacements for inserting or deleting #include directives in a<br>
>> -/// file.<br>
>> -class HeaderIncludes {<br>
>> -public:<br>
>> - HeaderIncludes(llvm::StringRef FileName, llvm::StringRef Code,<br>
>> - const IncludeStyle &Style);<br>
>> -<br>
>> - /// Inserts an #include directive of \p Header into the code. If \p IsAngled<br>
>> - /// is true, \p Header will be quoted with <> in the directive; otherwise, it<br>
>> - /// will be quoted with "".<br>
>> - ///<br>
>> - /// When searching for points to insert new header, this ignores #include's<br>
>> - /// after the #include block(s) in the beginning of a file to avoid inserting<br>
>> - /// headers into code sections where new #include's should not be added by<br>
>> - /// default. These code sections include:<br>
>> - /// - raw string literals (containing #include).<br>
>> - /// - #if blocks.<br>
>> - /// - Special #include's among declarations (e.g. functions).<br>
>> - ///<br>
>> - /// Returns a replacement that inserts the new header into a suitable #include<br>
>> - /// block of the same category. This respects the order of the existing<br>
>> - /// #includes in the block; if the existing #includes are not already sorted,<br>
>> - /// this will simply insert the #include in front of the first #include of the<br>
>> - /// same category in the code that should be sorted after \p IncludeName. If<br>
>> - /// \p IncludeName already exists (with exactly the same spelling), this<br>
>> - /// returns None.<br>
>> - llvm::Optional<tooling::<wbr>Replacement> insert(llvm::StringRef Header,<br>
>> - bool IsAngled) const;<br>
>> -<br>
>> - /// Removes all existing #includes of \p Header quoted with <> if \p IsAngled<br>
>> - /// is true or "" if \p IsAngled is false.<br>
>> - /// This doesn't resolve the header file path; it only deletes #includes with<br>
>> - /// exactly the same spelling.<br>
>> - tooling::Replacements remove(llvm::StringRef Header, bool IsAngled) const;<br>
>> -<br>
>> -private:<br>
>> - struct Include {<br>
>> - Include(StringRef Name, tooling::Range R) : Name(Name), R(R) {}<br>
>> -<br>
>> - // An include header quoted with either <> or "".<br>
>> - std::string Name;<br>
>> - // The range of the whole line of include directive including any eading<br>
>> - // whitespaces and trailing comment.<br>
>> - tooling::Range R;<br>
>> - };<br>
>> -<br>
>> - void addExistingInclude(Include IncludeToAdd, unsigned NextLineOffset);<br>
>> -<br>
>> - std::string FileName;<br>
>> - std::string Code;<br>
>> -<br>
>> - // Map from include name (quotation trimmed) to a list of existing includes<br>
>> - // (in case there are more than one) with the name in the current file. <x><br>
>> - // and "x" will be treated as the same header when deleting #includes.<br>
>> - llvm::StringMap<llvm::<wbr>SmallVector<Include, 1>> ExistingIncludes;<br>
>> -<br>
>> - /// Map from priorities of #include categories to all #includes in the same<br>
>> - /// category. This is used to find #includes of the same category when<br>
>> - /// inserting new #includes. #includes in the same categories are sorted in<br>
>> - /// in the order they appear in the source file.<br>
>> - /// See comment for "FormatStyle::<wbr>IncludeCategories" for details about include<br>
>> - /// priorities.<br>
>> - std::unordered_map<int, llvm::SmallVector<const Include *, 8>><br>
>> - IncludesByPriority;<br>
>> -<br>
>> - int FirstIncludeOffset;<br>
>> - // All new headers should be inserted after this offset (e.g. after header<br>
>> - // guards, file comment).<br>
>> - unsigned MinInsertOffset;<br>
>> - // Max insertion offset in the original code. For example, we want to avoid<br>
>> - // inserting new #includes into the actual code section (e.g. after a<br>
>> - // declaration).<br>
>> - unsigned MaxInsertOffset;<br>
>> - IncludeCategoryManager Categories;<br>
>> - // Record the offset of the end of the last include in each category.<br>
>> - std::unordered_map<int, int> CategoryEndOffsets;<br>
>> -<br>
>> - // All possible priorities.<br>
>> - std::set<int> Priorities;<br>
>> -<br>
>> - // Matches a whole #include directive.<br>
>> - llvm::Regex IncludeRegex;<br>
>> -};<br>
>> -<br>
>> -<br>
>> -} // namespace tooling<br>
>> -} // namespace clang<br>
>> -<br>
>> -#endif // LLVM_CLANG_TOOLING_CORE_<wbr>HEADERINCLUDES_H<br>
>> <br>
>> Removed: cfe/trunk/include/clang/<wbr>Tooling/Core/IncludeStyle.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h?rev=333873&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Tooling/Core/<wbr>IncludeStyle.h?rev=333873&<wbr>view=auto</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/include/clang/<wbr>Tooling/Core/IncludeStyle.h (original)<br>
>> +++ cfe/trunk/include/clang/<wbr>Tooling/Core/IncludeStyle.h (removed)<br>
>> @@ -1,133 +0,0 @@<br>
>> -//===--- IncludeStyle.h - Style of C++ #include directives -------*- C++-*-===//<br>
>> -//<br>
>> -// The LLVM Compiler Infrastructure<br>
>> -//<br>
>> -// This file is distributed under the University of Illinois Open Source<br>
>> -// License. See LICENSE.TXT for details.<br>
>> -//<br>
>> -//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
>> -<br>
>> -#ifndef LLVM_CLANG_TOOLING_CORE_<wbr>INCLUDESTYLE_H<br>
>> -#define LLVM_CLANG_TOOLING_CORE_<wbr>INCLUDESTYLE_H<br>
>> -<br>
>> -#include "llvm/Support/YAMLTraits.h"<br>
>> -#include <string><br>
>> -#include <vector><br>
>> -<br>
>> -namespace clang {<br>
>> -namespace tooling {<br>
>> -<br>
>> -/// Style for sorting and grouping C++ #include directives.<br>
>> -struct IncludeStyle {<br>
>> - /// Styles for sorting multiple ``#include`` blocks.<br>
>> - enum IncludeBlocksStyle {<br>
>> - /// Sort each ``#include`` block separately.<br>
>> - /// \code<br>
>> - /// #include "b.h" into #include "b.h"<br>
>> - ///<br>
>> - /// #include <lib/main.h> #include "a.h"<br>
>> - /// #include "a.h" #include <lib/main.h><br>
>> - /// \endcode<br>
>> - IBS_Preserve,<br>
>> - /// Merge multiple ``#include`` blocks together and sort as one.<br>
>> - /// \code<br>
>> - /// #include "b.h" into #include "a.h"<br>
>> - /// #include "b.h"<br>
>> - /// #include <lib/main.h> #include <lib/main.h><br>
>> - /// #include "a.h"<br>
>> - /// \endcode<br>
>> - IBS_Merge,<br>
>> - /// Merge multiple ``#include`` blocks together and sort as one.<br>
>> - /// Then split into groups based on category priority. See<br>
>> - /// ``IncludeCategories``.<br>
>> - /// \code<br>
>> - /// #include "b.h" into #include "a.h"<br>
>> - /// #include "b.h"<br>
>> - /// #include <lib/main.h><br>
>> - /// #include "a.h" #include <lib/main.h><br>
>> - /// \endcode<br>
>> - IBS_Regroup,<br>
>> - };<br>
>> -<br>
>> - /// Dependent on the value, multiple ``#include`` blocks can be sorted<br>
>> - /// as one and divided based on category.<br>
>> - IncludeBlocksStyle IncludeBlocks;<br>
>> -<br>
>> - /// See documentation of ``IncludeCategories``.<br>
>> - struct IncludeCategory {<br>
>> - /// The regular expression that this category matches.<br>
>> - std::string Regex;<br>
>> - /// The priority to assign to this category.<br>
>> - int Priority;<br>
>> - bool operator==(const IncludeCategory &Other) const {<br>
>> - return Regex == Other.Regex && Priority == Other.Priority;<br>
>> - }<br>
>> - };<br>
>> -<br>
>> - /// Regular expressions denoting the different ``#include`` categories<br>
>> - /// used for ordering ``#includes``.<br>
>> - ///<br>
>> - /// These regular expressions are matched against the filename of an include<br>
>> - /// (including the <> or "") in order. The value belonging to the first<br>
>> - /// matching regular expression is assigned and ``#includes`` are sorted first<br>
>> - /// according to increasing category number and then alphabetically within<br>
>> - /// each category.<br>
>> - ///<br>
>> - /// If none of the regular expressions match, INT_MAX is assigned as<br>
>> - /// category. The main header for a source file automatically gets category 0.<br>
>> - /// so that it is generally kept at the beginning of the ``#includes``<br>
>> - /// (<a href="http://llvm.org/docs/CodingStandards.html#include-style" rel="noreferrer" target="_blank">http://llvm.org/docs/<wbr>CodingStandards.html#include-<wbr>style</a>). However, you<br>
>> - /// can also assign negative priorities if you have certain headers that<br>
>> - /// always need to be first.<br>
>> - ///<br>
>> - /// To configure this in the .clang-format file, use:<br>
>> - /// \code{.yaml}<br>
>> - /// IncludeCategories:<br>
>> - /// - Regex: '^"(llvm|llvm-c|clang|clang-c)<wbr>/'<br>
>> - /// Priority: 2<br>
>> - /// - Regex: '^(<|"(gtest|gmock|isl|json)/)<wbr>'<br>
>> - /// Priority: 3<br>
>> - /// - Regex: '.*'<br>
>> - /// Priority: 1<br>
>> - /// \endcode<br>
>> - std::vector<IncludeCategory> IncludeCategories;<br>
>> -<br>
>> - /// Specify a regular expression of suffixes that are allowed in the<br>
>> - /// file-to-main-include mapping.<br>
>> - ///<br>
>> - /// When guessing whether a #include is the "main" include (to assign<br>
>> - /// category 0, see above), use this regex of allowed suffixes to the header<br>
>> - /// stem. A partial match is done, so that:<br>
>> - /// - "" means "arbitrary suffix"<br>
>> - /// - "$" means "no suffix"<br>
>> - ///<br>
>> - /// For example, if configured to "(_test)?$", then a header a.h would be seen<br>
>> - /// as the "main" include in both a.cc and a_test.cc.<br>
>> - std::string IncludeIsMainRegex;<br>
>> -};<br>
>> -<br>
>> -} // namespace tooling<br>
>> -} // namespace clang<br>
>> -<br>
>> -LLVM_YAML_IS_SEQUENCE_VECTOR(<wbr>clang::tooling::IncludeStyle::<wbr>IncludeCategory)<br>
>> -<br>
>> -namespace llvm {<br>
>> -namespace yaml {<br>
>> -<br>
>> -template <><br>
>> -struct MappingTraits<clang::tooling::<wbr>IncludeStyle::IncludeCategory> {<br>
>> - static void mapping(IO &IO,<br>
>> - clang::tooling::IncludeStyle::<wbr>IncludeCategory &Category);<br>
>> -};<br>
>> -<br>
>> -template <><br>
>> -struct ScalarEnumerationTraits<<br>
>> - clang::tooling::IncludeStyle::<wbr>IncludeBlocksStyle> {<br>
>> - static void<br>
>> - enumeration(IO &IO, clang::tooling::IncludeStyle::<wbr>IncludeBlocksStyle &Value);<br>
>> -};<br>
>> -<br>
>> -} // namespace yaml<br>
>> -} // namespace llvm<br>
>> -<br>
>> -#endif // LLVM_CLANG_TOOLING_CORE_<wbr>INCLUDESTYLE_H<br>
>> <br>
>> Copied: cfe/trunk/include/clang/<wbr>Tooling/Inclusions/<wbr>HeaderIncludes.h (from r333865, cfe/trunk/include/clang/<wbr>Tooling/Core/HeaderIncludes.h)<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h?p2=cfe/trunk/include/clang/Tooling/Inclusions/HeaderIncludes.h&p1=cfe/trunk/include/clang/Tooling/Core/HeaderIncludes.h&r1=333865&r2=333874&rev=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Tooling/Inclusions/<wbr>HeaderIncludes.h?p2=cfe/trunk/<wbr>include/clang/Tooling/<wbr>Inclusions/HeaderIncludes.h&<wbr>p1=cfe/trunk/include/clang/<wbr>Tooling/Core/HeaderIncludes.h&<wbr>r1=333865&r2=333874&rev=<wbr>333874&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/include/clang/<wbr>Tooling/Core/HeaderIncludes.h (original)<br>
>> +++ cfe/trunk/include/clang/<wbr>Tooling/Inclusions/<wbr>HeaderIncludes.h Mon Jun 4 02:04:12 2018<br>
>> @@ -7,12 +7,12 @@<br>
>> //<br>
>> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
>> <br>
>> -#ifndef LLVM_CLANG_TOOLING_CORE_<wbr>HEADERINCLUDES_H<br>
>> -#define LLVM_CLANG_TOOLING_CORE_<wbr>HEADERINCLUDES_H<br>
>> +#ifndef LLVM_CLANG_TOOLING_INCLUSIONS_<wbr>HEADERINCLUDES_H<br>
>> +#define LLVM_CLANG_TOOLING_INCLUSIONS_<wbr>HEADERINCLUDES_H<br>
>> <br>
>> #include "clang/Basic/SourceManager.h"<br>
>> #include "clang/Tooling/Core/<wbr>Replacement.h"<br>
>> -#include "clang/Tooling/Core/<wbr>IncludeStyle.h"<br>
>> +#include "clang/Tooling/Inclusions/<wbr>IncludeStyle.h"<br>
>> #include "llvm/Support/Path.h"<br>
>> #include "llvm/Support/Regex.h"<br>
>> #include <unordered_map><br>
>> @@ -134,4 +134,4 @@ private:<br>
>> } // namespace tooling<br>
>> } // namespace clang<br>
>> <br>
>> -#endif // LLVM_CLANG_TOOLING_CORE_<wbr>HEADERINCLUDES_H<br>
>> +#endif // LLVM_CLANG_TOOLING_INCLUSIONS_<wbr>HEADERINCLUDES_H<br>
>> <br>
>> Copied: cfe/trunk/include/clang/<wbr>Tooling/Inclusions/<wbr>IncludeStyle.h (from r333865, cfe/trunk/include/clang/<wbr>Tooling/Core/IncludeStyle.h)<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h?p2=cfe/trunk/include/clang/Tooling/Inclusions/IncludeStyle.h&p1=cfe/trunk/include/clang/Tooling/Core/IncludeStyle.h&r1=333865&r2=333874&rev=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Tooling/Inclusions/<wbr>IncludeStyle.h?p2=cfe/trunk/<wbr>include/clang/Tooling/<wbr>Inclusions/IncludeStyle.h&p1=<wbr>cfe/trunk/include/clang/<wbr>Tooling/Core/IncludeStyle.h&<wbr>r1=333865&r2=333874&rev=<wbr>333874&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/include/clang/<wbr>Tooling/Core/IncludeStyle.h (original)<br>
>> +++ cfe/trunk/include/clang/<wbr>Tooling/Inclusions/<wbr>IncludeStyle.h Mon Jun 4 02:04:12 2018<br>
>> @@ -7,8 +7,8 @@<br>
>> //<br>
>> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
>> <br>
>> -#ifndef LLVM_CLANG_TOOLING_CORE_<wbr>INCLUDESTYLE_H<br>
>> -#define LLVM_CLANG_TOOLING_CORE_<wbr>INCLUDESTYLE_H<br>
>> +#ifndef LLVM_CLANG_TOOLING_INCLUSIONS_<wbr>INCLUDESTYLE_H<br>
>> +#define LLVM_CLANG_TOOLING_INCLUSIONS_<wbr>INCLUDESTYLE_H<br>
>> <br>
>> #include "llvm/Support/YAMLTraits.h"<br>
>> #include <string><br>
>> @@ -130,4 +130,4 @@ struct ScalarEnumerationTraits<<br>
>> } // namespace yaml<br>
>> } // namespace llvm<br>
>> <br>
>> -#endif // LLVM_CLANG_TOOLING_CORE_<wbr>INCLUDESTYLE_H<br>
>> +#endif // LLVM_CLANG_TOOLING_INCLUSIONS_<wbr>INCLUDESTYLE_H<br>
>> <br>
>> Modified: cfe/trunk/include/clang/<wbr>module.modulemap<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=333874&r1=333873&r2=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/module.modulemap?rev=<wbr>333874&r1=333873&r2=333874&<wbr>view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/include/clang/<wbr>module.modulemap (original)<br>
>> +++ cfe/trunk/include/clang/<wbr>module.modulemap Mon Jun 4 02:04:12 2018<br>
>> @@ -154,3 +154,8 @@ module Clang_ToolingCore {<br>
>> requires cplusplus<br>
>> umbrella "Tooling/Core" module * { export * }<br>
>> }<br>
>> +<br>
>> +module Clang_ToolingInclusions {<br>
>> + requires cplusplus<br>
>> + umbrella "Tooling/Inclusions" module * { export * }<br>
>> +}<br>
>> <br>
>> Modified: cfe/trunk/lib/Format/<wbr>CMakeLists.txt<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/CMakeLists.txt?rev=333874&r1=333873&r2=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Format/<wbr>CMakeLists.txt?rev=333874&r1=<wbr>333873&r2=333874&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/Format/<wbr>CMakeLists.txt (original)<br>
>> +++ cfe/trunk/lib/Format/<wbr>CMakeLists.txt Mon Jun 4 02:04:12 2018<br>
>> @@ -20,4 +20,5 @@ add_clang_library(clangFormat<br>
>> clangBasic<br>
>> clangLex<br>
>> clangToolingCore<br>
>> + clangToolingInclusions<br>
>> )<br>
>> <br>
>> Modified: cfe/trunk/lib/Format/Format.<wbr>cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=333874&r1=333873&r2=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Format/<wbr>Format.cpp?rev=333874&r1=<wbr>333873&r2=333874&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/Format/Format.<wbr>cpp (original)<br>
>> +++ cfe/trunk/lib/Format/Format.<wbr>cpp Mon Jun 4 02:04:12 2018<br>
>> @@ -31,7 +31,7 @@<br>
>> #include "clang/Basic/SourceManager.h"<br>
>> #include "clang/Basic/<wbr>VirtualFileSystem.h"<br>
>> #include "clang/Lex/Lexer.h"<br>
>> -#include "clang/Tooling/Core/<wbr>HeaderIncludes.h"<br>
>> +#include "clang/Tooling/Inclusions/<wbr>HeaderIncludes.h"<br>
>> #include "llvm/ADT/STLExtras.h"<br>
>> #include "llvm/ADT/StringRef.h"<br>
>> #include "llvm/Support/Allocator.h"<br>
>> <br>
>> Modified: cfe/trunk/lib/Tooling/<wbr>CMakeLists.txt<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CMakeLists.txt?rev=333874&r1=333873&r2=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Tooling/<wbr>CMakeLists.txt?rev=333874&r1=<wbr>333873&r2=333874&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/Tooling/<wbr>CMakeLists.txt (original)<br>
>> +++ cfe/trunk/lib/Tooling/<wbr>CMakeLists.txt Mon Jun 4 02:04:12 2018<br>
>> @@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS<br>
>> )<br>
>> <br>
>> add_subdirectory(Core)<br>
>> +add_subdirectory(Inclusions)<br>
>> add_subdirectory(Refactoring)<br>
>> add_subdirectory(ASTDiff)<br>
>> <br>
>> <br>
>> Modified: cfe/trunk/lib/Tooling/Core/<wbr>CMakeLists.txt<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/CMakeLists.txt?rev=333874&r1=333873&r2=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Tooling/<wbr>Core/CMakeLists.txt?rev=<wbr>333874&r1=333873&r2=333874&<wbr>view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/Tooling/Core/<wbr>CMakeLists.txt (original)<br>
>> +++ cfe/trunk/lib/Tooling/Core/<wbr>CMakeLists.txt Mon Jun 4 02:04:12 2018<br>
>> @@ -2,8 +2,6 @@ set(LLVM_LINK_COMPONENTS support)<br>
>> <br>
>> add_clang_library(<wbr>clangToolingCore<br>
>> Diagnostic.cpp<br>
>> - HeaderIncludes.cpp<br>
>> - IncludeStyle.cpp<br>
>> Lookup.cpp<br>
>> Replacement.cpp<br>
>> <br>
>> <br>
>> Removed: cfe/trunk/lib/Tooling/Core/<wbr>HeaderIncludes.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp?rev=333873&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Tooling/<wbr>Core/HeaderIncludes.cpp?rev=<wbr>333873&view=auto</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/Tooling/Core/<wbr>HeaderIncludes.cpp (original)<br>
>> +++ cfe/trunk/lib/Tooling/Core/<wbr>HeaderIncludes.cpp (removed)<br>
>> @@ -1,330 +0,0 @@<br>
>> -//===--- HeaderIncludes.cpp - Insert/Delete #includes --*- C++ -*----------===//<br>
>> -//<br>
>> -// The LLVM Compiler Infrastructure<br>
>> -//<br>
>> -// This file is distributed under the University of Illinois Open Source<br>
>> -// License. See LICENSE.TXT for details.<br>
>> -//<br>
>> -//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
>> -<br>
>> -#include "clang/Tooling/Core/<wbr>HeaderIncludes.h"<br>
>> -#include "clang/Basic/SourceManager.h"<br>
>> -#include "clang/Lex/Lexer.h"<br>
>> -<br>
>> -namespace clang {<br>
>> -namespace tooling {<br>
>> -namespace {<br>
>> -<br>
>> -LangOptions createLangOpts() {<br>
>> - LangOptions LangOpts;<br>
>> - LangOpts.CPlusPlus = 1;<br>
>> - LangOpts.CPlusPlus11 = 1;<br>
>> - LangOpts.CPlusPlus14 = 1;<br>
>> - LangOpts.LineComment = 1;<br>
>> - LangOpts.CXXOperatorNames = 1;<br>
>> - LangOpts.Bool = 1;<br>
>> - LangOpts.ObjC1 = 1;<br>
>> - LangOpts.ObjC2 = 1;<br>
>> - LangOpts.MicrosoftExt = 1; // To get kw___try, kw___finally.<br>
>> - LangOpts.DeclSpecKeyword = 1; // To get __declspec.<br>
>> - LangOpts.WChar = 1; // To get wchar_t<br>
>> - return LangOpts;<br>
>> -}<br>
>> -<br>
>> -// Returns the offset after skipping a sequence of tokens, matched by \p<br>
>> -// GetOffsetAfterSequence, from the start of the code.<br>
>> -// \p GetOffsetAfterSequence should be a function that matches a sequence of<br>
>> -// tokens and returns an offset after the sequence.<br>
>> -unsigned getOffsetAfterTokenSequence(<br>
>> - StringRef FileName, StringRef Code, const IncludeStyle &Style,<br>
>> - llvm::function_ref<unsigned(<wbr>const SourceManager &, Lexer &, Token &)><br>
>> - GetOffsetAfterSequence) {<br>
>> - SourceManagerForFile VirtualSM(FileName, Code);<br>
>> - SourceManager &SM = VirtualSM.get();<br>
>> - Lexer Lex(SM.getMainFileID(), SM.getBuffer(SM.getMainFileID(<wbr>)), SM,<br>
>> - createLangOpts());<br>
>> - Token Tok;<br>
>> - // Get the first token.<br>
>> - Lex.LexFromRawLexer(Tok);<br>
>> - return GetOffsetAfterSequence(SM, Lex, Tok);<br>
>> -}<br>
>> -<br>
>> -// Check if a sequence of tokens is like "#<Name> <raw_identifier>". If it is,<br>
>> -// \p Tok will be the token after this directive; otherwise, it can be any token<br>
>> -// after the given \p Tok (including \p Tok).<br>
>> -bool checkAndConsumeDirectiveWithNa<wbr>me(Lexer &Lex, StringRef Name, Token &Tok) {<br>
>> - bool Matched = Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) &&<br>
>> - Tok.is(tok::raw_identifier) &&<br>
>> - Tok.getRawIdentifier() == Name && !Lex.LexFromRawLexer(Tok) &&<br>
>> - Tok.is(tok::raw_identifier);<br>
>> - if (Matched)<br>
>> - Lex.LexFromRawLexer(Tok);<br>
>> - return Matched;<br>
>> -}<br>
>> -<br>
>> -void skipComments(Lexer &Lex, Token &Tok) {<br>
>> - while (Tok.is(tok::comment))<br>
>> - if (Lex.LexFromRawLexer(Tok))<br>
>> - return;<br>
>> -}<br>
>> -<br>
>> -// Returns the offset after header guard directives and any comments<br>
>> -// before/after header guards. If no header guard presents in the code, this<br>
>> -// will returns the offset after skipping all comments from the start of the<br>
>> -// code.<br>
>> -unsigned getOffsetAfterHeaderGuardsAndC<wbr>omments(StringRef FileName,<br>
>> - StringRef Code,<br>
>> - const IncludeStyle &Style) {<br>
>> - return getOffsetAfterTokenSequence(<br>
>> - FileName, Code, Style,<br>
>> - [](const SourceManager &SM, Lexer &Lex, Token Tok) {<br>
>> - skipComments(Lex, Tok);<br>
>> - unsigned InitialOffset = SM.getFileOffset(Tok.<wbr>getLocation());<br>
>> - if (<wbr>checkAndConsumeDirectiveWithNa<wbr>me(Lex, "ifndef", Tok)) {<br>
>> - skipComments(Lex, Tok);<br>
>> - if (<wbr>checkAndConsumeDirectiveWithNa<wbr>me(Lex, "define", Tok))<br>
>> - return SM.getFileOffset(Tok.<wbr>getLocation());<br>
>> - }<br>
>> - return InitialOffset;<br>
>> - });<br>
>> -}<br>
>> -<br>
>> -// Check if a sequence of tokens is like<br>
>> -// "#include ("header.h" | <header.h>)".<br>
>> -// If it is, \p Tok will be the token after this directive; otherwise, it can be<br>
>> -// any token after the given \p Tok (including \p Tok).<br>
>> -bool checkAndConsumeInclusiveDirect<wbr>ive(Lexer &Lex, Token &Tok) {<br>
>> - auto Matched = [&]() {<br>
>> - Lex.LexFromRawLexer(Tok);<br>
>> - return true;<br>
>> - };<br>
>> - if (Tok.is(tok::hash) && !Lex.LexFromRawLexer(Tok) &&<br>
>> - Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == "include") {<br>
>> - if (Lex.LexFromRawLexer(Tok))<br>
>> - return false;<br>
>> - if (Tok.is(tok::string_literal))<br>
>> - return Matched();<br>
>> - if (Tok.is(tok::less)) {<br>
>> - while (!Lex.LexFromRawLexer(Tok) && Tok.isNot(tok::greater)) {<br>
>> - }<br>
>> - if (Tok.is(tok::greater))<br>
>> - return Matched();<br>
>> - }<br>
>> - }<br>
>> - return false;<br>
>> -}<br>
>> -<br>
>> -// Returns the offset of the last #include directive after which a new<br>
>> -// #include can be inserted. This ignores #include's after the #include block(s)<br>
>> -// in the beginning of a file to avoid inserting headers into code sections<br>
>> -// where new #include's should not be added by default.<br>
>> -// These code sections include:<br>
>> -// - raw string literals (containing #include).<br>
>> -// - #if blocks.<br>
>> -// - Special #include's among declarations (e.g. functions).<br>
>> -//<br>
>> -// If no #include after which a new #include can be inserted, this returns the<br>
>> -// offset after skipping all comments from the start of the code.<br>
>> -// Inserting after an #include is not allowed if it comes after code that is not<br>
>> -// #include (e.g. pre-processing directive that is not #include, declarations).<br>
>> -unsigned getMaxHeaderInsertionOffset(<wbr>StringRef FileName, StringRef Code,<br>
>> - const IncludeStyle &Style) {<br>
>> - return getOffsetAfterTokenSequence(<br>
>> - FileName, Code, Style,<br>
>> - [](const SourceManager &SM, Lexer &Lex, Token Tok) {<br>
>> - skipComments(Lex, Tok);<br>
>> - unsigned MaxOffset = SM.getFileOffset(Tok.<wbr>getLocation());<br>
>> - while (<wbr>checkAndConsumeInclusiveDirect<wbr>ive(Lex, Tok))<br>
>> - MaxOffset = SM.getFileOffset(Tok.<wbr>getLocation());<br>
>> - return MaxOffset;<br>
>> - });<br>
>> -}<br>
>> -<br>
>> -inline StringRef trimInclude(StringRef IncludeName) {<br>
>> - return IncludeName.trim("\"<>");<br>
>> -}<br>
>> -<br>
>> -const char IncludeRegexPattern[] =<br>
>> - R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][<wbr>^">]*[">]))";<br>
>> -<br>
>> -} // anonymous namespace<br>
>> -<br>
>> -IncludeCategoryManager::<wbr>IncludeCategoryManager(const IncludeStyle &Style,<br>
>> - StringRef FileName)<br>
>> - : Style(Style), FileName(FileName) {<br>
>> - FileStem = llvm::sys::path::stem(<wbr>FileName);<br>
>> - for (const auto &Category : Style.IncludeCategories)<br>
>> - CategoryRegexs.emplace_back(<wbr>Category.Regex, llvm::Regex::IgnoreCase);<br>
>> - IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") ||<br>
>> - FileName.endswith(".cpp") || FileName.endswith(".c++") ||<br>
>> - FileName.endswith(".cxx") || FileName.endswith(".m") ||<br>
>> - FileName.endswith(".mm");<br>
>> -}<br>
>> -<br>
>> -int IncludeCategoryManager::<wbr>getIncludePriority(StringRef IncludeName,<br>
>> - bool CheckMainHeader) const {<br>
>> - int Ret = INT_MAX;<br>
>> - for (unsigned i = 0, e = CategoryRegexs.size(); i != e; ++i)<br>
>> - if (CategoryRegexs[i].match(<wbr>IncludeName)) {<br>
>> - Ret = Style.IncludeCategories[i].<wbr>Priority;<br>
>> - break;<br>
>> - }<br>
>> - if (CheckMainHeader && IsMainFile && Ret > 0 && isMainHeader(IncludeName))<br>
>> - Ret = 0;<br>
>> - return Ret;<br>
>> -}<br>
>> -<br>
>> -bool IncludeCategoryManager::<wbr>isMainHeader(StringRef IncludeName) const {<br>
>> - if (!IncludeName.startswith("\"")<wbr>)<br>
>> - return false;<br>
>> - StringRef HeaderStem =<br>
>> - llvm::sys::path::stem(<wbr>IncludeName.drop_front(1).<wbr>drop_back(1));<br>
>> - if (FileStem.startswith(<wbr>HeaderStem) ||<br>
>> - FileStem.startswith_lower(<wbr>HeaderStem)) {<br>
>> - llvm::Regex MainIncludeRegex((HeaderStem + Style.IncludeIsMainRegex).str(<wbr>),<br>
>> - llvm::Regex::IgnoreCase);<br>
>> - if (MainIncludeRegex.match(<wbr>FileStem))<br>
>> - return true;<br>
>> - }<br>
>> - return false;<br>
>> -}<br>
>> -<br>
>> -HeaderIncludes::<wbr>HeaderIncludes(StringRef FileName, StringRef Code,<br>
>> - const IncludeStyle &Style)<br>
>> - : FileName(FileName), Code(Code), FirstIncludeOffset(-1),<br>
>> - MinInsertOffset(<br>
>> - getOffsetAfterHeaderGuardsAndC<wbr>omments(FileName, Code, Style)),<br>
>> - MaxInsertOffset(<wbr>MinInsertOffset +<br>
>> - getMaxHeaderInsertionOffset(<br>
>> - FileName, Code.drop_front(<wbr>MinInsertOffset), Style)),<br>
>> - Categories(Style, FileName),<br>
>> - IncludeRegex(llvm::Regex(<wbr>IncludeRegexPattern)) {<br>
>> - // Add 0 for main header and INT_MAX for headers that are not in any<br>
>> - // category.<br>
>> - Priorities = {0, INT_MAX};<br>
>> - for (const auto &Category : Style.IncludeCategories)<br>
>> - Priorities.insert(Category.<wbr>Priority);<br>
>> - SmallVector<StringRef, 32> Lines;<br>
>> - Code.drop_front(<wbr>MinInsertOffset).split(Lines, "\n");<br>
>> -<br>
>> - unsigned Offset = MinInsertOffset;<br>
>> - unsigned NextLineOffset;<br>
>> - SmallVector<StringRef, 4> Matches;<br>
>> - for (auto Line : Lines) {<br>
>> - NextLineOffset = std::min(Code.size(), Offset + Line.size() + 1);<br>
>> - if (IncludeRegex.match(Line, &Matches)) {<br>
>> - // If this is the last line without trailing newline, we need to make<br>
>> - // sure we don't delete across the file boundary.<br>
>> - addExistingInclude(<br>
>> - Include(Matches[2],<br>
>> - tooling::Range(<br>
>> - Offset, std::min(Line.size() + 1, Code.size() - Offset))),<br>
>> - NextLineOffset);<br>
>> - }<br>
>> - Offset = NextLineOffset;<br>
>> - }<br>
>> -<br>
>> - // Populate CategoryEndOfssets:<br>
>> - // - Ensure that CategoryEndOffset[Highest] is always populated.<br>
>> - // - If CategoryEndOffset[Priority] isn't set, use the next higher value<br>
>> - // that is set, up to CategoryEndOffset[Highest].<br>
>> - auto Highest = Priorities.begin();<br>
>> - if (CategoryEndOffsets.find(*<wbr>Highest) == CategoryEndOffsets.end()) {<br>
>> - if (FirstIncludeOffset >= 0)<br>
>> - CategoryEndOffsets[*Highest] = FirstIncludeOffset;<br>
>> - else<br>
>> - CategoryEndOffsets[*Highest] = MinInsertOffset;<br>
>> - }<br>
>> - // By this point, CategoryEndOffset[Highest] is always set appropriately:<br>
>> - // - to an appropriate location before/after existing #includes, or<br>
>> - // - to right after the header guard, or<br>
>> - // - to the beginning of the file.<br>
>> - for (auto I = ++Priorities.begin(), E = Priorities.end(); I != E; ++I)<br>
>> - if (CategoryEndOffsets.find(*I) == CategoryEndOffsets.end())<br>
>> - CategoryEndOffsets[*I] = CategoryEndOffsets[*std::prev(<wbr>I)];<br>
>> -}<br>
>> -<br>
>> -// \p Offset: the start of the line following this include directive.<br>
>> -void HeaderIncludes::<wbr>addExistingInclude(Include IncludeToAdd,<br>
>> - unsigned NextLineOffset) {<br>
>> - auto Iter =<br>
>> - ExistingIncludes.try_emplace(<wbr>trimInclude(IncludeToAdd.Name)<wbr>).first;<br>
>> - Iter->second.push_back(std::<wbr>move(IncludeToAdd));<br>
>> - auto &CurInclude = Iter->second.back();<br>
>> - // The header name with quotes or angle brackets.<br>
>> - // Only record the offset of current #include if we can insert after it.<br>
>> - if (CurInclude.R.getOffset() <= MaxInsertOffset) {<br>
>> - int Priority = Categories.getIncludePriority(<br>
>> - CurInclude.Name, /*CheckMainHeader=*/<wbr>FirstIncludeOffset < 0);<br>
>> - CategoryEndOffsets[Priority] = NextLineOffset;<br>
>> - IncludesByPriority[Priority].<wbr>push_back(&CurInclude);<br>
>> - if (FirstIncludeOffset < 0)<br>
>> - FirstIncludeOffset = CurInclude.R.getOffset();<br>
>> - }<br>
>> -}<br>
>> -<br>
>> -llvm::Optional<tooling::<wbr>Replacement><br>
>> -HeaderIncludes::insert(llvm::<wbr>StringRef IncludeName, bool IsAngled) const {<br>
>> - assert(IncludeName == trimInclude(IncludeName));<br>
>> - // If a <header> ("header") already exists in code, "header" (<header>) with<br>
>> - // different quotation will still be inserted.<br>
>> - // FIXME: figure out if this is the best behavior.<br>
>> - auto It = ExistingIncludes.find(<wbr>IncludeName);<br>
>> - if (It != ExistingIncludes.end())<br>
>> - for (const auto &Inc : It->second)<br>
>> - if ((IsAngled && StringRef(Inc.Name).<wbr>startswith("<")) ||<br>
>> - (!IsAngled && StringRef(Inc.Name).<wbr>startswith("\"")))<br>
>> - return llvm::None;<br>
>> - std::string Quoted = IsAngled ? ("<" + IncludeName + ">").str()<br>
>> - : ("\"" + IncludeName + "\"").str();<br>
>> - StringRef QuotedName = Quoted;<br>
>> - int Priority = Categories.getIncludePriority(<br>
>> - QuotedName, /*CheckMainHeader=*/<wbr>FirstIncludeOffset < 0);<br>
>> - auto CatOffset = CategoryEndOffsets.find(<wbr>Priority);<br>
>> - assert(CatOffset != CategoryEndOffsets.end());<br>
>> - unsigned InsertOffset = CatOffset->second; // Fall back offset<br>
>> - auto Iter = IncludesByPriority.find(<wbr>Priority);<br>
>> - if (Iter != IncludesByPriority.end()) {<br>
>> - for (const auto *Inc : Iter->second) {<br>
>> - if (QuotedName < Inc->Name) {<br>
>> - InsertOffset = Inc->R.getOffset();<br>
>> - break;<br>
>> - }<br>
>> - }<br>
>> - }<br>
>> - assert(InsertOffset <= Code.size());<br>
>> - std::string NewInclude = ("#include " + QuotedName + "\n").str();<br>
>> - // When inserting headers at end of the code, also append '\n' to the code<br>
>> - // if it does not end with '\n'.<br>
>> - // FIXME: when inserting multiple #includes at the end of code, only one<br>
>> - // newline should be added.<br>
>> - if (InsertOffset == Code.size() && (!Code.empty() && Code.back() != '\n'))<br>
>> - NewInclude = "\n" + NewInclude;<br>
>> - return tooling::Replacement(FileName, InsertOffset, 0, NewInclude);<br>
>> -}<br>
>> -<br>
>> -tooling::Replacements HeaderIncludes::remove(llvm::<wbr>StringRef IncludeName,<br>
>> - bool IsAngled) const {<br>
>> - assert(IncludeName == trimInclude(IncludeName));<br>
>> - tooling::Replacements Result;<br>
>> - auto Iter = ExistingIncludes.find(<wbr>IncludeName);<br>
>> - if (Iter == ExistingIncludes.end())<br>
>> - return Result;<br>
>> - for (const auto &Inc : Iter->second) {<br>
>> - if ((IsAngled && StringRef(Inc.Name).<wbr>startswith("\"")) ||<br>
>> - (!IsAngled && StringRef(Inc.Name).<wbr>startswith("<")))<br>
>> - continue;<br>
>> - llvm::Error Err = Result.add(tooling::<wbr>Replacement(<br>
>> - FileName, Inc.R.getOffset(), Inc.R.getLength(), ""));<br>
>> - if (Err) {<br>
>> - auto ErrMsg = "Unexpected conflicts in #include deletions: " +<br>
>> - llvm::toString(std::move(Err))<wbr>;<br>
>> - llvm_unreachable(ErrMsg.c_str(<wbr>));<br>
>> - }<br>
>> - }<br>
>> - return Result;<br>
>> -}<br>
>> -<br>
>> -<br>
>> -} // namespace tooling<br>
>> -} // namespace clang<br>
>> <br>
>> Removed: cfe/trunk/lib/Tooling/Core/<wbr>IncludeStyle.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp?rev=333873&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Tooling/<wbr>Core/IncludeStyle.cpp?rev=<wbr>333873&view=auto</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/Tooling/Core/<wbr>IncludeStyle.cpp (original)<br>
>> +++ cfe/trunk/lib/Tooling/Core/<wbr>IncludeStyle.cpp (removed)<br>
>> @@ -1,32 +0,0 @@<br>
>> -//===--- IncludeStyle.cpp - Style of C++ #include directives -----*- C++-*-===//<br>
>> -//<br>
>> -// The LLVM Compiler Infrastructure<br>
>> -//<br>
>> -// This file is distributed under the University of Illinois Open Source<br>
>> -// License. See LICENSE.TXT for details.<br>
>> -//<br>
>> -//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
>> -<br>
>> -#include "clang/Tooling/Core/<wbr>IncludeStyle.h"<br>
>> -<br>
>> -<br>
>> -using clang::tooling::IncludeStyle;<br>
>> -<br>
>> -namespace llvm {<br>
>> -namespace yaml {<br>
>> -<br>
>> -void MappingTraits<IncludeStyle::<wbr>IncludeCategory>::mapping(<br>
>> - IO &IO, IncludeStyle::IncludeCategory &Category) {<br>
>> - IO.mapOptional("Regex", Category.Regex);<br>
>> - IO.mapOptional("Priority", Category.Priority);<br>
>> -}<br>
>> -<br>
>> -void ScalarEnumerationTraits<<wbr>IncludeStyle::<wbr>IncludeBlocksStyle>::<wbr>enumeration(<br>
>> - IO &IO, IncludeStyle::<wbr>IncludeBlocksStyle &Value) {<br>
>> - IO.enumCase(Value, "Preserve", IncludeStyle::IBS_Preserve);<br>
>> - IO.enumCase(Value, "Merge", IncludeStyle::IBS_Merge);<br>
>> - IO.enumCase(Value, "Regroup", IncludeStyle::IBS_Regroup);<br>
>> -}<br>
>> -<br>
>> -} // namespace yaml<br>
>> -} // namespace llvm<br>
>> <br>
>> Copied: cfe/trunk/lib/Tooling/<wbr>Inclusions/CMakeLists.txt (from r333865, cfe/trunk/lib/Tooling/Core/<wbr>CMakeLists.txt)<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt?p2=cfe/trunk/lib/Tooling/Inclusions/CMakeLists.txt&p1=cfe/trunk/lib/Tooling/Core/CMakeLists.txt&r1=333865&r2=333874&rev=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Tooling/<wbr>Inclusions/CMakeLists.txt?p2=<wbr>cfe/trunk/lib/Tooling/<wbr>Inclusions/CMakeLists.txt&p1=<wbr>cfe/trunk/lib/Tooling/Core/<wbr>CMakeLists.txt&r1=333865&r2=<wbr>333874&rev=333874&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/Tooling/Core/<wbr>CMakeLists.txt (original)<br>
>> +++ cfe/trunk/lib/Tooling/<wbr>Inclusions/CMakeLists.txt Mon Jun 4 02:04:12 2018<br>
>> @@ -1,15 +1,12 @@<br>
>> set(LLVM_LINK_COMPONENTS support)<br>
>> <br>
>> -add_clang_library(<wbr>clangToolingCore<br>
>> - Diagnostic.cpp<br>
>> +add_clang_library(<wbr>clangToolingInclusions<br>
>> HeaderIncludes.cpp<br>
>> IncludeStyle.cpp<br>
>> - Lookup.cpp<br>
>> - Replacement.cpp<br>
>> <br>
>> LINK_LIBS<br>
>> - clangAST<br>
>> clangBasic<br>
>> clangLex<br>
>> clangRewrite<br>
>> + clangToolingCore<br>
>> )<br>
>> <br>
>> Copied: cfe/trunk/lib/Tooling/<wbr>Inclusions/HeaderIncludes.cpp (from r333865, cfe/trunk/lib/Tooling/Core/<wbr>HeaderIncludes.cpp)<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp?p2=cfe/trunk/lib/Tooling/Inclusions/HeaderIncludes.cpp&p1=cfe/trunk/lib/Tooling/Core/HeaderIncludes.cpp&r1=333865&r2=333874&rev=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Tooling/<wbr>Inclusions/HeaderIncludes.cpp?<wbr>p2=cfe/trunk/lib/Tooling/<wbr>Inclusions/HeaderIncludes.cpp&<wbr>p1=cfe/trunk/lib/Tooling/Core/<wbr>HeaderIncludes.cpp&r1=333865&<wbr>r2=333874&rev=333874&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/Tooling/Core/<wbr>HeaderIncludes.cpp (original)<br>
>> +++ cfe/trunk/lib/Tooling/<wbr>Inclusions/HeaderIncludes.cpp Mon Jun 4 02:04:12 2018<br>
>> @@ -7,7 +7,7 @@<br>
>> //<br>
>> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
>> <br>
>> -#include "clang/Tooling/Core/<wbr>HeaderIncludes.h"<br>
>> +#include "clang/Tooling/Inclusions/<wbr>HeaderIncludes.h"<br>
>> #include "clang/Basic/SourceManager.h"<br>
>> #include "clang/Lex/Lexer.h"<br>
>> <br>
>> <br>
>> Copied: cfe/trunk/lib/Tooling/<wbr>Inclusions/IncludeStyle.cpp (from r333865, cfe/trunk/lib/Tooling/Core/<wbr>IncludeStyle.cpp)<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp?p2=cfe/trunk/lib/Tooling/Inclusions/IncludeStyle.cpp&p1=cfe/trunk/lib/Tooling/Core/IncludeStyle.cpp&r1=333865&r2=333874&rev=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Tooling/<wbr>Inclusions/IncludeStyle.cpp?<wbr>p2=cfe/trunk/lib/Tooling/<wbr>Inclusions/IncludeStyle.cpp&<wbr>p1=cfe/trunk/lib/Tooling/Core/<wbr>IncludeStyle.cpp&r1=333865&r2=<wbr>333874&rev=333874&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/lib/Tooling/Core/<wbr>IncludeStyle.cpp (original)<br>
>> +++ cfe/trunk/lib/Tooling/<wbr>Inclusions/IncludeStyle.cpp Mon Jun 4 02:04:12 2018<br>
>> @@ -7,8 +7,7 @@<br>
>> //<br>
>> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
>> <br>
>> -#include "clang/Tooling/Core/<wbr>IncludeStyle.h"<br>
>> -<br>
>> +#include "clang/Tooling/Inclusions/<wbr>IncludeStyle.h"<br>
>> <br>
>> using clang::tooling::IncludeStyle;<br>
>> <br>
>> <br>
>> Modified: cfe/trunk/unittests/Tooling/<wbr>HeaderIncludesTest.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/HeaderIncludesTest.cpp?rev=333874&r1=333873&r2=333874&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/unittests/<wbr>Tooling/HeaderIncludesTest.<wbr>cpp?rev=333874&r1=333873&r2=<wbr>333874&view=diff</a><br>
>> ==============================<wbr>==============================<wbr>==================<br>
>> --- cfe/trunk/unittests/Tooling/<wbr>HeaderIncludesTest.cpp (original)<br>
>> +++ cfe/trunk/unittests/Tooling/<wbr>HeaderIncludesTest.cpp Mon Jun 4 02:04:12 2018<br>
>> @@ -7,7 +7,7 @@<br>
>> //<br>
>> //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
>> <br>
>> -#include "clang/Tooling/Core/<wbr>HeaderIncludes.h"<br>
>> +#include "clang/Tooling/Inclusions/<wbr>HeaderIncludes.h"<br>
>> #include "../Tooling/ReplacementTest.h"<br>
>> #include "../Tooling/<wbr>RewriterTestContext.h"<br>
>> #include "clang/Format/Format.h"<br>
>> <br>
>> <br>
>> ______________________________<wbr>_________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
> ______________________________<wbr>_________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div>