Author: rsmith Date: Tue Apr 18 16:55:37 2017 New Revision: 300611 URL: http://llvm.org/viewvc/llvm-project?rev=300611&view=rev Log: [modules-ts] Fold together -x c++ and -x c++-module at -cc1 level.
The driver needs to know whether it's building a module interface or implementation unit because it affects which outputs it produces and how it builds the command pipeline. But the frontend doesn't need to know and should not care: all it needs to know is what action it is being asked to perform on the input. (This is in preparation for permitting -emit-obj to be used on a module interface unit to produce object code without going via a "full" PCM file.) Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/Driver/modules-ts.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=300611&r1=300610&r2=300611&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Apr 18 16:55:37 2017 @@ -649,8 +649,24 @@ static void addDashXForInput(const ArgLi CmdArgs.push_back("-x"); if (Args.hasArg(options::OPT_rewrite_objc)) CmdArgs.push_back(types::getTypeName(types::TY_PP_ObjCXX)); - else - CmdArgs.push_back(types::getTypeName(Input.getType())); + else { + // Map the driver type to the frontend type. This is mostly an identity + // mapping, except that the distinction between module interface units + // and other source files does not exist at the frontend layer. + const char *ClangType; + switch (Input.getType()) { + case types::TY_CXXModule: + ClangType = "c++"; + break; + case types::TY_PP_CXXModule: + ClangType = "c++-cpp-output"; + break; + default: + ClangType = types::getTypeName(Input.getType()); + break; + } + CmdArgs.push_back(ClangType); + } } static void appendUserToPath(SmallVectorImpl<char> &Result) { Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=300611&r1=300610&r2=300611&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 18 16:55:37 2017 @@ -1353,13 +1353,11 @@ static InputKind ParseFrontendArgs(Front .Case("cl", IK_OpenCL) .Case("cuda", IK_CUDA) .Case("c++", IK_CXX) - .Case("c++-module", IK_CXX) .Case("objective-c", IK_ObjC) .Case("objective-c++", IK_ObjCXX) .Case("cpp-output", IK_PreprocessedC) .Case("assembler-with-cpp", IK_Asm) .Case("c++-cpp-output", IK_PreprocessedCXX) - .Case("c++-module-cpp-output", IK_PreprocessedCXX) .Case("cuda-cpp-output", IK_PreprocessedCuda) .Case("objective-c-cpp-output", IK_PreprocessedObjC) .Case("objc-cpp-output", IK_PreprocessedObjC) Modified: cfe/trunk/test/Driver/modules-ts.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/modules-ts.cpp?rev=300611&r1=300610&r2=300611&view=diff ============================================================================== --- cfe/trunk/test/Driver/modules-ts.cpp (original) +++ cfe/trunk/test/Driver/modules-ts.cpp Tue Apr 18 16:55:37 2017 @@ -4,7 +4,7 @@ // // CHECK-PRECOMPILE: -cc1 {{.*}} -emit-module-interface // CHECK-PRECOMPILE-SAME: -o {{.*}}.pcm -// CHECK-PRECOMPILE-SAME: -x c++-module +// CHECK-PRECOMPILE-SAME: -x c++ // CHECK-PRECOMPILE-SAME: modules-ts.cpp // Check compiling a .pcm file to a .o file. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits