From: Daniel Dunbar Date: Wed, 1 Apr 2009 05:09:09 +0000 (+0000) Subject: Pull clang-cc code for generating PTH files based on the input type. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b5b0da1580a5e4aca7605d31abf3c066838670c;p=clang Pull clang-cc code for generating PTH files based on the input type. - [pth] don't abuse -x to drive pth generation - Simpler, and fixes PR3915. Cleanup test cases for PTH: - Update to use -emit-pth - Removed PTH test of carbon.c and cocoa.mm; these didn't actually verify anything, and since PTH is token based the extra coverage (over cocoa.m) isn't particularly helpful. - Split PTH tests in cocoa.m to cocoa-pth.m, solely to increase available parallelism when running tests. Ted, could you update the PTH test cases (include-pth.c and cocoa-pth.m) to have some sort of positive check that the PTH is getting used? "# of PTH cache hits" or "tokens read from PTH cache" statistics would work great. :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68189 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Driver/preprocessor.c b/test/Driver/preprocessor.c new file mode 100644 index 0000000000..ec1f42f5ba --- /dev/null +++ b/test/Driver/preprocessor.c @@ -0,0 +1,6 @@ +// RUN: clang -E -x c-header %s > %t && +// RUN: grep 'B B' %t + +#define A B +A A + diff --git a/test/Preprocessor/include-pth.c b/test/Preprocessor/include-pth.c index 2bdc7dc874..2afc66a55b 100644 --- a/test/Preprocessor/include-pth.c +++ b/test/Preprocessor/include-pth.c @@ -1,3 +1,3 @@ -// RUN: clang-cc -x c-header %s -o %t && +// RUN: clang-cc -emit-pth %s -o %t && // RUN: clang-cc -include-pth %t %s -E | grep 'file_to_include' | count 2 #include "file_to_include.h" diff --git a/test/Sema/carbon.c b/test/Sema/carbon.c index edb4d9729b..983a000b2c 100644 --- a/test/Sema/carbon.c +++ b/test/Sema/carbon.c @@ -1,5 +1,4 @@ -// RUN: clang-cc %s -fsyntax-only -print-stats && -// RUN: clang-cc -x c-header -o %t %s && clang-cc -token-cache %t %s +// RUN: clang-cc %s -fsyntax-only -print-stats #ifdef __APPLE__ #include #endif diff --git a/test/SemaObjC/cocoa.m b/test/SemaObjC/cocoa.m index cba4481a5b..153c46e103 100644 --- a/test/SemaObjC/cocoa.m +++ b/test/SemaObjC/cocoa.m @@ -1,9 +1,5 @@ // RUN: clang-cc %s -print-stats && -// RUN: clang-cc %s -disable-free && -// RUN: clang-cc -x objective-c-header -o %t %s && -// RUN: clang-cc -token-cache %t %s && -// RUN: clang-cc -x objective-c-header -o %t %s && -// RUN: clang-cc -token-cache %t %s -E %s -o /dev/null +// RUN: clang-cc %s -disable-free #ifdef __APPLE__ #include #endif diff --git a/test/SemaObjCXX/cocoa.mm b/test/SemaObjCXX/cocoa.mm index 00b6d747c3..dd9684ce06 100644 --- a/test/SemaObjCXX/cocoa.mm +++ b/test/SemaObjCXX/cocoa.mm @@ -1,6 +1,4 @@ -// RUN: clang-cc %s -print-stats && -// RUN: clang-cc -x objective-c++-header -o %t %s && -// RUN: clang-cc -token-cache %t %s +// RUN: clang-cc %s -print-stats #ifdef __APPLE__ #include #endif diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index 58538067bc..6cfd168278 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -253,16 +253,12 @@ enum LangKind { langkind_c, langkind_c_cpp, langkind_asm_cpp, - langkind_c_pch, langkind_cxx, langkind_cxx_cpp, - langkind_cxx_pch, langkind_objc, langkind_objc_cpp, - langkind_objc_pch, langkind_objcxx, - langkind_objcxx_cpp, - langkind_objcxx_pch + langkind_objcxx_cpp }; static llvm::cl::opt @@ -282,14 +278,14 @@ BaseLang("x", llvm::cl::desc("Base language to compile"), "Preprocessed Objective C"), clEnumValN(langkind_objcxx_cpp, "objective-c++-cpp-output", "Preprocessed Objective C++"), - clEnumValN(langkind_c_pch, "c-header", - "Precompiled C header"), - clEnumValN(langkind_objc_pch, "objective-c-header", - "Precompiled Objective-C header"), - clEnumValN(langkind_cxx_pch, "c++-header", - "Precompiled C++ header"), - clEnumValN(langkind_objcxx_pch, "objective-c++-header", - "Precompiled Objective-C++ header"), + clEnumValN(langkind_c, "c-header", + "C header"), + clEnumValN(langkind_objc, "objective-c-header", + "Objective-C header"), + clEnumValN(langkind_cxx, "c++-header", + "C++ header"), + clEnumValN(langkind_objcxx, "objective-c++-header", + "Objective-C++ header"), clEnumValEnd)); static llvm::cl::opt @@ -358,32 +354,9 @@ static void InitializeObjCOptions(LangOptions &Options) { } -static bool InitializeLangOptions(LangOptions &Options, LangKind LK){ +static void InitializeLangOptions(LangOptions &Options, LangKind LK){ // FIXME: implement -fpreprocessed mode. bool NoPreprocess = false; - bool PCH = false; - - // Test for 'PCH'. - switch (LK) { - default: - break; - case langkind_c_pch: - LK = langkind_c; - PCH = true; - break; - case langkind_objc_pch: - LK = langkind_objc; - PCH = true; - break; - case langkind_cxx_pch: - LK = langkind_cxx; - PCH = true; - break; - case langkind_objcxx_pch: - LK = langkind_objcxx; - PCH = true; - break; - } switch (LK) { default: assert(0 && "Unknown language kind!"); @@ -416,8 +389,6 @@ static bool InitializeLangOptions(LangOptions &Options, LangKind LK){ Options.CPlusPlus = 1; break; } - - return PCH; } /// LangStds - Language standards we support. @@ -581,18 +552,14 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK, case langkind_c: case langkind_asm_cpp: case langkind_c_cpp: - case langkind_c_pch: case langkind_objc: case langkind_objc_cpp: - case langkind_objc_pch: LangStd = lang_gnu99; break; case langkind_cxx: case langkind_cxx_cpp: - case langkind_cxx_pch: case langkind_objcxx: case langkind_objcxx_cpp: - case langkind_objcxx_pch: LangStd = lang_gnucxx98; break; } @@ -1657,7 +1624,7 @@ int main(int argc, char **argv) { LangOptions LangInfo; InitializeBaseLanguage(); LangKind LK = GetLanguage(InFile); - bool PCH = InitializeLangOptions(LangInfo, LK); + InitializeLangOptions(LangInfo, LK); InitializeGCMode(LangInfo); InitializeLanguageStandard(LangInfo, LK, Target.get()); @@ -1688,7 +1655,7 @@ int main(int argc, char **argv) { Diags.setClient(TextDiagClient); // Process the source file. - ProcessInputFile(*PP, PPFactory, InFile, PCH ? GeneratePCH : ProgAction); + ProcessInputFile(*PP, PPFactory, InFile, ProgAction); HeaderInfo.ClearFileInfo(); }