compositeprimes created this revision. compositeprimes added reviewers: klimek, alexfh. Herald added a subscriber: cfe-commits.
The change infers whether a source file is Objective-C using LangOpts, and if it detects Objective-C, it uses "#import" instead of "#include" for all inserted imports. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D55545 Files: clang-tidy/utils/IncludeSorter.cpp Index: clang-tidy/utils/IncludeSorter.cpp =================================================================== --- clang-tidy/utils/IncludeSorter.cpp +++ clang-tidy/utils/IncludeSorter.cpp @@ -113,9 +113,10 @@ Optional<FixItHint> IncludeSorter::CreateIncludeInsertion(StringRef FileName, bool IsAngled) { + std::string IncludeDirective = LangOpts->ObjC ? "#import " : "#include "; std::string IncludeStmt = - IsAngled ? llvm::Twine("#include <" + FileName + ">\n").str() - : llvm::Twine("#include \"" + FileName + "\"\n").str(); + IsAngled ? llvm::Twine(IncludeDirective + "<" + FileName + ">\n").str() + : llvm::Twine(IncludeDirective + "\"" + FileName + "\"\n").str(); if (SourceLocations.empty()) { // If there are no includes in this file, add it in the first line. // FIXME: insert after the file comment or the header guard, if present.
Index: clang-tidy/utils/IncludeSorter.cpp =================================================================== --- clang-tidy/utils/IncludeSorter.cpp +++ clang-tidy/utils/IncludeSorter.cpp @@ -113,9 +113,10 @@ Optional<FixItHint> IncludeSorter::CreateIncludeInsertion(StringRef FileName, bool IsAngled) { + std::string IncludeDirective = LangOpts->ObjC ? "#import " : "#include "; std::string IncludeStmt = - IsAngled ? llvm::Twine("#include <" + FileName + ">\n").str() - : llvm::Twine("#include \"" + FileName + "\"\n").str(); + IsAngled ? llvm::Twine(IncludeDirective + "<" + FileName + ">\n").str() + : llvm::Twine(IncludeDirective + "\"" + FileName + "\"\n").str(); if (SourceLocations.empty()) { // If there are no includes in this file, add it in the first line. // FIXME: insert after the file comment or the header guard, if present.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits