blob: 3b3f447e256cb805c9b1d0d18b6e20b4bf9378cd [file] [log] [blame]
Zonr Changc383a502010-10-12 01:52:08 +08001/*
2 * Copyright 2010, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Stephen Hinese639eb52010-11-08 19:27:20 -080017#ifndef _FRAMEWORKS_COMPILE_SLANG_SLANG_PRAGMA_RECORDER_H_ // NOLINT
18#define _FRAMEWORKS_COMPILE_SLANG_SLANG_PRAGMA_RECORDER_H_
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070019
Shih-wei Liao462aefd2010-06-04 15:32:04 -070020#include <list>
21#include <string>
Stephen Hinese639eb52010-11-08 19:27:20 -080022#include <utility>
Shih-wei Liao462aefd2010-06-04 15:32:04 -070023
zonr6315f762010-10-05 15:35:14 +080024#include "clang/Lex/Pragma.h"
Shih-wei Liao462aefd2010-06-04 15:32:04 -070025
26namespace clang {
zonr6315f762010-10-05 15:35:14 +080027 class Token;
28 class Preprocessor;
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070029}
Shih-wei Liao462aefd2010-06-04 15:32:04 -070030
31namespace slang {
32
Shih-wei Liao462aefd2010-06-04 15:32:04 -070033typedef std::list< std::pair<std::string, std::string> > PragmaList;
34
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070035class PragmaRecorder : public clang::PragmaHandler {
36 private:
Stephen Hines3fd0a942011-01-18 12:27:39 -080037 PragmaList *mPragmas;
Shih-wei Liao462aefd2010-06-04 15:32:04 -070038
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070039 static bool GetPragmaNameFromToken(const clang::Token &Token,
40 std::string &PragmaName);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070041
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070042 static bool GetPragmaValueFromToken(const clang::Token &Token,
43 std::string &PragmaValue);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070044
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070045 public:
Stephen Hines3fd0a942011-01-18 12:27:39 -080046 explicit PragmaRecorder(PragmaList *Pragmas);
Shih-wei Liao462aefd2010-06-04 15:32:04 -070047
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070048 virtual void HandlePragma(clang::Preprocessor &PP,
Shih-wei Liaodf5bcce2011-02-28 18:39:23 -080049 clang::PragmaIntroducerKind Introducer,
Shih-wei Liao9ef2f782010-10-01 12:31:37 -070050 clang::Token &FirstToken);
51};
Stephen Hinese67239d2012-02-24 15:08:36 -080052} // namespace slang
Shih-wei Liao462aefd2010-06-04 15:32:04 -070053
Stephen Hinese639eb52010-11-08 19:27:20 -080054#endif // _FRAMEWORKS_COMPILE_SLANG_SLANG_PRAGMA_RECORDER_H_ NOLINT