From 635ffc9d026d28c788250e4b0c801d59c2599412 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 18 Oct 2017 05:21:17 +0000 Subject: [PATCH] [CMake] Use #cmakedefine01 for CLANG_ENABLE_(ARCMT|OBJC_REWRITER|STATIC_ANALYZER) It'd be better that they are #cmakedefine01 rather than #cmakedefine. (#if FOO rather than #if defined(FOO)) Then we can find missing #include "clang/Config/config.h" in the future. Differential Revision: https://reviews.llvm.org/D35541 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316061 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Config/config.h.cmake | 6 +++--- lib/Frontend/Rewrite/FrontendActions.cpp | 2 +- lib/Frontend/Rewrite/RewriteModernObjC.cpp | 2 +- lib/Frontend/Rewrite/RewriteObjC.cpp | 2 +- lib/FrontendTool/ExecuteCompilerInvocation.cpp | 14 +++++++------- tools/libclang/ARCMigrate.cpp | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake index 3ee7258b3b..10074aafd8 100644 --- a/include/clang/Config/config.h.cmake +++ b/include/clang/Config/config.h.cmake @@ -60,8 +60,8 @@ #cmakedefine01 ENABLE_X86_RELAX_RELOCATIONS /* Enable each functionality of modules */ -#cmakedefine CLANG_ENABLE_ARCMT -#cmakedefine CLANG_ENABLE_OBJC_REWRITER -#cmakedefine CLANG_ENABLE_STATIC_ANALYZER +#cmakedefine01 CLANG_ENABLE_ARCMT +#cmakedefine01 CLANG_ENABLE_OBJC_REWRITER +#cmakedefine01 CLANG_ENABLE_STATIC_ANALYZER #endif diff --git a/lib/Frontend/Rewrite/FrontendActions.cpp b/lib/Frontend/Rewrite/FrontendActions.cpp index 5efa6aeaf7..4d587048f6 100644 --- a/lib/Frontend/Rewrite/FrontendActions.cpp +++ b/lib/Frontend/Rewrite/FrontendActions.cpp @@ -154,7 +154,7 @@ bool FixItRecompile::BeginInvocation(CompilerInstance &CI) { return true; } -#ifdef CLANG_ENABLE_OBJC_REWRITER +#if CLANG_ENABLE_OBJC_REWRITER std::unique_ptr RewriteObjCAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { diff --git a/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/lib/Frontend/Rewrite/RewriteModernObjC.cpp index 21686b8c78..1954b24aed 100644 --- a/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -31,7 +31,7 @@ #include "llvm/Support/raw_ostream.h" #include -#ifdef CLANG_ENABLE_OBJC_REWRITER +#if CLANG_ENABLE_OBJC_REWRITER using namespace clang; using llvm::utostr; diff --git a/lib/Frontend/Rewrite/RewriteObjC.cpp b/lib/Frontend/Rewrite/RewriteObjC.cpp index e0d813df70..096b81bc3f 100644 --- a/lib/Frontend/Rewrite/RewriteObjC.cpp +++ b/lib/Frontend/Rewrite/RewriteObjC.cpp @@ -30,7 +30,7 @@ #include "llvm/Support/raw_ostream.h" #include -#ifdef CLANG_ENABLE_OBJC_REWRITER +#if CLANG_ENABLE_OBJC_REWRITER using namespace clang; using llvm::utostr; diff --git a/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp index f35769c965..4167e1fe20 100644 --- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -94,18 +94,18 @@ CreateFrontendBaseAction(CompilerInstance &CI) { case RewriteMacros: return llvm::make_unique(); case RewriteTest: return llvm::make_unique(); -#ifdef CLANG_ENABLE_OBJC_REWRITER +#if CLANG_ENABLE_OBJC_REWRITER case RewriteObjC: return llvm::make_unique(); #else case RewriteObjC: Action = "RewriteObjC"; break; #endif -#ifdef CLANG_ENABLE_ARCMT +#if CLANG_ENABLE_ARCMT case MigrateSource: return llvm::make_unique(); #else case MigrateSource: Action = "MigrateSource"; break; #endif -#ifdef CLANG_ENABLE_STATIC_ANALYZER +#if CLANG_ENABLE_STATIC_ANALYZER case RunAnalysis: return llvm::make_unique(); #else case RunAnalysis: Action = "RunAnalysis"; break; @@ -113,8 +113,8 @@ CreateFrontendBaseAction(CompilerInstance &CI) { case RunPreprocessorOnly: return llvm::make_unique(); } -#if !defined(CLANG_ENABLE_ARCMT) || !defined(CLANG_ENABLE_STATIC_ANALYZER) \ - || !defined(CLANG_ENABLE_OBJC_REWRITER) +#if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \ + || !CLANG_ENABLE_OBJC_REWRITER CI.getDiagnostics().Report(diag::err_fe_action_not_available) << Action; return 0; #else @@ -135,7 +135,7 @@ CreateFrontendAction(CompilerInstance &CI) { Act = llvm::make_unique(std::move(Act)); } -#ifdef CLANG_ENABLE_ARCMT +#if CLANG_ENABLE_ARCMT if (CI.getFrontendOpts().ProgramAction != frontend::MigrateSource && CI.getFrontendOpts().ProgramAction != frontend::GeneratePCH) { // Potentially wrap the base FE action in an ARC Migrate Tool action. @@ -228,7 +228,7 @@ bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) { llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get()); } -#ifdef CLANG_ENABLE_STATIC_ANALYZER +#if CLANG_ENABLE_STATIC_ANALYZER // Honor -analyzer-checker-help. // This should happen AFTER plugins have been loaded! if (Clang->getAnalyzerOpts()->ShowCheckerHelp) { diff --git a/tools/libclang/ARCMigrate.cpp b/tools/libclang/ARCMigrate.cpp index 0f2bd06db4..ed2ecdb29e 100644 --- a/tools/libclang/ARCMigrate.cpp +++ b/tools/libclang/ARCMigrate.cpp @@ -34,7 +34,7 @@ struct Remap { //===----------------------------------------------------------------------===// CXRemapping clang_getRemappings(const char *migrate_dir_path) { -#ifndef CLANG_ENABLE_ARCMT +#if !CLANG_ENABLE_ARCMT llvm::errs() << "error: feature not enabled in this build\n"; return nullptr; #else @@ -77,7 +77,7 @@ CXRemapping clang_getRemappings(const char *migrate_dir_path) { CXRemapping clang_getRemappingsFromFileList(const char **filePaths, unsigned numFiles) { -#ifndef CLANG_ENABLE_ARCMT +#if !CLANG_ENABLE_ARCMT llvm::errs() << "error: feature not enabled in this build\n"; return nullptr; #else -- 2.40.0