From 324f918438715b4a0d024af5930628c1674f4fcd Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 19 Jan 2019 08:50:56 +0000 Subject: Update the file headers across all of the LLVM projects in the monorepo to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Tooling/FixIt.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/Tooling/FixIt.cpp') diff --git a/lib/Tooling/FixIt.cpp b/lib/Tooling/FixIt.cpp index 70942c5ac8..c828c18871 100644 --- a/lib/Tooling/FixIt.cpp +++ b/lib/Tooling/FixIt.cpp @@ -1,9 +1,8 @@ //===--- FixIt.cpp - FixIt Hint utilities -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// 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 // //===----------------------------------------------------------------------===// // -- cgit v1.2.3 From 855491fe71084bff2086803f7c3e1a6b6f34b4bf Mon Sep 17 00:00:00 2001 From: Yitzhak Mandelbaum Date: Wed, 13 Mar 2019 19:48:51 +0000 Subject: [LibTooling] Add retrieval of extended AST-node source to FixIt library Summary: Introduces variants of `getText` and `getSourceRange` that extract the source text of an AST node potentially with a trailing token. Some of the new functions manipulate `CharSourceRange`s, rather than `SourceRange`s, because they document and dynamically enforce their type. So, this revision also updates the corresponding existing FixIt functions to manipulate `CharSourceRange`s. This change is not strictly necessary, but seems like the correct choice, to keep the API self-consistent. This revision is the first in a series intended to improve the abstractions available to users for writing source-to-source transformations. A full discussion of the end goal can be found on the cfe-dev list with subject "[RFC] Easier source-to-source transformations with clang tooling". Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: kimgr, riccibruno, JonasToth, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58556 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356095 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Tooling/FixIt.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/Tooling/FixIt.cpp') diff --git a/lib/Tooling/FixIt.cpp b/lib/Tooling/FixIt.cpp index c828c18871..ca12a5642a 100644 --- a/lib/Tooling/FixIt.cpp +++ b/lib/Tooling/FixIt.cpp @@ -18,12 +18,20 @@ namespace tooling { namespace fixit { namespace internal { -StringRef getText(SourceRange Range, const ASTContext &Context) { - return Lexer::getSourceText(CharSourceRange::getTokenRange(Range), - Context.getSourceManager(), +StringRef getText(CharSourceRange Range, const ASTContext &Context) { + return Lexer::getSourceText(Range, Context.getSourceManager(), Context.getLangOpts()); } -} // end namespace internal + +CharSourceRange maybeExtendRange(CharSourceRange Range, tok::TokenKind Next, + ASTContext &Context) { + Optional Tok = Lexer::findNextToken( + Range.getEnd(), Context.getSourceManager(), Context.getLangOpts()); + if (!Tok || !Tok->is(Next)) + return Range; + return CharSourceRange::getTokenRange(Range.getBegin(), Tok->getLocation()); +} +} // namespace internal } // end namespace fixit } // end namespace tooling -- cgit v1.2.3 From a50eeb5fd909ddd67d37785b624fc3e14ed4c9c2 Mon Sep 17 00:00:00 2001 From: Yitzhak Mandelbaum Date: Fri, 5 Apr 2019 14:05:03 +0000 Subject: [LibTooling] Add "SourceCode" library for functions relating to source-code manipulation. Summary: Introduces a utility library in Refactoring/ to collect routines related to source-code manipulation. In this change, we move "extended-range" functions from the FixIt library (in clangTooling) to this new library. We need to use this functionality in Refactoring/ and cannot access it if it resides in Tooling/, because that would cause clangToolingRefactor to depend on clangTooling, which would be a circular dependency. Reviewers: ilya-biryukov, ioeric Reviewed By: ilya-biryukov Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60269 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357764 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Tooling/FixIt.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'lib/Tooling/FixIt.cpp') diff --git a/lib/Tooling/FixIt.cpp b/lib/Tooling/FixIt.cpp index ca12a5642a..76c92c5437 100644 --- a/lib/Tooling/FixIt.cpp +++ b/lib/Tooling/FixIt.cpp @@ -22,15 +22,6 @@ StringRef getText(CharSourceRange Range, const ASTContext &Context) { return Lexer::getSourceText(Range, Context.getSourceManager(), Context.getLangOpts()); } - -CharSourceRange maybeExtendRange(CharSourceRange Range, tok::TokenKind Next, - ASTContext &Context) { - Optional Tok = Lexer::findNextToken( - Range.getEnd(), Context.getSourceManager(), Context.getLangOpts()); - if (!Tok || !Tok->is(Next)) - return Range; - return CharSourceRange::getTokenRange(Range.getBegin(), Tok->getLocation()); -} } // namespace internal } // end namespace fixit -- cgit v1.2.3